@kennethwkz/disposable-email-domains 1.3.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ali Torki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,520 @@
1
+ # Disposable Email Domains - TypeScript SDK
2
+
3
+ <div align="center">
4
+ <img src="assets/logo.svg" alt="Disposable Email Domains Logo" width="120" height="120">
5
+
6
+ <p><strong>A powerful TypeScript SDK for detecting disposable email addresses with DNS and SMTP validation</strong></p>
7
+
8
+ [![npm version](https://badge.fury.io/js/%40usex%2Fdisposable-email-domains.svg)](https://www.npmjs.com/package/@kennethwkz/disposable-email-domains)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ <a href="https://www.producthunt.com/products/github-192?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-detecting&#0045;disposable&#0045;email&#0045;addresses" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1021628&theme=light&t=1759345731657" alt="Detecting&#0032;disposable&#0032;email&#0032;addresses - A&#0032;powerful&#0032;SDK&#0032;for&#0032;detecting&#0032;disposable&#0032;email&#0032;addresses | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## โœจ Features
19
+
20
+ - **๐ŸŽฏ 119K+ Disposable Domains** - Real-time updates from 15+ sources
21
+ - **โšก High Performance** - Advanced caching, Trie indexing, Bloom filters
22
+ - **๐Ÿ”ง TypeScript-First** - Fully typed with strict type definitions
23
+ - **๐Ÿ›ก๏ธ Advanced Validation** - Format, MX records, SPF, DMARC, SMTP deliverability
24
+ - **๐Ÿ“Š Analytics & Insights** - Built-in metrics and performance monitoring
25
+ - **๐Ÿ’พ Flexible Caching** - Memory, Redis, Database, or custom adapters
26
+ - **๐ŸŽจ Extensible** - Plugin system for custom validation rules
27
+
28
+ <!-- START STATS -->
29
+
30
+ ## ๐Ÿ“Š Current Statistics
31
+
32
+ > **Last Updated**: April 9, 2026 at 04:48 PM GMT+8 | **Next Sync**: Automated twice daily (6 AM & 6 PM UTC)
33
+ > ๐Ÿ“‹ **[View Detailed Report](data/report.md)** | Last sync analysis and insights
34
+
35
+ <div align="center">
36
+
37
+ ### ๐ŸŽฏ Domain Coverage
38
+
39
+ | ๐Ÿ“ง **Total Domains** | ๐Ÿ†• **Recent Additions** | ๐Ÿ—‘๏ธ **Recent Removals** | ๐Ÿ“ˆ **Growth Rate** |
40
+ | :------------------: | :---------------------: | :--------------------: | :----------------: |
41
+ | **127,770** | **7,557** | **559** | **+5.48%** |
42
+
43
+ ### โšก Performance Metrics
44
+
45
+ | ๐Ÿš€ **Sync Time** | โœ… **Success Rate** | ๐Ÿ“ฆ **File Size** | ๐Ÿ”„ **Deduplication** |
46
+ | :--------------: | :-----------------: | :--------------: | :------------------: |
47
+ | **0.82s** | **100.0%** | **1.9 MB** | **164,587 removed** |
48
+
49
+ </div>
50
+
51
+ ### ๐Ÿ† Top Contributing Sources
52
+
53
+ | Repository | Domains | Success | Performance |
54
+ | ------------------------------------------------------------------------------------------------------------------------- | ------- | ------- | ---------------- |
55
+ | [kslr/disposable-email-domains](https://github.com/kslr/disposable-email-domains) | 118,653 | โœ… | 0.24s (1.8 MB) |
56
+ | [FGRibreau/mailchecker](https://github.com/FGRibreau/mailchecker) | 55,911 | โœ… | 0.21s (838.9 KB) |
57
+ | [wesbos/burner-email-providers](https://github.com/wesbos/burner-email-providers) | 27,284 | โœ… | 0.06s (388.1 KB) |
58
+ | [groundcat/disposable-email-domain-list](https://github.com/groundcat/disposable-email-domain-list) | 27,120 | โœ… | 0.19s (401.7 KB) |
59
+ | [disposable/disposable-email-domains](https://github.com/disposable/disposable-email-domains) | 26,548 | โœ… | 0.14s (371.1 KB) |
60
+ | [sublime-security/static-files](https://github.com/sublime-security/static-files) | 10,523 | โœ… | 0.08s (144.0 KB) |
61
+ | [7c/fakefilter](https://github.com/7c/fakefilter) | 9,311 | โœ… | 0.09s (130.5 KB) |
62
+ | [disposable-email-domains/disposable-email-domains](https://github.com/disposable-email-domains/disposable-email-domains) | 5,361 | โœ… | 0.03s (68.0 KB) |
63
+ | [willwhite/freemail](https://github.com/willwhite/freemail) | 4,462 | โœ… | 0.36s (61.8 KB) |
64
+ | [eser/sanitizer-svc](https://github.com/eser/sanitizer-svc) | 3,855 | โœ… | 0.19s (48.9 KB) |
65
+
66
+ <details>
67
+ <summary>๐Ÿ“ˆ <strong>Detailed Metrics</strong></summary>
68
+
69
+ #### ๐Ÿ” Sync Analysis
70
+
71
+ - **Total Sources**: 15 repositories monitored
72
+ - **Active Sources**: 15 successfully synchronized
73
+ - **Failed Sources**: 0 temporary failures
74
+ - **Processing Efficiency**: 156007 domains/second
75
+ - **Average Download Time**: 0.14s per repository
76
+ - **Total Data Processed**: 4.3 MB
77
+
78
+ #### ๐ŸŽฏ Quality Metrics
79
+
80
+ - **Duplicate Detection**: 164,587 duplicates identified and removed
81
+ - **Data Integrity**: 100.0% repository success rate
82
+ - **Coverage Efficiency**: 43.7% unique domains retained
83
+
84
+ </details>
85
+
86
+ ---
87
+
88
+ <!-- END STATS -->
89
+
90
+ ## ๐Ÿ“ฆ Installation
91
+
92
+ ```bash
93
+ # Using bun (recommended)
94
+ bun add @kennethwkz/disposable-email-domains
95
+
96
+ # Using npm
97
+ npm install @kennethwkz/disposable-email-domains
98
+
99
+ # Using yarn
100
+ yarn add @kennethwkz/disposable-email-domains
101
+ ```
102
+
103
+ ## ๐Ÿš€ Quick Start
104
+
105
+ ### Basic Usage
106
+
107
+ ```typescript
108
+ import { DisposableEmailChecker } from "@kennethwkz/disposable-email-domains";
109
+
110
+ const checker = new DisposableEmailChecker();
111
+
112
+ // Single email check
113
+ const result = await checker.checkEmail("test@mailinator.com");
114
+ console.log(result.isDisposable); // true
115
+ console.log(result.confidence); // 95
116
+
117
+ // Batch validation
118
+ const emails = ["user@gmail.com", "temp@10minutemail.com"];
119
+ const results = await checker.checkEmailsBatch(emails);
120
+ ```
121
+
122
+ ### DNS Validation
123
+
124
+ ```typescript
125
+ const checker = new DisposableEmailChecker({
126
+ checkMxRecord: true,
127
+ dnsValidation: {
128
+ validateMxConnectivity: true,
129
+ checkSpfRecord: true,
130
+ checkDmarcRecord: true,
131
+ timeout: 5000,
132
+ retries: 3,
133
+ },
134
+ });
135
+
136
+ const result = await checker.checkEmail("user@example.com");
137
+
138
+ // Access DNS validation results
139
+ console.log(result.dnsValidation?.hasMx); // true
140
+ console.log(result.dnsValidation?.mxRecords); // [{ exchange: 'mail.example.com', priority: 10 }]
141
+ console.log(result.dnsValidation?.hasSpf); // true
142
+ console.log(result.dnsValidation?.hasDmarc); // true
143
+ console.log(result.dnsValidation?.isConnectable); // true
144
+ ```
145
+
146
+ ### SMTP Validation
147
+
148
+ ```typescript
149
+ const checker = new DisposableEmailChecker({
150
+ checkMxRecord: true,
151
+ checkSmtpDeliverability: true,
152
+ smtpValidation: {
153
+ timeout: 10000,
154
+ port: 25,
155
+ fromEmail: "test@yourdomain.com",
156
+ helo: "mail.yourdomain.com",
157
+ },
158
+ });
159
+
160
+ const result = await checker.checkEmail("user@example.com");
161
+
162
+ // Access SMTP validation results
163
+ console.log(result.smtpValidation?.isDeliverable); // true
164
+ console.log(result.smtpValidation?.responseCode); // 250
165
+ console.log(result.smtpValidation?.responseMessage); // '2.1.5 Recipient OK'
166
+ console.log(result.smtpValidation?.serverTested); // 'mail.example.com'
167
+ ```
168
+
169
+ ### Combined DNS + SMTP Validation
170
+
171
+ ```typescript
172
+ // When both are enabled, MX records from DNS are passed to SMTP (no duplicate lookups)
173
+ const checker = new DisposableEmailChecker({
174
+ checkMxRecord: true,
175
+ checkSmtpDeliverability: true,
176
+ dnsValidation: {
177
+ validateMxConnectivity: true,
178
+ checkSpfRecord: true,
179
+ checkDmarcRecord: true,
180
+ },
181
+ smtpValidation: {
182
+ timeout: 8000,
183
+ fromEmail: "test@yourdomain.com",
184
+ },
185
+ });
186
+
187
+ const result = await checker.checkEmail("user@example.com");
188
+
189
+ // Get complete validation picture
190
+ console.log({
191
+ isValid: result.isValid,
192
+ isDisposable: result.isDisposable,
193
+ hasMx: result.dnsValidation?.hasMx,
194
+ isDeliverable: result.smtpValidation?.isDeliverable,
195
+ confidence: result.confidence,
196
+ });
197
+ ```
198
+
199
+ ## ๐Ÿ“‹ Configuration
200
+
201
+ ### DisposableEmailChecker Options
202
+
203
+ ```typescript
204
+ interface EmailCheckerConfig {
205
+ // Validation Options
206
+ strictValidation?: boolean; // Strict RFC validation (default: false)
207
+ checkMxRecord?: boolean; // Enable MX checking (default: false)
208
+ checkSmtpDeliverability?: boolean; // Enable SMTP testing (default: false)
209
+ enableSubdomainChecking?: boolean; // Check subdomains (default: true)
210
+ enablePatternMatching?: boolean; // Use regex patterns (default: true)
211
+
212
+ // Performance Options
213
+ enableCaching?: boolean; // Enable caching (default: true)
214
+ cacheSize?: number; // Cache size (default: 10000)
215
+ enableIndexing?: boolean; // Use Trie/Bloom filters (default: true)
216
+ indexingStrategy?: "trie" | "bloom" | "hybrid"; // Indexing strategy (default: 'hybrid')
217
+
218
+ // DNS Validation
219
+ dnsValidation?: {
220
+ timeout?: number; // DNS timeout in ms (default: 5000)
221
+ retries?: number; // Retry attempts (default: 3)
222
+ enableCaching?: boolean; // Cache DNS results (default: true)
223
+ cacheSize?: number; // DNS cache size (default: 5000)
224
+ cacheTtl?: number; // DNS cache TTL in ms (default: 300000)
225
+ concurrency?: number; // Max concurrent queries (default: 10)
226
+ validateMxConnectivity?: boolean; // Test SMTP connectivity (default: false)
227
+ checkSpfRecord?: boolean; // Check SPF records (default: false)
228
+ checkDmarcRecord?: boolean; // Check DMARC records (default: false)
229
+ customDnsServers?: string[]; // Custom DNS servers
230
+ fallbackDnsServers?: string[]; // Fallback DNS servers
231
+ };
232
+
233
+ // SMTP Validation
234
+ smtpValidation?: {
235
+ timeout?: number; // SMTP timeout in ms (default: 10000)
236
+ port?: number; // SMTP port (default: 25)
237
+ fromEmail?: string; // FROM address (default: 'test@example.com')
238
+ helo?: string; // HELO hostname (default: 'mail.example.com')
239
+ retries?: number; // Retry attempts (default: 2)
240
+ enableCaching?: boolean; // Cache SMTP results (default: true)
241
+ cacheSize?: number; // SMTP cache size (default: 1000)
242
+ cacheTtl?: number; // SMTP cache TTL in ms (default: 600000)
243
+ };
244
+
245
+ // Data Sources
246
+ disposableDomainsUrl?: string; // Remote domain list URL
247
+ localDataPath?: string; // Local domain list path
248
+ allowlistPath?: string; // Allowlist file path
249
+ blacklistPath?: string; // Blacklist file path
250
+
251
+ // Custom Configuration
252
+ customPatterns?: RegExp[]; // Custom regex patterns
253
+ trustedDomains?: string[]; // Trusted domains (always valid)
254
+ suspiciousPatterns?: RegExp[]; // Suspicious patterns
255
+ customCache?: any; // Custom cache implementation
256
+ }
257
+ ```
258
+
259
+ ## ๐ŸŽฏ API Reference
260
+
261
+ ### Core Methods
262
+
263
+ #### `checkEmail(email: string): Promise<EmailValidationResult>`
264
+
265
+ Validates a single email address with all enabled checks.
266
+
267
+ #### `checkEmailsBatch(emails: string[]): Promise<EmailValidationResult[]>`
268
+
269
+ Validates multiple emails efficiently with batch processing.
270
+
271
+ #### `validateDomain(domain: string): Promise<DnsValidationResult>`
272
+
273
+ Performs DNS validation for a domain (requires `checkMxRecord: true`).
274
+
275
+ #### `addToAllowlist(domain: string): void`
276
+
277
+ Adds a domain to the allowlist (always considered valid).
278
+
279
+ #### `addToBlacklist(domain: string): void`
280
+
281
+ Adds a domain to the blacklist (always considered invalid).
282
+
283
+ #### `getStats(): object`
284
+
285
+ Retrieves comprehensive statistics including DNS and SMTP metrics.
286
+
287
+ #### `getMetrics(): PerformanceMetrics`
288
+
289
+ Retrieves detailed performance metrics for all validation operations.
290
+
291
+ #### `clearAllCaches(): Promise<void>`
292
+
293
+ Clears all caches (email validation, DNS, and SMTP).
294
+
295
+ ### Result Interfaces
296
+
297
+ ```typescript
298
+ interface EmailValidationResult {
299
+ email: string;
300
+ isValid: boolean;
301
+ isDisposable: boolean;
302
+ isAllowed: boolean;
303
+ isBlacklisted: boolean;
304
+ domain: string;
305
+ localPart: string;
306
+ matchType: "exact" | "subdomain" | "pattern" | "none";
307
+ confidence: number; // 0-100
308
+ validationTime: number; // milliseconds
309
+ errors: string[];
310
+ warnings: string[];
311
+
312
+ // DNS validation results (when enabled)
313
+ dnsValidation?: {
314
+ hasMx: boolean;
315
+ mxRecords: Array<{ exchange: string; priority: number }>;
316
+ hasSpf: boolean;
317
+ hasDmarc: boolean;
318
+ isConnectable: boolean;
319
+ dnsValidationTime: number;
320
+ };
321
+
322
+ // SMTP validation results (when enabled)
323
+ smtpValidation?: {
324
+ isValid: boolean;
325
+ isDeliverable: boolean;
326
+ responseCode: number | null;
327
+ responseMessage: string | null;
328
+ smtpValidationTime: number;
329
+ serverTested: string | null;
330
+ };
331
+ }
332
+ ```
333
+
334
+ ## ๐Ÿ”ง Advanced Usage
335
+
336
+ ### Standalone Components
337
+
338
+ ```typescript
339
+ import { EmailValidator, DnsResolver, SmtpValidator } from "@kennethwkz/disposable-email-domains";
340
+
341
+ // Standalone DNS resolver
342
+ const dnsResolver = new DnsResolver({
343
+ timeout: 5000,
344
+ retries: 3,
345
+ validateMxConnectivity: true,
346
+ });
347
+ const dnsResult = await dnsResolver.validateMxRecord("gmail.com");
348
+
349
+ // Standalone SMTP validator
350
+ const smtpValidator = new SmtpValidator({
351
+ timeout: 10000,
352
+ fromEmail: "test@yourdomain.com",
353
+ });
354
+ const smtpResult = await smtpValidator.validateEmail("user@example.com");
355
+
356
+ // Email validator with DNS and SMTP
357
+ const emailValidator = new EmailValidator(
358
+ false, // strict mode
359
+ { timeout: 5000, validateMxConnectivity: true }, // DNS config
360
+ { timeout: 10000, fromEmail: "test@yourdomain.com" }, // SMTP config
361
+ );
362
+ const validation = await emailValidator.validateEmailDeliverability("user@example.com");
363
+ ```
364
+
365
+ ### Custom Cache Implementation
366
+
367
+ ```typescript
368
+ import { DisposableEmailChecker, type ICache } from "@kennethwkz/disposable-email-domains";
369
+
370
+ class RedisCache implements ICache {
371
+ async get(key: string): Promise<any> {
372
+ /* ... */
373
+ }
374
+ async set(key: string, value: any, ttl?: number): Promise<void> {
375
+ /* ... */
376
+ }
377
+ async has(key: string): Promise<boolean> {
378
+ /* ... */
379
+ }
380
+ async delete(key: string): Promise<boolean> {
381
+ /* ... */
382
+ }
383
+ async clear(): Promise<void> {
384
+ /* ... */
385
+ }
386
+ async size(): Promise<number> {
387
+ /* ... */
388
+ }
389
+ }
390
+
391
+ const checker = new DisposableEmailChecker({
392
+ customCache: new RedisCache(),
393
+ });
394
+ ```
395
+
396
+ ### Performance Monitoring
397
+
398
+ ```typescript
399
+ const checker = new DisposableEmailChecker({
400
+ checkMxRecord: true,
401
+ checkSmtpDeliverability: true,
402
+ enableCaching: true,
403
+ });
404
+
405
+ // Process some emails
406
+ await checker.checkEmail("test@gmail.com");
407
+ await checker.checkEmail("temp@10minutemail.com");
408
+
409
+ // Get comprehensive statistics
410
+ const stats = checker.getStats();
411
+ console.log("Performance:", {
412
+ totalValidations: stats.performance.totalValidations,
413
+ avgTime: stats.performance.averageValidationTime,
414
+ cacheHitRate: stats.performance.cacheHitRate,
415
+ dnsStats: stats.dns,
416
+ smtpStats: stats.smtp,
417
+ });
418
+ ```
419
+
420
+ ### High-Volume Batch Processing
421
+
422
+ ```typescript
423
+ async function validateLargeList(emails: string[]) {
424
+ const checker = new DisposableEmailChecker({
425
+ enableCaching: true,
426
+ cacheSize: 50000,
427
+ checkMxRecord: true,
428
+ checkSmtpDeliverability: true,
429
+ dnsValidation: {
430
+ enableCaching: true,
431
+ cacheSize: 20000,
432
+ concurrency: 25,
433
+ },
434
+ smtpValidation: {
435
+ enableCaching: true,
436
+ cacheSize: 10000,
437
+ },
438
+ });
439
+
440
+ const batchSize = 50;
441
+ const results = [];
442
+
443
+ for (let i = 0; i < emails.length; i += batchSize) {
444
+ const batch = emails.slice(i, i + batchSize);
445
+ const batchResults = await checker.checkEmailsBatch(batch);
446
+ results.push(...batchResults);
447
+
448
+ // Add delay for SMTP validation to respect mail servers
449
+ if (i + batchSize < emails.length) {
450
+ await new Promise((resolve) => setTimeout(resolve, 2000));
451
+ }
452
+ }
453
+
454
+ return results;
455
+ }
456
+ ```
457
+
458
+ ## โšก Performance
459
+
460
+ ### Benchmarks
461
+
462
+ | Operation | Time | Cache Hit Rate | Memory |
463
+ | ----------------------------- | ----------- | -------------- | ------ |
464
+ | Single email validation | ~1-5ms | 90%+ | <5MB |
465
+ | Batch validation (100 emails) | ~50-200ms | 90%+ | <10MB |
466
+ | DNS validation | ~50-200ms | 90%+ | <10MB |
467
+ | SMTP validation | ~500-2000ms | 75%+ | <5MB |
468
+ | Combined DNS+SMTP | ~600-2200ms | 85%+ | <15MB |
469
+
470
+ ### Optimization Tips
471
+
472
+ 1. **Enable caching** for all validation types (DNS, SMTP, email)
473
+ 2. **Use appropriate batch sizes**: 100-200 for DNS, 25-50 for SMTP
474
+ 3. **Set reasonable timeouts**: 5s for DNS, 10s for SMTP
475
+ 4. **Add delays between SMTP batches** (1-2s) to respect mail servers
476
+ 5. **Use hybrid indexing** for optimal performance with large domain lists
477
+
478
+ Run benchmarks locally:
479
+
480
+ ```bash
481
+ bun run test:bench
482
+ ```
483
+
484
+ ## ๐Ÿงช Testing
485
+
486
+ ```bash
487
+ # Run all tests
488
+ bun run test
489
+
490
+ # Type checking
491
+ bun run test:types
492
+
493
+ # Coverage report
494
+ bun run test:coverage
495
+
496
+ # Benchmarks
497
+ bun run test:bench
498
+ ```
499
+
500
+ ## ๐Ÿ”„ Domain Synchronization
501
+
502
+ The domain database is automatically synchronized from 15+ trusted sources twice daily (6 AM & 6 PM UTC). See [Syncer Documentation](./docs/syncer.md) for advanced synchronization features.
503
+
504
+ ## ๐Ÿ“š Documentation
505
+
506
+ - **[API Reference](./docs/api.md)** - Complete API documentation
507
+ - **[Configuration Guide](./docs/configuration.md)** - Detailed configuration options
508
+ - **[Performance Guide](./docs/performance.md)** - Optimization techniques
509
+ - **[Examples](./examples)** - More usage examples
510
+ - **[Syncer Documentation](./docs/syncer.md)** - Domain synchronization details
511
+
512
+ ## ๐Ÿ“„ License
513
+
514
+ MIT ยฉ [Ali Torki](https://github.com/ali-master)
515
+
516
+ ---
517
+
518
+ <div align="center">
519
+ <p>Made with โค๏ธ by <a href="https://github.com/ali-master">Ali Torki</a></p>
520
+ </div>