/** * Hook de vérification périodique du token Sanctum (Auth Check) * * Le package consulte l'endpoint POST /api/sso/check-token du SaaS * pour vérifier si l'utilisateur est toujours connecté. * * - Premier check 60s après login * - Checks suivants toutes les 2 min * - Si status === 'connected' → met à jour user_infos via le storage du package * - Si 401 → révoque l'IAM (POST /sso/disconnect) + nettoie le frontend * - Ne déconnecte PAS si offline ou serveur inaccessible * * @version 2.7.9 */ import type { UserInfos } from '../types/native'; export interface UseTokenHealthCheckOptions { /** Whether to enable health checks (true when authenticated) */ enabled: boolean; /** SaaS API base URL */ saasApiUrl: string; /** IAM API base URL (for revocation on 401) */ iamApiUrl: string; /** Called when the backend explicitly invalidates the token (401) */ onTokenInvalid: () => void; /** * Optional handler for 401. If provided, it can attempt a refresh and decide * whether the session was recovered. * * Return values: * - 'recovered': session is valid again (do NOT call onTokenInvalid) * - 'invalid': token is explicitly invalid (call onTokenInvalid) * - 'noop': fall back to default behavior */ onUnauthorized?: () => Promise<'recovered' | 'invalid' | 'noop'>; /** Called when fresh user_infos are received */ onUserUpdated?: (userInfos: UserInfos) => void; /** Debug mode */ debug?: boolean; } export declare function useTokenHealthCheck(options: UseTokenHealthCheckOptions): void; export default useTokenHealthCheck;