@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.
64 lines (63 loc) • 1.99 kB
TypeScript
/**
* Cloudflare Workers adapter for email validation
* Supports Workers, Pages Functions, and Durable Objects
*/
interface KVNamespace {
get<T = unknown>(key: string, type?: 'text' | 'json' | 'arrayBuffer' | 'stream'): Promise<T | null>;
put(key: string, value: string | ArrayBuffer | ReadableStream, options?: {
expirationTtl?: number;
}): Promise<void>;
delete(key: string): Promise<void>;
}
interface DurableObjectNamespace {
idFromName(name: string): DurableObjectId;
get(id: DurableObjectId): DurableObjectStub;
}
interface DurableObjectId {
toString(): string;
}
interface DurableObjectStub {
fetch(request: Request): Promise<Response>;
}
interface DurableObjectState {
storage: DurableObjectStorage;
}
interface DurableObjectStorage {
get<T = unknown>(key: string): Promise<T | undefined>;
put<T = unknown>(key: string, value: T): Promise<void>;
delete(key: string): Promise<void>;
}
export interface CloudflareRequest extends Request {
cf?: {
country?: string;
colo?: string;
timezone?: string;
};
}
export interface CloudflareEnv {
EMAIL_CACHE?: KVNamespace;
EMAIL_VALIDATOR?: DurableObjectNamespace;
[key: string]: unknown;
}
export interface CloudflareContext {
waitUntil(promise: Promise<unknown>): void;
passThroughOnException(): void;
}
declare function workerHandler(request: CloudflareRequest, env: CloudflareEnv, ctx: CloudflareContext): Promise<Response>;
export declare class EmailValidatorDO {
private state;
private env;
private cache;
constructor(state: DurableObjectState, env: CloudflareEnv);
fetch(request: Request): Promise<Response>;
private handleValidation;
private handleCacheClear;
private handleCacheStats;
}
declare const _default: {
fetch: typeof workerHandler;
workerHandler: typeof workerHandler;
EmailValidatorDO: typeof EmailValidatorDO;
};
export default _default;
export { workerHandler };