@visulima/email 2.1.5 → 2.1.7

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 (225) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/crypto/index.d.ts +183 -183
  3. package/dist/crypto/index.js +1 -1
  4. package/dist/deliverability/dmarc-report.d.ts +43 -43
  5. package/dist/deliverability/dmarc-report.js +1 -1
  6. package/dist/deliverability/index.d.ts +201 -201
  7. package/dist/events/index.d.ts +17 -17
  8. package/dist/inbound/index.d.ts +180 -180
  9. package/dist/index.d.ts +35 -46
  10. package/dist/index.js +1 -1
  11. package/dist/middleware/index.d.ts +213 -216
  12. package/dist/middleware/index.js +1 -1
  13. package/dist/packem_shared/{DkimSigner-CiLBaXrg.js → DkimSigner-sLcIw9bp.js} +6 -6
  14. package/dist/packem_shared/{DraftMailMessage-CGTVuy2z.js → DraftMailMessage-C3YTXqWo.js} +1 -1
  15. package/dist/packem_shared/EmailError-CDvYwuqz.js +1 -0
  16. package/dist/packem_shared/{Mail-CYAwMRnX.js → Mail-CIyxkmxu.js} +1 -1
  17. package/dist/packem_shared/MailMessage-DuEXJiCg.js +1 -0
  18. package/dist/packem_shared/{RequiredOptionError-DuNNY_a5.js → RequiredOptionError-DU2lxzk3.js} +1 -1
  19. package/dist/packem_shared/SmimeEncrypter-CzTbQM-z.js +6 -0
  20. package/dist/packem_shared/SmimeSigner-DjLShaOw.js +8 -0
  21. package/dist/packem_shared/{ahaSendProvider-DSuZIzaQ.js → ahaSendProvider-br1yB2un.js} +1 -1
  22. package/dist/packem_shared/arcMessageSignatureBase-D54jQIWu.js +17 -0
  23. package/dist/packem_shared/attachment-processor-D1cbAhQi.js +1 -0
  24. package/dist/packem_shared/{autoSendProvider-DqAoelWR.js → autoSendProvider-BSP8ueOC.js} +1 -1
  25. package/dist/packem_shared/{awsSesProvider-ClK1FUln.js → awsSesProvider-zRICW1pH.js} +13 -13
  26. package/dist/packem_shared/azureProvider-DwN4c5dC.js +1 -0
  27. package/dist/packem_shared/{brevoProvider-CIzuIDlt.js → brevoProvider-C491beE_.js} +1 -1
  28. package/dist/packem_shared/{build-mime-message-BW5FQ2Bt.js → build-mime-message-DT67qfMp.js} +1 -1
  29. package/dist/packem_shared/{circuitBreakerMiddleware-D2SA_07f.js → circuitBreakerMiddleware-N0CKF90q.js} +1 -1
  30. package/dist/packem_shared/{cloudflareEmailProvider-B8mOEl3N.js → cloudflareEmailProvider-8JxzLbpX.js} +1 -1
  31. package/dist/packem_shared/{createTestEmail-f12yLlWn.js → createTestEmail-D_ksEez3.js} +1 -1
  32. package/dist/packem_shared/dedupeMiddleware-CYYI_O7S.js +1 -0
  33. package/dist/packem_shared/{detectMimeType-DFH3kp6K.js → detectMimeType-CmYmWDXE.js} +1 -1
  34. package/dist/packem_shared/event-bus.d-BNQA-FZE.d.ts +104 -0
  35. package/dist/packem_shared/{failoverProvider-BgX6zfnY.js → failoverProvider-6qwE_HSJ.js} +1 -1
  36. package/dist/packem_shared/generate-boundary-0xGe9GqK.js +1 -0
  37. package/dist/packem_shared/{httpProvider-aBfTXyCT.js → httpProvider-BqrdZhGw.js} +1 -1
  38. package/dist/packem_shared/index-Gd7m-UQA.js +11 -0
  39. package/dist/packem_shared/{infobipProvider-DxzsONUX.js → infobipProvider-C2FU6VMP.js} +1 -1
  40. package/dist/packem_shared/isValidSigningCertUrl-DNxPA0Q-.js +3 -0
  41. package/dist/packem_shared/{loopsProvider-QBsAH6Ee.js → loopsProvider-Bz63so6m.js} +1 -1
  42. package/dist/packem_shared/mail.d-xKtvoKMK.d.ts +909 -0
  43. package/dist/packem_shared/{mailCrabProvider-DRE5snM9.js → mailCrabProvider-bkQy-2a1.js} +1 -1
  44. package/dist/packem_shared/{mailPaceProvider-DCa-4ghl.js → mailPaceProvider-S1AB-AYq.js} +1 -1
  45. package/dist/packem_shared/{mailchannelsProvider-GiwkYBdD.js → mailchannelsProvider-B_K6X4VY.js} +1 -1
  46. package/dist/packem_shared/{mailerSendProvider-RK6IbUrL.js → mailerSendProvider-DPEww2H1.js} +1 -1
  47. package/dist/packem_shared/mailgunProvider-DKxzVbDW.js +1 -0
  48. package/dist/packem_shared/mailjetProvider-C2TQcujL.js +1 -0
  49. package/dist/packem_shared/{mailomatProvider-DPDpVS8r.js → mailomatProvider-B8-5bQsu.js} +1 -1
  50. package/dist/packem_shared/{mailtrapProvider-DtrS4Q34.js → mailtrapProvider-DW7TLOdG.js} +1 -1
  51. package/dist/packem_shared/{make-request-B9XjBynA.js → make-request-CylyuRaN.js} +1 -1
  52. package/dist/packem_shared/{mandrillProvider-B84zH-eV.js → mandrillProvider-S-0lKNGd.js} +1 -1
  53. package/dist/packem_shared/{mockProvider-Behywbl1.js → mockProvider-BAl292mW.js} +1 -1
  54. package/dist/packem_shared/{netcoreProvider-D-wtCyJj.js → netcoreProvider-DajMprlo.js} +1 -1
  55. package/dist/packem_shared/{nodemailerProvider-BFHobXxt.js → nodemailerProvider-DRo0lJ6g.js} +1 -1
  56. package/dist/packem_shared/{opentelemetryProvider-ByHC01ub.js → opentelemetryProvider-C6spx2CD.js} +1 -1
  57. package/dist/packem_shared/{outlook365Provider-Btk4Emig.js → outlook365Provider-B0o7UZBW.js} +1 -1
  58. package/dist/packem_shared/{plunkProvider-Bw8e6460.js → plunkProvider-DJzEUEtU.js} +1 -1
  59. package/dist/packem_shared/{postalProvider-CT8zr89z.js → postalProvider-DHFjFE3Y.js} +1 -1
  60. package/dist/packem_shared/{postmarkProvider-CQSqZWDs.js → postmarkProvider-Dt1EGGBA.js} +1 -1
  61. package/dist/packem_shared/{provider-base-C7PuopYK.js → provider-base-DjPzWncP.js} +1 -1
  62. package/dist/packem_shared/{provider.d-J-y6iogK.d.ts → provider.d-Cx5YQJdP.d.ts} +9 -9
  63. package/dist/packem_shared/{resendProvider-drJYlvLP.js → resendProvider-qjI86j_d.js} +1 -1
  64. package/dist/packem_shared/{retry-ipI5DRJ8.js → retry-CG9iT2wF.js} +1 -1
  65. package/dist/packem_shared/{roundRobinProvider-D1by5KGW.js → roundRobinProvider-CO5YvhgR.js} +1 -1
  66. package/dist/packem_shared/{scalewayProvider-DU5gXQrl.js → scalewayProvider-CihQKhw6.js} +1 -1
  67. package/dist/packem_shared/{sendGridProvider-BuTbEXW8.js → sendGridProvider-Dkc5AKlC.js} +1 -1
  68. package/dist/packem_shared/{smtpProvider-5MI3-EPh.js → smtpProvider-CIXMxPu-.js} +12 -12
  69. package/dist/packem_shared/{sparkpostProvider-UAsFYIjP.js → sparkpostProvider-CKxQhpyB.js} +1 -1
  70. package/dist/packem_shared/{sweegoProvider-SUz0LIcA.js → sweegoProvider-DjmAs6La.js} +1 -1
  71. package/dist/packem_shared/{tracer.d-MU42G1jG.d.ts → tracer.d-sb5yrt_n.d.ts} +2 -2
  72. package/dist/packem_shared/types.d-B0t3PQ3t.d.ts +107 -0
  73. package/dist/packem_shared/{types.d-ejzh-xBP.d.ts → types.d-B9295M4_.d.ts} +82 -82
  74. package/dist/packem_shared/types.d-BzoHR9nB.d.ts +61 -0
  75. package/dist/packem_shared/types.d-C5geVKes.d.ts +51 -0
  76. package/dist/packem_shared/types.d-GKqPNk0I.d.ts +24 -0
  77. package/dist/packem_shared/types.d-I-KeZ5w2.d.ts +9 -0
  78. package/dist/packem_shared/types.d-kHO4kX9q.d.ts +69 -0
  79. package/dist/packem_shared/utils-DjEtR3qT.js +1 -0
  80. package/dist/packem_shared/verifyMailgunWebhook-DNk080BF.js +1 -0
  81. package/dist/packem_shared/verifyPostmarkWebhook-B4OIEHQF.js +1 -0
  82. package/dist/packem_shared/verifyResendWebhook-C7E32LZ1.js +1 -0
  83. package/dist/packem_shared/verifySendGridWebhook-1l9bqIMw.js +1 -0
  84. package/dist/packem_shared/withEvents-CytsykaK.js +1 -0
  85. package/dist/packem_shared/{withSuppression-DBaZDMAr.js → withSuppression-BoaO4Qdz.js} +1 -1
  86. package/dist/packem_shared/{zeptomailProvider-DXNX9mG_.js → zeptomailProvider-DSTC9pUi.js} +1 -1
  87. package/dist/providers/ahasend/index.d.ts +18 -18
  88. package/dist/providers/ahasend/index.js +1 -1
  89. package/dist/providers/autosend/index.d.ts +30 -30
  90. package/dist/providers/autosend/index.js +1 -1
  91. package/dist/providers/aws-ses/index.d.ts +20 -20
  92. package/dist/providers/aws-ses/index.js +1 -1
  93. package/dist/providers/azure/index.d.ts +26 -26
  94. package/dist/providers/azure/index.js +1 -1
  95. package/dist/providers/brevo/index.d.ts +35 -35
  96. package/dist/providers/brevo/index.js +1 -1
  97. package/dist/providers/cloudflare-email/index.d.ts +25 -25
  98. package/dist/providers/cloudflare-email/index.js +1 -1
  99. package/dist/providers/failover/index.d.ts +14 -14
  100. package/dist/providers/failover/index.js +1 -1
  101. package/dist/providers/http/index.d.ts +15 -15
  102. package/dist/providers/http/index.js +1 -1
  103. package/dist/providers/infobip/index.d.ts +28 -28
  104. package/dist/providers/infobip/index.js +1 -1
  105. package/dist/providers/loops/index.d.ts +25 -25
  106. package/dist/providers/loops/index.js +1 -1
  107. package/dist/providers/mailchannels/index.d.ts +13 -13
  108. package/dist/providers/mailchannels/index.js +1 -1
  109. package/dist/providers/mailcrab/index.d.ts +17 -17
  110. package/dist/providers/mailcrab/index.js +1 -1
  111. package/dist/providers/mailersend/index.d.ts +24 -24
  112. package/dist/providers/mailersend/index.js +1 -1
  113. package/dist/providers/mailgun/index.d.ts +37 -37
  114. package/dist/providers/mailgun/index.js +1 -1
  115. package/dist/providers/mailjet/index.d.ts +36 -36
  116. package/dist/providers/mailjet/index.js +1 -1
  117. package/dist/providers/mailomat/index.d.ts +20 -20
  118. package/dist/providers/mailomat/index.js +1 -1
  119. package/dist/providers/mailpace/index.d.ts +24 -24
  120. package/dist/providers/mailpace/index.js +1 -1
  121. package/dist/providers/mailtrap/index.d.ts +22 -22
  122. package/dist/providers/mailtrap/index.js +1 -1
  123. package/dist/providers/mandrill/index.d.ts +36 -36
  124. package/dist/providers/mandrill/index.js +1 -1
  125. package/dist/providers/mock/index.d.ts +8 -8
  126. package/dist/providers/mock/index.js +1 -1
  127. package/dist/providers/netcore/index.d.ts +17 -17
  128. package/dist/providers/netcore/index.js +1 -1
  129. package/dist/providers/nodemailer/index.d.ts +22 -22
  130. package/dist/providers/nodemailer/index.js +1 -1
  131. package/dist/providers/opentelemetry/index.d.ts +20 -20
  132. package/dist/providers/opentelemetry/index.js +1 -1
  133. package/dist/providers/outlook365/index.d.ts +82 -82
  134. package/dist/providers/outlook365/index.js +1 -1
  135. package/dist/providers/plunk/index.d.ts +18 -18
  136. package/dist/providers/plunk/index.js +1 -1
  137. package/dist/providers/postal/index.d.ts +24 -24
  138. package/dist/providers/postal/index.js +1 -1
  139. package/dist/providers/postmark/index.d.ts +30 -30
  140. package/dist/providers/postmark/index.js +1 -1
  141. package/dist/providers/resend/index.d.ts +24 -24
  142. package/dist/providers/resend/index.js +1 -1
  143. package/dist/providers/roundrobin/index.d.ts +14 -14
  144. package/dist/providers/roundrobin/index.js +1 -1
  145. package/dist/providers/scaleway/index.d.ts +22 -22
  146. package/dist/providers/scaleway/index.js +1 -1
  147. package/dist/providers/sendgrid/index.d.ts +25 -25
  148. package/dist/providers/sendgrid/index.js +1 -1
  149. package/dist/providers/smtp/index.d.ts +11 -11
  150. package/dist/providers/smtp/index.js +1 -1
  151. package/dist/providers/sparkpost/index.d.ts +21 -21
  152. package/dist/providers/sparkpost/index.js +1 -1
  153. package/dist/providers/sweego/index.d.ts +20 -20
  154. package/dist/providers/sweego/index.js +1 -1
  155. package/dist/providers/zeptomail/index.d.ts +17 -17
  156. package/dist/providers/zeptomail/index.js +1 -1
  157. package/dist/queue/bullmq-queue.d.ts +26 -26
  158. package/dist/queue/index.d.ts +86 -86
  159. package/dist/queue/pg-boss-queue.d.ts +13 -13
  160. package/dist/queue/sqs-queue.d.ts +20 -20
  161. package/dist/queue/unstorage-queue.d.ts +47 -47
  162. package/dist/queue/unstorage-queue.js +1 -1
  163. package/dist/render/cid.d.ts +12 -12
  164. package/dist/render/css-inline.d.ts +12 -12
  165. package/dist/render/css-inline.js +1 -1
  166. package/dist/render/dark-mode.d.ts +12 -12
  167. package/dist/render/preheader.d.ts +16 -16
  168. package/dist/template-engines/handlebars.d.ts +19 -19
  169. package/dist/template-engines/handlebars.js +1 -1
  170. package/dist/template-engines/html-to-text.d.ts +12 -12
  171. package/dist/template-engines/html-to-text.js +1 -1
  172. package/dist/template-engines/i18n.d.ts +43 -43
  173. package/dist/template-engines/i18n.js +1 -1
  174. package/dist/template-engines/jsx-email.d.ts +8 -8
  175. package/dist/template-engines/jsx-email.js +1 -1
  176. package/dist/template-engines/liquid.d.ts +9 -9
  177. package/dist/template-engines/liquid.js +1 -1
  178. package/dist/template-engines/mjml.d.ts +9 -9
  179. package/dist/template-engines/mjml.js +1 -1
  180. package/dist/template-engines/react-email.d.ts +8 -8
  181. package/dist/template-engines/react-email.js +1 -1
  182. package/dist/template-engines/vue-email.d.ts +8 -8
  183. package/dist/template-engines/vue-email.js +1 -1
  184. package/dist/test/index.d.ts +89 -89
  185. package/dist/test/index.js +1 -1
  186. package/dist/utils/cache.d.ts +27 -27
  187. package/dist/utils/format-email-address.d.ts +6 -6
  188. package/dist/utils/format-email-address.js +1 -1
  189. package/dist/utils/normalize-email-aliases.d.ts +19 -19
  190. package/dist/utils/parse-address.d.ts +16 -16
  191. package/dist/utils/parse-eml.d.ts +18 -18
  192. package/dist/utils/result.d.ts +30 -30
  193. package/dist/utils/result.js +1 -1
  194. package/dist/utils/validation/check-feature-support.d.ts +33 -33
  195. package/dist/utils/validation/validate-email.d.ts +4 -4
  196. package/dist/webhooks/index.d.ts +134 -134
  197. package/dist/webhooks/index.js +1 -1
  198. package/package.json +1 -1
  199. package/dist/packem_shared/EmailError-B-sEf3bp.js +0 -1
  200. package/dist/packem_shared/MailMessage-DQRgs5Dz.js +0 -1
  201. package/dist/packem_shared/SmimeEncrypter-DavopRlE.js +0 -6
  202. package/dist/packem_shared/SmimeSigner-0onWksAv.js +0 -8
  203. package/dist/packem_shared/arcMessageSignatureBase-DDLEHW2E.js +0 -17
  204. package/dist/packem_shared/attachment-processor-CMp7qqMI.js +0 -1
  205. package/dist/packem_shared/azureProvider-Cw_Tmde6.js +0 -1
  206. package/dist/packem_shared/dedupeMiddleware-B6ajWOTi.js +0 -1
  207. package/dist/packem_shared/event-bus.d-DEl3w_EW.d.ts +0 -104
  208. package/dist/packem_shared/generate-boundary-DQbzDiOI.js +0 -1
  209. package/dist/packem_shared/index-BoZvzveg.js +0 -11
  210. package/dist/packem_shared/isValidSigningCertUrl-Bii1AMGC.js +0 -3
  211. package/dist/packem_shared/mail.d-B9SSqyy0.d.ts +0 -909
  212. package/dist/packem_shared/mailgunProvider-D9HUWGKN.js +0 -1
  213. package/dist/packem_shared/mailjetProvider-DelLs2Vt.js +0 -1
  214. package/dist/packem_shared/types.d-BId55FW2.d.ts +0 -107
  215. package/dist/packem_shared/types.d-CmoWvdZi.d.ts +0 -61
  216. package/dist/packem_shared/types.d-DCkecJse.d.ts +0 -51
  217. package/dist/packem_shared/types.d-Mpu0HZoG.d.ts +0 -24
  218. package/dist/packem_shared/types.d-lcJZmwRK.d.ts +0 -69
  219. package/dist/packem_shared/types.d-nyR1ty1Q.d.ts +0 -9
  220. package/dist/packem_shared/utils-BfYfPB_I.js +0 -1
  221. package/dist/packem_shared/verifyMailgunWebhook-Cwl0OD3P.js +0 -1
  222. package/dist/packem_shared/verifyPostmarkWebhook-C72ZvbrG.js +0 -1
  223. package/dist/packem_shared/verifyResendWebhook-YK2zNDXR.js +0 -1
  224. package/dist/packem_shared/verifySendGridWebhook-Dbwc1tfG.js +0 -1
  225. package/dist/packem_shared/withEvents-CCVblSqj.js +0 -1
