expiresAtinstantrequiredWhen it stops being valid
Becomes the column expires_at of refresh_token.
Written at commons/data/models/identity/concepts.ts:300
A token that renews a session, kept as a hash, used once and replaced by the next one of its family
Model identity. Written in commons/data/models/identity/concepts.ts:293. Identified by refreshTokenId.
expiresAtinstantrequiredWhen it stops being valid
Becomes the column expires_at of refresh_token.
Written at commons/data/models/identity/concepts.ts:300
familyIdidentifierrequiredWhat every token rotated from one issue shares, so that a reuse ends them all
Becomes the column family_id of refresh_token.
Written at commons/data/models/identity/concepts.ts:297
issuedAtinstantrequiredWhen it was made
Becomes the column issued_at of refresh_token.
Written at commons/data/models/identity/concepts.ts:299
refreshTokenIdidentifierrequiredWhat identifies the token, made by the application
Becomes the column refresh_token_id of refresh_token.
Written at commons/data/models/identity/concepts.ts:296
revokedAtinstantoptionalWhen it was ended early
Becomes the column revoked_at of refresh_token.
Written at commons/data/models/identity/concepts.ts:302
tokenHashtextrequiredThe hash of the token
Becomes the column token_hash of refresh_token.
Written at commons/data/models/identity/concepts.ts:298
usedAtinstantoptionalWhen it was exchanged for the next
Becomes the column used_at of refresh_token.
Written at commons/data/models/identity/concepts.ts:301
replacedByoptionalThe token that took its place To refreshToken. Written at commons/data/models/identity/concepts.ts:307
sessiononeThe session it renews To loginSession. Written at commons/data/models/identity/concepts.ts:306
Projects to the table refresh_token with the primary key refresh_token_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
expires_at | timestamp | false | attribute | refreshToken.expiresAt |
family_id | text | false | attribute | refreshToken.familyId |
issued_at | timestamp | false | attribute | refreshToken.issuedAt |
refresh_token_id | text | false | attribute | refreshToken.refreshTokenId |
replaced_by_refresh_token_id | text | true | reference | refreshToken.replacedBy |
revoked_at | timestamp | true | attribute | refreshToken.revokedAt |
session_login_session_session_id | text | false | reference | refreshToken.session |
token_hash | text | false | attribute | refreshToken.tokenHash |
used_at | timestamp | true | attribute | refreshToken.usedAt |
CREATE TABLE IF NOT EXISTS "refresh_token" (
"refresh_token_id" VARCHAR NOT NULL PRIMARY KEY,
"family_id" VARCHAR NOT NULL,
"token_hash" VARCHAR NOT NULL,
"issued_at" TIMESTAMPTZ NOT NULL,
"expires_at" TIMESTAMPTZ NOT NULL,
"used_at" TIMESTAMPTZ,
"revoked_at" TIMESTAMPTZ,
"session_login_session_session_id" VARCHAR NOT NULL,
"replaced_by_refresh_token_id" VARCHAR,
CONSTRAINT "refresh_token_session_login_session_session_id_fk" FOREIGN KEY ("session_login_session_session_id") REFERENCES "login_session" ("session_id"),
CONSTRAINT "refresh_token_replaced_by_refresh_token_id_fk" FOREIGN KEY ("replaced_by_refresh_token_id") REFERENCES "refresh_token" ("refresh_token_id"),
CONSTRAINT "refresh_token_token_hash_uq" UNIQUE ("token_hash")
);CREATE TABLE IF NOT EXISTS "refresh_token" (
"refresh_token_id" TEXT NOT NULL PRIMARY KEY,
"family_id" TEXT NOT NULL,
"token_hash" TEXT NOT NULL,
"issued_at" TIMESTAMPTZ NOT NULL,
"expires_at" TIMESTAMPTZ NOT NULL,
"used_at" TIMESTAMPTZ,
"revoked_at" TIMESTAMPTZ,
"session_login_session_session_id" TEXT NOT NULL,
"replaced_by_refresh_token_id" TEXT,
CONSTRAINT "refresh_token_session_login_session_session_id_fk" FOREIGN KEY ("session_login_session_session_id") REFERENCES "login_session" ("session_id"),
CONSTRAINT "refresh_token_replaced_by_refresh_token_id_fk" FOREIGN KEY ("replaced_by_refresh_token_id") REFERENCES "refresh_token" ("refresh_token_id"),
CONSTRAINT "refresh_token_token_hash_uq" UNIQUE ("token_hash")
);CREATE TABLE IF NOT EXISTS "refresh_token" (
"refresh_token_id" TEXT NOT NULL PRIMARY KEY,
"family_id" TEXT NOT NULL,
"token_hash" TEXT NOT NULL,
"issued_at" TEXT NOT NULL,
"expires_at" TEXT NOT NULL,
"used_at" TEXT,
"revoked_at" TEXT,
"session_login_session_session_id" TEXT NOT NULL,
"replaced_by_refresh_token_id" TEXT,
CONSTRAINT "refresh_token_session_login_session_session_id_fk" FOREIGN KEY ("session_login_session_session_id") REFERENCES "login_session" ("session_id"),
CONSTRAINT "refresh_token_replaced_by_refresh_token_id_fk" FOREIGN KEY ("replaced_by_refresh_token_id") REFERENCES "refresh_token" ("refresh_token_id"),
CONSTRAINT "refresh_token_token_hash_uq" UNIQUE ("token_hash")
);Read and written from TypeScript with the types the model gives: import { refreshToken } 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 { refreshToken } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(refreshToken).select((s) => ({ refreshTokenId: s.refreshToken.refreshTokenId, familyId: s.refreshToken.familyId })).run(runner);