@emailcheck/email-validator-js 3.4.4 → 4.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 CHANGED
@@ -91,7 +91,7 @@ pnpm add @emailcheck/email-validator-js
91
91
  ```
92
92
 
93
93
  ### Requirements (consumers)
94
- - Node.js >= 18 (runtime target the published bundle is plain Node.js + ESM/CJS)
94
+ - Node.js >= 22 (currently-supported LTS lines: 22 Maintenance, 24 Active)
95
95
  - TypeScript >= 4.0 (for TypeScript users)
96
96
 
97
97
  ### Requirements (contributing)
@@ -864,7 +864,7 @@ bun run examples/high-level/advanced-usage.ts
864
864
  bun run examples/integrations/algolia.ts
865
865
  ```
866
866
 
867
- **After installation in your own project (Node 20.10+):**
867
+ **After installation in your own project (Node 22+):**
868
868
 
869
869
  ```bash
870
870
  node --experimental-strip-types examples/smtp/usage.ts
@@ -1386,7 +1386,7 @@ app.http('validateEmail', {
1386
1386
 
1387
1387
  ### Edge MX support via the built-in DoH resolver
1388
1388
 
1389
- A built-in `DoHResolver` ships with the package — works in any runtime with `fetch` (Cloudflare Workers, Vercel Edge, Deno, browsers, Node 18+):
1389
+ A built-in `DoHResolver` ships with the package — works in any runtime with `fetch` (Cloudflare Workers, Vercel Edge, Deno, browsers, Node 22+):
1390
1390
 
1391
1391
  ```typescript
1392
1392
  import {
@@ -1485,6 +1485,41 @@ const parsed = parseSmtpError('552 5.2.2 mailbox over quota');
1485
1485
 
1486
1486
  The four flags are orthogonal — a single message can fire multiple. See `__tests__/0112-smtp-error-parser.test.ts` for the full classification matrix.
1487
1487
 
1488
+ ### Refining a coarse reason via the RFC 3463 enhanced status
1489
+
1490
+ `verifyMailboxSMTP` returns a coarse `error` reason (`not_found` / `over_quota` / `temporary_failure` / `ambiguous` / …) that's stable across MX implementations. When the MX includes an enhanced status code (RFC 3463) — e.g. `5.1.1` for "user unknown" vs. `5.7.1` for "policy block" — pipe both through `refineReasonByEnhancedStatus` to get a more specific reason:
1491
+
1492
+ ```typescript
1493
+ import { refineReasonByEnhancedStatus, verifyMailboxSMTP } from '@emailcheck/email-validator-js';
1494
+
1495
+ const { smtpResult } = await verifyMailboxSMTP({
1496
+ local: 'alice', domain: 'example.com', mxRecords: ['mx.example.com'],
1497
+ });
1498
+ const refined = refineReasonByEnhancedStatus(smtpResult.error, smtpResult.enhancedStatus);
1499
+ // e.g. 'mailbox_does_not_exist' instead of 'not_found' when the MX returned 550 5.1.1
1500
+ ```
1501
+
1502
+ Mapping (codes not in the table return the original reason unchanged):
1503
+
1504
+ | DSN code | Refined reason |
1505
+ | --------- | ------------------------------------ |
1506
+ | `5.1.1` | `mailbox_does_not_exist` |
1507
+ | `5.1.2` | `bad_destination_system` |
1508
+ | `5.1.3` | `bad_destination_address` |
1509
+ | `5.1.6` | `mailbox_moved` |
1510
+ | `5.1.10` | `recipient_address_has_null_mx` |
1511
+ | `5.2.0` | `mailbox_status_other` |
1512
+ | `5.2.1` | `mailbox_disabled` |
1513
+ | `5.2.2` | `mailbox_full` |
1514
+ | `5.2.3` | `message_too_long` |
1515
+ | `5.2.4` | `mailing_list_expansion_problem` |
1516
+ | `4.4.1` | `no_answer_from_host` |
1517
+ | `4.4.2` | `bad_connection` |
1518
+ | `5.7.0` | `security_other` |
1519
+ | `5.7.1` | `delivery_not_authorized` |
1520
+ | `5.7.25` | `no_reverse_dns` |
1521
+ | `5.7.26` | `multiple_authentication_failures` |
1522
+
1488
1523
  ## 📊 Performance & Caching
1489
1524
 
1490
1525
  The library includes intelligent caching to improve performance:
@@ -5,9 +5,11 @@
5
5
  import type { DisposableEmailResult, DomainValidResult, FreeEmailResult, SmtpVerificationResult } from './types';
6
6
  import type { ParsedWhoisResult } from './whois-parser';
7
7
  /**
8
- * Generic cache interface that can be implemented by any cache store
8
+ * Generic cache interface that can be implemented by any cache store.
9
+ * Default type parameter is `unknown` — callers should narrow it
10
+ * (`CacheStore<DisposableEmailResult>`) rather than relying on the default.
9
11
  */
10
- export interface CacheStore<T = any> {
12
+ export interface CacheStore<T = unknown> {
11
13
  /**
12
14
  * Get a value from cache
13
15
  * @param key - The cache key