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.
Methods
Section titled “Methods”cleanup()
Section titled “cleanup()”cleanup():
void|Promise<void>
Defined in: state-store.ts:27
Prune expired entries. May be a no-op where the backend expires keys itself.
Returns
Section titled “Returns”void | Promise<void>
consume()
Section titled “consume()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”OAuthStateData | Promise<OAuthStateData | undefined> | undefined
delete()
Section titled “delete()”delete(
state):void|Promise<void>
Defined in: state-store.ts:14
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void | Promise<void>
get(
state):OAuthStateData|Promise<OAuthStateData|undefined> |undefined
Defined in: state-store.ts:13
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”OAuthStateData | Promise<OAuthStateData | undefined> | undefined
set(
state,data):void|Promise<void>
Defined in: state-store.ts:12
Parameters
Section titled “Parameters”string
Omit<OAuthStateData, "expiresAt">
Returns
Section titled “Returns”void | Promise<void>