/** * CSP directive map. Keys are camelCase; values are arrays of source * expressions. A value of `false` removes a default-provided directive. * @typedef {Record} CspDirectives */ /** * @typedef {object} CspOptions * @property {CspDirectives} [directives] * @property {boolean} [useDefaults=true] * @property {boolean} [reportOnly=false] */ /** * @typedef {object} HstsOptions * @property {number} [maxAge=15552000] Seconds. Default 180 days. * @property {boolean} [includeSubDomains=true] * @property {boolean} [preload=false] Requires maxAge >= 1y + includeSubDomains. */ /** * @typedef {'DENY' | 'SAMEORIGIN' | { action: 'DENY' | 'SAMEORIGIN' }} FrameguardOptions */ /** * @typedef {object} PermissionsPolicyOptions * @property {Record} [features] */ /** * A static-value policy option: * true → default value, false → skip, * string / { value } → verbatim override. * @typedef {boolean | string | { value: string } | undefined} StaticHeaderOption */ /** * @typedef {object} HeadersOptions * @property {boolean | CspOptions} [contentSecurityPolicy] * @property {boolean | HstsOptions} [hsts] * @property {boolean | HstsOptions} [strictTransportSecurity] Alias of `hsts`. * @property {StaticHeaderOption} [contentTypeOptions] * @property {StaticHeaderOption} [dnsPrefetchControl] * @property {StaticHeaderOption} [downloadOptions] * @property {StaticHeaderOption} [permittedCrossDomainPolicies] * @property {StaticHeaderOption} [originAgentCluster] * @property {StaticHeaderOption} [xssProtection] * @property {StaticHeaderOption} [crossOriginOpenerPolicy] * @property {StaticHeaderOption} [crossOriginEmbedderPolicy] * @property {StaticHeaderOption} [crossOriginResourcePolicy] * @property {StaticHeaderOption} [referrerPolicy] * @property {boolean | FrameguardOptions} [frameguard] * @property {boolean | PermissionsPolicyOptions} [permissionsPolicy] */ /** * Build a map of HTTP security headers. * * `headers()` with no options ships secure-by-default headers suitable for * an HTTPS API or SSR app. Each policy can be opted out with `false` or * customized via its own options object — see the individual `build*` * functions in `./policies.js` for supported shapes. * * import { headers } from '@exortek/security' * * const map = headers({ * hsts: { maxAge: 31536000, preload: true }, * contentSecurityPolicy: { * directives: { scriptSrc: ["'self'", "https://cdn.example.com"] }, * }, * crossOriginEmbedderPolicy: false, // COEP breaks many embeds * frameguard: 'SAMEORIGIN', * }) * // → { 'Content-Security-Policy': "...", 'Strict-Transport-Security': "...", ... } * * For per-request CSP nonces, use `cspNonce()` and template the resulting * string into `directives.scriptSrc` before calling `headers()`. * * Returns a plain `{ [name]: value }` object. Framework middleware iterates * and calls the framework's response setter; consumers can also assign the * map directly onto a Response. * * @param {HeadersOptions} [options] * @returns {Record} */ declare function headers(options?: HeadersOptions): Record; /** * Generate a fresh CSP nonce. * * A nonce is a random per-response value; embed the SAME nonce in your CSP * `script-src` (as `'nonce-'`) and on every inline `