@teamhanko/hanko-frontend-sdk
Version:
A package for simplifying UI integration with the Hanko API. It is meant for use in browsers only.
39 lines (38 loc) • 1.04 kB
TypeScript
/**
* Represents the session state with expiration and last check timestamps.
*
* @category SDK
* @subcategory Internal
*/
export interface State {
expiration: number;
lastCheck: number;
}
/**
* Manages session state persistence using localStorage.
*
* @category SDK
* @subcategory Internal
*/
export declare class SessionState {
private readonly storageKey;
private readonly defaultState;
/**
* Creates an instance of SessionState.
*
* @param {string} storageKey - The key used to store session state in localStorage.
*/
constructor(storageKey: string);
/**
* Loads the current session state from localStorage.
*
* @returns {State} The parsed session state or a default state if not found.
*/
load(): State;
/**
* Saves the session state to localStorage.
*
* @param {State | null} session - The session state to save. If null, the default state is used.
*/
save(session: State | null): void;
}