Skip to content

basalt / auth-prisma/src / PrismaAuthTokenStore

Class: PrismaAuthTokenStore ​

Defined in: auth-prisma/src/index.ts:425

Stores single-use, expiring tokens for verification and reset flows.

Implements ​

Constructors ​

Constructor ​

> new PrismaAuthTokenStore(client, options?): PrismaAuthTokenStore

Defined in: auth-prisma/src/index.ts:428

Parameters ​

client ​

PrismaAuthClient

options? ​

PrismaAuthStoreOptions = {}

Returns ​

PrismaAuthTokenStore

Methods ​

create() ​

> create(record): Promise<void>

Defined in: auth-prisma/src/index.ts:435

Parameters ​

record ​

AuthTokenRecord

Returns ​

Promise<void>

Implementation of ​

AuthTokenStore.create


deleteForUser() ​

> deleteForUser(userId, purpose): Promise<void>

Defined in: auth-prisma/src/index.ts:462

Invalidate outstanding tokens of a purpose for a user before issuing a new one.

Parameters ​

userId ​

string

purpose ​

AuthTokenPurpose

Returns ​

Promise<void>

Implementation of ​

AuthTokenStore.deleteForUser


find() ​

> find(token): Promise<AuthTokenRecord | null>

Defined in: auth-prisma/src/index.ts:447

Parameters ​

token ​

string

Returns ​

Promise<AuthTokenRecord | null>

Implementation of ​

AuthTokenStore.find


markUsed() ​

> markUsed(token): Promise<boolean>

Defined in: auth-prisma/src/index.ts:452

Consumes the token. MUST be a compare-and-swap: mark it used only if it is still unused, and return whether THIS call did the consuming — false means a concurrent caller got there first. Returning void keeps the pre-CAS behaviour (the caller then trusts its earlier read), so third-party stores written against the old contract keep working, without the race protection.

Parameters ​

token ​

string

Returns ​

Promise<boolean>

Implementation of ​

AuthTokenStore.markUsed

Released under the MIT License.