/** * The headers every answer carries — one chokepoint, applied last. * * The site is static pages with no script, no form and nothing from another * host. Their look is one stylesheet of the site's own (/cotton.css), with a * style attribute on the app icons (the name a page change morphs between); * its fonts, icons and screenshots are the site's own files, and the one * picture the stylesheet draws inline (a tick) is a data: URL. So the policy * allows those, and nothing else. */exportconst CONTENT_SECURITY_POLICY = ["default-src 'none'","style-src 'self' 'unsafe-inline'","img-src 'self' data:","font-src 'self'","form-action 'none'","base-uri 'none'","frame-ancestors 'none'","upgrade-insecure-requests",].join("; ");exportconst SECURITY_HEADERS: Readonly<Record<string, string>> = {"Strict-Transport-Security": "max-age=31536000; includeSubDomains","X-Content-Type-Options": "nosniff","Referrer-Policy": "strict-origin-when-cross-origin","Permissions-Policy": "camera=(), microphone=(), geolocation=()","Content-Security-Policy": CONTENT_SECURITY_POLICY,};/** The response, with the site's headers stamped on (a redirect included). */exportfunction withSiteHeaders(response: Response): Response {const headers = newHeaders(response.headers);for (const [name, value] ofObject.entries(SECURITY_HEADERS)) headers.set(name, value);returnnewResponse(response.body, { status: response.status, statusText: response.statusText, headers });}