@visulima/email-verifier 1.0.1 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## @visulima/email-verifier [1.0.2](https://github.com/visulima/visulima/compare/%40visulima%2Femail-verifier%401.0.1...%40visulima%2Femail-verifier%401.0.2) (2026-08-02)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/disposable-email-domains:** upgraded to 1.1.0
7
+ * **@visulima/email-provider-mx:** upgraded to 1.0.1
8
+ * **@visulima/free-email-domains:** upgraded to 1.0.1
9
+
1
10
  ## @visulima/email-verifier [1.0.1](https://github.com/visulima/visulima/compare/%40visulima%2Femail-verifier%401.0.0...%40visulima%2Femail-verifier%401.0.1) (2026-07-15)
2
11
 
3
12
 
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The result of local-part character analysis.
3
- */
2
+ * The result of local-part character analysis.
3
+ */
4
4
  interface CharacterResult {
5
5
  /** Ratio of digits to total characters in the local part (0–1). */
6
6
  digitRatio: number;
@@ -12,20 +12,20 @@ interface CharacterResult {
12
12
  reasons: string[];
13
13
  }
14
14
  /**
15
- * Analyzes the local part of an email for irregular characteristics that
16
- * correlate with low-quality, spam-trap, or machine-generated addresses.
17
- *
18
- * Heuristic and intentionally conservative — it flags *patterns* (excessive
19
- * length, digit-heavy locals, long unpronounceable consonant runs, long repeats)
20
- * rather than asserting invalidity.
21
- * @param email The email address to analyze.
22
- * @returns The character analysis result.
23
- * @example
24
- * ```ts
25
- * import { analyzeCharacters } from "@visulima/email-verifier/checks/character";
26
- *
27
- * analyzeCharacters("aaaaaaa@example.com").irregular; // long repeat ⇒ true
28
- * ```
29
- */
15
+ * Analyzes the local part of an email for irregular characteristics that
16
+ * correlate with low-quality, spam-trap, or machine-generated addresses.
17
+ *
18
+ * Heuristic and intentionally conservative — it flags *patterns* (excessive
19
+ * length, digit-heavy locals, long unpronounceable consonant runs, long repeats)
20
+ * rather than asserting invalidity.
21
+ * @param email The email address to analyze.
22
+ * @returns The character analysis result.
23
+ * @example
24
+ * ```ts
25
+ * import { analyzeCharacters } from "@visulima/email-verifier/checks/character";
26
+ *
27
+ * analyzeCharacters("aaaaaaa@example.com").irregular; // long repeat ⇒ true
28
+ * ```
29
+ */
30
30
  declare const analyzeCharacters: (email: string) => CharacterResult;
31
31
  export { type CharacterResult, analyzeCharacters, analyzeCharacters as default };
@@ -1 +1 @@
1
- export { type C as Cache, type I as InMemoryCache, type M as MxCheckOptions, type b as MxCheckResult, type c as MxRecord, type d as MxResolution, e as checkMxRecords, e as default } from "../packem_shared/mx.d-NAesS5sg.js";
1
+ export { type C as Cache, type I as InMemoryCache, type M as MxCheckOptions, type b as MxCheckResult, type c as MxRecord, type d as MxResolution, e as checkMxRecords, e as default } from "../packem_shared/mx.d-HxIDdxvR.js";
package/dist/checks/mx.js CHANGED
@@ -1 +1 @@
1
- import{createRequire as d}from"node:module";const u=d(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[r,s]=o.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return o.getBuiltinModule(e)}return u(e)},{resolveMx:v,resolve4:p,resolve6:h}=f("node:dns/promises"),c=async e=>{try{if((await p(e)).length>0)return!0}catch{}try{return(await h(e)).length>0}catch{return!1}},l=e=>({domainResolves:!0,records:[{exchange:e,priority:0}],resolvedVia:"address",valid:!0}),g=async(e,r)=>{try{const s=(await v(e)).map(t=>({exchange:t.exchange,priority:t.priority}));return s.length>0?{domainResolves:!0,records:s.toSorted((t,a)=>t.priority-a.priority),resolvedVia:"mx",valid:!0}:r&&await c(e)?l(e):{domainResolves:!1,records:[],resolvedVia:"none",valid:!1}}catch(s){return r&&await c(e)?l(e):{domainResolves:!1,error:s instanceof Error?s.message:String(s),resolvedVia:"none",valid:!1}}},y=async(e,r={})=>{const{fallbackToAddress:s=!0}=r,t=r.ttl??36e5,a=`${e}:${String(s)}`;if(r.cache){const n=await r.cache.get(a);if(n!==void 0)return n}const i=await g(e,s);return r.cache&&await r.cache.set(a,i,t),i};export{y as checkMxRecords,y as default};
1
+ import{createRequire as f}from"node:module";let h;const v=e=>(h??=f(import.meta.url))(e),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[r,t]=n.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return n.getBuiltinModule(e)}return v(e)},{resolveMx:g,resolve4:y,resolve6:_}=p("node:dns/promises"),m=new Set(["EAI_AGAIN","ECONNREFUSED","EREFUSED","ESERVFAIL","ETIMEDOUT","ETIMEOUT"]),E=e=>{const{code:r}=e??{};return r!==void 0&&m.has(r)},l=async e=>{try{if((await y(e)).length>0)return!0}catch{}try{return(await _(e)).length>0}catch{return!1}},u=e=>({domainResolves:!0,records:[{exchange:e,priority:0}],resolvedVia:"address",valid:!0}),w=async(e,r)=>{try{const t=(await g(e)).map(o=>({exchange:o.exchange,priority:o.priority}));return t.length>0?{domainResolves:!0,records:t.toSorted((o,s)=>o.priority-s.priority),resolvedVia:"mx",valid:!0}:r&&await l(e)?u(e):{domainResolves:!1,records:[],resolvedVia:"none",valid:!1}}catch(t){return r&&await l(e)?u(e):{deferred:E(t),domainResolves:!1,error:t instanceof Error?t.message:String(t),resolvedVia:"none",valid:!1}}},i=new Map,M=async(e,r={})=>{const{fallbackToAddress:t=!0}=r,o=r.ttl??36e5,s=`${e}:${String(t)}`;if(r.cache){const a=await r.cache.get(s);if(a!==void 0)return a}const c=i.get(s);if(c)return c;const d=(async()=>{const a=await w(e,t);return r.cache&&!a.deferred&&await r.cache.set(s,a,o),a})();i.set(s,d);try{return await d}finally{i.delete(s)}};export{M as checkMxRecords,M as default};
@@ -1,41 +1,41 @@
1
1
  /**
2
- * Local-part prefixes that indicate a no-reply / do-not-reply mailbox.
3
- * These are a strict subset of {@link ROLE_ACCOUNT_PREFIXES}.
4
- */
2
+ * Local-part prefixes that indicate a no-reply / do-not-reply mailbox.
3
+ * These are a strict subset of {@link ROLE_ACCOUNT_PREFIXES}.
4
+ */
5
5
  declare const NO_REPLY_PREFIXES: ReadonlySet<string>;
6
6
  /**
7
- * Local-part prefixes that identify a role-based (shared, function) mailbox
8
- * rather than a personal one. Superset of RFC 2142 plus common real-world roles.
9
- */
7
+ * Local-part prefixes that identify a role-based (shared, function) mailbox
8
+ * rather than a personal one. Superset of RFC 2142 plus common real-world roles.
9
+ */
10
10
  declare const ROLE_ACCOUNT_PREFIXES: ReadonlySet<string>;
11
11
  /**
12
- * Determines whether an email address is a role-based account.
13
- *
14
- * Matches the whole local part, the part before any `+tag`, and each
15
- * dot/dash/underscore-separated token (so `sales.john`, `info+news`, and
16
- * `no-reply` are all caught).
17
- * @param email The email address to check.
18
- * @param customPrefixes Optional additional role prefixes to recognize.
19
- * @returns True when the address is a role account.
20
- * @example
21
- * ```ts
22
- * import { isRoleAccount } from "@visulima/email-verifier/checks/role";
23
- *
24
- * isRoleAccount("info@example.com"); // true
25
- * isRoleAccount("john.doe@example.com"); // false
26
- * ```
27
- */
12
+ * Determines whether an email address is a role-based account.
13
+ *
14
+ * Matches the whole local part, the part before any `+tag`, and each
15
+ * dot/dash/underscore-separated token (so `sales.john`, `info+news`, and
16
+ * `no-reply` are all caught).
17
+ * @param email The email address to check.
18
+ * @param customPrefixes Optional additional role prefixes to recognize.
19
+ * @returns True when the address is a role account.
20
+ * @example
21
+ * ```ts
22
+ * import { isRoleAccount } from "@visulima/email-verifier/checks/role";
23
+ *
24
+ * isRoleAccount("info@example.com"); // true
25
+ * isRoleAccount("john.doe@example.com"); // false
26
+ * ```
27
+ */
28
28
  declare const isRoleAccount: (email: string, customPrefixes?: Iterable<string>) => boolean;
29
29
  /**
30
- * Determines whether an email address is a no-reply / do-not-reply mailbox.
31
- * @param email The email address to check.
32
- * @returns True when the address is a no-reply mailbox.
33
- * @example
34
- * ```ts
35
- * import { isNoReply } from "@visulima/email-verifier/checks/role";
36
- *
37
- * isNoReply("no-reply@example.com"); // true
38
- * ```
39
- */
30
+ * Determines whether an email address is a no-reply / do-not-reply mailbox.
31
+ * @param email The email address to check.
32
+ * @returns True when the address is a no-reply mailbox.
33
+ * @example
34
+ * ```ts
35
+ * import { isNoReply } from "@visulima/email-verifier/checks/role";
36
+ *
37
+ * isNoReply("no-reply@example.com"); // true
38
+ * ```
39
+ */
40
40
  declare const isNoReply: (email: string) => boolean;
41
41
  export { NO_REPLY_PREFIXES, ROLE_ACCOUNT_PREFIXES, isRoleAccount as default, isNoReply, isRoleAccount };
