Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / components / containers / login / interface.tsx
blob4ecef0c638e318c06f119e97d233601a8a66ba70
1 import type { ProductParam } from '@proton/shared/lib/apps/product';
2 import type { AuthResponse, AuthVersion } from '@proton/shared/lib/authentication/interface';
3 import type { OfflineKey } from '@proton/shared/lib/authentication/offlineKey';
4 import type { APP_NAMES } from '@proton/shared/lib/constants';
5 import type {
6     Address,
7     Api,
8     KeyMigrationKTVerifier,
9     PreAuthKTVerifier,
10     VerifyOutboundPublicKeys,
11     Address as tsAddress,
12     KeySalt as tsKeySalt,
13     User as tsUser,
14 } from '@proton/shared/lib/interfaces';
15 import type { AddressGenerationSetup, ClaimableAddress, ParsedUnprivatizationData } from '@proton/shared/lib/keys';
16 import type { AuthDeviceOutput, DeviceData, DeviceSecretData, DeviceSecretUser } from '@proton/shared/lib/keys/device';
17 import type { UnprivatizationContextData } from '@proton/shared/lib/keys/unprivatization/helper';
19 export interface AddressGeneration {
20     externalEmailAddress: Address | undefined;
21     availableDomains: string[];
22     setup: AddressGenerationSetup;
23     claimableAddress: ClaimableAddress | undefined;
26 export enum AuthStep {
27     LOGIN,
28     TWO_FA,
29     UNLOCK,
30     NEW_PASSWORD,
31     SSO,
32     DONE,
35 export interface AuthTypes {
36     totp: boolean;
37     fido2: boolean;
38     unlock: boolean;
41 export enum SSOLoginCapabilites {
42     SETUP_BACKUP_PASSWORD,
43     ASK_ADMIN,
44     ENTER_BACKUP_PASSWORD,
45     NEW_BACKUP_PASSWORD,
46     OTHER_DEVICES,
49 export interface SSOSetupData {
50     type: 'setup';
51     deviceData: DeviceData;
52     unprivatizationContextData: UnprivatizationContextData;
53     parsedUnprivatizationData: ParsedUnprivatizationData;
54     organizationData: UnprivatizationContextData['organizationData'];
55     authDevices: AuthDeviceOutput[];
56     intent: {
57         capabilities: Set<SSOLoginCapabilites>;
58         step: SSOLoginCapabilites;
59     };
62 export interface SSOSetPasswordData {
63     type: 'set-password';
64     keyPassword: string;
65     authDevices: AuthDeviceOutput[];
66     deviceSecretData: DeviceSecretData;
67     intent: {
68         capabilities: Set<SSOLoginCapabilites>;
69         step: SSOLoginCapabilites;
70     };
73 export type SSOPollingSuccessCb = (deviceSecretUser: DeviceSecretUser) => void;
74 export type SSOPollingErrorCb = (error: any) => void;
75 export type SSOPolling = {
76     start: () => () => void;
77     addListener: (success: SSOPollingSuccessCb, error: SSOPollingErrorCb) => () => void;
80 export interface SSOUnlockData {
81     type: 'unlock';
82     deviceData: DeviceData;
83     authDevices: AuthDeviceOutput[];
84     address: Address;
85     organizationData: UnprivatizationContextData['organizationData'];
86     poll: SSOPolling;
87     intent: {
88         capabilities: Set<SSOLoginCapabilites>;
89         step: SSOLoginCapabilites;
90     };
93 export interface SSOInactiveData {
94     type: 'inactive';
95     deviceData: DeviceData;
96     authDevices: AuthDeviceOutput[];
97     address: Address;
98     organizationData: UnprivatizationContextData['organizationData'];
99     poll: SSOPolling;
100     intent: {
101         capabilities: Set<SSOLoginCapabilites>;
102         step: SSOLoginCapabilites;
103     };
106 export interface AuthCacheResult {
107     appName: APP_NAMES;
108     toApp: APP_NAMES | undefined;
109     productParam: ProductParam;
110     shouldSetup?: boolean;
111     authType: AuthType;
112     authVersion: AuthVersion;
113     authResponse: AuthResponse;
114     api: Api;
115     verifyOutboundPublicKeys: VerifyOutboundPublicKeys | null;
116     data: {
117         user?: tsUser;
118         salts?: tsKeySalt[];
119         addresses?: Address[];
120         ssoData?: SSOSetupData | SSOUnlockData | SSOInactiveData | SSOSetPasswordData;
121     };
122     authTypes: AuthTypes;
123     username: string;
124     persistent: boolean;
125     loginPassword: string;
126     ignoreUnlock: boolean;
127     addressGeneration?: AddressGeneration;
128     setupVPN: boolean;
129     preAuthKTVerifier: PreAuthKTVerifier;
130     keyMigrationKTVerifier: KeyMigrationKTVerifier;
133 export type AuthFlows = 'signup' | 'reset' | 'switch' | 'login' | 'reauth' | undefined;
135 export interface AppIntent {
136     app: APP_NAMES;
137     ref?: 'product-switch';
140 export interface AuthSession {
141     UID: string;
142     EventID?: string;
143     LocalID: number;
144     User: tsUser;
145     Addresses?: tsAddress[];
146     keyPassword?: string;
147     loginPassword?: string;
148     path?: string;
149     flow?: AuthFlows;
150     prompt?: 'login' | null;
151     appIntent?: AppIntent;
152     persistent: boolean;
153     trusted: boolean;
154     clientKey: string;
155     offlineKey: OfflineKey | undefined;
158 export type AuthActionResponse =
159     | {
160           to: AuthStep.DONE;
161           session: AuthSession;
162       }
163     | {
164           cache: AuthCacheResult;
165           to: Exclude<AuthStep, AuthStep.DONE>;
166       };
168 export enum AuthType {
169     SRP,
170     ExternalSSO,
173 export enum ExternalSSOFlow {
174     Sp,
175     Idp,
176     Redirect,