UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

73 lines 2.18 kB
import { XcapJsonResult } from './index'; export declare const ACCESS_TOKEN_RESULT_KEY = "__s"; /** Session storage key for access token */ export declare const ACCESS_TOKEN_SESSION_STORAGE_KEY = "stackend-at"; /** Local storage key for extra data */ export declare const PERSISTENT_DATA_LOCAL_STORAGE_KEY = "stackend-at"; export declare const ACCESS_TOKEN_PATH_SUFFIX = ";s="; export interface PersistentData { [name: string]: any; } /** Access token */ export interface AccessToken { id: string; /** Creation date */ created: number; /** Life time in milli seconds */ ttl: number; /** additional data */ data?: PersistentData; } /** * If an access token is received, add it to localStorage * @param result */ export declare function handleAccessToken(result: XcapJsonResult): void; /** * Set the access token. If null or undefined, remove it. * @param at */ export declare function setAccessToken(at: AccessToken | null | undefined): void; /** * Append the access token (if still valid) to the path * @param path */ export declare function appendAccessToken(path: string): string; /** * Get the access token from local storage. */ export declare function getAccessToken(): AccessToken | undefined; /** * Get the access token id */ export declare function getAccessTokenValue(): string | undefined; /** * Clear the access token */ export declare function clearAccessToken(): void; /** * Get the persistent data * @param key, optional key. Will get a single item */ export declare function getPersistentData(key?: string): PersistentData; /** * Update persistent data * @param pd */ export declare function updatePersistentData(pd: PersistentData): PersistentData; /** * Remove an item from the persistent data * @param key */ export declare function removePersistentData(key: string): PersistentData | undefined; /** * Set an item in the persistent storage * @param key * @param value */ export declare function setPersistentData(key: string, value: any): PersistentData | undefined; /** * Clear all persistent data */ export declare function clearPersistentData(): void; //# sourceMappingURL=AccessToken.d.ts.map