@emailcheck/email-validator-js 3.4.4 → 4.0.0-beta.1

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/dist/types.d.ts CHANGED
@@ -177,47 +177,78 @@ export declare enum EmailProvider {
177
177
  everythingElse = "everything_else"
178
178
  }
179
179
  /**
180
- * Result for SMTP verification with metadata
181
- * Uses camelCase for consistency with TypeScript conventions
180
+ * Verdict from one `verifyMailboxSMTP` call. Flat by design — every field is
181
+ * one boolean / scalar so callers can switch on a few keys instead of walking
182
+ * a tree.
182
183
  */
183
184
  export interface SmtpVerificationResult {
184
- /** Whether SMTP connection was successful */
185
+ /** True when at least one MX×port responded with an SMTP greeting. */
185
186
  canConnectSmtp: boolean;
186
- /** Whether the mailbox is full */
187
+ /** True when the MX returned `552` / `452` (over-quota / mailbox full). */
187
188
  hasFullInbox: boolean;
188
- /** Whether the domain has catch-all enabled */
189
+ /**
190
+ * True when both the real RCPT TO and the random-local probe RCPT TO
191
+ * returned `250` — the MX accepts every recipient and the deliverability
192
+ * signal for the real address is unreliable.
193
+ */
189
194
  isCatchAll: boolean;
190
- /** Whether the email is deliverable */
195
+ /** True when the real RCPT TO returned `250` / `251`. */
191
196
  isDeliverable: boolean;
192
- /** Whether the email/account is disabled */
197
+ /** True when the real RCPT TO was definitively rejected. */
193
198
  isDisabled: boolean;
194
- /** Error message if verification failed */
199
+ /**
200
+ * Short reason key when `isDeliverable === false`. Vocabulary:
201
+ * `not_found` | `over_quota` | `temporary_failure` | `ambiguous` |
202
+ * `connection_error` | `connection_timeout` | `tls_error` |
203
+ * `ehlo_failed` | `helo_failed` | `mail_from_rejected` | `no_greeting` |
204
+ * `no_mx_records` | `unrecognized_response` | `step_timeout`
205
+ */
195
206
  error?: string;
196
- /** Which provider was detected/used */
197
- providerUsed?: EmailProvider;
198
- /** Additional compatibility properties */
199
- success?: boolean;
200
- canConnect?: boolean;
207
+ /** Most recent 3-digit SMTP code observed during the probe. */
201
208
  responseCode?: number;
202
- /** Provider-specific error details */
203
- providerSpecific?: {
204
- errorCode?: string;
205
- actionRequired?: string;
206
- details?: string;
207
- };
208
- /** Timestamp when this was checked (for cache) */
209
+ /**
210
+ * RFC 3463 enhanced status code from the most recent SMTP reply that
211
+ * carried one — e.g. `"5.1.1"` (mailbox unknown), `"5.7.1"` (policy
212
+ * block), `"4.7.0"` (transient policy). Undefined when no MX reply
213
+ * included an enhanced status.
214
+ */
215
+ enhancedStatus?: string;
216
+ /** Operational counters — always populated. See `SmtpProbeMetrics`. */
217
+ metrics?: SmtpProbeMetrics;
218
+ /** Wall-clock timestamp this verdict was produced (set on every result). */
209
219
  checkedAt?: number;
210
220
  /**
211
- * Server reply lines, in arrival order, prefixed `<port>|s| <line>` so
212
- * multi-port probes stay readable. Present when `captureTranscript` is set.
221
+ * Server reply lines, in arrival order, prefixed `<host>:<port>|s| <line>`
222
+ * so multi-MX dialogues stay readable. Present only when
223
+ * `captureTranscript: true` was passed.
213
224
  */
214
225
  transcript?: string[];
215
226
  /**
216
- * Client commands sent, in send order, prefixed `<port>|c| <command>`.
217
- * Present when `captureTranscript` is set.
227
+ * Client commands sent, in send order, prefixed `<host>:<port>|c| <cmd>`.
228
+ * Present only when `captureTranscript: true` was passed.
218
229
  */
219
230
  commands?: string[];
220
231
  }
