user_two_factor_recovery_codes API Postgres table
Unused single-use recovery codes for a user's two-factor sign-in.
Declared in packages/api-shared/src/schema/twoFactor.ts
Description
Only HMAC-SHA-256 hashes are stored, keyed by TWO_FACTOR_SECRET_KEY and bound to the user, so a database read alone cannot test guesses; the codes themselves are shown once. Using a code deletes its row, and turning two-factor off or replacing the codes deletes them all.
Columns
user_iduuid- not null
- references users (
id)
The user the code belongs to.
code_hashtext- not null
Lowercase hex HMAC-SHA-256 of the user id and normalized code, under a key derived from
TWO_FACTOR_SECRET_KEY.created_attimestamp- not null
- default now()
When the code was issued.
Keys and constraints
- Primary key
(user_id, code_hash) on delete cascade