@emailcheck/email-validator-js 2.13.1-beta.1 → 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,17 +129,16 @@ const result = await verifyEmail({
129
129
  timeout: 3000
130
130
  });
131
131
 
132
- console.log(result.valid); // Overall validity
133
- console.log(result.format.valid); // true
134
- console.log(result.domain.valid); // true or false
135
- console.log(result.smtp.valid); // 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
136
135
  ```
137
136
 
138
137
  ## API Reference
139
138
 
140
139
  ### Core Functions
141
140
 
142
- #### `verifyEmail(params: IVerifyEmailParams): Promise<DetailedVerificationResult>`
141
+ #### `verifyEmail(params: IVerifyEmailParams): Promise<VerificationResult>`
143
142
 
144
143
  Comprehensive email verification with detailed results and error codes.
145
144
 
@@ -161,33 +160,26 @@ Comprehensive email verification with detailed results and error codes.
161
160
  - `checkDomainAge` (boolean): Check domain age (default: false)
162
161
  - `checkDomainRegistration` (boolean): Check domain registration status (default: false)
163
162
  - `whoisTimeout` (number): WHOIS lookup timeout (default: 5000)
163
+ - `debug` (boolean): Enable debug logging including WHOIS lookups (default: false)
164
164
  - `cache` (ICache): Optional custom cache instance
165
165
 
166
166
  **Returns:**
167
167
  ```typescript
168
168
  {
169
- valid: boolean;
170
169
  email: string;
171
- format: {
172
- valid: boolean;
173
- error?: VerificationErrorCode;
174
- };
175
- domain: {
176
- valid: boolean | null;
177
- mxRecords?: string[];
178
- error?: VerificationErrorCode;
179
- };
180
- smtp: {
181
- valid: boolean | null;
182
- error?: VerificationErrorCode;
183
- };
184
- disposable: boolean;
185
- freeProvider: boolean;
170
+ validFormat: boolean;
171
+ validMx: boolean | null;
172
+ validSmtp: boolean | null;
173
+ isDisposable: boolean;
174
+ isFree: boolean;
186
175
  detectedName?: DetectedName | null;
176
+ domainAge?: DomainAgeInfo | null;
177
+ domainRegistration?: DomainRegistrationInfo | null;
187
178
  domainSuggestion?: DomainSuggestion | null;
188
179
  metadata?: {
189
180
  verificationTime: number;
190
181
  cached: boolean;
182
+ error?: VerificationErrorCode;
191
183
  };
192
184
  }
193
185
  ```
@@ -199,7 +191,6 @@ Verify multiple emails in parallel with concurrency control.
199
191
  **Parameters:**
200
192
  - `emailAddresses` (string[], required): Array of emails to verify
201
193
  - `concurrency` (number): Parallel processing limit (default: 5)
202
- - `detailed` (boolean): Return detailed results (default: false)
203
194
  - `detectName` (boolean): Detect names from email addresses
204
195
  - `suggestDomain` (boolean): Enable domain typo suggestions
205
196
  - Other parameters from `verifyEmail`
@@ -207,7 +198,7 @@ Verify multiple emails in parallel with concurrency control.
207
198
  **Returns:**
208
199
  ```typescript
