Skip to content

Reconcile registration-delegation with merged II contract; restyle callback page - #50

Merged
aterga merged 4 commits into
mainfrom
claude/registration-merged-contract
Jul 12, 2026
Merged

aterga merged 4 commits into
mainfrom
claude/registration-merged-contract

Conversation

@aterga

@aterga aterga commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What

Two related changes to the Phase-2 registration-delegation flow, both verified against the beta II canister's live .did (fgte5-ciaaa-aaaad-aaatq-cai).

1. Merged mcp_register_v2 contract (correctness)

II's merged frontend and canister no longer echo consent through the server. mcp_register_v2 now takes a single argument, session_key; the user's chosen permissions/max_ttl are captured earlier at prepare_mcp_registration_delegation (stored server-side on an index keyed by P_reg), and mcp_register_v2 recovers both them and the anchor from caller() == P_reg. Our code was still on the older three-argument echo; it kept working only because Candid silently drops the two extra trailing args.

  • The pinned callback page forwards only {delegation, state}.
  • RedeemBody drops permissions/ttl; parse_consent and IiPermissions::from_text are removed.
  • redeem_registration_delegation drops the consent argument and encodes Encode!(&session_der) (one arg). The reply (record { expiration; permissions }) is unchanged and still feeds the read-only guard.
  • A test locks the single-argument wire shape; another locks the reply's queries/all variant labels (the Fix read-only sessions: decode II delegation permissions as opt text #40 shape-drift lesson, moved to where the variant now lives).
  • Module docs and the README Phase-2 section rewritten for the merged shape.

2. Callback page rendering (UX)

GET /oauth/connect/callback shipped a strict CSP (default-src 'none') with no style-src, so the browser silently dropped the page's inline style attribute and rendered "Finishing sign-in..." as unstyled top-left serif text. Fixed by moving styling into a nonce'd <style> block and adding style-src 'nonce-...' to the CSP (no 'unsafe-inline'). The shared stylesheet gives a centered card, a system font, a CSS-only spinner (disabled under prefers-reduced-motion), light/dark theming, lang=en, and an accessible role=status/aria-live region; the error state hides the spinner. The sibling finishing_page and connect_error reuse the same look.

Testing

cargo test: 87 passing. No new build or clippy warnings. The registration-delegation shapes are verified against the beta II canister's live .did.

