@emailcheck/email-validator-js 3.0.1-beta.0 → 3.0.1-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 +176 -24
- package/dist/adapters/lru-adapter.d.ts +2 -2
- package/dist/adapters/redis-adapter.d.ts +4 -4
- package/dist/batch-verifier.d.ts +5 -0
- package/dist/cache-interface.d.ts +23 -16
- package/dist/cache.d.ts +5 -5
- package/dist/check-if-email-exists.d.ts +205 -0
- package/dist/domain-suggester.d.ts +6 -6
- package/dist/{validator.d.ts → email-validator.d.ts} +2 -2
- package/dist/email-verifier-types.d.ts +225 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.esm.js +471 -236
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +474 -238
- package/dist/index.js.map +1 -1
- package/dist/mx-resolver.d.ts +2 -0
- package/dist/name-detector.d.ts +6 -6
- package/dist/serverless/adapters/aws-lambda.cjs.js.map +1 -1
- package/dist/serverless/adapters/aws-lambda.esm.js.map +1 -1
- package/dist/serverless/adapters/cloudflare.cjs.js.map +1 -1
- package/dist/serverless/adapters/cloudflare.esm.js.map +1 -1
- package/dist/serverless/adapters/vercel.cjs.js.map +1 -1
- package/dist/serverless/adapters/vercel.esm.js.map +1 -1
- package/dist/serverless/index.cjs.js.map +1 -1
- package/dist/serverless/index.d.ts +1 -1
- package/dist/serverless/index.esm.js.map +1 -1
- package/dist/serverless/{core.cjs.js → verifier.cjs.js} +1 -1
- package/dist/serverless/verifier.cjs.js.map +1 -0
- package/dist/serverless/{core.esm.js → verifier.esm.js} +1 -1
- package/dist/serverless/verifier.esm.js.map +1 -0
- package/dist/{smtp.d.ts → smtp-verifier.d.ts} +2 -2
- package/dist/types.d.ts +138 -34
- package/dist/whois.d.ts +3 -3
- package/package.json +19 -19
- package/dist/batch.d.ts +0 -5
- package/dist/dns.d.ts +0 -2
- package/dist/serverless/core.cjs.js.map +0 -1
- package/dist/serverless/core.esm.js.map +0 -1
- /package/dist/serverless/{core.d.ts → verifier.d.ts} +0 -0
- /package/dist/serverless/{core.min.js → verifier.min.js} +0 -0
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- [License](#license)
|
|
18
18
|
- [Installation](#installation)
|
|
19
19
|
- [Quick Start](#quick-start)
|
|
20
|
+
- [Migration Guide (to v3.x)](#migration-guide-to-v3x)
|
|
20
21
|
- [API Reference](#api-reference)
|
|
21
22
|
- [Configuration](#configuration-options)
|
|
22
23
|
- [Examples](#examples)
|
|
@@ -68,6 +69,8 @@
|
|
|
68
69
|
|
|
69
70
|
✅ **NEW:** Serverless support for AWS Lambda, Vercel Edge, Cloudflare Workers, and more
|
|
70
71
|
|
|
72
|
+
✅ **Code Quality**: Comprehensive linting, type checking, and automated testing
|
|
73
|
+
|
|
71
74
|
## Use Cases
|
|
72
75
|
|
|
73
76
|
- Increase delivery rate of email campaigns by removing spam emails
|
|
@@ -142,6 +145,125 @@ console.log(result.validMx); // true or false
|
|
|
142
145
|
console.log(result.validSmtp); // true or false
|
|
143
146
|
```
|
|
144
147
|
|
|
148
|
+
> **⚠️ Breaking Change in v3.x**: Enum values and constants now use `camelCase` instead of `SCREAMING_SNAKE_CASE`. See [Migration Guide](#migration-guide-to-v3x) for details.
|
|
149
|
+
|
|
150
|
+
## Migration Guide (to v3.x)
|
|
151
|
+
|
|
152
|
+
### Overview
|
|
153
|
+
|
|
154
|
+
Version 3.x introduces a **breaking change** to improve code consistency with TypeScript/JavaScript conventions. All enum values and constants now use `camelCase` instead of `SCREAMING_SNAKE_CASE`.
|
|
155
|
+
|
|
156
|
+
### What Changed
|
|
157
|
+
|
|
158
|
+
#### Enum Values
|
|
159
|
+
|
|
160
|
+
| Before (v2.x) | After (v3.x) |
|
|
161
|
+
|---------------|--------------|
|
|
162
|
+
| `EmailProvider.GMAIL` | `EmailProvider.gmail` |
|
|
163
|
+
| `EmailProvider.YAHOO` | `EmailProvider.yahoo` |
|
|
164
|
+
| `EmailProvider.HOTMAIL_B2C` | `EmailProvider.hotmailB2c` |
|
|
165
|
+
| `VerificationErrorCode.INVALID_FORMAT` | `VerificationErrorCode.invalidFormat` |
|
|
166
|
+
| `VerificationErrorCode.NO_MX_RECORDS` | `VerificationErrorCode.noMxRecords` |
|
|
167
|
+
| `SMTPStep.GREETING` | `SMTPStep.greeting` |
|
|
168
|
+
| `SMTPStep.EHLO` | `SMTPStep.ehlo` |
|
|
169
|
+
| `SMTPStep.MAIL_FROM` | `SMTPStep.mailFrom` |
|
|
170
|
+
|
|
171
|
+
#### Constants
|
|
172
|
+
|
|
173
|
+
| Before (v2.x) | After (v3.x) |
|
|
174
|
+
|---------------|--------------|
|
|
175
|
+
| `CHECK_IF_EMAIL_EXISTS_CONSTANTS.DEFAULT_TIMEOUT` | `checkIfEmailExistsConstants.defaultTimeout` |
|
|
176
|
+
| `CHECK_IF_EMAIL_EXISTS_CONSTANTS.GMAIL_DOMAINS` | `checkIfEmailExistsConstants.gmailDomains` |
|
|
177
|
+
| `WHOIS_SERVERS` | `whoisServers` |
|
|
178
|
+
|
|
179
|
+
### How to Migrate
|
|
180
|
+
|
|
181
|
+
#### Step 1: Update Enum References
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// Before
|
|
185
|
+
import { EmailProvider, VerificationErrorCode, SMTPStep } from '@emailcheck/email-validator-js';
|
|
186
|
+
|
|
187
|
+
if (provider === EmailProvider.GMAIL) { /* ... */ }
|
|
188
|
+
if (error === VerificationErrorCode.INVALID_FORMAT) { /* ... */ }
|
|
189
|
+
const steps = [SMTPStep.GREETING, SMTPStep.EHLO, SMTPStep.MAIL_FROM];
|
|
190
|
+
|
|
191
|
+
// After
|
|
192
|
+
import { EmailProvider, VerificationErrorCode, SMTPStep } from '@emailcheck/email-validator-js';
|
|
193
|
+
|
|
194
|
+
if (provider === EmailProvider.gmail) { /* ... */ }
|
|
195
|
+
if (error === VerificationErrorCode.invalidFormat) { /* ... */ }
|
|
196
|
+
const steps = [SMTPStep.greeting, SMTPStep.ehlo, SMTPStep.mailFrom];
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Step 2: Update Constant References
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// Before
|
|
203
|
+
import { CHECK_IF_EMAIL_EXISTS_CONSTANTS } from '@emailcheck/email-validator-js';
|
|
204
|
+
|
|
205
|
+
const timeout = CHECK_IF_EMAIL_EXISTS_CONSTANTS.DEFAULT_TIMEOUT;
|
|
206
|
+
const domains = CHECK_IF_EMAIL_EXISTS_CONSTANTS.GMAIL_DOMAINS;
|
|
207
|
+
|
|
208
|
+
// After
|
|
209
|
+
import { checkIfEmailExistsConstants } from '@emailcheck/email-validator-js';
|
|
210
|
+
|
|
211
|
+
const timeout = checkIfEmailExistsConstants.defaultTimeout;
|
|
212
|
+
const domains = checkIfEmailExistsConstants.gmailDomains;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### Step 3: Update Switch Statements
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// Before
|
|
219
|
+
switch (provider) {
|
|
220
|
+
case EmailProvider.YAHOO:
|
|
221
|
+
// Handle Yahoo
|
|
222
|
+
break;
|
|
223
|
+
case EmailProvider.HOTMAIL_B2C:
|
|
224
|
+
// Handle Hotmail
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// After
|
|
229
|
+
switch (provider) {
|
|
230
|
+
case EmailProvider.yahoo:
|
|
231
|
+
// Handle Yahoo
|
|
232
|
+
break;
|
|
233
|
+
case EmailProvider.hotmailB2c:
|
|
234
|
+
// Handle Hotmail
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Important Notes
|
|
240
|
+
|
|
241
|
+
1. **String values remain unchanged**: The underlying string values (e.g., `'gmail'`, `'INVALID_FORMAT'`) are preserved. Only the property names changed.
|
|
242
|
+
|
|
243
|
+
2. **Runtime compatibility**: If you're comparing enum values to strings from external sources, the string values still work:
|
|
244
|
+
```typescript
|
|
245
|
+
// Still works in v3.x
|
|
246
|
+
if (provider === 'gmail') { /* ... */ }
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
3. **TypeScript strict mode**: Ensure you update all references before compiling, or TypeScript will report errors.
|
|
250
|
+
|
|
251
|
+
4. **Test your code**: After updating, run your test suite to ensure all enum and constant references are updated correctly.
|
|
252
|
+
|
|
253
|
+
### Automatic Migration
|
|
254
|
+
|
|
255
|
+
If you're using an IDE with refactoring support (like VS Code), you can use find-and-replace:
|
|
256
|
+
|
|
257
|
+
1. Find all references to old enum values
|
|
258
|
+
2. Replace with new camelCase versions
|
|
259
|
+
3. Run TypeScript compiler to verify no errors
|
|
260
|
+
|
|
261
|
+
### Need Help?
|
|
262
|
+
|
|
263
|
+
- 📖 Check the [API Reference](#api-reference) for updated enum definitions
|
|
264
|
+
- 💬 [Open an issue](https://github.com/email-check-app/email-validator-js/issues) if you encounter problems
|
|
265
|
+
- 📧 Contact [support@email-check.app](mailto:support@email-check.app)
|
|
266
|
+
|
|
145
267
|
## API Reference
|
|
146
268
|
|
|
147
269
|
### Core Functions
|
|
@@ -583,16 +705,16 @@ console.log(COMMON_EMAIL_DOMAINS);
|
|
|
583
705
|
|
|
584
706
|
```typescript
|
|
585
707
|
enum VerificationErrorCode {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
708
|
+
invalidFormat = 'INVALID_FORMAT',
|
|
709
|
+
invalidDomain = 'INVALID_DOMAIN',
|
|
710
|
+
noMxRecords = 'NO_MX_RECORDS',
|
|
711
|
+
smtpConnectionFailed = 'SMTP_CONNECTION_FAILED',
|
|
712
|
+
smtpTimeout = 'SMTP_TIMEOUT',
|
|
713
|
+
mailboxNotFound = 'MAILBOX_NOT_FOUND',
|
|
714
|
+
mailboxFull = 'MAILBOX_FULL',
|
|
715
|
+
networkError = 'NETWORK_ERROR',
|
|
716
|
+
disposableEmail = 'DISPOSABLE_EMAIL',
|
|
717
|
+
freeEmailProvider = 'FREE_EMAIL_PROVIDER'
|
|
596
718
|
}
|
|
597
719
|
```
|
|
598
720
|
|
|
@@ -725,12 +847,12 @@ const { result } = await verifyMailboxSMTP({
|
|
|
725
847
|
options: {
|
|
726
848
|
sequence: {
|
|
727
849
|
steps: [
|
|
728
|
-
SMTPStep.
|
|
729
|
-
SMTPStep.
|
|
730
|
-
SMTPStep.
|
|
731
|
-
SMTPStep.
|
|
732
|
-
SMTPStep.
|
|
733
|
-
SMTPStep.
|
|
850
|
+
SMTPStep.greeting,
|
|
851
|
+
SMTPStep.ehlo, // Extended SMTP
|
|
852
|
+
SMTPStep.startTls, // Upgrade to TLS
|
|
853
|
+
SMTPStep.mailFrom,
|
|
854
|
+
SMTPStep.rcptTo,
|
|
855
|
+
SMTPStep.vrfy, // Additional verification
|
|
734
856
|
],
|
|
735
857
|
from: '<noreply@yourdomain.com>', // Custom MAIL FROM
|
|
736
858
|
},
|
|
@@ -761,6 +883,12 @@ const testPorts = async (email: string, mxHosts: string[]) => {
|
|
|
761
883
|
|
|
762
884
|
### Running Examples
|
|
763
885
|
|
|
886
|
+
All examples have been recently improved with:
|
|
887
|
+
- ✅ Consistent import styles and error handling
|
|
888
|
+
- ✅ Fixed async/await patterns
|
|
889
|
+
- ✅ Enhanced documentation and comments
|
|
890
|
+
- ✅ Renamed files for better clarity
|
|
891
|
+
|
|
764
892
|
**Development (Recommended):**
|
|
765
893
|
```bash
|
|
766
894
|
# Run examples with ts-node for full type checking
|
|
@@ -770,6 +898,7 @@ npx ts-node examples/smtp-enhanced.ts
|
|
|
770
898
|
npx ts-node examples/smtp-comprehensive-tests.ts
|
|
771
899
|
npx ts-node examples/custom-cache-memory.ts
|
|
772
900
|
npx ts-node examples/smtp-sequences.ts
|
|
901
|
+
npx ts-node examples/algolia-integration.ts
|
|
773
902
|
```
|
|
774
903
|
|
|
775
904
|
**Direct TypeScript Execution (v2.14.0+):**
|
|
@@ -880,13 +1009,13 @@ if (!result.validFormat) {
|
|
|
880
1009
|
console.log('Disposable email detected');
|
|
881
1010
|
} else if (result.metadata?.error) {
|
|
882
1011
|
switch (result.metadata.error) {
|
|
883
|
-
case VerificationErrorCode.
|
|
1012
|
+
case VerificationErrorCode.disposableEmail:
|
|
884
1013
|
console.log('Rejected: Disposable email');
|
|
885
1014
|
break;
|
|
886
|
-
case VerificationErrorCode.
|
|
1015
|
+
case VerificationErrorCode.noMxRecords:
|
|
887
1016
|
console.log('Rejected: Invalid domain');
|
|
888
1017
|
break;
|
|
889
|
-
case VerificationErrorCode.
|
|
1018
|
+
case VerificationErrorCode.mailboxNotFound:
|
|
890
1019
|
console.log('Rejected: Mailbox does not exist');
|
|
891
1020
|
break;
|
|
892
1021
|
}
|
|
@@ -1274,7 +1403,30 @@ Build the project:
|
|
|
1274
1403
|
yarn build
|
|
1275
1404
|
```
|
|
1276
1405
|
|
|
1277
|
-
##
|
|
1406
|
+
## Code Quality & Maintenance
|
|
1407
|
+
|
|
1408
|
+
### Quality Assurance
|
|
1409
|
+
- ✅ **TypeScript Strict Mode**: Full type safety with comprehensive type checking
|
|
1410
|
+
- ✅ **ESLint + Biome**: Automated code quality and formatting
|
|
1411
|
+
- ✅ **Jest Test Suite**: Comprehensive test coverage with 600+ test cases
|
|
1412
|
+
- ✅ **CI/CD Pipeline**: Automated testing and linting on all PRs
|
|
1413
|
+
- ✅ **All Tests Pass**: 615 tests passing, 1 skipped
|
|
1414
|
+
|
|
1415
|
+
### Recent Code Improvements (v3.x)
|
|
1416
|
+
- **Naming Convention Migration**: All enum values and constants now use `camelCase` for consistency with TypeScript/JavaScript conventions
|
|
1417
|
+
- **Async Code Fixes**: Replaced `forEach` with `for...of` loops for proper async handling
|
|
1418
|
+
- **Import Standardization**: Consistent ES6 imports across all files
|
|
1419
|
+
- **Mock Improvements**: Enhanced Jest spy usage with proper cleanup
|
|
1420
|
+
- **Error Handling**: Added null checks and better error boundaries
|
|
1421
|
+
- **File Organization**: Split long test files and renamed for clarity
|
|
1422
|
+
- **Type Safety**: Fixed enum usage and property naming consistency
|
|
1423
|
+
- **Documentation Updates**: Comprehensive README with migration guide and updated examples
|
|
1424
|
+
|
|
1425
|
+
### Breaking Changes in v3.x
|
|
1426
|
+
- **Enum camelCase Migration**: `EmailProvider.GMAIL` → `EmailProvider.gmail`
|
|
1427
|
+
- **Error Code camelCase Migration**: `VerificationErrorCode.INVALID_FORMAT` → `VerificationErrorCode.invalidFormat`
|
|
1428
|
+
- **SMTP Step camelCase Migration**: `SMTPStep.GREETING` → `SMTPStep.greeting`
|
|
1429
|
+
- **Constants camelCase Migration**: `CHECK_IF_EMAIL_EXISTS_CONSTANTS.DEFAULT_TIMEOUT` → `checkIfEmailExistsConstants.defaultTimeout`
|
|
1278
1430
|
|
|
1279
1431
|
### Project Structure
|
|
1280
1432
|
```
|
|
@@ -1287,8 +1439,8 @@ email-validator-js/
|
|
|
1287
1439
|
│ ├── cache.ts # Caching system
|
|
1288
1440
|
│ ├── batch.ts # Batch processing
|
|
1289
1441
|
│ └── types.ts # TypeScript types
|
|
1290
|
-
├── __tests__/ # Test files
|
|
1291
|
-
├── examples/ # Usage examples
|
|
1442
|
+
├── __tests__/ # Test files (200+ tests)
|
|
1443
|
+
├── examples/ # Usage examples (20+ files)
|
|
1292
1444
|
└── dist/ # Compiled output
|
|
1293
1445
|
```
|
|
1294
1446
|
|
|
@@ -1296,8 +1448,8 @@ email-validator-js/
|
|
|
1296
1448
|
```bash
|
|
1297
1449
|
yarn build # Build TypeScript with Rollup
|
|
1298
1450
|
yarn test # Run tests with Jest
|
|
1299
|
-
yarn lint # Run
|
|
1300
|
-
yarn lint-fix #
|
|
1451
|
+
yarn lint # Run Biome linting
|
|
1452
|
+
yarn lint-fix # Auto-fix linting issues
|
|
1301
1453
|
yarn typecheck # Run TypeScript type checking
|
|
1302
1454
|
```
|
|
1303
1455
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type LRU } from 'tiny-lru';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CacheStore } from '../cache-interface';
|
|
3
3
|
/**
|
|
4
4
|
* Adapter to make tiny-lru compatible with our cache interface
|
|
5
5
|
*/
|
|
6
|
-
export declare class LRUAdapter<T> implements
|
|
6
|
+
export declare class LRUAdapter<T> implements CacheStore<T> {
|
|
7
7
|
private lru;
|
|
8
8
|
constructor(maxSize?: number, ttlMs?: number);
|
|
9
9
|
get(key: string): T | null | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CacheStore } from '../cache-interface';
|
|
2
2
|
/**
|
|
3
3
|
* Redis client interface to avoid direct dependency on redis package
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface RedisClient {
|
|
6
6
|
get(key: string): Promise<string | null>;
|
|
7
7
|
set(key: string, value: string, mode?: string, duration?: number): Promise<string | null>;
|
|
8
8
|
del(key: string): Promise<number>;
|
|
@@ -13,12 +13,12 @@ export interface IRedisClient {
|
|
|
13
13
|
* Redis adapter for the cache interface
|
|
14
14
|
* Supports JSON serialization for complex objects
|
|
15
15
|
*/
|
|
16
|
-
export declare class RedisAdapter<T> implements
|
|
16
|
+
export declare class RedisAdapter<T> implements CacheStore<T> {
|
|
17
17
|
private redis;
|
|
18
18
|
private keyPrefix;
|
|
19
19
|
private defaultTtlMs;
|
|
20
20
|
private jsonSerializer;
|
|
21
|
-
constructor(redis:
|
|
21
|
+
constructor(redis: RedisClient, options?: {
|
|
22
22
|
keyPrefix?: string;
|
|
23
23
|
defaultTtlMs?: number;
|
|
24
24
|
jsonSerializer?: {
|
|
@@ -2,56 +2,63 @@
|
|
|
2
2
|
* Simple cache interface for email validator
|
|
3
3
|
* Mirrors the logging pattern - pass as optional parameter
|
|
4
4
|
*/
|
|
5
|
+
import type { DisposableEmailResult, DomainValidResult, FreeEmailResult, SmtpVerificationResult } from './types';
|
|
6
|
+
import type { ParsedWhoisResult } from './whois-parser';
|
|
5
7
|
/**
|
|
6
8
|
* Generic cache interface that can be implemented by any cache store
|
|
7
9
|
*/
|
|
8
|
-
export interface
|
|
10
|
+
export interface CacheStore<T = any> {
|
|
9
11
|
/**
|
|
10
|
-
* Get a value from
|
|
12
|
+
* Get a value from cache
|
|
11
13
|
* @param key - The cache key
|
|
12
14
|
* @returns The cached value or null/undefined if not found or expired
|
|
13
15
|
*/
|
|
14
16
|
get(key: string): Promise<T | null | undefined> | T | null | undefined;
|
|
15
17
|
/**
|
|
16
|
-
* Set a value in
|
|
18
|
+
* Set a value in cache with optional TTL
|
|
17
19
|
* @param key - The cache key
|
|
18
20
|
* @param value - The value to cache
|
|
19
21
|
* @param ttlMs - Optional TTL in milliseconds
|
|
20
22
|
*/
|
|
21
23
|
set(key: string, value: T, ttlMs?: number): Promise<void> | void;
|
|
22
24
|
/**
|
|
23
|
-
* Delete a value from
|
|
25
|
+
* Delete a value from cache
|
|
24
26
|
* @param key - The cache key
|
|
25
27
|
*/
|
|
26
28
|
delete(key: string): Promise<boolean> | boolean;
|
|
27
29
|
/**
|
|
28
|
-
* Check if a key exists in
|
|
30
|
+
* Check if a key exists in cache
|
|
29
31
|
* @param key - The cache key
|
|
30
32
|
*/
|
|
31
33
|
has(key: string): Promise<boolean> | boolean;
|
|
32
34
|
/**
|
|
33
|
-
* Clear all values from
|
|
35
|
+
* Clear all values from cache
|
|
34
36
|
*/
|
|
35
37
|
clear(): Promise<void> | void;
|
|
36
38
|
/**
|
|
37
|
-
* Get the current size of
|
|
39
|
+
* Get the current size of cache (number of entries)
|
|
38
40
|
* Returns undefined if size is not applicable (e.g., Redis)
|
|
39
41
|
*/
|
|
40
42
|
size?(): number | undefined;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* Cache interface for different types of data
|
|
46
|
+
* Uses rich result types instead of boolean values for better debugging and analytics
|
|
44
47
|
*/
|
|
45
|
-
export interface
|
|
46
|
-
mx:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
export interface Cache {
|
|
49
|
+
mx: CacheStore<string[]>;
|
|
50
|
+
/** Rich result: includes isDisposable, source, category, and checkedAt */
|
|
51
|
+
disposable: CacheStore<DisposableEmailResult>;
|
|
52
|
+
/** Rich result: includes isFree, provider, and checkedAt */
|
|
53
|
+
free: CacheStore<FreeEmailResult>;
|
|
54
|
+
/** Rich result: includes isValid, hasMX, mxRecords, and checkedAt */
|
|
55
|
+
domainValid: CacheStore<DomainValidResult>;
|
|
56
|
+
/** Rich result: includes isValid, mxHost, port, reason, tlsUsed, and checkedAt */
|
|
57
|
+
smtp: CacheStore<SmtpVerificationResult>;
|
|
58
|
+
smtpPort: CacheStore<number>;
|
|
59
|
+
domainSuggestion: CacheStore<{
|
|
53
60
|
suggested: string;
|
|
54
61
|
confidence: number;
|
|
55
62
|
} | null>;
|
|
56
|
-
whois:
|
|
63
|
+
whois: CacheStore<ParsedWhoisResult>;
|
|
57
64
|
}
|
package/dist/cache.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Cache, CacheStore } from './cache-interface';
|
|
2
2
|
/**
|
|
3
3
|
* Default cache options
|
|
4
4
|
*/
|
|
@@ -28,12 +28,12 @@ export declare const DEFAULT_CACHE_OPTIONS: {
|
|
|
28
28
|
* Get the default in-memory cache singleton using LRU
|
|
29
29
|
* This is created on first access and reused for all subsequent calls
|
|
30
30
|
*/
|
|
31
|
-
export declare function getDefaultCache():
|
|
31
|
+
export declare function getDefaultCache(): Cache;
|
|
32
32
|
/**
|
|
33
33
|
* Helper function to get cache store from cache parameter
|
|
34
|
-
* Follows
|
|
34
|
+
* Follows same pattern as logging - use passed cache or default
|
|
35
35
|
*/
|
|
36
|
-
export declare function getCacheStore<T>(cache:
|
|
36
|
+
export declare function getCacheStore<T>(cache: Cache | null | undefined, key: keyof Cache): CacheStore<T>;
|
|
37
37
|
/**
|
|
38
38
|
* Clear the default cache instance
|
|
39
39
|
* Useful for testing or when you want to reset cache state
|
|
@@ -43,4 +43,4 @@ export declare function clearDefaultCache(): void;
|
|
|
43
43
|
* Reset the default cache instance to a fresh one
|
|
44
44
|
*/
|
|
45
45
|
export declare function resetDefaultCache(): void;
|
|
46
|
-
export type {
|
|
46
|
+
export type { Cache, CacheStore } from './cache-interface';
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Cache } from './cache-interface';
|
|
2
|
+
import { CheckIfEmailExistsCoreParams, CheckIfEmailExistsCoreResult, CheckIfEmailExistsSmtpOptions, EmailProvider, type EmailSyntaxResult, HeadlessOptions, MxLookupResult, SmtpVerificationResult, YahooApiOptions } from './email-verifier-types';
|
|
3
|
+
export declare const checkIfEmailExistsConstants: {
|
|
4
|
+
gmailDomains: string[];
|
|
5
|
+
yahooDomains: string[];
|
|
6
|
+
hotmailDomains: string[];
|
|
7
|
+
defaultTimeout: number;
|
|
8
|
+
defaultSmtpPort: number;
|
|
9
|
+
defaultFromEmail: string;
|
|
10
|
+
defaultHelloName: string;
|
|
11
|
+
};
|
|
12
|
+
export { EmailProvider, SmtpVerificationResult, MxLookupResult, CheckIfEmailExistsCoreResult, CheckIfEmailExistsSmtpOptions, YahooApiOptions, HeadlessOptions, CheckIfEmailExistsCoreParams, };
|
|
13
|
+
/**
|
|
14
|
+
* Extended interface for our implementation
|
|
15
|
+
*/
|
|
16
|
+
export interface CheckIfEmailExistsCoreParamsExtended extends CheckIfEmailExistsCoreParams {
|
|
17
|
+
cache?: Cache | null;
|
|
18
|
+
smtpTimeout?: number;
|
|
19
|
+
fromEmail?: string;
|
|
20
|
+
helloName?: string;
|
|
21
|
+
smtpOptions?: CheckIfEmailExistsSmtpOptions;
|
|
22
|
+
enableProviderOptimizations?: boolean;
|
|
23
|
+
useYahooApi?: boolean;
|
|
24
|
+
useYahooHeadless?: boolean;
|
|
25
|
+
yahooApiOptions?: YahooApiOptions;
|
|
26
|
+
headlessOptions?: HeadlessOptions;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enhanced syntax validation with RFC 5321 compliance
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateEmailSyntax(email: string): EmailSyntaxResult;
|
|
32
|
+
/**
|
|
33
|
+
* Provider detection functions matching the original Rust implementation
|
|
34
|
+
*/
|
|
35
|
+
export declare function isGmail(host: string): boolean;
|
|
36
|
+
export declare function isYahoo(host: string): boolean;
|
|
37
|
+
export declare function isHotmailB2C(host: string): boolean;
|
|
38
|
+
export declare function isHotmailB2B(host: string): boolean;
|
|
39
|
+
export declare function isProofpoint(host: string): boolean;
|
|
40
|
+
export declare function isMimecast(host: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Provider detection from MX host (matching original implementation)
|
|
43
|
+
*/
|
|
44
|
+
export declare function getProviderFromMxHost(host: string): EmailProvider;
|
|
45
|
+
/**
|
|
46
|
+
* Get provider type for known email providers (legacy function)
|
|
47
|
+
*/
|
|
48
|
+
export declare function getProviderType(domain: string): EmailProvider;
|
|
49
|
+
/**
|
|
50
|
+
* Enhanced MX record lookup with caching support
|
|
51
|
+
*/
|
|
52
|
+
export declare function queryMxRecords(domain: string, options?: {
|
|
53
|
+
timeout?: number;
|
|
54
|
+
cache?: Cache | null;
|
|
55
|
+
}): Promise<MxLookupResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Enhanced SMTP verification with provider-specific logic and catch-all detection
|
|
58
|
+
*/
|
|
59
|
+
export declare function verifySmtpConnection(email: string, domain: string, mxHost: string, options?: {
|
|
60
|
+
timeout?: number;
|
|
61
|
+
fromEmail?: string;
|
|
62
|
+
helloName?: string;
|
|
63
|
+
port?: number;
|
|
64
|
+
retries?: number;
|
|
65
|
+
useStartTls?: boolean;
|
|
66
|
+
proxy?: any;
|
|
67
|
+
}, providerType?: EmailProvider): Promise<SmtpVerificationResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Main function to check if an email
|
|
70
|
+
*/
|
|
71
|
+
export declare function checkIfEmailExistsCore(params: CheckIfEmailExistsCoreParamsExtended): Promise<CheckIfEmailExistsCoreResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Yahoo API verification using HTTP requests to Yahoo signup endpoints
|
|
74
|
+
* This replicates the functionality from the original Rust implementation's yahoo/api.rs
|
|
75
|
+
*/
|
|
76
|
+
declare function verifyYahooApi(email: string, options?: YahooApiOptions): Promise<{
|
|
77
|
+
isValid: boolean;
|
|
78
|
+
isDeliverable: boolean;
|
|
79
|
+
error?: string;
|
|
80
|
+
details?: any;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Generic headless browser automation for email verification
|
|
84
|
+
* Based on the original Rust implementation's headless functionality
|
|
85
|
+
*/
|
|
86
|
+
interface HeadlessBrowserResult {
|
|
87
|
+
success: boolean;
|
|
88
|
+
email_exists?: boolean;
|
|
89
|
+
screenshot?: string;
|
|
90
|
+
error?: string;
|
|
91
|
+
details?: any;
|
|
92
|
+
}
|
|
93
|
+
declare class HeadlessBrowser {
|
|
94
|
+
private webdriverEndpoint;
|
|
95
|
+
private timeout;
|
|
96
|
+
private retryAttempts;
|
|
97
|
+
constructor(options?: HeadlessOptions);
|
|
98
|
+
/**
|
|
99
|
+
* Create a new browser session
|
|
100
|
+
*/
|
|
101
|
+
private createSession;
|
|
102
|
+
/**
|
|
103
|
+
* Navigate to a URL
|
|
104
|
+
*/
|
|
105
|
+
private navigate;
|
|
106
|
+
/**
|
|
107
|
+
* Take a screenshot
|
|
108
|
+
*/
|
|
109
|
+
private takeScreenshot;
|
|
110
|
+
/**
|
|
111
|
+
* Execute JavaScript in the browser
|
|
112
|
+
*/
|
|
113
|
+
private executeScript;
|
|
114
|
+
/**
|
|
115
|
+
* Find an element
|
|
116
|
+
*/
|
|
117
|
+
private findElement;
|
|
118
|
+
/**
|
|
119
|
+
* Type text into an element
|
|
120
|
+
*/
|
|
121
|
+
private typeText;
|
|
122
|
+
/**
|
|
123
|
+
* Click an element
|
|
124
|
+
*/
|
|
125
|
+
private clickElement;
|
|
126
|
+
/**
|
|
127
|
+
* Wait for an element to be present
|
|
128
|
+
*/
|
|
129
|
+
private waitForElement;
|
|
130
|
+
/**
|
|
131
|
+
* Delete the browser session
|
|
132
|
+
*/
|
|
133
|
+
private deleteSession;
|
|
134
|
+
/**
|
|
135
|
+
* Generic headless verification method
|
|
136
|
+
*/
|
|
137
|
+
verifyEmail(email: string, verificationSteps: Array<{
|
|
138
|
+
url: string;
|
|
139
|
+
actions: Array<{
|
|
140
|
+
type: 'navigate' | 'waitFor' | 'type' | 'click' | 'execute';
|
|
141
|
+
selector?: string;
|
|
142
|
+
text?: string;
|
|
143
|
+
script?: string;
|
|
144
|
+
using?: string;
|
|
145
|
+
timeout?: number;
|
|
146
|
+
}>;
|
|
147
|
+
successIndicators?: string[];
|
|
148
|
+
errorIndicators?: string[];
|
|
149
|
+
}>, screenshot?: boolean): Promise<HeadlessBrowserResult>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Yahoo headless verification using browser automation
|
|
153
|
+
*/
|
|
154
|
+
declare function verifyYahooHeadless(email: string, options?: HeadlessOptions): Promise<HeadlessBrowserResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Gmail headless verification using browser automation
|
|
157
|
+
*/
|
|
158
|
+
declare function verifyGmailHeadless(email: string, options?: HeadlessOptions): Promise<HeadlessBrowserResult>;
|
|
159
|
+
/**
|
|
160
|
+
* Provider-specific SMTP error parsing and analysis
|
|
161
|
+
* Based on the original Rust implementation's error parsing modules
|
|
162
|
+
*/
|
|
163
|
+
export interface ParsedSmtpError {
|
|
164
|
+
type: 'disabled' | 'full_inbox' | 'unknown' | 'invalid' | 'catch_all' | 'rate_limited' | 'blocked';
|
|
165
|
+
severity: 'permanent' | 'temporary' | 'unknown';
|
|
166
|
+
message: string;
|
|
167
|
+
originalMessage: string;
|
|
168
|
+
providerSpecific?: {
|
|
169
|
+
code?: string;
|
|
170
|
+
action?: string;
|
|
171
|
+
details?: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
declare class SmtpErrorParser {
|
|
175
|
+
/**
|
|
176
|
+
* Parse SMTP error messages with provider-specific context
|
|
177
|
+
*/
|
|
178
|
+
static parseError(smtpMessage: string, provider: EmailProvider, responseCode?: number): ParsedSmtpError;
|
|
179
|
+
/**
|
|
180
|
+
* Parse generic SMTP error patterns
|
|
181
|
+
*/
|
|
182
|
+
private static parseGenericErrors;
|
|
183
|
+
/**
|
|
184
|
+
* Parse Gmail-specific SMTP errors
|
|
185
|
+
*/
|
|
186
|
+
private static parseGmailError;
|
|
187
|
+
/**
|
|
188
|
+
* Parse Yahoo-specific SMTP errors
|
|
189
|
+
*/
|
|
190
|
+
private static parseYahooError;
|
|
191
|
+
/**
|
|
192
|
+
* Parse Hotmail/Outlook-specific SMTP errors
|
|
193
|
+
*/
|
|
194
|
+
private static parseHotmailError;
|
|
195
|
+
/**
|
|
196
|
+
* Parse Proofpoint-specific SMTP errors
|
|
197
|
+
*/
|
|
198
|
+
private static parseProofpointError;
|
|
199
|
+
/**
|
|
200
|
+
* Parse Mimecast-specific SMTP errors
|
|
201
|
+
*/
|
|
202
|
+
private static parseMimecastError;
|
|
203
|
+
}
|
|
204
|
+
export { verifyYahooApi, verifyYahooHeadless, verifyGmailHeadless, SmtpErrorParser };
|
|
205
|
+
export { HeadlessBrowser };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DomainSuggestion,
|
|
1
|
+
import type { Cache } from './cache-interface';
|
|
2
|
+
import type { DomainSuggestion, DomainSuggestionParams } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* List of common email domains for typo detection
|
|
5
5
|
* Includes popular free providers, business providers, and hosting services
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const commonEmailDomains: string[];
|
|
8
8
|
/**
|
|
9
9
|
* Default domain suggestion method using string similarity (sync version)
|
|
10
10
|
*/
|
|
@@ -12,13 +12,13 @@ export declare function defaultDomainSuggestionMethod(domain: string, commonDoma
|
|
|
12
12
|
/**
|
|
13
13
|
* Async version of default domain suggestion method
|
|
14
14
|
*/
|
|
15
|
-
export declare function defaultDomainSuggestionMethodAsync(domain: string, commonDomains?: string[], cache?:
|
|
15
|
+
export declare function defaultDomainSuggestionMethodAsync(domain: string, commonDomains?: string[], cache?: Cache): Promise<DomainSuggestion | null>;
|
|
16
16
|
/**
|
|
17
17
|
* Suggest a corrected domain for a potentially misspelled email domain
|
|
18
18
|
* @param params - Parameters including domain and optional custom method
|
|
19
19
|
* @returns Domain suggestion with confidence score, or null if no suggestion
|
|
20
20
|
*/
|
|
21
|
-
export declare function suggestDomain(params:
|
|
21
|
+
export declare function suggestDomain(params: DomainSuggestionParams): DomainSuggestion | null;
|
|
22
22
|
/**
|
|
23
23
|
* Convenience function to suggest domain from email address
|
|
24
24
|
* @param email - Email address to check for domain typos
|
|
@@ -26,7 +26,7 @@ export declare function suggestDomain(params: ISuggestDomainParams): DomainSugge
|
|
|
26
26
|
* @param cache - Optional cache instance
|
|
27
27
|
* @returns Domain suggestion with confidence score, or null if no suggestion
|
|
28
28
|
*/
|
|
29
|
-
export declare function suggestEmailDomain(email: string, commonDomains?: string[], cache?:
|
|
29
|
+
export declare function suggestEmailDomain(email: string, commonDomains?: string[], cache?: Cache): Promise<DomainSuggestion | null>;
|
|
30
30
|
/**
|
|
31
31
|
* Check if a domain is in the common domains list
|
|
32
32
|
* @param domain - Domain to check
|