@visulima/email-verifier 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,117 +0,0 @@
1
- /**
2
- * Generic cache interface for caching any type of data.
3
- * Implementations can use in-memory cache, LRU cache, Redis, etc.
4
- */
5
- interface Cache<T = unknown> {
6
- /**
7
- * Clears all cached entries.
8
- */
9
- clear: () => Promise<void>;
10
- /**
11
- * Deletes a cached entry.
12
- * @param key The cache key.
13
- */
14
- delete: (key: string) => Promise<void>;
15
- /**
16
- * Gets a cached value.
17
- * @param key The cache key.
18
- * @returns The cached value or undefined if not found or expired.
19
- */
20
- get: (key: string) => Promise<T | undefined>;
21
- /**
22
- * Sets a cached value.
23
- * @param key The cache key.
24
- * @param value The value to cache.
25
- * @param ttl Time-to-live in milliseconds.
26
- */
27
- set: (key: string, value: T, ttl: number) => Promise<void>;
28
- }
29
- /**
30
- * Options for creating an in-memory cache.
31
- */
32
- interface InMemoryCacheOptions {
33
- /**
34
- * Maximum number of entries in the cache.
35
- * @default 500
36
- */
37
- max?: number;
38
- /**
39
- * Default TTL in milliseconds for entries.
40
- * @default 3600000 (1 hour)
41
- */
42
- ttl?: number;
43
- }
44
- /**
45
- * Default in-memory cache implementation using LRU cache.
46
- *
47
- * Shared by the MX and SMTP probes so repeated lookups against the same domain
48
- * (e.g. when verifying a list) avoid redundant DNS/socket work.
49
- */
50
- declare class InMemoryCache<T extends object = Record<string, unknown>> implements Cache<T> {
51
- private readonly cache;
52
- constructor(options?: InMemoryCacheOptions);
53
- clear: () => Promise<void>;
54
- delete: (key: string) => Promise<void>;
55
- get: (key: string) => Promise<T | undefined>;
56
- set: (key: string, value: T, ttl: number) => Promise<void>;
57
- }
58
- /**
59
- * MX record information.
60
- */
61
- interface MxRecord {
62
- exchange: string;
63
- priority: number;
64
- }
65
- /**
66
- * How the domain's mail-acceptance was established.
67
- *
68
- * - `mx`: the domain published MX records.
69
- * - `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.
70
- * - `none`: neither MX nor address records exist.
71
- */
72
- type MxResolution = "address" | "mx" | "none";
73
- /**
74
- * Result of an MX/domain check.
75
- */
76
- interface MxCheckResult {
77
- /** True when the domain itself resolves but publishes no MX records. */
78
- domainResolves: boolean;
79
- error?: string;
80
- records?: MxRecord[];
81
- resolvedVia: MxResolution;
82
- /** True when the domain can accept mail (has MX or A/AAAA records). */
83
- valid: boolean;
84
- }
85
- /**
86
- * Options for MX record checking.
87
- */
88
- interface MxCheckOptions {
89
- cache?: Cache<MxCheckResult>;
90
- /**
91
- * When true (the default), a domain with no MX records but a resolvable
92
- * A/AAAA record is still considered able to accept mail (implicit MX).
93
- */
94
- fallbackToAddress?: boolean;
95
- ttl?: number;
96
- }
97
- /**
98
- * Checks MX records for a domain, with an optional A/AAAA fallback.
99
- *
100
- * Distinguishes three states emailable separates as "MX Record Detection" and
101
- * "Domain Validation": records present (`mx`), no MX but the domain resolves
102
- * (`address`, implicit MX), and nothing resolves (`none`).
103
- * @param domain The domain to check.
104
- * @param options Options including caching and the address fallback toggle.
105
- * @returns The MX/domain check result.
106
- * @example
107
- * ```ts
108
- * import { checkMxRecords } from "@visulima/email-verifier/checks/mx";
109
- *
110
- * const result = await checkMxRecords("example.com");
111
- * if (result.valid) {
112
- * console.log(result.resolvedVia, result.records);
113
- * }
114
- * ```
115
- */
116
- declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise<MxCheckResult>;
117
- 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 };