/** * Types pour l'authentification Native SSO v1.0 * Architecture Frontend-First avec encryption directe * * @version 2.7.9 */ export type NativeAuthType = 'login_email' | 'login_phone' | 'login_access_otp' | 'register' | 'recovery_password'; export type AccountType = 'email' | 'phone-only'; export type RegistrationType = 'email' | 'phone'; export type NativeAuthStatus = 'pending_password' | 'pending_otp' | 'pending_registration' | 'pending_2fa' | 'needs_access' | 'completed' | 'expired' | 'failed'; export interface NativeCredentials { appKey: string; encryptedCredentials: string; } export interface NativeEncryptRequest { type: NativeAuthType; app_key: string; encrypted_credentials: string; email?: string; ccphone?: string; phone?: string; otp_code?: string; name?: string; town?: string; country?: string; registration_type?: RegistrationType; method?: 'email' | 'phone'; } export interface NativeConfigResponse { success: boolean; app_key: string; encrypted_credentials: string; debug?: boolean; credentials_ttl?: number; bypass?: boolean; } export interface NativeEncryptResponse { success: boolean; native_token: string; expires_in: number; message?: string; } export interface NativeInitResponse { success: boolean; message?: string; error_type?: 'email_not_found' | 'phone_not_found' | 'alias_disabled' | 'access_denied' | 'user_suspended' | 'invalid_token' | 'token_expired' | 'validation_error' | 'invalid_country_code' | string; process_token?: string; status?: NativeAuthStatus; expires_at?: string; needs_access?: boolean; callback_token?: string; otp_sent_to?: string; otp_expires_in?: number; otp_code_dev?: string; otp_method?: 'email' | 'sms'; disabled_type?: 'email' | 'phone'; alternative_method?: 'email' | 'phone' | null; alternative_email?: string; alternative_phone?: string; application?: { id: number; name: string; logo?: string; }; user?: { id: number; name: string; email?: string; image_url?: string; }; prompt?: { title: string; message: string; actions: ('grant_access' | 'cancel')[]; }; conflict?: { type: 'email' | 'phone'; masked_identifier: string; options: { can_login: boolean; can_recover_by_email: boolean; can_recover_by_sms: boolean; masked_email?: string; masked_phone?: string; }; }; } export interface NativeValidateResponse { success: boolean; message?: string; error_type?: 'invalid_password' | 'invalid_otp' | 'otp_expired' | 'max_attempts_exceeded' | 'session_expired' | 'invalid_token' | 'requires_2fa' | string; callback_token?: string; requires_2fa?: boolean; status?: NativeAuthStatus; needs_access?: boolean; process_token?: string; application?: { id: number; name: string; logo?: string; }; user?: { id: number; name: string; email?: string; image_url?: string; }; prompt?: { title: string; message: string; actions: string[]; }; } export interface NativeGrantAccessResponse { success: boolean; message?: string; error_type?: 'invalid_token' | 'access_exists' | string; callback_token?: string; status?: 'completed'; } export interface NativeResendOtpResponse { success: boolean; message?: string; error_type?: 'cooldown_active' | 'session_expired' | string; cooldown_remaining?: number; otp_sent_to?: string; otp_method?: 'email' | 'sms'; otp_expires_in?: number; otp_code_dev?: string; } export interface NativeUser { id?: number; reference: string; name: string; email?: string | null; phone?: string; ccphone?: string; image_url?: string; town?: string; country?: string; address?: string; auth_2fa?: boolean; alias_reference?: string; } export interface NativeExchangeResponse { success?: boolean; message?: string; error_type?: string; debug_error?: string; debug_file?: string; reference: string; alias_reference: string; iam_token: string; user_infos: UserInfos; expires_at?: string; refresh_expires_at?: string; } export interface NativeRefreshResponse { success?: boolean; message?: string; error_type?: string; reference?: string; alias_reference?: string; iam_token?: string; user_infos?: UserInfos; expires_at?: string; refresh_expires_at?: string; } export interface CheckTokenResponse { status?: string; success?: boolean; reference?: string; alias_reference?: string; iam_token?: string; user_infos?: UserInfos; expires_at?: string; refresh_expires_at?: string; } export interface NativeAuthState { credentialsLoaded: boolean; processToken: string | null; status: NativeAuthStatus | null; user: NativeUser | null; application: { id: number; name: string; logo?: string; } | null; prompt: { title: string; message: string; actions: string[]; } | null; alternativeMethod: { type: 'email' | 'phone'; value: string; } | null; conflict: { type: 'email' | 'phone'; maskedIdentifier: string; options: { canLogin: boolean; canRecoverByEmail: boolean; canRecoverBySms: boolean; maskedEmail?: string; maskedPhone?: string; }; } | null; loading: boolean; error: string | null; errorType: string | null; otpMethod?: 'email' | 'sms' | null; otpSentTo?: string | null; } export interface UserInfos { reference?: string; name: string; email: string | null; ccphone?: string; phone?: string; address?: string; town?: string; country?: string; image_url?: string; image?: string; auth_2fa?: boolean; alias_reference?: string; } export interface LinkPhoneRequest { app_key: string; secret_key: string; reference: string; ccphone: string; phone: string; } export interface LinkPhoneResponse { success: boolean; message: string; reference?: string; user_infos?: UserInfos; } export interface LinkEmailRequest { app_key: string; secret_key: string; reference: string; email: string; } export interface LinkEmailResponse { success: boolean; message: string; reference?: string; user_infos?: UserInfos; } export interface RefreshUserInfoSingleRequest { secret_key: string; alias_reference: string; } export interface RefreshUserInfoSingleResponse { success?: boolean; message?: string; reference?: string; alias_reference?: string; user_infos?: UserInfos; } export interface RefreshUserInfoBulkRequest { secret_key: string; alias_references: string[]; } export interface RefreshUserInfoBulkResponse { success?: boolean; message?: string; total_requested?: number; total_found?: number; total_errors?: number; data?: Array<{ reference: string; alias_reference: string; user_infos: UserInfos; }>; errors?: Array<{ alias_reference: string; error: string; }>; } export interface UpdateAvatarRequest { app_key: string; secret_key: string; alias_reference: string; avatar_url: string; } export interface UpdateAvatarResponse { success?: boolean; message?: string; reference?: string; alias_reference?: string; user_infos?: UserInfos; } export interface ResetAvatarRequest { app_key: string; secret_key: string; alias_reference: string; } export interface ResetAvatarResponse { success?: boolean; message?: string; reference?: string; alias_reference?: string; user_infos?: UserInfos; }