fix(host): extract show-token from packed orionUrl for bundle auth#20
Merged
Conversation
The Pulsar browser source addresses Solar with a single packed URL
(`index.html?orion=<orionUrl>&mode=broadcast`) where the show-token lives
inside `orionUrl`'s query (`…/show/stream.lsdp?token=<SHOW>`), not as a
top-level `?token=`. The host/dev entries read `params.get("token")` and got
"", so `mount({ token: "" })` → the runtime resolved an empty token → the
render-bundle GET went out header-less → Orion behind ZabGate replied 401 →
black frame (BUNDLE_FETCH_FAILED). This is the missing half of the 0.2.6
runtime auth-header fix, which assumed Solar already forwarded the token.
Resolve the show-token from the packed orionUrl (explicit top-level `?token=`
wins, else the embedded one) and pass it to mount({ token }); the runtime then
attaches `Authorization: Bearer <show-token>` to the bundle fetch. Solar-only,
no @lumencast/runtime change, no new dependency, mount()/SolarError surface
unchanged. An end-to-end test mounts the real runtime against the browser-source
URL shape and asserts the bundle GET carries the header.
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.
Cause (the last live-finale link)
BUNDLE_FETCH_FAILED: 401onGET …/orion/api/v1/scenes/{id}/render-bundle?v={hash}→ black frame.The runtime (
@lumencast/runtime0.6.0) is correct end-to-end:mount.tswiresgetAuthToken: () => ws.resolveCurrentToken(), which returnsMountOptions.token, and the bundle fetcher attachesAuthorization: Bearer <token>iff that token is non-empty. The runtime does not mine the WS URL for a token — it relies on the explicittokenoption.The bug is purely Solar host-entry. The Pulsar browser source packs everything into one URL:
The show-token lives inside the
orion=value's query, not as a top-level?token=.host-entry.tsx/dev-entry.tsxreadparams.get("token")→""→mount({ token: "" })→ emptyresolveCurrentToken()→ header-less fetch → 401. This is the missing half of the 0.2.6 runtime fix, which assumed Solar already forwarded the token.Fix — Solar-only (0.2.8), no Lumencast release
New pure helper
resolveShowToken(orionUrl, explicitToken): explicit top-level?token=wins, else the token embedded inorionUrl, else"". Both entries use it and pass the result tomount({ token }). The runtime then attachesAuthorization: Bearer <show-token>.@lumencast/runtimechange, no new dependency.mount()/SolarErrorpublic surface unchanged (patch).?token=deliberately stays out of the bundle URL (orion-bundle-url.tsdrops the query) — per the proof matrix, query-token = 401; header = 200.Empirical proof (not "it compiles")
tests/unit/bundle-fetch-auth.test.tsxmounts the real runtime via Solar'smount()against the browser-source URL shape (fake WS + fake fetch), drives a snapshot, and asserts:Authorization: Bearer <show-token>;Plus
resolve-show-token.test.ts(5 unit cases). Confirmed in the built host bundle:searchParams.get("token")+getAuthToken+Authorizationall present.Verification (run, not asserted)
npm run lint(src/ + tests/) → cleannpm run typecheck→ cleannpm test→ 29 passednpm run build→ green (host bundle regenerated)Release / deploy (Keeper)
Solar = vendored/static-served artifact, no auto-deploy. On merge: tag
v0.2.8→release.ymlpublishesdist/(CHANGELOG 0.2.8 entry ready). Then Orion static-serves the new bundle and/or Prism vendorsresources/solar/v0.2.8/. The Pulsar browser source needs no change — same packed URL.🤖 Generated with Claude Code