attemptsintegerrequiredHow many times it was tried
Becomes the column attempts of challenge.
Written at commons/data/models/identity/concepts.ts:218
Something a person is asked to prove, once: a reset link, a magic link, a code or a passkey challenge, kept as a hash
Model identity. Written in commons/data/models/identity/concepts.ts:212. Identified by challengeId.
attemptsintegerrequiredHow many times it was tried
Becomes the column attempts of challenge.
Written at commons/data/models/identity/concepts.ts:218
challengeIdidentifierrequiredWhat identifies the challenge, made by the application
Becomes the column challenge_id of challenge.
Written at commons/data/models/identity/concepts.ts:215
consumedAtinstantoptionalWhen it was used
Becomes the column consumed_at of challenge.
Written at commons/data/models/identity/concepts.ts:221
expiresAtinstantrequiredWhen it stops being valid
Becomes the column expires_at of challenge.
Written at commons/data/models/identity/concepts.ts:220
maxAttemptsintegerrequiredHow many times it may be
Becomes the column max_attempts of challenge.
Written at commons/data/models/identity/concepts.ts:219
purposecode of challengePurposerequiredWhat it is for
Becomes the column purpose of challenge.
Written at commons/data/models/identity/concepts.ts:216
secretHashtextrequiredThe hash of what was sent
Becomes the column secret_hash of challenge.
Written at commons/data/models/identity/concepts.ts:217
destinationoptionalWhere it was sent To electronicContact. Written at commons/data/models/identity/concepts.ts:226
principaloptionalWho it is for, where that is known To principal. Written at commons/data/models/identity/concepts.ts:225
Projects to the table challenge with the primary key challenge_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
attempts | integer | false | attribute | challenge.attempts |
challenge_id | text | false | attribute | challenge.challengeId |
consumed_at | timestamp | true | attribute | challenge.consumedAt |
destination_electronic_contact_id | text | true | reference | challenge.destination |
expires_at | timestamp | false | attribute | challenge.expiresAt |
max_attempts | integer | false | attribute | challenge.maxAttempts |
principal_id | text | true | reference | challenge.principal |
purpose | text | false | attribute | challenge.purpose |
secret_hash | text | false | attribute | challenge.secretHash |
CREATE TABLE IF NOT EXISTS "challenge" (
"challenge_id" VARCHAR NOT NULL PRIMARY KEY,
"purpose" VARCHAR NOT NULL,
"secret_hash" VARCHAR NOT NULL,
"attempts" INTEGER NOT NULL,
"max_attempts" INTEGER NOT NULL,
"expires_at" TIMESTAMPTZ NOT NULL,
"consumed_at" TIMESTAMPTZ,
"principal_id" VARCHAR,
"destination_electronic_contact_id" VARCHAR,
CONSTRAINT "challenge_principal_id_fk" FOREIGN KEY ("principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "challenge_destination_electronic_contact_id_fk" FOREIGN KEY ("destination_electronic_contact_id") REFERENCES "electronic_contact" ("electronic_contact_id"),
CONSTRAINT "challenge_purpose_ck" CHECK ("purpose" IN ('login', 'email_verification', 'password_reset', 'magic_link', 'step_up', 'passkey_registration', 'passkey_authentication'))
);CREATE TABLE IF NOT EXISTS "challenge" (
"challenge_id" TEXT NOT NULL PRIMARY KEY,
"purpose" TEXT NOT NULL,
"secret_hash" TEXT NOT NULL,
"attempts" INTEGER NOT NULL,
"max_attempts" INTEGER NOT NULL,
"expires_at" TIMESTAMPTZ NOT NULL,
"consumed_at" TIMESTAMPTZ,
"principal_id" TEXT,
"destination_electronic_contact_id" TEXT,
CONSTRAINT "challenge_principal_id_fk" FOREIGN KEY ("principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "challenge_destination_electronic_contact_id_fk" FOREIGN KEY ("destination_electronic_contact_id") REFERENCES "electronic_contact" ("electronic_contact_id"),
CONSTRAINT "challenge_purpose_ck" CHECK ("purpose" IN ('login', 'email_verification', 'password_reset', 'magic_link', 'step_up', 'passkey_registration', 'passkey_authentication'))
);CREATE TABLE IF NOT EXISTS "challenge" (
"challenge_id" TEXT NOT NULL PRIMARY KEY,
"purpose" TEXT NOT NULL,
"secret_hash" TEXT NOT NULL,
"attempts" INTEGER NOT NULL,
"max_attempts" INTEGER NOT NULL,
"expires_at" TEXT NOT NULL,
"consumed_at" TEXT,
"principal_id" TEXT,
"destination_electronic_contact_id" TEXT,
CONSTRAINT "challenge_principal_id_fk" FOREIGN KEY ("principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "challenge_destination_electronic_contact_id_fk" FOREIGN KEY ("destination_electronic_contact_id") REFERENCES "electronic_contact" ("electronic_contact_id"),
CONSTRAINT "challenge_purpose_ck" CHECK ("purpose" IN ('login', 'email_verification', 'password_reset', 'magic_link', 'step_up', 'passkey_registration', 'passkey_authentication'))
);Read and written from TypeScript with the types the model gives: import { challenge } 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 { challenge } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(challenge).select((s) => ({ challengeId: s.challenge.challengeId, purpose: s.challenge.purpose })).run(runner);