@emailcheck/email-validator-js
Version:
Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.
206 lines (205 loc) • 6.63 kB
TypeScript
import type { Cache } from './cache-interface';
import { CheckIfEmailExistsCoreParams, CheckIfEmailExistsCoreResult, CheckIfEmailExistsSmtpOptions, EmailProvider, type EmailSyntaxResult, HeadlessOptions, MxLookupResult, SmtpVerificationResult, YahooApiOptions } from './email-verifier-types';
export declare const checkIfEmailExistsConstants: {
gmailDomains: string[];
yahooDomains: string[];
hotmailDomains: string[];
defaultTimeout: number;
defaultSmtpPort: number;
defaultFromEmail: string;
defaultHelloName: string;
};
export { EmailProvider, SmtpVerificationResult, MxLookupResult, CheckIfEmailExistsCoreResult, CheckIfEmailExistsSmtpOptions, YahooApiOptions, HeadlessOptions, CheckIfEmailExistsCoreParams, };
/**
* Extended interface for our implementation
*/
export interface CheckIfEmailExistsCoreParamsExtended extends CheckIfEmailExistsCoreParams {
cache?: Cache | null;
smtpTimeout?: number;
fromEmail?: string;
helloName?: string;
smtpOptions?: CheckIfEmailExistsSmtpOptions;
enableProviderOptimizations?: boolean;
useYahooApi?: boolean;
useYahooHeadless?: boolean;
yahooApiOptions?: YahooApiOptions;
headlessOptions?: HeadlessOptions;
}
/**
* Enhanced syntax validation with RFC 5321 compliance
*/
export declare function validateEmailSyntax(email: string): EmailSyntaxResult;
/**
* Provider detection functions matching the original Rust implementation
*/
export declare function isGmail(host: string): boolean;
export declare function isYahoo(host: string): boolean;
export declare function isHotmailB2C(host: string): boolean;
export declare function isHotmailB2B(host: string): boolean;
export declare function isProofpoint(host: string): boolean;
export declare function isMimecast(host: string): boolean;
/**
* Provider detection from MX host (matching original implementation)
*/
export declare function getProviderFromMxHost(host: string): EmailProvider;
/**
* Get provider type for known email providers (legacy function)
*/
export declare function getProviderType(domain: string): EmailProvider;
/**
* Enhanced MX record lookup with caching support
*/
export declare function queryMxRecords(domain: string, options?: {
timeout?: number;
cache?: Cache | null;
}): Promise<MxLookupResult>;
/**
* Enhanced SMTP verification with provider-specific logic and catch-all detection
*/
export declare function verifySmtpConnection(email: string, domain: string, mxHost: string, options?: {
timeout?: number;
fromEmail?: string;
helloName?: string;
port?: number;
retries?: number;
useStartTls?: boolean;
proxy?: any;
}, providerType?: EmailProvider): Promise<SmtpVerificationResult>;
/**
* Main function to check if an email
*/
export declare function checkIfEmailExistsCore(params: CheckIfEmailExistsCoreParamsExtended): Promise<CheckIfEmailExistsCoreResult>;
/**
* Yahoo API verification using HTTP requests to Yahoo signup endpoints
* This replicates the functionality from the original Rust implementation's yahoo/api.rs
*/
declare function verifyYahooApi(email: string, options?: YahooApiOptions): Promise<{
isValid: boolean;
isDeliverable: boolean;
error?: string;
details?: any;
}>;
/**
* Generic headless browser automation for email verification
* Based on the original Rust implementation's headless functionality
*/
interface HeadlessBrowserResult {
success: boolean;
email_exists?: boolean;
screenshot?: string;
error?: string;
details?: any;
}
declare class HeadlessBrowser {
private webdriverEndpoint;
private timeout;
private retryAttempts;
constructor(options?: HeadlessOptions);
/**
* Create a new browser session
*/
private createSession;
/**
* Navigate to a URL
*/
private navigate;
/**
* Take a screenshot
*/
private takeScreenshot;
/**
* Execute JavaScript in the browser
*/
private executeScript;
/**
* Find an element
*/
private findElement;
/**
* Type text into an element
*/
private typeText;
/**
* Click an element
*/
private clickElement;
/**
* Wait for an element to be present
*/
private waitForElement;
/**
* Delete the browser session
*/
private deleteSession;
/**
* Generic headless verification method
*/
verifyEmail(email: string, verificationSteps: Array<{
url: string;
actions: Array<{
type: 'navigate' | 'waitFor' | 'type' | 'click' | 'execute';
selector?: string;
text?: string;
script?: string;
using?: string;
timeout?: number;
}>;
successIndicators?: string[];
errorIndicators?: string[];
}>, screenshot?: boolean): Promise<HeadlessBrowserResult>;
}
/**
* Yahoo headless verification using browser automation
*/
declare function verifyYahooHeadless(email: string, options?: HeadlessOptions): Promise<HeadlessBrowserResult>;
/**
* Gmail headless verification using browser automation
*/
declare function verifyGmailHeadless(email: string, options?: HeadlessOptions): Promise<HeadlessBrowserResult>;
/**
* Provider-specific SMTP error parsing and analysis
* Based on the original Rust implementation's error parsing modules
*/
export interface ParsedSmtpError {
type: 'disabled' | 'full_inbox' | 'unknown' | 'invalid' | 'catch_all' | 'rate_limited' | 'blocked';
severity: 'permanent' | 'temporary' | 'unknown';
message: string;
originalMessage: string;
providerSpecific?: {
code?: string;
action?: string;
details?: string;
};
}
declare class SmtpErrorParser {
/**
* Parse SMTP error messages with provider-specific context
*/
static parseError(smtpMessage: string, provider: EmailProvider, responseCode?: number): ParsedSmtpError;
/**
* Parse generic SMTP error patterns
*/
private static parseGenericErrors;
/**
* Parse Gmail-specific SMTP errors
*/
private static parseGmailError;
/**
* Parse Yahoo-specific SMTP errors
*/
private static parseYahooError;
/**
* Parse Hotmail/Outlook-specific SMTP errors
*/
private static parseHotmailError;
/**
* Parse Proofpoint-specific SMTP errors
*/
private static parseProofpointError;
/**
* Parse Mimecast-specific SMTP errors
*/
private static parseMimecastError;
}
export { verifyYahooApi, verifyYahooHeadless, verifyGmailHeadless, SmtpErrorParser };
export { HeadlessBrowser };