Skip to main content

Type Alias: OneTimeTokenStore

OneTimeTokenStore = object

Defined in: auth-core/src/emailAuthTypes.ts:104

App-provided one-time token persistence.

Every method takes or returns a tokenHash, never a redeemable token, which makes storing a usable secret impossible rather than merely discouraged.

Properties​

delete​

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

Defined in: auth-core/src/emailAuthTypes.ts:131

Delete a token, returning true only to the call that removed it — the single-use guarantee. Two concurrent redemptions of one link or code can both find it; the engine signs in only the caller this returns true to. Report the deleted row count (DELETE … WHERE token_hash = $1 AND purpose = $2 affecting one row), never a prior read.

Parameters​

ParameterType
args{ purpose: OneTimeTokenPurpose; tokenHash: string; }
args.purposeOneTimeTokenPurpose
args.tokenHashstring

Returns​

Promise<boolean> | boolean


deleteFor​

deleteFor: (args) => Promise<void> | void

Defined in: auth-core/src/emailAuthTypes.ts:139

Delete every outstanding token of this purpose for this address, so issuing a new one invalidates whatever preceded it.

Parameters​

ParameterType
args{ email: string; purpose: OneTimeTokenPurpose; }
args.emailstring
args.purposeOneTimeTokenPurpose

Returns​

Promise<void> | void


find​

find: (args) => Promise<StoredOneTimeToken | null> | StoredOneTimeToken | null

Defined in: auth-core/src/emailAuthTypes.ts:111

Look up by hash and purpose, so a token minted for one flow cannot be redeemed by another. This is the lookup for the link flows, where the token itself is the only thing the request carries.

Parameters​

ParameterType
args{ purpose: OneTimeTokenPurpose; tokenHash: string; }
args.purposeOneTimeTokenPurpose
args.tokenHashstring

Returns​

Promise<StoredOneTimeToken | null> | StoredOneTimeToken | null


findByEmail?​

optional findByEmail?: (args) => Promise<StoredOneTimeToken | null> | StoredOneTimeToken | null

Defined in: auth-core/src/emailAuthTypes.ts:120

Look up the outstanding token for an address. Required when emailCode is enabled: a wrong code hashes to nothing on record, so the engine has to find the record by address before it can compare and count the attempt.

Parameters​

ParameterType
args{ email: string; purpose: OneTimeTokenPurpose; }
args.emailstring
args.purposeOneTimeTokenPurpose

Returns​

Promise<StoredOneTimeToken | null> | StoredOneTimeToken | null


incrementAttempts?​

optional incrementAttempts?: (args) => Promise<void> | void

Defined in: auth-core/src/emailAuthTypes.ts:148

Record a failed attempt. Required when emailCode is enabled; the engine calls it on every wrong guess and destroys the token once maxAttempts is reached.

Parameters​

ParameterType
args{ purpose: OneTimeTokenPurpose; tokenHash: string; }
args.purposeOneTimeTokenPurpose
args.tokenHashstring

Returns​

Promise<void> | void


save​

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

Defined in: auth-core/src/emailAuthTypes.ts:105

Parameters​

ParameterType
tokenStoredOneTimeToken

Returns​

Promise<void> | void