import { RefreshScheduler } from "./refresh-scheduler"; import { ApiTokenStore } from "./api-token-store"; import { ApiTokenInfo } from "../types/auth-token"; export declare const DEFAULT_DELAY_BUFFER_PERCENT = 0.95; export interface ApiTokenManager { release(): void; getTokenInfo: () => Promise; } /** * Create the standard [[ApiTokenManager]] interface that will manage all the lifecycle * of a token. * * @param fetchTokenInfo The async function that should be used to retrieve a fresh token. * @param onTokenRefresh The function to call when a token has been refreshed. * @param delayBuffer The percentage of time to use to schedule the next token refresh * (i.e. with a value of `0.9` and a token valid for 1000ms from now, * the next refresh would be scheduled to happen at `now + (0.9 * 1000)`) * @param apiTokenStore The API token store interface to retrieve token from and to save it back to. * @param refreshScheduler The scheduler interface that should be used to schedule upcoming refresh token * and check if a scheduled one already exist. * * @kind Factories */ export declare function createApiTokenManager(fetchTokenInfo: () => Promise, onTokenRefresh: (apiToken: string) => void, delayBuffer: number, apiTokenStore: ApiTokenStore, refreshScheduler: RefreshScheduler): ApiTokenManager; /** * Create the Noop [[ApiTokenManager]] interface that will manage all the lifecycle * of a token. * * @param token The hardwired token value * * @kind Factories */ export declare function createNoopApiTokenManager(token: string): ApiTokenManager; /** * Check wheter the received [[ApiTokenInfo]] parameter is expired or near its * expiration. */ export declare function isApiTokenExpired(tokenInfo: ApiTokenInfo): boolean;