@mikkelscheike/email-provider-links
Version:
TypeScript library for email provider detection with 93 providers (207 domains), concurrent DNS resolution, optimized performance, 94.65% test coverage, and enterprise security for login and password reset flows
94 lines • 3.25 kB
TypeScript
/**
* Hash Verification System
*
* Provides cryptographic integrity verification for the email providers database
* to detect tampering or unauthorized modifications.
*/
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: any, 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: any[]): {
timestamp: string;
providerCount: number;
urlHashes: Record<string, string>;
manifestHash: string;
};
//# sourceMappingURL=hash-verifier.d.ts.map