@emailcheck/email-validator-js 2.13.1-beta.0 → 2.13.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 CHANGED
@@ -129,79 +129,57 @@ const result = await verifyEmail({
129
129
  timeout: 3000
130
130
  });
131
131
 
132
- console.log(result.validFormat); // true
133
- console.log(result.validMx); // true
134
- console.log(result.validSmtp); // true or false
132
+ console.log(result.validFormat); // true
133
+ console.log(result.validMx); // true or false
134
+ console.log(result.validSmtp); // true or false
135
135
  ```
136
136
 
137
137
  ## API Reference
138
138
 
139
139
  ### Core Functions
140
140
 
141
- #### `verifyEmail(params: IVerifyEmailParams): Promise<IVerifyEmailResult>`
141
+ #### `verifyEmail(params: IVerifyEmailParams): Promise<VerificationResult>`
142
142
 
143
- Basic email verification with backward compatibility.
143
+ Comprehensive email verification with detailed results and error codes.
144
144
 
145
145
  **Parameters:**
146
146
  - `emailAddress` (string, required): Email address to verify
147
147
  - `timeout` (number): Timeout in milliseconds (default: 4000)
148
- - `verifyMx` (boolean): Check MX records (default: false)
148
+ - `verifyMx` (boolean): Check MX records (default: true)
149
149
  - `verifySmtp` (boolean): Verify SMTP connection (default: false)
150
150
  - `smtpPort` (number): Custom SMTP port
151
151
  - `debug` (boolean): Enable debug logging (default: false)
152
+ - `checkDisposable` (boolean): Check for disposable emails (default: true)
153
+ - `checkFree` (boolean): Check for free email providers (default: true)
154
+ - `retryAttempts` (number): Retry attempts for failures (default: 1)
152
155
  - `detectName` (boolean): Detect names from email address (default: false)
153
156
  - `nameDetectionMethod` (function): Custom name detection method
154
- - `suggestDomain` (boolean): Enable domain typo suggestions (default: false)
157
+ - `suggestDomain` (boolean): Enable domain typo suggestions (default: true)
155
158
  - `domainSuggestionMethod` (function): Custom domain suggestion method
156
159
  - `commonDomains` (string[]): Custom list of domains for suggestions
160
+ - `checkDomainAge` (boolean): Check domain age (default: false)
161
+ - `checkDomainRegistration` (boolean): Check domain registration status (default: false)
162
+ - `whoisTimeout` (number): WHOIS lookup timeout (default: 5000)
163
+ - `debug` (boolean): Enable debug logging including WHOIS lookups (default: false)
164
+ - `cache` (ICache): Optional custom cache instance
157
165
 
158
166
  **Returns:**
159
167
  ```typescript
160
168
  {
169
+ email: string;
161
170
  validFormat: boolean;
162
171
  validMx: boolean | null;
163
172
  validSmtp: boolean | null;
173
+ isDisposable: boolean;
174
+ isFree: boolean;
164
175
  detectedName?: DetectedName | null;
165
- domainSuggestion?: DomainSuggestion | null;
166
- }
167
- ```
168
-
169
- #### `verifyEmailDetailed(params: IVerifyEmailParams): Promise<DetailedVerificationResult>`
170
-
171
- Advanced verification with detailed results and error codes.
172
-
173
- **Additional Parameters:**
174
- - `checkDisposable` (boolean): Check for disposable emails (default: true)
175
- - `checkFree` (boolean): Check for free email providers (default: true)
176
- - `retryAttempts` (number): Retry attempts for failures (default: 1)
177
- - `detectName` (boolean): Detect names from email address (default: false)
178
- - `suggestDomain` (boolean): Enable domain typo suggestions (default: true in detailed mode)
179
-
180
- **Returns:**
181
- ```typescript
182
- {
183
- valid: boolean;
184
- email: string;
185
- format: {
186
- valid: boolean;
187
- error?: VerificationErrorCode;
188
- };
189
- domain: {
190
- valid: boolean | null;
191
- mxRecords?: string[];
192
- error?: VerificationErrorCode;
193
- };
194
- smtp: {
195
- valid: boolean | null;
196
- error?: VerificationErrorCode;
197
- };
198
- disposable: boolean;
199
- freeProvider: boolean;
200
- detectedName?: DetectedName | null;
176
+ domainAge?: DomainAgeInfo | null;
177
+ domainRegistration?: DomainRegistrationInfo | null;
201
178
  domainSuggestion?: DomainSuggestion | null;
202
179
  metadata?: {
203
180
  verificationTime: number;
204
181
  cached: boolean;
182
+ error?: VerificationErrorCode;
205
183
  };
206
184
  }
