Skip to main content

Interface: RefreshTokenStore

Defined in: auth-core/src/oauthServerTypes.ts:187

App-provided store for refresh tokens, backing OAuth 2.1 rotation. The store is pure persistence — the rotation mechanics (single-use, expiry, reuse detection) live in createRefreshRotation. Back it with DynamoDB, Postgres, in-memory, … The "owner" of a token is the (clientId, subject) pair.

Properties​

consume​

consume: (args) => boolean | Promise<boolean>

Defined in: auth-core/src/oauthServerTypes.ts:204

Atomically mark a live token consumed, returning true only to the call that flipped it. A token already consumed (or unknown) returns false.

This is the single-use guarantee: two concurrent refreshes with the same token can both get it before either writes, so the check-then-write has to happen in one step — in Postgres, UPDATE … SET consumed_at = $at WHERE token_hash = $1 AND consumed_at IS NULL and report whether a row changed. Rotation treats false as reuse and revokes the owner's chain.

Parameters​

ParameterTypeDescription
args{ at: number; tokenHash: string; }-
args.atnumberUnix timestamp (milliseconds) to record as consumedAt.
args.tokenHashstring-

Returns​

boolean | Promise<boolean>


delete​

delete: (tokenHash) => void | Promise<void>

Defined in: auth-core/src/oauthServerTypes.ts:210

Remove a single refresh token by its hash.

Parameters​

ParameterType
tokenHashstring

Returns​

void | Promise<void>


deleteByOwner​

deleteByOwner: (owner) => void | Promise<void>

Defined in: auth-core/src/oauthServerTypes.ts:215

Remove every refresh token belonging to an owner. Called on reuse detection to revoke the entire chain (the live token included), forcing re-auth.

Parameters​

ParameterType
owner{ clientId: string; subject: string; }
owner.clientIdstring
owner.subjectstring

Returns​

void | Promise<void>


get​

get: (tokenHash) => StoredRefreshToken | Promise<StoredRefreshToken | undefined> | undefined

Defined in: auth-core/src/oauthServerTypes.ts:191

Look up a refresh token by its hash. Return undefined if unknown.

Parameters​

ParameterType
tokenHashstring

Returns​

StoredRefreshToken | Promise<StoredRefreshToken | undefined> | undefined


save​

save: (token) => void | Promise<void>

Defined in: auth-core/src/oauthServerTypes.ts:189

Persist a refresh token, upserting by tokenHash.

Parameters​

ParameterType
tokenStoredRefreshToken

Returns​

void | Promise<void>