Skip to content

WorkerTokenCache

Defined in: packages/client/src/worker/token-cache.ts:9

getToken: () => Promise<string | undefined>

Defined in: packages/client/src/worker/token-cache.ts:15

Resolve the access token for a shape/flush request. Returns the cached token when it is comfortably ahead of expiry; otherwise broadcasts ONE pull (deduped across concurrent callers) and resolves when a tab answers. Falls back to the (stale) cached token if a pull yields nothing.

Promise<string | undefined>


push: (token) => void

Defined in: packages/client/src/worker/token-cache.ts:17

The tab pushed a fresh token (auth state change or the initial attach) — cache it and satisfy any pull.

AuthTokenSnapshot | null

void


pushIfFresher: (token) => void

Defined in: packages/client/src/worker/token-cache.ts:24

Seed the cache from a LATER attach’s token, but only if it is strictly fresher than what is cached (ADR-0032 FIX 5). Attach seeding must never CLOBBER a fresher cached token with an older/null one — only the explicit push path (the tab as auth owner saying “this is current”) may overwrite unconditionally, including null on logout.

AuthTokenSnapshot | null

void


respond: (requestId, token) => void

Defined in: packages/client/src/worker/token-cache.ts:26

A tab answered a pull-request. First matching answer wins; later duplicates are ignored.

string

AuthTokenSnapshot | null

void