Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / components / containers / resetPassword / interface.ts
blobc184b96a7a21e6a45fd61cdcb118aa8e55b9cc04
1 import type { ProductParam } from '@proton/shared/lib/apps/product';
2 import type { AuthResponse } from '@proton/shared/lib/authentication/interface';
3 import type { APP_NAMES } from '@proton/shared/lib/constants';
4 import type {
5     Address,
6     Api,
7     DecryptedKey,
8     KeyTransparencyActivation,
9     ResetSelfAudit,
10 } from '@proton/shared/lib/interfaces';
12 import type { AuthSession } from '../login/interface';
14 export enum STEPS {
15     LOADING,
16     REQUEST_RECOVERY_METHODS = 1,
17     NO_RECOVERY_METHODS,
18     FORGOT_RECOVERY_METHOD,
19     REQUEST_RESET_TOKEN,
20     VALIDATE_RESET_TOKEN,
21     NEW_PASSWORD,
22     ERROR,
23     DONE,
26 // Login is valid for external accounts
27 export type RecoveryMethod = 'email' | 'sms' | 'login' | 'mnemonic';
28 export type AccountType = 'internal' | 'external';
30 export interface ValidateResetTokenResponse {
31     Addresses: Address[];
32     ToMigrate: 0 | 1;
33     SupportPgpV6Keys: 0 | 1;
36 interface MnemonicData {
37     api: Api;
38     decryptedUserKeys: DecryptedKey[];
39     authResponse: AuthResponse;
42 export interface ResetCacheResult {
43     appName: APP_NAMES;
44     username: string;
45     persistent: boolean;
46     productParam: ProductParam;
47     Methods: RecoveryMethod[];
48     type: AccountType;
49     method?: RecoveryMethod;
50     value?: string;
51     token?: string;
52     resetResponse?: ValidateResetTokenResponse;
53     mnemonicData?: MnemonicData;
54     ktActivation: KeyTransparencyActivation;
55     setupVPN: boolean;
56     resetSelfAudit: ResetSelfAudit;
59 export type ResetActionResponse =
60     | {
61           to: STEPS.DONE;
62           session: AuthSession;
63       }
64     | {
65           to: STEPS.NO_RECOVERY_METHODS;
66           error?: string;
67       }
68     | {
69           cache: ResetCacheResult;
70           to: Exclude<STEPS, STEPS.DONE | STEPS.NO_RECOVERY_METHODS>;
71       };