Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / shared / lib / interfaces / EncryptionPreferences.ts
blob237d477d1c2b9fa62fe44e1dd7e7c5fc7ae9b0ba
1 import type { PublicKeyReference } from '@proton/crypto';
3 import type {
4     API_KEY_SOURCE,
5     CONTACT_MIME_TYPES,
6     CONTACT_PGP_SCHEMES,
7     KEY_FLAG,
8     MIME_TYPES,
9     PGP_SCHEMES,
10     RECIPIENT_TYPES,
11 } from '../constants';
12 import type { Address } from './Address';
13 import type { KeyTransparencyVerificationResult } from './KeyTransparency';
14 import type { MailSettings } from './MailSettings';
16 export interface PublicKeyWithPref {
17     publicKey: PublicKeyReference;
18     pref?: number;
21 export interface SelfSend {
22     address: Address;
23     publicKey?: PublicKeyReference;
24     canSend?: boolean;
27 export type MimeTypeVcard = MIME_TYPES.PLAINTEXT;
29 export interface ProcessedApiKey {
30     armoredKey: string;
31     flags: KEY_FLAG;
32     publicKey: PublicKeyReference;
33     source: API_KEY_SOURCE;
36 export interface ApiKeysConfig {
37     publicKeys: ProcessedApiKey[];
38     Code?: number;
39     RecipientType?: RECIPIENT_TYPES;
40     isCatchAll?: boolean;
41     /**
42      * Internal addresses with e2ee disabled are marked as having EXTERNAL recipient type.
43      * This flag allows distinguishing them from actual external users, for which E2EE should
44      * never be disabled, even for mail (since e.g. they might have WKD set up, or uploaded keys associated with them).
45      */
46     isInternalWithDisabledE2EEForMail?: boolean;
47     MIMEType?: MIME_TYPES;
48     Warnings?: string[];
49     Errors?: string[];
50     ktVerificationResult?: KeyTransparencyVerificationResult;
53 export interface PinnedKeysConfig {
54     pinnedKeys: PublicKeyReference[];
55     encryptToPinned?: boolean;
56     encryptToUntrusted?: boolean;
57     sign?: boolean;
58     scheme?: PGP_SCHEMES;
59     mimeType?: MimeTypeVcard;
60     error?: Error;
61     isContact: boolean;
62     isContactSignatureVerified?: boolean;
63     contactSignatureTimestamp?: Date;
66 export interface PublicKeyConfigs {
67     emailAddress: string;
68     apiKeysConfig: ApiKeysConfig;
69     pinnedKeysConfig: PinnedKeysConfig;
70     mailSettings: MailSettings;
73 export interface ContactPublicKeyModel {
74     emailAddress: string;
75     publicKeys: {
76         apiKeys: PublicKeyReference[];
77         pinnedKeys: PublicKeyReference[];
78         verifyingPinnedKeys: PublicKeyReference[]; // Subset of pinned keys not marked as compromised
79     };
80     encrypt?: boolean;
81     sign?: boolean;
82     mimeType: CONTACT_MIME_TYPES;
83     scheme: CONTACT_PGP_SCHEMES;
84     isInternalWithDisabledE2EEForMail: boolean; // Both `encrypt` and `isInternalWithDisabledE2EEForMail` might be true at this stage
85     trustedFingerprints: Set<string>;
86     obsoleteFingerprints: Set<string>; // Keys that are not allowed to encrypt, because they are marked as obsolete.
87     encryptionCapableFingerprints: Set<string>; // Keys that are capable of encryption (regardless of whether they are allowed to encrypt).
88     compromisedFingerprints: Set<string>; // Keys that are not allowed to encrypt nor sign, because they are marked as compromised
89     isPGPExternal: boolean;
90     isPGPInternal: boolean;
91     isPGPExternalWithExternallyFetchedKeys: boolean; // Keys from e.g. WKD or keys.openpgp.org (KOO)
92     isPGPExternalWithoutExternallyFetchedKeys: boolean;
93     pgpAddressDisabled: boolean;
94     isContact: boolean;
95     isContactSignatureVerified?: boolean;
96     contactSignatureTimestamp?: Date;
97     emailAddressWarnings?: string[];
98     emailAddressErrors?: string[];
99     ktVerificationResult?: KeyTransparencyVerificationResult;
102 export interface ContactPublicKeyModelWithApiKeySource extends ContactPublicKeyModel {
103     apiKeysSourceMap: Partial<{ [source in API_KEY_SOURCE]: Set<string> }>; // map source to fingerprints
106 export interface PublicKeyModel {
107     emailAddress: string;
108     publicKeys: {
109         apiKeys: PublicKeyReference[];
110         pinnedKeys: PublicKeyReference[];
111         verifyingPinnedKeys: PublicKeyReference[];
112     };
113     encrypt: boolean;
114     sign: boolean;
115     mimeType: CONTACT_MIME_TYPES;
116     scheme: PGP_SCHEMES;
117     isInternalWithDisabledE2EEForMail: boolean; // Both `encrypt` and `isInternalWithDisabledE2EEForMail` might be true at this stage
118     trustedFingerprints: Set<string>;
119     obsoleteFingerprints: Set<string>;
120     encryptionCapableFingerprints: Set<string>;
121     compromisedFingerprints: Set<string>;
122     isPGPExternal: boolean;
123     isPGPInternal: boolean;
124     isPGPExternalWithExternallyFetchedKeys: boolean; // Keys from e.g. WKD or keys.openpgp.org (KOO)
125     isPGPExternalWithoutExternallyFetchedKeys: boolean;
126     pgpAddressDisabled: boolean;
127     isContact: boolean;
128     isContactSignatureVerified?: boolean;
129     contactSignatureTimestamp?: Date;
130     emailAddressWarnings?: string[];
131     emailAddressErrors?: string[];
132     ktVerificationResult?: KeyTransparencyVerificationResult;