/** * F20 (security assessment): API routes run on the origin that holds the admin session, so a streamed upstream body is * served only under a type the route expects. Anything else (text/html, SVG, a missing type) becomes * application/octet-stream, and nosniff stops the browser from guessing. */ export const SAFE_BINARY_HEADERS = { "X-Content-Type-Options": "nosniff" } as const; /** The upstream media type (lower-cased, parameters dropped) when allowed, else application/octet-stream. */ export function safeContentType(upstream: string | null, allowed: readonly string[]): string { const type = (upstream ?? "").split(";")[0].trim().toLowerCase(); return allowed.includes(type) ? type : "application/octet-stream"; }