allowedCidrstextmanyThe networks it may be used from
Becomes the column allowed_cidrs of api_key.
A random secret that a program presents, kept as a keyed hash and shown once, never wider in authority than its owner
Model identityMachine. Written in commons/data/models/identity-machine/mod.ts:56. Identified by credential.
allowedCidrstextmanyThe networks it may be used from
Becomes the column allowed_cidrs of api_key.
lastUsedAtinstantoptionalWhen it was last used
Becomes the column last_used_at of api_key.
prefixtextrequiredThe part that is not secret, by which the key is found, unique
Becomes the column prefix of api_key.
scopestextmanyThe permissions the key may use: the owner's, narrowed to these
Becomes the column scopes of api_key.
secretHashtextrequiredThe keyed hash of the secret
Becomes the column secret_hash of api_key.
credentialoneThe credential it is To credential. Written at commons/data/models/identity-machine/mod.ts:56
rotatedFromoptionalThe key it replaced To apiKey. Written at commons/data/models/identity-machine/mod.ts:56
Projects to the table api_key with the primary key credential_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
credential_id | text | false | reference | apiKey.credential |
last_used_at | timestamp | true | attribute | apiKey.lastUsedAt |
prefix | text | false | attribute | apiKey.prefix |
rotated_from_api_key_credential_id | text | true | reference | apiKey.rotatedFrom |
secret_hash | text | false | attribute | apiKey.secretHash |
CREATE TABLE IF NOT EXISTS "api_key" (
"credential_id" VARCHAR NOT NULL PRIMARY KEY,
"prefix" VARCHAR NOT NULL,
"secret_hash" VARCHAR NOT NULL,
"last_used_at" TIMESTAMPTZ,
"rotated_from_api_key_credential_id" VARCHAR,
CONSTRAINT "api_key_credential_id_fk" FOREIGN KEY ("credential_id") REFERENCES "credential" ("credential_id"),
CONSTRAINT "api_key_rotated_from_api_key_credential_id_fk" FOREIGN KEY ("rotated_from_api_key_credential_id") REFERENCES "api_key" ("credential_id"),
CONSTRAINT "api_key_prefix_uq" UNIQUE ("prefix")
);CREATE TABLE IF NOT EXISTS "api_key" (
"credential_id" TEXT NOT NULL PRIMARY KEY,
"prefix" TEXT NOT NULL,
"secret_hash" TEXT NOT NULL,
"last_used_at" TIMESTAMPTZ,
"rotated_from_api_key_credential_id" TEXT,
CONSTRAINT "api_key_credential_id_fk" FOREIGN KEY ("credential_id") REFERENCES "credential" ("credential_id"),
CONSTRAINT "api_key_rotated_from_api_key_credential_id_fk" FOREIGN KEY ("rotated_from_api_key_credential_id") REFERENCES "api_key" ("credential_id"),
CONSTRAINT "api_key_prefix_uq" UNIQUE ("prefix")
);CREATE TABLE IF NOT EXISTS "api_key" (
"credential_id" TEXT NOT NULL PRIMARY KEY,
"prefix" TEXT NOT NULL,
"secret_hash" TEXT NOT NULL,
"last_used_at" TEXT,
"rotated_from_api_key_credential_id" TEXT,
CONSTRAINT "api_key_credential_id_fk" FOREIGN KEY ("credential_id") REFERENCES "credential" ("credential_id"),
CONSTRAINT "api_key_rotated_from_api_key_credential_id_fk" FOREIGN KEY ("rotated_from_api_key_credential_id") REFERENCES "api_key" ("credential_id"),
CONSTRAINT "api_key_prefix_uq" UNIQUE ("prefix")
);Read and written from TypeScript with the types the model gives: import { apiKey } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity-machine.auto.ts: do not edit.
import { from } from "@intellectual-frontiers/data/sql/typed";
import { apiKey } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(apiKey).select((s) => ({ credentialId: s.apiKey.credentialId, prefix: s.apiKey.prefix })).run(runner);