/** * SMI-732: Input Sanitization Library * SMI-750: Added input length limits to prevent ReDoS attacks * * Provides comprehensive input sanitization functions for: * - HTML content (XSS prevention) * - File names (path traversal prevention) * - File paths (directory traversal prevention) * - URLs (injection prevention) * * All functions are defensive and return safe defaults on invalid input. * All functions accept maxLength parameter to prevent ReDoS attacks. */ export { isValidStripeId, sanitizeStripeCustomerId, sanitizeStripeSubscriptionId, sanitizeStripePriceId, sanitizeStripeInvoiceId, sanitizeStripeEventId, } from './stripe-validators.js'; /** Default maximum input length for sanitization functions to prevent ReDoS */ export declare const DEFAULT_MAX_LENGTH = 100000; /** * Sanitize HTML content to prevent XSS attacks * * Removes dangerous tags, attributes, and JavaScript while preserving safe HTML. * Uses a whitelist approach for maximum security. * * @param input - Raw HTML string * @param maxLength - Maximum allowed input length (default: 100000) * @returns Sanitized HTML safe for rendering * * @example * ```typescript * sanitizeHtml('

Hello

') * // Returns: '

Hello

' * ``` */ export declare function sanitizeHtml(input: string, maxLength?: number): string; /** * Sanitize file name to prevent path traversal and invalid characters * * Removes: * - Path separators (/, \) * - Parent directory references (..) * - Hidden file markers (leading .) * - Special characters that are invalid in file names * - Control characters * * @param name - Raw file name * @param maxLength - Maximum allowed input length (default: 100000) * @returns Safe file name or empty string if invalid * * @example * ```typescript * sanitizeFileName('../../../etc/passwd') * // Returns: 'etcpasswd' * * sanitizeFileName('my-file.txt') * // Returns: 'my-file.txt' * ``` */ export declare function sanitizeFileName(name: string, maxLength?: number): string; /** * Sanitize file path to prevent directory traversal attacks * * Ensures the path: * - Does not escape the root directory * - Contains no parent directory references * - Uses forward slashes consistently * - Is normalized * * @param path - Raw file path * @param rootDir - Root directory to constrain path to (optional) * @param maxLength - Maximum allowed input length (default: 100000) * @returns Safe path or empty string if invalid * * @example * ```typescript * sanitizePath('../../../etc/passwd', '/app/data') * // Returns: '' * * sanitizePath('user/files/doc.txt', '/app/data') * // Returns: 'user/files/doc.txt' * ``` */ export declare function sanitizePath(path: string, rootDir?: string, maxLength?: number): string; /** * Sanitize URL to prevent injection attacks * * Validates: * - Protocol is http or https * - No javascript:, data:, or vbscript: protocols * - No embedded credentials * - Valid URL structure * * @param url - Raw URL string * @param maxLength - Maximum allowed input length (default: 100000) * @returns Sanitized URL or empty string if invalid * * @example * ```typescript * sanitizeUrl('javascript:alert(1)') * // Returns: '' * * sanitizeUrl('https://example.com/page') * // Returns: 'https://example.com/page' * ``` */ export declare function sanitizeUrl(url: string, maxLength?: number): string; /** * Sanitize arbitrary text input for safe storage and display * * Removes: * - Control characters * - Zero-width characters * - Invalid Unicode * * @param input - Raw text input * @param maxLength - Maximum allowed input length (default: 100000) * @returns Sanitized text * * @example * ```typescript * sanitizeText('Hello\x00World\u200B') * // Returns: 'HelloWorld' * ``` */ export declare function sanitizeText(input: string, maxLength?: number): string; //# sourceMappingURL=sanitization.d.ts.map