UNPKG

tezx

Version:

TezX is a modern, ultra-lightweight, and high-performance JavaScript framework built specifically for Bun. It provides a minimal yet powerful API, seamless environment management, and a high-concurrency HTTP engine for building fast, scalable web applicat

39 lines (38 loc) โ€ข 1.36 kB
import { Middleware, ResHeaderKey } from "../types/index.js"; export type SanitizeHeadersOptions = { /** * ๐ŸŸข Whitelist of allowed headers (case-insensitive) * @default [] (allow all if empty) * @example * whitelist: ['content-type', 'authorization'] // Only allow these headers */ whitelist?: ResHeaderKey[]; /** * ๐Ÿ”ด Blacklist of disallowed headers (case-insensitive) * @default [] (block none if empty) * @example * blacklist: ['x-powered-by', 'server'] // Block server info headers */ blacklist?: ResHeaderKey[]; }; /** * ๐Ÿงผ Middleware to sanitize HTTP headers for security and compliance * * Removes dangerous headers, enforces allow/block lists, and normalizes headers. * Protects against header injection and information leakage. * * @param {SanitizeHeadersOptions} [options={}] - Configuration options * @returns {Middleware} Middleware function * * @example * // Basic usage with defaults * app.use(sanitizeHeaders()); * * // Strict configuration * app.use(sanitizeHeaders({ * whitelist: ['accept', 'content-type'], * normalizeKeys: true * })); */ declare const sanitizeHeaders: <T extends Record<string, any> = {}, Path extends string = any>(options?: SanitizeHeadersOptions) => Middleware<T, Path>; export { sanitizeHeaders as default, sanitizeHeaders };