react-cookie-auth
Version:
Authentication library with HTTP-only cookies and Page Visibility API for handling sleep/wake cycles
43 lines (42 loc) • 1.45 kB
TypeScript
import { AuthLibConfig } from './types';
/**
* Default refresh token interval: 10 minutes
*/
export declare const DEFAULT_REFRESH_TIMEOUT: number;
/**
* Default maximum number of retry attempts for token refresh
*/
export declare const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
/**
* Default delay between retry attempts: 1 second
*/
export declare const DEFAULT_RETRY_DELAY = 1000;
/**
* Default authentication API endpoints
*/
export declare const DEFAULT_LOGIN_ENDPOINT = "/token/";
export declare const DEFAULT_REFRESH_TOKEN_ENDPOINT = "/token/refresh/";
export declare const DEFAULT_LOGOUT_ENDPOINT = "/token/invalidate/";
/**
* Default configuration for the authentication library
*/
export declare const DEFAULT_AUTH_CONFIG: Partial<AuthLibConfig>;
/**
* Random delay range for refresh token after visibility change (in ms)
*/
export declare const VISIBILITY_CHANGE_MIN_DELAY = 1000;
export declare const VISIBILITY_CHANGE_MAX_DELAY = 5000;
/**
* Helper function to get a random delay between min and max values
* Used to prevent refresh token storms when a device wakes up
*
* @returns Random delay in milliseconds
*/
export declare const getRandomDelay: () => number;
/**
* Helper function for creating a delay promise
*
* @param ms Number of milliseconds to delay
* @returns Promise that resolves after specified delay
*/
export declare const delay: (ms: number) => Promise<void>;