import { RefreshTokenResult, RefreshType } from '../types'; /** * This interfaces provides the contract that an session management utility must * satisfiy in order to work with this SDK, please vist the example provided in the * README, to understand how this works. */ type Awaitable = T | Promise; type StoreListener = () => void | Promise; export declare enum StorageKeys { accessToken = "accessToken", idToken = "idToken", refreshToken = "refreshToken", state = "state", nonce = "nonce", codeVerifier = "codeVerifier", stepUpAcr = "stepUpAcr", stepUpMaxAge = "stepUpMaxAge" } export declare enum TimeoutActivityType { preWarning = "preWarning", timeout = "timeout" } export type TimeoutTokenData = { accessToken: string | null; idToken: string | null; refreshToken: string | null; }; export type StorageSettingsType = { keyPrefix: string; maxLength: number; useInsecureForRefreshToken: boolean; activityTimeoutMinutes?: number; /** * Pre-warning in minutes. MUST be less than activityTimeoutMinutes when set. */ activityTimeoutPreWarningMinutes?: number; onActivityTimeout?: (timeoutType: TimeoutActivityType, tokens?: TimeoutTokenData) => void | Promise; /** * Custom token refresh. Invoked while the token session lock is held so a * slower refresh cannot overwrite a newer session. * * Must not call `refreshToken`, `exchangeAuthCode`, or any other operation * that acquires the token session lock. The lock is not reentrant, and a * nested call is rejected instead of waiting. */ onRefreshHandler?: (refreshType: RefreshType) => Promise; }; export declare abstract class SessionBase implements SessionManager { abstract asyncStore: boolean; private listeners; private notificationScheduled; abstract getSessionItem(itemKey: V | StorageKeys): Awaitable; abstract setSessionItem(itemKey: V | StorageKeys, itemValue: T): Awaitable; abstract removeSessionItem(itemKey: V | StorageKeys): Awaitable; abstract destroySession(): Awaitable; notifyListeners(): void; private scheduleNotification; subscribe(listener: StoreListener): () => void; setItems(items: Partial>): Promise; getItems(...items: V[]): Promise>>; removeItems(...items: V[]): Promise; } export interface SessionManager { asyncStore: boolean; /** * * Gets the item for the provided key from the storage. * @param itemKey * @returns */ getSessionItem: (itemKey: V | StorageKeys) => Awaitable; /** * * Sets the provided key-value store to the storage. * @param itemKey * @param itemValue */ setSessionItem: (itemKey: V | StorageKeys, itemValue: T) => Awaitable; /** * * Removes the item for the provided key from the storage. * @param itemKey */ removeSessionItem: (itemKey: V | StorageKeys) => Awaitable; /** * * Destroys the session */ destroySession: () => Awaitable; /** * Sets multiple items simultaneously. * @param {Record} items - Object containing key-value pairs to store * @returns {Promise} */ setItems(items: Partial>): Awaitable; /** * Removes multiple items simultaneously. * @param items */ removeItems(...items: V[]): Awaitable; /** * Gets multiple items simultaneously. * @param items */ getItems(...items: V[]): Awaitable>>; /** * Subscribes to store changes. * @param listener - Function to call when store changes * @returns Unsubscribe function */ subscribe(listener: StoreListener): () => void; /** * Notifies listeners of store changes. */ notifyListeners(): void; } export {};