/** * Hook d'authentification Native SSO v1.0 * Architecture Frontend-First avec appels directs à l'IAM * * @version 2.7.9 */ import { type NativeStorageAdapter } from '../services/api'; import type { NativeAuthStatus, NativeExchangeResponse, AccountType, NativeUser } from '../types/native'; export interface UseNativeAuthOptions { /** URL du Backend SaaS */ saasApiUrl: string; /** URL du Backend IAM */ iamApiUrl: string; /** Charger les credentials automatiquement au montage */ autoLoadCredentials?: boolean; /** Type de compte par défaut à persister (défaut: 'user') */ defaultAccountType?: 'user' | 'client'; /** Préfixe local utilisé pour sélectionner les credentials côté SaaS */ configPrefix?: string; /** Stockage injecté pour les apps natives / Capacitor */ storage?: NativeStorageAdapter; } export declare function useNativeAuth(options: UseNativeAuthOptions): { 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; isAuthenticated: boolean; /** Debug réactif — mis à jour après loadCredentials */ isDebug: boolean; accountType: AccountType; isPhoneOnly: boolean; otpMethod: "email" | "sms" | null | undefined; otpSentTo: string | null | undefined; loadCredentials: () => Promise<{ success: boolean; error_type?: undefined; } | { success: boolean; error_type: string; }>; loginWithEmail: (email: string) => Promise<{ success: boolean; status: string; callback_token: string; error_type?: undefined; } | { success: boolean; status: string; callback_token?: undefined; error_type?: undefined; } | { success: boolean; status: NativeAuthStatus | undefined; callback_token?: undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; status?: undefined; callback_token?: undefined; }>; loginWithPhone: (ccphone: string, phone: string) => Promise<{ success: boolean; status: string; callback_token: string; error_type?: undefined; } | { success: boolean; status: string; callback_token?: undefined; error_type?: undefined; } | { success: boolean; status: NativeAuthStatus | undefined; callback_token?: undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; status?: undefined; callback_token?: undefined; }>; loginWithAccessOtp: (otpCode: string) => Promise<{ success: boolean; status: string; callback_token: string; error_type?: undefined; } | { success: boolean; status: string; callback_token?: undefined; error_type?: undefined; } | { success: boolean; status: NativeAuthStatus | undefined; callback_token?: undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; status?: undefined; callback_token?: undefined; }>; submitPassword: (password: string) => Promise<{ success: boolean; error: string; user?: undefined; callback_token?: undefined; requires_2fa?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; user: { reference: string; alias_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; }; callback_token: string; error?: undefined; requires_2fa?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; requires_2fa: boolean; error?: undefined; user?: undefined; callback_token?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; user: NativeUser; callback_token: string; error?: undefined; requires_2fa?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; status: string; error?: undefined; user?: undefined; callback_token?: undefined; requires_2fa?: undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; error?: undefined; user?: undefined; callback_token?: undefined; requires_2fa?: undefined; status?: undefined; }>; submitOtp: (otpCode: string) => Promise<{ success: boolean; error: string; user?: undefined; callback_token?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; user: { reference: string; alias_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; }; callback_token: string; error?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; status: string; error?: undefined; user?: undefined; callback_token?: undefined; error_type?: undefined; } | { success: boolean; user: NativeUser; callback_token: string; error?: undefined; status?: undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; error?: undefined; user?: undefined; callback_token?: undefined; status?: undefined; }>; submitTotp: (totpCode: string) => Promise<{ success: boolean; error: string; user?: undefined; error_type?: undefined; } | { success: boolean; user: { reference: string; alias_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; }; error?: undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; error?: undefined; user?: undefined; }>; grantAccess: () => Promise<{ success: boolean; error: string; user?: undefined; callback_token?: undefined; error_type?: undefined; } | { success: boolean; user: { reference: string; alias_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; }; callback_token: string; error?: undefined; error_type?: undefined; } | { success: boolean; error?: undefined; user?: undefined; callback_token?: undefined; error_type?: undefined; } | { success: boolean; error_type: string; error?: undefined; user?: undefined; callback_token?: undefined; }>; resendOtp: () => Promise<{ success: boolean; error: string; cooldown?: undefined; message?: undefined; otp_code_dev?: undefined; otp_method?: undefined; otp_sent_to?: undefined; } | { success: boolean; cooldown: number | undefined; message: string | undefined; otp_code_dev: string | undefined; otp_method: "email" | "sms" | undefined; otp_sent_to: string | undefined; error?: undefined; } | { success: boolean; error?: undefined; cooldown?: undefined; message?: undefined; otp_code_dev?: undefined; otp_method?: undefined; otp_sent_to?: undefined; }>; setSession: (data: NativeExchangeResponse) => void; logout: () => Promise; reset: () => void; clearError: () => void; register: (data: { name: string; email?: string; ccphone: string; phone: string; town?: string; country?: string; }) => Promise<{ success: boolean; status: NativeAuthStatus | undefined; error_type?: undefined; } | { success: boolean; error_type: string | undefined; status?: undefined; }>; setAccountType: import("react").Dispatch>; }; export default useNativeAuth;