IF Commons GitHub

otpSecret

concept

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.

Governance: attributes

algorithmcode of otpAlgorithmrequired

The hash the codes are made with

Becomes the column algorithm of otp_secret.

Written at commons/data/models/identity/concepts.ts:192

digitsintegerrequired

How many digits a code has

Becomes the column digits of otp_secret.

Written at commons/data/models/identity/concepts.ts:193

keyReferencetextrequired

Names the key that encrypted it

Becomes the column key_reference of otp_secret.

Written at commons/data/models/identity/concepts.ts:191

lastUsedStepintegeroptional

The 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

periodSecondsintegerrequired

How long a code lasts

Becomes the column period_seconds of otp_secret.

Written at commons/data/models/identity/concepts.ts:194

secretCiphertextbinaryrequired

The 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

Governance: relationships

credentialone

The credential it is To credential. Written at commons/data/models/identity/concepts.ts:187

Logical: the table

Projects to the table otp_secret with the primary key credential_id.

ColumnTypeNullRoleFrom
algorithmtextfalseattributeotpSecret.algorithm
credential_idtextfalsereferenceotpSecret.credential
digitsintegerfalseattributeotpSecret.digits
key_referencetextfalseattributeotpSecret.keyReference
last_used_stepintegertrueattributeotpSecret.lastUsedStep
period_secondsintegerfalseattributeotpSecret.periodSeconds
secret_ciphertextbytesfalseattributeotpSecret.secretCiphertext

Physical: SQL

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'))
);

Physical: the typed table

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);

Titles, headings, exports, tables, columns and requirements. Esc closes.