@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
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## @visulima/email [2.1.9](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.8...%40visulima%2Femail%402.1.9) (2026-08-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/fs:** upgraded to 6.0.1
|
|
7
|
+
|
|
8
|
+
## @visulima/email [2.1.8](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.7...%40visulima%2Femail%402.1.8) (2026-08-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* **@visulima/error:** upgraded to 6.1.0
|
|
14
|
+
* **@visulima/fs:** upgraded to 5.1.0
|
|
15
|
+
|
|
1
16
|
## @visulima/email [2.1.7](https://github.com/visulima/visulima/compare/%40visulima%2Femail%402.1.6...%40visulima%2Femail%402.1.7) (2026-07-27)
|
|
2
17
|
|
|
3
18
|
|
package/LICENSE.md
CHANGED
|
@@ -427,9 +427,41 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
427
427
|
>
|
|
428
428
|
> # Licenses of bundled types
|
|
429
429
|
> The published @visulima/fs artifact additionally contains code with the following licenses:
|
|
430
|
-
>
|
|
430
|
+
> MIT, (MIT OR CC0-1.0)
|
|
431
431
|
>
|
|
432
432
|
> # Bundled types:
|
|
433
|
+
> ## @visulima/yaml
|
|
434
|
+
> License: MIT
|
|
435
|
+
> By: Daniel Bannert
|
|
436
|
+
> Repository: git+https://github.com/visulima/visulima.git
|
|
437
|
+
>
|
|
438
|
+
> > MIT License
|
|
439
|
+
> >
|
|
440
|
+
> > Copyright (c) 2026 visulima
|
|
441
|
+
> >
|
|
442
|
+
> > Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
443
|
+
> > of this software and associated documentation files (the "Software"), to deal
|
|
444
|
+
> > in the Software without restriction, including without limitation the rights
|
|
445
|
+
> > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
446
|
+
> > copies of the Software, and to permit persons to whom the Software is
|
|
447
|
+
> > furnished to do so, subject to the following conditions:
|
|
448
|
+
> >
|
|
449
|
+
> > The above copyright notice and this permission notice shall be included in all
|
|
450
|
+
> > copies or substantial portions of the Software.
|
|
451
|
+
> >
|
|
452
|
+
> > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
453
|
+
> > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
454
|
+
> > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
455
|
+
> > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
456
|
+
> > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
457
|
+
> > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
458
|
+
> > SOFTWARE.
|
|
459
|
+
> >
|
|
460
|
+
> >
|
|
461
|
+
> >
|
|
462
|
+
>
|
|
463
|
+
> ---------------------------------------
|
|
464
|
+
>
|
|
433
465
|
> ## is-fs-case-sensitive
|
|
434
466
|
> License: MIT
|
|
435
467
|
> By: Hiroki Osame
|
|
@@ -488,24 +520,132 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
488
520
|
>
|
|
489
521
|
> ---------------------------------------
|
|
490
522
|
>
|
|
491
|
-
> ##
|
|
492
|
-
> License:
|
|
493
|
-
> By:
|
|
494
|
-
> Repository:
|
|
495
|
-
>
|
|
496
|
-
> >
|
|
497
|
-
> >
|
|
498
|
-
> >
|
|
499
|
-
> >
|
|
500
|
-
> >
|
|
501
|
-
> >
|
|
502
|
-
> >
|
|
503
|
-
> >
|
|
504
|
-
> >
|
|
505
|
-
> >
|
|
506
|
-
> > OF
|
|
507
|
-
> >
|
|
508
|
-
> >
|
|
523
|
+
> ## type-fest
|
|
524
|
+
> License: (MIT OR CC0-1.0)
|
|
525
|
+
> By: Sindre Sorhus
|
|
526
|
+
> Repository: sindresorhus/type-fest
|
|
527
|
+
>
|
|
528
|
+
> > Creative Commons Legal Code
|
|
529
|
+
> >
|
|
530
|
+
> > CC0 1.0 Universal
|
|
531
|
+
> >
|
|
532
|
+
> > CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
533
|
+
> > LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
534
|
+
> > ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
535
|
+
> > INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
536
|
+
> > REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
537
|
+
> > PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
538
|
+
> > THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
539
|
+
> > HEREUNDER.
|
|
540
|
+
> >
|
|
541
|
+
> > Statement of Purpose
|
|
542
|
+
> >
|
|
543
|
+
> > The laws of most jurisdictions throughout the world automatically confer
|
|
544
|
+
> > exclusive Copyright and Related Rights (defined below) upon the creator
|
|
545
|
+
> > and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
546
|
+
> > authorship and/or a database (each, a "Work").
|
|
547
|
+
> >
|
|
548
|
+
> > Certain owners wish to permanently relinquish those rights to a Work for
|
|
549
|
+
> > the purpose of contributing to a commons of creative, cultural and
|
|
550
|
+
> > scientific works ("Commons") that the public can reliably and without fear
|
|
551
|
+
> > of later claims of infringement build upon, modify, incorporate in other
|
|
552
|
+
> > works, reuse and redistribute as freely as possible in any form whatsoever
|
|
553
|
+
> > and for any purposes, including without limitation commercial purposes.
|
|
554
|
+
> > These owners may contribute to the Commons to promote the ideal of a free
|
|
555
|
+
> > culture and the further production of creative, cultural and scientific
|
|
556
|
+
> > works, or to gain reputation or greater distribution for their Work in
|
|
557
|
+
> > part through the use and efforts of others.
|
|
558
|
+
> >
|
|
559
|
+
> > For these and/or other purposes and motivations, and without any
|
|
560
|
+
> > expectation of additional consideration or compensation, the person
|
|
561
|
+
> > associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
562
|
+
> > is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
563
|
+
> > elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
564
|
+
> > terms, with knowledge of his or her Copyright and Related Rights in the
|
|
565
|
+
> > Work and the meaning and intended legal effect of CC0 on those rights.
|
|
566
|
+
> >
|
|
567
|
+
> > 1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
568
|
+
> > protected by copyright and related or neighboring rights ("Copyright and
|
|
569
|
+
> > Related Rights"). Copyright and Related Rights include, but are not
|
|
570
|
+
> > limited to, the following:
|
|
571
|
+
> >
|
|
572
|
+
> > i. the right to reproduce, adapt, distribute, perform, display,
|
|
573
|
+
> > communicate, and translate a Work;
|
|
574
|
+
> > ii. moral rights retained by the original author(s) and/or performer(s);
|
|
575
|
+
> > iii. publicity and privacy rights pertaining to a person's image or
|
|
576
|
+
> > likeness depicted in a Work;
|
|
577
|
+
> > iv. rights protecting against unfair competition in regards to a Work,
|
|
578
|
+
> > subject to the limitations in paragraph 4(a), below;
|
|
579
|
+
> > v. rights protecting the extraction, dissemination, use and reuse of data
|
|
580
|
+
> > in a Work;
|
|
581
|
+
> > vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
582
|
+
> > European Parliament and of the Council of 11 March 1996 on the legal
|
|
583
|
+
> > protection of databases, and under any national implementation
|
|
584
|
+
> > thereof, including any amended or successor version of such
|
|
585
|
+
> > directive); and
|
|
586
|
+
> > vii. other similar, equivalent or corresponding rights throughout the
|
|
587
|
+
> > world based on applicable law or treaty, and any national
|
|
588
|
+
> > implementations thereof.
|
|
589
|
+
> >
|
|
590
|
+
> > 2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
591
|
+
> > of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
592
|
+
> > irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
593
|
+
> > Affirmer's Copyright and Related Rights and associated claims and causes
|
|
594
|
+
> > of action, whether now known or unknown (including existing as well as
|
|
595
|
+
> > future claims and causes of action), in the Work (i) in all territories
|
|
596
|
+
> > worldwide, (ii) for the maximum duration provided by applicable law or
|
|
597
|
+
> > treaty (including future time extensions), (iii) in any current or future
|
|
598
|
+
> > medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
599
|
+
> > including without limitation commercial, advertising or promotional
|
|
600
|
+
> > purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
601
|
+
> > member of the public at large and to the detriment of Affirmer's heirs and
|
|
602
|
+
> > successors, fully intending that such Waiver shall not be subject to
|
|
603
|
+
> > revocation, rescission, cancellation, termination, or any other legal or
|
|
604
|
+
> > equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
605
|
+
> > as contemplated by Affirmer's express Statement of Purpose.
|
|
606
|
+
> >
|
|
607
|
+
> > 3. Public License Fallback. Should any part of the Waiver for any reason
|
|
608
|
+
> > be judged legally invalid or ineffective under applicable law, then the
|
|
609
|
+
> > Waiver shall be preserved to the maximum extent permitted taking into
|
|
610
|
+
> > account Affirmer's express Statement of Purpose. In addition, to the
|
|
611
|
+
> > extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
612
|
+
> > person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
613
|
+
> > irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
614
|
+
> > Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
615
|
+
> > maximum duration provided by applicable law or treaty (including future
|
|
616
|
+
> > time extensions), (iii) in any current or future medium and for any number
|
|
617
|
+
> > of copies, and (iv) for any purpose whatsoever, including without
|
|
618
|
+
> > limitation commercial, advertising or promotional purposes (the
|
|
619
|
+
> > "License"). The License shall be deemed effective as of the date CC0 was
|
|
620
|
+
> > applied by Affirmer to the Work. Should any part of the License for any
|
|
621
|
+
> > reason be judged legally invalid or ineffective under applicable law, such
|
|
622
|
+
> > partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
623
|
+
> > of the License, and in such case Affirmer hereby affirms that he or she
|
|
624
|
+
> > will not (i) exercise any of his or her remaining Copyright and Related
|
|
625
|
+
> > Rights in the Work or (ii) assert any associated claims and causes of
|
|
626
|
+
> > action with respect to the Work, in either case contrary to Affirmer's
|
|
627
|
+
> > express Statement of Purpose.
|
|
628
|
+
> >
|
|
629
|
+
> > 4. Limitations and Disclaimers.
|
|
630
|
+
> >
|
|
631
|
+
> > a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
632
|
+
> > surrendered, licensed or otherwise affected by this document.
|
|
633
|
+
> > b. Affirmer offers the Work as-is and makes no representations or
|
|
634
|
+
> > warranties of any kind concerning the Work, express, implied,
|
|
635
|
+
> > statutory or otherwise, including without limitation warranties of
|
|
636
|
+
> > title, merchantability, fitness for a particular purpose, non
|
|
637
|
+
> > infringement, or the absence of latent or other defects, accuracy, or
|
|
638
|
+
> > the present or absence of errors, whether or not discoverable, all to
|
|
639
|
+
> > the greatest extent permissible under applicable law.
|
|
640
|
+
> > c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
641
|
+
> > that may apply to the Work or any use thereof, including without
|
|
642
|
+
> > limitation any person's Copyright and Related Rights in the Work.
|
|
643
|
+
> > Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
644
|
+
> > consents, permissions or other rights required for any use of the
|
|
645
|
+
> > Work.
|
|
646
|
+
> > d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
647
|
+
> > party to this document and has no duty or obligation with respect to
|
|
648
|
+
> > this CC0 or use of the Work.
|
|
509
649
|
|
|
510
650
|
---------------------------------------
|
|
511
651
|
|
package/dist/crypto/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{arcMessageSignatureBase as m,arcSealBase as i,signArc as a,verifyArc as t}from"../packem_shared/arcMessageSignatureBase-
|
|
1
|
+
import{arcMessageSignatureBase as m,arcSealBase as i,signArc as a,verifyArc as t}from"../packem_shared/arcMessageSignatureBase-B0Qi-724.js";import{DkimSigner as c,createDkimSigner as n}from"../packem_shared/DkimSigner-B_pEwGCS.js";import{SmimeEncrypter as g,createSmimeEncrypter as p}from"../packem_shared/SmimeEncrypter-BjBwjaTg.js";import{SmimeSigner as s,createSmimeSigner as x}from"../packem_shared/SmimeSigner-CK5TITxI.js";export{c as DkimSigner,g as SmimeEncrypter,s as SmimeSigner,m as arcMessageSignatureBase,i as arcSealBase,n as createDkimSigner,p as createSmimeEncrypter,x as createSmimeSigner,a as signArc,t as verifyArc};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from"../packem_shared/EmailError-BIaHK1Uw.js";const g=r=>r==null?[]:Array.isArray(r)?r:[r],e=r=>{if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r)},u=r=>{const a=e(r);if(a===void 0)return;const i=Number(a);return Number.isNaN(i)?void 0:i},f=r=>g(r).map(a=>({domain:e(a.domain),result:e(a.result)})),_=async r=>{let a;try{({XMLParser:a}=await import("fast-xml-parser"))}catch(t){throw t instanceof Error&&(t.code==="ERR_MODULE_NOT_FOUND"||t.message.includes("Cannot find module")||t.message.includes("Cannot find package"))?new c("deliverability","fast-xml-parser is not installed. Please install it: pnpm add fast-xml-parser",{cause:t}):new c("deliverability",`Failed to load fast-xml-parser: ${t.message}`,{cause:t})}let i;try{i=new a({ignoreAttributes:!0,parseTagValue:!1}).parse(r)}catch(t){throw new c("deliverability",`Failed to parse DMARC report: ${t.message}`,{cause:t})}const n=i.feedback??{},o=n.report_metadata??{},m=o.date_range??{},s=n.policy_published??{},y=g(n.record).map(t=>{const d=t.row??{},p=d.policy_evaluated??{},b=t.identifiers??{},l=t.auth_results??{};return{authResults:{dkim:f(l.dkim),spf:f(l.spf)},count:u(d.count)??0,disposition:e(p.disposition),dkim:e(p.dkim),headerFrom:e(b.header_from),sourceIp:e(d.source_ip),spf:e(p.spf)}});return{dateRangeBegin:e(m.begin),dateRangeEnd:e(m.end),email:e(o.email),organizationName:e(o.org_name),policyPublished:{adkim:e(s.adkim),aspf:e(s.aspf),domain:e(s.domain),p:e(s.p),pct:u(s.pct),sp:e(s.sp)},records:y,reportId:e(o.report_id)}};export{_ as parseDmarcReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseArfReport as o}from"../packem_shared/parseArfReport-
|
|
1
|
+
import{parseArfReport as o}from"../packem_shared/parseArfReport-VbQeofN4.js";import{parseDmarcRecord as p}from"../packem_shared/parseDmarcRecord-9B3Qhba8.js";import{buildListUnsubscribe as a,parseListUnsubscribe as i}from"../packem_shared/buildListUnsubscribe-g1CoihSv.js";import{buildMtaStsPolicy as m,parseMtaStsPolicy as c}from"../packem_shared/buildMtaStsPolicy-BA2YXL72.js";import{createSuppressionStore as u,filterSuppressed as x}from"../packem_shared/createSuppressionStore-DbocihI8.js";import{parseTlsReport as b,parseTlsRptRecord as d}from"../packem_shared/parseTlsReport-DSiCaKFH.js";import{default as n}from"../packem_shared/MemorySuppressionStore-D_bge6rS.js";export{n as MemorySuppressionStore,a as buildListUnsubscribe,m as buildMtaStsPolicy,u as createSuppressionStore,x as filterSuppressed,o as parseArfReport,p as parseDmarcRecord,i as parseListUnsubscribe,c as parseMtaStsPolicy,b as parseTlsReport,d as parseTlsRptRecord};
|
package/dist/events/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ALL_EVENTS as r,EventBus as t}from"../packem_shared/ALL_EVENTS-
|
|
1
|
+
import{ALL_EVENTS as r,EventBus as t}from"../packem_shared/ALL_EVENTS-CSpGgYbV.js";import{default as f}from"../packem_shared/MemoryEventStore-CuhfO9aj.js";export{r as ALL_EVENTS,t as EventBus,f as MemoryEventStore};
|
package/dist/inbound/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineInboundHandler as o,parseInbound as a}from"../packem_shared/defineInboundHandler-
|
|
1
|
+
import{defineInboundHandler as o,parseInbound as a}from"../packem_shared/defineInboundHandler-CnYn10ex.js";import{default as d}from"../packem_shared/parseCloudflareInbound-BKZzk0De.js";import{default as t}from"../packem_shared/parseMailgunInbound-nY-DXZrK.js";import{default as f}from"../packem_shared/parsePostmarkInbound-0zG71J7F.js";import{default as l}from"../packem_shared/parseSendGridInbound-BzEhN-gd.js";import{default as x}from"../packem_shared/parseSesInbound-C4cRtAUq.js";import{extractReply as I}from"../packem_shared/extractReply-CLoWMY97.js";import{normalizeMessageId as c,normalizeSubject as S,stitchThreads as g}from"../packem_shared/normalizeMessageId-0yB1zeyC.js";import{parseAddress as z,parseAddressList as A,parseReferences as M}from"../packem_shared/parseAddress-DW9suGjV.js";export{o as defineInboundHandler,I as extractReply,c as normalizeMessageId,S as normalizeSubject,z as parseAddress,A as parseAddressList,d as parseCloudflareInbound,a as parseInbound,t as parseMailgunInbound,f as parsePostmarkInbound,M as parseReferences,l as parseSendGridInbound,x as parseSesInbound,g as stitchThreads};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-
|
|
1
|
+
export { type A as AttachmentDataOptions, type a as AttachmentOptions, type B as BatchBase, type b as BatchRenderer, D as DraftMailMessage, type F as FeatureCheckMode, M as Mail, type c as MailGlobalConfig, d as MailMessage, type e as MailOptions, type P as Personalization, type S as SendBatchOptions, type f as SendableMessage, g as createMail, h as detectMimeType, i as generateContentId, r as readFileAsBuffer } from "./packem_shared/mail.d-8M9NjOr0.js";
|
|
2
2
|
export type { M as Middleware, S as SendFunction } from "./packem_shared/types.d-GKqPNk0I.js";
|
|
3
3
|
export { type a as Provider, type P as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-Cx5YQJdP.js";
|
|
4
4
|
export type { T as TemplateRenderer } from "./packem_shared/types.d-I-KeZ5w2.js";
|
|
@@ -8,7 +8,6 @@ export { type OkResult, isErr, isOk, mapOk, tryAsync, unwrap, unwrapOr } from ".
|
|
|
8
8
|
export { type FeatureSupportResult, type FeatureViolation, default as checkFeatureSupport } from "./utils/validation/check-feature-support.js";
|
|
9
9
|
import 'ical-generator';
|
|
10
10
|
import 'node:buffer';
|
|
11
|
-
import 'node:crypto';
|
|
12
11
|
import "./packem_shared/types.d-B0t3PQ3t.js";
|
|
13
12
|
interface ErrorProperties {
|
|
14
13
|
cause?: unknown;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-
|
|
1
|
+
import{detectMimeType as a,generateContentId as t,readFileAsBuffer as o}from"./packem_shared/detectMimeType-DVC9Uvy9.js";import{default as p}from"./packem_shared/DraftMailMessage-Tj3sH8nn.js";import{default as m}from"./packem_shared/EmailError-BIaHK1Uw.js";import{default as l}from"./packem_shared/RequiredOptionError-ctDEEB1s.js";import{Mail as u,createMail as x}from"./packem_shared/Mail-Cm24B3w0.js";import{default as M}from"./packem_shared/MailMessage-BtI4qMU1.js";import{defineProvider as E}from"./packem_shared/defineProvider-C9q-7iwt.js";import{default as g}from"./utils/parse-eml.js";import{isErr as y,isOk as w,mapOk as A,tryAsync as F,unwrap as h,unwrapOr as q}from"./utils/result.js";import{default as B}from"./utils/validation/check-feature-support.js";export{p as DraftMailMessage,m as EmailError,u as Mail,M as MailMessage,l as RequiredOptionError,B as checkFeatureSupport,x as createMail,E as defineProvider,a as detectMimeType,t as generateContentId,y as isErr,w as isOk,A as mapOk,g as parseEml,o as readFileAsBuffer,F as tryAsync,h as unwrap,q as unwrapOr};
|
package/dist/middleware/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{circuitBreakerMiddleware as o}from"../packem_shared/circuitBreakerMiddleware-
|
|
1
|
+
import{circuitBreakerMiddleware as o}from"../packem_shared/circuitBreakerMiddleware-DcBN7K6H.js";import{dedupeMiddleware as i}from"../packem_shared/dedupeMiddleware-BTo8Qjje.js";import{withEvents as p}from"../packem_shared/withEvents-BinK2hMw.js";import{loggingMiddleware as f}from"../packem_shared/loggingMiddleware-DNVf8O1B.js";import{withMetrics as w}from"../packem_shared/withMetrics-i3mZVfeE.js";import{oauth2Middleware as l}from"../packem_shared/oauth2Middleware-DbKGd7Z9.js";import{RATE_LIMIT_PRESETS as h,rateLimitMiddleware as s}from"../packem_shared/RATE_LIMIT_PRESETS-BIFmRuh2.js";import{default as c}from"../packem_shared/withRender-Ce6leoYE.js";import{retryMiddleware as E}from"../packem_shared/retryMiddleware-CaTv0UIm.js";import{withSuppression as g}from"../packem_shared/withSuppression-B0eZ2xNQ.js";import{withTelemetry as S}from"../packem_shared/withTelemetry-DEKTis1I.js";import{composeMiddleware as I}from"../packem_shared/composeMiddleware-B3RCDFsy.js";export{h as RATE_LIMIT_PRESETS,o as circuitBreakerMiddleware,I as composeMiddleware,i as dedupeMiddleware,f as loggingMiddleware,l as oauth2Middleware,s as rateLimitMiddleware,E as retryMiddleware,p as withEvents,w as withMetrics,c as withRender,g as withSuppression,S as withTelemetry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r="*";class o{listeners=new Map;on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>{this.off(e,t)}}once(e,t){const s=i=>{this.off(e,s),t(i)};return this.on(e,s)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e){const t=s=>{try{s(e)}catch{}};for(const s of this.listeners.get(e.type)??[])t(s);for(const s of this.listeners.get("*")??[])t(s)}clear(e){e===void 0?this.listeners.clear():this.listeners.delete(e)}}export{r as ALL_EVENTS,o as EventBus};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{createRequire as $}from"node:module";import{z as v}from"./index-B8wiKJdh.js";import{h as L}from"./headers-to-record-ZOZ7Dubo.js";let j;const C=n=>(j??=$(import.meta.url))(n),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=n=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,t]=p.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return p.getBuiltinModule(n)}return C(n)},{createHash:f,createPrivateKey:w,sign:H,createSign:T}=z("node:crypto"),_=(n,e="simple")=>{const t=[];for(const[r,s]of Object.entries(n)){const o=e==="relaxed"?r.toLowerCase().trim():r,a=e==="relaxed"?s.replaceAll(/\s+/g," ").trim():s;t.push(`${o}:${a}`)}return t.join(`\r
|
|
2
|
+
`)},S=(n,e="simple")=>{if(e==="simple"){const i=n.replace(/(\r\n|\r|\n)$/,`
|
|
3
|
+
`);let c=i.length;for(;c>0&&i[c-1]===`
|
|
4
|
+
`;)c-=1;const h=i.slice(0,c);return h?`${h}
|
|
5
|
+
`:`
|
|
6
|
+
`}let t=n.replaceAll(`\r
|
|
7
|
+
`,`
|
|
8
|
+
`).replaceAll("\r",`
|
|
9
|
+
`);t=t.split(`
|
|
10
|
+
`).map(i=>i.replaceAll(/\s+/g," ").replace(/[ \t]+$/,"")).join(`
|
|
11
|
+
`);let o=t.length;for(;o>0&&t[o-1]===`
|
|
12
|
+
`;)o-=1;const a=t.slice(0,o);return a?`${a}
|
|
13
|
+
`:`
|
|
14
|
+
`},x=(n,e,t)=>{const r=e.headerCanon??"simple",s=e.bodyCanon??"simple",o=Object.keys(n).filter(i=>!e.headersToIgnore?.some(c=>c.toLowerCase()===i.toLowerCase())).map(i=>i.toLowerCase()).join(":");return["v=1",`a=${e.algorithm??"rsa-sha256"}`,`c=${r}/${s}`,`d=${e.domainName}`,`s=${e.keySelector}`,`h=${o}`,`bh=${t}`,"b="].join("; ")},I=(n,e,t)=>t==="ed25519-sha256"?H(null,f("sha256").update(n).digest(),e).toString("base64"):T("RSA-SHA256").update(n).sign(e,"base64");class l{static sanitizeDisplayName(e){let t=e.replaceAll(/[\r\n\t]+/g," ");t=[...t].filter(o=>{const a=o.codePointAt(0);return a===void 0?!1:a>=32&&a<=126||a>159}).join("");const r="\\",s='"';return t=t.replaceAll(r,r+r).replaceAll(s,r+s),t=t.trim().replaceAll(/\s+/g," "),t}static formatAddress(e){if(e.name){const t=l.sanitizeDisplayName(e.name);return t?`"${t}" <${e.email}>`:e.email}return e.email}static formatAddresses(e){return(Array.isArray(e)?e:[e]).map(r=>l.formatAddress(r)).join(", ")}options;constructor(e){this.options=e}async sign(e){let t=this.options.privateKey;if(t.startsWith("file://")){const d=t.slice(7);t=await v(d,{encoding:"utf8"})}const r={...e.headers?L(e.headers):{},From:l.formatAddress(e.from),To:l.formatAddresses(e.to)};e.cc&&(r.Cc=l.formatAddresses(e.cc)),e.replyTo&&(r["Reply-To"]=l.formatAddress(e.replyTo)),r.Subject=e.subject,r["MIME-Version"]="1.0";const s=[];e.text&&s.push(e.text),e.html&&s.push(e.html);const o=s.join(`
|
|
15
|
+
|
|
16
|
+
`),a=this.options.headerCanon??"simple",i=this.options.bodyCanon??"simple",c=_(r,a),h=S(o,i),g=f("sha256").update(h).digest("base64"),m=x(r,this.options,g),y=`${c}\r
|
|
17
|
+
DKIM-Signature: ${m}`;let u;try{const d=w({key:t,passphrase:this.options.passphrase});u=I(y,d,this.options.algorithm)}catch(d){throw new Error(`Failed to create DKIM signature: ${d.message}`)}const A=u.match(/.{1,72}/g)?.join(`\r
|
|
18
|
+
`)??u,b={...r,"DKIM-Signature":`${m}${A}`};return{...e,headers:b}}}const R=n=>new l(n);export{l as DkimSigner,R as createDkimSigner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./MailMessage-BtI4qMU1.js";class t extends e{constructor(){super(),this.header("X-Unsent","1")}}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class l extends Error{loc;title;hint;type="VisulimaError";constructor({cause:t,hint:e,location:s,message:a,name:c,stack:r,title:h}){super(a,{cause:t}),this.title=h,this.name=c,this.stack=r??this.stack,this.loc=s,this.hint=e}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}class o extends l{component;code;constructor(t,e,s){super({cause:s?.cause,hint:s?.hint,message:`[@visulima/email] [${t}] ${e}`,name:"EmailError",title:`Email ${t} Error`}),this.component=t,this.code=s?.code}}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import f from"./DraftMailMessage-Tj3sH8nn.js";import v from"./EmailError-BIaHK1Uw.js";import u from"./MailMessage-BtI4qMU1.js";import{composeMiddleware as w}from"./composeMiddleware-B3RCDFsy.js";import{b as C}from"./build-mime-message-QNCMA6oQ.js";import{c as M}from"./create-logger-CazqtXcL.js";import{h as d}from"./headers-to-record-ZOZ7Dubo.js";import T from"../utils/validation/check-feature-support.js";const S=(a,e,r)=>{e.success&&e.data?a&&a.info("Email sent successfully",{messageId:e.data.messageId,provider:e.data.provider}):a&&a.error("Email send failed",{error:e.error,provider:r})},E=async(a,e,r)=>{const t={...a,to:e.to};return e.cc&&(t.cc=e.cc),e.bcc&&(t.bcc=e.bcc),e.replyTo&&(t.replyTo=e.replyTo),e.headers&&(t.headers={...d(a.headers??{}),...d(e.headers)}),t.subject=e.subject??a.subject,r&&e.data&&(t.subject=await r(t.subject,e.data),a.html!==void 0&&(t.html=await r(a.html,e.data)),a.text!==void 0&&(t.text=await r(a.text,e.data))),t};class h{static extractErrorMessages(e){return e instanceof Error?[e.message]:[String(e??"Unknown error")]}provider;logger;loggerInstance;globalConfig;featureCheck;middlewares=[];composedSend;mountedProviders=new Map;constructor(e,r){this.provider=e,this.featureCheck=r?.featureCheck??"error"}setLogger(e){return this.loggerInstance=e,this.logger=M("Mail",e),this}use(e){return this.middlewares.push(e),this.composedSend=void 0,this}mount(e,r){return this.mountedProviders.set(e,r),this}setFrom(e){return this.globalConfig??={},this.globalConfig.from=e,this.logger&&this.logger.debug("Default from address updated",{from:e.email}),this}setReplyTo(e){return this.globalConfig??={},this.globalConfig.replyTo=e,this.logger&&this.logger.debug("Default reply-to address updated",{replyTo:e.email}),this}setHeaders(e){if(this.globalConfig??={},this.globalConfig.headers=e,this.logger){const r=d(e);this.logger.debug("Default headers updated",{count:Object.keys(r).length,headers:Object.keys(r)})}return this}async draft(e){let r=e instanceof u||e instanceof f?await this.buildDraftFromMessage(e):await this.buildDraftFromOptions(e);r=this.applyGlobalConfig(r);const t=r.headers?d(r.headers):{};r.headers={...t,"X-Unsent":"1"};const s=await C(r,{includeBcc:!0});return this.logger&&this.logger.debug("Draft created successfully in EML format",{from:r.from.email,size:s.length,subject:r.subject,to:Array.isArray(r.to)?r.to.length:1}),s}async send(e){if(e instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");let r;if(e instanceof u)this.logger&&this.logger.debug("Sending MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),r=await e.build();else{const o=e;this.logger&&this.logger.debug("Sending email with options",{subject:o.subject,to:Array.isArray(o.to)?o.to.length:1}),r=o}r=this.applyGlobalConfig(r);const t=this.assertFeatureSupport(r,this.resolveProvider(r));if(t)return{error:t,success:!1};const s=await this.dispatch(r);return S(this.logger,s,this.provider.name??"unknown"),s}sendMany(e,r){const t=Math.max(1,Math.floor(r?.concurrency??1));return t===1?this.sendManySerial(e,r?.signal):this.sendManyConcurrent(e,t,r?.signal)}sendBatch(e,r,t){const s=async function*(){const o=e instanceof u?await e.build():e;for(const i of r)yield await E(o,i,t?.render)};return this.sendMany(s(),{concurrency:t?.concurrency,signal:t?.signal})}async sendOneToReceipt(e){const r=this.provider.name;try{const t=await this.send(e);return t.success&&t.data?{messageId:t.data.messageId,provider:t.data.provider??r,response:t.data.response,successful:!0,timestamp:t.data.timestamp}:{errorMessages:h.extractErrorMessages(t.error),provider:r,successful:!1}}catch(t){return{errorMessages:h.extractErrorMessages(t),provider:r,successful:!1}}}async*sendManySerial(e,r){const t=this.provider.name;let s=0,o=0,i=0;this.logger&&this.logger.debug("Starting batch email send",{provider:t});for await(const l of e){if(l instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");if(r?.aborted){this.logger&&this.logger.warn("Batch send operation was aborted",{failed:i,processed:s,successful:o}),yield{errorMessages:["Send operation was aborted"],provider:t,successful:!1};return}s+=1;const n=await this.sendOneToReceipt(l);n.successful?o+=1:i+=1,yield n}this.logger&&this.logger.debug("Batch email send completed",{failureCount:i,processedCount:s,provider:t,successCount:o})}async*sendManyConcurrent(e,r,t){const s=this.provider.name;this.logger&&this.logger.debug("Starting concurrent batch email send",{concurrency:r,provider:s});const o=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator](),i=new Map;let l=0,n=!1,p=!1;const m=async()=>{for(;!n&&!p&&i.size<r;){const g=await o.next();if(g.done){n=!0;break}const c=g.value;if(c instanceof f)throw new TypeError("Cannot send draft messages. Convert to MailMessage first or remove X-Unsent header.");const b=l;l+=1,i.set(b,this.sendOneToReceipt(c).then(y=>({id:b,receipt:y})))}};for(await m();i.size>0;){if(t?.aborted){p=!0,yield{errorMessages:["Send operation was aborted"],provider:s,successful:!1};return}const{id:g,receipt:c}=await Promise.race(i.values());i.delete(g),yield c,await m()}this.logger&&this.logger.debug("Concurrent batch email send completed",{processedCount:l,provider:s})}async dispatch(e){return this.middlewares.length===0?await this.resolveProvider(e).sendEmail(e):(this.composedSend??=w(this.middlewares,r=>Promise.resolve(this.resolveProvider(r).sendEmail(r))),await this.composedSend(e))}resolveProvider(e){return e.stream!==void 0?this.mountedProviders.get(e.stream)??this.provider:this.provider}assertFeatureSupport(e,r){if(this.featureCheck==="off")return;const{supported:t,violations:s}=T(e,r.features);if(t)return;const o=r.name??"unknown",i=s.map(n=>n.field),l=s.map(n=>n.message);if(this.featureCheck==="warn"){this.logger&&this.logger.warn("Message uses capabilities the provider does not support",{fields:i,provider:o});return}return this.logger&&this.logger.error("Message rejected by capability guard",{fields:i,provider:o}),new v(o,`Provider does not support the following message fields: ${i.join(", ")}`,{code:"UNSUPPORTED_FEATURES",hint:l})}async buildDraftFromMessage(e){return this.logger&&this.logger.debug("Creating draft from MailMessage instance"),this.loggerInstance&&e.setLogger(this.loggerInstance),this.applyGlobalConfigToMessage(e),await e.build()}async buildDraftFromOptions(e){return this.logger&&this.logger.debug("Creating draft from email options",{subject:e.subject,to:Array.isArray(e.to)?e.to.length:1}),e}applyGlobalConfigToMessage(e){const r=this.globalConfig?.from;r&&!e.getFrom()&&e.from(r);const t=this.globalConfig?.replyTo;if(t&&!e.getReplyTo()&&e.replyTo(t),this.globalConfig?.headers){const s=d(this.globalConfig.headers);Object.entries(s).forEach(([o,i])=>{e.header(o,i)})}}applyGlobalConfig(e){if(!this.globalConfig)return e;const r={...e};if(!r.from&&this.globalConfig.from&&(r.from=this.globalConfig.from,this.logger&&this.logger.debug("Applied global from address",{from:this.globalConfig.from.email})),!r.replyTo&&this.globalConfig.replyTo&&(r.replyTo=this.globalConfig.replyTo,this.logger&&this.logger.debug("Applied global reply-to address",{replyTo:this.globalConfig.replyTo.email})),this.globalConfig.headers){const t=d(this.globalConfig.headers),s=r.headers?d(r.headers):{};r.headers={...t,...s},this.logger&&this.logger.debug("Merged global headers",{globalCount:Object.keys(t).length,messageCount:Object.keys(s).length})}return r}}const O=(a,e)=>new h(a,e);export{h as Mail,O as createMail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as p}from"node:module";import{readFileAsBuffer as c,detectMimeType as d,generateContentId as u}from"./detectMimeType-DVC9Uvy9.js";import{c as T}from"./create-logger-CazqtXcL.js";import{h as l}from"./headers-to-record-ZOZ7Dubo.js";let y;const A=n=>(y??=p(import.meta.url))(n),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=n=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,e]=o.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return o.getBuiltinModule(n)}return A(n)},{basename:g}=f("node:path"),{fileURLToPath:b}=f("node:url"),m=async()=>(await import("../template-engines/html-to-text.js")).default,x=async()=>(await import("ical-generator")).default,a=n=>Array.isArray(n)?n.map(t=>typeof t=="string"?{email:t}:t):typeof n=="string"?[{email:n}]:[n];class D{fromAddress;toAddresses=[];ccAddresses=[];bccAddresses=[];subjectText="";textContent;textCharset="utf8";autoTextEnabled=!0;htmlContent;htmlCharset="utf8";dateValue;returnPathAddress;senderAddress;headers={};attachments=[];replyToAddress;priorityValue;tagsValue=[];signer;encrypter;logger;icalEventData;icalEventBuilder;from(t){return this.fromAddress=typeof t=="string"?{email:t}:t,this}to(t){return this.toAddresses.length=0,this.toAddresses.push(...a(t)),this}cc(t){return this.ccAddresses.length=0,this.ccAddresses.push(...a(t)),this}bcc(t){return this.bccAddresses.length=0,this.bccAddresses.push(...a(t)),this}subject(t){return this.subjectText=t,this}text(t,e="utf8"){return this.textContent=t,this.textCharset=e,this}html(t,e="utf8"){return this.htmlContent=t,this.htmlCharset=e,this}header(t,e){return this.headers[t]=e,this}setHeaders(t){const e=l(t);return Object.assign(this.headers,e),this}async attachFromPath(t,e){try{const r=await c(t),i=e?.filename??(g(t)||"attachment"),s=e?.contentType??d(i);this.attachments.push({cid:e?.cid,content:r,contentDisposition:e?.contentDisposition??"attachment",contentType:s,encoding:e?.encoding,filename:i,headers:e?.headers}),this.logger&&this.logger.debug(`Attachment added from path: ${t}`,{contentType:s,filename:i})}catch(r){throw this.logger&&this.logger.error(`Failed to attach file from path: ${t}`,r),r}return this}attachData(t,e){const r=e.contentType??d(e.filename);return this.attachments.push({cid:e.cid,content:t,contentDisposition:e.contentDisposition??"attachment",contentType:r,encoding:e.encoding,filename:e.filename,headers:e.headers}),this.logger&&this.logger.debug("Attachment added from data",{contentType:r,filename:e.filename}),this}async embedFromPath(t,e){try{const r=await c(t),i=e?.filename??(g(t)||"inline"),s=e?.contentType??d(i),h=u(i);return this.attachments.push({cid:h,content:r,contentDisposition:"inline",contentType:s,filename:i}),this.logger&&this.logger.debug(`Inline attachment embedded from path: ${t}`,{cid:h,contentType:s,filename:i}),h}catch(r){throw this.logger&&this.logger.error(`Failed to embed file from path: ${t}`,r),r}}embedData(t,e,r){const i=r?.contentType??d(e),s=u(e);return this.attachments.push({cid:s,content:t,contentDisposition:"inline",contentType:i,filename:e}),this.logger&&this.logger.debug("Inline attachment embedded from data",{cid:s,contentType:i,filename:e}),s}replyTo(t){return this.replyToAddress=typeof t=="string"?{email:t}:t,this}date(t){return this.dateValue=typeof t=="string"?new Date(t):t,this.logger&&this.logger.debug("Date header set",{date:this.dateValue.toISOString()}),this}returnPath(t){return this.returnPathAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Return-path address set",{returnPath:this.returnPathAddress.email}),this}sender(t){return this.senderAddress=typeof t=="string"?{email:t}:t,this.logger&&this.logger.debug("Sender address set",{sender:this.senderAddress.email}),this}addTo(t){return this.toAddresses.push(...a(t)),this}addCc(t){return this.ccAddresses.push(...a(t)),this}addBcc(t){return this.bccAddresses.push(...a(t)),this}addReplyTo(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const r=e[0];this.replyToAddress=typeof r=="string"?{email:r}:r}return this}addFrom(t){const e=Array.isArray(t)?t:[t];if(e.length>0){const r=e[0];this.fromAddress=typeof r=="string"?{email:r}:r}return this}priority(t){return this.priorityValue=t,this}tags(t){return this.tagsValue=Array.isArray(t)?t:[t],this}sign(t){return this.signer=t,this.logger&&this.logger.debug("Email signer configured"),this}encrypt(t){return this.encrypter=t,this.logger&&this.logger.debug("Email encrypter configured"),this}setLogger(t){return this.logger=T("MailMessage",t),this}icalEvent(t,e){return typeof t=="function"?(this.icalEventBuilder={build:t,options:e},this.icalEventData=void 0):(this.icalEventBuilder=void 0,this.icalEventData={content:t,...e}),this.logger&&this.logger.debug("Calendar event attached",{method:e?.method}),this}icalEventFromFile(t,e){const r=typeof t=="string"?t:b(t);return this.icalEventData={path:r,...e},this.logger&&this.logger.debug(`Calendar event attached from file: ${r}`,{method:e?.method}),this}icalEventFromUrl(t,e){return this.icalEventData={href:t,...e},this.logger&&this.logger.debug(`Calendar event attached from URL: ${t}`,{method:e?.method}),this}async view(t,e,r,i){try{const s=i?.autoText!==!1;this.autoTextEnabled=s,this.logger&&this.logger.debug("Rendering template",{autoText:s});const h=await t(e,r,i);this.html(h),s&&h&&await this.tryAutoGenerateText(h),this.logger&&this.logger.debug("Template rendered successfully")}catch(s){throw this.logger&&this.logger.error("Failed to render template",s),new Error(`Failed to render template: ${s.message}`)}return this}async viewText(t,e,r,i){try{this.logger&&this.logger.debug("Rendering text template");const s=await t(e,r,i);if(typeof s=="string")this.text(s),this.logger&&this.logger.debug("Text template rendered successfully");else throw new TypeError("Text renderer must return a string")}catch(s){throw this.logger&&this.logger.error("Failed to render text template",s),new Error(`Failed to render text template: ${s.message}`)}return this}async build(){if(this.logger&&this.logger.debug("Building email message"),this.fromAddress||this.throwAndLogError("From address is required","Build failed: from address is required"),this.toAddresses.length===0&&this.throwAndLogError("At least one recipient is required","Build failed: at least one recipient is required"),this.subjectText||this.throwAndLogError("Subject is required","Build failed: subject is required"),this.htmlContent&&!this.textContent&&this.autoTextEnabled)try{const e=await m();this.textContent=e(this.htmlContent),this.logger&&this.logger.debug("Auto-generated text content from HTML")}catch{this.logger&&this.logger.debug("Failed to convert HTML to text; proceeding without text content.")}!this.textContent&&!this.htmlContent&&this.throwAndLogError("Either text or html content is required","Build failed: either text or html content is required");let t={from:this.fromAddress,html:this.htmlContent,subject:this.subjectText,text:this.textContent,to:this.toAddresses.length===1?this.toAddresses[0]:this.toAddresses};if(this.ccAddresses.length>0&&(t.cc=this.ccAddresses.length===1?this.ccAddresses[0]:this.ccAddresses),this.bccAddresses.length>0&&(t.bcc=this.bccAddresses.length===1?this.bccAddresses[0]:this.bccAddresses),Object.keys(this.headers).length>0&&(t.headers=this.headers),this.attachments.length>0&&(t.attachments=this.attachments,this.logger&&this.logger.debug(`Email includes ${this.attachments.length} attachment(s)`)),this.replyToAddress&&(t.replyTo=this.replyToAddress),this.priorityValue&&(t.priority=this.priorityValue),this.tagsValue.length>0&&(t.tags=this.tagsValue),this.icalEventBuilder){const r=(await x())();this.icalEventBuilder.build(r),this.icalEventData={content:r.toString(),...this.icalEventBuilder.options}}return this.icalEventData&&(t.icalEvent=this.icalEventData,this.logger&&this.logger.debug("Email includes calendar event")),this.dateValue&&(t.headers={...l(t.headers??{}),Date:this.dateValue.toUTCString()}),this.returnPathAddress&&(t.headers={...l(t.headers??{}),"Return-Path":this.returnPathAddress.email}),this.senderAddress&&(t.headers={...l(t.headers??{}),Sender:this.senderAddress.email}),this.signer&&(this.logger&&this.logger.debug("Signing email message"),t=await this.signer.sign(t),this.logger&&this.logger.debug("Email message signed successfully")),this.encrypter&&(this.logger&&this.logger.debug("Encrypting email message"),t=await this.encrypter.encrypt(t),this.logger&&this.logger.debug("Email message encrypted successfully")),this.logger&&this.logger.debug("Email message built successfully",{bcc:this.bccAddresses.length,cc:this.ccAddresses.length,hasHtml:!!this.htmlContent,hasText:!!this.textContent,to:this.toAddresses.length}),t}getSubject(){return this.subjectText}getFrom(){return this.fromAddress}getTo(){return[...this.toAddresses]}getCc(){return[...this.ccAddresses]}getBcc(){return[...this.bccAddresses]}getReplyTo(){return this.replyToAddress}getSender(){return this.senderAddress}getReturnPath(){return this.returnPathAddress}getDate(){return this.dateValue}getPriority(){return this.priorityValue}getTextBody(){return this.textContent}getTextCharset(){return this.textCharset}getHtmlBody(){return this.htmlContent}getHtmlCharset(){return this.htmlCharset}getAttachments(){return[...this.attachments]}async tryAutoGenerateText(t){try{const r=(await m())(t);r&&!this.textContent&&this.text(r),this.logger&&this.logger.debug("Auto-generated text content from HTML template")}catch(e){this.logger&&this.logger.warn("Failed to auto-generate text from HTML template",e)}}throwAndLogError(t,e){const r=new Error(t);throw this.logger&&this.logger.error(e??t),r}}export{D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=a=>a.trim().toLowerCase();class i{entries=new Map;constructor(e){if(e)for(const{address:r,metadata:n,reason:t}of e)this.add(r,t,n)}add(e,r,n){const t=s(e);this.entries.set(t,{address:t,createdAt:new Date,metadata:n,reason:r})}get(e){return this.entries.get(s(e))}has(e){return this.entries.has(s(e))}list(){return this.entries.values()}remove(e){return this.entries.delete(s(e))}get size(){return this.entries.size}}export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const w=a=>new Promise(n=>{setTimeout(n,a)}),p={"aws-ses":14,mailgun:100,postmark:100,resend:10,sendgrid:100},h=a=>{const{burst:n,now:o=Date.now,rate:t,sleep:d=w}=a;if(t<=0||Number.isNaN(t))throw new TypeError("rateLimitMiddleware: `rate` must be a positive number");const c=n??t;let s=c,l=o(),u=Promise.resolve();const m=async()=>{const i=()=>{const e=o(),r=(e-l)/1e3;s=Math.min(c,s+r*t),l=e};for(i();s<1;){const e=1-s;await d(Math.ceil(e/t*1e3)),i()}s-=1};return async(i,e)=>{const r=u.then(()=>m());return u=r.catch(()=>{}),await r,e(i)}};export{p as RATE_LIMIT_PRESETS,h as rateLimitMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"./EmailError-BIaHK1Uw.js";class n extends s{constructor(o,r){const e=Array.isArray(r)?`Missing required options: ${r.map(i=>`'${i}'`).join(", ")}`:`Missing required option: '${r}'`;super(o,e,{hint:Array.isArray(r)?`Please provide the following required options: ${r.map(i=>`'${i}'`).join(", ")}`:`Please provide the required option: '${r}'`}),this.name="RequiredOptionError"}}export{n as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{createRequire as O}from"node:module";import{z as I}from"./index-B8wiKJdh.js";import{fromBER as S,OctetString as B}from"asn1js";import{Certificate as P,EnvelopedData as G,EncryptedContentInfo as V,id_ContentType_Data as J,RecipientInfo as Q,KeyTransRecipientInfo as W,IssuerAndSerialNumber as X,AlgorithmIdentifier as $,ContentInfo as Y,id_ContentType_EnvelopedData as Z}from"pkijs";let L;const q=s=>(L??=O(import.meta.url))(s),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=s=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,t]=y.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return y.getBuiltinModule(s)}return q(s)},{randomBytes:T,createCipheriv:U,createPublicKey:z,publicEncrypt:H}=F("node:crypto"),g=globalThis.Buffer!==void 0,D=s=>{const e=s.replaceAll(/-----BEGIN[^-]+-----/g,"").replaceAll(/-----END[^-]+-----/g,"").replaceAll(/\s/g,"");if(g)return Buffer.from(e,"base64");const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n+=1)r[n]=t.charCodeAt(n);return r},j=(s,e)=>{let t;if(g)t=Buffer.from(s).toString("base64");else{const n=new Uint8Array(s);let l="";const o=8192;for(let c=0;c<n.length;c+=o){const h=n.subarray(c,Math.min(c+o,n.length));l+=String.fromCharCode(...h)}t=btoa(l)}const r=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
|
|
2
|
+
${r.join(`
|
|
3
|
+
`)}
|
|
4
|
+
-----END ${e}-----
|
|
5
|
+
`};class i{static collectRecipients(e){const t=[],r=n=>{if(!n)return;const l=Array.isArray(n)?n:[n];for(const o of l){const c=typeof o=="string"?o:o.email;c&&t.push(c)}};return r(e.to),r(e.cc),r(e.bcc),[...new Set(t)]}static formatAddress(e){return typeof e=="string"?e:e.name?`"${e.name}" <${e.email}>`:e.email}static formatAddresses(e){return(Array.isArray(e)?e:[e]).map(r=>i.formatAddress(r)).join(", ")}options;constructor(e){this.options=e}async encrypt(e){const t=i.collectRecipients(e),r=[];if(typeof this.options.certificates=="string"){const a=await I(this.options.certificates,{encoding:"utf8"}),f=D(a),u=S(f);if(u.offset===-1)throw new Error("Failed to parse certificate: Invalid ASN.1 structure");r.push(new P({schema:u.result}))}else{const a=t.map(async f=>{const u=this.options.certificates[f];if(!u)throw new Error(`No certificate found for recipient: ${f}`);const A=await I(u,{encoding:"utf8"}),E=D(A),p=S(E);if(p.offset===-1)throw new Error(`Failed to parse certificate for ${f}: Invalid ASN.1 structure`);return new P({schema:p.result})});r.push(...await Promise.all(a))}const n=await this.buildMessage(e),l=new TextEncoder().encode(n),o=new G({version:0});o.encryptedContentInfo=new V({contentType:J});const h=(this.options.algorithm??"aes-256-cbc").toLowerCase();if(h==="3des"||h==="des-ede3-cbc")throw new Error("3DES/DES-EDE3-CBC is deprecated and insecure (Sweet32 vulnerability). Please use AES-256-CBC, AES-192-CBC, or AES-128-CBC instead.");let m,d;switch(h){case"aes128":case"aes-128-cbc":{m="2.16.840.1.101.3.4.1.2",d=16;break}case"aes192":case"aes-192-cbc":{m="2.16.840.1.101.3.4.1.22",d=24;break}default:{m="2.16.840.1.101.3.4.1.42",d=32;break}}const w=T(d),k=g?w:new Uint8Array(w),C=T(16),_=g?C:new Uint8Array(C),v=U(`aes-${d*8}-cbc`,w,C),x=Buffer.from(l),N=[v.update(x),v.final()],b=Buffer.concat(N);o.encryptedContentInfo.encryptedContent=new B({valueHex:b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength)});const R=await Promise.all(r.map(async a=>{const f=a.toSchema().toBER(!1),u=j(f,"CERTIFICATE"),A=z(u),E=Buffer.from(k),p=H({key:A,padding:1},E);return new Q({value:new W({encryptedKey:new B({valueHex:p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength)}),keyEncryptionAlgorithm:new $({algorithmId:"1.2.840.113549.1.1.1"}),rid:new X({issuer:a.issuer,serialNumber:a.serialNumber}),version:0}),variant:0})}));o.recipientInfos.push(...R),o.encryptedContentInfo.contentEncryptionAlgorithm=new $({algorithmId:m,algorithmParams:new B({valueHex:_.buffer})});const K=new Y({content:o.toSchema(),contentType:Z}).toSchema().toBER(!1),M=j(K,"PKCS7");return{...e,headers:{...e.headers,"Content-Disposition":"attachment; filename=smime.p7m","Content-Transfer-Encoding":"base64","Content-Type":"application/pkcs7-mime; smime-type=enveloped-data; name=smime.p7m"},html:void 0,text:M}}async buildMessage(e){const t=[`From: ${i.formatAddress(e.from)}`,`To: ${i.formatAddresses(e.to)}`,...e.cc?[`Cc: ${i.formatAddresses(e.cc)}`]:[]];if(e.replyTo&&t.push(`Reply-To: ${i.formatAddress(e.replyTo)}`),t.push(`Subject: ${e.subject}`,"MIME-Version: 1.0"),e.headers)for(const[r,n]of Object.entries(e.headers))t.push(`${r}: ${n}`);return e.html?t.push("Content-Type: text/html; charset=utf-8"):e.text&&t.push("Content-Type: text/plain; charset=utf-8"),t.push(""),e.html?t.push(e.html):e.text&&t.push(e.text),t.join(`\r
|
|
6
|
+
`)}}const se=s=>new i(s);export{i as SmimeEncrypter,se as createSmimeEncrypter};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{createRequire as F}from"node:module";import{z as y}from"./index-B8wiKJdh.js";import{fromBER as D,ObjectIdentifier as W,OctetString as I,UTCTime as X}from"asn1js";import{Certificate as j,SignedData as Y,EncapsulatedContentInfo as Z,id_ContentType_Data as x,SignerInfo as ee,AlgorithmIdentifier as E,IssuerAndSerialNumber as te,id_sha256 as ne,SignedAndUnsignedAttributes as se,Attribute as b,ContentInfo as re,id_ContentType_SignedData as oe}from"pkijs";import{g as ie}from"./generate-boundary-BCSUEi6x.js";let V;const z=o=>(V??=F(import.meta.url))(o),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=o=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,t]=p.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return p.getBuiltinModule(o)}return z(o)},{createPrivateKey:B,createHash:L,createSign:J,randomBytes:Q}=G("node:crypto"),ae="1.2.840.113549.1.9.3",ce="1.2.840.113549.1.9.4",ue="1.2.840.113549.1.9.5",fe="1.2.840.113549.1.1.1",pe={v1:1},le={v1:1},l=globalThis.Buffer!==void 0,N=o=>{const e=o.replaceAll(/-----BEGIN[^-]+-----/g,"").replaceAll(/-----END[^-]+-----/g,"").replaceAll(/\s/g,"");if(l)return Buffer.from(e,"base64");const t=atob(e),s=new Uint8Array(t.length);for(let n=0;n<t.length;n+=1)s[n]=t.codePointAt(n);return s},de=(o,e)=>{let t;if(l)t=Buffer.from(o).toString("base64");else{const n=new Uint8Array(o);let r="";const a=8192;for(let i=0;i<n.length;i+=a){const h=n.subarray(i,Math.min(i+a,n.length));r+=String.fromCharCode(...h)}t=btoa(r)}const s=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
|
|
2
|
+
${s.join(`
|
|
3
|
+
`)}
|
|
4
|
+
-----END ${e}-----
|
|
5
|
+
`};class d{static formatAddress(e){return e.name?`"${e.name.replaceAll("\\","\\\\").replaceAll('"',String.raw`\"`)}" <${e.email}>`:e.email}options;constructor(e){this.options=e}async sign(e){const t=await y(this.options.certificate,{encoding:"utf8"}),s=await y(this.options.privateKey,{encoding:"utf8"}),n=N(t),r=D(n);if(r.offset===-1)throw new Error("Failed to parse certificate: Invalid ASN.1 structure");const a=new j({schema:r.result});let i;try{i=this.options.passphrase?B({key:s,passphrase:this.options.passphrase}):B(s)}catch(c){throw new Error(`Failed to parse private key: ${c.message}`)}const h=[];if(this.options.intermediateCerts){const c=this.options.intermediateCerts.map(async _=>{const H=await y(_,{encoding:"utf8"}),q=N(H),$=D(q);if($.offset===-1)throw new Error(`Failed to parse intermediate certificate ${_}: Invalid ASN.1 structure`);return new j({schema:$.result})});h.push(...await Promise.all(c))}const A=this.buildMessage(e),w=new TextEncoder().encode(A),m=new Y({version:pe.v1});m.encapContentInfo=new Z({eContentType:x});const g=new ee({digestAlgorithm:new E({algorithmId:ne}),sid:new te({issuer:a.issuer,serialNumber:a.serialNumber}),signatureAlgorithm:new E({algorithmId:fe}),version:le.v1}),C=L("sha256");C.update(l?Buffer.from(w):w);const P=C.digest(),M=new Uint8Array(P),T=new se({attributes:[new b({type:ae,values:[new W({value:x})]}),new b({type:ce,values:[new I({valueHex:M.buffer.slice(0)})]}),new b({type:ue,values:[new X({valueDate:new Date})]})]});g.signedAttrs=T;const v=T.toSchema().toBER(!1),R=l?Buffer.from(v):new Uint8Array(v),S=J("RSA-SHA256");S.update(R);const u=S.sign(i),k=l?u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength):u.buffer;g.signature=new I({valueHex:k}),m.signerInfos.push(g),m.certificates=[a,...h];const K=new re({content:m.toSchema(),contentType:oe}).toSchema().toBER(!1),O=de(K,"PKCS7"),f=`----_=_NextPart_${Date.now()}_${Q(8).toString("hex")}`,U=[`Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="${f}"`,"",`--${f}`,A,`--${f}`,"Content-Type: application/pkcs7-signature; name=smime.p7s","Content-Transfer-Encoding: base64","Content-Disposition: attachment; filename=smime.p7s","",O.split(`
|
|
6
|
+
`).filter(c=>c.trim()&&!c.includes("-----")).join(""),`--${f}--`].join(`\r
|
|
7
|
+
`);return{...e,headers:{...e.headers,"Content-Type":`multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="${f}"`},html:void 0,text:U}}buildMessage(e){const t=[`From: ${d.formatAddress(e.from)}`,`To: ${this.formatAddresses(e.to)}`];if(e.cc&&t.push(`Cc: ${this.formatAddresses(e.cc)}`),e.replyTo&&t.push(`Reply-To: ${d.formatAddress(e.replyTo)}`),t.push(`Subject: ${e.subject}`,"MIME-Version: 1.0"),e.headers)for(const[a,i]of Object.entries(e.headers))t.push(`${a}: ${i}`);const s=!!e.text,n=!!e.html;let r;return s&&n?(r=ie(),t.push(`Content-Type: multipart/alternative; boundary="${r}"`)):n?t.push("Content-Type: text/html; charset=utf-8"):t.push("Content-Type: text/plain; charset=utf-8"),t.push(""),s&&n&&r?t.push(`--${r}`,"Content-Type: text/plain; charset=utf-8","",e.text,"",`--${r}`,"Content-Type: text/html; charset=utf-8","",e.html,"",`--${r}--`):s?t.push(e.text):n&&t.push(e.html),t.join(`\r
|
|
8
|
+
`)}formatAddresses(e){return(Array.isArray(e)?e:[e]).map(s=>d.formatAddress(s)).join(", ")}}const we=o=>new d(o);export{d as SmimeSigner,we as createSmimeSigner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"./format-address-BDKhXcXV.js";const e=r=>m(r),o=r=>(Array.isArray(r)?r:[r]).map(t=>e(t)),i=r=>{const a={email:r.email};return r.name&&(a.name=r.name),a},f=r=>(Array.isArray(r)?r:[r]).map(t=>i(t)),u=r=>(Array.isArray(r)?r:[r]).map(t=>t.email),A=r=>({email:r.email,...r.name&&{displayName:r.name}}),y=r=>(Array.isArray(r)?r:[r]).map(t=>A(t)),c=r=>{const a={Email:r.email};return r.name&&(a.Name=r.name),a},L=r=>(Array.isArray(r)?r:[r]).map(t=>c(t)),l=(r,a="to")=>({email:r.email,...r.name&&{name:r.name},type:a}),p=(r,a="to")=>(Array.isArray(r)?r:[r]).map(n=>l(n,a)),s=r=>({address:r.email,...r.name&&{name:r.name}}),M=r=>(Array.isArray(r)?r:[r]).map(t=>s(t)),j=r=>o(r),z=r=>s(r);export{i as a,y as b,A as c,u as d,o as e,f,e as g,L as h,c as i,j,p as k,M as l,s as m,z as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=["attachments","batchSending","customHeaders","html","replyTo","scheduling","tagging","templates","tracking"],a=e=>typeof e=="function",c=e=>e!==null&&typeof e=="object"&&"initialize"in e&&"isAvailable"in e&&"sendEmail"in e,f=e=>{if(c(e))return e.features;if(a(e))try{return e({}).features}catch{return}};function u(e){const i=e.map(t=>f(t)).filter(t=>t!==void 0),n={};if(i.length===0)return n;for(const t of o){const s=i.map(r=>r[t]);s.every(r=>r===!0)?n[t]=!0:s.every(r=>r===!1)&&(n[t]=!1)}return n}export{u as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import c from"./EmailError-BIaHK1Uw.js";import b from"./RequiredOptionError-ctDEEB1s.js";import{g as v}from"./generate-message-id-B2n2yqR6.js";import{h as E}from"./headers-to-record-ZOZ7Dubo.js";import{m as u}from"./make-request-Cyz5_yu8.js";import{r as h}from"./retry-aghj7y8m.js";import{v as w}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as A}from"./defineProvider-C9q-7iwt.js";import{c as T,h as g,P as I}from"./provider-base-BEz00m9R.js";import{f as l,a as P}from"./address-formatter-CXZ1aWBX.js";import{p as S}from"./attachment-processor-BJFDS343.js";const t="ahasend",C="https://api.ahasend.com",R=3e4,$=3,N=A((o={})=>{if(!o.apiKey)throw new b(t,"apiKey");const a={apiKey:o.apiKey,debug:o.debug??!1,endpoint:o.endpoint??C,retries:o.retries??$,timeout:o.timeout??R,...o.logger&&{logger:o.logger}},y=new I,s=T(t,o.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(t,"Email ID is required to retrieve email details"),success:!1};await this.initialize();const i={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"};s.debug("Retrieving email details",{id:e});const r=await h(async()=>u(`${a.endpoint}/emails/${e}`,{headers:i,method:"GET",timeout:a.timeout}),a.retries);return r.success?(s.debug("Email details retrieved successfully"),{data:r.data?.body,success:!0}):(s.debug("API request failed when retrieving email",r.error),{error:new c(t,`Failed to retrieve email: ${r.error instanceof Error?r.error.message:"Unknown error"}`,{cause:r.error}),success:!1})}catch(i){return{error:g(t,"retrieve email",i,s),success:!1}}},async initialize(){await y.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(t,"AhaSend API not available or invalid API key");s.debug("Provider initialized successfully")},t)},async isAvailable(){try{s.debug("Checking AhaSend API availability");const e=await u(`${a.endpoint}/v2/ping`,{headers:{Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},method:"GET",timeout:a.timeout});if(e.success)return!0;const i=e.data?.statusCode??e.error?.statusCode;return!1}catch(e){return s.debug("Error checking availability:",e),!1}},name:t,options:a,async sendEmail(e){try{const i=w(e);if(i.length>0)return{error:new c(t,`Invalid email options: ${i.join(", ")}`),success:!1};await this.initialize();const r={from:{email:e.from.email,name:e.from.name},subject:e.subject,to:l(e.to)};if(e.html&&(r.html=e.html),e.text&&(r.text=e.text),e.cc&&(r.cc=l(e.cc)),e.bcc&&(r.bcc=l(e.bcc)),e.replyTo&&(r.replyTo=P(e.replyTo)),e.templateId&&(r.templateId=e.templateId,e.templateVariables&&(r.templateVariables=e.templateVariables)),e.tags&&e.tags.length>0&&(r.tags=e.tags),e.headers){const n=E(e.headers);r.headers=n}e.attachments&&e.attachments.length>0&&(r.attachments=await Promise.all(e.attachments.map(async n=>({content:await S(n,t),contentType:n.contentType??"application/octet-stream",filename:n.filename,...n.cid&&{cid:n.cid}})))),s.debug("Sending email via AhaSend API",{subject:r.subject,to:r.to});const p={Authorization:`Bearer ${a.apiKey}`,"Content-Type":"application/json"},d=await h(async()=>u(`${a.endpoint}/send`,{headers:p,method:"POST",timeout:a.timeout},JSON.stringify(r)),a.retries);if(!d.success)return s.debug("API request failed when sending email",d.error),{error:d.error??new c(t,"Failed to send email"),success:!1};const m=d.data?.body,f=m?.messageId??m?.id??v();return s.debug("Email sent successfully",{messageId:f}),{data:{messageId:f,provider:t,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:g(t,"send email",i,s),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{N as default};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{createRequire as D}from"node:module";import{z as W}from"./index-B8wiKJdh.js";import{h as T}from"./headers-to-record-ZOZ7Dubo.js";import{f as y}from"./format-address-BDKhXcXV.js";let K;const L=e=>(K??=D(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[s,t]=m.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return m.getBuiltinModule(e)}return L(e)},{Buffer:j}=M("node:buffer"),{createPublicKey:V,createHash:b,createPrivateKey:P,sign:z,createSign:q,verify:C}=M("node:crypto"),x=/\s+/g,F=/ $/,G=/^\s*i=(\d+)\s*;/,U=["from","to","cc","subject","date","message-id","mime-version"],d=(e,s)=>`${e.toLowerCase()}:${s.replaceAll(x," ").trim()}`,J=e=>{let a=e.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).replaceAll("\r",`
|
|
4
|
+
`).split(`
|
|
5
|
+
`).map(n=>n.replaceAll(x," ").replace(F,"")).join(`\r
|
|
6
|
+
`);for(;a.endsWith(`\r
|
|
7
|
+
`);)a=a.slice(0,-2);return a.length>0?`${a}\r
|
|
8
|
+
`:`\r
|
|
9
|
+
`},E=e=>{const s={...e.headers?T(e.headers):{},From:y(e.from),Subject:e.subject,To:y(e.to)};return e.cc&&(s.Cc=y(e.cc)),s["MIME-Version"]??="1.0",s},_=e=>{const s={};for(const t of e.split(";")){const a=t.indexOf("=");a!==-1&&(s[t.slice(0,a).trim()]=t.slice(a+1).trim())}return s},H=e=>{const s=e.lastIndexOf("b=");return s===-1?e:e.slice(0,s+2)},N=e=>{const s=[e.text,e.html].filter(t=>t!==void 0).join(`
|
|
10
|
+
|
|
11
|
+
`);return b("sha256").update(J(s)).digest("base64")},w=(e,s,t)=>t==="ed25519-sha256"?z(null,b("sha256").update(e).digest(),s).toString("base64"):q("RSA-SHA256").update(e).sign(s,"base64"),B=(e,s,t,a)=>{const n=j.from(s,"base64");try{return a==="ed25519-sha256"?C(null,b("sha256").update(e).digest(),t,n):C("RSA-SHA256",j.from(e),t,n)}catch{return!1}},Q=(e,s)=>{const t=s.instance??1,a=s.algorithm??"rsa-sha256",n=s.timestamp??Math.floor(Date.now()/1e3),r=E(e),i=(s.headersToSign??U).filter(g=>{const u=Object.keys(r).find(h=>h.toLowerCase()===g);return u!==void 0&&r[u]!==void 0&&r[u]!==""}),c=[`i=${String(t)}`,`a=${a}`,"c=relaxed/relaxed",`d=${s.domainName}`,`s=${s.keySelector}`,`t=${String(n)}`,`h=${i.join(":")}`,`bh=${N(e)}`,"b="].join("; "),l=`${i.map(g=>{const u=Object.keys(r).find(h=>h.toLowerCase()===g);return d(g,r[u]??"")}).join(`\r
|
|
12
|
+
`)}\r
|
|
13
|
+
${d("ARC-Message-Signature",c)}`;return{header:c,signBase:l}},X=(e,s,t)=>{const a=t.instance??1,n=t.algorithm??"rsa-sha256",r=t.timestamp??Math.floor(Date.now()/1e3),i=t.cv??"none",c=[`i=${String(a)}`,`a=${n}`,`cv=${i}`,`d=${t.domainName}`,`s=${t.keySelector}`,`t=${String(r)}`,"b="].join("; "),o=[d("ARC-Authentication-Results",e),d("ARC-Message-Signature",s),d("ARC-Seal",c)].join(`\r
|
|
14
|
+
`);return{header:c,signBase:o}},Y=async(e,s)=>{let t=e;return t.startsWith("file://")&&(t=await W(t.slice(7),{encoding:"utf8"})),P({key:t,passphrase:s})},re=async(e,s)=>{const t=s.instance??1,a=s.cv??"none";if(t!==1)throw new Error(`signArc only supports an originating sealer (instance 1); received i=${String(t)}`);if(a!=="none")throw new Error(`signArc only supports cv=none for an originating sealer; received cv=${a}`);const n=s.algorithm??"rsa-sha256",r={...s,cv:"none",timestamp:s.timestamp??Math.floor(Date.now()/1e3)},i=await Y(s.privateKey,s.passphrase),c=`i=${String(t)}; ${s.authenticationResults}`,o=Q(e,r),l=`${o.header}${w(o.signBase,i,n)}`,g=X(c,l,r),u=`${g.header}${w(g.signBase,i,n)}`,h={"ARC-Authentication-Results":c,"ARC-Message-Signature":l,"ARC-Seal":u};return{email:{...e,headers:{...e.headers?T(e.headers):{},...h}},headers:h}},ce=(e,s,t)=>{const a=Object.fromEntries(Object.entries(s).map(([f,p])=>[f.toLowerCase(),p])),n=a["arc-message-signature"],r=a["arc-seal"],i=a["arc-authentication-results"];if(!n||!r||!i)return{components:{ams:!1,bodyHash:!1,seal:!1},reason:"missing-arc-headers",valid:!1};let c;try{c=typeof t.publicKey=="string"?V(t.publicKey):t.publicKey}catch{return{components:{ams:!1,bodyHash:!1,seal:!1},reason:"invalid-public-key",valid:!1}}const o=_(n),l=_(r);if(G.exec(i)?.[1]!=="1"||o.i!=="1"||l.i!=="1"||l.cv!=="none")return{components:{ams:!1,bodyHash:!1,seal:!1},cv:l.cv,reason:"unsupported-arc-instance",valid:!1};const u=o.a==="ed25519-sha256"?"ed25519-sha256":"rsa-sha256",h=l.a==="ed25519-sha256"?"ed25519-sha256":"rsa-sha256",A=o.bh!==void 0&&o.bh===N(e),v=E(e),k=`${(o.h??"").split(":").map(f=>f.trim().toLowerCase()).filter(Boolean).map(f=>{const p=Object.keys(v).find(O=>O.toLowerCase()===f);return d(f,p?v[p]??"":"")}).join(`\r
|
|
15
|
+
`)}\r
|
|
16
|
+
${d("ARC-Message-Signature",H(n))}`,S=B(k,o.b??"",c,u),I=[d("ARC-Authentication-Results",i),d("ARC-Message-Signature",n),d("ARC-Seal",H(r))].join(`\r
|
|
17
|
+
`),$=B(I,l.b??"",c,h),R=S&&$&&A;return{components:{ams:S,bodyHash:A,seal:$},cv:l.cv,reason:R?void 0:"signature-mismatch",valid:R}};export{Q as arcMessageSignatureBase,X as arcSealBase,re as signArc,ce as verifyArc};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as r}from"node:module";import l from"./EmailError-BIaHK1Uw.js";let c;const p=e=>(c??=r(import.meta.url))(e),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[n,o]=t.versions.node.split(".").map(Number);if(n>22||n===22&&o>=3||n===20&&o>=16)return t.getBuiltinModule(e)}return p(e)},{Buffer:a}=f("node:buffer"),s=async(e,n)=>{let o;if(e.content)if(typeof e.content=="string")o=e.content;else if(e.content instanceof Promise){const i=await e.content;o=a.from(i).toString("base64")}else o=e.content.toString("base64");else if(e.raw)o=typeof e.raw=="string"?e.raw:e.raw.toString("base64");else throw new l(n,`Attachment ${e.filename} has no content`);return o},y=async(e,n)=>({content:await s(e,n),contentType:e.contentType??"application/octet-stream",disposition:e.contentDisposition??"attachment",filename:e.filename,...e.cid&&{contentId:e.cid}}),_=async(e,n)=>({content:await s(e,n),disposition:e.contentDisposition??"attachment",filename:e.filename,type:e.contentType??"application/octet-stream",...e.cid&&{content_id:e.cid}}),g=async(e,n)=>({Content:await s(e,n),ContentType:e.contentType??"application/octet-stream",Name:e.filename,...e.cid&&{ContentID:e.cid}}),w=async(e,n,o)=>({content:await s(e,n),key:`attachment[${o}]`});export{w as a,g as b,y as c,_ as d,s as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import d from"./EmailError-BIaHK1Uw.js";import _ from"./RequiredOptionError-ctDEEB1s.js";import{h as N}from"./headers-to-record-ZOZ7Dubo.js";import{m as k}from"./make-request-Cyz5_yu8.js";import{r as D}from"./retry-aghj7y8m.js";import{s as M,a as j}from"./sanitize-header-CW0f3IT7.js";import{v as C}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as H}from"./defineProvider-C9q-7iwt.js";import{c as P,h as L,P as U}from"./provider-base-BEz00m9R.js";import{a as b,f as y}from"./address-formatter-CXZ1aWBX.js";import{c as z}from"./attachment-processor-BJFDS343.js";const n="autosend",G="https://api.autosend.com/v1",x=3e4,B=3,p=50,v=20,T=40*1024*1024,w=20,$=1e3,I=998,F=/^[A-Z0-9-]{1,76}$/i,K="^[A-Za-z0-9-]{1,76}$",X="Either text or html content is required",h=t=>[t].flat(),q=async t=>{const s=await z(t,n);return{content:s.content,contentType:s.contentType,fileName:s.filename}},V=(t,s)=>{const c=h(t.to);if(c.length!==1)return`AutoSend's send endpoint takes exactly one 'to' recipient, but ${String(c.length)} were given — use 'cc'/'bcc', or send one message per recipient`;const o=c.length+(t.cc?h(t.cc).length:0)+(t.bcc?h(t.bcc).length:0);if(o>p)return`AutoSend allows at most ${String(p)} recipients across to/cc/bcc, but ${String(o)} were given`;if(t.attachments&&t.attachments.length>v)return`AutoSend allows at most ${String(v)} attachments, but ${String(t.attachments.length)} were given`;const e=t.attachments?.find(r=>r.cid);if(e)return`AutoSend does not support inline (cid) attachments, but '${e.filename}' sets one — host the image and reference it by URL instead`;if(t.subject.length>I)return`AutoSend allows a subject of at most ${String(I)} characters, but ${String(t.subject.length)} were given`;const a=Object.keys(s);if(a.length>w)return`AutoSend allows at most ${String(w)} custom headers, but ${String(a.length)} were given`;const i=a.find(r=>!F.test(r));if(i!==void 0)return`AutoSend header names must match ${K}, but '${i}' does not`;const l=a.find(r=>s[r].length>$);if(l!==void 0)return`AutoSend allows header values of at most ${String($)} characters, but '${l}' is longer`},J=t=>{if(typeof t!="object"||t===null)return{};const s=t;if(s.success===!0)return{emailId:typeof s.data?.emailId=="string"?s.data.emailId:void 0};const c=[s.message,s.error].find(o=>typeof o=="string");return{reason:typeof c=="string"?c:void 0}},ce=H((t={})=>{if(!t.apiKey)throw new _(n,"apiKey");const s={apiKey:t.apiKey,debug:t.debug??!1,endpoint:t.endpoint??G,logger:t.logger,retries:t.retries??B,timeout:t.timeout??x},c=new U,o=P(n,t.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!0},async initialize(){c.setInitialized()},async isAvailable(){return s.apiKey.length>0},name:n,options:s,async sendEmail(e){try{const a=C(e).filter(u=>!(e.templateId!==void 0&&u===X));if(a.length>0)return{error:new d(n,`Invalid email options: ${a.join(", ")}`),success:!1};const i=e.headers?N(e.headers):{},l=V(e,i);if(l)return{error:new d(n,l),success:!1};const r={from:b(e.from),subject:e.subject,to:b(h(e.to)[0])};if(e.templateId?r.templateId=e.templateId:(e.html&&(r.html=e.html),e.text&&(r.text=e.text)),e.cc&&(r.cc=y(e.cc)),e.bcc&&(r.bcc=y(e.bcc)),e.replyTo&&(r.replyTo=b(e.replyTo)),e.dynamicData&&(r.dynamicData=e.dynamicData),e.unsubscribeGroupId&&(r.unsubscribeGroupId=e.unsubscribeGroupId),e.trackingClick!==void 0&&(r.trackingClick=e.trackingClick),e.trackingOpen!==void 0&&(r.trackingOpen=e.trackingOpen),e.bypassSuppressions!==void 0&&(r.bypassSuppressions=e.bypassSuppressions),Object.keys(i).length>0&&(r.headers=Object.fromEntries(Object.entries(i).map(([u,m])=>[M(u),j(m)]))),e.attachments&&e.attachments.length>0){const u=await Promise.all(e.attachments.map(async A=>q(A))),m=u.reduce((A,R)=>A+R.content.length,0);if(m>T)return{error:new d(n,`AutoSend allows at most ${String(T)} bytes of attachments after Base64 encoding, but this message carries ${String(m)}`),success:!1};r.attachments=u}const g=await D(async()=>k(`${s.endpoint}/mails/send`,{headers:{Authorization:`Bearer ${s.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:s.timeout},JSON.stringify(r)),s.retries),S=g.data?.body,{emailId:E,reason:f}=J(S);return g.success?f?{error:new d(n,`Failed to send email: ${f}`),success:!1}:E?(o.debug(`Email queued successfully: ${E}`),{data:{messageId:E,provider:n,response:S,sent:!0,timestamp:new Date},success:!0}):{error:new d(n,"AutoSend accepted the message but returned no emailId"),success:!1}:{error:f?new d(n,`Failed to send email: ${f}`):g.error??new d(n,"Failed to send email"),success:!1}}catch(a){return{error:L(n,"send email",a,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{ce as default};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import{createRequire as F}from"node:module";import M from"./EmailError-BIaHK1Uw.js";import X from"./RequiredOptionError-ctDEEB1s.js";import{c as J}from"./create-logger-CazqtXcL.js";import p from"../utils/format-email-address.js";import{h as Y}from"./headers-to-record-ZOZ7Dubo.js";import{m as Z}from"./make-request-Cyz5_yu8.js";import{a as _,s as O}from"./sanitize-header-CW0f3IT7.js";import{v as ee}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as re}from"./defineProvider-C9q-7iwt.js";let L;const Q=S=>(L??=F(import.meta.url))(S),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=S=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[a,i]=b.versions.node.split(".").map(Number);if(a>22||a===22&&i>=3||a===20&&i>=16)return b.getBuiltinModule(S)}return Q(S)},{randomUUID:q,createHash:x,createHmac:w}=G("node:crypto"),te=globalThis.Buffer!==void 0,I=()=>{if(!te)throw new Error("Buffer is required for AWS SES provider");return globalThis.Buffer},y="aws-ses",j={apiVersion:"2010-12-01",maxAttempts:3,region:"us-east-1"},he=re((S={})=>{const a={...j,...S},i=J("AWS-SES",S.logger),k=(e,c,r,s,n)=>{const d=Object.keys(r).toSorted().map(u=>{const f=r[u];return f===void 0?"":`${encodeURIComponent(u)}=${encodeURIComponent(f)}`}).filter(Boolean).join("&"),t=`${Object.keys(s).toSorted().map(u=>`${u.toLowerCase()}:${s[u]}`).join(`
|
|
2
|
+
`)}
|
|
3
|
+
`,o=Object.keys(s).toSorted().map(u=>u.toLowerCase()).join(";"),g=x("sha256").update(n).digest("hex");return[e,c,d,t,o,g].join(`
|
|
4
|
+
`)},P=(e,c,r)=>{const s=e.slice(0,8),n=x("sha256").update(r).digest("hex");return["AWS4-HMAC-SHA256",e,`${s}/${c}/ses/aws4_request`,n].join(`
|
|
5
|
+
`)},B=(e,c,r,s)=>{const n=c.slice(0,8),d=w("sha256",`AWS4${e}`).update(n).digest(),t=w("sha256",d).update(r).digest(),o=w("sha256",t).update("ses").digest(),g=w("sha256",o).update("aws4_request").digest();return w("sha256",g).update(s).digest("hex")},W=(e,c,r,s,n)=>{const d=c.slice(0,8),t=Object.keys(s).toSorted().map(o=>o.toLowerCase()).join(";");return[`AWS4-HMAC-SHA256 Credential=${e}/${d}/${r}/ses/aws4_request`,`SignedHeaders=${t}`,`Signature=${n}`].join(", ")},R=async(e,c)=>{if(!a.accessKeyId||!a.secretAccessKey)throw i.debug("Missing required credentials: accessKeyId or secretAccessKey"),new X(y,["accessKeyId","secretAccessKey"]);try{const r=a.region||j.region,s=a.apiVersion||j.apiVersion,n=a.endpoint||`email.${r}.amazonaws.com`,d="/",t="POST";i.debug("Making request to AWS SES:",{action:e,host:n,region:r});const o=new URLSearchParams;o.append("Action",e),o.append("Version",s),Object.entries(c).forEach(([m,l])=>{l!=null&&o.append(m,String(l))});const g=o.toString();i.debug("Request body:",g);const f=new Date().toISOString().replaceAll(/[:-]|\.\d{3}/g,""),h={"Content-Length":I().byteLength(g).toString(),"Content-Type":"application/x-www-form-urlencoded",Host:n,"X-Amz-Date":f};a.sessionToken&&(h["X-Amz-Security-Token"]=a.sessionToken),i.debug("Request headers:",h);const D=k(t,d,{},h,g),z=P(f,r,D),U=B(a.secretAccessKey,f,r,z);h.Authorization=W(a.accessKeyId,f,r,h,U),i.debug("Making HTTPS request to:",`https://${n}${d}`);const N=`https://${n}${d}`,E=await Z(N,{headers:h,method:t},g);if(!E.success)throw E.error??new Error("AWS SES API request failed");const A=E.data?.body;if(!A)throw new Error("No response body from AWS SES");const v=E.data?.statusCode;i.debug("Response status:",v),i.debug("Response data:",A);const T=v;if(T&&T>=200&&T<300){const m={};if(e==="SendRawEmail"){const l=A.match(/<MessageId>(.*?)<\/MessageId>/);if(l){const[,V]=l;m.MessageId=V,i.debug("Extracted MessageId:",m.MessageId)}}else if(e==="GetSendQuota"){const l=A.match(/<Max24HourSend>(.*?)<\/Max24HourSend>/);l?.[1]&&(m.Max24HourSend=Number.parseFloat(l[1]),i.debug("Extracted Max24HourSend:",m.Max24HourSend))}return m}const C=A.match(/<Message>(.*?)<\/Message>/),H=C?C[1]:"Unknown AWS SES error";throw i.debug("AWS SES Error:",H),new Error(`AWS SES API Error: ${H}`)}catch(r){const s=r instanceof Error?r.message:String(r);throw i.debug("makeAwsRequest exception:",s),r instanceof Error?r:new Error(s)}},K=e=>{const c=`----=${q().replaceAll("-","")}`,r=new Date().toUTCString(),s=e.from.email.includes("@")?e.from.email.split("@")[1]:"localhost",n=`<${q().replaceAll("-","")}@${s}>`,d=I();let t="";if(t+=`From: ${p(e.from)}\r
|
|
6
|
+
`,t+=Array.isArray(e.to)?`To: ${e.to.map(o=>p(o)).join(", ")}\r
|
|
7
|
+
`:`To: ${p(e.to)}\r
|
|
8
|
+
`,e.cc&&(t+=Array.isArray(e.cc)?`Cc: ${e.cc.map(o=>p(o)).join(", ")}\r
|
|
9
|
+
`:`Cc: ${p(e.cc)}\r
|
|
10
|
+
`),e.bcc&&(t+=Array.isArray(e.bcc)?`Bcc: ${e.bcc.map(o=>p(o)).join(", ")}\r
|
|
11
|
+
`:`Bcc: ${p(e.bcc)}\r
|
|
12
|
+
`),t+=`Subject: ${_(e.subject)}\r
|
|
13
|
+
`,t+=`Date: ${r}\r
|
|
14
|
+
`,t+=`Message-ID: ${n}\r
|
|
15
|
+
`,t+=`MIME-Version: 1.0\r
|
|
16
|
+
`,e.headers){const o=Y(e.headers);for(const[g,u]of Object.entries(o)){const f=O(g),$=_(u);t+=`${f}: ${$}\r
|
|
17
|
+
`}}return t+=`Content-Type: multipart/alternative; boundary="${c}"\r
|
|
18
|
+
\r
|
|
19
|
+
`,e.text&&(t+=`--${c}\r
|
|
20
|
+
`,t+=`Content-Type: text/plain; charset=UTF-8\r
|
|
21
|
+
`,t+=`Content-Transfer-Encoding: base64\r
|
|
22
|
+
\r
|
|
23
|
+
`,t+=`${d.from(e.text,"utf8").toString("base64")}\r
|
|
24
|
+
\r
|
|
25
|
+
`),e.html&&(t+=`--${c}\r
|
|
26
|
+
`,t+=`Content-Type: text/html; charset=UTF-8\r
|
|
27
|
+
`,t+=`Content-Transfer-Encoding: base64\r
|
|
28
|
+
\r
|
|
29
|
+
`,t+=`${d.from(e.html,"utf8").toString("base64")}\r
|
|
30
|
+
\r
|
|
31
|
+
`),t+=`--${c}--\r
|
|
32
|
+
`,t};return{features:{attachments:!1,batchSending:!1,customHeaders:!0,html:!0,replyTo:!1,scheduling:!1,tagging:!1,templates:!1,tracking:!1},getInstance:()=>{},initialize(){i.debug("Initializing AWS SES provider with options:",{accessKeyId:a.accessKeyId?`***${a.accessKeyId.slice(-4)}`:void 0,endpoint:a.endpoint,region:a.region,secretAccessKey:a.secretAccessKey?"***":void 0})},async isAvailable(){try{return!!(await R("GetSendQuota",{})).Max24HourSend}catch{return!1}},name:y,options:a,async sendEmail(e){const c=r=>{const s=[];return r.attachments&&r.attachments.length>0&&s.push("attachments"),r.priority&&s.push("priority"),r.tags&&r.tags.length>0&&s.push("tags (use messageTags instead)"),r.replyTo&&s.push("replyTo"),s};try{const r=ee(e);if(r.length>0)throw new M(y,`Invalid email options: ${r.join(", ")}`);const s=c(e);if(s.length>0)throw new M(y,`Unsupported fields provided: ${s.join(", ")}. These fields are not supported by AWS SES Raw Email API and would be silently ignored.`);const n={};e.configurationSetName&&(n.ConfigurationSetName=e.configurationSetName),e.sourceArn&&(n.SourceArn=e.sourceArn),e.returnPath&&(n.ReturnPath=e.returnPath),e.returnPathArn&&(n.ReturnPathArn=e.returnPathArn),e.messageTags&&Object.keys(e.messageTags).length>0&&Object.entries(e.messageTags).forEach(([f,$],h)=>{n[`Tags.member.${h+1}.Name`]=f,n[`Tags.member.${h+1}.Value`]=$});const d=K(e),o=I().from(d).toString("base64");n["RawMessage.Data"]=o;const g=await R("SendRawEmail",n),u=g.MessageId;return!u||u.trim()===""?{error:new M(y,"AWS SES API returned a response without a MessageId. The email may not have been sent successfully."),success:!1}:{data:{messageId:u,provider:y,response:g,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:new M(y,`Failed to send email: ${r instanceof Error?r.message:String(r)}`,{cause:r instanceof Error?r:new Error(String(r))}),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{he as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as A}from"node:module";import u from"./EmailError-BIaHK1Uw.js";import v from"./RequiredOptionError-ctDEEB1s.js";import{g as I}from"./generate-message-id-B2n2yqR6.js";import{h as _}from"./headers-to-record-ZOZ7Dubo.js";import{m as h}from"./make-request-Cyz5_yu8.js";import{r as T}from"./retry-aghj7y8m.js";import{v as P}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as j}from"./defineProvider-C9q-7iwt.js";import{c as $,P as B,h as w}from"./provider-base-BEz00m9R.js";import{b as y,c as R}from"./address-formatter-CXZ1aWBX.js";let E;const z=s=>(E??=A(import.meta.url))(s),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[l,r]=m.versions.node.split(".").map(Number);if(l>22||l===22&&r>=3||l===20&&r>=16)return m.getBuiltinModule(s)}return z(s)},{Buffer:p}=k("node:buffer"),o="azure",C=3e4,q=3,Q=j((s={})=>{if(!s.region)throw new v(o,"region");if(!s.connectionString&&!s.accessToken)throw new v(o,"connectionString or accessToken");const l=s.endpoint??`https://${s.region}.communication.azure.com`,r={debug:s.debug??!1,endpoint:l,region:s.region,retries:s.retries??q,timeout:s.timeout??C,...s.connectionString&&{connectionString:s.connectionString},...s.accessToken&&{accessToken:s.accessToken},...s.logger&&{logger:s.logger}},g=new B,a=$(o,s.logger);return{features:{attachments:!0,batchSending:!1,customHeaders:!0,html:!0,replyTo:!0,scheduling:!1,tagging:!1,templates:!0,tracking:!1},async getEmail(e){try{if(!e)return{error:new u(o,"Email ID is required to retrieve email details"),success:!1};await g.ensureInitialized(()=>this.initialize(),o);const i={"Content-Type":"application/json"};if(r.accessToken)i.Authorization=`Bearer ${r.accessToken}`;else if(r.connectionString){const c=r.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);c&&(i.Authorization=`Bearer ${c[2]}`)}a.debug("Retrieving email details",{id:e});const t=await T(async()=>h(`${r.endpoint}/emails/${e}`,{headers:i,method:"GET",timeout:r.timeout}),r.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 u(o,`Failed to retrieve email: ${t.error instanceof Error?t.error.message:"Unknown error"}`,{cause:t.error}),success:!1})}catch(i){return{error:w(o,"retrieve email",i,a),success:!1}}},async initialize(){await g.ensureInitialized(async()=>{if(!await this.isAvailable())throw new u(o,"Azure Communication Services API not available or invalid credentials");a.debug("Provider initialized successfully")},o)},async isAvailable(){try{const e={"Content-Type":"application/json"};if(r.accessToken)e.Authorization=`Bearer ${r.accessToken}`;else if(r.connectionString){const c=r.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(c)e.Authorization=`Bearer ${c[2]}`;else return!1}else return!1;a.debug("Checking Azure Communication Services API availability");const i=await h(`${r.endpoint}/emails:send`,{headers:e,method:"POST",timeout:r.timeout},JSON.stringify({}));if(i.success)return!0;const t=i.data?.statusCode;return t===401||t===403?!1:t===400}catch(e){if(a.debug("Error checking availability:",e),e instanceof Error){const i=e.message;if(i.includes("401")||i.includes("403"))return!1}return!1}},name:o,options:r,async sendEmail(e){try{const i=P(e);if(i.length>0)return{error:new u(o,`Invalid email options: ${i.join(", ")}`),success:!1};await g.ensureInitialized(()=>this.initialize(),o);const t={content:{subject:e.subject},recipients:{to:y(e.to)},senderAddress:e.from.email};if(e.html&&(t.content.html=e.html),e.text&&(t.content.plainText=e.text),e.cc&&(t.recipients.cc=y(e.cc)),e.bcc&&(t.recipients.bcc=y(e.bcc)),e.replyTo&&(t.replyTo=R(e.replyTo).email),e.importance&&(t.importance=e.importance),e.headers){const n=_(e.headers);t.headers=n}e.attachments&&e.attachments.length>0&&(t.attachments=await Promise.all(e.attachments.map(async n=>{let f;if(n.content)if(typeof n.content=="string")f=p.from(n.content,"utf8").toString("base64");else if(n.content&&typeof n.content.then=="function"){const S=await n.content;f=p.from(S).toString("base64")}else f=n.content.toString("base64");else if(n.raw)f=typeof n.raw=="string"?p.from(n.raw,"utf8").toString("base64"):n.raw.toString("base64");else throw new u(o,`Attachment ${n.filename} has no content`);return{contentInBase64:f,contentType:n.contentType??"application/octet-stream",name:n.filename}}))),a.debug("Sending email via Azure Communication Services API",{subject:t.content.subject,to:t.recipients.to});const c={"Content-Type":"application/json"};if(r.accessToken)c.Authorization=`Bearer ${r.accessToken}`;else if(r.connectionString){const n=r.connectionString.match(/endpoint=([^;]+);accesskey=([^;]+)/);if(n)c.Authorization=`Bearer ${n[2]}`;else return{error:new u(o,"Invalid connection string format"),success:!1}}const d=await T(async()=>h(`${r.endpoint}/emails:send`,{headers:c,method:"POST",timeout:r.timeout},JSON.stringify(t)),r.retries);if(!d.success)return a.debug("API request failed when sending email",d.error),{error:d.error??new u(o,"Failed to send email"),success:!1};const b=d.data?.body?.messageId??I();return a.debug("Email sent successfully",{messageId:b}),{data:{messageId:b,provider:o,response:d.data,sent:!0,timestamp:new Date},success:!0}}catch(i){return{error:w(o,"send email",i,a),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{Q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import c from"./EmailError-BIaHK1Uw.js";import w from"./RequiredOptionError-ctDEEB1s.js";import{g as A}from"./generate-message-id-B2n2yqR6.js";import{h as I}from"./headers-to-record-ZOZ7Dubo.js";import{m as y}from"./make-request-Cyz5_yu8.js";import{r as g}from"./retry-aghj7y8m.js";import{v as E}from"./validate-email-options-DxdAVLlu.js";import{defineProvider as P}from"./defineProvider-C9q-7iwt.js";import{c as C,P as R,h as b}from"./provider-base-BEz00m9R.js";import{f,a as m}from"./address-formatter-CXZ1aWBX.js";import{p as S}from"./attachment-processor-BJFDS343.js";const t="brevo",k="https://api.brevo.com/v3",j=3e4,z=3,M=P((d={})=>{if(!d.apiKey)throw new w(t,"apiKey");const v=d.endpoint??k,s={apiKey:d.apiKey,debug:d.debug??!1,endpoint:v,hardValidation:d.hardValidation??!1,retries:d.retries??z,timeout:d.timeout??j,...d.logger&&{logger:d.logger}},l=new R,o=C(t,d.logger);return{endpoint:s.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 c(t,"Email ID is required to retrieve email details"),success:!1};await l.ensureInitialized(()=>this.initialize(),t);const r={"api-key":s.apiKey,"Content-Type":"application/json"};o.debug("Retrieving email details",{id:e});const i=await g(async()=>y(`${s.endpoint}/smtp/emails/${e}`,{headers:r,method:"GET",timeout:s.timeout}),s.retries);return i.success?(o.debug("Email details retrieved successfully"),{data:i.data?.body,success:!0}):(o.debug("API request failed when retrieving email",i.error),{error:new c(t,`Failed to retrieve email: ${i.error instanceof Error?i.error.message:"Unknown error"}`,{cause:i.error}),success:!1})}catch(r){return{error:b(t,"retrieve email",r,o),success:!1}}},async initialize(){await l.ensureInitialized(async()=>{if(!await this.isAvailable())throw new c(t,"Brevo API not available or invalid API key");o.debug("Provider initialized successfully")},t)},async isAvailable(){try{const e={"api-key":s.apiKey,"Content-Type":"application/json"};o.debug("Checking Brevo API availability");const r=await y(`${s.endpoint}/account`,{headers:e,method:"GET",timeout:s.timeout});return o.debug("Brevo 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:t,options:s,async sendEmail(e){try{let r;Array.isArray(e.replyTo)?r=e.replyTo.length>0?e.replyTo[0]:void 0:r=e.replyTo;const i={...e,replyTo:r},h=E(i);if(h.length>0)return{error:new c(t,`Invalid email options: ${h.join(", ")}`),success:!1};await l.ensureInitialized(()=>this.initialize(),t);const a={sender:m(e.from),subject:e.subject,to:f(e.to)};if(e.html&&(a.htmlContent=e.html),e.text&&(a.textContent=e.text),e.cc&&(a.cc=f(e.cc)),e.bcc&&(a.bcc=f(e.bcc)),e.replyTo)if(Array.isArray(e.replyTo)){if(s.hardValidation)return{error:new c(t,"Only one replyTo address is allowed"),success:!1};if(e.replyTo.length===0)return{error:new c(t,"replyTo array cannot be empty"),success:!1};const n=e.replyTo[0];if(!n)return{error:new c(t,"replyTo array cannot be empty"),success:!1};a.replyTo=m(n)}else a.replyTo=m(e.replyTo);if(e.templateId&&(a.templateId=e.templateId,e.templateParams&&(a.params=e.templateParams)),e.tags&&e.tags.length>0&&(a.tags=e.tags),e.scheduledAt){const n=typeof e.scheduledAt=="number"?new Date(e.scheduledAt*1e3).toISOString():e.scheduledAt;a.scheduledAt=n}if(e.batchId&&(a.batchId=e.batchId),e.headers){const n=I(e.headers);a.headers=n}e.attachments&&e.attachments.length>0&&(a.attachment=await Promise.all(e.attachments.map(async n=>({content:await S(n,t),name:n.filename,...n.contentType&&{type:n.contentType}})))),o.debug("Sending email via Brevo API",{subject:a.subject,to:a.to});const T={"api-key":s.apiKey,"Content-Type":"application/json"},u=await g(async()=>y(`${s.endpoint}/smtp/email`,{headers:T,method:"POST",timeout:s.timeout},JSON.stringify(a)),s.retries);if(!u.success)return o.debug("API request failed when sending email",u.error),{error:u.error??new c(t,"Failed to send email"),success:!1};const p=u.data?.body?.messageId??A();return o.debug("Email sent successfully",{messageId:p}),{data:{messageId:p,provider:t,response:u.data,sent:!0,timestamp:new Date},success:!0}}catch(r){return{error:b(t,"send email",r,o),success:!1}}},async validateCredentials(){return this.isAvailable()}}});export{M as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import S from"./EmailError-BIaHK1Uw.js";import d from"../utils/format-email-address.js";import{g as y}from"./generate-boundary-BCSUEi6x.js";import{h as A}from"./headers-to-record-ZOZ7Dubo.js";import{e as M}from"./quoted-printable-BgiHOYdV.js";import{s as T,a as f}from"./sanitize-header-CW0f3IT7.js";const b=globalThis.Buffer!==void 0,$=e=>{if(typeof e=="string"){if(b)return Buffer.from(e,"utf8").toString("base64");const s=new TextEncoder().encode(e);let r="";const n=8192;for(let o=0;o<s.length;o+=n){const h=s.subarray(o,Math.min(o+n,s.length));r+=String.fromCharCode(...h)}return btoa(r)}if(b&&e instanceof Buffer)return e.toString("base64");const i=e instanceof Uint8Array?e:new Uint8Array(e);if(b)return Buffer.from(i).toString("base64");let u="";const a=8192;for(let t=0;t<i.length;t+=a){const s=i.subarray(t,Math.min(t+a,i.length));u+=String.fromCharCode(...s)}return btoa(u)},v=globalThis.Buffer!==void 0,z=/[^\u0000-\u007F]/,j=e=>!z.test(e),k=e=>{if(j(e))return e;const i=45,u=new TextDecoder,a=v?Buffer.from(e,"utf8"):new TextEncoder().encode(e),t=[];let s=0;for(;s<a.length;){let r=Math.min(s+i,a.length);if(r<a.length)for(;r>s&&(a[r]&192)===128;)r-=1;const n=a.subarray(s,r),o=u.decode(n);t.push(`=?UTF-8?B?${$(o)}?=`),s=r}return t.join(" ")},g=e=>Array.isArray(e)?e.map(i=>d(i)).join(", "):d(e),I=/[^ -~\r\n\t]/,C=e=>k(f(e)),N=globalThis.Buffer!==void 0,B=e=>e.replaceAll(/.{1,76}/g,`$&\r
|
|
2
|
+
`).trimEnd(),O=async(e,i={})=>{const{includeBcc:u=!1}=i,a=y(),t=[`From: ${d(e.from)}`,`To: ${g(e.to)}`];if(e.cc&&t.push(`Cc: ${g(e.cc)}`),u&&e.bcc&&t.push(`Bcc: ${g(e.bcc)}`),e.replyTo&&t.push(`Reply-To: ${d(e.replyTo)}`),t.push(`Subject: ${C(e.subject)}`,"MIME-Version: 1.0"),e.headers){const r=A(e.headers);Object.entries(r).forEach(([n,o])=>{const h=T(n),m=f(o);t.push(`${h}: ${m}`)})}t.push(`Content-Type: multipart/mixed; boundary="${a}"`,"");const s=(r,n)=>I.test(n)?[`Content-Type: ${r}; charset=UTF-8`,"Content-Transfer-Encoding: quoted-printable","",M(n),""]:[`Content-Type: ${r}; charset=UTF-8`,"Content-Transfer-Encoding: 7bit","",n,""];if(e.text&&e.html){const r=y();t.push(`--${a}`,`Content-Type: multipart/alternative; boundary="${r}"`,"",`--${r}`,...s("text/plain",e.text),`--${r}`,...s("text/html",e.html),`--${r}--`,"")}else e.text?t.push(`--${a}`,...s("text/plain",e.text)):e.html&&t.push(`--${a}`,...s("text/html",e.html));if(e.attachments&&e.attachments.length>0){const r=await Promise.all(e.attachments.map(async n=>{let o;if(n.raw!==void 0)o=n.raw;else{if(n.content===void 0)throw new S("attachment",`Attachment '${n.filename}' must have content, raw, or be resolved from path/href before building MIME message`);o=n.content instanceof Promise?await n.content:n.content}return{...n,resolvedContent:o}}));for(const n of r){t.push(`--${a}`);const o=f(n.contentType??"application/octet-stream"),h=C(n.filename);t.push(`Content-Type: ${o}; name="${h}"`);const m=f(n.contentDisposition??"attachment");t.push(`Content-Disposition: ${m}; filename="${h}"`),n.cid&&t.push(`Content-ID: <${f(n.cid)}>`),n.headers&&Object.entries(n.headers).forEach(([p,E])=>{const w=T(p),x=f(E);t.push(`${w}: ${x}`)});const l=f(n.encoding??"base64");t.push(`Content-Transfer-Encoding: ${l}`,"");const c=n.resolvedContent;if(l==="base64")t.push(B($(c)));else if(l==="7bit"||l==="8bit")if(typeof c=="string")t.push(c);else if(N&&c instanceof Buffer)t.push(c.toString("utf8"));else{const p=new TextDecoder;t.push(p.decode(c))}else t.push(B($(c)));t.push("")}}return t.push(`--${a}--`),t.join(`\r
|
|
3
|
+
`)};export{O as b};
|