Skip to content

Carry a host's CSP nonce on every inline block of the browser page - #141

Merged
imanimanyara merged 3 commits into
mainfrom
feat/host-csp-nonce
Nov 6, 2026
Merged

imanimanyara merged 3 commits into
mainfrom
feat/host-csp-nonce

Conversation

@imanimanyara

Copy link
Copy Markdown
Contributor

Summary

The browser page now runs under a host's nonce-based Content-Security-Policy, which ichava.com needs before it can serve the browser at /ichava/icons.

  • A host that sends script-src 'self' 'nonce-…' / style-src 'self' 'nonce-…' hands its nonce to Vite (Vite::useCspNonce()). The page now puts it on the loader's <style> and <script>, the frame <style>, the stylesheet, the module scripts and the dev-server scripts, and writes <meta name="csp-nonce"> for the styles React Aria injects at runtime. Before, those blocks had no nonce and ichava.com's policy blocked them.
  • Without a host nonce, the package's nonce CSP mode supplies core's nonce, as before; with neither, the page writes no nonce. Support\PageNonce resolves which, and Prepaint uses it.
  • HostCspNonceTest renders /ichava/icons with a host nonce and checks every non-JSON <style>/<script> and the meta tag (proved red against the old view); PrepaintTest gains the host-wins and no-nonce cases. docs/tools/host-integration.md gains a Content Security Policy section.

The bundle loads nothing from another origin (its external URLs are documentation links), so 'self', the nonce and img-src 'self' data: cover it.

Verification

Local: vendor/bin/pest (411 passed), phpstan --debug --memory-limit=2G (no errors), laranail-pint --test (passed).

A host with a nonce-based policy (script-src 'self' 'nonce-...') hands its
nonce to Vite. The loader, the frame style, the stylesheet, the module and
dev-server scripts now carry it, and a csp-nonce meta tag gives it to the
styles React Aria injects. Without a host nonce the package's nonce mode
supplies core's, as before.
Copilot AI balanced review requested due to automatic review settings November 6, 2026 10:35

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

A fresh dependency resolution minifies one default parameter differently
(i=void 0 becomes i); no source changed. The committed-build check
compares against exactly this.
The page chunks import ./inertia-app.js with no query, and the layout
loaded the entry with ?v=, so the browser held two copies of the module
and two Inertia contexts: every page threw 'usePage must be used within
the Inertia component' and the browser showed no icons.
@imanimanyara
imanimanyara merged commit e07852c into main Nov 6, 2026
15 checks passed
@imanimanyara
imanimanyara deleted the feat/host-csp-nonce branch November 6, 2026 16:13
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.

2 participants