@visulima/email 2.1.6 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/crypto/index.d.ts +183 -183
- package/dist/crypto/index.js +1 -1
- package/dist/deliverability/dmarc-report.d.ts +43 -43
- package/dist/deliverability/dmarc-report.js +1 -1
- package/dist/deliverability/index.d.ts +201 -201
- package/dist/events/index.d.ts +17 -17
- package/dist/inbound/index.d.ts +180 -180
- package/dist/index.d.ts +35 -46
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +213 -216
- package/dist/middleware/index.js +1 -1
- package/dist/packem_shared/{DkimSigner-CiLBaXrg.js → DkimSigner-sLcIw9bp.js} +6 -6
- package/dist/packem_shared/{DraftMailMessage-CGTVuy2z.js → DraftMailMessage-C3YTXqWo.js} +1 -1
- package/dist/packem_shared/EmailError-CDvYwuqz.js +1 -0
- package/dist/packem_shared/{Mail-CYAwMRnX.js → Mail-CIyxkmxu.js} +1 -1
- package/dist/packem_shared/MailMessage-DuEXJiCg.js +1 -0
- package/dist/packem_shared/{RequiredOptionError-DuNNY_a5.js → RequiredOptionError-DU2lxzk3.js} +1 -1
- package/dist/packem_shared/SmimeEncrypter-CzTbQM-z.js +6 -0
- package/dist/packem_shared/SmimeSigner-DjLShaOw.js +8 -0
- package/dist/packem_shared/{ahaSendProvider-DSuZIzaQ.js → ahaSendProvider-br1yB2un.js} +1 -1
- package/dist/packem_shared/arcMessageSignatureBase-D54jQIWu.js +17 -0
- package/dist/packem_shared/attachment-processor-D1cbAhQi.js +1 -0
- package/dist/packem_shared/{autoSendProvider-DqAoelWR.js → autoSendProvider-BSP8ueOC.js} +1 -1
- package/dist/packem_shared/{awsSesProvider-ClK1FUln.js → awsSesProvider-zRICW1pH.js} +13 -13
- package/dist/packem_shared/azureProvider-DwN4c5dC.js +1 -0
- package/dist/packem_shared/{brevoProvider-CIzuIDlt.js → brevoProvider-C491beE_.js} +1 -1
- package/dist/packem_shared/{build-mime-message-BW5FQ2Bt.js → build-mime-message-DT67qfMp.js} +1 -1
- package/dist/packem_shared/{circuitBreakerMiddleware-D2SA_07f.js → circuitBreakerMiddleware-N0CKF90q.js} +1 -1
- package/dist/packem_shared/{cloudflareEmailProvider-B8mOEl3N.js → cloudflareEmailProvider-8JxzLbpX.js} +1 -1
- package/dist/packem_shared/{createTestEmail-f12yLlWn.js → createTestEmail-D_ksEez3.js} +1 -1
- package/dist/packem_shared/dedupeMiddleware-CYYI_O7S.js +1 -0
- package/dist/packem_shared/{detectMimeType-DFH3kp6K.js → detectMimeType-CmYmWDXE.js} +1 -1
- package/dist/packem_shared/event-bus.d-BNQA-FZE.d.ts +104 -0
- package/dist/packem_shared/{failoverProvider-BgX6zfnY.js → failoverProvider-6qwE_HSJ.js} +1 -1
- package/dist/packem_shared/generate-boundary-0xGe9GqK.js +1 -0
- package/dist/packem_shared/{httpProvider-aBfTXyCT.js → httpProvider-BqrdZhGw.js} +1 -1
- package/dist/packem_shared/index-Gd7m-UQA.js +11 -0
- package/dist/packem_shared/{infobipProvider-DxzsONUX.js → infobipProvider-C2FU6VMP.js} +1 -1
- package/dist/packem_shared/isValidSigningCertUrl-DNxPA0Q-.js +3 -0
- package/dist/packem_shared/{loopsProvider-QBsAH6Ee.js → loopsProvider-Bz63so6m.js} +1 -1
- package/dist/packem_shared/mail.d-xKtvoKMK.d.ts +909 -0
- package/dist/packem_shared/{mailCrabProvider-DRE5snM9.js → mailCrabProvider-bkQy-2a1.js} +1 -1
- package/dist/packem_shared/{mailPaceProvider-DCa-4ghl.js → mailPaceProvider-S1AB-AYq.js} +1 -1
- package/dist/packem_shared/{mailchannelsProvider-GiwkYBdD.js → mailchannelsProvider-B_K6X4VY.js} +1 -1
- package/dist/packem_shared/{mailerSendProvider-RK6IbUrL.js → mailerSendProvider-DPEww2H1.js} +1 -1
- package/dist/packem_shared/mailgunProvider-DKxzVbDW.js +1 -0
- package/dist/packem_shared/mailjetProvider-C2TQcujL.js +1 -0
- package/dist/packem_shared/{mailomatProvider-DPDpVS8r.js → mailomatProvider-B8-5bQsu.js} +1 -1
- package/dist/packem_shared/{mailtrapProvider-DtrS4Q34.js → mailtrapProvider-DW7TLOdG.js} +1 -1
- package/dist/packem_shared/{make-request-B9XjBynA.js → make-request-CylyuRaN.js} +1 -1
- package/dist/packem_shared/{mandrillProvider-B84zH-eV.js → mandrillProvider-S-0lKNGd.js} +1 -1
- package/dist/packem_shared/{mockProvider-Behywbl1.js → mockProvider-BAl292mW.js} +1 -1
- package/dist/packem_shared/{netcoreProvider-D-wtCyJj.js → netcoreProvider-DajMprlo.js} +1 -1
- package/dist/packem_shared/{nodemailerProvider-BFHobXxt.js → nodemailerProvider-DRo0lJ6g.js} +1 -1
- package/dist/packem_shared/{opentelemetryProvider-ByHC01ub.js → opentelemetryProvider-C6spx2CD.js} +1 -1
- package/dist/packem_shared/{outlook365Provider-Btk4Emig.js → outlook365Provider-B0o7UZBW.js} +1 -1
- package/dist/packem_shared/{plunkProvider-Bw8e6460.js → plunkProvider-DJzEUEtU.js} +1 -1
- package/dist/packem_shared/{postalProvider-CT8zr89z.js → postalProvider-DHFjFE3Y.js} +1 -1
- package/dist/packem_shared/{postmarkProvider-CQSqZWDs.js → postmarkProvider-Dt1EGGBA.js} +1 -1
- package/dist/packem_shared/{provider-base-C7PuopYK.js → provider-base-DjPzWncP.js} +1 -1
- package/dist/packem_shared/{provider.d-J-y6iogK.d.ts → provider.d-Cx5YQJdP.d.ts} +9 -9
- package/dist/packem_shared/{resendProvider-drJYlvLP.js → resendProvider-qjI86j_d.js} +1 -1
- package/dist/packem_shared/{retry-ipI5DRJ8.js → retry-CG9iT2wF.js} +1 -1
- package/dist/packem_shared/{roundRobinProvider-D1by5KGW.js → roundRobinProvider-CO5YvhgR.js} +1 -1
- package/dist/packem_shared/{scalewayProvider-DU5gXQrl.js → scalewayProvider-CihQKhw6.js} +1 -1
- package/dist/packem_shared/{sendGridProvider-BuTbEXW8.js → sendGridProvider-Dkc5AKlC.js} +1 -1
- package/dist/packem_shared/{smtpProvider-5MI3-EPh.js → smtpProvider-CIXMxPu-.js} +12 -12
- package/dist/packem_shared/{sparkpostProvider-UAsFYIjP.js → sparkpostProvider-CKxQhpyB.js} +1 -1
- package/dist/packem_shared/{sweegoProvider-SUz0LIcA.js → sweegoProvider-DjmAs6La.js} +1 -1
- package/dist/packem_shared/{tracer.d-MU42G1jG.d.ts → tracer.d-sb5yrt_n.d.ts} +2 -2
- package/dist/packem_shared/types.d-B0t3PQ3t.d.ts +107 -0
- package/dist/packem_shared/{types.d-ejzh-xBP.d.ts → types.d-B9295M4_.d.ts} +82 -82
- package/dist/packem_shared/types.d-BzoHR9nB.d.ts +61 -0
- package/dist/packem_shared/types.d-C5geVKes.d.ts +51 -0
- package/dist/packem_shared/types.d-GKqPNk0I.d.ts +24 -0
- package/dist/packem_shared/types.d-I-KeZ5w2.d.ts +9 -0
- package/dist/packem_shared/types.d-kHO4kX9q.d.ts +69 -0
- package/dist/packem_shared/utils-DjEtR3qT.js +1 -0
- package/dist/packem_shared/verifyMailgunWebhook-DNk080BF.js +1 -0
- package/dist/packem_shared/verifyPostmarkWebhook-B4OIEHQF.js +1 -0
- package/dist/packem_shared/verifyResendWebhook-C7E32LZ1.js +1 -0
- package/dist/packem_shared/verifySendGridWebhook-1l9bqIMw.js +1 -0
- package/dist/packem_shared/withEvents-CytsykaK.js +1 -0
- package/dist/packem_shared/{withSuppression-DBaZDMAr.js → withSuppression-BoaO4Qdz.js} +1 -1
- package/dist/packem_shared/{zeptomailProvider-DXNX9mG_.js → zeptomailProvider-DSTC9pUi.js} +1 -1
- package/dist/providers/ahasend/index.d.ts +18 -18
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/autosend/index.d.ts +30 -30
- package/dist/providers/autosend/index.js +1 -1
- package/dist/providers/aws-ses/index.d.ts +20 -20
- package/dist/providers/aws-ses/index.js +1 -1
- package/dist/providers/azure/index.d.ts +26 -26
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.d.ts +35 -35
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.d.ts +25 -25
- package/dist/providers/cloudflare-email/index.js +1 -1
- package/dist/providers/failover/index.d.ts +14 -14
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/http/index.d.ts +15 -15
- package/dist/providers/http/index.js +1 -1
- package/dist/providers/infobip/index.d.ts +28 -28
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/loops/index.d.ts +25 -25
- package/dist/providers/loops/index.js +1 -1
- package/dist/providers/mailchannels/index.d.ts +13 -13
- package/dist/providers/mailchannels/index.js +1 -1
- package/dist/providers/mailcrab/index.d.ts +17 -17
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.d.ts +24 -24
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.d.ts +37 -37
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.d.ts +36 -36
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.d.ts +20 -20
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.d.ts +24 -24
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.d.ts +22 -22
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.d.ts +36 -36
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/mock/index.d.ts +8 -8
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/netcore/index.d.ts +17 -17
- package/dist/providers/netcore/index.js +1 -1
- package/dist/providers/nodemailer/index.d.ts +22 -22
- package/dist/providers/nodemailer/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +20 -20
- package/dist/providers/opentelemetry/index.js +1 -1
- package/dist/providers/outlook365/index.d.ts +82 -82
- package/dist/providers/outlook365/index.js +1 -1
- package/dist/providers/plunk/index.d.ts +18 -18
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.d.ts +24 -24
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.d.ts +30 -30
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.d.ts +24 -24
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +14 -14
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/scaleway/index.d.ts +22 -22
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.d.ts +25 -25
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.d.ts +11 -11
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sparkpost/index.d.ts +21 -21
- package/dist/providers/sparkpost/index.js +1 -1
- package/dist/providers/sweego/index.d.ts +20 -20
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.d.ts +17 -17
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/queue/bullmq-queue.d.ts +26 -26
- package/dist/queue/index.d.ts +86 -86
- package/dist/queue/pg-boss-queue.d.ts +13 -13
- package/dist/queue/sqs-queue.d.ts +20 -20
- package/dist/queue/unstorage-queue.d.ts +47 -47
- package/dist/queue/unstorage-queue.js +1 -1
- package/dist/render/cid.d.ts +12 -12
- package/dist/render/css-inline.d.ts +12 -12
- package/dist/render/css-inline.js +1 -1
- package/dist/render/dark-mode.d.ts +12 -12
- package/dist/render/preheader.d.ts +16 -16
- package/dist/template-engines/handlebars.d.ts +19 -19
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/html-to-text.d.ts +12 -12
- package/dist/template-engines/html-to-text.js +1 -1
- package/dist/template-engines/i18n.d.ts +43 -43
- package/dist/template-engines/i18n.js +1 -1
- package/dist/template-engines/jsx-email.d.ts +8 -8
- package/dist/template-engines/jsx-email.js +1 -1
- package/dist/template-engines/liquid.d.ts +9 -9
- package/dist/template-engines/liquid.js +1 -1
- package/dist/template-engines/mjml.d.ts +9 -9
- package/dist/template-engines/mjml.js +1 -1
- package/dist/template-engines/react-email.d.ts +8 -8
- package/dist/template-engines/react-email.js +1 -1
- package/dist/template-engines/vue-email.d.ts +8 -8
- package/dist/template-engines/vue-email.js +1 -1
- package/dist/test/index.d.ts +89 -89
- package/dist/test/index.js +1 -1
- package/dist/utils/cache.d.ts +27 -27
- package/dist/utils/format-email-address.d.ts +6 -6
- package/dist/utils/format-email-address.js +1 -1
- package/dist/utils/normalize-email-aliases.d.ts +19 -19
- package/dist/utils/parse-address.d.ts +16 -16
- package/dist/utils/parse-eml.d.ts +18 -18
- package/dist/utils/result.d.ts +30 -30
- package/dist/utils/result.js +1 -1
- package/dist/utils/validation/check-feature-support.d.ts +33 -33
- package/dist/utils/validation/validate-email.d.ts +4 -4
- package/dist/webhooks/index.d.ts +134 -134
- package/dist/webhooks/index.js +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/EmailError-B-sEf3bp.js +0 -1
- package/dist/packem_shared/MailMessage-DQRgs5Dz.js +0 -1
- package/dist/packem_shared/SmimeEncrypter-DavopRlE.js +0 -6
- package/dist/packem_shared/SmimeSigner-0onWksAv.js +0 -8
- package/dist/packem_shared/arcMessageSignatureBase-DDLEHW2E.js +0 -17
- package/dist/packem_shared/attachment-processor-CMp7qqMI.js +0 -1
- package/dist/packem_shared/azureProvider-Cw_Tmde6.js +0 -1
- package/dist/packem_shared/dedupeMiddleware-B6ajWOTi.js +0 -1
- package/dist/packem_shared/event-bus.d-DEl3w_EW.d.ts +0 -104
- package/dist/packem_shared/generate-boundary-DQbzDiOI.js +0 -1
- package/dist/packem_shared/index-BoZvzveg.js +0 -11
- package/dist/packem_shared/isValidSigningCertUrl-Bii1AMGC.js +0 -3
- package/dist/packem_shared/mail.d-B9SSqyy0.d.ts +0 -909
- package/dist/packem_shared/mailgunProvider-D9HUWGKN.js +0 -1
- package/dist/packem_shared/mailjetProvider-DelLs2Vt.js +0 -1
- package/dist/packem_shared/types.d-BId55FW2.d.ts +0 -107
- package/dist/packem_shared/types.d-CmoWvdZi.d.ts +0 -61
- package/dist/packem_shared/types.d-DCkecJse.d.ts +0 -51
- package/dist/packem_shared/types.d-Mpu0HZoG.d.ts +0 -24
- package/dist/packem_shared/types.d-lcJZmwRK.d.ts +0 -69
- package/dist/packem_shared/types.d-nyR1ty1Q.d.ts +0 -9
- package/dist/packem_shared/utils-BfYfPB_I.js +0 -1
- package/dist/packem_shared/verifyMailgunWebhook-Cwl0OD3P.js +0 -1
- package/dist/packem_shared/verifyPostmarkWebhook-C72ZvbrG.js +0 -1
- package/dist/packem_shared/verifyResendWebhook-YK2zNDXR.js +0 -1
- package/dist/packem_shared/verifySendGridWebhook-Dbwc1tfG.js +0 -1
- package/dist/packem_shared/withEvents-CCVblSqj.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as j}from"node:module";import u from"./EmailError-B-sEf3bp.js";import w from"./RequiredOptionError-DuNNY_a5.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{s as R}from"./headers-to-record-De1Eg951.js";import{m as h}from"./make-request-B9XjBynA.js";import{i as T}from"./retry-ipI5DRJ8.js";import{f as S}from"./validate-email-options-mCM9dVug.js";import{defineProvider as _}from"./defineProvider-C9q-7iwt.js";import{P as z,h as k,c as E}from"./provider-base-C7PuopYK.js";import{e as b,g as I}from"./address-formatter-BWR2Dddx.js";import{a as U}from"./attachment-processor-CMp7qqMI.js";const A=j(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[i,n]=m.versions.node.split(".").map(Number);if(i>22||i===22&&n>=3||i===20&&n>=16)return m.getBuiltinModule(s)}return A(s)},{Buffer:y}=C("node:buffer"),a="mailgun",q="https://api.mailgun.net",M=3e4,K=3,B=s=>{const i=[];for(const[n,r]of Object.entries(s))if(r!=null)if(Array.isArray(r))for(const e of r)i.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(e))}`);else typeof r=="object"?i.push(`${encodeURIComponent(n)}=${encodeURIComponent(JSON.stringify(r))}`):i.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`);return i.join("&")},X=_((s={})=>{if(!s.apiKey)throw new w(a,"apiKey");if(!s.domain)throw new w(a,"domain");const i={apiKey:s.apiKey,debug:s.debug??!1,domain:s.domain,endpoint:s.endpoint??q,retries:s.retries??K,timeout:s.timeout??M,...s.logger&&{logger:s.logger}},n=new z,r=E(a,s.logger);return{endpoint:i.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new u(a,"Email ID is required to retrieve email details"),success:!1};await n.ensureInitialized(()=>this.initialize(),a);const o={Authorization:`Basic ${y.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};r.debug("Retrieving email details",{id:e});const t=await T(async()=>h(`${i.endpoint}/v3/${i.domain}/events?message-id=${encodeURIComponent(e)}&limit=1`,{headers:o,method:"GET",timeout:i.timeout}),i.retries);if(!t.success)return r.debug("API request failed when retrieving email",t.error),{error:new u(a,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1};r.debug("Email details retrieved successfully");const p=t.data?.items??[],g=p.length>0?p[0]:void 0;return{data:g?.message?.headers??g?.storage??void 0,success:!0}}catch(o){return{error:k(a,"retrieve email",o,r),success:!1}}},async initialize(){await n.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(a,"Mailgun API not available or invalid API key/domain");r.debug("Provider initialized successfully")},a)},async isAvailable(){try{const e={Authorization:`Basic ${y.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/json"};r.debug("Checking Mailgun API availability");const o=await h(`${i.endpoint}/v3/domains/${i.domain}`,{headers:e,method:"GET",timeout:i.timeout});if(r.debug("Mailgun API availability check response:",{error:o.error instanceof Error?o.error.message:void 0,statusCode:o.data?.statusCode,success:o.success}),!o.success||!o.data||typeof o.data!="object")return!1;const{statusCode:t}=o.data;return typeof t=="number"&&t>=200&&t<300}catch(e){return r.debug("Error checking availability:",e),!1}},name:a,options:i,async sendEmail(e){try{const o=S(e);if(o.length>0)return{error:new u(a,`Invalid email options: ${o.join(", ")}`),success:!1};await n.ensureInitialized(()=>this.initialize(),a);const t={from:I(e.from),to:b(e.to).join(",")};if(e.subject&&(t.subject=e.subject),e.cc&&(t.cc=b(e.cc).join(",")),e.bcc&&(t.bcc=b(e.bcc).join(",")),e.replyTo&&(t["h:Reply-To"]=I(e.replyTo)),e.html&&(t.html=e.html),e.text&&(t.text=e.text),e.template&&(t.template=e.template,e.templateVariables))for(const[d,c]of Object.entries(e.templateVariables))t[`v:${d}`]=c;if(e.tags&&e.tags.length>0&&(t["o:tag"]=e.tags),e.campaignId&&(t["o:campaign"]=e.campaignId),e.deliveryTime&&(t["o:deliverytime"]=typeof e.deliveryTime=="number"?new Date(e.deliveryTime*1e3).toUTCString():e.deliveryTime),e.clickTracking!==void 0&&(t["o:clicktracking"]=e.clickTracking?"yes":"no"),e.openTracking!==void 0&&(t["o:tracking"]=e.openTracking?"yes":"no"),e.unsubscribeTracking!==void 0&&(t["o:tracking-clicks"]=e.unsubscribeTracking?"yes":"no"),e.testMode&&(t["o:testmode"]="yes"),e.requireTls&&(t["o:require-tls"]="yes"),e.skipVerification&&(t["o:skip-verification"]="yes"),e.headers){const d=R(e.headers);for(const[c,f]of Object.entries(d))t[`h:${c}`]=f}if(e.attachments&&e.attachments.length>0){const d=await Promise.all(e.attachments.map((c,f)=>U(c,a,f)));for(const c of d)t[c.key]=c.content}r.debug("Sending email via Mailgun API",{subject:t.subject,to:t.to});const p={Authorization:`Basic ${y.from(`api:${i.apiKey}`).toString("base64")}`,"Content-Type":"application/x-www-form-urlencoded"},g=B(t),l=await T(async()=>h(`${i.endpoint}/v3/${i.domain}/messages`,{headers:p,method:"POST",timeout:i.timeout},g),i.retries);if(!l.success)return r.debug("API request failed when sending email",l.error),{error:l.error??new u(a,"Failed to send email"),success:!1};const v=l.data?.body?.id??P();return r.debug("Email sent successfully",{messageId:v}),{data:{messageId:v,provider:a,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(o){return{error:k(a,"send email",o,r),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as S}from"node:module";import u from"./EmailError-B-sEf3bp.js";import h from"./RequiredOptionError-DuNNY_a5.js";import{e as E}from"./generate-message-id-gXAuMz4g.js";import{s as M}from"./headers-to-record-De1Eg951.js";import{m as g}from"./make-request-B9XjBynA.js";import{i as b}from"./retry-ipI5DRJ8.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as z}from"./defineProvider-C9q-7iwt.js";import{P as D,h as v,c as B}from"./provider-base-C7PuopYK.js";import{h as f,i as T}from"./address-formatter-BWR2Dddx.js";import{p as R}from"./attachment-processor-CMp7qqMI.js";const P=S(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[a,c]=d.versions.node.split(".").map(Number);if(a>22||a===22&&c>=3||a===20&&c>=16)return d.getBuiltinModule(s)}return P(s)},{Buffer:p}=A("node:buffer"),i="mailjet",k="https://api.mailjet.com",q=3e4,K=3,X=z((s={})=>{if(!s.apiKey)throw new h(i,"apiKey");if(!s.apiSecret)throw new h(i,"apiSecret");const a={apiKey:s.apiKey,apiSecret:s.apiSecret,debug:s.debug??!1,endpoint:s.endpoint??k,retries:s.retries??K,timeout:s.timeout??q,...s.logger&&{logger:s.logger}},c=new D,o=B(i,s.logger);return{endpoint:a.endpoint,features:{attachments:!0,batchSending:!0,customHeaders:!0,html:!0,replyTo:!0,scheduling:!0,tagging:!0,templates:!0,tracking:!0},async getEmail(e){try{if(!e)return{error:new u(i,"Email ID is required to retrieve email details"),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const r={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const t=await b(async()=>g(`${a.endpoint}/v3.1/REST/message/${e}`,{headers:r,method:"GET",timeout:a.timeout}),a.retries);return t.success?(o.debug("Email details retrieved successfully"),{data:t.data?.body,success:!0}):(o.debug("API request failed when retrieving email",t.error),{error:new u(i,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(r){return{error:v(i,"retrieve email",r,o),success:!1}}},async initialize(){await c.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(i,"Mailjet API not available or invalid API credentials");o.debug("Provider initialized successfully")},i)},async isAvailable(){try{const e={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"};o.debug("Checking Mailjet API availability");const r=await g(`${a.endpoint}/v3.1/REST/user`,{headers:e,method:"GET",timeout:a.timeout});return o.debug("Mailjet API availability check response:",{error:r.error instanceof Error?r.error.message:void 0,statusCode:r.data?.statusCode,success:r.success}),!!(r.success&&r.data&&typeof r.data=="object"&&"statusCode"in r.data&&typeof r.data.statusCode=="number"&&r.data.statusCode>=200&&r.data.statusCode<300)}catch(e){return o.debug("Error checking availability:",e),!1}},name:i,options:a,async sendEmail(e){try{const r=_(e);if(r.length>0)return{error:new u(i,`Invalid email options: ${r.join(", ")}`),success:!1};await c.ensureInitialized(()=>this.initialize(),i);const t={From:T(e.from),Subject:e.subject,To:f(e.to)};if(e.html&&(t.HTMLPart=e.html),e.text&&(t.TextPart=e.text),e.cc&&(t.Cc=f(e.cc)),e.bcc&&(t.Bcc=f(e.bcc)),e.replyTo&&(t.ReplyTo=T(e.replyTo)),e.templateId&&(t.TemplateID=e.templateId,t.TemplateLanguage=e.templateLanguage??!0,e.templateVariables&&(t.Variables=e.templateVariables)),e.customId&&(t.CustomID=e.customId),e.eventPayload&&(t.EventPayload=e.eventPayload),e.campaign&&(t.Campaign=e.campaign),e.deduplicateCampaign!==void 0&&(t.DeduplicateCampaign=e.deduplicateCampaign),e.deliveryTime&&(t.Deliverytime=new Date(e.deliveryTime*1e3).toISOString()),e.priority!==void 0&&(t.Priority=e.priority),e.urlTags&&(t.URLTags=e.urlTags),e.tags&&e.tags.length>0&&(t.CustomCampaign=e.tags.join(",")),e.headers){const n=M(e.headers),m=[];for(const[C,I]of Object.entries(n))m.push({Name:C,Value:String(I)});m.length>0&&(t.Headers=m)}e.attachments&&e.attachments.length>0&&(t.Attachments=await Promise.all(e.attachments.map(async n=>({Base64Content:await R(n,i),ContentType:n.contentType??"application/octet-stream",Filename:n.filename,...n.cid&&{ContentID:n.cid}}))));const j={Messages:[t]};o.debug("Sending email via Mailjet API",{subject:t.Subject,to:t.To});const w={Authorization:`Basic ${p.from(`${a.apiKey}:${a.apiSecret}`).toString("base64")}`,"Content-Type":"application/json"},l=await b(async()=>g(`${a.endpoint}/v3.1/send`,{headers:w,method:"POST",timeout:a.timeout},JSON.stringify(j)),a.retries);if(!l.success)return o.debug("API request failed when sending email",l.error),{error:l.error??new u(i,"Failed to send email"),success:!1};const y=l.data?.body?.Messages?.[0]?.To?.[0]?.MessageID?.toString()??E();return o.debug("Email sent successfully",{messageId:y}),{data:{messageId:y,provider:i,response:l.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:v(i,"send email",r,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{X as default};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { E as EmailOptions } from "./types.d-ejzh-xBP.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,61 +0,0 @@
|
|
|
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 };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { b as Receipt, B as BaseConfig, E as EmailOptions, a as EmailResult } from "./types.d-ejzh-xBP.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 };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { E as EmailOptions, a as EmailResult, R as Result } from "./types.d-ejzh-xBP.js";
|
|
2
|
-
/**
|
|
3
|
-
* The terminal send function a middleware wraps — ultimately the provider's `sendEmail`.
|
|
4
|
-
*/
|
|
5
|
-
type SendFunction = (options: EmailOptions) => Promise<Result<EmailResult>>;
|
|
6
|
-
/**
|
|
7
|
-
* A send middleware. Receives the (fully-resolved) message and the `next` function in the chain;
|
|
8
|
-
* may short-circuit, retry, mutate, or observe.
|
|
9
|
-
*
|
|
10
|
-
* Middlewares run in registration order, wrapping outward-in (the first registered runs first and is
|
|
11
|
-
* the outermost wrapper around the provider call).
|
|
12
|
-
* @param options The resolved email options.
|
|
13
|
-
* @param next The next middleware (or the provider send) in the chain.
|
|
14
|
-
* @returns The send result.
|
|
15
|
-
*/
|
|
16
|
-
type Middleware = (options: EmailOptions, next: SendFunction) => Promise<Result<EmailResult>>;
|
|
17
|
-
/**
|
|
18
|
-
* Composes a middleware stack around a terminal send function.
|
|
19
|
-
* @param middlewares The middlewares, in registration order.
|
|
20
|
-
* @param terminal The provider send call at the centre of the chain.
|
|
21
|
-
* @returns A single {@link SendFunction} that runs the whole chain.
|
|
22
|
-
*/
|
|
23
|
-
declare const composeMiddleware: (middlewares: ReadonlyArray<Middleware>, terminal: SendFunction) => SendFunction;
|
|
24
|
-
export { Middleware as M, SendFunction as S, composeMiddleware as c };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { E as EmailOptions } from "./types.d-ejzh-xBP.js";
|
|
2
|
-
/**
|
|
3
|
-
* A queued email job.
|
|
4
|
-
*/
|
|
5
|
-
interface QueueJob {
|
|
6
|
-
/**
|
|
7
|
-
* Number of delivery attempts so far.
|
|
8
|
-
*/
|
|
9
|
-
attempts: number;
|
|
10
|
-
/**
|
|
11
|
-
* Unique job id.
|
|
12
|
-
*/
|
|
13
|
-
id: string;
|
|
14
|
-
/**
|
|
15
|
-
* The message to send.
|
|
16
|
-
*/
|
|
17
|
-
message: EmailOptions;
|
|
18
|
-
/**
|
|
19
|
-
* Earliest time (ms since epoch) the job may be delivered. Used for `scheduledAt` and retry backoff.
|
|
20
|
-
*/
|
|
21
|
-
scheduledAt: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Options when enqueueing a message.
|
|
25
|
-
*/
|
|
26
|
-
interface EnqueueOptions {
|
|
27
|
-
/**
|
|
28
|
-
* Deliver no earlier than this time. Accepts a `Date` or epoch milliseconds.
|
|
29
|
-
*/
|
|
30
|
-
scheduledAt?: Date | number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A durable email queue. The in-memory default (`MemoryQueue`) implements this; adapters can
|
|
34
|
-
* back it with Redis/BullMQ, pg-boss, SQS, or `unstorage`.
|
|
35
|
-
*
|
|
36
|
-
* Delivery is reserve → ack/retry: {@link EmailQueue.reserve} hands out a job and hides it for a
|
|
37
|
-
* visibility window; the worker then {@link EmailQueue.ack}s it on success or {@link EmailQueue.retry}s
|
|
38
|
-
* it on failure.
|
|
39
|
-
*/
|
|
40
|
-
interface EmailQueue {
|
|
41
|
-
/**
|
|
42
|
-
* Marks a reserved job as successfully processed and removes it.
|
|
43
|
-
* @param id The job id.
|
|
44
|
-
*/
|
|
45
|
-
ack: (id: string) => Promise<void> | void;
|
|
46
|
-
/**
|
|
47
|
-
* Adds a message to the queue.
|
|
48
|
-
* @param message The message to send later.
|
|
49
|
-
* @param options Optional scheduling. See {@link EnqueueOptions}.
|
|
50
|
-
* @returns The new job id.
|
|
51
|
-
*/
|
|
52
|
-
enqueue: (message: EmailOptions, options?: EnqueueOptions) => Promise<string> | string;
|
|
53
|
-
/**
|
|
54
|
-
* Reserves the next ready job, hiding it from other workers for a visibility window.
|
|
55
|
-
* @returns The next job, or `undefined` when none is ready.
|
|
56
|
-
*/
|
|
57
|
-
reserve: () => (QueueJob | undefined) | Promise<QueueJob | undefined>;
|
|
58
|
-
/**
|
|
59
|
-
* Returns a reserved job to the queue, optionally after a delay, incrementing its attempt count.
|
|
60
|
-
* @param id The job id.
|
|
61
|
-
* @param delayMs Milliseconds to wait before the job becomes ready again.
|
|
62
|
-
*/
|
|
63
|
-
retry: (id: string, delayMs?: number) => Promise<void> | void;
|
|
64
|
-
/**
|
|
65
|
-
* The number of jobs not yet acked (ready + reserved).
|
|
66
|
-
*/
|
|
67
|
-
size: () => number | Promise<number>;
|
|
68
|
-
}
|
|
69
|
-
export { EnqueueOptions as E, QueueJob as Q, EmailQueue as a };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Template render function type.
|
|
3
|
-
* @param template Template content (string, React component, etc.).
|
|
4
|
-
* @param data Data/variables to pass to the template.
|
|
5
|
-
* @param options Options specific to the template engine.
|
|
6
|
-
* @returns Rendered HTML string.
|
|
7
|
-
*/
|
|
8
|
-
type TemplateRenderer = (template: unknown, data?: Record<string, unknown>, options?: Record<string, unknown>) => string | Promise<string>;
|
|
9
|
-
export { TemplateRenderer as T };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as c}from"node:module";const f=c(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,a=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[t,o]=r.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return r.getBuiltinModule(e)}return f(e)},{Buffer:i}=a("node:buffer"),{timingSafeEqual:u}=a("node:crypto"),d=(e,t)=>{if(e instanceof Headers)return e.get(t)??void 0;const o=t.toLowerCase();for(const[s,n]of Object.entries(e))if(s.toLowerCase()===o)return Array.isArray(n)?n[0]:n},g=(e,t)=>{const o=i.from(e),s=i.from(t);return o.length!==s.length?!1:u(o,s)},m=(e,t,o=Date.now())=>t<=0?!0:Number.isFinite(e)?Math.abs(o/1e3-e)<=t:!1;export{d as g,m as i,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as m}from"node:module";import{i as d,t as g}from"./utils-BfYfPB_I.js";const l=m(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,r]=t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return t.getBuiltinModule(s)}return l(s)},{createHmac:f}=p("node:crypto"),b=s=>{const{now:e,signature:r,signingKey:o,timestamp:i,token:n,tolerance:a=300}=s,c=typeof i=="number"?i:Number.parseInt(i,10);if(!d(c,a,e))return{reason:"timestamp-out-of-tolerance",valid:!1};const u=f("sha256",o).update(`${String(i)}${n}`).digest("hex");return g(r,u)?{valid:!0}:{reason:"signature-mismatch",valid:!1}};export{b as verifyMailgunWebhook};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as a}from"node:module";import{t as l}from"./utils-BfYfPB_I.js";const c=a(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=r=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,t]=s.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return s.getBuiltinModule(r)}return c(r)},{Buffer:f}=u("node:buffer"),p=r=>{const{authorization:e,password:t,username:o}=r;if(!e?.startsWith("Basic "))return{reason:"missing-credentials",valid:!1};const i=f.from(e.slice(6),"base64").toString("utf8"),n=`${o}:${t}`;return l(i,n)?{valid:!0}:{reason:"credentials-mismatch",valid:!1}};export{p as verifyPostmarkWebhook};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{g as t,i as k,t as w}from"./utils-BfYfPB_I.js";const y=_(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[s,r]=o.versions.node.split(".").map(Number);if(s>22||s===22&&r>=3||s===20&&r>=16)return o.getBuiltinModule(e)}return y(e)},{Buffer:u}=f("node:buffer"),{createHmac:j}=f("node:crypto"),T="v1",W=e=>e.startsWith("whsec_")?u.from(e.slice(6),"base64"):u.from(e,"utf8"),q=e=>{const{headers:s,now:r,payload:l,secret:d,tolerance:m=300}=e,n=t(s,"webhook-id")??t(s,"svix-id"),i=t(s,"webhook-timestamp")??t(s,"svix-timestamp"),a=t(s,"webhook-signature")??t(s,"svix-signature");if(!n||!i||!a)return{reason:"missing-headers",valid:!1};const p=Number.parseInt(i,10);if(!k(p,m,r))return{reason:"timestamp-out-of-tolerance",valid:!1};const g=`${n}.${i}.${l}`,h=j("sha256",W(d)).update(g).digest("base64");return a.split(" ").some(b=>{const[v,c]=b.split(",");return v!==T||!c?!1:w(c,h)})?{valid:!0}:{reason:"signature-mismatch",valid:!1}},B=e=>q(e);export{B as verifyResendWebhook,q as verifyStandardWebhook};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as y}from"node:module";import _ from"./EmailError-B-sEf3bp.js";import{i as g}from"./utils-BfYfPB_I.js";const b=y(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[r,s]=o.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return o.getBuiltinModule(e)}return b(e)},{Buffer:i}=f("node:buffer"),{verify:h,createPublicKey:l}=f("node:crypto"),v=e=>e.includes("-----BEGIN")?l(e):l({format:"der",key:i.from(e,"base64"),type:"spki"}),w=e=>{const{now:r,payload:s,publicKey:d,signature:n,timestamp:t,tolerance:u=300}=e;if(!n||!t)return{reason:"missing-headers",valid:!1};let a;try{a=v(d)}catch(p){throw new _("webhooks","Failed to parse SendGrid verification key",{cause:p})}const m=i.from(t+s,"utf8");let c;try{c=h("sha256",m,{dsaEncoding:"der",key:a},i.from(n,"base64"))}catch{return{reason:"signature-malformed",valid:!1}}return c?g(Number.parseInt(t,10),u,r)?{valid:!0}:{reason:"timestamp-out-of-tolerance",valid:!1}:{reason:"signature-mismatch",valid:!1}};export{w as verifySendGridWebhook};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as d}from"node:module";const p=d(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,m=e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[s,r]=i.versions.node.split(".").map(Number);if(s>22||s===22&&r>=3||s===20&&r>=16)return i.getBuiltinModule(e)}return p(e)},{randomUUID:u}=m("node:crypto"),l=e=>(Array.isArray(e)?e[0]:e)?.email,f=(e,s={})=>{const{idFactory:r=u,now:o=Date.now}=s;return async(a,c)=>{const n=l(a.to);e.emit({id:r(),recipient:n,timestamp:new Date(o()),type:"queued"});const t=await c(a);return t.success?e.emit({id:r(),messageId:t.data?.messageId,provider:t.data?.provider,recipient:n,timestamp:new Date(o()),type:"sent"}):e.emit({data:{error:t.error instanceof Error?t.error.message:String(t.error)},id:r(),recipient:n,timestamp:new Date(o()),type:"failed"}),t}};export{f as withEvents};
|