/** * Security Validators * * Input validation utilities for secure rendering. * * @module @kya-os/consent/security/validators */ /** * Validate that a string is a valid hex color * * Only accepts 6-digit hex colors with # prefix. * * @param color - Color string to validate * @returns The color if valid, undefined otherwise * * @example * ```typescript * validateColor('#2563EB') // Returns '#2563EB' * validateColor('2563EB') // Returns undefined * validateColor('#fff') // Returns undefined (3-digit not allowed) * ``` */ export declare function validateColor(color: string | undefined): string | undefined; /** * Validate that a string is a valid URL * * Only accepts http and https protocols. * * @param url - URL string to validate * @returns The URL if valid, undefined otherwise * * @example * ```typescript * validateUrl('https://example.com') // Returns 'https://example.com' * validateUrl('javascript:alert(1)') // Returns undefined * validateUrl('ftp://files.example.com') // Returns undefined * ``` */ export declare function validateUrl(url: string | undefined): string | undefined; /** * Validate that a string is a valid email address * * Uses a simple but effective email pattern. * * @param email - Email string to validate * @returns The email if valid, undefined otherwise */ export declare function validateEmail(email: string | undefined): string | undefined; /** * Validate that a string is a valid DID * * @param did - DID string to validate * @returns The DID if valid, undefined otherwise */ export declare function validateDid(did: string | undefined): string | undefined; /** * Validate that a string contains no control characters * * @param text - Text to validate * @returns The text if valid, undefined otherwise */ export declare function validateNoControlChars(text: string | undefined): string | undefined; /** * Validate and sanitize a string for display * * Removes control characters and trims whitespace. * * @param text - Text to sanitize * @param maxLength - Maximum allowed length * @returns Sanitized text or undefined if invalid */ export declare function sanitizeDisplayText(text: string | undefined, maxLength?: number): string | undefined; /** * Validate that a string is alphanumeric with underscores only * * Useful for field names and identifiers. * * @param text - Text to validate * @returns The text if valid, undefined otherwise */ export declare function validateIdentifier(text: string | undefined): string | undefined; /** * Check if a value is a safe integer within range * * @param value - Value to check * @param min - Minimum value (inclusive) * @param max - Maximum value (inclusive) * @returns True if valid */ export declare function isValidInteger(value: unknown, min?: number, max?: number): value is number; /** * Validate a CSRF token format * * @param token - Token to validate * @returns The token if valid, undefined otherwise */ export declare function validateCSRFToken(token: string | undefined): string | undefined; //# sourceMappingURL=validators.d.ts.map