This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk / TokenStore

TokenStore ​

Where the SDK keeps the tokens. Implement it to use cookies, IndexedDB etc.

Methods ​

clear() ​

clear(): void

Removes the tokens.

Returns ​

void


get() ​

get(): Tokens | null

Current tokens or null without a session. Must be synchronous and cheap. If it throws, createEnginexClient and session.get() do not throw (the session stays as it was — anonymous at creation) and the error shows up as an EnginexError on the next request that needs the tokens.

Returns ​

Tokens | null


set() ​

set(tokens): void

Stores new tokens.

Parameters ​

tokens ​

Tokens

Returns ​

void


subscribe() ​

subscribe(listener): () => void

Notifies when the tokens change (including from another tab). Returns the cancel function.

Parameters ​

listener ​

() => void

Returns ​

() => void