/** * Generic cache interface for caching any type of data. * Implementations can use in-memory cache, LRU cache, Redis, etc. */ interface Cache { /** * Clears all cached entries. */ clear: () => Promise; /** * Deletes a cached entry. * @param key The cache key. */ delete: (key: string) => Promise; /** * Gets a cached value. * @param key The cache key. * @returns The cached value or undefined if not found or expired. */ get: (key: string) => Promise; /** * Sets a cached value. * @param key The cache key. * @param value The value to cache. * @param ttl Time-to-live in milliseconds. */ set: (key: string, value: T, ttl: number) => Promise; } /** * Options for creating an in-memory cache. */ interface InMemoryCacheOptions { /** * Maximum number of entries in the cache. * @default 500 */ max?: number; /** * Default TTL in milliseconds for entries. * @default 3600000 (1 hour) */ ttl?: number; } /** * Default in-memory cache implementation using LRU cache. * * Shared by the MX and SMTP probes so repeated lookups against the same domain * (e.g. when verifying a list) avoid redundant DNS/socket work. */ declare class InMemoryCache> implements Cache { private readonly cache; constructor(options?: InMemoryCacheOptions); clear: () => Promise; delete: (key: string) => Promise; get: (key: string) => Promise; set: (key: string, value: T, ttl: number) => Promise; } /** * MX record information. */ interface MxRecord { exchange: string; priority: number; } /** * How the domain's mail-acceptance was established. * * - `mx`: the domain published MX records. * - `address`: the domain has no MX but resolves to an A/AAAA record, so by RFC 5321 §5.1 the address itself is treated as an implicit MX. * - `none`: neither MX nor address records exist. */ type MxResolution = "address" | "mx" | "none"; /** * Result of an MX/domain check. */ interface MxCheckResult { /** * True when the lookup was inconclusive because of a transient DNS failure * (timeout, SERVFAIL, refused, …) rather than a definitive "no records" * answer. Such a result is neither cached nor treated as undeliverable. */ deferred?: boolean; /** True when the domain itself resolves but publishes no MX records. */ domainResolves: boolean; error?: string; records?: MxRecord[]; resolvedVia: MxResolution; /** True when the domain can accept mail (has MX or A/AAAA records). */ valid: boolean; } /** * Options for MX record checking. */ interface MxCheckOptions { cache?: Cache; /** * When true (the default), a domain with no MX records but a resolvable * A/AAAA record is still considered able to accept mail (implicit MX). */ fallbackToAddress?: boolean; ttl?: number; } declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise; export { Cache as C, InMemoryCache as I, MxCheckOptions as M, InMemoryCacheOptions as a, MxCheckResult as b, MxRecord as c, MxResolution as d, checkMxRecords as e };