232
+ /**
233
+ * Operational counters for one `verifyMailboxSMTP` call. The cost of
234
+ * collecting these is trivial — pure bookkeeping during the existing flow.
235
+ */
236
+ export interface SmtpProbeMetrics {
237
+ /** How many MX hostnames the outer loop attempted before stopping. */
238
+ mxAttempts: number;
239
+ /** Total connection attempts across the whole call (sum across MX×port). */
240
+ portAttempts: number;
241
+ /** MX hostnames attempted in priority order (matches `mxRecords` slice). */
242
+ mxHostsTried: string[];
243
+ /**
244
+ * MX hostname that produced the final answer. Undefined when every MX
245
+ * failed (in which case `result.isDeliverable === false` and the SMTP
246
+ * reason is whatever the last attempted MX returned).
247
+ */
248
+ mxHostUsed?: string;
249
+ /** Total wall-clock time the probe spent, in milliseconds. */
250
+ totalDurationMs: number;
251
+ }
221
252
  /**
222
253
  * Result for batch verification
223
254
  */
@@ -263,11 +294,35 @@ export interface SMTPVerifyOptions {
263
294
  debug?: boolean;
264
295
  /**
265
296
  * When true, the returned `SmtpVerificationResult` carries `transcript` and
266
- * `commands` arrays prefixed with `<port>|s| …` / `<port>|c| …`. Aggregated
267
- * across every port attempted.
297
+ * `commands` arrays prefixed with `<host>:<port>|s| …` / `<host>:<port>|c| …`.
298
+ * Aggregated across every MX×port attempted.
299
+ *
300
+ * Default: `false`. The strings are O(N×wire-bytes); skip when you don't
301
+ * need the trace.
268
302
  */
269
303
  captureTranscript?: boolean;
270
304
  sequence?: SMTPSequence;
305
+ /**
306
+ * Override the random-local-part generator used by the catch-all probe.
307
+ * Useful for deterministic tests; receives the real local-part and domain
308
+ * so callers can derive a probe-local that matches the MX's syntax rules.
309
+ *
310
+ * Default: `<16 hex chars>-noexist` — long enough to never collide,
311
+ * structured so it's clearly synthetic and passes common syntax filters.
312
+ */
313
+ catchAllProbeLocal?: (realLocal: string, domain: string) => string;
314
+ /**
315
+ * Use SMTP PIPELINING (RFC 2920) to batch the envelope phase
316
+ * (RCPT TO real + RCPT TO probe + RSET) into one `socket.write()` when
317
+ * the MX advertises support.
318
+ *
319
+ * - `'auto'` (default): pipeline when EHLO multi-line includes
320
+ * `PIPELINING`, sequential otherwise.
321
+ * - `'never'`: always sequential — useful for deterministic wire-level
322
+ * assertions in tests, or when investigating a flaky pipeline-buggy MX.
323
+ * - `'force'`: pipeline without checking — testing escape hatch.
324
+ */
325
+ pipelining?: 'auto' | 'never' | 'force';
271
326
  }
272
327
  export interface VerifyMailboxSMTPParams {
273
328
  local: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailcheck/email-validator-js",
3
- "version": "3.4.4",
3
+ "version": "4.0.0-beta.1",
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": [
@@ -87,6 +87,10 @@
87
87
  "files": [
88
88
  "dist"
89
89
  ],
90
+ "publishConfig": {
91
+ "access": "public",
92
+ "provenance": true
93
+ },
90
94
  "scripts": {
91
95
  "build": "rm -rf dist && rollup -c rollup.config.cjs && rollup -c rollup.config.serverless.cjs && cp src/*.json dist/ && chmod +x dist/cli/index.js",
92
96
  "build:main": "rollup -c rollup.config.cjs",
@@ -136,20 +140,26 @@
136
140
  "@rollup/plugin-node-resolve": "^16.0.3",
137
141
  "@rollup/plugin-terser": "^1.0.0",
138
142
  "@rollup/plugin-typescript": "^12.3.0",
143
+ "@semantic-release/commit-analyzer": "^13.0.1",
144
+ "@semantic-release/github": "^12.0.6",
145
+ "@semantic-release/npm": "^13.1.5",
146
+ "@semantic-release/release-notes-generator": "^14.1.0",
139
147
  "@types/aws-lambda": "^8.10.161",
140
148
  "@types/bun": "^1.3.13",
141
149
  "@types/node": "25.6.0",
150
+ "conventional-changelog-conventionalcommits": "^9.3.1",
142
151
  "esbuild": "^0.28.0",
143
152
  "husky": "9.1.7",
144
153
  "lint-staged": "16.4.0",
145
154
  "rollup": "^4.60.2",
146
155
  "rollup-plugin-esbuild": "^6.2.1",
156
+ "semantic-release": "^25.0.3",
147
157
  "tslib": "^2.8.1",
148
158
  "typescript": "6.0.3"
149
159
  },
150
160
  "packageManager": "bun@1.3.13",
151
161
  "engines": {
152
- "node": ">= 18.0",
162
+ "node": ">= 22.0",
153
163
  "bun": ">= 1.3"
154
164
  }
155
165
  }