/** * CORS configuration */ export interface CorsConfig { enabled?: boolean; origin?: string | string[] | boolean; methods?: string[]; allowedHeaders?: string[]; credentials?: boolean; maxAge?: number; preflightContinue?: boolean; optionsSuccessStatus?: number; } /** * Input validation configuration */ export interface ValidationConfig { enabled?: boolean; sanitizeInput?: boolean; maxBodySize?: string; maxParameterLength?: number; allowedFileTypes?: string[]; maxFileSize?: number; validateEmails?: boolean; validateUrls?: boolean; validatePhoneNumbers?: boolean; validateParamLength?: boolean; detectCsvInjection?: boolean; csvInjectionWhitelistedFields?: string[]; strictMode?: boolean; skipSuspiciousPatterns?: boolean; whitelistedPatterns?: RegExp[]; preserveSlashFields?: string[]; } /** * Security headers configuration */ export interface SecurityHeadersConfig { enabled?: boolean; contentSecurityPolicy?: boolean | string; hsts?: boolean | { maxAge?: number; includeSubDomains?: boolean; preload?: boolean; }; noSniff?: boolean; xssFilter?: boolean; referrerPolicy?: boolean | string; frameOptions?: boolean | 'DENY' | 'SAMEORIGIN'; permittedCrossDomainPolicies?: boolean; hidePoweredBy?: boolean; } /** * SQL Injection protection configuration */ export interface SqlInjectionConfig { enabled?: boolean; enableProtection?: boolean; whitelistQueries?: string[]; customPatterns?: RegExp[]; strictMode?: boolean; blockSuspiciousPatterns?: boolean; } /** * XSS protection configuration */ export interface XssConfig { enabled?: boolean; enableProtection?: boolean; customPatterns?: RegExp[]; sanitizeInput?: boolean; strictMode?: boolean; allowedTags?: string[]; allowedAttributes?: string[]; } /** * Logging configuration */ export interface LoggingConfig { enabled?: boolean; logLevel?: 'error' | 'warn' | 'info' | 'debug'; logSuspiciousActivity?: boolean; logSuccessfulRequests?: boolean; logFailedRequests?: boolean; includeRequestDetails?: boolean; includeResponseDetails?: boolean; maskSensitiveData?: boolean; sensitiveFields?: string[]; } /** * Error response configuration for client-facing messages */ export interface ErrorResponseConfig { exposeDetailedErrors?: boolean; customErrorMessage?: string; } /** * File upload security configuration */ export interface FileUploadConfig { enabled?: boolean; maxFileSize?: number; maxFiles?: number; allowedMimeTypes?: string[]; allowedExtensions?: string[]; scanForMalware?: boolean; quarantineInfected?: boolean; validateFileHeaders?: boolean; validateContent?: boolean; allowExecutables?: boolean; quarantinePath?: string; } /** * Comprehensive security configuration interface */ export interface SecurityConfig { skip?: boolean; cors?: CorsConfig; validation?: ValidationConfig; headers?: SecurityHeadersConfig; sqlInjection?: SqlInjectionConfig; xss?: XssConfig; logging?: LoggingConfig; fileUpload?: FileUploadConfig; errorResponse?: ErrorResponseConfig; enableAllProtections?: boolean; skipOnError?: boolean; healthCheckPaths?: string[]; skipFields?: string[]; skipUrls?: string[]; } /** * Interface defining the component's options object */ export interface FcSecurityComponentOptions extends SecurityConfig { globalConfig?: SecurityConfig; componentName?: string; version?: string; } /** * Security validation result interface */ export interface SecurityValidationResult { isValid: boolean; errors: string[]; warnings?: string[]; sanitizedData?: Record; blocked?: boolean; reason?: string; metadata?: Record; } /** * Security event interface for logging */ export interface SecurityEvent { timestamp: string; eventType: 'SECURITY_CHECK_PASSED' | 'SECURITY_VIOLATION' | 'MALICIOUS_ACTIVITY'; ip?: string; userAgent?: string; url?: string; method?: string; error?: string; requestId?: string; rootRequestId?: string; userId?: string; severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; metadata?: Record; }