@visulima/email 2.1.7 → 2.1.9
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 +15 -0
- package/LICENSE.md +159 -19
- package/dist/crypto/index.js +1 -1
- package/dist/deliverability/dmarc-report.js +1 -1
- package/dist/deliverability/index.js +1 -1
- package/dist/events/index.js +1 -1
- package/dist/inbound/index.js +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/middleware/index.js +1 -1
- package/dist/packem_shared/ALL_EVENTS-CSpGgYbV.js +1 -0
- package/dist/packem_shared/DkimSigner-B_pEwGCS.js +18 -0
- package/dist/packem_shared/DraftMailMessage-Tj3sH8nn.js +1 -0
- package/dist/packem_shared/EmailError-BIaHK1Uw.js +1 -0
- package/dist/packem_shared/Mail-Cm24B3w0.js +1 -0
- package/dist/packem_shared/MailMessage-BtI4qMU1.js +1 -0
- package/dist/packem_shared/MemorySuppressionStore-D_bge6rS.js +1 -0
- package/dist/packem_shared/RATE_LIMIT_PRESETS-BIFmRuh2.js +1 -0
- package/dist/packem_shared/RequiredOptionError-ctDEEB1s.js +1 -0
- package/dist/packem_shared/SmimeEncrypter-BjBwjaTg.js +6 -0
- package/dist/packem_shared/SmimeSigner-CK5TITxI.js +8 -0
- package/dist/packem_shared/address-formatter-CXZ1aWBX.js +1 -0
- package/dist/packem_shared/aggregate-features-Bst55u8k.js +1 -0
- package/dist/packem_shared/ahaSendProvider-DY559XjD.js +1 -0
- package/dist/packem_shared/arcMessageSignatureBase-B0Qi-724.js +17 -0
- package/dist/packem_shared/attachment-processor-BJFDS343.js +1 -0
- package/dist/packem_shared/autoSendProvider-BgdWf422.js +1 -0
- package/dist/packem_shared/awsSesProvider-DTnLwAbE.js +32 -0
- package/dist/packem_shared/azureProvider-Bs4BGYR1.js +1 -0
- package/dist/packem_shared/brevoProvider-xoRTeFIx.js +1 -0
- package/dist/packem_shared/build-mime-message-QNCMA6oQ.js +3 -0
- package/dist/packem_shared/buildListUnsubscribe-g1CoihSv.js +1 -0
- package/dist/packem_shared/buildMtaStsPolicy-BA2YXL72.js +6 -0
- package/dist/packem_shared/circuitBreakerMiddleware-DcBN7K6H.js +1 -0
- package/dist/packem_shared/cloudflareEmailProvider-BkR-P0YD.js +1 -0
- package/dist/packem_shared/composeMiddleware-B3RCDFsy.js +1 -0
- package/dist/packem_shared/create-logger-CazqtXcL.js +1 -0
- package/dist/packem_shared/create-token-cache-BdMsMzf7.js +1 -0
- package/dist/packem_shared/createSuppressionStore-DbocihI8.js +1 -0
- package/dist/packem_shared/createTestEmail-CPnHNKBT.js +1 -0
- package/dist/packem_shared/createWorker-ChuTgETP.js +1 -0
- package/dist/packem_shared/dedupeMiddleware-BTo8Qjje.js +1 -0
- package/dist/packem_shared/defineInboundHandler-CnYn10ex.js +1 -0
- package/dist/packem_shared/detectMimeType-DVC9Uvy9.js +1 -0
- package/dist/packem_shared/emailMatchers-DpwItmkN.js +1 -0
- package/dist/packem_shared/extractReply-CLoWMY97.js +5 -0
- package/dist/packem_shared/failoverProvider-DSsuXHYK.js +1 -0
- package/dist/packem_shared/format-address-BDKhXcXV.js +1 -0
- package/dist/packem_shared/{generate-boundary-0xGe9GqK.js → generate-boundary-BCSUEi6x.js} +1 -1
- package/dist/packem_shared/generate-message-id-B2n2yqR6.js +1 -0
- package/dist/packem_shared/headers-to-record-ZOZ7Dubo.js +1 -0
- package/dist/packem_shared/httpProvider-CdoJ-tL7.js +1 -0
- package/dist/packem_shared/index-B8wiKJdh.js +1 -0
- package/dist/packem_shared/infobipProvider-mEYgfWJ7.js +1 -0
- package/dist/packem_shared/isValidSigningCertUrl-CK1t2a7x.js +3 -0
- package/dist/packem_shared/loggingMiddleware-DNVf8O1B.js +1 -0
- package/dist/packem_shared/loopsProvider-CKJ_rzLq.js +1 -0
- package/dist/packem_shared/{mail.d-xKtvoKMK.d.ts → mail.d-8M9NjOr0.d.ts} +2 -2
- package/dist/packem_shared/mailCrabProvider-Cx9rnuyE.js +1 -0
- package/dist/packem_shared/mailPaceProvider-DvSlan-v.js +1 -0
- package/dist/packem_shared/mailchannelsProvider-Cgb8el7C.js +1 -0
- package/dist/packem_shared/mailerSendProvider-BvRIjuVE.js +1 -0
- package/dist/packem_shared/mailgunProvider-kNcvF_z6.js +1 -0
- package/dist/packem_shared/mailjetProvider-DqJUhLuH.js +1 -0
- package/dist/packem_shared/mailomatProvider-BBOqRhV_.js +1 -0
- package/dist/packem_shared/mailtrapProvider-CeBW2Gzg.js +1 -0
- package/dist/packem_shared/make-request-Cyz5_yu8.js +1 -0
- package/dist/packem_shared/mandrillProvider-Dab8i0gF.js +1 -0
- package/dist/packem_shared/mockProvider-Bf5eJ_rl.js +1 -0
- package/dist/packem_shared/netcoreProvider-DMJsQ8IM.js +1 -0
- package/dist/packem_shared/nodemailerProvider-CJ4zkTPF.js +1 -0
- package/dist/packem_shared/normalizeMessageId-0yB1zeyC.js +1 -0
- package/dist/packem_shared/oauth2Middleware-DbKGd7Z9.js +1 -0
- package/dist/packem_shared/opentelemetryProvider-s0gvh05u.js +1 -0
- package/dist/packem_shared/outlook365Provider-DKMz0Vvh.js +1 -0
- package/dist/packem_shared/parseAddress-DW9suGjV.js +1 -0
- package/dist/packem_shared/parseArfReport-VbQeofN4.js +6 -0
- package/dist/packem_shared/parseCloudflareInbound-BKZzk0De.js +1 -0
- package/dist/packem_shared/parseDmarcRecord-9B3Qhba8.js +1 -0
- package/dist/packem_shared/parseMailgunInbound-nY-DXZrK.js +1 -0
- package/dist/packem_shared/parsePostmarkInbound-0zG71J7F.js +1 -0
- package/dist/packem_shared/parseSendGridInbound-BzEhN-gd.js +4 -0
- package/dist/packem_shared/parseSesInbound-C4cRtAUq.js +1 -0
- package/dist/packem_shared/parseTlsReport-DSiCaKFH.js +1 -0
- package/dist/packem_shared/plunkProvider-B-JtCJQy.js +1 -0
- package/dist/packem_shared/postalProvider-COVY4T94.js +1 -0
- package/dist/packem_shared/postmarkProvider-Cj64C4dc.js +1 -0
- package/dist/packem_shared/provider-base-BEz00m9R.js +1 -0
- package/dist/packem_shared/quoted-printable-BgiHOYdV.js +7 -0
- package/dist/packem_shared/resendProvider-Da5r7dMe.js +1 -0
- package/dist/packem_shared/retry-aghj7y8m.js +1 -0
- package/dist/packem_shared/retryMiddleware-CaTv0UIm.js +1 -0
- package/dist/packem_shared/roundRobinProvider-Dr1DdT2L.js +1 -0
- package/dist/packem_shared/sanitize-header-CW0f3IT7.js +1 -0
- package/dist/packem_shared/scalewayProvider-CDjpYmJc.js +1 -0
- package/dist/packem_shared/sendGridProvider-C1rp9hpg.js +1 -0
- package/dist/packem_shared/smtpProvider-Dr2XAFQu.js +27 -0
- package/dist/packem_shared/sparkpostProvider-DKon_hyx.js +1 -0
- package/dist/packem_shared/sweegoProvider-BclZuNBf.js +1 -0
- package/dist/packem_shared/toEmailSnapshot-BOhTn44E.js +1 -0
- package/dist/packem_shared/utils-CDV8xy3e.js +1 -0
- package/dist/packem_shared/validate-email-options-DxdAVLlu.js +1 -0
- package/dist/packem_shared/{verifyMailgunWebhook-DNk080BF.js → verifyMailgunWebhook-DS4o0kZL.js} +1 -1
- package/dist/packem_shared/{verifyPostmarkWebhook-B4OIEHQF.js → verifyPostmarkWebhook-pLwWmeOl.js} +1 -1
- package/dist/packem_shared/verifyResendWebhook-D3GuwWjv.js +1 -0
- package/dist/packem_shared/verifySendGridWebhook-csuRasH3.js +1 -0
- package/dist/packem_shared/withEvents-BinK2hMw.js +1 -0
- package/dist/packem_shared/withMetrics-i3mZVfeE.js +1 -0
- package/dist/packem_shared/withRender-Ce6leoYE.js +1 -0
- package/dist/packem_shared/withSuppression-B0eZ2xNQ.js +1 -0
- package/dist/packem_shared/{withTelemetry-DL2qo0Hp.js → withTelemetry-DEKTis1I.js} +1 -1
- package/dist/packem_shared/zeptomailProvider-D5B3kqFm.js +1 -0
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/autosend/index.js +1 -1
- package/dist/providers/aws-ses/index.js +1 -1
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.js +1 -1
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/http/index.js +1 -1
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/loops/index.js +1 -1
- package/dist/providers/mailchannels/index.js +1 -1
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/netcore/index.js +1 -1
- package/dist/providers/nodemailer/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +1 -1
- package/dist/providers/opentelemetry/index.js +1 -1
- package/dist/providers/outlook365/index.js +1 -1
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sparkpost/index.js +1 -1
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/queue/bullmq-queue.js +1 -1
- package/dist/queue/index.js +1 -1
- package/dist/queue/pg-boss-queue.js +1 -1
- package/dist/queue/sqs-queue.js +1 -1
- package/dist/queue/unstorage-queue.js +1 -1
- package/dist/render/cid.js +1 -1
- package/dist/render/css-inline.js +1 -1
- package/dist/render/dark-mode.js +1 -1
- package/dist/render/preheader.js +1 -1
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/html-to-text.js +1 -1
- package/dist/template-engines/i18n.js +1 -1
- package/dist/template-engines/jsx-email.js +1 -1
- package/dist/template-engines/liquid.js +1 -1
- package/dist/template-engines/mjml.js +1 -1
- package/dist/template-engines/react-email.js +1 -1
- package/dist/template-engines/vue-email.js +1 -1
- package/dist/test/index.d.ts +2 -3
- package/dist/test/index.js +1 -1
- package/dist/utils/cache.js +1 -1
- package/dist/utils/format-email-address.js +1 -1
- package/dist/utils/parse-address.js +1 -1
- package/dist/utils/parse-eml.js +4 -4
- package/dist/utils/result.js +1 -1
- package/dist/utils/validation/check-feature-support.js +1 -1
- package/dist/utils/validation/validate-email.js +1 -1
- package/dist/webhooks/index.js +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/ALL_EVENTS-3kwh5CBE.js +0 -1
- package/dist/packem_shared/DkimSigner-sLcIw9bp.js +0 -18
- package/dist/packem_shared/DraftMailMessage-C3YTXqWo.js +0 -1
- package/dist/packem_shared/EmailError-CDvYwuqz.js +0 -1
- package/dist/packem_shared/Mail-CIyxkmxu.js +0 -1
- package/dist/packem_shared/MailMessage-DuEXJiCg.js +0 -1
- package/dist/packem_shared/MemorySuppressionStore-DZnbz-_B.js +0 -1
- package/dist/packem_shared/RATE_LIMIT_PRESETS-BPADLgcA.js +0 -1
- package/dist/packem_shared/RequiredOptionError-DU2lxzk3.js +0 -1
- package/dist/packem_shared/SmimeEncrypter-CzTbQM-z.js +0 -6
- package/dist/packem_shared/SmimeSigner-DjLShaOw.js +0 -8
- package/dist/packem_shared/address-formatter-BWR2Dddx.js +0 -1
- package/dist/packem_shared/aggregate-features-BqEjPd42.js +0 -1
- package/dist/packem_shared/ahaSendProvider-br1yB2un.js +0 -1
- package/dist/packem_shared/arcMessageSignatureBase-D54jQIWu.js +0 -17
- package/dist/packem_shared/attachment-processor-D1cbAhQi.js +0 -1
- package/dist/packem_shared/autoSendProvider-BSP8ueOC.js +0 -1
- package/dist/packem_shared/awsSesProvider-zRICW1pH.js +0 -32
- package/dist/packem_shared/azureProvider-DwN4c5dC.js +0 -1
- package/dist/packem_shared/brevoProvider-C491beE_.js +0 -1
- package/dist/packem_shared/build-mime-message-DT67qfMp.js +0 -3
- package/dist/packem_shared/buildListUnsubscribe-Cdr8MvR_.js +0 -1
- package/dist/packem_shared/buildMtaStsPolicy-oEQg8y_C.js +0 -6
- package/dist/packem_shared/circuitBreakerMiddleware-N0CKF90q.js +0 -1
- package/dist/packem_shared/cloudflareEmailProvider-8JxzLbpX.js +0 -1
- package/dist/packem_shared/composeMiddleware-BHwLLEzK.js +0 -1
- package/dist/packem_shared/create-logger-BQTS3f-I.js +0 -1
- package/dist/packem_shared/create-token-cache-D56KQGVQ.js +0 -1
- package/dist/packem_shared/createSuppressionStore-CeAZKCbY.js +0 -1
- package/dist/packem_shared/createTestEmail-D_ksEez3.js +0 -1
- package/dist/packem_shared/createWorker-_-yMWcNQ.js +0 -1
- package/dist/packem_shared/dedupeMiddleware-CYYI_O7S.js +0 -1
- package/dist/packem_shared/defineInboundHandler-CnL2BzlL.js +0 -1
- package/dist/packem_shared/detectMimeType-CmYmWDXE.js +0 -1
- package/dist/packem_shared/emailMatchers-DZDkrZ_3.js +0 -1
- package/dist/packem_shared/extractReply-BUjIBt9A.js +0 -5
- package/dist/packem_shared/failoverProvider-6qwE_HSJ.js +0 -1
- package/dist/packem_shared/format-address-DTl-9O70.js +0 -1
- package/dist/packem_shared/generate-message-id-gXAuMz4g.js +0 -1
- package/dist/packem_shared/headers-to-record-De1Eg951.js +0 -1
- package/dist/packem_shared/httpProvider-BqrdZhGw.js +0 -1
- package/dist/packem_shared/index-Gd7m-UQA.js +0 -11
- package/dist/packem_shared/infobipProvider-C2FU6VMP.js +0 -1
- package/dist/packem_shared/isValidSigningCertUrl-DNxPA0Q-.js +0 -3
- package/dist/packem_shared/loggingMiddleware-CZIiVMVp.js +0 -1
- package/dist/packem_shared/loopsProvider-Bz63so6m.js +0 -1
- package/dist/packem_shared/mailCrabProvider-bkQy-2a1.js +0 -1
- package/dist/packem_shared/mailPaceProvider-S1AB-AYq.js +0 -1
- package/dist/packem_shared/mailchannelsProvider-B_K6X4VY.js +0 -1
- package/dist/packem_shared/mailerSendProvider-DPEww2H1.js +0 -1
- package/dist/packem_shared/mailgunProvider-DKxzVbDW.js +0 -1
- package/dist/packem_shared/mailjetProvider-C2TQcujL.js +0 -1
- package/dist/packem_shared/mailomatProvider-B8-5bQsu.js +0 -1
- package/dist/packem_shared/mailtrapProvider-DW7TLOdG.js +0 -1
- package/dist/packem_shared/make-request-CylyuRaN.js +0 -1
- package/dist/packem_shared/mandrillProvider-S-0lKNGd.js +0 -1
- package/dist/packem_shared/mockProvider-BAl292mW.js +0 -1
- package/dist/packem_shared/netcoreProvider-DajMprlo.js +0 -1
- package/dist/packem_shared/nodemailerProvider-DRo0lJ6g.js +0 -1
- package/dist/packem_shared/normalizeMessageId-DAx2pGe2.js +0 -1
- package/dist/packem_shared/oauth2Middleware-DQh-hIkv.js +0 -1
- package/dist/packem_shared/opentelemetryProvider-C6spx2CD.js +0 -1
- package/dist/packem_shared/outlook365Provider-B0o7UZBW.js +0 -1
- package/dist/packem_shared/parseAddress-DdbViBAJ.js +0 -1
- package/dist/packem_shared/parseArfReport-Ds6S3c4J.js +0 -6
- package/dist/packem_shared/parseCloudflareInbound-C__j-oNa.js +0 -1
- package/dist/packem_shared/parseDmarcRecord-DXZ-_rF0.js +0 -1
- package/dist/packem_shared/parseMailgunInbound-BpC6uPNe.js +0 -1
- package/dist/packem_shared/parsePostmarkInbound-Co3_c6-9.js +0 -1
- package/dist/packem_shared/parseSendGridInbound-DsALoijO.js +0 -4
- package/dist/packem_shared/parseSesInbound-CH5tHIjp.js +0 -1
- package/dist/packem_shared/parseTlsReport-wPe1lIDs.js +0 -1
- package/dist/packem_shared/plunkProvider-DJzEUEtU.js +0 -1
- package/dist/packem_shared/postalProvider-DHFjFE3Y.js +0 -1
- package/dist/packem_shared/postmarkProvider-Dt1EGGBA.js +0 -1
- package/dist/packem_shared/provider-base-DjPzWncP.js +0 -1
- package/dist/packem_shared/quoted-printable-nSGDA1tA.js +0 -7
- package/dist/packem_shared/resendProvider-qjI86j_d.js +0 -1
- package/dist/packem_shared/retry-CG9iT2wF.js +0 -1
- package/dist/packem_shared/retryMiddleware-DbViDX4r.js +0 -1
- package/dist/packem_shared/roundRobinProvider-CO5YvhgR.js +0 -1
- package/dist/packem_shared/sanitize-header-DtQwAnzg.js +0 -1
- package/dist/packem_shared/scalewayProvider-CihQKhw6.js +0 -1
- package/dist/packem_shared/sendGridProvider-Dkc5AKlC.js +0 -1
- package/dist/packem_shared/smtpProvider-CIXMxPu-.js +0 -25
- package/dist/packem_shared/sparkpostProvider-CKxQhpyB.js +0 -1
- package/dist/packem_shared/sweegoProvider-DjmAs6La.js +0 -1
- package/dist/packem_shared/toEmailSnapshot-DeRqM5SJ.js +0 -1
- package/dist/packem_shared/utils-DjEtR3qT.js +0 -1
- package/dist/packem_shared/validate-email-options-mCM9dVug.js +0 -1
- package/dist/packem_shared/verifyResendWebhook-C7E32LZ1.js +0 -1
- package/dist/packem_shared/verifySendGridWebhook-1l9bqIMw.js +0 -1
- package/dist/packem_shared/withEvents-CytsykaK.js +0 -1
- package/dist/packem_shared/withMetrics-DWywX_6M.js +0 -1
- package/dist/packem_shared/withRender-VP9wE5Yr.js +0 -1
- package/dist/packem_shared/withSuppression-BoaO4Qdz.js +0 -1
- package/dist/packem_shared/zeptomailProvider-DSTC9pUi.js +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
`).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}):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
|
-
\r
|
|
8
|
-
`);if(!i||!n)return e;const s=i.split(`\r
|
|
9
|
-
`),a=T=>T.replaceAll(`\r
|
|
10
|
-
`,`
|
|
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
|
-
${s.join(`\r
|
|
14
|
-
`)}\r
|
|
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 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
|
-
\r
|
|
18
|
-
`);if(r!==-1){const m=a.slice(0,r),j=a.slice(r+4);a=`${m}\r
|
|
19
|
-
${h.join(`\r
|
|
20
|
-
`)}\r
|
|
21
|
-
\r
|
|
22
|
-
${j}`}}t.dkim&&(e.useDkim||e.useDkim===void 0)&&(a=z(a));const g=a.replaceAll(`\r
|
|
23
|
-
.`,`\r
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as r}from"./headers-to-record-De1Eg951.js";const s=e=>e.name?`${e.name} <${e.email}>`:e.email,a=e=>{if(e!==void 0)return(Array.isArray(e)?e:[e]).map(t=>s(t))},h=e=>{const t="options"in e?e.options:e,o={from:s(t.from),subject:t.subject,to:a(t.to)??[]},c=a(t.cc),m=a(t.bcc);if(c&&(o.cc=c),m&&(o.bcc=m),t.replyTo&&(o.replyTo=s(t.replyTo)),t.text!==void 0&&(o.text=t.text),t.html!==void 0&&(o.html=t.html),t.headers!==void 0){const n=r(t.headers);Object.keys(n).length>0&&(o.headers=n)}return t.attachments&&t.attachments.length>0&&(o.attachments=t.attachments.map(n=>({contentType:n.contentType,filename:n.filename}))),o};export{h as toEmailSnapshot};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as c}from"node:module";let f;const u=e=>(f??=c(import.meta.url))(e),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,a=e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[t,r]=s.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return s.getBuiltinModule(e)}return u(e)},{Buffer:i}=a("node:buffer"),{timingSafeEqual:l}=a("node:crypto"),_=(e,t)=>{if(e instanceof Headers)return e.get(t)??void 0;const r=t.toLowerCase();for(const[o,n]of Object.entries(e))if(o.toLowerCase()===r)return Array.isArray(n)?n[0]:n},g=(e,t)=>{const r=i.from(e),o=i.from(t);return r.length!==o.length?!1:l(r,o)},m=(e,t,r=Date.now())=>t<=0?!0:Number.isFinite(e)?Math.abs(r/1e3-e)<=t:!1;export{_ as g,m as i,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import l from"../utils/validation/validate-email.js";const a=i=>{const r=[];i.from?.email||r.push("Missing required field: from"),i.to||r.push("Missing required field: to"),i.subject||r.push("Missing required field: subject"),!i.text&&!i.html&&r.push("Either text or html content is required"),i.from&&i.from.email&&!l(i.from.email)&&r.push(`Invalid from email address: ${i.from.email}`);const e=(s,m)=>{s&&(Array.isArray(s)?s:[s]).forEach(o=>{l(o.email)||r.push(`Invalid ${m} email address: ${o.email}`)})};return e(i.to,"to"),e(i.cc,"cc"),e(i.bcc,"bcc"),i.replyTo&&!l(i.replyTo.email)&&r.push(`Invalid replyTo email address: ${i.replyTo.email}`),r};export{a as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as v}from"node:module";import{g as t,i as q,t as w}from"./utils-DjEtR3qT.js";let y;const j=e=>(y??=v(import.meta.url))(e),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[s,o]=r.versions.node.split(".").map(Number);if(s>22||s===22&&o>=3||s===20&&o>=16)return r.getBuiltinModule(e)}return j(e)},{Buffer:u}=l("node:buffer"),{createHmac:k}=l("node:crypto"),T="v1",W=e=>e.startsWith("whsec_")?u.from(e.slice(6),"base64"):u.from(e,"utf8"),x=e=>{const{headers:s,now:o,payload:d,secret:f,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(!q(p,m,o))return{reason:"timestamp-out-of-tolerance",valid:!1};const h=`${n}.${i}.${d}`,_=k("sha256",W(f)).update(h).digest("base64");return a.split(" ").some(g=>{const[b,c]=g.split(",");return b!==T||!c?!1:w(c,_)})?{valid:!0}:{reason:"signature-mismatch",valid:!1}},B=e=>x(e);export{B as verifyResendWebhook,x as verifyStandardWebhook};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as y}from"node:module";import g from"./EmailError-CDvYwuqz.js";import{i as v}from"./utils-DjEtR3qT.js";let _;const b=e=>(_??=y(import.meta.url))(e),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[r,o]=s.versions.node.split(".").map(Number);if(r>22||r===22&&o>=3||r===20&&o>=16)return s.getBuiltinModule(e)}return b(e)},{Buffer:i}=d("node:buffer"),{verify:h,createPublicKey:l}=d("node:crypto"),j=e=>e.includes("-----BEGIN")?l(e):l({format:"der",key:i.from(e,"base64"),type:"spki"}),w=e=>{const{now:r,payload:o,publicKey:f,signature:n,timestamp:t,tolerance:u=300}=e;if(!n||!t)return{reason:"missing-headers",valid:!1};let a;try{a=j(f)}catch(p){throw new g("webhooks","Failed to parse SendGrid verification key",{cause:p})}const m=i.from(t+o,"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?v(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";let p;const m=e=>(p??=d(import.meta.url))(e),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[s,t]=i.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return i.getBuiltinModule(e)}return m(e)},{randomUUID:_}=u("node:crypto"),l=e=>(Array.isArray(e)?e[0]:e)?.email,y=(e,s={})=>{const{idFactory:t=_,now:o=Date.now}=s;return async(a,c)=>{const n=l(a.to);e.emit({id:t(),recipient:n,timestamp:new Date(o()),type:"queued"});const r=await c(a);return r.success?e.emit({id:t(),messageId:r.data?.messageId,provider:r.data?.provider,recipient:n,timestamp:new Date(o()),type:"sent"}):e.emit({data:{error:r.error instanceof Error?r.error.message:String(r.error)},id:t(),recipient:n,timestamp:new Date(o()),type:"failed"}),r}};export{y as withEvents};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const i=(e,r={})=>{const s=r.prefix??"email_";return async(a,o)=>{const c=Date.now(),t=await o(a),n={provider:t.data?.provider??"unknown",status:t.success?"success":"failure"};return e.increment(`${s}sent_total`,n),e.observe(`${s}duration_ms`,Date.now()-c,n),t}};export{i as withMetrics};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const s=a=>async(t,o)=>o(await a(t));export{s as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{filterSuppressed as d}from"./createSuppressionStore-CeAZKCbY.js";import w from"./EmailError-CDvYwuqz.js";const u=(o,c={})=>async(e,p)=>{const t={allowed:[],suppressed:[]},r=await d(e.to,o),l=e.cc?await d(e.cc,o):t,s=e.bcc?await d(e.bcc,o):t,a=[...r.suppressed,...l.suppressed,...s.suppressed];return a.length>0&&c.onSuppressed?.(a),r.allowed.length===0&&l.allowed.length===0&&s.allowed.length===0?{error:new w("middleware","All recipients are suppressed",{code:"ALL_SUPPRESSED"}),success:!1}:p({...e,bcc:s.allowed.length>0?s.allowed:void 0,cc:l.allowed.length>0?l.allowed:void 0,to:r.allowed})};export{u as withSuppression};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import l from"./EmailError-CDvYwuqz.js";import y from"./RequiredOptionError-DU2lxzk3.js";import{e as b}from"./generate-message-id-gXAuMz4g.js";import{s as k}from"./headers-to-record-De1Eg951.js";import{m as v}from"./make-request-CylyuRaN.js";import{i as w}from"./retry-CG9iT2wF.js";import{s as A,a as z}from"./sanitize-header-DtQwAnzg.js";import{f as _}from"./validate-email-options-mCM9dVug.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{P,h as I,c as T}from"./provider-base-DjPzWncP.js";import{n as h}from"./address-formatter-BWR2Dddx.js";const i="zeptomail",O="https://api.zeptomail.com/v1.1",Z=3e4,E=3,L=j((s={})=>{if(!s.token)throw new y(i,"token");if(!s.token.startsWith("Zoho-enczapikey "))throw new l(i,'Token should be in the format "Zoho-enczapikey <your_api_key>"');const o={debug:s.debug??!1,endpoint:s.endpoint??O,logger:s.logger,retries:s.retries??E,timeout:s.timeout??Z,token:s.token},u=new P,n=T(i,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!1,tracking:!0},async initialize(){await u.ensureInitialized(async()=>{if(!await this.isAvailable())throw new l(i,"Zeptomail API not available or invalid token");n.debug("Provider initialized successfully")},i)},async isAvailable(){try{return o.token&&o.token.startsWith("Zoho-enczapikey ")?(n.debug("Token format is valid, assuming Zeptomail is available"),!0):!1}catch(e){return n.debug("Error checking availability:",e),!1}},name:i,options:o,async sendEmail(e){try{const m=_(e);if(m.length>0)return{error:new l(i,`Invalid email options: ${m.join(", ")}`),success:!1};await u.ensureInitialized(()=>this.initialize(),i);const a={from:h(e.from).address,subject:e.subject};if(Array.isArray(e.to)?a.to=e.to.length===1?e.to[0].email:e.to.map(t=>t.email):a.to=e.to.email,e.text&&(a.textbody=e.text),e.html&&(a.htmlbody=e.html),e.cc&&(Array.isArray(e.cc)?a.cc=e.cc.length===1?e.cc[0].email:e.cc.map(t=>t.email):a.cc=e.cc.email),e.bcc&&(Array.isArray(e.bcc)?a.bcc=e.bcc.length===1?e.bcc[0].email:e.bcc.map(t=>t.email):a.bcc=e.bcc.email),e.replyTo&&(a.reply_to=[h(e.replyTo).address]),e.trackClicks!==void 0&&(a.track_clicks=e.trackClicks),e.trackOpens!==void 0&&(a.track_opens=e.trackOpens),e.clientReference&&(a.client_reference=e.clientReference),e.mimeHeaders&&Object.keys(e.mimeHeaders).length>0){const t={};for(const[r,d]of Object.entries(e.mimeHeaders))t[r]=d;a.mime_headers=t}if(e.headers){const t=k(e.headers);Object.keys(t).length>0&&(a.mime_headers??={},Object.entries(t).forEach(([r,d])=>{a.mime_headers&&(a.mime_headers[A(r)]=z(d))}))}e.attachments&&e.attachments.length>0&&(a.attachments=e.attachments.map(t=>{const r={name:t.filename};return t.content?(r.content=typeof t.content=="string"?t.content:t.content.toString("base64"),t.contentType&&(r.mime_type=t.contentType)):t.path&&(r.file_cache_key=t.path),r})),n.debug("Sending email via Zeptomail API",{subject:a.subject,to:a.to});const g={Accept:"application/json",Authorization:o.token,"Content-Type":"application/json"},c=await w(async()=>v(`${o.endpoint}/email`,{headers:g,method:"POST",timeout:o.timeout},JSON.stringify(a)),o.retries);if(!c.success){n.debug("API request failed",c.error);let t=c.error instanceof Error?c.error.message:"Unknown error";const r=c.data;return r?.body?.message?t+=` Details: ${r.body.message}`:r?.body?.error?.message&&(t+=` Details: ${r.body.error.message}`),{error:new l(i,`Failed to send email: ${t}`,{cause:c.error}),success:!1}}const p=c.data?.body,f=p?.request_id??b();return n.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:i,response:p,sent:!0,timestamp:new Date},success:!0}}catch(m){return{error:I(i,"send email",m,n),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{L as default};
|