Expand description
PKCE Authorization Code flow for Cognito desktop login.
Flow (cloud-relayed callback — no loopback listener; see docs/specs/SPEC_MUXBUS_CLOUD_RELAYED_LOGIN_CALLBACK_2026_08_15.md):
- Generate code_verifier + code_challenge (S256).
- Register the flow’s state with the muxbus login relay.
- Open browser to Cognito hosted UI; it redirects to the hosted /desktop-callback page, which posts {state, code} to the relay.
- Poll the relay for the code (single-read on the relay side).
- Exchange code for tokens via /oauth2/token (PKCE verifier never left this process).
- Decode email from id_token claims (no re-verification needed — we fetched the token directly from Cognito).
Structs§
Enums§
- Refresh
Token Error - Typed so callers (the credential broker’s registered
refreshclosure) can distinguish “worth retrying” from “this refresh_token is dead, only a fresh login fixes it” without string-sniffing an error message.Rejectedspecifically means the token endpoint responded but rejected the request (Cognito’sinvalid_grant-class 4xx for a revoked/expired refresh_token) — the credential itself is the problem.Network/ParseFailedmean the ATTEMPT failed, not the credential.
Constants§
Statics§
Functions§
- cancel_
active_ login - Abort the in-flight login flow, if any. Returns false if there was none (a harmless no-op — the UI can call this without checking state first).
- extract_
jwt_ 🔒claims - percent_
encode 🔒 - refresh_
token - run_
pkce_ login - run_
pkce_ 🔒login_ inner - token_
sub 🔒 - The
subclaim of a Cognito token (unverified decode: this names the account a token we already hold belongs to, it doesn’t authenticate it). Empty if the token isn’t a JWT or has nosub.