basalt / auth-sqlite/src / SqliteAuthTokenStore
Class: SqliteAuthTokenStore
Defined in: auth-sqlite/src/index.ts:327
Stores single-use, expiring tokens for verification and reset flows.
Implements
Constructors
Constructor
> new SqliteAuthTokenStore(db): SqliteAuthTokenStore
Defined in: auth-sqlite/src/index.ts:328
Parameters
db
DatabaseSync
Returns
SqliteAuthTokenStore
Methods
create()
> create(record): Promise<void>
Defined in: auth-sqlite/src/index.ts:330
Parameters
record
Returns
Promise<void>
Implementation of
deleteForUser()
> deleteForUser(userId, purpose): Promise<void>
Defined in: auth-sqlite/src/index.ts:351
Invalidate outstanding tokens of a purpose for a user before issuing a new one.
Parameters
userId
string
purpose
Returns
Promise<void>
Implementation of
find()
> find(token): Promise<AuthTokenRecord | null>
Defined in: auth-sqlite/src/index.ts:336
Parameters
token
string
Returns
Promise<AuthTokenRecord | null>
Implementation of
markUsed()
> markUsed(token): Promise<boolean>
Defined in: auth-sqlite/src/index.ts:343
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>