feat: consume embedded-handoff ZeroID token from URL hash (skip sign-in when framed) - #210
Merged
Conversation
…p sign-in when framed)
When codeoid's web UI is embedded by a host app (Highflame Studio), the host has
already authenticated the user and hands off a short-lived ZeroID token in the
iframe URL hash (#codeoid_token=…). Until now the web UI ignored it and showed
codeoid's own sign-in page inside the frame.
main.tsx now calls consumeEmbedToken() before the app boots: when actually framed
(window.parent !== window) it reads #codeoid_token, stores it in the OAuth-token
slot (so resolveToken uses it and reloads stay signed in), and scrubs the token
from the address bar / history. At the top level ("Open in new tab") it's a no-op,
so a token is never consumed outside the embed path. The daemon still verifies the
token on every WebSocket (JWKS signature, tenancy, expiry), so this skips only the
interactive sign-in — it does not bypass authorization.
Tests: consumeEmbedToken stores + scrubs when framed, resolveToken then picks it
up, other hash state is preserved, and it's a no-op at top level / with no token.
web: vitest run src/lib/auth.test.ts (25) ✅ · tsc -b --noEmit ✅ · eslint ✅
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #210 +/- ##
=======================================
Coverage 88.02% 88.02%
=======================================
Files 129 129
Lines 22045 22045
=======================================
Hits 19405 19405
Misses 2640 2640
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Merged
saucam
added a commit
that referenced
this pull request
Jul 20, 2026
Bump package.json 0.3.1 → 0.3.2 and roll the 0.3.2 CHANGELOG section (the release workflow gates on package.json matching the tag). 0.3.2 carries the SDLC pipeline primitive (#204–#209), the /settings MCP Servers surface (#203), embedded-handoff ZeroID token consumption (#210), and the cross-cutting audit fixes (#211). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When codeoid's web UI is embedded by a host app (Highflame Studio's Agent Sandbox), the host has already authenticated the user and hands off a short-lived ZeroID token in the iframe URL hash —
…/ui/#codeoid_token=<jwt>. But the web UI ignored it and rendered codeoid's own sign-in page inside the frame, so the "SSO" experience dead-ended at a login screen.Fix
main.tsxnow calls a newconsumeEmbedToken()before the app boots:window.parent !== window). At the top level ("Open in new tab") it's a no-op, so a token is never consumed outside the embed path.#codeoid_tokenfrom the hash, stores it in the OAuth-token slot (codeoid.token) viarememberOAuthToken()— soresolveToken()picks it up through its existing OAuth-token fallback and reloads stay signed in.replaceState), preserving any other hash state.Security: the token is a normal ZeroID JWT the daemon still verifies on every WebSocket (JWKS signature, mandatory
account_id/project_id, per-message expiry). This only skips the interactive sign-in; it does not bypass authorization.Companion changes (Highflame side)
#codeoid_tokenwhen framing (highflame-studio).Follow-ups (hardening, not required for this to work)
audience=codeoidand setframe-ancestors/CODEOID_EMBED_ALLOWED_ORIGINSto restrict which hosts may embed (clickjacking) — framing is currently open.Test
web: vitest run src/lib/auth.test.ts→ 25 passed (5 new: stores+scrubs when framed,resolveTokenpicks it up, preserves other hash state, no-op at top level, no-op without a token)tsc -b --noEmit✅ ·eslint src✅