/** * Session State Management for Mobile Deeplink Flow * * Manages session state across deeplink redirects using sessionStorage. * This is critical for the two-phase mobile authentication flow where * the page context is lost during the deeplink redirect. * * @module utils/session */ /** * Types of pending operations */ export type OperationType = 'enroll' | 'verify'; /** * Session state data structure */ export interface SessionState { /** * Type of operation (enrollment or verification) */ operation: OperationType; /** * Username (for enrollment) */ username?: string; /** * User ID (base64-encoded) */ userId?: string; /** * Domain/rpId */ domain: string; /** * Display name (for enrollment) */ displayName?: string; /** * Challenge (base64-encoded) */ challenge?: string; /** * Credential ID (base64-encoded, for verification) */ credentialId?: string; /** * Custom authentication options */ customOptions?: { checkLiveness?: boolean; checkAge?: boolean; checkAgeAboveThreshold?: boolean; checkGeoLocation?: boolean; ageThreshold?: number; }; /** * Verification mode */ verification?: 'none' | 'default' | { custom: { endpoint: string; apiKey: string; }; }; /** * Allowed credentials for authentication */ allowCredentials?: string[]; /** * Timeout value */ timeout?: number; /** * Timestamp when the state was saved */ timestamp: number; } /** * Saves pending operation state to sessionStorage * * This is called before redirecting to the mobile app via deeplink. * The state will be retrieved after the app redirects back. * * @param state - Session state to save * * @throws {Error} If sessionStorage is not available * * @example * ```typescript * savePendingOperation({ * operation: 'enroll', * username: 'john.doe', * domain: 'example.com', * timestamp: Date.now() * }); * ``` */ export declare function savePendingOperation(state: SessionState): void; /** * Retrieves pending operation state from sessionStorage * * This is called after the mobile app redirects back to the website. * Returns null if no state exists or if the state is stale. * * @returns The session state, or null if not found or stale * * @example * ```typescript * const state = getPendingOperation(); * if (state) { * console.log('Operation type:', state.operation); * console.log('Domain:', state.domain); * } * ``` */ export declare function getPendingOperation(): SessionState | null; /** * Clears pending operation state from sessionStorage * * This should be called after successfully completing the operation * or when cancelling/aborting. * * @example * ```typescript * // After successfully completing WebAuthn ceremony * clearPendingOperation(); * ``` */ export declare function clearPendingOperation(): void; /** * Checks if there is a pending operation * * @returns true if there is a valid pending operation * * @example * ```typescript * if (hasPendingOperation()) { * // Handle callback from mobile app * await sdk.handleDeeplinkCallback(); * } * ``` */ export declare function hasPendingOperation(): boolean; /** * Gets the age of the current pending operation in milliseconds * * @returns Age in milliseconds, or null if no pending operation * * @example * ```typescript * const age = getPendingOperationAge(); * if (age && age > 60000) { * console.log('Operation is over 1 minute old'); * } * ``` */ export declare function getPendingOperationAge(): number | null; //# sourceMappingURL=session.d.ts.map