UNPKG

@mikkelscheike/email-provider-links

Version:

TypeScript library for email provider detection with 140 providers (259 domains), concurrent DNS resolution, alias normalization, and HTTPS login URL validation for login and password reset flows

99 lines 3.36 kB
/** * Hash Verification System * * Provides cryptographic integrity verification for the email providers database * to detect tampering or unauthorized modifications. */ type ProviderLike = { companyProvider?: string; loginUrl?: string | null; }; export interface HashVerificationResult { isValid: boolean; expectedHash?: string; actualHash: string; reason?: string; file: string; } /** * Calculates SHA-256 hash of a file or string content * * @param content - File content as string or Buffer * @returns SHA-256 hash as hex string */ export declare function calculateHash(content: string | Buffer): string; /** * Calculates SHA-256 hash of a file * * @param filePath - Path to the file * @returns SHA-256 hash as hex string */ export declare function calculateFileHash(filePath: string): string; /** * Verifies the integrity of the email providers JSON file * * @param filePath - Path to the providers JSON file * @param expectedHash - Optional expected hash (if not provided, uses KNOWN_GOOD_HASHES) * @returns Verification result */ export declare function verifyProvidersIntegrity(filePath: string, expectedHash?: string): HashVerificationResult; /** * Verifies the integrity of providers data from JSON object * * @param providersData - The providers data object * @param expectedHash - Expected hash of the JSON string * @returns Verification result */ export declare function verifyProvidersDataIntegrity(providersData: unknown, expectedHash?: string): HashVerificationResult; /** * Generates security hashes for critical files - use this during development * * @param basePath - Base path of the project * @returns Object with calculated hashes */ export declare function generateSecurityHashes(basePath?: string): Record<string, string>; /** * Easy-to-use function to recalculate and display current hashes * for updating KNOWN_GOOD_HASHES when making legitimate changes * * @param basePath - Base path of the project * @returns Formatted hash configuration for copy-paste */ export declare function recalculateHashes(basePath?: string): string; /** * Enhanced security warning system for hash mismatches * * @param result - Hash verification result * @param options - Warning options */ export declare function handleHashMismatch(result: HashVerificationResult, options?: { throwOnMismatch?: boolean; logLevel?: 'error' | 'warn' | 'silent'; onMismatch?: (result: HashVerificationResult) => void; }): void; /** * Comprehensive security audit including hash verification * * @param providersFilePath - Path to providers JSON file * @returns Complete security audit result */ export declare function performSecurityAudit(providersFilePath?: string): { hashVerification: HashVerificationResult; recommendations: string[]; securityLevel: 'HIGH' | 'MEDIUM' | 'LOW' | 'CRITICAL'; }; /** * Creates a signed manifest of all provider URLs with their hashes * This can be used to detect any URL modifications * * @param providers - Array of email providers * @returns Signed manifest with URL hashes */ export declare function createProviderManifest(providers: ProviderLike[]): { timestamp: string; providerCount: number; urlHashes: Record<string, string>; manifestHash: string; }; export {}; //# sourceMappingURL=hash-verifier.d.ts.map