@@ -1,25 +1,25 @@
1
- import{createRequire as x}from"node:module";import f from"./EmailError-B-sEf3bp.js";import W from"./RequiredOptionError-DuNNY_a5.js";import{F as Q}from"./build-mime-message-BW5FQ2Bt.js";import{e as Z}from"./generate-message-id-gXAuMz4g.js";import{f as J}from"./validate-email-options-mCM9dVug.js";import{defineProvider as V}from"./defineProvider-C9q-7iwt.js";const G=x(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=h=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,A]=O.versions.node.split(".").map(Number);if(t>22||t===22&&A>=3||t===20&&A>=16)return O.getBuiltinModule(h)}return G(h)},{Buffer:I}=k("node:buffer"),{createHmac:B,createHash:X,createSign:Y}=k("node:crypto"),{Socket:q,createConnection:K}=k("node:net"),{connect:E}=k("node:tls"),ee=(h,t)=>new Promise(A=>{const w=new q,y=()=>{w.destroy(),A(!1)};w.setTimeout(1e3),w.on("error",y),w.on("timeout",y),w.connect(t,h,()=>{w.end(),A(!0)})}),l="smtp",te=25,re=465,se=1e4,oe=!1,ae=5,P=3e4,ie=/^\./,pe=V((h={})=>{if(!h.host)throw new W(l,"host");const t={authMethod:h.authMethod??"LOGIN",debug:h.debug??!1,dkim:h.dkim,host:h.host,maxConnections:h.maxConnections??ae,oauth2:h.oauth2,password:h.password,pool:h.pool??!1,port:h.port!==void 0?h.port:h.secure?re:te,rejectUnauthorized:h.rejectUnauthorized??!0,retries:h.retries??0,secure:h.secure??oe,timeout:h.timeout??se,user:h.user,...h.logger&&{logger:h.logger}};let A=!1;const w=[],y=[],S=e=>e.replaceAll(/[\r\n\t\v\f]/g," ").trim(),v=e=>{const u=e.split(`\r
2
- `),o={};for(const c of u)if(c.startsWith("250-")||c.startsWith("250 ")){const i=c.slice(4).trim().split(" "),n=i[0];n&&(o[n]=i.slice(1))}return o},p=async(e,u,o)=>new Promise((c,i)=>{const n=Array.isArray(o)?o:[o];let s="",a="";const d=setTimeout(()=>{g(),i(new f(l,`Command timeout after ${t.timeout}ms: ${u?.slice(0,50)}...`))},t.timeout),g=()=>{e.removeListener("data",b),e.removeListener("error",r),d&&clearTimeout(d)},b=m=>{s+=m.toString();const j=s.split(`\r
1
+ import{createRequire as x}from"node:module";import f from"./EmailError-CDvYwuqz.js";import Q from"./RequiredOptionError-DU2lxzk3.js";import{F as Z}from"./build-mime-message-DT67qfMp.js";import{e as J}from"./generate-message-id-gXAuMz4g.js";import{f as V}from"./validate-email-options-mCM9dVug.js";import{defineProvider as ee}from"./defineProvider-C9q-7iwt.js";let G;const B=d=>(G??=x(import.meta.url))(d),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=d=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,A]=O.versions.node.split(".").map(Number);if(t>22||t===22&&A>=3||t===20&&A>=16)return O.getBuiltinModule(d)}return B(d)},{Buffer:I}=k("node:buffer"),{createHmac:q,createHash:X,createSign:Y}=k("node:crypto"),{Socket:K,createConnection:W}=k("node:net"),{connect:E}=k("node:tls"),te=(d,t)=>new Promise(A=>{const w=new K,y=()=>{w.destroy(),A(!1)};w.setTimeout(1e3),w.on("error",y),w.on("timeout",y),w.connect(t,d,()=>{w.end(),A(!0)})}),l="smtp",re=25,se=465,oe=1e4,ae=!1,ie=5,P=3e4,ne=/^\./,me=ee((d={})=>{if(!d.host)throw new Q(l,"host");const t={authMethod:d.authMethod??"LOGIN",debug:d.debug??!1,dkim:d.dkim,host:d.host,maxConnections:d.maxConnections??ie,oauth2:d.oauth2,password:d.password,pool:d.pool??!1,port:d.port!==void 0?d.port:d.secure?se:re,rejectUnauthorized:d.rejectUnauthorized??!0,retries:d.retries??0,secure:d.secure??ae,timeout:d.timeout??oe,user:d.user,...d.logger&&{logger:d.logger}};let A=!1;const w=[],y=[],S=e=>e.replaceAll(/[\r\n\t\v\f]/g," ").trim(),v=e=>{const u=e.split(`\r
2
+ `),o={};for(const c of u)if(c.startsWith("250-")||c.startsWith("250 ")){const i=c.slice(4).trim().split(" "),n=i[0];n&&(o[n]=i.slice(1))}return o},p=async(e,u,o)=>new Promise((c,i)=>{const n=Array.isArray(o)?o:[o];let s="",a="";const h=setTimeout(()=>{g(),i(new f(l,`Command timeout after ${t.timeout}ms: ${u?.slice(0,50)}...`))},t.timeout),g=()=>{e.removeListener("data",b),e.removeListener("error",r),h&&clearTimeout(h)},b=m=>{s+=m.toString();const j=s.split(`\r
3
3
  `).filter(Boolean);if(j.length>0){const $=j.at(-1);if($){const U=$.match(/^(\d{3})[\s-]/);if(U){const[,M]=U;a=M,$[3]===" "&&(g(),n.includes(a)?c(s):i(new f(l,`Expected ${n.join(" or ")}, got ${a}: ${s.trim()}`)))}}}},r=m=>{g(),i(new f(l,`Socket error: ${m.message}`,{cause:m}))};e.on("data",b),e.on("error",r),u&&e.write(`${u}\r
4
- `)}),C=async()=>{if(t.pool&&w.length>0){const e=w.pop();if(e&&!e.destroyed)return e}return t.pool&&w.length+1>=t.maxConnections?new Promise((e,u)=>{const o={reject:u,resolve:e};o.timeout=setTimeout(()=>{const c=y.indexOf(o);c!==-1&&y.splice(c,1),u(new f(l,`Connection queue timeout after ${P}ms`))},P),y.push(o)}):new Promise((e,u)=>{let o,c=!1,i;const n=()=>{o&&clearTimeout(o)};o=setTimeout(()=>{c||(c=!0,i&&!i.destroyed&&i.destroy(),n(),u(new f(l,`Connection timeout to ${t.host}:${t.port} after ${t.timeout}ms`)))},t.timeout);try{i=t.secure?E({host:t.host,port:t.port,rejectUnauthorized:t.rejectUnauthorized}):K(t.port,t.host),i.on("error",s=>{c||(c=!0,n(),u(new f(l,`Connection error: ${s.message}`,{cause:s})))}),i.once("data",s=>{if(!c&&i){c=!0,n();const a=s.toString();a.slice(0,3)==="220"?e(i):(i.destroy(),u(new f(l,`Unexpected server greeting: ${a.trim()}`)))}})}catch(s){c||(c=!0,n(),u(new f(l,`Failed to create connection: ${s.message}`,{cause:s})))}})},R=async e=>new Promise((u,o)=>{let c,i=!1,n;const s=()=>{c&&clearTimeout(c)};c=setTimeout(()=>{i||(i=!0,n&&!n.destroyed&&n.destroy(),s(),o(new f(l,`TLS connection timeout after ${t.timeout}ms`)))},t.timeout);try{const a={host:t.host,rejectUnauthorized:t.rejectUnauthorized,socket:e};n=E(a),n.on("error",d=>{i||(i=!0,s(),o(new f(l,`TLS connection error: ${d.message}`,{cause:d})))}),n.once("secure",()=>{!i&&n&&(i=!0,s(),u(n))})}catch(a){i||(i=!0,s(),o(new f(l,`Failed to upgrade to TLS: ${a.message}`,{cause:a})))}}),z=e=>{if(e.destroyed||!t.pool){try{e.destroy()}catch{}return}if(y.length>0){const u=y.shift();if(u){clearTimeout(u.timeout),u.resolve(e);return}}w.push(e)},L=async(e,u=!1)=>new Promise(o=>{try{if(u){e.write(`RSET\r
5
- `),z(e),o();return}e.write(`QUIT\r
6
- `),e.end(),e.once("close",()=>{o()})}catch{o()}}),N=async e=>{if(!t.user)return;const u=await p(e,`EHLO ${t.host}`,"250"),o=v(u),c=Object.keys(o).find(s=>s.toUpperCase()==="AUTH");if(!c&&(t.user||t.password))throw new f(l,"Server does not support authentication");const i=c?o[c]??[]:[];let{authMethod:n}=t;if(n||(i.includes("CRAM-MD5")?n="CRAM-MD5":i.includes("LOGIN")?n="LOGIN":i.includes("PLAIN")&&(n="PLAIN")),!n)throw new f(l,"No supported authentication methods");if(n==="OAUTH2"&&t.oauth2)try{const{accessToken:s,user:a}=t.oauth2,d=`user=${a}auth=Bearer ${s}`,g=I.from(d).toString("base64");await p(e,`AUTH XOAUTH2 ${g}`,"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid OAuth2 credentials"):s}if(n==="CRAM-MD5"&&t.password)try{const s=(await p(e,"AUTH CRAM-MD5","334")).split(" ")[1];if(!s)throw new f(l,"Invalid CRAM-MD5 challenge response");const a=I.from(s,"base64").toString("utf8"),d=B("md5",t.password);d.update(a);const g=d.digest("hex"),b=`${t.user} ${g}`;await p(e,I.from(b).toString("base64"),"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid username or password"):s}if(n==="LOGIN"&&t.password)try{await p(e,"AUTH LOGIN","334"),await p(e,I.from(t.user).toString("base64"),"334"),await p(e,I.from(t.password).toString("base64"),"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid username or password"):s}if(n==="PLAIN"&&t.password)try{const s=I.from(`\0${t.user}\0${t.password}`).toString("base64");await p(e,`AUTH PLAIN ${s}`,"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid username or password"):s}throw new f(l,"Authentication failed - no valid credentials or method")},F=e=>{if(!t.dkim)return e;const{domainName:u,keySelector:o,privateKey:c}=t.dkim;try{const[i,n]=e.split(`\r
4
+ `)}),C=async()=>{if(t.pool&&w.length>0){const e=w.pop();if(e&&!e.destroyed)return e}return t.pool&&w.length+1>=t.maxConnections?new Promise((e,u)=>{const o={reject:u,resolve:e};o.timeout=setTimeout(()=>{const c=y.indexOf(o);c!==-1&&y.splice(c,1),u(new f(l,`Connection queue timeout after ${P}ms`))},P),y.push(o)}):new Promise((e,u)=>{let o,c=!1,i;const n=()=>{o&&clearTimeout(o)};o=setTimeout(()=>{c||(c=!0,i&&!i.destroyed&&i.destroy(),n(),u(new f(l,`Connection timeout to ${t.host}:${t.port} after ${t.timeout}ms`)))},t.timeout);try{i=t.secure?E({host:t.host,port:t.port,rejectUnauthorized:t.rejectUnauthorized}):W(t.port,t.host),i.on("error",s=>{c||(c=!0,n(),u(new f(l,`Connection error: ${s.message}`,{cause:s})))}),i.once("data",s=>{if(!c&&i){c=!0,n();const a=s.toString();a.slice(0,3)==="220"?e(i):(i.destroy(),u(new f(l,`Unexpected server greeting: ${a.trim()}`)))}})}catch(s){c||(c=!0,n(),u(new f(l,`Failed to create connection: ${s.message}`,{cause:s})))}})},H=async e=>new Promise((u,o)=>{let c,i=!1,n;const s=()=>{c&&clearTimeout(c)};c=setTimeout(()=>{i||(i=!0,n&&!n.destroyed&&n.destroy(),s(),o(new f(l,`TLS connection timeout after ${t.timeout}ms`)))},t.timeout);try{const a={host:t.host,rejectUnauthorized:t.rejectUnauthorized,socket:e};n=E(a),n.on("error",h=>{i||(i=!0,s(),o(new f(l,`TLS connection error: ${h.message}`,{cause:h})))}),n.once("secure",()=>{!i&&n&&(i=!0,s(),u(n))})}catch(a){i||(i=!0,s(),o(new f(l,`Failed to upgrade to TLS: ${a.message}`,{cause:a})))}}),_=e=>{if(e.destroyed||!t.pool){try{e.destroy()}catch{}return}if(y.length>0){const u=y.shift();if(u){clearTimeout(u.timeout),u.resolve(e);return}}w.push(e)},L=async(e,u=!1)=>new Promise(o=>{try{if(u){e.write(`RSET\r
5
+ `),_(e),o();return}e.write(`QUIT\r
6
+ `),e.end(),e.once("close",()=>{o()})}catch{o()}}),N=async e=>{if(!t.user)return;const u=await p(e,`EHLO ${t.host}`,"250"),o=v(u),c=Object.keys(o).find(s=>s.toUpperCase()==="AUTH");if(!c&&(t.user||t.password))throw new f(l,"Server does not support authentication");const i=c?o[c]??[]:[];let{authMethod:n}=t;if(n||(i.includes("CRAM-MD5")?n="CRAM-MD5":i.includes("LOGIN")?n="LOGIN":i.includes("PLAIN")&&(n="PLAIN")),!n)throw new f(l,"No supported authentication methods");if(n==="OAUTH2"&&t.oauth2)try{const{accessToken:s,user:a}=t.oauth2,h=`user=${a}auth=Bearer ${s}`,g=I.from(h).toString("base64");await p(e,`AUTH XOAUTH2 ${g}`,"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid OAuth2 credentials"):s}if(n==="CRAM-MD5"&&t.password)try{const s=(await p(e,"AUTH CRAM-MD5","334")).split(" ")[1];if(!s)throw new f(l,"Invalid CRAM-MD5 challenge response");const a=I.from(s,"base64").toString("utf8"),h=q("md5",t.password);h.update(a);const g=h.digest("hex"),b=`${t.user} ${g}`;await p(e,I.from(b).toString("base64"),"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid username or password"):s}if(n==="LOGIN"&&t.password)try{await p(e,"AUTH LOGIN","334"),await p(e,I.from(t.user).toString("base64"),"334"),await p(e,I.from(t.password).toString("base64"),"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid username or password"):s}if(n==="PLAIN"&&t.password)try{const s=I.from(`\0${t.user}\0${t.password}`).toString("base64");await p(e,`AUTH PLAIN ${s}`,"235");return}catch(s){const a=s.message;throw a.includes("535")||a.includes("Authentication failed")?new f(l,"Authentication failed: Invalid username or password"):s}throw new f(l,"Authentication failed - no valid credentials or method")},z=e=>{if(!t.dkim)return e;const{domainName:u,keySelector:o,privateKey:c}=t.dkim;try{const[i,n]=e.split(`\r
7
7
  \r
8
8
  `);if(!i||!n)return e;const s=i.split(`\r
9
9
  `),a=T=>T.replaceAll(`\r
10
10
  `,`
11
- `).replaceAll(/\s+/g," ").trim(),d=a(n),g=X("sha256").update(d).digest("base64"),b=["from","to","subject","date"],r=s.filter(T=>b.some(H=>T.toLowerCase().startsWith(`${H}:`))),m=r.map(T=>T.split(":")[0]?.toLowerCase()??"").filter(Boolean).join(":"),j=Math.floor(Date.now()/1e3),$={a:"rsa-sha256",bh:g,c:"relaxed/relaxed",d:u,h:m,s:o,t:j.toString(),v:"1"},U=`DKIM-Signature: ${Object.entries($).map(([T,H])=>`${T}=${H}`).join("; ")}; b=`,M=[...r,U].map(T=>a(T)).join(`\r
12
- `),D=Y("RSA-SHA256");D.update(M);const _=D.sign(c,"base64");return`${`${U}${_}`}\r
11
+ `).replaceAll(/\s+/g," ").trim(),h=a(n),g=X("sha256").update(h).digest("base64"),b=["from","to","subject","date"],r=s.filter(T=>b.some(R=>T.toLowerCase().startsWith(`${R}:`))),m=r.map(T=>T.split(":")[0]?.toLowerCase()??"").filter(Boolean).join(":"),j=Math.floor(Date.now()/1e3),$={a:"rsa-sha256",bh:g,c:"relaxed/relaxed",d:u,h:m,s:o,t:j.toString(),v:"1"},U=`DKIM-Signature: ${Object.entries($).map(([T,R])=>`${T}=${R}`).join("; ")}; b=`,M=[...r,U].map(T=>a(T)).join(`\r
12
+ `),D=Y("RSA-SHA256");D.update(M);const F=D.sign(c,"base64");return`${`${U}${F}`}\r
13
13
  ${s.join(`\r
14
14
  `)}\r
15
15
  \r
16
- ${n}`}catch(i){return console.error(`[${l}] DKIM signing error:`,i),e}};return{features:{attachments:!0,batchSending:t.pool,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!A)try{if(!await this.isAvailable())throw new f(l,`SMTP server not available at ${t.host}:${t.port}`);A=!0}catch(e){throw new f(l,`Failed to initialize: ${e.message}`,{cause:e})}},async isAvailable(){try{if(!await ee(t.host,t.port))return!1;const e=await C();return await L(e),!0}catch{return!1}},name:l,options:t,async sendEmail(e){try{const u=J(e);if(u.length>0)return{error:new f(l,`Invalid email options: ${u.join(", ")}`),success:!1};A||await this.initialize();let o=await C();try{let c=v(await p(o,`EHLO ${t.host}`,"250"));if(!t.secure)try{const r=await p(o,`EHLO ${t.host}`,"250"),m=v(r);c=m,Object.keys(m).includes("STARTTLS")&&(await p(o,"STARTTLS","220"),o=await R(o),c=v(await p(o,`EHLO ${t.host}`,"250")))}catch(r){if(t.rejectUnauthorized)throw new f(l,`STARTTLS failed or not supported: ${r.message}`,{cause:r})}await N(o);const i=Object.keys(c).some(r=>r.toUpperCase()==="DSN");let n="";if(e.dsn&&i){const r=[];e.dsn.success&&r.push("SUCCESS"),e.dsn.failure&&r.push("FAILURE"),e.dsn.delay&&r.push("DELAY"),r.length>0&&(n=` NOTIFY=${r.join(",")}`)}await p(o,`MAIL FROM:<${e.from.email}>`,"250");const s=[];Array.isArray(e.to)?s.push(...e.to.map(r=>r.email)):s.push(e.to.email),e.cc&&(Array.isArray(e.cc)?s.push(...e.cc.map(r=>r.email)):s.push(e.cc.email)),e.bcc&&(Array.isArray(e.bcc)?s.push(...e.bcc.map(r=>r.email)):s.push(e.bcc.email));for(const r of s)await p(o,`RCPT TO:<${r}>${n}`,"250");await p(o,"DATA","354");let a=await Q(e);const d=[];if(e.dsn&&!i){const r=[];e.dsn.success&&r.push("SUCCESS"),e.dsn.failure&&r.push("FAILURE"),e.dsn.delay&&r.push("DELAY"),r.length>0&&d.push(`X-DSN-NOTIFY: ${r.join(",")}`)}if(e.priority){let r="";switch(e.priority){case"high":{r="1 (Highest)",d.push("Importance: High");break}case"low":{r="5 (Lowest)",d.push("Importance: Low");break}case"normal":{r="3 (Normal)",d.push("Importance: Normal");break}default:{r="3 (Normal)";break}}d.push(`X-Priority: ${r}`)}if(e.inReplyTo&&d.push(`In-Reply-To: ${S(e.inReplyTo)}`),e.references){const r=Array.isArray(e.references)?e.references.map(m=>S(m)).join(" "):S(e.references);d.push(`References: ${r}`)}if(e.listUnsubscribe){const r=Array.isArray(e.listUnsubscribe)?e.listUnsubscribe.map(m=>`<${S(m)}>`).join(", "):`<${S(e.listUnsubscribe)}>`;d.push(`List-Unsubscribe: ${r}`)}if(e.googleMailHeaders){const{googleMailHeaders:r}=e;r.feedbackId&&d.push(`Feedback-ID: ${S(r.feedbackId)}`),r.promotionalContent&&d.push("X-Google-Promotion: promotional"),r.category&&d.push(`X-Gmail-Labels: ${r.category}`)}if(d.length>0){const r=a.indexOf(`\r
16
+ ${n}`}catch(i){return console.error(`[${l}] DKIM signing error:`,i),e}};return{features:{attachments:!0,batchSending:t.pool,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!1},async initialize(){if(!A)try{if(!await this.isAvailable())throw new f(l,`SMTP server not available at ${t.host}:${t.port}`);A=!0}catch(e){throw new f(l,`Failed to initialize: ${e.message}`,{cause:e})}},async isAvailable(){try{if(!await te(t.host,t.port))return!1;const e=await C();return await L(e),!0}catch{return!1}},name:l,options:t,async sendEmail(e){try{const u=V(e);if(u.length>0)return{error:new f(l,`Invalid email options: ${u.join(", ")}`),success:!1};A||await this.initialize();let o=await C();try{let c=v(await p(o,`EHLO ${t.host}`,"250"));if(!t.secure)try{const r=await p(o,`EHLO ${t.host}`,"250"),m=v(r);c=m,Object.keys(m).includes("STARTTLS")&&(await p(o,"STARTTLS","220"),o=await H(o),c=v(await p(o,`EHLO ${t.host}`,"250")))}catch(r){if(t.rejectUnauthorized)throw new f(l,`STARTTLS failed or not supported: ${r.message}`,{cause:r})}await N(o);const i=Object.keys(c).some(r=>r.toUpperCase()==="DSN");let n="";if(e.dsn&&i){const r=[];e.dsn.success&&r.push("SUCCESS"),e.dsn.failure&&r.push("FAILURE"),e.dsn.delay&&r.push("DELAY"),r.length>0&&(n=` NOTIFY=${r.join(",")}`)}await p(o,`MAIL FROM:<${e.from.email}>`,"250");const s=[];Array.isArray(e.to)?s.push(...e.to.map(r=>r.email)):s.push(e.to.email),e.cc&&(Array.isArray(e.cc)?s.push(...e.cc.map(r=>r.email)):s.push(e.cc.email)),e.bcc&&(Array.isArray(e.bcc)?s.push(...e.bcc.map(r=>r.email)):s.push(e.bcc.email));for(const r of s)await p(o,`RCPT TO:<${r}>${n}`,"250");await p(o,"DATA","354");let a=await Z(e);const h=[];if(e.dsn&&!i){const r=[];e.dsn.success&&r.push("SUCCESS"),e.dsn.failure&&r.push("FAILURE"),e.dsn.delay&&r.push("DELAY"),r.length>0&&h.push(`X-DSN-NOTIFY: ${r.join(",")}`)}if(e.priority){let r="";switch(e.priority){case"high":{r="1 (Highest)",h.push("Importance: High");break}case"low":{r="5 (Lowest)",h.push("Importance: Low");break}case"normal":{r="3 (Normal)",h.push("Importance: Normal");break}default:{r="3 (Normal)";break}}h.push(`X-Priority: ${r}`)}if(e.inReplyTo&&h.push(`In-Reply-To: ${S(e.inReplyTo)}`),e.references){const r=Array.isArray(e.references)?e.references.map(m=>S(m)).join(" "):S(e.references);h.push(`References: ${r}`)}if(e.listUnsubscribe){const r=Array.isArray(e.listUnsubscribe)?e.listUnsubscribe.map(m=>`<${S(m)}>`).join(", "):`<${S(e.listUnsubscribe)}>`;h.push(`List-Unsubscribe: ${r}`)}if(e.googleMailHeaders){const{googleMailHeaders:r}=e;r.feedbackId&&h.push(`Feedback-ID: ${S(r.feedbackId)}`),r.promotionalContent&&h.push("X-Google-Promotion: promotional"),r.category&&h.push(`X-Gmail-Labels: ${r.category}`)}if(h.length>0){const r=a.indexOf(`\r
17
17
  \r
18
18
  `);if(r!==-1){const m=a.slice(0,r),j=a.slice(r+4);a=`${m}\r
19
- ${d.join(`\r
19
+ ${h.join(`\r
20
20
  `)}\r
21
21
  \r
22
- ${j}`}}t.dkim&&(e.useDkim||e.useDkim===void 0)&&(a=F(a));const g=a.replaceAll(`\r
22
+ ${j}`}}t.dkim&&(e.useDkim||e.useDkim===void 0)&&(a=z(a));const g=a.replaceAll(`\r
23
23
  .`,`\r
24
- ..`).replace(ie,"..");await p(o,`${g}\r
25
- .`,"250");const b=Z();return await L(o,t.pool),{data:{messageId:b,provider:l,response:"Message accepted",sent:!0,timestamp:new Date},success:!0}}catch(c){try{await L(o)}catch{}throw c}}catch(u){return{error:new f(l,`Failed to send email: ${u.message}`,{cause:u}),success:!1}}},async shutdown(){for(const e of w)try{await L(e)}catch{}w.length=0;for(const e of y)clearTimeout(e.timeout),e.reject(new Error("Provider shutdown"));y.length=0},async validateCredentials(){try{if(!await this.isAvailable())return!1;const e=await C();try{if(await p(e,`EHLO ${t.host}`,"250"),!t.secure)try{const u=await p(e,`EHLO ${t.host}`,"250"),o=v(u);if(Object.keys(o).includes("STARTTLS")){await p(e,"STARTTLS","220");const c=await R(e);Object.assign(e,c),await p(e,`EHLO ${t.host}`,"250")}}catch{if(t.rejectUnauthorized)return!1}return await N(e),await L(e),!0}catch{return await L(e),!1}}catch{return!1}}}});export{pe as default};
24
+ ..`).replace(ne,"..");await p(o,`${g}\r
25
+ .`,"250");const b=J();return await L(o,t.pool),{data:{messageId:b,provider:l,response:"Message accepted",sent:!0,timestamp:new Date},success:!0}}catch(c){try{await L(o)}catch{}throw c}}catch(u){return{error:new f(l,`Failed to send email: ${u.message}`,{cause:u}),success:!1}}},async shutdown(){for(const e of w)try{await L(e)}catch{}w.length=0;for(const e of y)clearTimeout(e.timeout),e.reject(new Error("Provider shutdown"));y.length=0},async validateCredentials(){try{if(!await this.isAvailable())return!1;const e=await C();try{if(await p(e,`EHLO ${t.host}`,"250"),!t.secure)try{const u=await p(e,`EHLO ${t.host}`,"250"),o=v(u);if(Object.keys(o).includes("STARTTLS")){await p(e,"STARTTLS","220");const c=await H(e);Object.assign(e,c),await p(e,`EHLO ${t.host}`,"250")}}catch{if(t.rejectUnauthorized)return!1}return await N(e),await L(e),!0}catch{return await L(e),!1}}catch{return!1}}}});export{me as default};
@@ -1 +1 @@
1
- import h from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-B9XjBynA.js";import{i as I}from"./retry-ipI5DRJ8.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as z,h as _,c as C}from"./provider-base-C7PuopYK.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-CMp7qqMI.js";const a="sparkpost",O="https://api.sparkpost.com/api/v1",T=3e4,x=3,d=r=>[r].flat(),B=S((r={})=>{if(!r.apiKey)throw new w(a,"apiKey");const n={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??O,logger:r.logger,retries:r.retries??x,timeout:r.timeout??T},g=new z,y=C(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new h(a,"SparkPost API not available or invalid API key");y.debug("Provider initialized successfully")},a)},async isAvailable(){return n.apiKey.length>0},name:a,options:n,async sendEmail(t){try{const o=A(t);if(o.length>0)return{error:new h(a,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),a);const p=d(t.to),u=t.cc?d(t.cc):[],k=t.bcc?d(t.bcc):[],v=[...p.map(e=>({address:l(e)})),...u.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}})),...k.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}}))],s={from:l(t.from),subject:t.subject};if(t.html&&(s.html=t.html),t.text&&(s.text=t.text),t.replyTo){const e=d(t.replyTo)[0];e&&(s.reply_to=e.email)}const c={};if(u.length>0&&(c.CC=u.map(e=>e.email).join(", ")),t.headers)for(const[e,i]of Object.entries(t.headers))c[e]=String(i);Object.keys(c).length>0&&(s.headers=c),t.templateId&&(s.template_id=t.templateId),t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const i=await K(e,a);return{data:i.content,name:i.filename,type:i.contentType}})));const f={content:s,recipients:v};t.campaignId&&(f.campaign_id=t.campaignId),(t.trackOpens!==void 0||t.trackClicks!==void 0)&&(f.options={click_tracking:t.trackClicks??!0,open_tracking:t.trackOpens??!0});const m=await I(async()=>j(`${n.endpoint}/transmissions`,{headers:{Authorization:n.apiKey,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify(f)),n.retries);if(!m.success)return{error:m.error??new h(a,"Failed to send email"),success:!1};const{body:b}=m.data;return{data:{messageId:b?.results?.id??P(),provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:_(a,"send email",o,y),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
1
+ import h from"./EmailError-CDvYwuqz.js";import w from"./RequiredOptionError-DU2lxzk3.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-CylyuRaN.js";import{i as I}from"./retry-CG9iT2wF.js";import{f as A}from"./validate-email-options-mCM9dVug.js";import{defineProvider as S}from"./defineProvider-C9q-7iwt.js";import{P as z,h as _,c as C}from"./provider-base-DjPzWncP.js";import{a as l}from"./address-formatter-BWR2Dddx.js";import{c as K}from"./attachment-processor-D1cbAhQi.js";const a="sparkpost",O="https://api.sparkpost.com/api/v1",T=3e4,x=3,d=r=>[r].flat(),B=S((r={})=>{if(!r.apiKey)throw new w(a,"apiKey");const n={apiKey:r.apiKey,debug:r.debug??!1,endpoint:r.endpoint??O,logger:r.logger,retries:r.retries??x,timeout:r.timeout??T},g=new z,y=C(a,r.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new h(a,"SparkPost API not available or invalid API key");y.debug("Provider initialized successfully")},a)},async isAvailable(){return n.apiKey.length>0},name:a,options:n,async sendEmail(t){try{const o=A(t);if(o.length>0)return{error:new h(a,`Invalid email options: ${o.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),a);const p=d(t.to),u=t.cc?d(t.cc):[],k=t.bcc?d(t.bcc):[],v=[...p.map(e=>({address:l(e)})),...u.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}})),...k.map(e=>({address:{...l(e),header_to:p.map(i=>i.email).join(", ")}}))],s={from:l(t.from),subject:t.subject};if(t.html&&(s.html=t.html),t.text&&(s.text=t.text),t.replyTo){const e=d(t.replyTo)[0];e&&(s.reply_to=e.email)}const c={};if(u.length>0&&(c.CC=u.map(e=>e.email).join(", ")),t.headers)for(const[e,i]of Object.entries(t.headers))c[e]=String(i);Object.keys(c).length>0&&(s.headers=c),t.templateId&&(s.template_id=t.templateId),t.attachments&&t.attachments.length>0&&(s.attachments=await Promise.all(t.attachments.map(async e=>{const i=await K(e,a);return{data:i.content,name:i.filename,type:i.contentType}})));const f={content:s,recipients:v};t.campaignId&&(f.campaign_id=t.campaignId),(t.trackOpens!==void 0||t.trackClicks!==void 0)&&(f.options={click_tracking:t.trackClicks??!0,open_tracking:t.trackOpens??!0});const m=await I(async()=>j(`${n.endpoint}/transmissions`,{headers:{Authorization:n.apiKey,"Content-Type":"application/json"},method:"POST",timeout:n.timeout},JSON.stringify(f)),n.retries);if(!m.success)return{error:m.error??new h(a,"Failed to send email"),success:!1};const{body:b}=m.data;return{data:{messageId:b?.results?.id??P(),provider:a,response:m.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:_(a,"send email",o,y),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{B as default};
@@ -1 +1 @@
1
- import c from"./EmailError-B-sEf3bp.js";import b from"./RequiredOptionError-DuNNY_a5.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as f}from"./retry-ipI5DRJ8.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as T}from"./provider-base-C7PuopYK.js";import{f as d,a as z}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-CMp7qqMI.js";const r="sweego",E="https://api.sweego.com",j=3e4,k=3,H=A((i={})=>{if(!i.apiKey)throw new b(r,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??E,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new P,a=T(r,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const o={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"};a.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(a.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(a.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:h(r,"retrieve email",o,a),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Sweego API not available or invalid API key");a.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.debug("Checking Sweego API availability"),!0}catch(e){return a.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(r,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=z(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,r),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),a.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return a.debug("API request failed when sending email",l.error),{error:l.error??new c(r,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??w();return a.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(r,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
1
+ import c from"./EmailError-CDvYwuqz.js";import b from"./RequiredOptionError-DU2lxzk3.js";import{e as w}from"./generate-message-id-gXAuMz4g.js";import{s as v}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-CylyuRaN.js";import{i as f}from"./retry-CG9iT2wF.js";import{f as I}from"./validate-email-options-mCM9dVug.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{P,h,c as T}from"./provider-base-DjPzWncP.js";import{f as d,a as z}from"./address-formatter-BWR2Dddx.js";import{p as S}from"./attachment-processor-D1cbAhQi.js";const r="sweego",E="https://api.sweego.com",j=3e4,k=3,H=A((i={})=>{if(!i.apiKey)throw new b(r,"apiKey");const s={apiKey:i.apiKey,debug:i.debug??!1,endpoint:i.endpoint??E,retries:i.retries??k,timeout:i.timeout??j,...i.logger&&{logger:i.logger}},m=new P,a=T(r,i.logger);return{features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new c(r,"Email ID is required to retrieve email details"),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const o={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"};a.debug("Retrieving email details",{id:e});const t=await f(async()=>g(`${s.endpoint}/emails/${e}`,{headers:o,method:"GET",timeout:s.timeout}),s.retries);return t.success?(a.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(a.debug("API request failed when retrieving email",t.error),{error:new c(r,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(o){return{error:h(r,"retrieve email",o,a),success:!1}}},async initialize(){await m.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(r,"Sweego API not available or invalid API key");a.debug("Provider initialized successfully")},r)},async isAvailable(){try{return a.debug("Checking Sweego API availability"),!0}catch(e){return a.debug("Error checking availability:",e),!1}},name:r,options:s,async sendEmail(e){try{const o=I(e);if(o.length>0)return{error:new c(r,`Invalid email options: ${o.join(", ")}`),success:!1};await m.ensureInitialized(()=>this.initialize(),r);const t={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:d(e.to)};if(e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.cc&&(t.cc=d(e.cc)),e.bcc&&(t.bcc=d(e.bcc)),e.replyTo&&(t.replyTo=z(e.replyTo)),e.templateId&&(t.templateId=e.templateId,e.templateVariables&&(t.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(t.tags=e.tags),e.headers){const n=v(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,r),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),a.debug("Sending email via Sweego API",{subject:t.subject,to:t.to});const y={Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},l=await f(async()=>g(`${s.endpoint}/send`,{headers:y,method:"POST",timeout:s.timeout},JSON.stringify(t)),s.retries);if(!l.success)return a.debug("API request failed when sending email",l.error),{error:l.error??new c(r,"Failed to send email"),success:!1};const u=l.data?.body,p=u?.messageId??u?.id??w();return a.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:r,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:h(r,"send email",o,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{H as default};
@@ -221,7 +221,7 @@ declare enum SpanStatusCode {
221
221
  /**
222
222
  * The operation contains an error.
223
223
  */
224
- ERROR = 2,
224
+ ERROR = 2
225
225
  }
226
226
  /**
227
227
  * A pointer from the current {@link Span} to another span in the same trace or
@@ -400,7 +400,7 @@ declare enum SpanKind {
400
400
  * broker. Unlike client and server, there is no direct critical path latency
401
401
  * relationship between producer and consumer spans.
402
402
  */
403
- CONSUMER = 4,
403
+ CONSUMER = 4
404
404
  }
405
405
  /**
406
406
  * Options needed for span creation
@@ -0,0 +1,107 @@
1
+ import { E as EmailOptions } from "./types.d-B9295M4_.js";
2
+ /**
3
+ * Options for DKIM signing
4
+ */
5
+ interface DkimOptions {
6
+ /**
7
+ * Signature algorithm. 'rsa-sha256' (default, RFC 6376) or 'ed25519-sha256' (RFC 8463).
8
+ * Default: 'rsa-sha256'
9
+ */
10
+ algorithm?: "ed25519-sha256" | "rsa-sha256";
11
+ /**
12
+ * Body canonicalization algorithm ('simple' or 'relaxed')
13
+ * Default: 'simple'
14
+ */
15
+ bodyCanon?: "relaxed" | "simple";
16
+ /**
17
+ * Domain name used for DKIM signing
18
+ */
19
+ domainName: string;
20
+ /**
21
+ * Header canonicalization algorithm ('simple' or 'relaxed')
22
+ * Default: 'simple'
23
+ */
24
+ headerCanon?: "relaxed" | "simple";
25
+ /**
26
+ * List of header names to ignore when signing
27
+ */
28
+ headersToIgnore?: string[];
29
+ /**
30
+ * Key selector used for DNS lookup
31
+ */
32
+ keySelector: string;
33
+ /**
34
+ * Passphrase for the private key (if encrypted)
35
+ */
36
+ passphrase?: string;
37
+ /**
38
+ * Private key for signing (PEM format)
39
+ * Can be a string with the key content or a path prefixed with 'file://'
40
+ */
41
+ privateKey: string;
42
+ }
43
+ /**
44
+ * Options for S/MIME signing
45
+ */
46
+ interface SmimeSignOptions {
47
+ /**
48
+ * Path to the certificate file (PEM format)
49
+ */
50
+ certificate: string;
51
+ /**
52
+ * Path to intermediate certificates (optional)
53
+ */
54
+ intermediateCerts?: string[];
55
+ /**
56
+ * Signing options flags
57
+ * Reserved for future use
58
+ */
59
+ options?: number;
60
+ /**
61
+ * Passphrase for the private key (if encrypted)
62
+ */
63
+ passphrase?: string;
64
+ /**
65
+ * Path to the private key file (PEM format)
66
+ */
67
+ privateKey: string;
68
+ }
69
+ /**
70
+ * Options for S/MIME encryption
71
+ */
72
+ interface SmimeEncryptOptions {
73
+ /**
74
+ * Encryption algorithm (cipher)
75
+ * Supported: 'aes-256-cbc', 'aes-192-cbc', 'aes-128-cbc'
76
+ * Default: 'aes-256-cbc'
77
+ */
78
+ algorithm?: string;
79
+ /**
80
+ * Certificate(s) for encryption
81
+ * Can be a single certificate path or a map of email -> certificate path
82
+ */
83
+ certificates: string | Record<string, string>;
84
+ }
85
+ /**
86
+ * Interface for email signers
87
+ */
88
+ interface EmailSigner {
89
+ /**
90
+ * Sign an email message
91
+ * @param email The email options to sign
92
+ * @returns The signed email options (may include additional headers or modified content)
93
+ */
94
+ sign: (email: EmailOptions) => Promise<EmailOptions>;
95
+ }
96
+ /**
97
+ * Interface for email encrypters
98
+ */
99
+ interface EmailEncrypter {
100
+ /**
101
+ * Encrypt an email message
102
+ * @param email The email options to encrypt
103
+ * @returns The encrypted email options (content will be encrypted)
104
+ */
105
+ encrypt: (email: EmailOptions) => Promise<EmailOptions>;
106
+ }
107
+ export { DkimOptions as D, EmailSigner as E, SmimeEncryptOptions as S, EmailEncrypter as a, SmimeSignOptions as b };
@@ -1,11 +1,11 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  /**
3
- * Utility type for values that can be promises
4
- */
3
+ * Utility type for values that can be promises
4
+ */
5
5
  type MaybePromise<T> = T | Promise<T>;
6
6
  /**
7
- * Feature flags indicating what capabilities a provider supports
8
- */
7
+ * Feature flags indicating what capabilities a provider supports
8
+ */
9
9
  interface FeatureFlags {
10
10
  attachments?: boolean;
11
11
  batchSending?: boolean;
@@ -18,8 +18,8 @@ interface FeatureFlags {
18
18
  tracking?: boolean;
19
19
  }
20
20
  /**
21
- * Base configuration for all providers
22
- */
21
+ * Base configuration for all providers
22
+ */
23
23
  interface BaseConfig {
24
24
  debug?: boolean;
25
25
  logger?: Console;
@@ -27,104 +27,104 @@ interface BaseConfig {
27
27
  timeout?: number;
28
28
  }
29
29
  /**
30
- * Email address with optional name
31
- */
30
+ * Email address with optional name
31
+ */
32
32
  interface EmailAddress {
33
33
  email: string;
34
34
  name?: string;
35
35
  }
36
36
  /**
37
- * Email attachment
38
- */
37
+ * Email attachment
38
+ */
39
39
  interface Attachment {
40
40
  /**
41
- * Content-ID for inline attachments (used in HTML with cid:)
42
- */
41
+ * Content-ID for inline attachments (used in HTML with cid:)
42
+ */
43
43
  cid?: string;
44
44
  /**
45
- * Attachment content (string, Buffer, or Promise&lt;Uint8Array> for async loading)
46
- * Required if path, href, or raw are not provided
47
- */
45
+ * Attachment content (string, Buffer, or Promise&lt;Uint8Array> for async loading)
46
+ * Required if path, href, or raw are not provided
47
+ */
48
48
  content?: string | Buffer | Promise<Uint8Array>;
49
49
  /**
50
- * Content disposition: 'attachment' (default) or 'inline'
51
- */
50
+ * Content disposition: 'attachment' (default) or 'inline'
51
+ */
52
52
  contentDisposition?: "attachment" | "inline";
53
53
  /**
54
- * MIME type of the attachment
55
- */
54
+ * MIME type of the attachment
55
+ */
56
56
  contentType?: string;
57
57
  /**
58
- * Content transfer encoding (e.g., 'base64', '7bit', 'quoted-printable')
59
- */
58
+ * Content transfer encoding (e.g., 'base64', '7bit', 'quoted-printable')
59
+ */
60
60
  encoding?: string;
61
61
  /**
62
- * Filename for the attachment
63
- */
62
+ * Filename for the attachment
63
+ */
64
64
  filename: string;
65
65
  /**
66
- * Custom headers for this attachment
67
- */
66
+ * Custom headers for this attachment
67
+ */
68
68
  headers?: Record<string, string>;
69
69
  /**
70
- * URL to fetch attachment from
71
- * Alternative to content or path
72
- */
70
+ * URL to fetch attachment from
71
+ * Alternative to content or path
72
+ */
73
73
  href?: string;
74
74
  /**
75
- * HTTP headers to use when fetching from href
76
- */
75
+ * HTTP headers to use when fetching from href
76
+ */
77
77
  httpHeaders?: Record<string, string>;
78
78
  /**
79
- * File path to read attachment from
80
- * Alternative to content
81
- */
79
+ * File path to read attachment from
80
+ * Alternative to content
81
+ */
82
82
  path?: string;
83
83
  /**
84
- * Raw attachment data (alternative to content)
85
- * Can be used for pre-encoded content
86
- */
84
+ * Raw attachment data (alternative to content)
85
+ * Can be used for pre-encoded content
86
+ */
87
87
  raw?: string | Buffer;
88
88
  }
89
89
  /**
90
- * Email tag for categorization
91
- */
90
+ * Email tag for categorization
91
+ */
92
92
  interface EmailTag {
93
93
  name: string;
94
94
  value: string;
95
95
  }
96
96
  /**
97
- * Priority levels for email messages
98
- */
97
+ * Priority levels for email messages
98
+ */
99
99
  type Priority = "high" | "normal" | "low";
100
100
  /**
101
- * Represents the headers of an email message.
102
- * This type is a supertype of the standard `Headers` class, which is used to manage HTTP headers.
103
- * Note that this type does not include methods for modifying the headers,
104
- * such as `append`, `delete`, or `set`. It is intended to be used for
105
- * read-only access to the headers of an email message.
106
- */
101
+ * Represents the headers of an email message.
102
+ * This type is a supertype of the standard `Headers` class, which is used to manage HTTP headers.
103
+ * Note that this type does not include methods for modifying the headers,
104
+ * such as `append`, `delete`, or `set`. It is intended to be used for
105
+ * read-only access to the headers of an email message.
106
+ */
107
107
  type ImmutableHeaders = Omit<Headers, "append" | "delete" | "set">;
108
108
  /**
109
- * Email headers can be either a plain object or an ImmutableHeaders instance
110
- */
109
+ * Email headers can be either a plain object or an ImmutableHeaders instance
110
+ */
111
111
  type EmailHeaders = Record<string, string> | ImmutableHeaders;
112
112
  /**
113
- * Options for calendar event attachments
114
- */
113
+ * Options for calendar event attachments
114
+ */
115
115
  interface CalendarEventOptions {
116
116
  /**
117
- * Alternative text for the calendar event
118
- */
117
+ * Alternative text for the calendar event
118
+ */
119
119
  alternativeText?: string;
120
120
  /**
121
- * Method for the calendar event (e.g., 'REQUEST', 'CANCEL', 'REPLY')
122
- */
121
+ * Method for the calendar event (e.g., 'REQUEST', 'CANCEL', 'REPLY')
122
+ */
123
123
  method?: string;
124
124
  }
125
125
  /**
126
- * Common email options that all providers support
127
- */
126
+ * Common email options that all providers support
127
+ */
128
128
  interface EmailOptions {
129
129
  attachments?: Attachment[];
130
130
  bcc?: EmailAddress | EmailAddress[];
@@ -140,9 +140,9 @@ interface EmailOptions {
140
140
  priority?: Priority;
141
141
  replyTo?: EmailAddress;
142
142
  /**
143
- * The message stream this email belongs to. Used by `Mail.mount` to route the message to a
144
- * mounted provider (e.g. a Postmark broadcast stream). Providers that don't support streams ignore it.
145
- */
143
+ * The message stream this email belongs to. Used by `Mail.mount` to route the message to a
144
+ * mounted provider (e.g. a Postmark broadcast stream). Providers that don't support streams ignore it.
145
+ */
146
146
  stream?: string;
147
147
  subject: string;
148
148
  tags?: string[];
@@ -150,8 +150,8 @@ interface EmailOptions {
150
150
  to: EmailAddress | EmailAddress[];
151
151
  }
152
152
  /**
153
- * Result of sending an email
154
- */
153
+ * Result of sending an email
154
+ */
155
155
  interface EmailResult {
156
156
  messageId: string;
157
157
  provider?: string;
@@ -160,47 +160,47 @@ interface EmailResult {
160
160
  timestamp: Date;
161
161
  }
162
162
  /**
163
- * Receipt type for email sending results
164
- * Uses discriminated union for type safety
165
- */
163
+ * Receipt type for email sending results
164
+ * Uses discriminated union for type safety
165
+ */
166
166
  type Receipt = {
167
167
  /**
168
- * The unique identifier for the message that was sent
169
- */
168
+ * The unique identifier for the message that was sent
169
+ */
170
170
  readonly messageId: string;
171
171
  /**
172
- * Optional provider name
173
- */
172
+ * Optional provider name
173
+ */
174
174
  readonly provider?: string;
175
175
  /**
176
- * Optional response data from provider
177
- */
176
+ * Optional response data from provider
177
+ */
178
178
  readonly response?: unknown;
179
179
  /**
180
- * Indicates that the email was sent successfully
181
- */
180
+ * Indicates that the email was sent successfully
181
+ */
182
182
  readonly successful: true;
183
183
  /**
184
- * Timestamp when email was sent
185
- */
184
+ * Timestamp when email was sent
185
+ */
186
186
  readonly timestamp: Date;
187
187
  } | {
188
188
  /**
189
- * An array of error messages that occurred during the sending process
190
- */
189
+ * An array of error messages that occurred during the sending process
190
+ */
191
191
  readonly errorMessages: ReadonlyArray<string>;
192
192
  /**
193
- * Optional provider name
194
- */
193
+ * Optional provider name
194
+ */
195
195
  readonly provider?: string;
196
196
  /**
197
- * Indicates that the email failed to send
198
- */
197
+ * Indicates that the email failed to send
198
+ */
199
199
  readonly successful: false;
200
200
  };
201
201
  /**
202
- * Generic result type
203
- */
202
+ * Generic result type
203
+ */
204
204
  interface Result<T = unknown> {
205
205
  data?: T;
206
206
  error?: Error | unknown;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Why a recipient address is suppressed from future sends.
3
+ */
4
+ type SuppressionReason = "bounce" | "complaint" | "manual" | "unsubscribe";
5
+ /**
6
+ * A suppression-list entry.
7
+ */
8
+ interface SuppressionEntry {
9
+ /**
10
+ * The normalized (lower-cased) email address.
11
+ */
12
+ address: string;
13
+ /**
14
+ * When the address was added.
15
+ */
16
+ createdAt: Date;
17
+ /**
18
+ * Optional free-form context (e.g. the bounce sub-type, or who suppressed it manually).
19
+ */
20
+ metadata?: Record<string, unknown>;
21
+ /**
22
+ * Why the address was suppressed.
23
+ */
24
+ reason: SuppressionReason;
25
+ }
26
+ /**
27
+ * A pluggable suppression store. Implementations back the in-memory default with a durable store
28
+ * (Redis, Postgres, `unstorage`, a provider's native suppression API, etc.).
29
+ *
30
+ * Addresses must be matched case-insensitively; implementations are expected to normalize on write.
31
+ */
32
+ interface SuppressionStore {
33
+ /**
34
+ * Adds (or refreshes) an address on the suppression list.
35
+ * @param address The recipient address.
36
+ * @param reason Why it is suppressed.
37
+ * @param metadata Optional context to persist with the entry.
38
+ */
39
+ add: (address: string, reason: SuppressionReason, metadata?: Record<string, unknown>) => Promise<void> | void;
40
+ /**
41
+ * Returns the suppression entry for an address, or `undefined` when it is not suppressed.
42
+ * @param address The recipient address.
43
+ */
44
+ get: (address: string) => (SuppressionEntry | undefined) | Promise<SuppressionEntry | undefined>;
45
+ /**
46
+ * Returns whether an address is currently suppressed.
47
+ * @param address The recipient address.
48
+ */
49
+ has: (address: string) => boolean | Promise<boolean>;
50
+ /**
51
+ * Lists all suppression entries. Optional — stores backed by huge datasets may omit it.
52
+ */
53
+ list?: () => Iterable<SuppressionEntry> | Promise<Iterable<SuppressionEntry>>;
54
+ /**
55
+ * Removes an address from the suppression list.
56
+ * @param address The recipient address.
57
+ * @returns `true` when an entry was removed.
58
+ */
59
+ remove: (address: string) => boolean | Promise<boolean>;
60
+ }
61
+ export { SuppressionReason as S, SuppressionEntry as a, SuppressionStore as b };
@@ -0,0 +1,51 @@
1
+ import { b as Receipt, B as BaseConfig, E as EmailOptions, a as EmailResult } from "./types.d-B9295M4_.js";
2
+ /**
3
+ * Random delay range configuration
4
+ */
5
+ interface RandomDelayRange {
6
+ max: number;
7
+ min: number;
8
+ }
9
+ /**
10
+ * Mock configuration for testing
11
+ */
12
+ interface MockConfig extends BaseConfig {
13
+ /**
14
+ * Default response to return for send operations
15
+ */
16
+ defaultResponse?: Receipt;
17
+ /**
18
+ * Delay in milliseconds before resolving (default: 0)
19
+ * Useful for testing async behavior
20
+ */
21
+ delay?: number;
22
+ /**
23
+ * Failure rate (0-1) for simulating random failures (default: 0)
24
+ * 0 = never fail, 1 = always fail
25
+ */
26
+ failureRate?: number;
27
+ /**
28
+ * Random delay range in milliseconds
29
+ * When set, delay will be randomly chosen between min and max
30
+ */
31
+ randomDelayRange?: RandomDelayRange;
32
+ /**
33
+ * Whether to simulate failures (default: false)
34
+ * When true, sendEmail will return an error
35
+ */
36
+ simulateFailure?: boolean;
37
+ }
38
+ /**
39
+ * Mock-specific email options
40
+ */
41
+ type MockEmailOptions = EmailOptions;
42
+ /**
43
+ * Stored email entry in mock provider
44
+ */
45
+ interface MockEmailEntry {
46
+ id: string;
47
+ options: EmailOptions;
48
+ result: EmailResult;
49
+ timestamp: Date;
50
+ }
51
+ export { MockConfig as M, RandomDelayRange as R, MockEmailEntry as a, MockEmailOptions as b };