Files
mesh-catalog/modules/gitea/tools/tokenlease.ts
T
jschoubben 39ed20c5bc C4: the forge module's tokens live in the vault, one process mints at a time
Two processes that minted at once left the forge two tokens by one name, and a token kept in a file in the
runtime state is a plain state. Both accounts' tokens (mesh-tools, mesh-packages) are now the module's own
secrets in the vault, written through the seat mesh-vault's own-put and read through its get, sealed to the
reading process's key. A refused or expired (token-ttl) token is minted again only by the holder of the lease
mint in the state token-lease (mint-lease); each mint is named <account>-<generation>, and the token it
replaces is deleted by id only after own-put landed. The Go bundles read their tokens through get at start
and at secret-changed; the MESH_GITEA_*_TOKEN_FILE words go. forge_token_lease reads the lease and each
token's age, never the token.

Builds: design 47 H2 §808, §822; H-A-407, H-A-422, H-A-426, H-A-430 (1)
2026-11-22 01:41:30 +01:00

17 lines
966 B
TypeScript

// The tool forge_token_lease (design 47 H2 §808, the tools table): the mint lease's holder and since when, and each
// account's token age, read from the vault's `changed-at`; never the token.
import type { ToolDefinition } from "@novox/mesh-sdk/tools";
import { tokenLease, type MintLease, type TokenVault } from "../token.js";
export function tokenLeaseTool(vault: TokenVault, lease: MintLease, accounts: readonly string[], now: () => Date = () => new Date()): ToolDefinition {
return {
name: "forge_token_lease",
description: "The forge token's mint lease and each account's token age (design 47 H2 §808): who holds the lease `mint` in the " +
"state token-lease and since when, and for each account (" + accounts.join(", ") + ") the vault's generation of its token " +
"and when it changed, never the token itself.",
input: { type: "object", properties: {} },
run: async () => tokenLease(vault, lease, accounts, now()),
};
}