@visulima/email 1.0.0-alpha.2 → 1.0.0-alpha.21

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.
Files changed (231) hide show
  1. package/CHANGELOG.md +246 -0
  2. package/LICENSE.md +536 -899
  3. package/README.md +36 -21
  4. package/dist/crypto/index.d.ts +147 -4
  5. package/dist/crypto/index.js +1 -1
  6. package/dist/index.d.ts +785 -9
  7. package/dist/index.js +1 -1
  8. package/dist/packem_shared/{DkimSigner-pFd4c3fZ.js → DkimSigner-CT2DSHD1.js} +4 -4
  9. package/dist/packem_shared/Mail-D93oo_9g.js +1 -0
  10. package/dist/packem_shared/MailMessage-BvaH5tZZ.js +1 -0
  11. package/dist/packem_shared/{SmimeEncrypter-CBevU534.js → SmimeEncrypter-ZhHEgDwY.js} +2 -2
  12. package/dist/packem_shared/{SmimeSigner-CObA4jzT.js → SmimeSigner-CYSVF6ez.js} +1 -1
  13. package/dist/packem_shared/{ahaSendProvider-DlFKEQ6D.js → ahaSendProvider-DOAAW65O.js} +1 -1
  14. package/dist/packem_shared/{attachment-processor-2rHmfa7j.js → attachment-processor-DsmIomKc.js} +1 -1
  15. package/dist/packem_shared/{awsSesProvider-Ba-eVJxZ.js → awsSesProvider-DX1630Ms.js} +7 -7
  16. package/dist/packem_shared/azureProvider-EkNYKAiF.js +1 -0
  17. package/dist/packem_shared/{brevoProvider-5p6jjiK9.js → brevoProvider-CkR4U4RD.js} +1 -1
  18. package/dist/packem_shared/build-mime-message-6xstxaUV.js +2 -0
  19. package/dist/packem_shared/defineProvider-CtLH0VBE.js +1 -0
  20. package/dist/packem_shared/detectMimeType-bo5oxfnt.js +1 -0
  21. package/dist/packem_shared/failoverProvider-W5ctAhdC.js +1 -0
  22. package/dist/packem_shared/httpProvider-DUg1AQfO.js +1 -0
  23. package/dist/packem_shared/{infobipProvider-CtLwrUaP.js → infobipProvider-BhTsWi7e.js} +1 -1
  24. package/dist/packem_shared/{mailCrabProvider-CM_CFDca.js → mailCrabProvider-B7H6HwWu.js} +1 -1
  25. package/dist/packem_shared/mailPaceProvider-DRt6Z9Hr.js +1 -0
  26. package/dist/packem_shared/{mailerSendProvider-CeeIXFnW.js → mailerSendProvider-Dx_iHInH.js} +1 -1
  27. package/dist/packem_shared/mailgunProvider-ChkLGZZW.js +1 -0
  28. package/dist/packem_shared/mailjetProvider-BMRhNe6H.js +1 -0
  29. package/dist/packem_shared/{mailomatProvider-DMQmjKHT.js → mailomatProvider-CydV-JB6.js} +1 -1
  30. package/dist/packem_shared/{mailtrapProvider-BN3UBEQw.js → mailtrapProvider-CuAfJWDr.js} +1 -1
  31. package/dist/packem_shared/{make-request-BDzF9W9D.js → make-request-CaT4d5oC.js} +1 -1
  32. package/dist/packem_shared/{mandrillProvider-370y7CLu.js → mandrillProvider-BBeLbaw0.js} +1 -1
  33. package/dist/packem_shared/mockProvider-C0P1lKOy.js +1 -0
  34. package/dist/packem_shared/{nodemailerProvider-_w8QXMU-.js → nodemailerProvider-DFcvoVFv.js} +1 -1
  35. package/dist/packem_shared/{opentelemetryProvider-C_ZXOLSd.js → opentelemetryProvider-Dwv88G3O.js} +1 -1
  36. package/dist/packem_shared/{plunkProvider-DfJumQ4U.js → plunkProvider-BQyjG6YT.js} +1 -1
  37. package/dist/packem_shared/{postalProvider-Bavx2FcH.js → postalProvider-DPHQ620q.js} +1 -1
  38. package/dist/packem_shared/{postmarkProvider-DFC0uvjO.js → postmarkProvider-bMTC2gdJ.js} +1 -1
  39. package/dist/packem_shared/provider.d-DcfYeGJJ.d.ts +28 -0
  40. package/dist/packem_shared/readFile-BAVMZg5e-C4whBIPd.js +1 -0
  41. package/dist/packem_shared/resendProvider-Cns1tvF5.js +1 -0
  42. package/dist/packem_shared/roundRobinProvider-FvZQKl6n.js +1 -0
  43. package/dist/packem_shared/{scalewayProvider-be1HPimL.js → scalewayProvider-O1dHz7iJ.js} +1 -1
  44. package/dist/packem_shared/{sendGridProvider-BVI1sq3n.js → sendGridProvider-DmywC-eT.js} +1 -1
  45. package/dist/packem_shared/{smtpProvider-BV-ufR53.js → smtpProvider-Unjao_fn.js} +8 -8
  46. package/dist/packem_shared/sweegoProvider-D086G6xG.js +1 -0
  47. package/dist/packem_shared/types.d-CNnnk-Ya.d.ts +102 -0
  48. package/dist/packem_shared/types.d-nyR1ty1Q.d.ts +9 -0
  49. package/dist/packem_shared/types.d-wwpgA3to.d.ts +204 -0
  50. package/dist/packem_shared/validate-email-options-DPo3SgC0.js +1 -0
  51. package/dist/packem_shared/zeptomailProvider-DKKEpEsW.js +1 -0
  52. package/dist/providers/ahasend/index.d.ts +36 -3
  53. package/dist/providers/ahasend/index.js +1 -1
  54. package/dist/providers/aws-ses/index.d.ts +47 -3
  55. package/dist/providers/aws-ses/index.js +1 -1
  56. package/dist/providers/azure/index.d.ts +52 -3
  57. package/dist/providers/azure/index.js +1 -1
  58. package/dist/providers/brevo/index.d.ts +65 -3
  59. package/dist/providers/brevo/index.js +1 -1
  60. package/dist/providers/failover/index.d.ts +27 -3
  61. package/dist/providers/failover/index.js +1 -1
  62. package/dist/providers/http/index.d.ts +35 -3
  63. package/dist/providers/http/index.js +1 -1
  64. package/dist/providers/infobip/index.d.ts +56 -3
  65. package/dist/providers/infobip/index.js +1 -1
  66. package/dist/providers/mailcrab/index.d.ts +32 -3
  67. package/dist/providers/mailcrab/index.js +1 -1
  68. package/dist/providers/mailersend/index.d.ts +51 -3
  69. package/dist/providers/mailersend/index.js +1 -1
  70. package/dist/providers/mailgun/index.d.ts +73 -3
  71. package/dist/providers/mailgun/index.js +1 -1
  72. package/dist/providers/mailjet/index.d.ts +72 -3
  73. package/dist/providers/mailjet/index.js +1 -1
  74. package/dist/providers/mailomat/index.d.ts +40 -3
  75. package/dist/providers/mailomat/index.js +1 -1
  76. package/dist/providers/mailpace/index.d.ts +52 -3
  77. package/dist/providers/mailpace/index.js +1 -1
  78. package/dist/providers/mailtrap/index.d.ts +44 -3
  79. package/dist/providers/mailtrap/index.js +1 -1
  80. package/dist/providers/mandrill/index.d.ts +87 -3
  81. package/dist/providers/mandrill/index.js +1 -1
  82. package/dist/providers/mock/index.d.ts +59 -3
  83. package/dist/providers/mock/index.js +1 -1
  84. package/dist/providers/nodemailer/index.d.ts +38 -3
  85. package/dist/providers/nodemailer/index.js +1 -1
  86. package/dist/providers/opentelemetry/index.d.ts +529 -3
  87. package/dist/providers/opentelemetry/index.js +1 -1
  88. package/dist/providers/plunk/index.d.ts +38 -3
  89. package/dist/providers/plunk/index.js +1 -1
  90. package/dist/providers/postal/index.d.ts +48 -3
  91. package/dist/providers/postal/index.js +1 -1
  92. package/dist/providers/postmark/index.d.ts +60 -3
  93. package/dist/providers/postmark/index.js +1 -1
  94. package/dist/providers/resend/index.d.ts +51 -3
  95. package/dist/providers/resend/index.js +1 -1
  96. package/dist/providers/roundrobin/index.d.ts +27 -3
  97. package/dist/providers/roundrobin/index.js +1 -1
  98. package/dist/providers/scaleway/index.d.ts +44 -3
  99. package/dist/providers/scaleway/index.js +1 -1
  100. package/dist/providers/sendgrid/index.d.ts +84 -3
  101. package/dist/providers/sendgrid/index.js +1 -1
  102. package/dist/providers/smtp/index.d.ts +71 -3
  103. package/dist/providers/smtp/index.js +1 -1
  104. package/dist/providers/sweego/index.d.ts +40 -3
  105. package/dist/providers/sweego/index.js +1 -1
  106. package/dist/providers/zeptomail/index.d.ts +37 -3
  107. package/dist/providers/zeptomail/index.js +1 -1
  108. package/dist/template-engines/handlebars.d.ts +23 -22
  109. package/dist/template-engines/handlebars.js +1 -1
  110. package/dist/template-engines/html-to-text.d.ts +24 -24
  111. package/dist/template-engines/mjml.d.ts +10 -10
  112. package/dist/template-engines/react-email.d.ts +9 -9
  113. package/dist/template-engines/vue-email.d.ts +9 -9
  114. package/dist/utils/cache.d.ts +49 -48
  115. package/dist/utils/format-email-address.d.ts +8 -7
  116. package/dist/utils/normalize-email-aliases.d.ts +20 -20
  117. package/dist/utils/parse-address.d.ts +18 -17
  118. package/dist/utils/parse-address.js +1 -1
  119. package/dist/utils/validation/check-mx-records.d.ts +36 -35
  120. package/dist/utils/validation/disposable-email-domains.d.ts +1 -13
  121. package/dist/utils/validation/role-accounts.d.ts +18 -18
  122. package/dist/utils/validation/validate-email.d.ts +5 -5
  123. package/dist/utils/validation/verify-email.d.ts +45 -42
  124. package/dist/utils/validation/verify-email.js +1 -1
  125. package/dist/utils/validation/verify-smtp.d.ts +35 -34
  126. package/dist/utils/validation/verify-smtp.js +1 -1
  127. package/package.json +61 -61
  128. package/dist/attachment-helpers.d.ts +0 -64
  129. package/dist/crypto/dkim-signer.d.ts +0 -48
  130. package/dist/crypto/smime-encrypter.d.ts +0 -53
  131. package/dist/crypto/smime-signer.d.ts +0 -48
  132. package/dist/crypto/types.d.ts +0 -101
  133. package/dist/draft-mail-message.d.ts +0 -13
  134. package/dist/errors/email-error.d.ts +0 -17
  135. package/dist/errors/required-option-error.d.ts +0 -10
  136. package/dist/mail-message.d.ts +0 -425
  137. package/dist/mail.d.ts +0 -206
  138. package/dist/packem_shared/Mail-6Bltpy_p.js +0 -1
  139. package/dist/packem_shared/MailMessage-B76GPBBA.js +0 -1
  140. package/dist/packem_shared/azureProvider-CQYAkgVF.js +0 -1
  141. package/dist/packem_shared/build-mime-message-IYaUqqPJ.js +0 -2
  142. package/dist/packem_shared/defineProvider-B9rSklAJ.js +0 -1
  143. package/dist/packem_shared/detectMimeType-S8WRsNtY.js +0 -1
  144. package/dist/packem_shared/failoverProvider-CAHQQueo.js +0 -1
  145. package/dist/packem_shared/httpProvider-CZD6LZX3.js +0 -1
  146. package/dist/packem_shared/mailPaceProvider-B6yKvh6z.js +0 -1
  147. package/dist/packem_shared/mailgunProvider-mmjKzouh.js +0 -1
  148. package/dist/packem_shared/mailjetProvider-DwN6i0VA.js +0 -1
  149. package/dist/packem_shared/mockProvider-DN5ZwutD.js +0 -1
  150. package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +0 -1
  151. package/dist/packem_shared/resendProvider-CfqU7UdE.js +0 -1
  152. package/dist/packem_shared/roundRobinProvider-1WQnuKR8.js +0 -1
  153. package/dist/packem_shared/sweegoProvider-7419CSAq.js +0 -1
  154. package/dist/packem_shared/validate-email-options-DfJ7llf8.js +0 -1
  155. package/dist/packem_shared/zeptomailProvider-C2lh0Xmo.js +0 -1
  156. package/dist/providers/ahasend/provider.d.ts +0 -7
  157. package/dist/providers/ahasend/types.d.ts +0 -28
  158. package/dist/providers/aws-ses/provider.d.ts +0 -8
  159. package/dist/providers/aws-ses/types.d.ts +0 -38
  160. package/dist/providers/azure/provider.d.ts +0 -7
  161. package/dist/providers/azure/types.d.ts +0 -44
  162. package/dist/providers/brevo/provider.d.ts +0 -7
  163. package/dist/providers/brevo/types.d.ts +0 -57
  164. package/dist/providers/failover/provider.d.ts +0 -7
  165. package/dist/providers/failover/types.d.ts +0 -19
  166. package/dist/providers/http/provider.d.ts +0 -7
  167. package/dist/providers/http/types.d.ts +0 -27
  168. package/dist/providers/infobip/provider.d.ts +0 -7
  169. package/dist/providers/infobip/types.d.ts +0 -48
  170. package/dist/providers/mailcrab/provider.d.ts +0 -9
  171. package/dist/providers/mailcrab/types.d.ts +0 -22
  172. package/dist/providers/mailersend/provider.d.ts +0 -7
  173. package/dist/providers/mailersend/types.d.ts +0 -43
  174. package/dist/providers/mailgun/provider.d.ts +0 -7
  175. package/dist/providers/mailgun/types.d.ts +0 -65
  176. package/dist/providers/mailjet/provider.d.ts +0 -7
  177. package/dist/providers/mailjet/types.d.ts +0 -64
  178. package/dist/providers/mailomat/provider.d.ts +0 -7
  179. package/dist/providers/mailomat/types.d.ts +0 -32
  180. package/dist/providers/mailpace/provider.d.ts +0 -7
  181. package/dist/providers/mailpace/types.d.ts +0 -44
  182. package/dist/providers/mailtrap/provider.d.ts +0 -7
  183. package/dist/providers/mailtrap/types.d.ts +0 -36
  184. package/dist/providers/mandrill/provider.d.ts +0 -7
  185. package/dist/providers/mandrill/types.d.ts +0 -79
  186. package/dist/providers/mock/provider.d.ts +0 -8
  187. package/dist/providers/mock/types.d.ts +0 -50
  188. package/dist/providers/nodemailer/provider.d.ts +0 -7
  189. package/dist/providers/nodemailer/types.d.ts +0 -30
  190. package/dist/providers/opentelemetry/provider.d.ts +0 -8
  191. package/dist/providers/opentelemetry/types.d.ts +0 -31
  192. package/dist/providers/plunk/provider.d.ts +0 -7
  193. package/dist/providers/plunk/types.d.ts +0 -30
  194. package/dist/providers/postal/provider.d.ts +0 -7
  195. package/dist/providers/postal/types.d.ts +0 -40
  196. package/dist/providers/postmark/provider.d.ts +0 -7
  197. package/dist/providers/postmark/types.d.ts +0 -52
  198. package/dist/providers/provider.d.ts +0 -27
  199. package/dist/providers/resend/provider.d.ts +0 -7
  200. package/dist/providers/resend/types.d.ts +0 -43
  201. package/dist/providers/roundrobin/provider.d.ts +0 -7
  202. package/dist/providers/roundrobin/types.d.ts +0 -19
  203. package/dist/providers/scaleway/provider.d.ts +0 -7
  204. package/dist/providers/scaleway/types.d.ts +0 -36
  205. package/dist/providers/sendgrid/provider.d.ts +0 -7
  206. package/dist/providers/sendgrid/types.d.ts +0 -76
  207. package/dist/providers/smtp/provider.d.ts +0 -7
  208. package/dist/providers/smtp/types.d.ts +0 -63
  209. package/dist/providers/sweego/provider.d.ts +0 -7
  210. package/dist/providers/sweego/types.d.ts +0 -32
  211. package/dist/providers/utils/address-formatter.d.ts +0 -139
  212. package/dist/providers/utils/attachment-processor.d.ts +0 -58
  213. package/dist/providers/utils/index.d.ts +0 -4
  214. package/dist/providers/utils/payload-builder.d.ts +0 -78
  215. package/dist/providers/utils/provider-base.d.ts +0 -69
  216. package/dist/providers/zeptomail/provider.d.ts +0 -7
  217. package/dist/providers/zeptomail/types.d.ts +0 -29
  218. package/dist/template-engines/types.d.ts +0 -8
  219. package/dist/types.d.ts +0 -203
  220. package/dist/utils/build-mime-message.d.ts +0 -8
  221. package/dist/utils/create-logger.d.ts +0 -16
  222. package/dist/utils/format-email-addresses.d.ts +0 -8
  223. package/dist/utils/generate-boundary.d.ts +0 -7
  224. package/dist/utils/generate-message-id.d.ts +0 -6
  225. package/dist/utils/headers-to-record.d.ts +0 -9
  226. package/dist/utils/is-port-available.d.ts +0 -9
  227. package/dist/utils/make-request.d.ts +0 -18
  228. package/dist/utils/retry.d.ts +0 -10
  229. package/dist/utils/sanitize-header.d.ts +0 -14
  230. package/dist/utils/to-base64.d.ts +0 -8
  231. package/dist/utils/validation/validate-email-options.d.ts +0 -8
