/** * Response security headers. * * Ownership model: * - The app emits the browser-facing policy for every response that reaches * `handle`: `Content-Security-Policy`, `Referrer-Policy`, * `Permissions-Policy`, `X-Frame-Options`, `X-Content-Type-Options`, * `Cross-Origin-Opener-Policy`. * - Static assets and prerendered pages are served by adapter-node's sirv * (Vite in dev) *before* hooks run, so they never pass through here. * - The TLS edge (Caddy, backend repo) owns what the app cannot see — HSTS, * TLS, body limits, `-Server` — and emits its own copies of the headers * above with set-if-absent (`header ?Name`) semantics, so the app's values * win wherever the app sends them and sirv-served assets still get a * baseline. Keep the two in agreement. * * Split of the CSP header itself: * - `svelte.config.js` (`kit.csp`) declares `script-src` because Kit must * own that directive to append its per-request nonce, plus the three * directives that must survive an `ADAPTER=static` build (no hooks there). * - Everything else is built here at runtime so instance-specific hosts * come from the environment instead of the build. * * Pure: no env access, no SvelteKit imports. `hooks.server.ts` wires it up. */ import { EMBED_FRAME_ORIGINS } from '$lib/app/util/embed-hosts' export interface SecurityHeaderOptions { /** Vite dev server: HMR needs inline `