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';
8 KeyMigrationKTVerifier,
10 VerifyOutboundPublicKeys,
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 {
35 export interface AuthTypes {
41 export enum SSOLoginCapabilites {
42 SETUP_BACKUP_PASSWORD,
44 ENTER_BACKUP_PASSWORD,
49 export interface SSOSetupData {
51 deviceData: DeviceData;
52 unprivatizationContextData: UnprivatizationContextData;
53 parsedUnprivatizationData: ParsedUnprivatizationData;
54 organizationData: UnprivatizationContextData['organizationData'];
55 authDevices: AuthDeviceOutput[];
57 capabilities: Set<SSOLoginCapabilites>;
58 step: SSOLoginCapabilites;
62 export interface SSOSetPasswordData {
65 authDevices: AuthDeviceOutput[];
66 deviceSecretData: DeviceSecretData;
68 capabilities: Set<SSOLoginCapabilites>;
69 step: SSOLoginCapabilites;
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 {
82 deviceData: DeviceData;
83 authDevices: AuthDeviceOutput[];
85 organizationData: UnprivatizationContextData['organizationData'];
88 capabilities: Set<SSOLoginCapabilites>;
89 step: SSOLoginCapabilites;
93 export interface SSOInactiveData {
95 deviceData: DeviceData;
96 authDevices: AuthDeviceOutput[];
98 organizationData: UnprivatizationContextData['organizationData'];
101 capabilities: Set<SSOLoginCapabilites>;
102 step: SSOLoginCapabilites;
106 export interface AuthCacheResult {
108 toApp: APP_NAMES | undefined;
109 productParam: ProductParam;
110 shouldSetup?: boolean;
112 authVersion: AuthVersion;
113 authResponse: AuthResponse;
115 verifyOutboundPublicKeys: VerifyOutboundPublicKeys | null;
119 addresses?: Address[];
120 ssoData?: SSOSetupData | SSOUnlockData | SSOInactiveData | SSOSetPasswordData;
122 authTypes: AuthTypes;
125 loginPassword: string;
126 ignoreUnlock: boolean;
127 addressGeneration?: AddressGeneration;
129 preAuthKTVerifier: PreAuthKTVerifier;
130 keyMigrationKTVerifier: KeyMigrationKTVerifier;
133 export type AuthFlows = 'signup' | 'reset' | 'switch' | 'login' | 'reauth' | undefined;
135 export interface AppIntent {
137 ref?: 'product-switch';
140 export interface AuthSession {
145 Addresses?: tsAddress[];
146 keyPassword?: string;
147 loginPassword?: string;
150 prompt?: 'login' | null;
151 appIntent?: AppIntent;
155 offlineKey: OfflineKey | undefined;
158 export type AuthActionResponse =
161 session: AuthSession;
164 cache: AuthCacheResult;
165 to: Exclude<AuthStep, AuthStep.DONE>;
168 export enum AuthType {
173 export enum ExternalSSOFlow {