209
200
  {
210
- results: Map<string, DetailedVerificationResult | IVerifyEmailResult>;
201
+ results: Map<string, VerificationResult>;
211
202
  summary: {
212
203
  total: number;
213
204
  valid: number;
@@ -583,10 +574,9 @@ const result = await verifyEmail({
583
574
  verifySmtp: true,
584
575
  timeout: 3000
585
576
  });
586
- console.log(result.valid); // true
587
- console.log(result.format.valid); // true
588
- console.log(result.domain.valid); // true
589
- console.log(result.smtp.valid); // true
577
+ console.log(result.validFormat); // true
578
+ console.log(result.validMx); // true
579
+ console.log(result.validSmtp); // true
590
580
  ```
591
581
 
592
582
  ### Detailed Verification (NEW)
@@ -600,10 +590,11 @@ const result = await verifyEmail({
600
590
  checkDisposable: true,
601
591
  checkFree: true
602
592
  });
603
- // result.valid: true
604
- // result.disposable: false
605
- // result.freeProvider: false
606
- // 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
607
598
  // result.metadata.verificationTime: 125
608
599
  ```
609
600
 
@@ -617,7 +608,8 @@ const result = await verifyEmailBatch({
617
608
  emailAddresses: emails,
618
609
  concurrency: 5,
619
610
  verifyMx: true,
620
- detailed: true
611
+ checkDisposable: true,
612
+ checkFree: true
621
613
  });
622
614
  // result.summary.valid: 2
623
615
  // result.summary.invalid: 1
@@ -697,16 +689,15 @@ const result = await verifyEmail({
697
689
  verifyMx: true,
698
690
  verifySmtp: true
699
691
  });
700
- // result.valid: false (domain or SMTP failed)
701
- // result.format.valid: true
702
- // result.domain.valid: false
703
- // result.smtp.valid: 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)
704
695
  ```
705
696
 
706
697
  ### Using Detailed Verification for Better Insights
707
698
 
708
699
  ```typescript
709
- const detailed = await verifyEmail({
700
+ const result = await verifyEmail({
710
701
  emailAddress: 'user@suspicious-domain.com',
711
702
  verifyMx: true,
712
703
  verifySmtp: true,
@@ -714,8 +705,14 @@ const detailed = await verifyEmail({
714
705
  checkFree: true
715
706
  });
716
707
 
717
- if (!detailed.valid) {
718
- 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) {
719
716
  case VerificationErrorCode.DISPOSABLE_EMAIL:
720
717
  console.log('Rejected: Disposable email');
721
718
  break;
@@ -755,7 +752,7 @@ console.log(`Time: ${batch.summary.processingTime}ms`);
755
752
  // Filter out invalid emails
756
753
  const validEmails = [];
757
754
  for (const [email, result] of batch.results) {
758
- if (result.valid) {
755
+ if (result.validFormat) {
759
756
  validEmails.push(email);
760
757
  }
761
758
  }
@@ -1046,7 +1043,7 @@ process.on('SIGTERM', async () => {
1046
1043
  });
1047
1044
  ```
1048
1045
 
1049
- **Note:** Yahoo, Hotmail, and some providers always return `result.smtp.valid: 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.
1050
1047
 
1051
1048
  ## 🌐 Serverless Deployment
1052
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 } 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';
@@ -13,4 +13,4 @@ export declare const domainPorts: Record<string, number>;
13
13
  /**
14
14
  * Verify email address
15
15
  */
16
- export declare function verifyEmail(params: IVerifyEmailParams): Promise<DetailedVerificationResult>;
16
+ export declare function verifyEmail(params: IVerifyEmailParams): Promise<VerificationResult>;
package/dist/index.esm.js CHANGED
@@ -1732,37 +1732,50 @@ const WHOIS_SERVERS = {
1732
1732
  ar: "whois.nic.ar",
1733
1733
  cl: "whois.nic.cl"
1734
1734
  };
1735
- function queryWhoisServer(domain, server, timeout = 5e3) {
1735
+ function queryWhoisServer(domain, server, timeout = 5e3, debug = false) {
1736
+ const log = debug ? console.debug : (..._args) => {
1737
+ };
1736
1738
  return new Promise((resolve, reject) => {
1737
1739
  const client = new net.Socket();
1738
1740
  let data = "";
1741
+ log(`[whois] querying ${server} for domain ${domain}`);
1739
1742
  const timer = setTimeout(() => {
1743
+ log(`[whois] timeout after ${timeout}ms for ${domain} at ${server}`);
1740
1744
  client.destroy();
1741
1745
  reject(new Error("WHOIS query timeout"));
1742
1746
  }, timeout);
1743
1747
  client.connect(43, server, () => {
1748
+ log(`[whois] connected to ${server}, sending query for ${domain}`);
1744
1749
  client.write(`${domain}\r
1745
1750
  `);
1746
1751
  });
1747
1752
  client.on("data", (chunk) => {
1748
- data += chunk.toString();
1753
+ const chunkStr = chunk.toString();
1754
+ data += chunkStr;
1755
+ log(`[whois] received ${chunkStr.length} bytes from ${server}`);
1749
1756
  });
1750
1757
  client.on("close", () => {
1751
1758
  clearTimeout(timer);
1759
+ log(`[whois] connection closed, received total ${data.length} bytes from ${server}`);
1752
1760
  resolve(data);
1753
1761
  });
1754
1762
  client.on("error", (err) => {
1755
1763
  clearTimeout(timer);
1764
+ log(`[whois] error querying ${server}: ${err.message}`);
1756
1765
  reject(err);
1757
1766
  });
1758
1767
  });
1759
1768
  }
1760
- async function getWhoisData(domain, timeout = 5e3) {
1769
+ async function getWhoisData(domain, timeout = 5e3, debug = false) {
1761
1770
  var _a;
1771
+ const log = debug ? console.debug : (..._args) => {
1772
+ };
1762
1773
  const cacheKey = `whois:${domain}`;
1763
1774
  const cache = whoisCacheStore();
1775
+ log(`[whois] getting WHOIS data for ${domain}`);
1764
1776
  const cached = await cache.get(cacheKey);
1765
1777
  if (cached !== null && cached !== void 0) {
1778
+ log(`[whois] using cached data for ${domain}`);
1766
1779
  return cached;
1767
1780
  }
1768
1781
  try {
@@ -1770,41 +1783,55 @@ async function getWhoisData(domain, timeout = 5e3) {
1770
1783
  if (!tld) {
1771
1784
  throw new Error("Invalid domain");
1772
1785
  }
1786
+ log(`[whois] extracted TLD: ${tld} for domain: ${domain}`);
1773
1787
  const whoisServer = WHOIS_SERVERS[tld];
1774
1788
  if (!whoisServer) {
1789
+ log(`[whois] no specific server for TLD ${tld}, trying IANA`);
1775
1790
  const defaultServer = "whois.iana.org";
1776
- const ianaResponse = await queryWhoisServer(domain, defaultServer, timeout);
1791
+ const ianaResponse = await queryWhoisServer(domain, defaultServer, timeout, debug);
1777
1792
  const referMatch = ianaResponse.match(/refer:\s+(\S+)/i);
1778
1793
  if (referMatch === null || referMatch === void 0 ? void 0 : referMatch[1]) {
1779
1794
  const referredServer = referMatch[1];
1780
- const whoisResponse2 = await queryWhoisServer(domain, referredServer, timeout);
1795
+ log(`[whois] IANA referred to ${referredServer} for ${domain}`);
1796
+ const whoisResponse2 = await queryWhoisServer(domain, referredServer, timeout, debug);
1781
1797
  const whoisData3 = parseWhoisData({ rawData: whoisResponse2, domain });
1782
1798
  await cache.set(cacheKey, whoisData3);
1799
+ log(`[whois] successfully retrieved and cached WHOIS data from referred server for ${domain}`);
1783
1800
  return whoisData3;
1784
1801
  }
1785
1802
  const whoisData2 = parseWhoisData({ rawData: ianaResponse, domain });
1786
1803
  await cache.set(cacheKey, whoisData2);
1804
+ log(`[whois] successfully retrieved and cached WHOIS data from IANA for ${domain}`);
1787
1805
  return whoisData2;
1788
1806
  }
1789
- const whoisResponse = await queryWhoisServer(domain, whoisServer, timeout);
1807
+ log(`[whois] using WHOIS server ${whoisServer} for TLD ${tld}`);
1808
+ const whoisResponse = await queryWhoisServer(domain, whoisServer, timeout, debug);
1790
1809
  const whoisData = parseWhoisData({ rawData: whoisResponse, domain });
1791
1810
  await cache.set(cacheKey, whoisData);
1811
+ log(`[whois] successfully retrieved and cached WHOIS data for ${domain}`);
1792
1812
  return whoisData;
1793
1813
  } catch (_error) {
1814
+ log(`[whois] failed to get WHOIS data for ${domain}: ${_error instanceof Error ? _error.message : "Unknown error"}`);
1794
1815
  return null;
1795
1816
  }
1796
1817
  }
1797
- async function getDomainAge(domain, timeout = 5e3) {
1818
+ async function getDomainAge(domain, timeout = 5e3, debug = false) {
1819
+ const log = debug ? console.debug : (..._args) => {
1820
+ };
1798
1821
  try {
1799
1822
  const cleanDomain = domain.replace(/^https?:\/\//, "").split("/")[0].split("@").pop();
1800
1823
  if (!cleanDomain) {
1824
+ log(`[whois] invalid domain format: ${domain}`);
1801
1825
  return null;
1802
1826
  }
1827
+ log(`[whois] checking domain age for ${cleanDomain}`);
1803
1828
  if (!isValid(cleanDomain)) {
1829
+ log(`[whois] domain validation failed: ${cleanDomain}`);
1804
1830
  return null;
1805
1831
  }
1806
- const whoisData = await getWhoisData(cleanDomain, timeout);
1832
+ const whoisData = await getWhoisData(cleanDomain, timeout, debug);
1807
1833
  if (!whoisData || !whoisData.creationDate) {
1834
+ log(`[whois] no creation date found for ${cleanDomain}`);
1808
1835
  return null;
1809
1836
  }
1810
1837
  const now = /* @__PURE__ */ new Date();
@@ -1812,6 +1839,7 @@ async function getDomainAge(domain, timeout = 5e3) {
1812
1839
  const ageInMilliseconds = now.getTime() - creationDate.getTime();
1813
1840
  const ageInDays = Math.floor(ageInMilliseconds / (1e3 * 60 * 60 * 24));
1814
1841
  const ageInYears = ageInDays / 365.25;
1842
+ log(`[whois] calculated age for ${cleanDomain}: ${ageInDays} days (${ageInYears.toFixed(2)} years)`);
1815
1843
  return {
1816
1844
  domain: cleanDomain,
1817
1845
  creationDate,
@@ -1821,20 +1849,27 @@ async function getDomainAge(domain, timeout = 5e3) {
1821
1849
  updatedDate: whoisData.updatedDate ? new Date(whoisData.updatedDate) : null
1822
1850
  };
1823
1851
  } catch (_error) {
1852
+ log(`[whois] error getting domain age for ${domain}: ${_error instanceof Error ? _error.message : "Unknown error"}`);
1824
1853
  return null;
1825
1854
  }
1826
1855
  }
1827
- async function getDomainRegistrationStatus(domain, timeout = 5e3) {
1856
+ async function getDomainRegistrationStatus(domain, timeout = 5e3, debug = false) {
1857
+ const log = debug ? console.debug : (..._args) => {
1858
+ };
1828
1859
  try {
1829
1860
  const cleanDomain = domain.replace(/^https?:\/\//, "").split("/")[0].split("@").pop();
1830
1861
  if (!cleanDomain) {
1862
+ log(`[whois] invalid domain format: ${domain}`);
1831
1863
  return null;
1832
1864
  }
1865
+ log(`[whois] checking domain registration status for ${cleanDomain}`);
1833
1866
  if (!isValid(cleanDomain)) {
1867
+ log(`[whois] domain validation failed: ${cleanDomain}`);
1834
1868
  return null;
1835
1869
  }
1836
- const whoisData = await getWhoisData(cleanDomain, timeout);
1870
+ const whoisData = await getWhoisData(cleanDomain, timeout, debug);
1837
1871
  if (!whoisData || whoisData.isAvailable) {
1872
+ log(`[whois] domain ${cleanDomain} is available or not registered`);
1838
1873
  return {
1839
1874
  domain: cleanDomain,
1840
1875
  isRegistered: false,
@@ -1862,6 +1897,7 @@ async function getDomainRegistrationStatus(domain, timeout = 5e3) {
1862
1897
  if (!isExpired) {
1863
1898
  daysUntilExpiration = Math.floor((expirationTime - currentTime) / (1e3 * 60 * 60 * 24));
1864
1899
  }
1900
+ log(`[whois] domain ${cleanDomain} expires in ${daysUntilExpiration} days`);
1865
1901
  }
1866
1902
  const statusList = whoisData.status || [];
1867
1903
  const formattedStatusList = statusList.map((s) => {
@@ -1870,6 +1906,7 @@ async function getDomainRegistrationStatus(domain, timeout = 5e3) {
1870
1906
  });
1871
1907
  const isPendingDelete = formattedStatusList.some((s) => s.toLowerCase().includes("pendingdelete") || s.toLowerCase().includes("redemption"));
1872
1908
  const isLocked = formattedStatusList.some((s) => s.toLowerCase().includes("clienttransferprohibited") || s.toLowerCase().includes("servertransferprohibited"));
1909
+ log(`[whois] domain ${cleanDomain} - registered: ${isRegistered}, expired: ${isExpired}, locked: ${isLocked}, pending delete: ${isPendingDelete}`);
1873
1910
  return {
1874
1911
  domain: cleanDomain,
1875
1912
  isRegistered,
@@ -1884,6 +1921,7 @@ async function getDomainRegistrationStatus(domain, timeout = 5e3) {
1884
1921
  isLocked
1885
1922
  };
1886
1923
  } catch (_error) {
1924
+ log(`[whois] error getting domain registration status for ${domain}: ${_error instanceof Error ? _error.message : "Unknown error"}`);
1887
1925
  return null;
1888
1926
  }
1889
1927
  }
@@ -1916,7 +1954,7 @@ async function verifyEmailBatch(params) {
1916
1954
  commonDomains,
1917
1955
  cache
1918
1956
  });
1919
- if (result.valid) {
1957
+ if (result.validFormat) {
1920
1958
  totalValid++;
1921
1959
  } else {
1922
1960
  totalInvalid++;
@@ -1926,7 +1964,7 @@ async function verifyEmailBatch(params) {
1926
1964
  totalErrors++;
1927
1965
  return {
1928
1966
  email,
1929
- result: createErrorDetailedResult(email)
1967
+ result: createErrorResult(email)
1930
1968
  };
1931
1969
  }
1932
1970
  });
@@ -1946,18 +1984,18 @@ async function verifyEmailBatch(params) {
1946
1984
  }
1947
1985
  };
1948
1986
  }
1949
- function createErrorDetailedResult(email, _error) {
1987
+ function createErrorResult(email, _error) {
1950
1988
  return {
1951
- valid: false,
1952
1989
  email,
1953
- format: { valid: false },
1954
- domain: { valid: null },
1955
- smtp: { valid: null },
1956
- disposable: false,
1957
- freeProvider: false,
1990
+ validFormat: false,
1991
+ validMx: null,
1992
+ validSmtp: null,
1993
+ isDisposable: false,
1994
+ isFree: false,
1958
1995
  metadata: {
1959
1996
  verificationTime: 0,
1960
- cached: false
1997
+ cached: false,
1998
+ error: VerificationErrorCode.SMTP_CONNECTION_FAILED
1961
1999
  }
1962
2000
  };
1963
2001
  }
@@ -2027,26 +2065,25 @@ async function verifyEmail(params) {
2027
2065
  const log = debug ? console.debug : (..._args) => {
2028
2066
  };
2029
2067
  const result = {
2030
- valid: false,
2031
2068
  email: emailAddress,
2032
- format: { valid: false },
2033
- domain: { valid: null },
2034
- smtp: { valid: null },
2035
- disposable: false,
2036
- freeProvider: false,
2069
+ validFormat: false,
2070
+ validMx: null,
2071
+ validSmtp: null,
2072
+ isDisposable: false,
2073
+ isFree: false,
2037
2074
  metadata: {
2038
2075
  verificationTime: 0,
2039
2076
  cached: false
2040
2077
  }
2041
2078
  };
2042
2079
  if (!isValidEmail(emailAddress)) {
2043
- result.format.error = VerificationErrorCode.INVALID_FORMAT;
2044
2080
  if (result.metadata) {
2045
2081
  result.metadata.verificationTime = Date.now() - startTime;
2082
+ result.metadata.error = VerificationErrorCode.INVALID_FORMAT;
2046
2083
  }
2047
2084
  return result;
2048
2085
  }
2049
- result.format.valid = true;
2086
+ result.validFormat = true;
2050
2087
  if (detectName2) {
2051
2088
  result.detectedName = detectNameFromEmail({
2052
2089
  email: emailAddress,
@@ -2056,64 +2093,67 @@ async function verifyEmail(params) {
2056
2093
  if (suggestDomain2) {
2057
2094
  const [, emailDomain] = emailAddress.split("@");
2058
2095
  if (emailDomain) {
2059
- result.domainSuggestion = domainSuggestionMethod ? domainSuggestionMethod(emailDomain) : await suggestEmailDomain(emailAddress, commonDomains);
2096
+ const suggestion = domainSuggestionMethod ? domainSuggestionMethod(emailDomain) : await suggestEmailDomain(emailAddress, commonDomains);
2097
+ if (suggestion) {
2098
+ result.domainSuggestion = suggestion;
2099
+ } else {
2100
+ result.domainSuggestion = null;
2101
+ }
2060
2102
  }
2061
2103
  }
2062
2104
  const [local, domain] = emailAddress.split("@");
2063
2105
  if (!domain || !local) {
2064
- result.format.error = VerificationErrorCode.INVALID_FORMAT;
2065
2106
  if (result.metadata) {
2066
2107
  result.metadata.verificationTime = Date.now() - startTime;
2108
+ result.metadata.error = VerificationErrorCode.INVALID_FORMAT;
2067
2109
  }
2068
2110
  return result;
2069
2111
  }
2070
2112
  if (!await isValidEmailDomain(domain, params.cache)) {
2071
- result.domain.error = VerificationErrorCode.INVALID_DOMAIN;
2072
2113
  if (result.metadata) {
2073
2114
  result.metadata.verificationTime = Date.now() - startTime;
2115
+ result.metadata.error = VerificationErrorCode.INVALID_DOMAIN;
2074
2116
  }
2075
2117
  return result;
2076
2118
  }
2077
2119
  if (checkDisposable) {
2078
- result.disposable = await isDisposableEmail(emailAddress, params.cache);
2079
- if (result.disposable) {
2080
- result.valid = false;
2081
- result.domain.error = VerificationErrorCode.DISPOSABLE_EMAIL;
2120
+ result.isDisposable = await isDisposableEmail(emailAddress, params.cache);
2121
+ if (result.isDisposable && result.metadata) {
2122
+ result.metadata.error = VerificationErrorCode.DISPOSABLE_EMAIL;
2082
2123
  }
2083
2124
  }
2084
2125
  if (checkFree) {
2085
- result.freeProvider = await isFreeEmail(emailAddress, params.cache);
2126
+ result.isFree = await isFreeEmail(emailAddress, params.cache);
2086
2127
  }
2087
2128
  if (checkDomainAge) {
2088
2129
  try {
2089
- result.domainAge = await getDomainAge(domain, whoisTimeout);
2130
+ result.domainAge = await getDomainAge(domain, whoisTimeout, debug);
2090
2131
  } catch (err) {
2091
- log("[verifyEmailDetailed] Failed to get domain age", err);
2132
+ log("[verifyEmail] Failed to get domain age", err);
2092
2133
  result.domainAge = null;
2093
2134
  }
2094
2135
  }
2095
2136
  if (checkDomainRegistration) {
2096
2137
  try {
2097
- result.domainRegistration = await getDomainRegistrationStatus(domain, whoisTimeout);
2138
+ result.domainRegistration = await getDomainRegistrationStatus(domain, whoisTimeout, debug);
2098
2139
  } catch (err) {
2099
- log("[verifyEmailDetailed] Failed to get domain registration status", err);
2140
+ log("[verifyEmail] Failed to get domain registration status", err);
2100
2141
  result.domainRegistration = null;
2101
2142
  }
2102
2143
  }
2103
2144
  if (verifyMx || verifySmtp) {
2104
2145
  try {
2105
2146
  const mxRecords = await resolveMxRecords(domain, params.cache);
2106
- result.domain.mxRecords = mxRecords;
2107
- result.domain.valid = mxRecords.length > 0;
2108
- if (!result.domain.valid) {
2109
- result.domain.error = VerificationErrorCode.NO_MX_RECORDS;
2147
+ result.validMx = mxRecords.length > 0;
2148
+ if (!result.validMx && result.metadata) {
2149
+ result.metadata.error = VerificationErrorCode.NO_MX_RECORDS;
2110
2150
  }
2111
2151
  if (verifySmtp && mxRecords.length > 0) {
2112
2152
  const cacheKey = `${emailAddress}:smtp`;
2113
2153
  const smtpCacheInstance = smtpCacheStore(params.cache);
2114
2154
  const cachedSmtp = await smtpCacheInstance.get(cacheKey);
2115
2155
  if (cachedSmtp !== null && cachedSmtp !== void 0) {
2116
- result.smtp.valid = cachedSmtp;
2156
+ result.validSmtp = cachedSmtp;
2117
2157
  if (result.metadata) {
2118
2158
  result.metadata.cached = true;
2119
2159
  }
@@ -2141,21 +2181,22 @@ async function verifyEmail(params) {
2141
2181
  retryAttempts: params.retryAttempts
2142
2182
  });
2143
2183
  await smtpCacheInstance.set(cacheKey, smtpResult);
2144
- result.smtp.valid = smtpResult;
2184
+ result.validSmtp = smtpResult;
2145
2185
  }
2146
- if (result.smtp.valid === false) {
2147
- result.smtp.error = VerificationErrorCode.MAILBOX_NOT_FOUND;
2148
- } else if (result.smtp.valid === null) {
2149
- result.smtp.error = VerificationErrorCode.SMTP_CONNECTION_FAILED;
2186
+ if (result.validSmtp === false && result.metadata) {
2187
+ result.metadata.error = VerificationErrorCode.MAILBOX_NOT_FOUND;
2188
+ } else if (result.validSmtp === null && result.metadata) {
2189
+ result.metadata.error = VerificationErrorCode.SMTP_CONNECTION_FAILED;
2150
2190
  }
2151
2191
  }
2152
2192
  } catch (err) {
2153
- log("[verifyEmailDetailed] Failed to resolve MX records", err);
2154
- result.domain.valid = false;
2155
- result.domain.error = VerificationErrorCode.NO_MX_RECORDS;
2193
+ log("[verifyEmail] Failed to resolve MX records", err);
2194
+ result.validMx = false;
2195
+ if (result.metadata) {
2196
+ result.metadata.error = VerificationErrorCode.NO_MX_RECORDS;
2197
+ }
2156
2198
  }
2157
2199
  }
2158
- result.valid = result.format.valid && result.domain.valid !== false && result.smtp.valid !== false && !result.disposable;
2159
2200
  if (result.metadata) {
2160
2201
  result.metadata.verificationTime = Date.now() - startTime;
2161
2202
  }