@@ -1,54 +1,55 @@
1
1
  /**
2
- * Generic cache interface for caching any type of data.
3
- * Implementations can use in-memory cache, LRU cache, Redis, etc.
4
- */
5
- export 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>;
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
28
  }
29
29
  /**
30
- * Options for creating an in-memory cache.
31
- */
32
- export 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;
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
43
  }
44
44
  /**
45
- * Default in-memory cache implementation using LRU cache.
46
- */
47
- export declare class InMemoryCache<T extends object = Record<string, unknown>> implements Cache<T> {
48
- private readonly cache;
49
- constructor(options?: InMemoryCacheOptions);
50
- clear: () => Promise<void>;
51
- delete: (key: string) => Promise<void>;
52
- get: (key: string) => Promise<T | undefined>;
53
- set: (key: string, value: T, ttl: number) => Promise<void>;
45
+ * Default in-memory cache implementation using LRU cache.
46
+ */
47
+ declare class InMemoryCache<T extends object = Record<string, unknown>> implements Cache<T> {
48
+ private readonly cache;
49
+ constructor(options?: InMemoryCacheOptions);
50
+ clear: () => Promise<void>;
51
+ delete: (key: string) => Promise<void>;
52
+ get: (key: string) => Promise<T | undefined>;
53
+ set: (key: string, value: T, ttl: number) => Promise<void>;
54
54
  }
55
+ export { Cache, InMemoryCache, InMemoryCacheOptions };
@@ -1,9 +1,10 @@
1
- import type { EmailAddress } from "../types.d.ts";
1
+ import { b as EmailAddress } from "../packem_shared/types.d-wwpgA3to.js";
2
+ import 'node:buffer';
2
3
  /**
3
- * Formats an email address as "Name &lt;email@example.com>" or just "email@example.com" if no name is provided.
4
- * @param address The email address object to format.
5
- * @returns The formatted email address string in RFC 5322 format.
6
- * @throws {EmailError} When the email address is invalid.
7
- */
4
+ * Formats an email address as "Name &lt;email@example.com>" or just "email@example.com" if no name is provided.
5
+ * @param address The email address object to format.
6
+ * @returns The formatted email address string in RFC 5322 format.
7
+ * @throws {EmailError} When the email address is invalid.
8
+ */
8
9
  declare const formatEmailAddress: (address: EmailAddress) => string;
9
- export default formatEmailAddress;
10
+ export { formatEmailAddress as default };
@@ -1,22 +1,22 @@
1
1
  /**
2
- * Normalizes email aliases for supported email providers.
3
- * For example: example@gmail.com and example+another@gmail.com point to the same email address.
4
- * This function normalizes aliases to their canonical form.
5
- *
6
- * Supported providers:
7
- * - Gmail: Removes dots and plus aliases (example+test@gmail.com → example@gmail.com)
8
- * - Yahoo, Outlook, Hotmail, Live, MSN, iCloud, ProtonMail, Zoho, FastMail, Mail.com, GMX: Removes plus aliases only
9
- * @param email The email address to normalize.
10
- * @returns The normalized email address, or the original email if not supported or invalid.
11
- * @example
12
- * ```ts
13
- * import { normalizeEmailAliases } from "@visulima/email/utils/normalize-email-aliases";
14
- *
15
- * normalizeEmailAliases("example+test@gmail.com"); // "example@gmail.com"
16
- * normalizeEmailAliases("ex.ample@gmail.com"); // "example@gmail.com"
17
- * normalizeEmailAliases("user+tag@yahoo.com"); // "user@yahoo.com"
18
- * normalizeEmailAliases("user@example.com"); // "user@example.com" (unchanged)
19
- * ```
20
- */
2
+ * Normalizes email aliases for supported email providers.
3
+ * For example: example@gmail.com and example+another@gmail.com point to the same email address.
4
+ * This function normalizes aliases to their canonical form.
5
+ *
6
+ * Supported providers:
7
+ * - Gmail: Removes dots and plus aliases (example+test@gmail.com → example@gmail.com)
8
+ * - Yahoo, Outlook, Hotmail, Live, MSN, iCloud, ProtonMail, Zoho, FastMail, Mail.com, GMX: Removes plus aliases only
9
+ * @param email The email address to normalize.
10
+ * @returns The normalized email address, or the original email if not supported or invalid.
11
+ * @example
12
+ * ```ts
13
+ * import { normalizeEmailAliases } from "@visulima/email/utils/normalize-email-aliases";
14
+ *
15
+ * normalizeEmailAliases("example+test@gmail.com"); // "example@gmail.com"
16
+ * normalizeEmailAliases("ex.ample@gmail.com"); // "example@gmail.com"
17
+ * normalizeEmailAliases("user+tag@yahoo.com"); // "user@yahoo.com"
18
+ * normalizeEmailAliases("user@example.com"); // "user@example.com" (unchanged)
19
+ * ```
20
+ */
21
21
  declare const normalizeEmailAliases: (email: string) => string;
22
- export default normalizeEmailAliases;
22
+ export { normalizeEmailAliases as default };
@@ -1,19 +1,20 @@
1
- import type { EmailAddress } from "../types.d.ts";
1
+ import { b as EmailAddress } from "../packem_shared/types.d-wwpgA3to.js";
2
+ import 'node:buffer';
2
3
  /**
3
- * Parses a string representation of an email address into an EmailAddress object.
4
- * Supports formats: "email@example.com", "Name &lt;email@example.com>", "&lt;email@example.com>".
5
- * @example Parsing an address with a name
6
- * ```ts
7
- * const address = parseAddress("John Doe <john@example.com>");
8
- * // { name: "John Doe", email: "john@example.com" }
9
- * ```
10
- * @example Parsing an address without a name
11
- * ```ts
12
- * const address = parseAddress("jane@example.com");
13
- * // { email: "jane@example.com" }
14
- * ```
15
- * @param address The string representation of the address to parse.
16
- * @returns An EmailAddress object if parsing is successful, or undefined if invalid.
17
- */
4
+ * Parses a string representation of an email address into an EmailAddress object.
5
+ * Supports formats: "email@example.com", "Name &lt;email@example.com>", "&lt;email@example.com>".
6
+ * @example Parsing an address with a name
7
+ * ```ts
8
+ * const address = parseAddress("John Doe <john@example.com>");
9
+ * // { name: "John Doe", email: "john@example.com" }
10
+ * ```
11
+ * @example Parsing an address without a name
12
+ * ```ts
13
+ * const address = parseAddress("jane@example.com");
14
+ * // { email: "jane@example.com" }
15
+ * ```
16
+ * @param address The string representation of the address to parse.
17
+ * @returns An EmailAddress object if parsing is successful, or undefined if invalid.
18
+ */
18
19
  declare const parseAddress: (address: string) => EmailAddress | undefined;
19
- export default parseAddress;
20
+ export { parseAddress as default };
@@ -1 +1 @@
1
- var m=Object.defineProperty;var o=(t,e)=>m(t,"name",{value:e,configurable:!0});import d from"./validation/validate-email.js";var h=Object.defineProperty,c=o((t,e)=>h(t,"name",{value:e,configurable:!0}),"l");const g=c(t=>{const e=t.replace(/^"(.+)"$/,"$1");return!(!e||e.length===0||e.includes("..")||e.startsWith(".")||e.endsWith("."))},"isValidLocalPart"),a=c(t=>{const e=t.indexOf("@[");if(e>0&&t.endsWith("]")){const n=t.length-1,l=t.slice(e+2,n);if(l.includes("@["))return!1;const i=t.slice(0,e),s=l;return!s||s.trim().length===0||s.includes("]")?!1:i?g(i):!1}if(t.includes("@[")&&!t.includes("]"))return!1;const r=t.match(/^"((?:[^"\\]|\\.)+)"@(.+)$/);if(r&&r[2]){const n=r[2];return n.startsWith("[")?!1:d(`test@${n}`)}return d(t)},"isValidEmailFormat"),$=c(t=>{if(!t||typeof t!="string")return;const e=t.trim();if(!e)return;const r=e.lastIndexOf("<"),n=e.lastIndexOf(">");if(r!==-1&&n>r){const i=e.slice(0,r).trim(),s=e.slice(r+1,n).trim();if(s&&a(s)){if(i){const f=i.replace(/^"(.+)"$/,"$1");return{email:s,name:f}}return{email:s}}}const l=e.match(/^<([^>]+)>$/);if(l&&l[1]){const i=l[1].trim();return a(i)?{email:i}:void 0}if(!(e.includes("]")&&!e.includes("@["))&&!(e.includes('"')&&!e.startsWith('"')&&e.indexOf('"')<e.indexOf("@"))){if(e.startsWith('"')){let i=1,s=!1;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length)i+=2;else if(e[i]==='"'){if(i+1<e.length&&e[i+1]==="@"){s=!0;break}i+=1}else i+=1;if(!s&&e.includes("@")){const f=e.indexOf("@"),u=e.slice(1).indexOf('"');if(u===-1||f<u+1)return}}if(a(e))return{email:e}}},"parseAddress");export{$ as default};
1
+ var m=Object.defineProperty;var o=(t,e)=>m(t,"name",{value:e,configurable:!0});import d from"./validation/validate-email.js";var h=Object.defineProperty,c=o((t,e)=>h(t,"name",{value:e,configurable:!0}),"l");const g=c(t=>{const e=t.replace(/^"(.+)"$/,"$1");return!(!e||e.length===0||e.includes("..")||e.startsWith(".")||e.endsWith("."))},"isValidLocalPart"),a=c(t=>{const e=t.indexOf("@[");if(e>0&&t.endsWith("]")){const n=t.length-1,l=t.slice(e+2,n);if(l.includes("@["))return!1;const i=t.slice(0,e),s=l;return!s||s.trim().length===0||s.includes("]")?!1:i?g(i):!1}if(t.includes("@[")&&!t.includes("]"))return!1;const r=t.match(/^"((?:[^"\\]|\\.)+)"@(.+)$/);if(r?.[2]){const n=r[2];return n.startsWith("[")?!1:d(`test@${n}`)}return d(t)},"isValidEmailFormat"),$=c(t=>{if(!t||typeof t!="string")return;const e=t.trim();if(!e)return;const r=e.lastIndexOf("<"),n=e.lastIndexOf(">");if(r!==-1&&n>r){const i=e.slice(0,r).trim(),s=e.slice(r+1,n).trim();if(s&&a(s)){if(i){const f=i.replace(/^"(.+)"$/,"$1");return{email:s,name:f}}return{email:s}}}const l=e.match(/^<([^>]+)>$/);if(l?.[1]){const i=l[1].trim();return a(i)?{email:i}:void 0}if(!(e.includes("]")&&!e.includes("@["))&&!(e.includes('"')&&!e.startsWith('"')&&e.indexOf('"')<e.indexOf("@"))){if(e.startsWith('"')){let i=1,s=!1;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length)i+=2;else if(e[i]==='"'){if(i+1<e.length&&e[i+1]==="@"){s=!0;break}i+=1}else i+=1;if(!s&&e.includes("@")){const f=e.indexOf("@"),u=e.slice(1).indexOf('"');if(u===-1||f<u+1)return}}if(a(e))return{email:e}}},"parseAddress");export{$ as default};
@@ -1,42 +1,43 @@
1
- import type { Cache } from "../cache.d.ts";
2
- export type { Cache, InMemoryCache } from "../cache.d.ts";
1
+ import { Cache } from "../cache.js";
2
+ export { type InMemoryCache } from "../cache.js";
3
3
  /**
4
- * MX record information.
5
- */
6
- export interface MxRecord {
7
- exchange: string;
8
- priority: number;
4
+ * MX record information.
5
+ */
6
+ interface MxRecord {
7
+ exchange: string;
8
+ priority: number;
9
9
  }
10
10
  /**
11
- * Result of MX record check.
12
- */
13
- export interface MxCheckResult {
14
- error?: string;
15
- records?: MxRecord[];
16
- valid: boolean;
11
+ * Result of MX record check.
12
+ */
13
+ interface MxCheckResult {
14
+ error?: string;
15
+ records?: MxRecord[];
16
+ valid: boolean;
17
17
  }
18
18
  /**
19
- * Options for MX record checking.
20
- */
21
- export interface MxCheckOptions {
22
- cache?: Cache<MxCheckResult>;
23
- ttl?: number;
19
+ * Options for MX record checking.
20
+ */
21
+ interface MxCheckOptions {
22
+ cache?: Cache<MxCheckResult>;
23
+ ttl?: number;
24
24
  }
25
25
  /**
26
- * Checks MX records for a domain.
27
- * @param domain The domain to check MX records for.
28
- * @param options Options for MX record checking, including caching.
29
- * @returns Result containing MX records or error.
30
- * @example
31
- * ```ts
32
- * import { checkMxRecords } from "@visulima/email/validation/check-mx-records";
33
- * import { InMemoryCache } from "@visulima/email/utils/cache";
34
- *
35
- * const cache = new InMemoryCache();
36
- * const result = await checkMxRecords("example.com", { cache });
37
- * if (result.valid) {
38
- * console.log("MX records:", result.records);
39
- * }
40
- * ```
41
- */
42
- export declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise<MxCheckResult>;
26
+ * Checks MX records for a domain.
27
+ * @param domain The domain to check MX records for.
28
+ * @param options Options for MX record checking, including caching.
29
+ * @returns Result containing MX records or error.
30
+ * @example
31
+ * ```ts
32
+ * import { checkMxRecords } from "@visulima/email/validation/check-mx-records";
33
+ * import { InMemoryCache } from "@visulima/email/utils/cache";
34
+ *
35
+ * const cache = new InMemoryCache();
36
+ * const result = await checkMxRecords("example.com", { cache });
37
+ * if (result.valid) {
38
+ * console.log("MX records:", result.records);
39
+ * }
40
+ * ```
41
+ */
42
+ declare const checkMxRecords: (domain: string, options?: MxCheckOptions) => Promise<MxCheckResult>;
43
+ export { type Cache, MxCheckOptions, MxCheckResult, MxRecord, checkMxRecords };
@@ -1,13 +1 @@
1
- /**
2
- * Re-exports all functionality from @visulima/disposable-email-domains.
3
- * This provides access to disposable email domain checking utilities.
4
- * @example
5
- * ```ts
6
- * import { isDisposableEmail, isDisposableDomain, getDomainList } from "\@visulima/email/validation/disposable-email-domains";
7
- *
8
- * if (isDisposableEmail("user@mailinator.com")) {
9
- * console.log("Disposable email detected!");
10
- * }
11
- * ```
12
- */
13
- export * from "@visulima/disposable-email-domains";
1
+ export * from '@visulima/disposable-email-domains';
@@ -1,21 +1,21 @@
1
1
  /**
2
- * Common role account prefixes that indicate non-personal email addresses.
3
- * Includes RFC 2142 standard role accounts and common business/operational prefixes.
4
- */
2
+ * Common role account prefixes that indicate non-personal email addresses.
3
+ * Includes RFC 2142 standard role accounts and common business/operational prefixes.
4
+ */
5
5
  declare const ROLE_ACCOUNT_PREFIXES: Set<string>;
6
6
  /**
7
- * Checks if an email address is a role account (non-personal).
8
- * @param email The email address to check.
9
- * @param customPrefixes Optional set of additional role account prefixes.
10
- * @returns True if the email is a role account, false otherwise.
11
- * @example
12
- * ```ts
13
- * import { isRoleAccount } from "@visulima/email/validation/role-accounts";
14
- *
15
- * if (isRoleAccount("noreply@example.com")) {
16
- * console.log("This is a role account");
17
- * }
18
- * ```
19
- */
20
- export declare const isRoleAccount: (email: string, customPrefixes?: Set<string>) => boolean;
21
- export { ROLE_ACCOUNT_PREFIXES };
7
+ * Checks if an email address is a role account (non-personal).
8
+ * @param email The email address to check.
9
+ * @param customPrefixes Optional set of additional role account prefixes.
10
+ * @returns True if the email is a role account, false otherwise.
11
+ * @example
12
+ * ```ts
13
+ * import { isRoleAccount } from "@visulima/email/validation/role-accounts";
14
+ *
15
+ * if (isRoleAccount("noreply@example.com")) {
16
+ * console.log("This is a role account");
17
+ * }
18
+ * ```
19
+ */
20
+ declare const isRoleAccount: (email: string, customPrefixes?: Set<string>) => boolean;
21
+ export { ROLE_ACCOUNT_PREFIXES, isRoleAccount };
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Validates an email address format according to basic RFC standards.
3
- * @param email The email address string to validate.
4
- * @returns True if the email address is valid, false otherwise.
5
- */
2
+ * Validates an email address format according to basic RFC standards.
3
+ * @param email The email address string to validate.
4
+ * @returns True if the email address is valid, false otherwise.
5
+ */
6
6
  declare const validateEmail: (email: string) => boolean;
7
- export default validateEmail;
7
+ export { validateEmail as default };
@@ -1,47 +1,50 @@
1
- import type { SmtpVerificationOptions } from "./verify-smtp.d.ts";
1
+ import { SmtpVerificationOptions } from "./verify-smtp.js";
2
+ import "../cache.js";
3
+ import "./check-mx-records.js";
2
4
  /**
3
- * Options for comprehensive email verification.
4
- */
5
- export interface EmailVerificationOptions extends SmtpVerificationOptions {
6
- checkDisposable?: boolean;
7
- checkMx?: boolean;
8
- checkRoleAccount?: boolean;
9
- checkSmtp?: boolean;
10
- customDisposableDomains?: Set<string>;
11
- customRolePrefixes?: Set<string>;
5
+ * Options for comprehensive email verification.
6
+ */
7
+ interface EmailVerificationOptions extends SmtpVerificationOptions {
8
+ checkDisposable?: boolean;
9
+ checkMx?: boolean;
10
+ checkRoleAccount?: boolean;
11
+ checkSmtp?: boolean;
12
+ customDisposableDomains?: Set<string>;
13
+ customRolePrefixes?: Set<string>;
12
14
  }
13
15
  /**
14
- * Result of comprehensive email verification.
15
- */
16
- export interface EmailVerificationResult {
17
- disposable?: boolean;
18
- errors: string[];
19
- formatValid: boolean;
20
- mxValid?: boolean;
21
- roleAccount?: boolean;
22
- smtpValid?: boolean;
23
- valid: boolean;
24
- warnings: string[];
16
+ * Result of comprehensive email verification.
17
+ */
18
+ interface EmailVerificationResult {
19
+ disposable?: boolean;
20
+ errors: string[];
21
+ formatValid: boolean;
22
+ mxValid?: boolean;
23
+ roleAccount?: boolean;
24
+ smtpValid?: boolean;
25
+ valid: boolean;
26
+ warnings: string[];
25
27
  }
26
28
  /**
27
- * Comprehensive email verification combining multiple checks.
28
- * @param email The email address to verify.
29
- * @param options Verification options.
30
- * @returns Detailed verification result.
31
- * @example
32
- * ```ts
33
- * import { verifyEmail } from "@visulima/email/validation/verify-email";
34
- *
35
- * const result = await verifyEmail("user@example.com", {
36
- * checkDisposable: true,
37
- * checkRoleAccount: true,
38
- * checkMx: true,
39
- * checkSmtp: false
40
- * });
41
- *
42
- * if (result.valid) {
43
- * console.log("Email is valid!");
44
- * }
45
- * ```
46
- */
47
- export declare const verifyEmail: (email: string, options?: EmailVerificationOptions) => Promise<EmailVerificationResult>;
29
+ * Comprehensive email verification combining multiple checks.
30
+ * @param email The email address to verify.
31
+ * @param options Verification options.
32
+ * @returns Detailed verification result.
33
+ * @example
34
+ * ```ts
35
+ * import { verifyEmail } from "@visulima/email/validation/verify-email";
36
+ *
37
+ * const result = await verifyEmail("user@example.com", {
38
+ * checkDisposable: true,
39
+ * checkRoleAccount: true,
40
+ * checkMx: true,
41
+ * checkSmtp: false
42
+ * });
43
+ *
44
+ * if (result.valid) {
45
+ * console.log("Email is valid!");
46
+ * }
47
+ * ```
48
+ */
49
+ declare const verifyEmail: (email: string, options?: EmailVerificationOptions) => Promise<EmailVerificationResult>;
50
+ export { EmailVerificationOptions, EmailVerificationResult, verifyEmail };
@@ -1 +1 @@
1
- var V=Object.defineProperty;var f=(e,r)=>V(e,"name",{value:r,configurable:!0});import{checkMxRecords as y}from"./check-mx-records.js";import{isRoleAccount as k}from"./role-accounts.js";import w from"./validate-email.js";import{verifySmtp as E}from"./verify-smtp.js";import{isDisposableEmail as A}from"@visulima/disposable-email-domains";var D=Object.defineProperty,M=f((e,r)=>D(e,"name",{value:r,configurable:!0}),"f");const N=M(async(e,r={})=>{const{checkDisposable:p=!0,checkMx:d=!0,checkRoleAccount:u=!0,checkSmtp:h=!1,customDisposableDomains:v,customRolePrefixes:b,...g}=r,c=w(e),a=[],i=[];if(!c)return a.push("Invalid email format"),{errors:a,formatValid:!1,valid:!1,warnings:i};let s,l,m,n;if(p)try{s=A(e,v),s&&i.push("Email is from a disposable email service")}catch{}if(u&&(l=k(e,b),l&&i.push("Email appears to be a role account (non-personal)")),d){const o=e.split("@")[1];if(!o)return a.push("Invalid email format: missing domain"),{disposable:s,errors:a,formatValid:!1,mxValid:!1,roleAccount:l,valid:!1,warnings:i};const t=await y(o,{cache:r.cache});m=t.valid,t.valid||a.push(t.error||"No valid MX records found")}if(h){const o=await E(e,{...g,cache:r.cache,smtpCache:r.smtpCache});n=o.valid,!o.valid&&o.error&&a.push(`SMTP verification failed: ${o.error}`)}const x=c&&a.length===0;return{disposable:s,errors:a,formatValid:c,mxValid:m,roleAccount:l,smtpValid:n,valid:x,warnings:i}},"verifyEmail");export{N as verifyEmail};
1
+ var V=Object.defineProperty;var f=(e,r)=>V(e,"name",{value:r,configurable:!0});import{checkMxRecords as y}from"./check-mx-records.js";import{isRoleAccount as k}from"./role-accounts.js";import w from"./validate-email.js";import{verifySmtp as E}from"./verify-smtp.js";import{isDisposableEmail as A}from"@visulima/disposable-email-domains";var D=Object.defineProperty,M=f((e,r)=>D(e,"name",{value:r,configurable:!0}),"f");const N=M(async(e,r={})=>{const{checkDisposable:p=!0,checkMx:d=!0,checkRoleAccount:u=!0,checkSmtp:h=!1,customDisposableDomains:v,customRolePrefixes:b,...g}=r,c=w(e),a=[],i=[];if(!c)return a.push("Invalid email format"),{errors:a,formatValid:!1,valid:!1,warnings:i};let s,l,m,n;if(p)try{s=A(e,v),s&&i.push("Email is from a disposable email service")}catch{}if(u&&(l=k(e,b),l&&i.push("Email appears to be a role account (non-personal)")),d){const o=e.split("@")[1];if(!o)return a.push("Invalid email format: missing domain"),{disposable:s,errors:a,formatValid:!1,mxValid:!1,roleAccount:l,valid:!1,warnings:i};const t=await y(o,{cache:r.cache});m=t.valid,t.valid||a.push(t.error??"No valid MX records found")}if(h){const o=await E(e,{...g,cache:r.cache,smtpCache:r.smtpCache});n=o.valid,!o.valid&&o.error&&a.push(`SMTP verification failed: ${o.error}`)}const x=c&&a.length===0;return{disposable:s,errors:a,formatValid:c,mxValid:m,roleAccount:l,smtpValid:n,valid:x,warnings:i}},"verifyEmail");export{N as verifyEmail};
@@ -1,39 +1,40 @@
1
- import type { Cache } from "../cache.d.ts";
2
- import type { MxCheckResult, MxRecord } from "./check-mx-records.d.ts";
1
+ import { Cache } from "../cache.js";
2
+ import { MxCheckResult, MxRecord } from "./check-mx-records.js";
3
3
  /**
4
- * Options for SMTP verification.
5
- */
6
- export interface SmtpVerificationOptions {
7
- cache?: Cache<MxCheckResult>;
8
- fromEmail?: string;
9
- port?: number;
10
- smtpCache?: Cache<SmtpVerificationResult>;
11
- timeout?: number;
12
- ttl?: number;
4
+ * Options for SMTP verification.
5
+ */
6
+ interface SmtpVerificationOptions {
7
+ cache?: Cache<MxCheckResult>;
8
+ fromEmail?: string;
9
+ port?: number;
10
+ smtpCache?: Cache<SmtpVerificationResult>;
11
+ timeout?: number;
12
+ ttl?: number;
13
13
  }
14
14
  /**
15
- * Detailed result of SMTP verification attempt.
16
- */
17
- export interface SmtpVerificationResult {
18
- error?: string;
19
- mxRecords?: MxRecord[];
20
- smtpResponse?: string;
21
- valid: boolean;
15
+ * Detailed result of SMTP verification attempt.
16
+ */
17
+ interface SmtpVerificationResult {
18
+ error?: string;
19
+ mxRecords?: MxRecord[];
20
+ smtpResponse?: string;
21
+ valid: boolean;
22
22
  }
23
23
  /**
24
- * Verifies an email address by checking MX records and attempting SMTP verification.
25
- * Note: Many mail servers block SMTP verification to prevent email harvesting.
26
- * @param email The email address to verify.
27
- * @param options Verification options.
28
- * @returns Result containing verification status.
29
- * @example
30
- * ```ts
31
- * import { verifySmtp } from "@visulima/email/validation/verify-smtp";
32
- *
33
- * const result = await verifySmtp("user@example.com", {
34
- * timeout: 5000,
35
- * fromEmail: "test@example.com"
36
- * });
37
- * ```
38
- */
39
- export declare const verifySmtp: (email: string, options?: SmtpVerificationOptions) => Promise<SmtpVerificationResult>;
24
+ * Verifies an email address by checking MX records and attempting SMTP verification.
25
+ * Note: Many mail servers block SMTP verification to prevent email harvesting.
26
+ * @param email The email address to verify.
27
+ * @param options Verification options.
28
+ * @returns Result containing verification status.
29
+ * @example
30
+ * ```ts
31
+ * import { verifySmtp } from "@visulima/email/validation/verify-smtp";
32
+ *
33
+ * const result = await verifySmtp("user@example.com", {
34
+ * timeout: 5000,
35
+ * fromEmail: "test@example.com"
36
+ * });
37
+ * ```
38
+ */
39
+ declare const verifySmtp: (email: string, options?: SmtpVerificationOptions) => Promise<SmtpVerificationResult>;
40
+ export { SmtpVerificationOptions, SmtpVerificationResult, verifySmtp };
@@ -1,4 +1,4 @@
1
- var j=Object.defineProperty;var R=(t,e)=>j(t,"name",{value:e,configurable:!0});import{createRequire as S}from"node:module";import{checkMxRecords as C}from"./check-mx-records.js";const $=S(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=R(t=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[e,d]=u.versions.node.split(".").map(Number);if(e>22||e===22&&d>=3||e===20&&d>=16)return u.getBuiltinModule(t)}return $(t)},"__cjs_getBuiltinModule"),{Socket:P}=O("node:net");var E=Object.defineProperty,p=R((t,e)=>E(t,"name",{value:e,configurable:!0}),"n");const A=p(async(t,e={})=>{const{fromEmail:d="test@example.com",port:x=25,timeout:M=5e3,ttl:_=36e5}=e;if(!t||typeof t!="string")return{error:"Invalid email address",valid:!1};const l=t.toLowerCase().trim(),h=l.indexOf("@");if(h===-1||h===l.length-1)return{error:"Invalid email format",valid:!1};const{smtpCache:c}=e,g=`smtp:${l}:${d}:${x}`;if(c){const n=await c.get(g);if(n!==void 0)return n}const w=l.slice(h+1),W=e.cache,r=await C(w,{cache:W});if(!r.valid||!r.records||r.records.length===0){const n={error:r.error||"No MX records found",mxRecords:r.records,valid:!1};return c&&await c.set(g,n,_),n}const y=r.records[0];return new Promise(n=>{const o=new P;let v="",s="connected";const m=p(()=>{o.removeAllListeners(),o.destroy()},"cleanup"),f=p(a=>{c&&c.set(g,a,_).catch(()=>{}),n(a)},"cacheAndResolve"),T=p(a=>{m(),f({error:a.message,mxRecords:r.records,valid:!1})},"onError"),b=p(()=>{m(),f({error:"SMTP connection timeout",mxRecords:r.records,valid:!1})},"onTimeout");o.setTimeout(M),o.on("error",T),o.on("timeout",b),o.on("data",a=>{v+=a.toString();const i=v.slice(-3);s==="connected"&&(i.startsWith("220")||i.startsWith("250"))?(s="helo",o.write(`HELO ${w}\r
1
+ var j=Object.defineProperty;var R=(t,e)=>j(t,"name",{value:e,configurable:!0});import{createRequire as S}from"node:module";import{checkMxRecords as C}from"./check-mx-records.js";const $=S(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=R(t=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[e,d]=u.versions.node.split(".").map(Number);if(e>22||e===22&&d>=3||e===20&&d>=16)return u.getBuiltinModule(t)}return $(t)},"__cjs_getBuiltinModule"),{Socket:P}=O("node:net");var E=Object.defineProperty,p=R((t,e)=>E(t,"name",{value:e,configurable:!0}),"n");const A=p(async(t,e={})=>{const{fromEmail:d="test@example.com",port:x=25,timeout:M=5e3,ttl:_=36e5}=e;if(!t||typeof t!="string")return{error:"Invalid email address",valid:!1};const l=t.toLowerCase().trim(),h=l.indexOf("@");if(h===-1||h===l.length-1)return{error:"Invalid email format",valid:!1};const{smtpCache:c}=e,g=`smtp:${l}:${d}:${x}`;if(c){const n=await c.get(g);if(n!==void 0)return n}const w=l.slice(h+1),W=e.cache,r=await C(w,{cache:W});if(!r.valid||!r.records||r.records.length===0){const n={error:r.error??"No MX records found",mxRecords:r.records,valid:!1};return c&&await c.set(g,n,_),n}const y=r.records[0];return new Promise(n=>{const o=new P;let v="",s="connected";const m=p(()=>{o.removeAllListeners(),o.destroy()},"cleanup"),f=p(a=>{c&&c.set(g,a,_).catch(()=>{}),n(a)},"cacheAndResolve"),T=p(a=>{m(),f({error:a.message,mxRecords:r.records,valid:!1})},"onError"),b=p(()=>{m(),f({error:"SMTP connection timeout",mxRecords:r.records,valid:!1})},"onTimeout");o.setTimeout(M),o.on("error",T),o.on("timeout",b),o.on("data",a=>{v+=a.toString();const i=v.slice(-3);s==="connected"&&(i.startsWith("220")||i.startsWith("250"))?(s="helo",o.write(`HELO ${w}\r
2
2
  `)):s==="helo"&&i.startsWith("250")?(s="mail-from",o.write(`MAIL FROM:<${d}>\r
3
3
  `)):s==="mail-from"&&i.startsWith("250")?(s="rcpt-to",o.write(`RCPT TO:<${l}>\r
4
4
  `)):s==="rcpt-to"&&i.startsWith("250")?(m(),f({mxRecords:r.records,smtpResponse:v,valid:!0})):s==="rcpt-to"&&(i.startsWith("550")||i.startsWith("551")||i.startsWith("553"))&&(m(),f({error:"Email address does not exist",mxRecords:r.records,smtpResponse:v,valid:!1}))}),y?o.connect(x,y.exchange):(m(),f({error:"No MX record available",mxRecords:r.records,valid:!1}))})},"verifySmtp");export{A as verifySmtp};