207
185
  ```
@@ -213,7 +191,6 @@ Verify multiple emails in parallel with concurrency control.
213
191
  **Parameters:**
214
192
  - `emailAddresses` (string[], required): Array of emails to verify
215
193
  - `concurrency` (number): Parallel processing limit (default: 5)
216
- - `detailed` (boolean): Return detailed results (default: false)
217
194
  - `detectName` (boolean): Detect names from email addresses
218
195
  - `suggestDomain` (boolean): Enable domain typo suggestions
219
196
  - Other parameters from `verifyEmail`
@@ -221,7 +198,7 @@ Verify multiple emails in parallel with concurrency control.
221
198
  **Returns:**
222
199
  ```typescript
223
200
  {
224
- results: Map<string, DetailedVerificationResult | IVerifyEmailResult>;
201
+ results: Map<string, VerificationResult>;
225
202
  summary: {
226
203
  total: number;
227
204
  valid: number;
@@ -591,32 +568,33 @@ Number of retry attempts for transient failures. Default: `1`.
591
568
  ```typescript
592
569
  import { verifyEmail } from '@emailcheck/email-validator-js';
593
570
 
594
- const { validFormat, validSmtp, validMx } = await verifyEmail({
595
- emailAddress: 'foo@email.com',
596
- verifyMx: true,
597
- verifySmtp: true,
598
- timeout: 3000
571
+ const result = await verifyEmail({
572
+ emailAddress: 'foo@email.com',
573
+ verifyMx: true,
574
+ verifySmtp: true,
575
+ timeout: 3000
599
576
  });
600
- // validFormat: true
601
- // validMx: true
602
- // validSmtp: true
577
+ console.log(result.validFormat); // true
578
+ console.log(result.validMx); // true
579
+ console.log(result.validSmtp); // true
603
580
  ```
604
581
 
605
582
  ### Detailed Verification (NEW)
606
583
  ```typescript
607
- import { verifyEmailDetailed } from '@emailcheck/email-validator-js';
584
+ import { verifyEmail } from '@emailcheck/email-validator-js';
608
585
 
609
- const result = await verifyEmailDetailed({
586
+ const result = await verifyEmail({
610
587
  emailAddress: 'foo@email.com',
611
588
  verifyMx: true,
612
589
  verifySmtp: true,
613
590
  checkDisposable: true,
614
591
  checkFree: true
615
592
  });
616
- // result.valid: true
617
- // result.disposable: false
618
- // result.freeProvider: false
619
- // result.domain.mxRecords: ['mx1.email.com', 'mx2.email.com']
593
+ // result.validFormat: true
594
+ // result.validMx: true
595
+ // result.validSmtp: true
596
+ // result.isDisposable: false
597
+ // result.isFree: false
620
598
  // result.metadata.verificationTime: 125
621
599
  ```
622
600
 
@@ -630,7 +608,8 @@ const result = await verifyEmailBatch({
630
608
  emailAddresses: emails,
631
609
  concurrency: 5,
632
610
  verifyMx: true,
633
- detailed: true
611
+ checkDisposable: true,
612
+ checkFree: true
634
613
  });
635
614
  // result.summary.valid: 2
636
615
  // result.summary.invalid: 1
@@ -639,7 +618,7 @@ const result = await verifyEmailBatch({
639
618
 
640
619
  ### Name Detection (ENHANCED)
641
620
  ```typescript
642
- import { detectName, verifyEmailDetailed } from '@emailcheck/email-validator-js';
621
+ import { detectName, verifyEmail } from '@emailcheck/email-validator-js';
643
622
 
644
623
  // Standalone name detection - now with composite name support
645
624
  const name = detectName('john.doe@mydomain.com');
@@ -657,7 +636,7 @@ const withSuffix = detectName('jane.smith.dev@mydomain.com');
657
636
  // withSuffix: { firstName: 'Jane', lastName: 'Smith', confidence: 0.7 }
658
637
 
659
638
  // Integrated with email verification
660
- const result = await verifyEmailDetailed({
639
+ const result = await verifyEmail({
661
640
  emailAddress: 'jane_smith@mydomain.com',
662
641
  detectName: true
663
642
  });
@@ -678,14 +657,14 @@ const resultCustom = await verifyEmail({
678
657
 
679
658
  ### Domain Typo Detection (NEW)
680
659
  ```typescript
681
- import { suggestEmailDomain, verifyEmailDetailed } from '@emailcheck/email-validator-js';
660
+ import { suggestEmailDomain, verifyEmail } from '@emailcheck/email-validator-js';
682
661
 
683
662
  // Standalone domain suggestion
684
663
  const suggestion = suggestEmailDomain('user@gmial.com');
685
664
  // suggestion: { original: 'user@gmial.com', suggested: 'user@gmail.com', confidence: 0.95 }
686
665
 
687
666
  // Integrated with email verification (enabled by default in detailed mode)
688
- const result = await verifyEmailDetailed({
667
+ const result = await verifyEmail({
689
668
  emailAddress: 'john@yaho.com',
690
669
  suggestDomain: true // Default: true for detailed verification
691
670
  });
@@ -705,20 +684,20 @@ const resultCustom = await verifyEmail({
705
684
 
706
685
  When a domain does not exist or has no MX records:
707
686
  ```typescript
708
- const result = await verifyEmail({
709
- emailAddress: 'foo@bad-domain.com',
710
- verifyMx: true,
711
- verifySmtp: true
687
+ const result = await verifyEmail({
688
+ emailAddress: 'foo@bad-domain.com',
689
+ verifyMx: true,
690
+ verifySmtp: true
712
691
  });
713
- // validFormat: true
714
- // validMx: false
715
- // validSmtp: null (couldn't be performed)
692
+ // result.validFormat: true (format is valid)
693
+ // result.validMx: false (no MX records)
694
+ // result.validSmtp: null (couldn't be performed)
716
695
  ```
717
696
 
718
697
  ### Using Detailed Verification for Better Insights
719
698
 
720
699
  ```typescript
721
- const detailed = await verifyEmailDetailed({
700
+ const result = await verifyEmail({
722
701
  emailAddress: 'user@suspicious-domain.com',
723
702
  verifyMx: true,
724
703
  verifySmtp: true,
@@ -726,8 +705,14 @@ const detailed = await verifyEmailDetailed({
726
705
  checkFree: true
727
706
  });
728
707
 
729
- if (!detailed.valid) {
730
- switch (detailed.domain.error) {
708
+ if (!result.validFormat) {
709
+ console.log('Invalid email format');
710
+ } else if (!result.validMx) {
711
+ console.log('Invalid domain - no MX records');
712
+ } else if (result.isDisposable) {
713
+ console.log('Disposable email detected');
714
+ } else if (result.metadata?.error) {
715
+ switch (result.metadata.error) {
731
716
  case VerificationErrorCode.DISPOSABLE_EMAIL:
732
717
  console.log('Rejected: Disposable email');
733
718
  break;
@@ -767,7 +752,7 @@ console.log(`Time: ${batch.summary.processingTime}ms`);
767
752
  // Filter out invalid emails
768
753
  const validEmails = [];
769
754
  for (const [email, result] of batch.results) {
770
- if (result.valid) {
755
+ if (result.validFormat) {
771
756
  validEmails.push(email);
772
757
  }
773
758
  }
@@ -907,7 +892,7 @@ const customCache = CacheFactory.createCustomCache(
907
892
  );
908
893
 
909
894
  // Use with verification
910
- const result = await verifyEmailDetailed({
895
+ const result = await verifyEmail({
911
896
  emailAddress: 'user@mydomain.com',
912
897
  verifyMx: true,
913
898
  verifySmtp: true,
@@ -1058,7 +1043,7 @@ process.on('SIGTERM', async () => {
1058
1043
  });
1059
1044
  ```
1060
1045
 
1061
- **Note:** Yahoo, Hotmail, and some providers always return `validSmtp: true` as they don't allow mailbox verification.
1046
+ **Note:** Yahoo, Hotmail, and some providers always return `result.validSmtp: true` as they don't allow mailbox verification.
1062
1047
 
1063
1048
  ## 🌐 Serverless Deployment
1064
1049
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ICache } from './cache-interface';
2
- import { type DetailedVerificationResult, type IVerifyEmailParams, type IVerifyEmailResult } from './types';
2
+ import { type IVerifyEmailParams, type VerificationResult } from './types';
3
3
  export { verifyEmailBatch } from './batch';
4
4
  export { clearAllCaches } from './cache';
5
5
  export { COMMON_EMAIL_DOMAINS, defaultDomainSuggestionMethod, getDomainSimilarity, isCommonDomain, suggestDomain, suggestEmailDomain, } from './domain-suggester';
@@ -11,10 +11,6 @@ export declare function isDisposableEmail(emailOrDomain: string, cache?: ICache
11
11
  export declare function isFreeEmail(emailOrDomain: string, cache?: ICache | null): Promise<boolean>;
12
12
  export declare const domainPorts: Record<string, number>;
13
13
  /**
14
- * Verify email address with basic result format (backward compatible)
14
+ * Verify email address
15
15
  */
16
- export declare function verifyEmail(params: IVerifyEmailParams): Promise<IVerifyEmailResult>;
17
- /**
18
- * Verify email address with detailed result format
19
- */
20
- export declare function verifyEmailDetailed(params: IVerifyEmailParams): Promise<DetailedVerificationResult>;
16
+ export declare function verifyEmail(params: IVerifyEmailParams): Promise<VerificationResult>;