Skip to content

OAuthStateStore

Defined in: state-store.ts:11

Storage for pending OAuth authorization state. Methods are sync-or-async so a shared store (e.g. Redis via @mantlejs/auth-redis) can be injected without an interface change.

cleanup(): void | Promise<void>

Defined in: state-store.ts:27

Prune expired entries. May be a no-op where the backend expires keys itself.

void | Promise<void>


consume(state): OAuthStateData | Promise<OAuthStateData | undefined> | undefined

Defined in: state-store.ts:25

Atomically read and remove a pending state entry — the callback handler’s single-use check. Must not be implementable as a separate get() followed by delete(): two concurrent callback requests for the same state (a double-fired network request, or a replayed callback URL) would otherwise both pass the pending-state check before either deletes it, letting both proceed to exchange the same authorization code. Implementations backed by a real datastore should use its native atomic fetch-and-delete (e.g. Redis GETDEL, which @mantlejs/auth-redis’s redisStateStore uses); the in-memory default here is atomic by construction since it never awaits between the read and the delete.

string

OAuthStateData | Promise<OAuthStateData | undefined> | undefined


delete(state): void | Promise<void>

Defined in: state-store.ts:14

string

void | Promise<void>


get(state): OAuthStateData | Promise<OAuthStateData | undefined> | undefined

Defined in: state-store.ts:13

string

OAuthStateData | Promise<OAuthStateData | undefined> | undefined


set(state, data): void | Promise<void>

Defined in: state-store.ts:12

string

Omit<OAuthStateData, "expiresAt">

void | Promise<void>