/** * Content Security Policy (CSP) Middleware * * Provides configurable CSP headers for Hono applications. * Supports environment-based configuration (stricter in production). * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP */ import type { MiddlewareHandler } from 'hono'; /** * CSP directive values */ export type CSPDirectiveValue = string | string[] | boolean; /** * CSP directives configuration */ export interface CSPDirectives { /** Fallback for other fetch directives */ 'default-src'?: CSPDirectiveValue; /** Valid sources for JavaScript */ 'script-src'?: CSPDirectiveValue; /** Valid sources for stylesheets */ 'style-src'?: CSPDirectiveValue; /** Valid sources for fetch, XHR, WebSockets, EventSource */ 'connect-src'?: CSPDirectiveValue; /** Valid sources for images */ 'img-src'?: CSPDirectiveValue; /** Valid sources for fonts */ 'font-src'?: CSPDirectiveValue; /** Valid sources for media (audio, video) */ 'media-src'?: CSPDirectiveValue; /** Valid sources for , , */ 'object-src'?: CSPDirectiveValue; /** Valid sources for nested browsing contexts (frames) */ 'frame-src'?: CSPDirectiveValue; /** Valid sources for workers and nested browsing contexts */ 'child-src'?: CSPDirectiveValue; /** Valid sources for web workers */ 'worker-src'?: CSPDirectiveValue; /** Valid parents that can embed this page in ,