/** * A generic store for tracking seen values and detecting replays. * Used to prevent reuse of one-time tokens such as JTI claims. * * @template T - The type of values stored (string or number). */ export interface ReplayStore { /** * Returns `true` if the value is currently tracked (i.e. has been seen and not yet expired). * @param value - The value to check. */ has(value: T): Promise; /** * Removes a value from the store before its TTL expires. * @param value - The value to remove. */ delete(value: T): Promise; /** * Adds a value to the store. The value will be automatically removed after `ttlSeconds`. * If the value already exists, its TTL is reset. * @param value - The value to track. * @param ttlSeconds - Lifetime in seconds before the value is automatically removed. */ add(value: T, ttlSeconds: number): Promise; } /** * In-memory implementation of {@link ReplayStore} backed by a plain object with `setTimeout`-based expiry. * * Suitable for single-process deployments. For distributed or multi-process environments, * provide a custom {@link ReplayStore} implementation backed by a shared store (e.g. Redis). * * @template T - The type of values stored. Defaults to `string | number`. */ export declare class InMemoryReplayStore implements ReplayStore { private values; /** * Returns `true` if the value is currently tracked. * @param value - The value to check. */ has(value: T): Promise; /** * Removes a value from the store and clears its expiry timer. * @param value - The value to remove. */ delete(value: T): Promise; /** * Adds a value to the store with an automatic expiry. * If the value already exists, its TTL timer is reset. * @param value - The value to track. * @param ttlSeconds - Lifetime in seconds before the value is automatically removed. */ add(value: T, ttlSeconds: number): Promise; /** * Clears all tracked values and their expiry timers. */ clear(): Promise; } /** * Specialization of {@link ReplayStore} for string values. * Used to detect replayed tokens via their JTI claim or token string. */ export type ReplayDetector = ReplayStore; /** * Creates a new {@link InMemoryReplayStore} instance. * * @template T - The type of values stored. Defaults to `string | number`. * @returns A new in-memory replay store. */ export declare function createInMemoryReplayStore(): InMemoryReplayStore; //# sourceMappingURL=replay_store.d.ts.map