class MemoryRefreshTokenStore
implements RefreshTokenStore

In-memory implementation of RefreshTokenStore.

Entries are lazily expired on get() — when runtime.now() >= expiresAt the entry is deleted and null is returned. This keeps the map bounded without requiring a background cleanup job.

Constructors

MemoryRefreshTokenStore(runtime: IRuntimeServices)

Methods

get(jti: string): Promise<RefreshTokenRecord | null>

Retrieve a record by jti; returns null if missing or expired. A revoked record is still returned so the caller can distinguish replay of a rotated token from an unknown token.

revoke(jti: string): Promise<void>

Revoke a token by jti.

revokeFamily(jti: string): Promise<readonly RefreshTokenRecord[]>

Revoke every refresh token in the requested token's family.

Returns the affected records so the caller can also revoke their paired access credentials through its separately configured store. Remote implementations must serialize this operation with rotate() for the same family: durably mark the family revoked and revoke current members in one operation, while rotate() atomically rejects a marked family. A rotation ordered before this operation must have its successor included; one ordered after it must not persist a successor.

rotate(
jti: string,
): Promise<IRefreshTokenRotation>

Atomically consume a live refresh token and persist its successor.

Remote implementations must make the conditional live-token check, parent revocation, successor write, and family-revoked-marker check one atomic operation. This prevents two concurrent refresh requests from minting independent descendants and prevents a rotation after family revocation.

save(record: RefreshTokenRecord): Promise<void>

Store or update a refresh token record.

Usage

import { MemoryRefreshTokenStore } from "auth-plugin/src/index.ts";