import { createHash } from 'crypto'; /** * Versão simplificada do MetadataCollector para quando faltam dependências */ export class FallbackMetadataCollector { /** * Coleta metadados básicos a partir dos dados fornecidos */ async collectMetadata(data: { userAgent: string; ipAddress: string; timestamp: Date; fileName: string; fileSize: number; [key: string]: any; }) { const timestamp = new Date(); // Retornar metadados simplificados return { timestamp: timestamp.toISOString(), collectionTime: timestamp.toISOString(), userAgent: data.userAgent, ipAddress: data.ipAddress, fileName: data.fileName, fileSize: data.fileSize, fileSizeFormatted: this.formatFileSize(data.fileSize), integrityHash: this.generateHash(data.fileName, data.fileSize.toString(), timestamp.toISOString()) }; } private formatFileSize(bytes: number): string { if (bytes < 1024) return bytes + ' bytes'; else if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB'; else if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(2) + ' MB'; else return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB'; } private generateHash(...values: string[]): string { return createHash('sha256') .update(values.join('|')) .digest('hex'); } }