Skip to content

TokenModel

Defined in: packages/core/src/models/token.ts:16

Data operations for CI tokens.

new TokenModel(db, tables?): TokenModel

Defined in: packages/core/src/models/token.ts:24

DatabaseAdapter

Database adapter.

TokenTables

Table handles.

TokenModel

create(projectId, input): Promise<Token>

Defined in: packages/core/src/models/token.ts:37

Create a token record storing its hash.

string

Project ID.

Token name, hash, and optional owning user ID (null for legacy/admin-token minting; such tokens resolve as viewer).

string

string

string | null

Promise<Token>

The created token.


findByHash(hash): Promise<Token | null>

Defined in: packages/core/src/models/token.ts:85

Fetch a token by its hashed value, or null if not found.

string

Promise<Token | null>


get(projectId, id): Promise<Token | null>

Defined in: packages/core/src/models/token.ts:73

Fetch a token by id within a project, or null if not found.

string

string

Promise<Token | null>


issue(projectId, input): Promise<{ token: Token; value: string; }>

Defined in: packages/core/src/models/token.ts:56

Mint a new shelf_ token for a project and store only its hash.

string

string

string | null

Promise<{ token: Token; value: string; }>

The stored record and the plaintext value (shown to the user once).


list(projectId): Promise<Token[]>

Defined in: packages/core/src/models/token.ts:66

List all tokens for a project.

string

Promise<Token[]>


remove(id): Promise<void>

Defined in: packages/core/src/models/token.ts:94

Delete a token by id.

string

Promise<void>