algorithmcode of otpAlgorithmrequiredThe hash the codes are made with
Becomes the column algorithm of otp_secret.
Written at commons/data/models/identity/concepts.ts:192
The secret of a one-time-code factor, kept as ciphertext under a key held outside the database
Model identity. Written in commons/data/models/identity/concepts.ts:187. Identified by credential.
algorithmcode of otpAlgorithmrequiredThe hash the codes are made with
Becomes the column algorithm of otp_secret.
Written at commons/data/models/identity/concepts.ts:192
digitsintegerrequiredHow many digits a code has
Becomes the column digits of otp_secret.
Written at commons/data/models/identity/concepts.ts:193
keyReferencetextrequiredNames the key that encrypted it
Becomes the column key_reference of otp_secret.
Written at commons/data/models/identity/concepts.ts:191
lastUsedStepintegeroptionalThe time step of the last code taken, so that none is taken twice
Becomes the column last_used_step of otp_secret.
Written at commons/data/models/identity/concepts.ts:195
periodSecondsintegerrequiredHow long a code lasts
Becomes the column period_seconds of otp_secret.
Written at commons/data/models/identity/concepts.ts:194
secretCiphertextbinaryrequiredThe secret, encrypted: the server must make codes from it, so it cannot be only hashed
Becomes the column secret_ciphertext of otp_secret.
Written at commons/data/models/identity/concepts.ts:190
credentialoneThe credential it is To credential. Written at commons/data/models/identity/concepts.ts:187
Projects to the table otp_secret with the primary key credential_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
algorithm | text | false | attribute | otpSecret.algorithm |
credential_id | text | false | reference | otpSecret.credential |
digits | integer | false | attribute | otpSecret.digits |
key_reference | text | false | attribute | otpSecret.keyReference |
last_used_step | integer | true | attribute | otpSecret.lastUsedStep |
period_seconds | integer | false | attribute | otpSecret.periodSeconds |
secret_ciphertext | bytes | false | attribute | otpSecret.secretCiphertext |
CREATE TABLE IF NOT EXISTS "otp_secret" (
"credential_id" VARCHAR NOT NULL PRIMARY KEY,
"secret_ciphertext" BLOB NOT NULL,
"key_reference" VARCHAR NOT NULL,
"algorithm" VARCHAR NOT NULL,
"digits" INTEGER NOT NULL,
"period_seconds" INTEGER NOT NULL,
"last_used_step" INTEGER,
CONSTRAINT "otp_secret_credential_id_fk" FOREIGN KEY ("credential_id") REFERENCES "credential" ("credential_id"),
CONSTRAINT "otp_secret_algorithm_ck" CHECK ("algorithm" IN ('sha_1', 'sha_256', 'sha_512'))
);CREATE TABLE IF NOT EXISTS "otp_secret" (
"credential_id" TEXT NOT NULL PRIMARY KEY,
"secret_ciphertext" BYTEA NOT NULL,
"key_reference" TEXT NOT NULL,
"algorithm" TEXT NOT NULL,
"digits" INTEGER NOT NULL,
"period_seconds" INTEGER NOT NULL,
"last_used_step" INTEGER,
CONSTRAINT "otp_secret_credential_id_fk" FOREIGN KEY ("credential_id") REFERENCES "credential" ("credential_id"),
CONSTRAINT "otp_secret_algorithm_ck" CHECK ("algorithm" IN ('sha_1', 'sha_256', 'sha_512'))
);CREATE TABLE IF NOT EXISTS "otp_secret" (
"credential_id" TEXT NOT NULL PRIMARY KEY,
"secret_ciphertext" BLOB NOT NULL,
"key_reference" TEXT NOT NULL,
"algorithm" TEXT NOT NULL,
"digits" INTEGER NOT NULL,
"period_seconds" INTEGER NOT NULL,
"last_used_step" INTEGER,
CONSTRAINT "otp_secret_credential_id_fk" FOREIGN KEY ("credential_id") REFERENCES "credential" ("credential_id"),
CONSTRAINT "otp_secret_algorithm_ck" CHECK ("algorithm" IN ('sha_1', 'sha_256', 'sha_512'))
);Read and written from TypeScript with the types the model gives: import { otpSecret } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity.auto.ts: do not edit.
import { from } from "@intellectual-frontiers/data/sql/typed";
import { otpSecret } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(otpSecret).select((s) => ({ credentialId: s.otpSecret.credentialId, secretCiphertext: s.otpSecret.secretCiphertext })).run(runner);