/** * MIME Type Validator * * Validates file types using: * - File extension (quick check) * - Magic bytes (file signature) * - Server-side MIME type validation * * Supports comprehensive file type detection for: * - Images: JPEG, PNG, GIF, WebP, SVG, ICO, AVIF, HEIC * - Documents: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX * - Audio: MP3, WAV, OGG, FLAC, M4A * - Video: MP4, WEBM, AVI, MOV, MKV * - Archives: ZIP, RAR, 7Z, TAR, GZIP * - And more... */ export interface MimeTypeConfig { /** Allowed MIME types */ allowedTypes?: string[]; /** Allowed file extensions */ allowedExtensions?: string[]; /** Maximum file size in bytes */ maxSize?: number; /** Use magic bytes validation (default: true) */ useMagicBytes?: boolean; /** Custom MIME type mappings */ customMappings?: Record; } export interface MimeTypeValidationResult { /** Validation success */ valid: boolean; /** Detected MIME type */ mimeType?: string; /** Detected extension */ extension?: string; /** File size in bytes */ size?: number; /** Validation errors */ errors?: string[]; /** Warnings (non-blocking) */ warnings?: string[]; } /** * MIME type validator class */ export declare class MimeValidator { private config; private customMappings; constructor(config?: MimeTypeConfig); /** * Validate a file */ validate(file: File | Blob): Promise; /** * Detect MIME type using magic bytes */ detectMimeType(file: File | Blob): Promise; /** * Detect MIME type from magic bytes (file signature) */ private detectFromMagicBytes; /** * Check if bytes match signature at offset */ private matchesMagicBytes; /** * Check if MIME type is allowed */ isAllowedType(mimeType: string): boolean; /** * Check if extension is allowed */ isAllowedExtension(extension: string): boolean; /** * Check if a string is a valid MIME type */ isValidMimeType(mimeType: string): boolean; /** * Get file extension from filename */ getExtension(fileName: string): string; /** * Get MIME type from extension */ getMimeTypeFromExtension(extension: string): string | undefined; /** * Get extension from MIME type */ getExtensionFromMimeType(mimeType: string): string | undefined; /** * Update allowed types */ setAllowedTypes(types: string[]): void; /** * Update allowed extensions */ setAllowedExtensions(extensions: string[]): void; /** * Update max size */ setMaxSize(size: number): void; } /** * Create a MIME validator instance */ export declare function createMimeValidator(config?: MimeTypeConfig): MimeValidator; /** * Validate a file (convenience function) */ export declare function validateMimeType(file: File | Blob, config?: MimeTypeConfig): Promise; /** * Get MIME type from extension */ export declare function getMimeTypeFromExtension(extension: string): string | undefined; /** * Get extension from MIME type */ export declare function getExtensionFromMimeType(mimeType: string): string | undefined; export default MimeValidator;