- withSecurityConfig: poweredByHeader false + strips X-Powered-By from headers()
(Next's and withPayload's), works on either side of withPayload
- buildSecurityHeaders({ csp }): CSP + Reporting-Endpoints; mode switches
report-only → enforce
- buildCsp: reportUri/reportGroup, nonce + strict-dynamic, dev unsafe-eval,
metaPixel/linkedIn/tiktok/clarity flags, media-src for R2, override
- buildAdminCsp(Headers): looser policy for Payload admin (Monaco CDN, blob workers)
- createCspReportRoute + parseCspReports: report collector for both formats
- createProxy({ csp }) + createCspNonce: per-request nonce, x-nonce header;
SiteProviders/ThemeScript/Analytics/ConsentScript accept nonce
- docs: security.md, AGENT.md, ipal-setup/reference/upgrade; ipal-audit checks
Co-Authored-By: Claude Opus 5.5 <[email protected]>
11 lines
368 B
TypeScript
11 lines
368 B
TypeScript
/** Request header the proxy uses to hand the nonce to server components. */
|
|
export const CSP_NONCE_HEADER = 'x-nonce'
|
|
|
|
/**
|
|
* A fresh per-request nonce (base64 of a random UUID, 128 bits of randomness).
|
|
* Works in the Edge and Node runtimes (Web Crypto + btoa are globals in both).
|
|
*/
|
|
export function createCspNonce(): string {
|
|
return btoa(crypto.randomUUID())
|
|
}
|