Notes

  • Branched from main (the prior working branch's remote tip was a closed-PR commit).
  • The commit shows as "Unverified" on GitHub because SSH commit signing is unavailable in this environment (0-byte signing key); the committer email is correct.

🤖 Generated with Claude Code

https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym


Generated by Claude Code

…llback page

Two related changes to the Phase-2 registration-delegation flow, both verified
against the beta II canister's live .did (fgte5-ciaaa-aaaad-aaatq-cai).

Merged mcp_register_v2 contract (correctness)
---------------------------------------------
II's merged frontend/canister no longer echo consent through the server:
mcp_register_v2 now takes a SINGLE argument, session_key. The user's chosen
permissions/max_ttl are captured earlier at prepare_mcp_registration_delegation
(stored server-side keyed by P_reg) and mcp_register_v2 recovers both them and
the anchor from caller() == P_reg. Our code was still on the older 3-arg echo;
it kept working only because Candid silently drops the two extra trailing args.

- Fragment/redeem: the pinned page forwards only {delegation, state}; RedeemBody
  drops permissions/ttl; parse_consent and the fragment reads are removed.
- Redemption: redeem_registration_delegation drops the consent argument and
  encodes Encode!(&session_der) (one arg). The reply (record { expiration;
  permissions }) is unchanged and still feeds the read-only guard.
- Removed RegistrationConsent and IiPermissions::from_text (now dead). The
  IiPermissions variant stays for decoding the reply; a test locks its on-wire
  queries/all labels (the #40 shape-drift lesson, moved to where it now lives).
- Docs (module headers, README Phase-2 section) rewritten for the merged shape.

Callback page rendering (UX)
----------------------------
The pinned callback page shipped a strict CSP (default-src 'none') with no
style-src, so the browser silently dropped the page's inline style attribute and
rendered "Finishing sign-in…" as unstyled top-left serif text. Fixed by moving
styling into a nonce'd <style> block and adding style-src 'nonce-…' to the CSP
(no 'unsafe-inline'). The shared stylesheet gives a centered card, system font,
a CSS-only spinner (disabled under prefers-reduced-motion), light/dark theming,
lang=en, and an accessible role=status/aria-live region; errors hide the spinner.
The sibling finishing_page and connect_error pages reuse the same look.

cargo test: 87 passing; no new build/clippy warnings.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Phase-2 registration-delegation flow to match Internet Identity’s merged mcp_register_v2 Candid contract (single session_key arg, consent recovered server-side by II) and fixes the /oauth/connect/callback UX regression caused by a strict CSP blocking inline styling.

Changes:

  • Reconciles Phase-2 redemption with the merged II contract by removing the echoed consent tuple from the callback fragment, redeem body, and mcp_register_v2 call site (now encodes exactly one argument).
  • Adds contract-shape tests to lock the one-argument mcp_register_v2 wire shape and to pin the on-wire Permissions variant labels (queries/all).
  • Restyles the connect interstitial/error pages using a shared CSS block and updates the pinned callback page CSP to allow nonce’d inline styles via style-src 'nonce-…' (no unsafe-inline).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/identities.rs Updates Phase-2 registration delegation redemption to call mcp_register_v2(session_key) only; removes consent-echo plumbing; adds/updates tests to pin argument shape and permissions variant labels.
src/auth.rs Updates pinned callback fragment/redeem payload to {delegation,state} only; removes consent parsing; adds shared CSS and nonce’d <style> plus CSP style-src for the pinned page; restyles related pages.
README.md Updates Phase-2 protocol documentation to describe the merged II contract and the new fragment/redeem shapes (no consent echo).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Restyle the OAuth connect interstitial/error pages (pinned callback, v1
finishing page, connect error) to the DFINITY brand system, and add the
official DFINITY logo.

- Palette: Parchment #faf9f5 / Ink #1a1a1a / Rust #a8482b, hairline surfaces,
  grid-paper texture; dark theme uses the brand's Bark #14110d / Bone #f0ebe0 /
  Ember #c25a37 via prefers-color-scheme with a data-theme override.
- Typography: editorial serif (Newsreader-style) for the status line, UI sans
  (Inter-style) for the eyebrow/hint, both from CSP-safe system-font stacks.
- Logo: the official gradient-infinity mark + DFINITY wordmark, taken from
  dfinity.org and inlined as SVG so it loads under the pinned page's strict
  default-src 'none' CSP (no external fetch). The wordmark uses currentColor so
  it follows the Ink/Bone text color across themes; the infinity keeps its
  brand gradients.
- Layout: centered card with hairline border and soft shadow, DFINITY logo, an
  "Internet Identity" eyebrow, the rust/ember spinner, and the status line.

Everything stays self-contained (no external fonts/images/stylesheets), so the
pinned callback page still renders under its strict CSP. cargo test: 87 passing.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym
@aterga
aterga marked this pull request as ready for review July 11, 2026 18:42
Copilot AI review requested due to automatic review settings July 11, 2026 18:42
Comment thread src/auth.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/auth.rs Resolved
Comment thread README.md Resolved
Comment thread src/auth.rs Resolved
…docs

Review feedback on PR #50:

- Move the inlined connect-page stylesheet and DFINITY logo out of auth.rs
  into real asset files (src/assets/connect.css, src/assets/dfinity-logo.svg)
  and embed them with include_str!. Content is still compiled into the binary
  (no runtime file I/O, still self-contained under the strict CSP); the served
  HTML is byte-identical. Authoring them as .css/.svg keeps auth.rs readable.
- connect_error: escape `&` first (then `<` and `>`) before interpolating the
  message into HTML, so a message containing `&` or entities can't be
  misread as markup.
- Docs: the README and auth.rs module doc described mcp_register_v2 as
  returning `record { expiration; permissions }`; it actually returns
  `variant { Ok : record { ... }; Err : text }` (a candid Result). Corrected
  both to the full variant shape (the Ok payload carries expiry + access level).

cargo test: 87 passing; no new build warnings.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym
Copilot AI review requested due to automatic review settings July 11, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/identities.rs Resolved
Comment thread src/auth.rs Resolved
Comment thread src/auth.rs Resolved
…hape doc

- Accessibility (Copilot): move role=status / aria-live=polite off the whole
  <main> card and onto just the status <p> on both the pinned callback page and
  the v1 finishing page, so updating the message no longer risks re-announcing
  the logo's aria-label or the eyebrow.
- Docs (Copilot): the identities.rs redeem note still described the
  mcp_register_v2 reply as `record { expiration; permissions }`; correct it to
  the full `variant { Ok : record { ... }; Err : text }` (decoded as
  McpRegisterV2Reply; McpRegisterV2Ok is the Ok payload).

cargo test: 87 passing.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014T9N8USDfNK5yzznPGg7Ym
Copilot AI review requested due to automatic review settings July 11, 2026 19:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

@aterga
aterga merged commit ca1ac02 into main Jul 12, 2026
2 checks passed
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.

3 participants