tezx
Version:
TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, an
53 lines (52 loc) โข 1.67 kB
TypeScript
import { Middleware } 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?: string[];
/**
* ๐ด Blacklist of disallowed headers (case-insensitive)
* @default [] (block none if empty)
* @example
* blacklist: ['x-powered-by', 'server'] // Block server info headers
*/
blacklist?: string[];
/**
* ๐ต Normalize header keys to lowercase
* @default true
* @example
* normalizeKeys: false // Preserve original header case
*/
normalizeKeys?: boolean;
/**
* ๐ Allow potentially unsafe characters in header values
* @default false
* @warning Enabling this may reduce security
* @example
* allowUnsafeCharacters: true // Allow CR/LF in headers
*/
allowUnsafeCharacters?: boolean;
};
/**
* ๐งผ 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
* }));
*/
export declare const sanitizeHeaders: (options?: SanitizeHeadersOptions) => Middleware;