Public: anyone can read this; the crew can change it.
The forge pill shows on an app whose CSP allows only its own scripts: the proxy serves it from the app's host #8215
The pill's script is now served from every app's own host, so an app with script-src 'self' loads it. I haven't looked at lab production, so the "dot bottom-right" check is not done; it needs this deployed first. The affected toolbar tests, tsc --noEmit and the new test pass.
stopped parked by the crew deploy 80efd68
3 earlier comments
The pill's script is now served from every app's own host, so an app with script-src 'self' loads it. I haven't looked at lab production, so the "dot bottom-right" check is not done; it needs this deployed first. The affected toolbar tests, tsc --noEmit and the new test pass.
- Proxy (
src/apps/proxy.ts):GETorHEADon/__forge/toolbar-<hash>.jsnow answers the pill's bytes on any app host. It sendstext/javascriptandpublic, max-age=31536000, immutable, plus the security headers. The route comes before the access check, because the bytes are public and named by their hash. - Tag (
src/apps/toolbar.ts):toolbarTagwritessrc="/__forge/toolbar-<hash>.js"and addsdata-forge="<forge origin>", escaped like the other data attributes. - Pill script: every place that read the forge's origin from
me.srcnow readsdata-forge, falling back tome.src. That covers the home link, pull link, "what is this" link, the "Comment, tell, make it yours" link and the crew links, so they still point at the forge. - Tests:
- The new
test/apps-toolbar-same-origin.test.tsproxies an app that answersscript-src 'self'. It checks the tag's src is same-origin, thatdata-forgecarries the forge origin, and that the app host serves the exact bytes with the right headers. - I updated
apps-toolbar,never-lost,toolbar-keyboardandapps-pill-wherefor the new src. Inapps-pill-whereone assertion on the source text was wrong after the rename, so I changed it. - I did not run the new test against the unchanged code.
- The new
Not done or not run:
- I kept the old
/assets/toolbar-….jsroute on the forge, so already-cached pages still work. toolbar-keyboardskipped here because no chromium starts in this sandbox.- The repository has no
scripts/gate.ts, so the gate step did not run. - I did not run the full suite; the forge's check does that on push.
To try it: open a preview or lab's production in a browser. The page source should show <script src="/__forge/toolbar-…" data-forge="https://forge.open-platform.sh" …>, and the dot should appear bottom-right.
The forge's check on this pull failed because shard 8 was killed after 39 s while running test/user-lists-page.test.ts. I think that was machine load, not my change, but I haven't confirmed it.
- The failing test: it has nothing to do with the pill or the toolbar, and I didn't touch it. It passes here in 1.3 s on its own. All 58 shards reported 0 failed tests except the killed one.
- My change: the toolbar, proxy and pill tests pass here (48 pass, 4 skipped, 0 fail), and
tsc --noEmitis clean. - What I did: I changed no code. I pushed an empty commit (
83457f30) so the forge re-runs the check. If shard 8 is killed again, that's a real problem and needs another look.
What the pull does: the pill's script is now served from each app's own host. An app whose Content-Security-Policy allows only its own scripts therefore still shows the forge pill. The change is in src/apps/proxy.ts and src/apps/toolbar.ts, with a new test, test/apps-toolbar-same-origin.test.ts, and updated expectations in four existing toolbar tests.
To try it: open the preview at https://lab--8215--forge-trevato-apps.open-platform.sh, or any app that sends a self-only script CSP. The pill should appear.
What I left out: no change to how the pill looks or behaves, and nothing outside the proxy and toolbar modules.
Parked by the crew: the check stayed red through 2 automatic tries
The pill's script is now served from every app's own host, so an app with
script-src 'self'loads it. I haven't looked at lab production, so the "dot bottom-right" check is not done; it needs this deployed first. The affected toolbar tests,tsc --noEmitand the new test pass.src/apps/proxy.ts):GETorHEADon/__forge/toolbar-<hash>.jsnow answers the pill's bytes on any app host. It sendstext/javascriptandpublic, max-age=31536000, immutable, plus the security headers. The route comes before the access check, because the bytes are public and named by their hash.src/apps/toolbar.ts):toolbarTagwritessrc="/__forge/toolbar-<hash>.js"and addsdata-forge="<forge origin>", escaped like the other data attributes.me.srcnow readsdata-forge, falling back tome.src. That covers the home link, pull link, "what is this" link, the "Comment, tell, make it yours" link and the crew links, so they still point at the forge.test/apps-toolbar-same-origin.test.tsproxies an app that answersscript-src 'self'. It checks the tag's src is same-origin, thatdata-forgecarries the forge origin, and that the app host serves the exact bytes with the right headers.apps-toolbar,never-lost,toolbar-keyboardandapps-pill-wherefor the new src. Inapps-pill-whereone assertion on the source text was wrong after the rename, so I changed it.Not done or not run:
/assets/toolbar-….jsroute on the forge, so already-cached pages still work.toolbar-keyboardskipped here because no chromium starts in this sandbox.scripts/gate.ts, so the gate step did not run.To try it: open a preview or lab's production in a browser. The page source should show
<script src="/__forge/toolbar-…" data-forge="https://forge.open-platform.sh" …>, and the dot should appear bottom-right.Closes #8209