Skip to content

feat(ceremony): tell an expired authorization code apart - #186

Merged
Wondertan merged 3 commits into
mainfrom
feat/authorization-expired
Nov 20, 2026
Merged

Wondertan merged 3 commits into
mainfrom
feat/authorization-expired

Conversation

@Wondertan

@Wondertan Wondertan commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

An expired authorization code now fails as authorization-expired, which applications can catch and explain, instead of an unexplained platform refusal.

A slow connection can spend longer setting up the notarized token request than the platform keeps its authorization code. On Nov 20 an X run's token setup took 94 s on a high-latency link, and X refused the code; with #182 the refusal is visible, but it still looks like any other.

Changes

  • Measured, per platform: each notarized platform's provider.ts declares expiredCode, its answer to an expired code and the code's lifetime.
    • X: 400 invalid_request with "Value passed for the authorization code was invalid." (the description is matched too, since invalid_request alone names other failures). Lifetime 25 s: real codes redeemed from X's redirect were accepted at 10, 15, 18, 21, 22, 23 and 24 s and refused at 25 and 40 s.
    • GitHub: 200 bad_verification_code. Lifetime 600 s, the 10 minutes GitHub documents: real codes were accepted at 540 s and refused at 660 s with that answer.
  • The rule: when the token request is refused with exactly that answer and the Prover has run at least the lifetime (prover-ms, a lower bound on the code's age), platform-refusal carries reason: 'authorization-expired' and the failure text starts with "X did not accept the sign-in: it expired after N s, while this connection set up the proof. Check your connection and try again." Timing alone never sets it; a refusal before the lifetime keeps no reason.
  • Client: a failure of the operation that event named becomes CeremonyError with reason: 'authorization-expired' (new optional property).
  • Spec and docs: specs/ccdp.md defines this one reason, carried by the event, never by CeremonyFailed. docs/metrics.md documents the attribute. docs/provers.md (Adding a platform) requires measuring a notarized platform's code lifetime and exact expired-code answer with real codes before release.

Verified

  • @libid/ceremony tests: 1070 passed, covering for GitHub and X the expired-code answer before and after the lifetime, and a different answer however late; and the client attaching the reason only to the failure the event named.
  • pnpm -C ts lint, fmt:check and the ceremony typecheck pass.
  • X's and GitHub's answers and lifetimes were measured against the real token endpoints with real codes.

Not verified / known issues

  • Browser e2e not run locally; CI runs it.

🤖 Generated with Claude Code

A slow connection can spend longer setting up the notarized token request than the platform keeps its authorization code: X refuses one older than about 25 s. The refusal then looked like any other.

Each notarized platform now declares its measured answer to an expired code and the code's lifetime. When the token request is refused with exactly that answer and the Prover has run at least that long, platform-refusal carries reason authorization-expired, the failure text says to check the connection, and the Client raises a CeremonyError with that reason. Timing alone never sets it. X's answer and lifetime were measured with real codes (accepted up to 24 s, refused at 25 s); GitHub's answer was measured and its lifetime is the documented 10 minutes until measured. Adding a platform now requires the measurement.

Assisted-by: Claude Opus 5.5
Signed-off-by: Wondertan <hlibwondertan@gmail.com>
Real GitHub codes redeemed from the redirect were accepted at 540 s and refused at 660 s with bad_verification_code, bracketing the 10 minutes GitHub documents.

Assisted-by: Claude Opus 5.5
Signed-off-by: Wondertan <hlibwondertan@gmail.com>
Ships authorization-expired: CeremonyError.reason for a platform-refused, expired authorization code.

Assisted-by: Claude Opus 5.5
Signed-off-by: Wondertan <hlibwondertan@gmail.com>
@Wondertan
Wondertan merged commit 321ce7c into main Nov 20, 2026
15 checks passed
@Wondertan
Wondertan deleted the feat/authorization-expired branch November 20, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant