Skip to main content

Module account

Module account 

Source
Expand description

Account references for multi-account OAuth credentials.

An account is a (provider, label) pair. The bare provider storage key ("openai-codex") is the default account; every other account is stored under "<provider>@<label>". Nothing that already exists moves or needs migration.

Labels are validated at every boundary (CLI, env, config, HTTP query, proxy body) before they are used as a JSON key, a file-name fragment, a URL parameter, or a log field. A label that fails the grammar never reaches the filesystem.

Structs§

AccountLabel
Validated account label. Grammar: ^[a-z0-9][a-z0-9._-]{0,31}$; the words default and auto are reserved and rejected.
AccountPolicy
Per-provider account selection. Built once from config (+ env overlay); never mutates the process environment or the active profile.
AccountSummary
Non-secret listing row for one stored account. Never carries token material; account_id_prefix is at most 8 characters.
CredentialRef
A fully addressed OAuth credential: provider + account slot.
SeatIdentity
Identity of the credential material currently stored in one slot. Scopes per-slot caches and pairs a proven-capacity reading with the token vended for it: the provider seat (via seat_fingerprint) when the credential carries an account id — stable across token rotation — otherwise a digest of the refresh material, which changes on re-login and on rotation. An opaque digest: not reversible, never logged with token material.

Enums§

Account
A concrete account slot for a provider.
AccountSelector
What a caller asks for when no explicit account is given.

Constants§

AUTO_ACCOUNT_NAME
Reserved selector word for opt-in automatic selection (G5).
DEFAULT_ACCOUNT_NAME
Reserved word for the bare provider slot. Never a label.

Functions§

account_config_key
Config key carrying the selected account for a provider.
account_env_var
Environment variable that selects the account for a provider: SYNAPS_ACCOUNT_<PROVIDER> with - → _, upper-cased.
seat_fingerprint
Stable, opaque seat fingerprint: hex SHA-256 over a domain tag, the provider id and the provider’s FULL account id (e.g. the Codex chatgpt_account_id claim). Deterministic across processes and hosts, so a consumer holding a vended token can derive the same value from that token’s claim and compare it with AccountSummary::seat_fingerprint before spending on the listed seat. Never derived from token material.