@visulima/email 2.1.8 → 3.0.0
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 +14 -0
- package/LICENSE.md +159 -19
- package/dist/crypto/index.d.ts +50 -47
- 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 +2 -3
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +19 -6
- package/dist/middleware/index.js +1 -1
- package/dist/packem_chunks/index.js +27 -0
- package/dist/packem_shared/ALL_EVENTS-CSpGgYbV.js +1 -0
- package/dist/packem_shared/DkimSigner-CCxFKitN.js +4 -0
- package/dist/packem_shared/DraftMailMessage-B0gwf8n_.js +1 -0
- package/dist/packem_shared/EmailError-BIaHK1Uw.js +1 -0
- package/dist/packem_shared/Mail-DmYNQ0KK.js +1 -0
- package/dist/packem_shared/MailMessage-DmmaNHHc.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-DnlfpjUX.js +6 -0
- package/dist/packem_shared/SmimeSigner-DTvclzLq.js +8 -0
- package/dist/packem_shared/address-formatter-w36S9ZYj.js +1 -0
- package/dist/packem_shared/aggregate-features-Bst55u8k.js +1 -0
- package/dist/packem_shared/ahaSendProvider-C1qvG8Cj.js +1 -0
- package/dist/packem_shared/arcMessageSignatureBase-su9VTRB7.js +9 -0
- package/dist/packem_shared/attachment-processor-BJFDS343.js +1 -0
- package/dist/packem_shared/autoSendProvider-yxUx3sEj.js +1 -0
- package/dist/packem_shared/awsSesProvider-DTnLwAbE.js +32 -0
- package/dist/packem_shared/azureProvider-CLLRKtOf.js +1 -0
- package/dist/packem_shared/brevoProvider-CHlodyzV.js +1 -0
- package/dist/packem_shared/build-mime-message-BCFKPqaW.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/canonicalize-BEjQUnUe.js +11 -0
- package/dist/packem_shared/circuitBreakerMiddleware-DcBN7K6H.js +1 -0
- package/dist/packem_shared/cloudflareEmailProvider-Ckh_u-0D.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-sB6z8m6Z.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-BRz3Qjyz.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-Bb7xk8G_.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/infobipProvider-BEu1ycxS.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-B9JyPxzq.d.ts → mail.d-BdyyyQO5.d.ts} +11 -9
- package/dist/packem_shared/mailCrabProvider-BQ5ELwPU.js +1 -0
- package/dist/packem_shared/mailPaceProvider-Ca3cz8JU.js +1 -0
- package/dist/packem_shared/mailchannelsProvider-BZeuZk3d.js +1 -0
- package/dist/packem_shared/mailerSendProvider-C_Db652T.js +1 -0
- package/dist/packem_shared/mailgunProvider-CU2b8ie8.js +1 -0
- package/dist/packem_shared/mailjetProvider-VqvqCS7I.js +1 -0
- package/dist/packem_shared/mailomatProvider-FMk4FZZz.js +1 -0
- package/dist/packem_shared/mailtrapProvider-Qs0exKiJ.js +1 -0
- package/dist/packem_shared/make-request-Cyz5_yu8.js +1 -0
- package/dist/packem_shared/mandrillProvider-Co_EfMxl.js +1 -0
- package/dist/packem_shared/mockProvider-Bf5eJ_rl.js +1 -0
- package/dist/packem_shared/netcoreProvider-_kXjZ0bE.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-C0M1w3_2.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-tEBNXL3h.js +1 -0
- package/dist/packem_shared/postmarkProvider-DdavP5x5.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-CMtlyIye.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-BFA1PQ73.js +1 -0
- package/dist/packem_shared/sendGridProvider-DV80Lg7a.js +1 -0
- package/dist/packem_shared/smtpProvider-BCEzJmay.js +14 -0
- package/dist/packem_shared/sparkpostProvider-C3pATjJX.js +1 -0
- package/dist/packem_shared/sweegoProvider-CkFtUAzq.js +1 -0
- package/dist/packem_shared/toEmailSnapshot-BOhTn44E.js +1 -0
- package/dist/packem_shared/{types.d-B0t3PQ3t.d.ts → types.d-Cb5fls_X.d.ts} +1 -1
- 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-tqRYpQlv.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.d.ts +17 -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.d.ts +9 -5
- 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-udCl3JXO.js +0 -18
- package/dist/packem_shared/DraftMailMessage-BgP1OF1G.js +0 -1
- package/dist/packem_shared/EmailError-2CCyVX1S.js +0 -1
- package/dist/packem_shared/Mail-DduRntbB.js +0 -1
- package/dist/packem_shared/MailMessage-BRBT4Jea.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-BmpC5whN.js +0 -1
- package/dist/packem_shared/SmimeEncrypter-Dm9McVTQ.js +0 -6
- package/dist/packem_shared/SmimeSigner-B6hkacNk.js +0 -8
- package/dist/packem_shared/address-formatter-bfmGfQ83.js +0 -1
- package/dist/packem_shared/aggregate-features-BqEjPd42.js +0 -1
- package/dist/packem_shared/ahaSendProvider-C6nBGCCa.js +0 -1
- package/dist/packem_shared/arcMessageSignatureBase-B2uArM48.js +0 -17
- package/dist/packem_shared/attachment-processor-DjbjtJ6H.js +0 -1
- package/dist/packem_shared/autoSendProvider-Dhig--Zo.js +0 -1
- package/dist/packem_shared/awsSesProvider-CMqAmU5N.js +0 -32
- package/dist/packem_shared/azureProvider-C-bNOOil.js +0 -1
- package/dist/packem_shared/brevoProvider-CkOjDyir.js +0 -1
- package/dist/packem_shared/build-mime-message-t8KYiQkO.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-BSCPR72q.js +0 -1
- package/dist/packem_shared/cloudflareEmailProvider-RCixPWnY.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-XiF5E8vJ.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-B9_7ujpC.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-BkOOP7pt.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-6idLfv-f.js +0 -1
- package/dist/packem_shared/index-y0s2wQdc.js +0 -11
- package/dist/packem_shared/infobipProvider-CHHsqRXy.js +0 -1
- package/dist/packem_shared/isValidSigningCertUrl-D7PuiRW4.js +0 -3
- package/dist/packem_shared/loggingMiddleware-CZIiVMVp.js +0 -1
- package/dist/packem_shared/loopsProvider-Cl-dOuCN.js +0 -1
- package/dist/packem_shared/mailCrabProvider-De2YxPlF.js +0 -1
- package/dist/packem_shared/mailPaceProvider-DwNTuFb2.js +0 -1
- package/dist/packem_shared/mailchannelsProvider-Dwl0Typz.js +0 -1
- package/dist/packem_shared/mailerSendProvider-CyMIbqGq.js +0 -1
- package/dist/packem_shared/mailgunProvider-DWKJYRKT.js +0 -1
- package/dist/packem_shared/mailjetProvider-DXPJQO1G.js +0 -1
- package/dist/packem_shared/mailomatProvider-DopZk27y.js +0 -1
- package/dist/packem_shared/mailtrapProvider-CTg4z3GN.js +0 -1
- package/dist/packem_shared/make-request-CDhxj-9b.js +0 -1
- package/dist/packem_shared/mandrillProvider-CAQeMtU_.js +0 -1
- package/dist/packem_shared/mockProvider-EcpYlg-_.js +0 -1
- package/dist/packem_shared/netcoreProvider-ua1avx07.js +0 -1
- package/dist/packem_shared/nodemailerProvider-BZmQfKlM.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-CAfWpywa.js +0 -1
- package/dist/packem_shared/outlook365Provider-SFYELGDr.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-9amwuQri.js +0 -1
- package/dist/packem_shared/postalProvider-CeF3TOIW.js +0 -1
- package/dist/packem_shared/postmarkProvider-BPgKEkgF.js +0 -1
- package/dist/packem_shared/provider-base-B-xhQSqE.js +0 -1
- package/dist/packem_shared/quoted-printable-nSGDA1tA.js +0 -7
- package/dist/packem_shared/resendProvider-C9_sM8bH.js +0 -1
- package/dist/packem_shared/retry-D1Rh-6Z4.js +0 -1
- package/dist/packem_shared/retryMiddleware-DbViDX4r.js +0 -1
- package/dist/packem_shared/roundRobinProvider-BPzLWZf-.js +0 -1
- package/dist/packem_shared/sanitize-header-DtQwAnzg.js +0 -1
- package/dist/packem_shared/scalewayProvider-DfC7275i.js +0 -1
- package/dist/packem_shared/sendGridProvider-CUBBHBzs.js +0 -1
- package/dist/packem_shared/smtpProvider-9nBSGtQl.js +0 -27
- package/dist/packem_shared/sparkpostProvider-Be_d7S8o.js +0 -1
- package/dist/packem_shared/sweegoProvider-CP1cNC-d.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-DtFMgBRP.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-wDl4NTb-.js +0 -1
- package/dist/packem_shared/zeptomailProvider-BZ0fK0Lk.js +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{createRequire as z}from"node:module";import f from"./EmailError-2CCyVX1S.js";import K from"./RequiredOptionError-BmpC5whN.js";import{j as Q}from"./build-mime-message-t8KYiQkO.js";import{e as V}from"./generate-message-id-gXAuMz4g.js";import{f as Z}from"./validate-email-options-mCM9dVug.js";import{defineProvider as J}from"./defineProvider-C9q-7iwt.js";let F;const B=i=>(F??=z(import.meta.url))(i),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,H=i=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,m]=O.versions.node.split(".").map(Number);if(t>22||t===22&&m>=3||t===20&&m>=16)return O.getBuiltinModule(i)}return B(i)},{Buffer:I}=H("node:buffer"),{createHash:G,createSign:q,createHmac:W}=H("node:crypto"),{Socket:X,createConnection:Y}=H("node:net"),{connect:P}=H("node:tls"),ee=(i,t)=>new Promise(m=>{const w=new X,y=()=>{w.destroy(),m(!1)};w.setTimeout(1e3),w.on("error",y),w.on("timeout",y),w.connect(t,i,()=>{w.end(),m(!0)})}),te=i=>{const t=i.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`).map(w=>w.replaceAll(/[ \t]+/g," ").replace(/ +$/,""));let m=t.length;for(;m>0&&t[m-1]==="";)m-=1;return m>0?`${t.slice(0,m).join(`\r
|
|
5
|
-
`)}\r
|
|
6
|
-
`:""},re=i=>{const t=i.indexOf(":");if(t===-1)return`${i.toLowerCase().trim()}:`;const m=i.slice(0,t).toLowerCase().trim(),w=i.slice(t+1).replaceAll(/\s+/g," ").trim();return`${m}:${w}`},se=(i,t)=>{const{domainName:m,keySelector:w,privateKey:y}=t,S=i.indexOf(`\r
|
|
7
|
-
\r
|
|
8
|
-
`);if(S===-1)return i;const R=i.slice(0,S),$=i.slice(S+4),A=R.split(`\r
|
|
9
|
-
`),L=te($),p=G("sha256").update(L).digest("base64"),v=["from","to","subject","date"],U=A.filter(a=>v.some(c=>a.toLowerCase().startsWith(`${c}:`))),N=U.map(a=>a.split(":")[0]?.toLowerCase()??"").filter(Boolean).join(":"),T=Math.floor(Date.now()/1e3),k={a:"rsa-sha256",bh:p,c:"relaxed/relaxed",d:m,h:N,s:w,t:T.toString(),v:"1"},C=`DKIM-Signature: ${Object.entries(k).map(([a,c])=>`${a}=${c}`).join("; ")}; b=`,e=[...U,C].map(a=>re(a)).join(`\r
|
|
10
|
-
`),n=q("RSA-SHA256");n.update(e);const o=n.sign(y,"base64");return`${`${C}${o}`}\r
|
|
11
|
-
${A.join(`\r
|
|
12
|
-
`)}\r
|
|
13
|
-
\r
|
|
14
|
-
${$}`},d="smtp",oe=25,ae=465,ie=1e4,ne=!1,ce=5,_=3e4,ue=/^\./,ge=J((i={})=>{if(!i.host)throw new K(d,"host");const t={authMethod:i.authMethod??"LOGIN",debug:i.debug??!1,dkim:i.dkim,host:i.host,maxConnections:i.maxConnections??ce,oauth2:i.oauth2,password:i.password,pool:i.pool??!1,port:i.port!==void 0?i.port:i.secure?ae:oe,rejectUnauthorized:i.rejectUnauthorized??!0,retries:i.retries??0,secure:i.secure??ne,timeout:i.timeout??ie,user:i.user,...i.logger&&{logger:i.logger}};let m=!1;const w=[],y=[];let S=0;const R=()=>{S+=1},$=()=>{S>0&&(S-=1)},A=e=>e.replaceAll(/[\r\n\t\v\f]/g," ").trim(),L=e=>{const n=e.split(`\r
|
|
15
|
-
`),o={};for(const a of n)if(a.startsWith("250-")||a.startsWith("250 ")){const c=a.slice(4).trim().split(" "),l=c[0];l&&(o[l]=c.slice(1))}return o},p=async(e,n,o)=>new Promise((a,c)=>{const l=Array.isArray(o)?o:[o];let s="",u="";const h=setTimeout(()=>{b(),c(new f(d,`Command timeout after ${t.timeout}ms: ${n?.slice(0,50)}...`))},t.timeout),b=()=>{e.removeListener("data",j),e.removeListener("error",r),h&&clearTimeout(h)},j=g=>{s+=g.toString();const M=s.split(`\r
|
|
16
|
-
`).filter(Boolean);if(M.length>0){const D=M.at(-1);if(D){const E=D.match(/^(\d{3})[\s-]/);if(E){const[,x]=E;u=x,D[3]===" "&&(b(),l.includes(u)?a(s):c(new f(d,`Expected ${l.join(" or ")}, got ${u}: ${s.trim()}`)))}}}},r=g=>{b(),c(new f(d,`Socket error: ${g.message}`,{cause:g}))};e.on("data",j),e.on("error",r),n&&e.write(`${n}\r
|
|
17
|
-
`)}),v=async()=>{if(t.pool&&w.length>0){const e=w.pop();if(e&&!e.destroyed)return e;e&&$()}return t.pool&&S>=t.maxConnections?new Promise((e,n)=>{const o={reject:n,resolve:e};o.timeout=setTimeout(()=>{const a=y.indexOf(o);a!==-1&&y.splice(a,1),n(new f(d,`Connection queue timeout after ${_}ms`))},_),y.push(o)}):new Promise((e,n)=>{let o,a=!1,c;const l=()=>{o&&clearTimeout(o)};o=setTimeout(()=>{a||(a=!0,c&&!c.destroyed&&c.destroy(),l(),n(new f(d,`Connection timeout to ${t.host}:${t.port} after ${t.timeout}ms`)))},t.timeout);try{c=t.secure?P({host:t.host,port:t.port,rejectUnauthorized:t.rejectUnauthorized}):Y(t.port,t.host),c.on("error",s=>{a||(a=!0,l(),n(new f(d,`Connection error: ${s.message}`,{cause:s})))}),c.once("data",s=>{if(!a&&c){a=!0,l();const u=s.toString();u.slice(0,3)==="220"?(R(),e(c)):(c.destroy(),n(new f(d,`Unexpected server greeting: ${u.trim()}`)))}})}catch(s){a||(a=!0,l(),n(new f(d,`Failed to create connection: ${s.message}`,{cause:s})))}})},U=async e=>new Promise((n,o)=>{let a,c=!1,l;const s=()=>{a&&clearTimeout(a)};a=setTimeout(()=>{c||(c=!0,l&&!l.destroyed&&l.destroy(),s(),o(new f(d,`TLS connection timeout after ${t.timeout}ms`)))},t.timeout);try{const u={host:t.host,rejectUnauthorized:t.rejectUnauthorized,socket:e};l=P(u),l.on("error",h=>{c||(c=!0,s(),o(new f(d,`TLS connection error: ${h.message}`,{cause:h})))}),l.once("secure",()=>{!c&&l&&(c=!0,s(),n(l))})}catch(u){c||(c=!0,s(),o(new f(d,`Failed to upgrade to TLS: ${u.message}`,{cause:u})))}}),N=e=>{if(e.destroyed||!t.pool){try{e.destroy()}catch{}$();return}if(y.length>0){const n=y.shift();if(n){clearTimeout(n.timeout),n.resolve(e);return}}w.push(e)},T=async(e,n=!1)=>{if(n){if(!e.destroyed)try{await p(e,"RSET","250")}catch{e.destroy()}N(e);return}await new Promise(o=>{try{$(),e.write(`QUIT\r
|
|
18
|
-
`),e.end(),e.once("close",()=>{o()})}catch{o()}})},k=async e=>{if(!t.user)return;const n=await p(e,`EHLO ${t.host}`,"250"),o=L(n),a=Object.keys(o).find(s=>s.toUpperCase()==="AUTH");if(!a&&(t.user||t.password))throw new f(d,"Server does not support authentication");const c=a?o[a]??[]:[];let{authMethod:l}=t;if(l||(c.includes("CRAM-MD5")?l="CRAM-MD5":c.includes("LOGIN")?l="LOGIN":c.includes("PLAIN")&&(l="PLAIN")),!l)throw new f(d,"No supported authentication methods");if(l==="OAUTH2"&&t.oauth2)try{const{accessToken:s,user:u}=t.oauth2,h=`user=${u}auth=Bearer ${s}`,b=I.from(h).toString("base64");await p(e,`AUTH XOAUTH2 ${b}`,"235");return}catch(s){const u=s.message;throw u.includes("535")||u.includes("Authentication failed")?new f(d,"Authentication failed: Invalid OAuth2 credentials"):s}if(l==="CRAM-MD5"&&t.password)try{const s=(await p(e,"AUTH CRAM-MD5","334")).split(" ")[1];if(!s)throw new f(d,"Invalid CRAM-MD5 challenge response");const u=I.from(s,"base64").toString("utf8"),h=W("md5",t.password);h.update(u);const b=h.digest("hex"),j=`${t.user} ${b}`;await p(e,I.from(j).toString("base64"),"235");return}catch(s){const u=s.message;throw u.includes("535")||u.includes("Authentication failed")?new f(d,"Authentication failed: Invalid username or password"):s}if(l==="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 u=s.message;throw u.includes("535")||u.includes("Authentication failed")?new f(d,"Authentication failed: Invalid username or password"):s}if(l==="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 u=s.message;throw u.includes("535")||u.includes("Authentication failed")?new f(d,"Authentication failed: Invalid username or password"):s}throw new f(d,"Authentication failed - no valid credentials or method")},C=e=>{if(!t.dkim)return e;try{return se(e,t.dkim)}catch(n){return console.error(`[${d}] DKIM signing error:`,n),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(!m)try{if(!await this.isAvailable())throw new f(d,`SMTP server not available at ${t.host}:${t.port}`);m=!0}catch(e){throw new f(d,`Failed to initialize: ${e.message}`,{cause:e})}},async isAvailable(){try{if(!await ee(t.host,t.port))return!1;const e=await v();return await T(e),!0}catch{return!1}},name:d,options:t,async sendEmail(e){try{const n=Z(e);if(n.length>0)return{error:new f(d,`Invalid email options: ${n.join(", ")}`),success:!1};m||await this.initialize();let o=await v();try{let a=L(await p(o,`EHLO ${t.host}`,"250"));if(!t.secure)try{const r=await p(o,`EHLO ${t.host}`,"250"),g=L(r);a=g,Object.keys(g).includes("STARTTLS")&&(await p(o,"STARTTLS","220"),o=await U(o),a=L(await p(o,`EHLO ${t.host}`,"250")))}catch(r){if(t.rejectUnauthorized)throw new f(d,`STARTTLS failed or not supported: ${r.message}`,{cause:r})}await k(o);const c=Object.keys(a).some(r=>r.toUpperCase()==="DSN");let l="";if(e.dsn&&c){const r=[];e.dsn.success&&r.push("SUCCESS"),e.dsn.failure&&r.push("FAILURE"),e.dsn.delay&&r.push("DELAY"),r.length>0&&(l=` 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}>${l}`,"250");await p(o,"DATA","354");let u=await Q(e);const h=[];if(e.dsn&&!c){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: ${A(e.inReplyTo)}`),e.references){const r=Array.isArray(e.references)?e.references.map(g=>A(g)).join(" "):A(e.references);h.push(`References: ${r}`)}if(e.listUnsubscribe){const r=Array.isArray(e.listUnsubscribe)?e.listUnsubscribe.map(g=>`<${A(g)}>`).join(", "):`<${A(e.listUnsubscribe)}>`;h.push(`List-Unsubscribe: ${r}`)}if(e.googleMailHeaders){const{googleMailHeaders:r}=e;r.feedbackId&&h.push(`Feedback-ID: ${A(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=u.indexOf(`\r
|
|
19
|
-
\r
|
|
20
|
-
`);if(r!==-1){const g=u.slice(0,r),M=u.slice(r+4);u=`${g}\r
|
|
21
|
-
${h.join(`\r
|
|
22
|
-
`)}\r
|
|
23
|
-
\r
|
|
24
|
-
${M}`}}t.dkim&&(e.useDkim||e.useDkim===void 0)&&(u=C(u));const b=u.replaceAll(`\r
|
|
25
|
-
.`,`\r
|
|
26
|
-
..`).replace(ue,"..");await p(o,`${b}\r
|
|
27
|
-
.`,"250");const j=V();return await T(o,t.pool),{data:{messageId:j,provider:d,response:"Message accepted",sent:!0,timestamp:new Date},success:!0}}catch(a){try{await T(o)}catch{}throw a}}catch(n){return{error:new f(d,`Failed to send email: ${n.message}`,{cause:n}),success:!1}}},async shutdown(){for(const e of w)try{await T(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;let e=await v();try{if(await p(e,`EHLO ${t.host}`,"250"),!t.secure)try{const n=await p(e,`EHLO ${t.host}`,"250"),o=L(n);Object.keys(o).includes("STARTTLS")&&(await p(e,"STARTTLS","220"),e=await U(e),await p(e,`EHLO ${t.host}`,"250"))}catch{if(t.rejectUnauthorized)return await T(e),!1}return await k(e),await T(e),!0}catch{return await T(e),!1}}catch{return!1}}}});export{ge as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import h from"./EmailError-2CCyVX1S.js";import w from"./RequiredOptionError-BmpC5whN.js";import{e as P}from"./generate-message-id-gXAuMz4g.js";import{m as j}from"./make-request-CDhxj-9b.js";import{i as I}from"./retry-D1Rh-6Z4.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-B-xhQSqE.js";import{a as l}from"./address-formatter-bfmGfQ83.js";import{c as K}from"./attachment-processor-DjbjtJ6H.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-2CCyVX1S.js";import b from"./RequiredOptionError-BmpC5whN.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-CDhxj-9b.js";import{i as f}from"./retry-D1Rh-6Z4.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-B-xhQSqE.js";import{f as d,a as z}from"./address-formatter-bfmGfQ83.js";import{p as S}from"./attachment-processor-DjbjtJ6H.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-2CCyVX1S.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-2CCyVX1S.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-2CCyVX1S.js";import y from"./RequiredOptionError-BmpC5whN.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-CDhxj-9b.js";import{i as w}from"./retry-D1Rh-6Z4.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-B-xhQSqE.js";import{n as h}from"./address-formatter-bfmGfQ83.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};
|