@@ -1 +1 @@
1
- import{splitAddress as c}from"../packem_shared/extractDomain-CYJf1_0N.js";const l=new Set(["do-not-reply","do_not_reply","donotreply","no-reply","no_reply","noreply","notification","notifications","notify"]),n=new Set(["abuse","accounting","accounts","admin","administrator","all","billing","board","career","careers","ceo","cfo","compliance","contact","contacts","cto","customercare","customerservice","dev","developer","devnull","do-not-reply","do_not_reply","donotreply","enquiries","enquiry","everyone","feedback","finance","ftp","hello","help","helpdesk","hi","hostmaster","hr","info","information","inquiries","inquiry","investor","investors","it","jobs","legal","list","list-request","mail","mailer-daemon","mailerdaemon","majordomo","marketing","media","members","newsletter","no-reply","no_reply","noc","noreply","notification","notifications","notify","office","operations","order","orders","postmaster","press","privacy","purchasing","recruitment","register","registration","root","sales","secretary","security","service","services","shop","spam","staff","subscribe","support","sysadmin","team","tech","test","unsubscribe","usenet","uucp","webmaster","welcome","www"]),u=/[.\-_+]/,o=(t,e,r)=>{if(e.has(t))return!0;if(r){for(const s of r)if(s.toLowerCase()===t)return!0}return!1},m=(t,e)=>{const r=c(t);if(!r)return!1;const{localPart:s}=r,i=s.split("+")[0];if(o(s,n,e)||o(i,n,e))return!0;const a=i.split(u).filter(Boolean);return a.length>1&&a.some(p=>o(p,n,e))},d=t=>{const e=c(t);if(!e)return!1;const r=e.localPart.split("+")[0];return o(e.localPart,l)||o(r,l)};export{l as NO_REPLY_PREFIXES,n as ROLE_ACCOUNT_PREFIXES,m as default,d as isNoReply,m as isRoleAccount};
1
+ import{splitAddress as m}from"../packem_shared/extractDomain-CYJf1_0N.js";const p=new Set(["do-not-reply","do_not_reply","donotreply","no-reply","no_reply","noreply","notification","notifications","notify"]),i=new Set(["abuse","accounting","accounts","admin","administrator","all","billing","board","career","careers","ceo","cfo","compliance","contact","contacts","cto","customercare","customerservice","dev","developer","devnull","do-not-reply","do_not_reply","donotreply","enquiries","enquiry","everyone","feedback","finance","ftp","hello","help","helpdesk","hi","hostmaster","hr","info","information","inquiries","inquiry","investor","investors","it","jobs","legal","list","list-request","mail","mailer-daemon","mailerdaemon","majordomo","marketing","media","members","newsletter","no-reply","no_reply","noc","noreply","notification","notifications","notify","office","operations","order","orders","postmaster","press","privacy","purchasing","recruitment","register","registration","root","sales","secretary","security","service","services","shop","spam","staff","subscribe","support","sysadmin","team","tech","test","unsubscribe","usenet","uucp","webmaster","welcome","www"]),u=/[.\-_+]/,t=(o,e,r)=>e.has(o)||(r?.has(o)??!1),f=(o,e)=>{const r=m(o);if(!r)return!1;const{localPart:a}=r,l=a.split("+")[0],s=e?new Set([...e].map(n=>n.toLowerCase())):void 0;if(t(a,i,s)||t(l,i,s))return!0;const c=l.split(u).filter(Boolean);return c.length>1&&c.some(n=>t(n,i,s))},y=o=>{const e=m(o);if(!e)return!1;const r=e.localPart.split("+")[0];return t(e.localPart,p)||t(r,p)};export{p as NO_REPLY_PREFIXES,i as ROLE_ACCOUNT_PREFIXES,f as default,y as isNoReply,f as isRoleAccount};
@@ -1,43 +1,43 @@
1
- import { b as MxCheckResult, C as Cache, c as MxRecord } from "../packem_shared/mx.d-NAesS5sg.js";
1
+ import { b as MxCheckResult, C as Cache, c as MxRecord } from "../packem_shared/mx.d-HxIDdxvR.js";
2
2
  /**
3
- * Options for SMTP verification.
4
- */
3
+ * Options for SMTP verification.
4
+ */
5
5
  interface SmtpVerificationOptions {
6
6
  /** Cache for the underlying MX lookup. */
7
7
  cache?: Cache<MxCheckResult>;
8
8
  /**
9
- * Number of random, almost-certainly-nonexistent addresses to probe for
10
- * catch-all detection. More probes reduce false positives from
11
- * deferred-rejection servers. Set to 0 to disable.
12
- * @default 1
13
- */
9
+ * Number of random, almost-certainly-nonexistent addresses to probe for
10
+ * catch-all detection. More probes reduce false positives from
11
+ * deferred-rejection servers. Set to 0 to disable.
12
+ * @default 1
13
+ */
14
14
  catchAllProbes?: number;
15
15
  /**
16
- * MAIL FROM address used during the probe; defaults to `verify@` followed by
17
- * the HELO host.
18
- */
16
+ * MAIL FROM address used during the probe; defaults to `verify@` followed by
17
+ * the HELO host.
18
+ */
19
19
  fromEmail?: string;
20
20
  /**
21
- * HELO/EHLO hostname presented to the remote server.
22
- * @default the address domain
23
- */
21
+ * HELO/EHLO hostname presented to the remote server.
22
+ * @default the address domain
23
+ */
24
24
  heloHost?: string;
25
25
  /**
26
- * Pre-resolved MX records to probe, in priority order. When provided, the
27
- * probe skips its own DNS lookup — the orchestrator passes the records it
28
- * already resolved so the domain is not queried twice.
29
- */
26
+ * Pre-resolved MX records to probe, in priority order. When provided, the
27
+ * probe skips its own DNS lookup — the orchestrator passes the records it
28
+ * already resolved so the domain is not queried twice.
29
+ */
30
30
  mxRecords?: MxRecord[];
31
31
  port?: number;
32
32
  /**
33
- * Number of times to retry the whole probe on a temporary (greylist) failure.
34
- * @default 1
35
- */
33
+ * Number of times to retry the whole probe on a temporary (greylist) failure.
34
+ * @default 1
35
+ */
36
36
  retries?: number;
37
37
  /**
38
- * Delay in milliseconds between greylist retries.
39
- * @default 5000
40
- */
38
+ * Delay in milliseconds between greylist retries.
39
+ * @default 5000
40
+ */
41
41
  retryDelay?: number;
42
42
  /** Cache for SMTP results. */
43
43
  smtpCache?: Cache<SmtpVerificationResult>;
@@ -45,8 +45,8 @@ interface SmtpVerificationOptions {
45
45
  ttl?: number;
46
46
  }
47
47
  /**
48
- * Detailed result of an SMTP verification attempt.
49
- */
48
+ * Detailed result of an SMTP verification attempt.
49
+ */
50
50
  interface SmtpVerificationResult {
51
51
  /** True when the server accepts a random, nonexistent recipient (catch-all). */
52
52
  acceptAll?: boolean;
@@ -64,30 +64,5 @@ interface SmtpVerificationResult {
64
64
  /** True when the real RCPT TO was accepted (250). */
65
65
  valid: boolean;
66
66
  }
67
- /**
68
- * Verifies an email address over SMTP without sending a message.
69
- *
70
- * Performs the full handshake (greeting → EHLO/HELO → MAIL FROM → RCPT TO),
71
- * then — when the real recipient is accepted — issues additional RCPT TO probes
72
- * for random addresses to detect catch-all (accept-all) servers. Temporary
73
- * (4xx) failures are surfaced as `deferred` and retried up to `retries` times to
74
- * survive greylisting, and over-quota responses set `mailboxFull`.
75
- *
76
- * Note: many networks block outbound port 25 and many servers refuse or tarpit
77
- * verification probes, so treat a `deferred`/errored result as inconclusive
78
- * rather than undeliverable.
79
- * @param email The email address to verify.
80
- * @param options Verification options.
81
- * @returns The detailed SMTP verification result.
82
- * @example
83
- * ```ts
84
- * import { verifySmtp } from "@visulima/email-verifier/checks/smtp";
85
- *
86
- * const result = await verifySmtp("user@example.com", { catchAllProbes: 2 });
87
- * if (result.valid && !result.acceptAll) {
88
- * console.log("Mailbox exists");
89
- * }
90
- * ```
91
- */
92
67
  declare const verifySmtp: (email: string, options?: SmtpVerificationOptions) => Promise<SmtpVerificationResult>;
93
68
  export { type SmtpVerificationOptions, type SmtpVerificationResult, verifySmtp as default, verifySmtp };
@@ -1,7 +1,7 @@
1
- import{createRequire as x}from"node:module";import{splitAddress as M}from"../packem_shared/extractDomain-CYJf1_0N.js";import{checkMxRecords as j}from"./mx.js";const $=x(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=r=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[e,t]=h.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return h.getBuiltinModule(r)}return $(r)},{Socket:T}=R("node:net"),y=/[\u0000-\u001F\u007F]/,k=/\b([245]\.\d{1,3}\.\d{1,3})\b/,C=/^(\d{3})(?: |$)/,E=/\r?\n/,g="abcdefghijklmnopqrstuvwxyz0123456789",P=(r=20)=>{let e="";for(let t=0;t<r;t+=1)e+=g[Math.floor(Math.random()*g.length)]??"";return e},S=async r=>new Promise(e=>{setTimeout(e,r)});class _{transcript="";buffer="";completed=[];failure;finished=!1;socket;waiter;constructor(e){this.socket=e,e.on("data",o=>{this.transcript+=o.toString(),this.buffer+=o.toString(),this.drain()});const t=o=>{this.finished=!0,this.failure=o??new Error("Connection closed by server"),this.completed.length===0&&this.waiter&&(this.waiter.reject(this.failure),this.waiter=void 0)};e.on("error",t),e.on("close",()=>{t()}),e.on("timeout",()=>{t(new Error("SMTP socket timeout")),e.destroy()})}async command(e){return this.transcript+=`${e}\r
1
+ import{createRequire as x}from"node:module";import{splitAddress as L}from"../packem_shared/extractDomain-CYJf1_0N.js";import{checkMxRecords as _}from"./mx.js";let R;const M=r=>(R??=x(import.meta.url))(r),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=r=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,t]=m.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return m.getBuiltinModule(r)}return M(r)},{Socket:j}=T("node:net"),b=/[\u0000-\u001F\u007F]/,k=/\b([245]\.\d{1,3}\.\d{1,3})\b/,C=/^(\d{3})(?: |$)/,E=/\r?\n/,$="abcdefghijklmnopqrstuvwxyz0123456789",P=(r=20)=>{let e="";for(let t=0;t<r;t+=1)e+=$[Math.floor(Math.random()*$.length)]??"";return e},S=async r=>new Promise(e=>{setTimeout(e,r)});class A{transcript="";buffer="";completed=[];failure;finished=!1;socket;waiter;constructor(e){this.socket=e,e.on("data",s=>{this.transcript+=s.toString(),this.buffer+=s.toString(),this.drain()});const t=s=>{this.finished=!0,this.failure=s??new Error("Connection closed by server"),this.completed.length===0&&this.waiter&&(this.waiter.reject(this.failure),this.waiter=void 0)};e.on("error",t),e.on("close",()=>{t()}),e.on("timeout",()=>{t(new Error("SMTP socket timeout")),e.destroy()})}async command(e){return this.transcript+=`${e}\r
2
2
  `,this.socket.write(`${e}\r
3
3
  `),this.readReply()}close(){try{this.socket.write(`QUIT\r
4
- `)}catch{}this.socket.removeAllListeners(),this.socket.destroy()}async readReply(){if(this.completed.length>0)return this.completed.shift();if(this.finished)throw this.failure??new Error("Connection closed");return new Promise((e,t)=>{this.waiter={reject:t,resolve:e}})}drain(){const e=this.buffer.split(E);this.buffer=e.pop()??"";let t=[];for(const o of e){t.push(o);const a=C.exec(o);if(a){const i=t.join(`
5
- `),c=k.exec(i)?.[1];this.completed.push({code:Number.parseInt(a[1],10),enhanced:c,text:i}),t=[]}}if(t.length>0&&(this.buffer=`${t.join(`
4
+ `)}catch{}this.socket.removeAllListeners(),this.socket.destroy()}async readReply(){if(this.completed.length>0)return this.completed.shift();if(this.finished)throw this.failure??new Error("Connection closed");return new Promise((e,t)=>{this.waiter={reject:t,resolve:e}})}drain(){const e=this.buffer.split(E);this.buffer=e.pop()??"";let t=[];for(const s of e){t.push(s);const c=C.exec(s);if(c){const o=t.join(`
5
+ `),l=k.exec(o)?.[1];this.completed.push({code:Number.parseInt(c[1],10),enhanced:l,text:o}),t=[]}}if(t.length>0&&(this.buffer=`${t.join(`
6
6
  `)}
7
- ${this.buffer}`),this.waiter&&this.completed.length>0){const{resolve:o}=this.waiter;this.waiter=void 0,o(this.completed.shift())}}}const A=r=>{const{code:e,enhanced:t}=r;return e>=200&&e<300?{code:e,enhancedCode:t,valid:!0}:e===452||e===552||t==="4.2.2"||t==="5.2.2"?{code:e,deferred:e===452,enhancedCode:t,mailboxFull:!0,valid:!1}:e>=400&&e<500?{code:e,deferred:!0,enhancedCode:t,valid:!1}:{code:e,enhancedCode:t,valid:!1}},L=async(r,e,t)=>new Promise((o,a)=>{const i=new T;i.setTimeout(t);const c=f=>{i.removeAllListeners(),i.destroy(),a(f)},l=()=>{c(new Error("SMTP connection timeout"))};i.once("error",c),i.once("timeout",l),i.connect(e,r,()=>{i.removeListener("error",c),i.removeListener("timeout",l),o(new _(i))})}),H=async(r,e,t,o)=>{const{catchAllProbes:a=1,port:i=25,timeout:c=5e3}=o,l=o.heloHost??e,f=o.fromEmail??`verify@${l}`;let n;try{n=await L(t.exchange,i,c);const d=await n.readReply();if(d.code!==220)return{deferred:!0,error:`Unexpected greeting: ${d.text}`,valid:!1};let s=await n.command(`EHLO ${l}`);if(s.code!==250&&(s=await n.command(`HELO ${l}`),s.code!==250))return{deferred:!0,error:`HELO rejected: ${s.text}`,valid:!1};const u=await n.command(`MAIL FROM:<${f}>`);if(u.code!==250)return{deferred:!0,error:`MAIL FROM rejected: ${u.text}`,valid:!1};const b=await n.command(`RCPT TO:<${r}>`),p=A(b);let m;if(p.valid&&a>0){m=!0;for(let v=0;v<a;v+=1){const w=await n.command(`RCPT TO:<${P()}@${e}>`);if(w.code<200||w.code>=300){m=!1;break}}}return{...p,acceptAll:m,smtpResponse:n.transcript}}finally{n?.close()}},O=async(r,e,t,o)=>{let a="SMTP verification did not complete";for(const i of t)try{return await H(r,e,i,o)}catch(c){a=c instanceof Error?c.message:String(c)}return{deferred:!0,error:a,valid:!1}},I=r=>{if(r.heloHost!==void 0&&y.test(r.heloHost))return{error:"Invalid heloHost: control characters are not allowed",valid:!1};if(r.fromEmail!==void 0&&y.test(r.fromEmail))return{error:"Invalid fromEmail: control characters are not allowed",valid:!1}},B=async(r,e={})=>{const t=M(r);if(!t)return{error:"Invalid email format",valid:!1};const{domain:o}=t,a=I(e);if(a)return a;const{retries:i=1,retryDelay:c=5e3,ttl:l=36e5}=e,f=["smtp",t.address,e.fromEmail??"",String(e.port??25),e.heloHost??"",String(e.catchAllProbes??1),(e.mxRecords??[]).map(s=>s.exchange).join(",")].join("|");if(e.smtpCache){const s=await e.smtpCache.get(f);if(s!==void 0)return s}let n=e.mxRecords;if(!n||n.length===0){const s=await j(o,{cache:e.cache,fallbackToAddress:!1});if(!s.valid||!s.records||s.records.length===0)return{error:s.error??"No MX records found",mxRecords:s.records,valid:!1};n=s.records}let d={error:"SMTP verification did not complete",valid:!1};for(let s=0;s<=i&&(d=await O(t.address,o,n,e),!(!d.deferred||s===i));s+=1)await S(c);return d={...d,mxRecords:n},e.smtpCache&&!d.deferred&&await e.smtpCache.set(f,d,l),d};export{B as default,B as verifySmtp};
7
+ ${this.buffer}`),this.waiter&&this.completed.length>0){const{resolve:s}=this.waiter;this.waiter=void 0,s(this.completed.shift())}}}const H=r=>{const{code:e,enhanced:t}=r;return e>=200&&e<300?{code:e,enhancedCode:t,valid:!0}:e===452||e===552||t==="4.2.2"||t==="5.2.2"?{code:e,deferred:e===452,enhancedCode:t,mailboxFull:!0,valid:!1}:e>=400&&e<500?{code:e,deferred:!0,enhancedCode:t,valid:!1}:{code:e,enhancedCode:t,valid:!1}},O=async(r,e,t)=>new Promise((s,c)=>{const o=new j;o.setTimeout(t);const l=a=>{o.removeAllListeners(),o.destroy(),c(a)},i=()=>{l(new Error("SMTP connection timeout"))};o.once("error",l),o.once("timeout",i),o.connect(e,r,()=>{o.removeListener("error",l),o.removeListener("timeout",i),s(new A(o))})}),I=async(r,e,t,s)=>{const{catchAllProbes:c=1,port:o=25,timeout:l=5e3}=s,i=s.heloHost??e,a=s.fromEmail??`verify@${i}`;let d;try{d=await O(t.exchange,o,l);const u=await d.readReply();if(u.code!==220)return{connectionLevel:!0,deferred:!0,error:`Unexpected greeting: ${u.text}`,valid:!1};let n=await d.command(`EHLO ${i}`);if(n.code!==250&&(n=await d.command(`HELO ${i}`),n.code!==250))return{connectionLevel:!0,deferred:!0,error:`HELO rejected: ${n.text}`,valid:!1};const h=await d.command(`MAIL FROM:<${a}>`);if(h.code!==250)return{connectionLevel:!0,deferred:!0,error:`MAIL FROM rejected: ${h.text}`,valid:!1};const f=await d.command(`RCPT TO:<${r}>`),w=H(f);let p;if(w.valid&&c>0){p=!0;for(let y=0;y<c;y+=1){const g=await d.command(`RCPT TO:<${P()}@${e}>`);if(g.code<200||g.code>=300){p=!1;break}}}return{...w,acceptAll:p,smtpResponse:d.transcript}}finally{d?.close()}},q=async(r,e,t,s)=>{let c="SMTP verification did not complete",o;for(const l of t){let i;try{i=await I(r,e,l,s)}catch(a){c=a instanceof Error?a.message:String(a);continue}if(i.connectionLevel){o=i;continue}return i}if(o){const{connectionLevel:l,...i}=o;return i}return{deferred:!0,error:c,valid:!1}},F=r=>{if(r.heloHost!==void 0&&b.test(r.heloHost))return{error:"Invalid heloHost: control characters are not allowed",valid:!1};if(r.fromEmail!==void 0&&b.test(r.fromEmail))return{error:"Invalid fromEmail: control characters are not allowed",valid:!1}},v=new Map,z=async(r,e={})=>{const t=L(r);if(!t)return{error:"Invalid email format",valid:!1};const{domain:s}=t,c=F(e);if(c)return c;const{retries:o=1,retryDelay:l=5e3,ttl:i=36e5}=e,a=["smtp",t.address,e.fromEmail??"",String(e.port??25),e.heloHost??"",String(e.catchAllProbes??1),(e.mxRecords??[]).map(n=>n.exchange).join(",")].join("|");if(e.smtpCache){const n=await e.smtpCache.get(a);if(n!==void 0)return n}const d=v.get(a);if(d)return d;const u=(async()=>{let n=e.mxRecords;if(!n||n.length===0){const f=await _(s,{cache:e.cache,fallbackToAddress:!1});if(!f.valid||!f.records||f.records.length===0)return{error:f.error??"No MX records found",mxRecords:f.records,valid:!1};n=f.records}let h={error:"SMTP verification did not complete",valid:!1};for(let f=0;f<=o&&(h=await q(t.address,s,n,e),!(!h.deferred||f===o));f+=1)await S(l);return h={...h,mxRecords:n},e.smtpCache&&!h.deferred&&await e.smtpCache.set(a,h,i),h})();v.set(a,u);try{return await u}finally{v.delete(a)}};export{z as default,z as verifySmtp};
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The result of symbol / Unicode analysis.
3
- */
2
+ * The result of symbol / Unicode analysis.
3
+ */
4
4
  interface SymbolResult {
5
5
  /** True when the address mixes Unicode scripts (a homoglyph-spoofing signal). */
6
6
  hasMixedScripts: boolean;
@@ -12,18 +12,18 @@ interface SymbolResult {
12
12
  scripts: string[];
13
13
  }
14
14
  /**
15
- * Detects symbols, emoji, and mixed Unicode scripts in an email address.
16
- *
17
- * Mixed-script local parts (e.g. Latin + Cyrillic) are a classic homoglyph /
18
- * spoofing signal; symbol or emoji characters indicate a non-standard address.
19
- * @param email The email address to analyze.
20
- * @returns The symbol analysis result.
21
- * @example
22
- * ```ts
23
- * import { analyzeSymbols } from "@visulima/email-verifier/checks/symbol";
24
- *
25
- * analyzeSymbols("раypal@example.com").hasMixedScripts; // true (Cyrillic "ра")
26
- * ```
27
- */
15
+ * Detects symbols, emoji, and mixed Unicode scripts in an email address.
16
+ *
17
+ * Mixed-script local parts (e.g. Latin + Cyrillic) are a classic homoglyph /
18
+ * spoofing signal; symbol or emoji characters indicate a non-standard address.
19
+ * @param email The email address to analyze.
20
+ * @returns The symbol analysis result.
21
+ * @example
22
+ * ```ts
23
+ * import { analyzeSymbols } from "@visulima/email-verifier/checks/symbol";
24
+ *
25
+ * analyzeSymbols("раypal@example.com").hasMixedScripts; // true (Cyrillic "ра")
26
+ * ```
27
+ */
28
28
  declare const analyzeSymbols: (email: string) => SymbolResult;
29
29
  export { type SymbolResult, analyzeSymbols, analyzeSymbols as default };
@@ -1,19 +1,19 @@
1
1
  /**
2
- * Validates an email address format according to basic RFC standards.
3
- *
4
- * This is intentionally pragmatic rather than a full RFC 5322 parser: it rejects
5
- * the address shapes that never deliver (missing parts, consecutive dots, leading
6
- * or trailing dots, hyphen-bounded domain labels) while accepting the long tail
7
- * of legitimate real-world addresses.
8
- * @param email The email address string to validate.
9
- * @returns True if the email address is syntactically valid, false otherwise.
10
- * @example
11
- * ```ts
12
- * import { validateSyntax } from "@visulima/email-verifier/checks/syntax";
13
- *
14
- * validateSyntax("user@example.com"); // true
15
- * validateSyntax("user@@example.com"); // false
16
- * ```
17
- */
2
+ * Validates an email address format according to basic RFC standards.
3
+ *
4
+ * This is intentionally pragmatic rather than a full RFC 5322 parser: it rejects
5
+ * the address shapes that never deliver (missing parts, consecutive dots, leading
6
+ * or trailing dots, hyphen-bounded domain labels) while accepting the long tail
7
+ * of legitimate real-world addresses.
8
+ * @param email The email address string to validate.
9
+ * @returns True if the email address is syntactically valid, false otherwise.
10
+ * @example
11
+ * ```ts
12
+ * import { validateSyntax } from "@visulima/email-verifier/checks/syntax";
13
+ *
14
+ * validateSyntax("user@example.com"); // true
15
+ * validateSyntax("user@@example.com"); // false
16
+ * ```
17
+ */
18
18
  declare const validateSyntax: (email: string) => boolean;
19
19
  export { validateSyntax as default, validateSyntax };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The result of sub-address (tag) detection.
3
- */
2
+ * The result of sub-address (tag) detection.
3
+ */
4
4
  interface TagResult {
5
5
  /** The local part with the tag and separator removed (the "real" mailbox). */
6
6
  baseLocalPart: string;
@@ -12,20 +12,20 @@ interface TagResult {
12
12
  tag?: string;
13
13
  }
14
14
  /**
15
- * Detects plus-addressing / sub-addressing tags in an email address.
16
- *
17
- * Most providers (Gmail, Outlook, iCloud, Proton, …) delimit the tag with `+`;
18
- * a few (Fastmail, Yahoo) use `-`. The returned {@link TagResult.baseLocalPart}
19
- * is the canonical mailbox with the tag stripped.
20
- * @param email The email address to inspect.
21
- * @returns The tag detection result.
22
- * @example
23
- * ```ts
24
- * import { detectTag } from "@visulima/email-verifier/checks/tag";
25
- *
26
- * detectTag("user+newsletter@gmail.com");
27
- * // { hasTag: true, tag: "newsletter", separator: "+", baseLocalPart: "user" }
28
- * ```
29
- */
15
+ * Detects plus-addressing / sub-addressing tags in an email address.
16
+ *
17
+ * Most providers (Gmail, Outlook, iCloud, Proton, …) delimit the tag with `+`;
18
+ * a few (Fastmail, Yahoo) use `-`. The returned {@link TagResult.baseLocalPart}
19
+ * is the canonical mailbox with the tag stripped.
20
+ * @param email The email address to inspect.
21
+ * @returns The tag detection result.
22
+ * @example
23
+ * ```ts
24
+ * import { detectTag } from "@visulima/email-verifier/checks/tag";
25
+ *
26
+ * detectTag("user+newsletter@gmail.com");
27
+ * // { hasTag: true, tag: "newsletter", separator: "+", baseLocalPart: "user" }
28
+ * ```
29
+ */
30
30
  declare const detectTag: (email: string) => TagResult;
31
31
  export { type TagResult, detectTag as default, detectTag };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * A name parsed from an email's local part.
3
- */
2
+ * A name parsed from an email's local part.
3
+ */
4
4
  interface NameResult {
5
5
  /** Confidence in the parse: `high` (clear separator), `medium` (camelCase), `low` (heuristic), `none`. */
6
6
  confidence: "high" | "low" | "medium" | "none";
@@ -12,21 +12,21 @@ interface NameResult {
12
12
  lastName?: string;
13
13
  }
14
14
  /**
15
- * Heuristically parses a person's name from the local part of an email address.
16
- *
17
- * Handles separator-delimited (`john.doe`), camelCase (`johnDoe`), and
18
- * single-token local parts, stripping trailing digits. This is best-effort name
19
- * parsing only — no gender detection — and confidence is reported so callers
20
- * can decide how much to trust it.
21
- * @param email The email address to parse.
22
- * @returns The parsed name and a confidence level.
23
- * @example
24
- * ```ts
25
- * import { parseName } from "@visulima/email-verifier/enrich/name";
26
- *
27
- * parseName("john.doe@example.com");
28
- * // { firstName: "John", lastName: "Doe", fullName: "John Doe", confidence: "high" }
29
- * ```
30
- */
15
+ * Heuristically parses a person's name from the local part of an email address.
16
+ *
17
+ * Handles separator-delimited (`john.doe`), camelCase (`johnDoe`), and
18
+ * single-token local parts, stripping trailing digits. This is best-effort name
19
+ * parsing only — no gender detection — and confidence is reported so callers
20
+ * can decide how much to trust it.
21
+ * @param email The email address to parse.
22
+ * @returns The parsed name and a confidence level.
23
+ * @example
24
+ * ```ts
25
+ * import { parseName } from "@visulima/email-verifier/enrich/name";
26
+ *
27
+ * parseName("john.doe@example.com");
28
+ * // { firstName: "John", lastName: "Doe", fullName: "John Doe", confidence: "high" }
29
+ * ```
30
+ */
31
31
  declare const parseName: (email: string) => NameResult;
32
32
  export { type NameResult, parseName as default, parseName };
@@ -1,9 +1,9 @@
1
1
  import { MxProviderInfo } from '@visulima/email-provider-mx';
2
2
  export { type MxProviderInfo, classifyMx, classifyMxRecords, isSecureEmailGateway } from '@visulima/email-provider-mx';
3
- import { c as MxRecord, b as MxCheckResult, C as Cache } from "../packem_shared/mx.d-NAesS5sg.js";
3
+ import { c as MxRecord, b as MxCheckResult, C as Cache } from "../packem_shared/mx.d-HxIDdxvR.js";
4
4
  /**
5
- * The enriched provider details for an email address.
6
- */
5
+ * The enriched provider details for an email address.
6
+ */
7
7
  interface ProviderDetails {
8
8
  /** True when the resolving MX is a Secure Email Gateway (Proofpoint, Mimecast, …). */
9
9
  isSecureEmailGateway: boolean;
@@ -13,28 +13,28 @@ interface ProviderDetails {
13
13
  provider?: MxProviderInfo;
14
14
  }
15
15
  /**
16
- * Options for provider enrichment.
17
- */
16
+ * Options for provider enrichment.
17
+ */
18
18
  interface ProviderEnrichOptions {
19
19
  cache?: Cache<MxCheckResult>;
20
20
  ttl?: number;
21
21
  }
22
22
  /**
23
- * Resolves an email address's mailbox/SEG provider from its MX records.
24
- *
25
- * Looks up the domain's MX records, then classifies the highest-priority host
26
- * via `@visulima/email-provider-mx` — emailable's "SMTP Provider Details" plus
27
- * Secure-Email-Gateway detection.
28
- * @param email The email address to enrich.
29
- * @param options Caching options for the MX lookup.
30
- * @returns The provider details, including the MX records used.
31
- * @example
32
- * ```ts
33
- * import { enrichProvider } from "@visulima/email-verifier/enrich/provider";
34
- *
35
- * const details = await enrichProvider("user@gmail.com");
36
- * console.log(details.provider?.display); // "Google"
37
- * ```
38
- */
23
+ * Resolves an email address's mailbox/SEG provider from its MX records.
24
+ *
25
+ * Looks up the domain's MX records, then classifies the highest-priority host
26
+ * via `@visulima/email-provider-mx` — emailable's "SMTP Provider Details" plus
27
+ * Secure-Email-Gateway detection.
28
+ * @param email The email address to enrich.
29
+ * @param options Caching options for the MX lookup.
30
+ * @returns The provider details, including the MX records used.
31
+ * @example
32
+ * ```ts
33
+ * import { enrichProvider } from "@visulima/email-verifier/enrich/provider";
34
+ *
35
+ * const details = await enrichProvider("user@gmail.com");
36
+ * console.log(details.provider?.display); // "Google"
37
+ * ```
38
+ */
39
39
  declare const enrichProvider: (email: string, options?: ProviderEnrichOptions) => Promise<ProviderDetails>;
40
40
  export { type ProviderDetails, type ProviderEnrichOptions, enrichProvider as default, enrichProvider };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * A suggested correction for a likely-misspelled email address.
3
- */
2
+ * A suggested correction for a likely-misspelled email address.
3
+ */
4
4
  interface TypoSuggestion {
5
5
  /** The suggested corrected domain. */
6
6
  domain: string;
@@ -8,52 +8,52 @@ interface TypoSuggestion {
8
8
  full: string;
9
9
  }
10
10
  /**
11
- * Options for typo suggestion.
12
- */
11
+ * Options for typo suggestion.
12
+ */
13
13
  interface TypoOptions {
14
14
  /** Popular full domains to match against (e.g. `gmail.com`). */
15
15
  domains?: string[];
16
16
  /**
17
- * Distance threshold for the full-domain match.
18
- * @default 2
19
- */
17
+ * Distance threshold for the full-domain match.
18
+ * @default 2
19
+ */
20
20
  domainThreshold?: number;
21
21
  /** Popular second-level domains to match against (e.g. `gmail`). */
22
22
  secondLevelDomains?: string[];
23
23
  /**
24
- * Distance threshold for the second-level match.
25
- * @default 2
26
- */
24
+ * Distance threshold for the second-level match.
25
+ * @default 2
26
+ */
27
27
  secondLevelThreshold?: number;
28
28
  /** Popular top-level domains to match against (e.g. `com`). */
29
29
  topLevelDomains?: string[];
30
30
  /**
31
- * Distance threshold for the top-level match.
32
- * @default 2
33
- */
31
+ * Distance threshold for the top-level match.
32
+ * @default 2
33
+ */
34
34
  topLevelThreshold?: number;
35
35
  }
36
36
  declare const sift3Distance: (s1: string, s2: string) => number;
37
37
  /**
38
- * Suggests a corrected domain for a likely-misspelled one, using the mailcheck
39
- * algorithm (full-domain match, then second-level + top-level matching).
40
- * @param domain The domain to check.
41
- * @param options Override domain lists and thresholds.
42
- * @returns The suggested domain, or `undefined` when the domain looks fine.
43
- */
38
+ * Suggests a corrected domain for a likely-misspelled one, using the mailcheck
39
+ * algorithm (full-domain match, then second-level + top-level matching).
40
+ * @param domain The domain to check.
41
+ * @param options Override domain lists and thresholds.
42
+ * @returns The suggested domain, or `undefined` when the domain looks fine.
43
+ */
44
44
  declare const suggestDomain: (domain: string, options?: TypoOptions) => string | undefined;
45
45
  /**
46
- * Suggests a corrected email address when the domain looks misspelled
47
- * (e.g. `user@gmial.com` → `user@gmail.com`).
48
- * @param email The email address to check.
49
- * @param options Override domain lists and thresholds.
50
- * @returns A {@link TypoSuggestion}, or `undefined` when nothing looks wrong.
51
- * @example
52
- * ```ts
53
- * import { suggestEmailTypo } from "@visulima/email-verifier/enrich/typo";
54
- *
55
- * suggestEmailTypo("user@gmial.com")?.full; // "user@gmail.com"
56
- * ```
57
- */
46
+ * Suggests a corrected email address when the domain looks misspelled
47
+ * (e.g. `user@gmial.com` → `user@gmail.com`).
48
+ * @param email The email address to check.
49
+ * @param options Override domain lists and thresholds.
50
+ * @returns A {@link TypoSuggestion}, or `undefined` when nothing looks wrong.
51
+ * @example
52
+ * ```ts
53
+ * import { suggestEmailTypo } from "@visulima/email-verifier/enrich/typo";
54
+ *
55
+ * suggestEmailTypo("user@gmial.com")?.full; // "user@gmail.com"
56
+ * ```
57
+ */
58
58
  declare const suggestEmailTypo: (email: string, options?: TypoOptions) => TypoSuggestion | undefined;
59
59
  export { type TypoOptions, type TypoSuggestion, suggestEmailTypo as default, sift3Distance, suggestDomain, suggestEmailTypo };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { type CharacterResult, analyzeCharacters } from "./checks/character.js";
2
2
  export { type DisposableEmailOptions, areDisposableEmails, isDisposableDomain, isDisposableEmail } from '@visulima/disposable-email-domains';
3
3
  export { type FreeEmailOptions, areFreeEmails, isFreeDomain, isFreeEmail } from '@visulima/free-email-domains';
4
- export { type C as Cache, I as InMemoryCache, type a as InMemoryCacheOptions, type M as MxCheckOptions, type b as MxCheckResult, type c as MxRecord, type d as MxResolution, e as checkMxRecords } from "./packem_shared/mx.d-NAesS5sg.js";
4
+ export { type C as Cache, I as InMemoryCache, type a as InMemoryCacheOptions, type M as MxCheckOptions, type b as MxCheckResult, type c as MxRecord, type d as MxResolution, e as checkMxRecords } from "./packem_shared/mx.d-HxIDdxvR.js";
5
5
  export { NO_REPLY_PREFIXES, ROLE_ACCOUNT_PREFIXES, isNoReply, default as isRoleAccount } from "./checks/role.js";
6
6
  export { type SmtpVerificationOptions, type SmtpVerificationResult, default as verifySmtp } from "./checks/smtp.js";
7
7
  export { type SymbolResult, analyzeSymbols } from "./checks/symbol.js";
@@ -10,12 +10,12 @@ export { type TagResult, default as detectTag } from "./checks/tag.js";
10
10
  export { type NameResult, default as parseName } from "./enrich/name.js";
11
11
  export { type ProviderDetails, type ProviderEnrichOptions, default as enrichProvider } from "./enrich/provider.js";
12
12
  export { type TypoOptions, type TypoSuggestion, sift3Distance, suggestDomain, default as suggestEmailTypo } from "./enrich/typo.js";
13
- export { D as DEFAULT_WEIGHTS, type a as DomainReport, type E as EmailVerificationReport, type S as ScoreInput, type b as ScoreResult, type c as ScoreWeights, type V as VerificationState, s as scoreReport } from "./packem_shared/score.d-BTcZnl2L.js";
13
+ export { D as DEFAULT_WEIGHTS, type a as DomainReport, type E as EmailVerificationReport, type S as ScoreInput, type b as ScoreResult, type c as ScoreWeights, type V as VerificationState, s as scoreReport } from "./packem_shared/score.d-a6cl6fPu.js";
14
14
  export { type VerifyEmailOptions, default as verifyEmail } from "./verify-email.js";
15
15
  export { type MxProviderInfo, classifyMx, classifyMxRecords, isSecureEmailGateway } from '@visulima/email-provider-mx';
16
16
  /**
17
- * The split parts of an email address.
18
- */
17
+ * The split parts of an email address.
18
+ */
19
19
  interface AddressParts {
20
20
  /** The full normalized (lowercased, trimmed) address. */
21
21
  address: string;
@@ -25,21 +25,21 @@ interface AddressParts {
25
25
  localPart: string;
26
26
  }
27
27
  /**
28
- * Splits an email address into its normalized local and domain parts.
29
- *
30
- * Uses the last `@` as the separator so quoted local parts containing `@` are
31
- * handled the same way the SMTP/MX probes treat them. Inputs containing
32
- * whitespace (after trimming) are rejected so a payload that embeds a CRLF
33
- * followed by a second SMTP command cannot be smuggled into the SMTP dialogue
34
- * by callers of the standalone probes.
35
- * @param email The email address to split.
36
- * @returns The normalized parts, or `undefined` if the address is structurally invalid.
37
- */
28
+ * Splits an email address into its normalized local and domain parts.
29
+ *
30
+ * Uses the last `@` as the separator so quoted local parts containing `@` are
31
+ * handled the same way the SMTP/MX probes treat them. Inputs containing
32
+ * whitespace (after trimming) are rejected so a payload that embeds a CRLF
33
+ * followed by a second SMTP command cannot be smuggled into the SMTP dialogue
34
+ * by callers of the standalone probes.
35
+ * @param email The email address to split.
36
+ * @returns The normalized parts, or `undefined` if the address is structurally invalid.
37
+ */
38
38
  declare const splitAddress: (email: string) => AddressParts | undefined;
39
39
  /**
40
- * Extracts and normalizes just the domain from an email address.
41
- * @param email The email address to extract the domain from.
42
- * @returns The normalized domain, or `undefined` if invalid.
43
- */
40
+ * Extracts and normalizes just the domain from an email address.
41
+ * @param email The email address to extract the domain from.
42
+ * @returns The normalized domain, or `undefined` if invalid.
43
+ */
44
44
  declare const extractDomain: (email: string) => string | undefined;
45
45
  export { type AddressParts, extractDomain, splitAddress };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Generic cache interface for caching any type of data.
3
+ * Implementations can use in-memory cache, LRU cache, Redis, etc.
4
+ */
5
+ interface Cache<T = unknown> {
6
+ /**
7
+ * Clears all cached entries.
8
+ */
9
+ clear: () => Promise<void>;
10
+ /**
11
+ * Deletes a cached entry.
12
+ * @param key The cache key.
13
+ */
14
+ delete: (key: string) => Promise<void>;
15
+ /**
16
+ * Gets a cached value.
17
+ * @param key The cache key.
18
+ * @returns The cached value or undefined if not found or expired.
19
+ */
20
+ get: (key: string) => Promise<T | undefined>;
21
+ /**
22
+ * Sets a cached value.
23
+ * @param key The cache key.
24
+ * @param value The value to cache.
25
+ * @param ttl Time-to-live in milliseconds.
26
+ */
27
+ set: (key: string, value: T, ttl: number) => Promise<void>;
28
+ }
29
+ /**
30
+ * Options for creating an in-memory cache.
31
+ */
32
+ interface InMemoryCacheOptions {
33
+ /**
34
+ * Maximum number of entries in the cache.
35
+ * @default 500
36
+ */
37
+ max?: number;
38
+ /**
39
+ * Default TTL in milliseconds for entries.
40
+ * @default 3600000 (1 hour)
41
+ */
42
+ ttl?: number;
43
+ }
44
+ /**
45
+ * Default in-memory cache implementation using LRU cache.
46
+ *
47
+ * Shared by the MX and SMTP probes so repeated lookups against the same domain
48
+ * (e.g. when verifying a list) avoid redundant DNS/socket work.
49
+ */
50
+ declare class InMemoryCache<T extends object = Record<string, unknown>> implements Cache<T> {
51
+ private readonly cache;
52
+ constructor(options?: InMemoryCacheOptions);
53
+ clear: () => Promise<void>;
54
+ delete: (key: string) => Promise<void>;
55
+ get: (key: string) => Promise<T | undefined>;
56
+ set: (key: string, value: T, ttl: number) => Promise<void>;
57
+ }
58
+ /**
59
+ * MX record information.
60
+ */
61
+ interface MxRecord {
62
+ exchange: string;
63
+ priority: number;
64
+ }
65
+ /**
66
+ * How the domain's mail-acceptance was established.
67
+ *
68
+ * - `mx`: the domain published MX records.
69
+ * - `address`: the domain has no MX but resolves to an A/AAAA record, so by RFC 5321 §5.1 the address itself is treated as an implicit MX.
70
+ * - `none`: neither MX nor address records exist.
71
+ */
72
+ type MxResolution = "address" | "mx" | "none";
73
+ /**
74
+ * Result of an MX/domain check.
75
+ */
76
+ interface MxCheckResult {
77
+ /**
78
+ * True when the lookup was inconclusive because of a transient DNS failure
79
+ * (timeout, SERVFAIL, refused, …) rather than a definitive "no records"
80
+ * answer. Such a result is neither cached nor treated as undeliverable.
81
+ */
82
+ deferred?: boolean;
83
+ /** True when the domain itself resolves but publishes no MX records. */
84
+ domainResolves: boolean;
85
+ error?: string;
86
+ records?: MxRecord[];
87
+ resolvedVia: MxResolution;
88
+ /** True when the domain can accept mail (has MX or A/AAAA records). */
89
+ valid: boolean;
90
+ }
91
+ /**
92
+ * Options for MX record checking.
93
+ */
94
+ interface MxCheckOptions {
95
+ cache?: Cache<MxCheckResult>;
96
+ /**
97
+ * When true (the default), a domain with no MX records but a resolvable
98
+ * A/AAAA record is still considered able to accept mail (implicit MX).
99
+ */
100
+ fallbackToAddress?: boolean;
101
+ ttl?: number;
102
+ }
103
+ declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise<MxCheckResult>;
104
+ export { Cache as C, InMemoryCache as I, MxCheckOptions as M, InMemoryCacheOptions as a, MxCheckResult as b, MxRecord as c, MxResolution as d, checkMxRecords as e };
@@ -1,23 +1,29 @@
1
1
  import { CharacterResult } from "../checks/character.js";
2
- import { c as MxRecord, d as MxResolution } from "./mx.d-NAesS5sg.js";
2
+ import { c as MxRecord, d as MxResolution } from "./mx.d-HxIDdxvR.js";
3
3
  import { SmtpVerificationResult } from "../checks/smtp.js";
4
4
  import { SymbolResult } from "../checks/symbol.js";
5
5
  import { TagResult } from "../checks/tag.js";
6
6
  import { NameResult } from "../enrich/name.js";
7
7
  import { MxProviderInfo } from '@visulima/email-provider-mx';
8
8
  /**
9
- * The overall deliverability verdict for an address, mirroring emailable's states.
10
- *
11
- * - `deliverable`: the mailbox almost certainly exists and accepts mail.
12
- * - `risky`: deliverable but lower-quality (catch-all, role, disposable, full mailbox).
13
- * - `undeliverable`: syntax/domain/mailbox failure — do not send.
14
- * - `unknown`: could not be determined (SMTP blocked, greylisted, or not probed).
15
- */
9
+ * The overall deliverability verdict for an address, mirroring emailable's states.
10
+ *
11
+ * - `deliverable`: the mailbox almost certainly exists and accepts mail.
12
+ * - `risky`: deliverable but lower-quality (catch-all, role, disposable, full mailbox).
13
+ * - `undeliverable`: syntax/domain/mailbox failure — do not send.
14
+ * - `unknown`: could not be determined (SMTP blocked, greylisted, or not probed).
15
+ */
16
16
  type VerificationState = "deliverable" | "risky" | "undeliverable" | "unknown";
17
17
  /**
18
- * The resolved domain portion of a verification report.
19
- */
18
+ * The resolved domain portion of a verification report.
19
+ */
20
20
  interface DomainReport {
21
+ /**
22
+ * True when the domain lookup was inconclusive because of a transient DNS
23
+ * failure (timeout, SERVFAIL, refused). The domain is neither confirmed nor
24
+ * proven undeliverable — treat as `unknown`.
25
+ */
26
+ deferred?: boolean;
21
27
  /** The MX records found (empty when resolved via A/AAAA or not at all). */
22
28
  records: MxRecord[];
23
29
  /** How mail-acceptance was established (`unchecked` when DNS was skipped). */
@@ -26,11 +32,11 @@ interface DomainReport {
26
32
  valid: boolean;
27
33
  }
28
34
  /**
29
- * A complete email verification + enrichment report.
30
- *
31
- * Aggregates every check and enrichment into a single object whose shape reads
32
- * as a drop-in mental model for emailable's API response.
33
- */
35
+ * A complete email verification + enrichment report.
36
+ *
37
+ * Aggregates every check and enrichment into a single object whose shape reads
38
+ * as a drop-in mental model for emailable's API response.
39
+ */
34
40
  interface EmailVerificationReport {
35
41
  /** True when the SMTP server accepts any recipient (catch-all / accept-all). */
36
42
  acceptAll: boolean;
@@ -76,16 +82,16 @@ interface EmailVerificationReport {
76
82
  tag: TagResult;
77
83
  }
78
84
  /**
79
- * The fields of a report the scorer consumes (everything except the derived
80
- * `score`, `state`, and `reason`).
81
- */
85
+ * The fields of a report the scorer consumes (everything except the derived
86
+ * `score`, `state`, and `reason`).
87
+ */
82
88
  type ScoreInput = Omit<EmailVerificationReport, "reason" | "score" | "state">;
83
89
  /**
84
- * Overridable penalty/bonus weights for the quality score.
85
- *
86
- * Each value is points applied to a 100-point baseline. Penalties are positive
87
- * numbers that get subtracted; bonuses are added.
88
- */
90
+ * Overridable penalty/bonus weights for the quality score.
91
+ *
92
+ * Each value is points applied to a 100-point baseline. Penalties are positive
93
+ * numbers that get subtracted; bonuses are added.
94
+ */
89
95
  interface ScoreWeights {
90
96
  acceptAll: number;
91
97
  character: number;
@@ -102,33 +108,33 @@ interface ScoreWeights {
102
108
  symbol: number;
103
109
  }
104
110
  /**
105
- * The default scoring rubric. Transparent and additive so callers can reason
106
- * about — and override — every weight.
107
- */
111
+ * The default scoring rubric. Transparent and additive so callers can reason
112
+ * about — and override — every weight.
113
+ */
108
114
  declare const DEFAULT_WEIGHTS: ScoreWeights;
109
115
  /**
110
- * The outcome of scoring: the numeric score plus the derived state and reason.
111
- */
116
+ * The outcome of scoring: the numeric score plus the derived state and reason.
117
+ */
112
118
  interface ScoreResult {
113
119
  reason: string;
114
120
  score: number;
115
121
  state: VerificationState;
116
122
  }
117
123
  /**
118
- * Computes a 0–100 quality score and the deliverability state for a report.
119
- *
120
- * The state is derived from hard signals (syntax, domain, SMTP verdict); the
121
- * score layers transparent penalties/bonuses on top so two `risky` addresses can
122
- * still be ranked against each other.
123
- * @param input The verification signals (a report without its derived fields).
124
- * @param weights Optional weight overrides.
125
- * @returns The score, state, and reason.
126
- * @example
127
- * ```ts
128
- * import { scoreReport } from "@visulima/email-verifier/score";
129
- *
130
- * const { score, state } = scoreReport(report);
131
- * ```
132
- */
124
+ * Computes a 0–100 quality score and the deliverability state for a report.
125
+ *
126
+ * The state is derived from hard signals (syntax, domain, SMTP verdict); the
127
+ * score layers transparent penalties/bonuses on top so two `risky` addresses can
128
+ * still be ranked against each other.
129
+ * @param input The verification signals (a report without its derived fields).
130
+ * @param weights Optional weight overrides.
131
+ * @returns The score, state, and reason.
132
+ * @example
133
+ * ```ts
134
+ * import { scoreReport } from "@visulima/email-verifier/score";
135
+ *
136
+ * const { score, state } = scoreReport(report);
137
+ * ```
138
+ */
133
139
  declare const scoreReport: (input: ScoreInput, weights?: Partial<ScoreWeights>) => ScoreResult;
134
140
  export { DEFAULT_WEIGHTS as D, EmailVerificationReport as E, ScoreInput as S, VerificationState as V, DomainReport as a, ScoreResult as b, ScoreWeights as c, scoreReport as s };
package/dist/score.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { D as DEFAULT_WEIGHTS, type S as ScoreInput, type b as ScoreResult, type c as ScoreWeights, s as default, s as scoreReport } from "./packem_shared/score.d-BTcZnl2L.js";
1
+ export { D as DEFAULT_WEIGHTS, type S as ScoreInput, type b as ScoreResult, type c as ScoreWeights, s as default, s as scoreReport } from "./packem_shared/score.d-a6cl6fPu.js";
2
2
  import "./checks/character.js";
3
- import "./packem_shared/mx.d-NAesS5sg.js";
3
+ import "./packem_shared/mx.d-HxIDdxvR.js";
4
4
  import "./checks/smtp.js";
5
5
  import "./checks/symbol.js";
6
6
  import "./checks/tag.js";
package/dist/score.js CHANGED
@@ -1 +1 @@
1
- const t={acceptAll:25,character:15,deferred:15,didYouMean:20,disposable:60,free:5,knownProvider:5,mailboxFull:40,mixedScripts:30,noReply:25,role:25,smtpUnverified:10,symbol:10},i=e=>Math.max(0,Math.min(100,Math.round(e))),n=e=>e.smtp!==void 0&&!e.smtp.valid&&!e.smtp.deferred&&!e.mailboxFull&&(e.smtp.code??0)>=500,d=e=>e.disposable?{reason:"disposable_mailbox",state:"risky"}:e.mailboxFull?{reason:"mailbox_full",state:"risky"}:e.acceptAll?{reason:"accept_all",state:"risky"}:e.noReply?{reason:"no_reply",state:"risky"}:e.role?{reason:"role_account",state:"risky"}:{reason:"accepted_email",state:"deliverable"},m=e=>n(e)?{reason:"rejected_email",state:"undeliverable"}:e.smtp?.valid?d(e):e.mailboxFull?{reason:"mailbox_full",state:"risky"}:e.smtp?.deferred?{reason:"greylisted",state:"unknown"}:{reason:"unknown",state:"unknown"},c=e=>e.syntaxValid?e.domain.resolvedVia!=="unchecked"&&!e.domain.valid?{reason:e.domain.resolvedVia==="none"?"no_mx_records":"invalid_domain",state:"undeliverable"}:e.smtp?m(e):e.disposable?{reason:"disposable_mailbox",state:"risky"}:{reason:"smtp_not_checked",state:"unknown"}:{reason:"invalid_syntax",state:"undeliverable"},p=(e,o={})=>{const s={...t,...o},{reason:l,state:r}=c(e);if(r==="undeliverable")return{reason:l,score:0,state:r};let a=100;return e.smtp?.valid!==!0&&(a-=s.smtpUnverified),e.deferred&&(a-=s.deferred),e.disposable&&(a-=s.disposable),e.acceptAll&&(a-=s.acceptAll),e.mailboxFull&&(a-=s.mailboxFull),e.role&&(a-=s.role),e.noReply&&(a-=s.noReply),e.free&&(a-=s.free),e.character.irregular&&(a-=s.character),e.symbol.hasMixedScripts?a-=s.mixedScripts:e.symbol.hasSymbols&&(a-=s.symbol),e.didYouMean&&(a-=s.didYouMean),e.provider&&(a+=s.knownProvider),{reason:l,score:i(a),state:r}};export{t as DEFAULT_WEIGHTS,p as default,p as scoreReport};
1
+ const t={acceptAll:25,character:15,deferred:15,didYouMean:20,disposable:60,free:5,knownProvider:5,mailboxFull:40,mixedScripts:30,noReply:25,role:25,smtpUnverified:10,symbol:10},n=e=>Math.max(0,Math.min(100,Math.round(e))),i=e=>e.smtp!==void 0&&!e.smtp.valid&&!e.smtp.deferred&&!e.mailboxFull&&(e.smtp.code??0)>=500,d=e=>e.disposable?{reason:"disposable_mailbox",state:"risky"}:e.mailboxFull?{reason:"mailbox_full",state:"risky"}:e.acceptAll?{reason:"accept_all",state:"risky"}:e.noReply?{reason:"no_reply",state:"risky"}:e.role?{reason:"role_account",state:"risky"}:{reason:"accepted_email",state:"deliverable"},m=e=>i(e)?{reason:"rejected_email",state:"undeliverable"}:e.smtp?.valid?d(e):e.mailboxFull?{reason:"mailbox_full",state:"risky"}:e.smtp?.deferred?{reason:"greylisted",state:"unknown"}:{reason:"unknown",state:"unknown"},c=e=>e.syntaxValid?e.domain.resolvedVia!=="unchecked"&&!e.domain.valid?e.domain.deferred?{reason:"dns_error",state:"unknown"}:{reason:e.domain.resolvedVia==="none"?"no_mx_records":"invalid_domain",state:"undeliverable"}:e.smtp?m(e):e.disposable?{reason:"disposable_mailbox",state:"risky"}:{reason:"smtp_not_checked",state:"unknown"}:{reason:"invalid_syntax",state:"undeliverable"},p=(e,l={})=>{const s={...t,...l},{reason:o,state:r}=c(e);if(r==="undeliverable")return{reason:o,score:0,state:r};let a=100;return e.smtp?.valid!==!0&&(a-=s.smtpUnverified),e.deferred&&(a-=s.deferred),e.disposable&&(a-=s.disposable),e.acceptAll&&(a-=s.acceptAll),e.mailboxFull&&(a-=s.mailboxFull),e.role&&(a-=s.role),e.noReply&&(a-=s.noReply),e.free&&(a-=s.free),e.character.irregular&&(a-=s.character),e.symbol.hasMixedScripts?a-=s.mixedScripts:e.symbol.hasSymbols&&(a-=s.symbol),e.didYouMean&&(a-=s.didYouMean),e.provider&&(a+=s.knownProvider),{reason:o,score:n(a),state:r}};export{t as DEFAULT_WEIGHTS,p as default,p as scoreReport};
@@ -1,35 +1,35 @@
1
1
  import { DisposableEmailOptions } from '@visulima/disposable-email-domains';
2
2
  import { FreeEmailOptions } from '@visulima/free-email-domains';
3
- import { b as MxCheckResult, C as Cache } from "./packem_shared/mx.d-NAesS5sg.js";
3
+ import { b as MxCheckResult, C as Cache } from "./packem_shared/mx.d-HxIDdxvR.js";
4
4
  import { SmtpVerificationOptions } from "./checks/smtp.js";
5
5
  import { TypoOptions } from "./enrich/typo.js";
6
- import { c as ScoreWeights, E as EmailVerificationReport } from "./packem_shared/score.d-BTcZnl2L.js";
7
- export type { V as VerificationState } from "./packem_shared/score.d-BTcZnl2L.js";
6
+ import { c as ScoreWeights, E as EmailVerificationReport } from "./packem_shared/score.d-a6cl6fPu.js";
7
+ export type { V as VerificationState } from "./packem_shared/score.d-a6cl6fPu.js";
8
8
  import "./checks/character.js";
9
9
  import "./checks/symbol.js";
10
10
  import "./checks/tag.js";
11
11
  import "./enrich/name.js";
12
12
  import '@visulima/email-provider-mx';
13
13
  /**
14
- * Options for `verifyEmail`.
15
- */
14
+ * Options for `verifyEmail`.
15
+ */
16
16
  interface VerifyEmailOptions {
17
17
  /** Shared cache for MX/SMTP lookups (dedupes work when verifying lists). */
18
18
  cache?: Cache<MxCheckResult>;
19
19
  /**
20
- * Run live SMTP verification (catch-all, mailbox-full, greylist).
21
- * @default true
22
- */
20
+ * Run live SMTP verification (catch-all, mailbox-full, greylist).
21
+ * @default true
22
+ */
23
23
  checkSmtp?: boolean;
24
24
  /** Disposable-list overrides. */
25
25
  disposable?: DisposableEmailOptions;
26
26
  /** Free-list overrides. */
27
27
  free?: FreeEmailOptions;
28
28
  /**
29
- * Skip all network checks (MX, SMTP, provider) and produce a syntax +
30
- * heuristic-only report. Overrides `checkSmtp`.
31
- * @default false
32
- */
29
+ * Skip all network checks (MX, SMTP, provider) and produce a syntax +
30
+ * heuristic-only report. Overrides `checkSmtp`.
31
+ * @default false
32
+ */
33
33
  offline?: boolean;
34
34
  /** Additional role-account prefixes to recognize. */
35
35
  roleCustomPrefixes?: Iterable<string>;
@@ -41,22 +41,22 @@ interface VerifyEmailOptions {
41
41
  weights?: Partial<ScoreWeights>;
42
42
  }
43
43
  /**
44
- * Verifies and enriches a single email address end-to-end.
45
- *
46
- * Runs the offline checks (syntax, disposable, free, role, tag, character,
47
- * symbol, name, typo) immediately, then — unless `offline` is set — resolves the
48
- * domain's MX and runs the SMTP probe and provider classification concurrently.
49
- * Everything is aggregated into one {@link EmailVerificationReport} and scored.
50
- * @param email The email address to verify.
51
- * @param options Verification options.
52
- * @returns The complete verification report.
53
- * @example
54
- * ```ts
55
- * import { verifyEmail } from "@visulima/email-verifier";
56
- *
57
- * const report = await verifyEmail("user@gmail.com");
58
- * console.log(report.state, report.score); // "deliverable" 95
59
- * ```
60
- */
44
+ * Verifies and enriches a single email address end-to-end.
45
+ *
46
+ * Runs the offline checks (syntax, disposable, free, role, tag, character,
47
+ * symbol, name, typo) immediately, then — unless `offline` is set — resolves the
48
+ * domain's MX and runs the SMTP probe and provider classification concurrently.
49
+ * Everything is aggregated into one {@link EmailVerificationReport} and scored.
50
+ * @param email The email address to verify.
51
+ * @param options Verification options.
52
+ * @returns The complete verification report.
53
+ * @example
54
+ * ```ts
55
+ * import { verifyEmail } from "@visulima/email-verifier";
56
+ *
57
+ * const report = await verifyEmail("user@gmail.com");
58
+ * console.log(report.state, report.score); // "deliverable" 95
59
+ * ```
60
+ */
61
61
  declare const verifyEmail: (email: string, options?: VerifyEmailOptions) => Promise<EmailVerificationReport>;
62
62
  export { type EmailVerificationReport, type VerifyEmailOptions, verifyEmail as default, verifyEmail };
@@ -1 +1 @@
1
- import{analyzeCharacters as h}from"./checks/character.js";import{checkMxRecords as v}from"./checks/mx.js";import x,{isNoReply as b}from"./checks/role.js";import g from"./checks/smtp.js";import{analyzeSymbols as w}from"./checks/symbol.js";import V from"./checks/syntax.js";import E from"./checks/tag.js";import R from"./enrich/name.js";import $ from"./enrich/typo.js";import{splitAddress as k}from"./packem_shared/extractDomain-CYJf1_0N.js";import f from"./score.js";import{classifyMxRecords as A}from"@visulima/email-provider-mx";import{isFreeEmail as F}from"@visulima/free-email-domains";import{isDisposableEmail as C}from"@visulima/disposable-email-domains";const p=(e,a)=>({character:h(e),didYouMean:$(e,a.typo)?.full,disposable:C(e,a.disposable),free:F(e,a.free),name:R(e),noReply:b(e),role:x(e,a.roleCustomPrefixes),symbol:w(e),tag:E(e)}),J=async(e,a={})=>{const{checkSmtp:n=!0,offline:y=!1}=a,o=k(e),t=o?.address??(typeof e=="string"?e.trim().toLowerCase():"");if(!V(e)||!o){const s={...p(t,a),acceptAll:!1,deferred:!1,domain:{records:[],resolvedVia:"unchecked",valid:!1},email:t,mailboxFull:!1,secureEmailGateway:!1,syntaxValid:!1};return{...s,...f(s,a.weights)}}const u=p(o.address,a);let m={records:[],resolvedVia:"unchecked",valid:!1},r,l,d=!1;if(!y){const s=await v(o.domain,{cache:a.cache});m={records:s.records??[],resolvedVia:s.resolvedVia,valid:s.valid};const i=s.records??[];s.valid&&i.length>0&&(l=A(i),d=l?.type==="seg",n&&(r=await g(o.address,{cache:a.cache,...a.smtp,mxRecords:i})))}const c={...u,acceptAll:r?.acceptAll??!1,deferred:r?.deferred??!1,domain:m,email:o.address,mailboxFull:r?.mailboxFull??!1,provider:l,secureEmailGateway:d,smtp:r,syntaxValid:!0};return{...c,...f(c,a.weights)}};export{J as default,J as verifyEmail};
1
+ import{analyzeCharacters as h}from"./checks/character.js";import{checkMxRecords as v}from"./checks/mx.js";import x,{isNoReply as b}from"./checks/role.js";import g from"./checks/smtp.js";import{analyzeSymbols as w}from"./checks/symbol.js";import V from"./checks/syntax.js";import E from"./checks/tag.js";import R from"./enrich/name.js";import k from"./enrich/typo.js";import{splitAddress as A}from"./packem_shared/extractDomain-CYJf1_0N.js";import f from"./score.js";import{classifyMxRecords as F}from"@visulima/email-provider-mx";import{isFreeEmail as C}from"@visulima/free-email-domains";import{isDisposableEmail as M}from"@visulima/disposable-email-domains";const p=(e,a)=>({character:h(e),didYouMean:k(e,a.typo)?.full,disposable:M(e,a.disposable),free:C(e,a.free),name:R(e),noReply:b(e),role:x(e,a.roleCustomPrefixes),symbol:w(e),tag:E(e)}),J=async(e,a={})=>{const{checkSmtp:n=!0,offline:u=!1}=a,r=A(e),d=r?.address??(typeof e=="string"?e.trim().toLowerCase():"");if(!V(r?.address??e)||!r){const s={...p(d,a),acceptAll:!1,deferred:!1,domain:{records:[],resolvedVia:"unchecked",valid:!1},email:d,mailboxFull:!1,secureEmailGateway:!1,syntaxValid:!1};return{...s,...f(s,a.weights)}}const y=p(r.address,a);let t={records:[],resolvedVia:"unchecked",valid:!1},o,l,m=!1;if(!u){const s=await v(r.domain,{cache:a.cache});t={deferred:s.deferred,records:s.records??[],resolvedVia:s.resolvedVia,valid:s.valid};const i=s.records??[];s.valid&&i.length>0&&(l=F(i),m=l?.type==="seg",n&&(o=await g(r.address,{cache:a.cache,...a.smtp,mxRecords:i})))}const c={...y,acceptAll:o?.acceptAll??!1,deferred:o?.deferred??!1,domain:t,email:r.address,mailboxFull:o?.mailboxFull??!1,provider:l,secureEmailGateway:m,smtp:o,syntaxValid:!0};return{...c,...f(c,a.weights)}};export{J as default,J as verifyEmail};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/email-verifier",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Mailer-free email address verification and enrichment: syntax, MX/SMTP probing, disposable/free/role detection, catch-all, provider & secure-email-gateway classification, typo suggestions, and a 0–100 quality score.",
5
5
  "keywords": [
6
6
  "accept-all",
@@ -114,9 +114,9 @@
114
114
  "provenance": true
115
115
  },
116
116
  "dependencies": {
117
- "@visulima/disposable-email-domains": "1.0.1",
118
- "@visulima/email-provider-mx": "1.0.0",
119
- "@visulima/free-email-domains": "1.0.0",
117
+ "@visulima/disposable-email-domains": "1.1.0",
118
+ "@visulima/email-provider-mx": "1.0.1",
119
+ "@visulima/free-email-domains": "1.0.1",
120
120
  "lru-cache": "11.5.1"
121
121
  },
122
122
  "engines": {
@@ -1,117 +0,0 @@
1
- /**
2
- * Generic cache interface for caching any type of data.
3
- * Implementations can use in-memory cache, LRU cache, Redis, etc.
4
- */
5
- interface Cache<T = unknown> {
6
- /**
7
- * Clears all cached entries.
8
- */
9
- clear: () => Promise<void>;
10
- /**
11
- * Deletes a cached entry.
12
- * @param key The cache key.
13
- */
14
- delete: (key: string) => Promise<void>;
15
- /**
16
- * Gets a cached value.
17
- * @param key The cache key.
18
- * @returns The cached value or undefined if not found or expired.
19
- */
20
- get: (key: string) => Promise<T | undefined>;
21
- /**
22
- * Sets a cached value.
23
- * @param key The cache key.
24
- * @param value The value to cache.
25
- * @param ttl Time-to-live in milliseconds.
26
- */
27
- set: (key: string, value: T, ttl: number) => Promise<void>;
28
- }
29
- /**
30
- * Options for creating an in-memory cache.
31
- */
32
- interface InMemoryCacheOptions {
33
- /**
34
- * Maximum number of entries in the cache.
35
- * @default 500
36
- */
37
- max?: number;
38
- /**
39
- * Default TTL in milliseconds for entries.
40
- * @default 3600000 (1 hour)
41
- */
42
- ttl?: number;
43
- }
44
- /**
45
- * Default in-memory cache implementation using LRU cache.
46
- *
47
- * Shared by the MX and SMTP probes so repeated lookups against the same domain
48
- * (e.g. when verifying a list) avoid redundant DNS/socket work.
49
- */
50
- declare class InMemoryCache<T extends object = Record<string, unknown>> implements Cache<T> {
51
- private readonly cache;
52
- constructor(options?: InMemoryCacheOptions);
53
- clear: () => Promise<void>;
54
- delete: (key: string) => Promise<void>;
55
- get: (key: string) => Promise<T | undefined>;
56
- set: (key: string, value: T, ttl: number) => Promise<void>;
57
- }
58
- /**
59
- * MX record information.
60
- */
61
- interface MxRecord {
62
- exchange: string;
63
- priority: number;
64
- }
65
- /**
66
- * How the domain's mail-acceptance was established.
67
- *
68
- * - `mx`: the domain published MX records.
69
- * - `address`: the domain has no MX but resolves to an A/AAAA record, so by RFC 5321 §5.1 the address itself is treated as an implicit MX.
70
- * - `none`: neither MX nor address records exist.
71
- */
72
- type MxResolution = "address" | "mx" | "none";
73
- /**
74
- * Result of an MX/domain check.
75
- */
76
- interface MxCheckResult {
77
- /** True when the domain itself resolves but publishes no MX records. */
78
- domainResolves: boolean;
79
- error?: string;
80
- records?: MxRecord[];
81
- resolvedVia: MxResolution;
82
- /** True when the domain can accept mail (has MX or A/AAAA records). */
83
- valid: boolean;
84
- }
85
- /**
86
- * Options for MX record checking.
87
- */
88
- interface MxCheckOptions {
89
- cache?: Cache<MxCheckResult>;
90
- /**
91
- * When true (the default), a domain with no MX records but a resolvable
92
- * A/AAAA record is still considered able to accept mail (implicit MX).
93
- */
94
- fallbackToAddress?: boolean;
95
- ttl?: number;
96
- }
97
- /**
98
- * Checks MX records for a domain, with an optional A/AAAA fallback.
99
- *
100
- * Distinguishes three states emailable separates as "MX Record Detection" and
101
- * "Domain Validation": records present (`mx`), no MX but the domain resolves
102
- * (`address`, implicit MX), and nothing resolves (`none`).
103
- * @param domain The domain to check.
104
- * @param options Options including caching and the address fallback toggle.
105
- * @returns The MX/domain check result.
106
- * @example
107
- * ```ts
108
- * import { checkMxRecords } from "@visulima/email-verifier/checks/mx";
109
- *
110
- * const result = await checkMxRecords("example.com");
111
- * if (result.valid) {
112
- * console.log(result.resolvedVia, result.records);
113
- * }
114
- * ```
115
- */
116
- declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise<MxCheckResult>;
117
- export { Cache as C, InMemoryCache as I, MxCheckOptions as M, InMemoryCacheOptions as a, MxCheckResult as b, MxRecord as c, MxResolution as d, checkMxRecords as e };