@emailcheck/email-validator-js 5.0.0-beta.1 → 5.0.0-beta.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.
- package/README.md +128 -30
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +86 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +155 -0
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recommended `verifyEmail` / `verifyMailboxSMTP` configuration presets for
|
|
3
|
+
* common deployment shapes.
|
|
4
|
+
*
|
|
5
|
+
* These are not magic — every value is just a `SMTPVerifyOptions` /
|
|
6
|
+
* `VerifyEmailParams` field with a sensible default for that workload.
|
|
7
|
+
* Use them directly, or spread + override:
|
|
8
|
+
*
|
|
9
|
+
* await verifyEmail({
|
|
10
|
+
* emailAddress: 'foo@bar.com',
|
|
11
|
+
* ...VERIFY_EMAIL_PRESETS.serverless,
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* // Or override one field:
|
|
15
|
+
* await verifyEmail({
|
|
16
|
+
* emailAddress: 'foo@bar.com',
|
|
17
|
+
* ...VERIFY_EMAIL_PRESETS.serverless,
|
|
18
|
+
* smtpTotalDeadlineMs: 3000,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* Two parallel sets are exported:
|
|
22
|
+
*
|
|
23
|
+
* - `SMTP_PRESETS` — `SMTPVerifyOptions` shape, for callers using
|
|
24
|
+
* `verifyMailboxSMTP` directly.
|
|
25
|
+
* - `VERIFY_EMAIL_PRESETS` — `VerifyEmailParams` shape, with the `smtp`-
|
|
26
|
+
* prefixed field names that `verifyEmail` uses.
|
|
27
|
+
*
|
|
28
|
+
* Presets:
|
|
29
|
+
*
|
|
30
|
+
* - `serverless` — tight latency budget. Cuts off bad MXes fast.
|
|
31
|
+
* Suitable for Lambda / Vercel / Cloudflare-Workers
|
|
32
|
+
* request handlers with sub-10s SLAs.
|
|
33
|
+
* - `dedicated` — long-running server. Willing to retry once and wait
|
|
34
|
+
* longer. Suitable for a dedicated worker / dyno that
|
|
35
|
+
* isn't latency-bound.
|
|
36
|
+
* - `batch` — running through millions of addresses, accuracy more
|
|
37
|
+
* important than per-call latency. Multiple retries with
|
|
38
|
+
* exponential backoff, generous timeouts.
|
|
39
|
+
* - `fast` — favor speed over coverage. Single MX, single retry,
|
|
40
|
+
* short deadlines. For autocomplete / form-validation
|
|
41
|
+
* UX where the answer is needed in <2s.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Presets for `verifyMailboxSMTP`'s `options` field. Each preset is a
|
|
45
|
+
* subset of `SMTPVerifyOptions` — spread it and override fields as needed.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SMTP_PRESETS: {
|
|
48
|
+
/**
|
|
49
|
+
* **Serverless** — Lambda / Vercel / Cloudflare-Workers handlers.
|
|
50
|
+
*
|
|
51
|
+
* Tight latency budget; cuts off bad MXes fast. The total wall-clock
|
|
52
|
+
* is bounded at 5 s so the probe finishes well inside a typical 10 s
|
|
53
|
+
* handler SLA, leaving headroom for everything else the handler does.
|
|
54
|
+
*/
|
|
55
|
+
readonly serverless: {
|
|
56
|
+
readonly perAttemptTimeoutMs: 2500;
|
|
57
|
+
readonly totalDeadlineMs: 5000;
|
|
58
|
+
readonly maxConsecutiveFailures: 3;
|
|
59
|
+
readonly maxMxHosts: 2;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* **Dedicated** — long-running server / worker.
|
|
63
|
+
*
|
|
64
|
+
* Not latency-bound. Tries every MX, retries connection-class failures
|
|
65
|
+
* once with a 500 ms backoff. Suitable for an always-on backend that
|
|
66
|
+
* processes verification requests as they arrive.
|
|
67
|
+
*/
|
|
68
|
+
readonly dedicated: {
|
|
69
|
+
readonly perAttemptTimeoutMs: 5000;
|
|
70
|
+
readonly totalDeadlineMs: 30000;
|
|
71
|
+
readonly retry: {
|
|
72
|
+
readonly attempts: 1;
|
|
73
|
+
readonly delayMs: 500;
|
|
74
|
+
readonly backoff: "exponential";
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* **Batch** — bulk processing.
|
|
79
|
+
*
|
|
80
|
+
* Each address can take a while; what matters is correctness across
|
|
81
|
+
* the whole batch. Multiple retries with exponential backoff to ride
|
|
82
|
+
* out transient network blips. Generous per-attempt budget so slow
|
|
83
|
+
* MXes get a fair shot.
|
|
84
|
+
*/
|
|
85
|
+
readonly batch: {
|
|
86
|
+
readonly perAttemptTimeoutMs: 10000;
|
|
87
|
+
readonly totalDeadlineMs: 60000;
|
|
88
|
+
readonly retry: {
|
|
89
|
+
readonly attempts: 2;
|
|
90
|
+
readonly delayMs: 1000;
|
|
91
|
+
readonly backoff: "exponential";
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* **Fast** — UX-bound (form autocomplete / signup-form validation).
|
|
96
|
+
*
|
|
97
|
+
* Optimize for speed; accept that ambiguous results may be more common.
|
|
98
|
+
* Tries the primary MX only, single retry, sub-3s wall-clock.
|
|
99
|
+
*/
|
|
100
|
+
readonly fast: {
|
|
101
|
+
readonly perAttemptTimeoutMs: 1500;
|
|
102
|
+
readonly totalDeadlineMs: 3000;
|
|
103
|
+
readonly maxConsecutiveFailures: 2;
|
|
104
|
+
readonly maxMxHosts: 1;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Presets for `verifyEmail`'s top-level params. Each preset is a subset of
|
|
109
|
+
* `VerifyEmailParams` — spread it and override fields as needed. The keys
|
|
110
|
+
* use the `smtp`-prefixed names that `verifyEmail` accepts (matching the
|
|
111
|
+
* unprefixed `SMTP_PRESETS` field-for-field).
|
|
112
|
+
*/
|
|
113
|
+
export declare const VERIFY_EMAIL_PRESETS: {
|
|
114
|
+
/** See `SMTP_PRESETS.serverless`. */
|
|
115
|
+
readonly serverless: {
|
|
116
|
+
readonly smtpPerAttemptTimeoutMs: 2500;
|
|
117
|
+
readonly smtpTotalDeadlineMs: 5000;
|
|
118
|
+
readonly smtpMaxConsecutiveFailures: 3;
|
|
119
|
+
readonly smtpMaxMxHosts: 2;
|
|
120
|
+
readonly whoisTimeoutMs: 3000;
|
|
121
|
+
};
|
|
122
|
+
/** See `SMTP_PRESETS.dedicated`. */
|
|
123
|
+
readonly dedicated: {
|
|
124
|
+
readonly smtpPerAttemptTimeoutMs: 5000;
|
|
125
|
+
readonly smtpTotalDeadlineMs: 30000;
|
|
126
|
+
readonly smtpRetry: {
|
|
127
|
+
readonly attempts: 1;
|
|
128
|
+
readonly delayMs: 500;
|
|
129
|
+
readonly backoff: "exponential";
|
|
130
|
+
};
|
|
131
|
+
readonly whoisTimeoutMs: 5000;
|
|
132
|
+
};
|
|
133
|
+
/** See `SMTP_PRESETS.batch`. */
|
|
134
|
+
readonly batch: {
|
|
135
|
+
readonly smtpPerAttemptTimeoutMs: 10000;
|
|
136
|
+
readonly smtpTotalDeadlineMs: 60000;
|
|
137
|
+
readonly smtpRetry: {
|
|
138
|
+
readonly attempts: 2;
|
|
139
|
+
readonly delayMs: 1000;
|
|
140
|
+
readonly backoff: "exponential";
|
|
141
|
+
};
|
|
142
|
+
readonly whoisTimeoutMs: 8000;
|
|
143
|
+
};
|
|
144
|
+
/** See `SMTP_PRESETS.fast`. */
|
|
145
|
+
readonly fast: {
|
|
146
|
+
readonly smtpPerAttemptTimeoutMs: 1500;
|
|
147
|
+
readonly smtpTotalDeadlineMs: 3000;
|
|
148
|
+
readonly smtpMaxConsecutiveFailures: 2;
|
|
149
|
+
readonly smtpMaxMxHosts: 1;
|
|
150
|
+
readonly whoisTimeoutMs: 2000;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/** Type-level sugar for picking a preset by name. */
|
|
154
|
+
export type SmtpPresetName = keyof typeof SMTP_PRESETS;
|
|
155
|
+
export type VerifyEmailPresetName = keyof typeof VERIFY_EMAIL_PRESETS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emailcheck/email-validator-js",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.",
|
|
6
6
|
"keywords": [
|