The host page is a static document that sits between a shell and each napplet. It exists because a srcdoc frame inherits its parent's Content Security Policy, and any shell with a strict policy blocks every napplet. The page has no welshman dependencies, so any web shell can bundle it.
Flotilla's script-src lists hashes of the inline scripts in app.html and has no 'unsafe-inline'. Browsers ignore 'unsafe-inline' when a hash is present, and every napplet is inline script. A test in Chrome 158 confirmed that no napplet can run as a direct child of Flotilla's document, and that a host page fixes it.
Parent of the napplet frame
Napplet script runs
A page with Flotilla's policy: script-src 'self' plus a hash, frame-src 'none'
No
The same page with 'unsafe-inline' added beside the hash
No
A page with script-src 'self' 'unsafe-inline' and frame-src 'none'
Yes
A sandboxed host page with its own policy, inside a page with Flotilla's policy plus frame-src 'self'
Yes
In the last case the napplet's port reached the top page and the two exchanged messages directly. The napplet's origin was null, and it couldn't touch localStorage. The third case shows that frame-src 'none' doesn't block srcdoc frames, because loading one makes no navigation request.
The two tests
Both scripts are in .local/napplets/tests/. Each serves its pages from a local HTTP server and connects to bridge chrome --headless on port 9222.
Verifies bytes, binds the port, serves requests. Adds frame-src 'self'.
Host page
host.html
sandbox="allow-scripts". Prepares the frame, hands the port up, reports faults.
Napplet
srcdoc
sandbox="allow-scripts", under the host page's CSP and the injected one
The host page has an opaque origin, so it can't reach the shell's storage. It makes no network requests. Each host page holds one napplet, and the shell creates a new one for each instance.
Prepares the srcdoc: the CSP meta, the window.napplet bootstrap for the domains the shell names, and Kehto's WebRTC and nested-frame locks
Resolves the manifest and verifies the artifact's signature and hash
Refuses bytes that contain dns-prefetch, preconnect or prerender links
Decides which domains to expose
Accepts exactly one napplet.hello with exactly one port, from its own child
Binds the napplet's identity and scope to the port it receives
Transfers that port to the shell
Serves every request on the port
Reports a second hello, any other window message, a second load event or a child frame inside the napplet
Closes the port and revokes grants on any fault
Forwards diagnostics: CSP violations, errors and unhandled rejections
Shows napplet failures in its own UI
The shell verifies the bytes, so identity never depends on the host page. The host page is still part of the shell's trusted code, because it holds the port before handing it over.
The host page's own policy is inherited by the napplet and by every srcdoc or about:blank frame the napplet creates, and the napplet can't relax it. The host page therefore sets a floor beneath the policy injected into each napplet.
frame-src 'none' doesn't stop the host page from creating the napplet's srcdoc frame, as the tests show. connect-src 'none' is the reason the host page fetches nothing itself.
declare function mountHostPage(container: HTMLElement, src: string, events: HostPageEvents): HostPage
src is the bundled host.html. The function creates the sandboxed frame, waits for the page to load, and accepts messages only from that frame's window.
Each shell bundles the page. A host page loaded from another origin would sit inside every embedding shell's trust boundary: its operator could swap bytes or keep ports, and a shell can't check a cross-origin frame's code. Bundling also keeps napplets working offline in Capacitor builds. Flotilla copies the page to static/napplet/host.html at build time.
A hosted copy at a versioned path still suits prototypes and shells that can't ship static files.
The package starts in the welshman monorepo, with no welshman dependencies. It moves to the napplet org once its API settles.