UNPKG

codecrucible-synth

Version:

Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability

110 lines 2.82 kB
/** * Enterprise Input Validation Middleware * Implements comprehensive input sanitization and validation with security rules */ export interface ValidationRule { type: 'string' | 'number' | 'boolean' | 'email' | 'url' | 'uuid' | 'json' | 'array' | 'object' | 'custom'; required?: boolean; min?: number; max?: number; pattern?: RegExp; enum?: any[]; custom?: (value: any) => boolean | string; sanitize?: boolean; errorMessage?: string; } export interface ValidationSchema { [fieldPath: string]: ValidationRule; } export interface ValidationOptions { allowExtraFields?: boolean; stripExtraFields?: boolean; abortEarly?: boolean; skipMissing?: boolean; } export interface ValidationResult { isValid: boolean; errors: ValidationError[]; sanitizedData?: any; warnings: string[]; } export interface ValidationError { field: string; message: string; value: any; rule: string; } export interface SecurityConfig { maxDepth: number; maxKeys: number; maxStringLength: number; maxArrayLength: number; allowedTags: string[]; blockedPatterns: RegExp[]; sqlInjectionPatterns: RegExp[]; xssPatterns: RegExp[]; pathTraversalPatterns: RegExp[]; } export declare class InputValidator { private securityConfig; constructor(securityConfig?: Partial<SecurityConfig>); /** * Validate data against schema */ validate(data: any, schema: ValidationSchema, options?: ValidationOptions): ValidationResult; /** * Perform security validation */ private performSecurityValidation; /** * Validate against schema */ private validateSchema; /** * Validate a single field */ private validateField; /** * Validate data type */ private validateType; /** * Validate size/length constraints */ private validateSize; /** * Scan for security threats */ private scanForThreats; /** * Analyze data complexity */ private analyzeComplexity; /** * Sanitize string input */ private sanitizeString; /** * Validation helper methods */ private isValidEmail; private isValidUrl; private isValidUuid; /** * Utility methods for nested object access */ private getNestedValue; private setNestedValue; private deleteNestedValue; private findExtraFields; private getAllFieldPaths; /** * Express middleware factory */ static middleware(schema: ValidationSchema, options?: ValidationOptions): (req: any, res: any, next: any) => any; /** * Create common validation schemas */ static createCommonSchemas(): Record<string, ValidationSchema>; } //# sourceMappingURL=input-validator.d.ts.map