IF Commons GitHub

refreshToken

concept

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.

Governance: attributes

expiresAtinstantrequired

When it stops being valid

Becomes the column expires_at of refresh_token.

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

familyIdidentifierrequired

What 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

issuedAtinstantrequired

When it was made

Becomes the column issued_at of refresh_token.

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

refreshTokenIdidentifierrequired

What 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

revokedAtinstantoptional

When it was ended early

Becomes the column revoked_at of refresh_token.

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

tokenHashtextrequired

The hash of the token

Becomes the column token_hash of refresh_token.

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

usedAtinstantoptional

When it was exchanged for the next

Becomes the column used_at of refresh_token.

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

Governance: relationships

replacedByoptional

The token that took its place To refreshToken. Written at commons/data/models/identity/concepts.ts:307

sessionone

The session it renews To loginSession. Written at commons/data/models/identity/concepts.ts:306

Logical: the table

Projects to the table refresh_token with the primary key refresh_token_id.

ColumnTypeNullRoleFrom
expires_attimestampfalseattributerefreshToken.expiresAt
family_idtextfalseattributerefreshToken.familyId
issued_attimestampfalseattributerefreshToken.issuedAt
refresh_token_idtextfalseattributerefreshToken.refreshTokenId
replaced_by_refresh_token_idtexttruereferencerefreshToken.replacedBy
revoked_attimestamptrueattributerefreshToken.revokedAt
session_login_session_session_idtextfalsereferencerefreshToken.session
token_hashtextfalseattributerefreshToken.tokenHash
used_attimestamptrueattributerefreshToken.usedAt

Physical: SQL

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

Physical: the typed table

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

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