Expand description
Codewhale-owned OAuth login and protected credential lifecycle. ChatGPT uses its official dynamic registration and direct inference grant. Providers are data rows in the parameter table below, not modules.
External Codex CLI credentials are read only after an exact, provider-scoped consent grant. Codewhale never refreshes or rewrites that external file.
§Security
Token values are never logged or printed. All debug representations redact sensitive fields.
Structs§
- Browser
Auth Request - A browser authorization request in flight: state, PKCE pair, and the registered redirect the callback server answers on.
- Chatgpt
Keys - Chatgpt
Registration - Verified registration identity. The client ID also binds the selected workspace. One active registration is supported; use CODEWHALE_CHATGPT_NEW_ACCOUNT=1 to explicitly replace it after a new, fully validated browser sign-in.
- Codex
Credentials - Resolved OAuth credentials ready for API use.
- OAuth
Activation - Receipt for a committed Codewhale-owned OAuth generation.
- OAuth
EnvOverrides - Test/dev knobs a provider reads from the environment. Data, so a new provider adds rows here instead of a new module.
- OAuth
Provider Params - Everything about one provider’s OAuth login that is not logic.
- OAuth
Token Material - Token material from a completed grant. No Debug: the tokens never print.
intervalrides along because aslow_downerror response may carry the server’s new minimum, which the loop prefers over its own tracked value (RFC 8628 §3.5; WSL/VM clock drift). - Orca
Credential - The credential the rest of Codewhale consumes for OrcaRouter.
- Orca
Login Inputs - Where an injected OrcaRouter login reads its inputs from. Tests override this so the whole adapter — bind, authorize URL, callback, exchange — runs against a local fake auth server with no network egress.
- Owned
Auth Entry - One entry in a Codewhale-owned auth generation. Reads both historical
on-disk shapes;
keywas the xAI/Grok field name for the access token. - OwnedO
Auth Credentials - Resolved owned credentials ready for API use. No Debug: bearer material never prints; consumers redact explicitly.
- PendingO
Auth Login - A completed login awaiting activation (owned-generation commit). The provider is the table row it resolved through; unified activation (3b-ii) matches on it.
- Pkce
Challenge - RFC 7636 S256 PKCE pair. Custom Debug: the verifier is exchanged for bearer material and never prints.
- PluginO
Auth Config - Declarative public OAuth configuration for a reviewed plugin provider.
- PluginO
Auth Tokens - ReqwestO
Auth Form Client - ResolvedO
Auth Inputs - Resolved login inputs: schema defaults, environment-tested in order.
- Usable
Sign In - A subscription sign-in the structural check found usable, named by the same read that proved it usable. Holds a display label only.
Enums§
- Callback
Outcome - Parsed callback query: a code+state pair, or the issuer’s refusal.
- OAuth
Provider - Providers with an OAuth login Codewhale can own.
- Orca
Callback - Orca
Credential Source - How an
OrcaCredentialwas obtained. Presentation only: it selects copy, never behaviour. Nothing downstream of the credential seam may read it to decide whether the key is usable.
Constants§
- CALLBACK_
TIMEOUT - CHATGPT_
OAUTH_ CLIENT_ ID - CHATGPT_
OAUTH_ ISSUER - ChatGPT issuer and public client.
- CHATGPT_
OAUTH_ PARAMS - CHATGPT_
OAUTH_ RESOURCE - CHATGPT_
OAUTH_ SCOPE - DEFAULT_
SCOPES - GROK_
OIDC_ CLIENT_ ID - ORCAROUTER_
API_ BASE - OrcaRouter’s public inference/catalog origin.
- ORCAROUTER_
APP_ ID - ORCAROUTER_
APP_ NAME - Shown on the OrcaRouter consent screen.
- ORCAROUTER_
AUTHORIZE_ PATH - Consent endpoint path. Not an API route: the browser is pointed at it.
- ORCAROUTER_
AUTH_ BASE - OrcaRouter’s public authentication origin. Inference lives on a different
host (
https://api.orcarouter.ai/v1); neither origin is derived from the other. - ORCAROUTER_
CLIENT_ ID - OrcaRouter’s authorize contract carries no client id: this public label is a constant, not a secret. PKCE — not a client secret — binds the auth code to this process.
- ORCAROUTER_
EXCHANGE_ PATH - Code-for-key exchange path under the auth origin. The relay’s
/v1/auth/keysis a different route and a 404; the auth API lives at/api/v1/auth/keys. - ORCAROUTER_
OAUTH_ PARAMS - ORCAROUTER_
REF - ORCAROUTER_
SCOPE - The scope this client asks for, and the only scope it accepts back.
- XAI_
OAUTH_ PARAMS - XAI_
OIDC_ ISSUER - xAI issuer and public client (constants the params rows and the route surfaces share).
Traits§
Functions§
- account_
label_ from_ id_ token - Non-secret account label from an ID token’s claims, decoded locally:
email,email (plan), or for a workspace planemail (plan, workspace 1a2b3c4d). The signature is not verified: the label is for display only and never authorizes anything. Claim text is bounded and stripped of control characters so a hostile token cannot smuggle terminal escapes into status output.Nonewhen no usable email claim exists. - activate_
login - Commit a pending login as a uniquely named owned generation and atomically point the provider’s config table at it under the shared config lock.
- activate_
orcarouter_ credential - Persist an
OrcaCredentialthrough the host’s ordinary, transactional provider-credential path. - auth_
file_ path - Resolve the path to the Codex auth file.
- auth_
mode_ uses_ xai_ oauth - Whether
[providers.xai] auth_modeselects the OAuth path. - bind_
loopback_ callback - Bind ChatGPT’s exact 127.0.0.1 callback, with an ephemeral-port fallback. Other providers using localhost bind both IP stacks when available.
- bind_
orcarouter_ callback - Bind the OrcaRouter loopback callback: always
127.0.0.1, ephemeral port. - build_
authorize_ url - build_
orcarouter_ authorize_ url - The OrcaRouter authorize URL.
- clear_
dangling_ generation - Best-effort repair for the #5032 bricked-launch state: remove the stale
oauth_credential_generationpointer from the PERSISTED config file so the next launch is no longer bricked. Mirrors the document edits inactivate_login_locked(which replaces the pointer under the config lock) andcrate::config::clear_api_key’s unlocked scrub. - cli_
challenge_ writer - Terminal-or-stdout challenge writer for shell commands that drive a login
outside the TUI (
codewhale auth ...). - credentials_
present - credentials_
valid - Prompt-free structural check for owned OAuth material. Never refreshes, writes, or makes network requests. External storage is not inspected until exact read-only consent has been persisted, and then only at the exact consented path — no ambient candidate is ever resolved or opened (#5772).
- device_
code_ login - Interactive device-code login for any provider whose row offers it. Shows the verification URL + user code only on a terminal and polls until approved. A provider with no device flow (ChatGPT) fails here with the reason, instead of deep in transport code.
- exchange_
orcarouter_ code - Exchange an OrcaRouter auth code for a durable API key.
- generate_
pkce - RFC 7636 S256 PKCE pair.
- generate_
state - get_
credentials - Load read-only credentials from the exact external path authorized by
grant. Expired tokens fail with guidance; they are never refreshed. - get_
owned_ credentials - Load owned subscription credentials from the configured generation, refreshing through the seam when stale.
- get_
owned_ credentials_ read_ only - Read-only diagnostics: never refreshes or changes protected storage.
- get_
xai_ credentials - Load xAI OAuth credentials with full precedence: configured generation, legacy owned file, then the consented Grok CLI import. Codewhale-owned credentials may refresh and rewrite Codewhale-owned storage; external credentials are read-only.
- grok_
auth_ file_ path - Resolve the Grok CLI auth file path.
- login
- One login entry point for every provider: the params row decides whether the grant is device-code or browser PKCE. A provider with neither fails here with the reason.
- login_
with_ config - Reauthorize the registration selected by the caller’s actual config.
- missing_
auth_ message - oauth_
provider_ params - The parameter table. A provider login looks its row up here; adding a provider means adding a row, never a module.
- official_
chatgpt_ registration - Metadata only: no network, refresh, token return, or external credential import.
- orcarouter_
exchange_ url - The OrcaRouter code-for-key exchange endpoint, always on the auth origin.
- orcarouter_
pkce_ login - One interactive OrcaRouter PKCE login.
- owned_
account_ label_ for_ generation - Account label of the Codewhale-owned sign-in stored in one generation
file. Reads only that file; never refreshes, writes, or touches the
network.
Ok(None)when the usable entry’s ID token carries no email;Err(a fixed, token-free reason) when the generation name is invalid, the file is missing or unreadable, or it holds no usable sign-in. - owned_
generation_ is_ dangling - Detect the #5032 bricked-launch state: the provider’s config selects
OAuth and points
oauth_credential_generationat a Codewhale-owned credential file that no longer exists. This is a distinct, more specific failure than “unconfigured” — the pointer is present and authoritative, socredentials_validreturns false and cannot fall through to a legacy or external credential, which is exactly what bricked the dogfood machine. - owned_
oauth_ account_ label - Non-secret account label (email, plan) of the Codewhale-owned
subscription sign-in stored in
generation, forcodewhale auth statusandauth list. Reads only that Codewhale-owned file: no refresh, no network, no external CLI file.Errcarries a fixed, token-free reason the sign-in is unusable (missing, unreadable, no usable entry). - parse_
callback_ query - pin_
plugin_ oauth_ grant - pkce_
login - Interactive PKCE browser login for any provider whose row offers it. Shows the authorize URL only on a terminal, opens a browser, and waits for the loopback callback. A provider with no browser flow (xAI) fails here with the reason, before any listener binds.
- plugin_
oauth_ access_ token - Resolve only the exact provider, endpoint and descriptor-bound credential. Async consumers must call this sync secure-store/HTTP worker off-runtime.
- plugin_
oauth_ access_ token_ for_ grant - plugin_
oauth_ credentials_ present - Prompt-free stored-login status. Readiness reads only this exact host-owned secure slot, without refreshing, migrating or contacting the issuer.
- plugin_
oauth_ logout - Local logout is authoritative; declarative plugins do not get a remote revocation hook or raw refresh token.
- plugin_
oauth_ slot - plugin_
token_ response - resolve_
orcarouter_ api_ base - Resolve the OrcaRouter inference/catalog origin.
- resolve_
orcarouter_ auth_ base - Resolve the OrcaRouter authentication origin.
- revoke_
owned_ login - Remove Codewhale-owned tokens and the config pointer for one provider.
- start_
orcarouter_ auth_ request - Build the loopback callback URL + authorize URL for one OrcaRouter attempt.
- usable_
sign_ in credentials_valid, also naming the account of the entry that passed: the configured Codewhale-owned generation, else (xAI) the legacy owned file or the consented Grok CLI import — the credential the route would send. Readiness surfaces take the label from here so naming the account costs no second credential read.- usage_
limit_ guidance - What to tell someone whose subscription sign-in hit a plan limit: which account made the request (label only, never a token) and how to sign in with a different one, both inside a running session and from a shell. A shell login does not reach a session that is already open, so the shell route says to restart.
- validate_
grok_ external_ credentials - Grant-time validation for an external Grok CLI credential file (#5772).
- wait_
for_ callback_ validated - wait_
for_ orcarouter_ callback