@visulima/email 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +527 -0
- package/LICENSE.md +541 -847
- package/README.md +207 -5
- package/dist/crypto/index.d.ts +304 -4
- package/dist/crypto/index.js +1 -1
- package/dist/deliverability/dmarc-report.d.ts +95 -0
- package/dist/deliverability/dmarc-report.js +1 -0
- package/dist/deliverability/index.d.ts +360 -0
- package/dist/deliverability/index.js +1 -0
- package/dist/events/index.d.ts +31 -0
- package/dist/events/index.js +1 -0
- package/dist/inbound/index.d.ts +375 -0
- package/dist/inbound/index.js +1 -0
- package/dist/index.d.ts +94 -9
- package/dist/index.js +1 -1
- package/dist/middleware/index.d.ts +346 -0
- package/dist/middleware/index.js +1 -0
- package/dist/packem_shared/ALL_EVENTS-3kwh5CBE.js +1 -0
- package/dist/packem_shared/DkimSigner-BuSbnos1.js +18 -0
- package/dist/packem_shared/DraftMailMessage-C9tevR8K.js +1 -0
- package/dist/packem_shared/EmailError-B-sEf3bp.js +1 -0
- package/dist/packem_shared/Mail-DpjH0Exh.js +1 -0
- package/dist/packem_shared/MailMessage-L-Q9yc5v.js +1 -0
- package/dist/packem_shared/MemoryEventStore-CuhfO9aj.js +1 -0
- package/dist/packem_shared/MemoryQueue-Dl1Fa6OJ.js +1 -0
- package/dist/packem_shared/MemorySuppressionStore-DZnbz-_B.js +1 -0
- package/dist/packem_shared/RATE_LIMIT_PRESETS-BPADLgcA.js +1 -0
- package/dist/packem_shared/RequiredOptionError-DuNNY_a5.js +1 -0
- package/dist/packem_shared/SmimeEncrypter-C7usORKF.js +6 -0
- package/dist/packem_shared/SmimeSigner-DgAApLPS.js +8 -0
- package/dist/packem_shared/addDarkModeSupport-DZYxULjl.js +1 -0
- package/dist/packem_shared/address-formatter-BWR2Dddx.js +1 -0
- package/dist/packem_shared/aggregate-features-BqEjPd42.js +1 -0
- package/dist/packem_shared/ahaSendProvider-Dq5mElHZ.js +1 -0
- package/dist/packem_shared/arcMessageSignatureBase-BY4j0TxM.js +17 -0
- package/dist/packem_shared/attachment-processor-BjTNoMyb.js +1 -0
- package/dist/packem_shared/awsSesProvider-BGZJUIep.js +32 -0
- package/dist/packem_shared/azureProvider-DlM6UWUv.js +1 -0
- package/dist/packem_shared/brevoProvider-D_Hhc0Z-.js +1 -0
- package/dist/packem_shared/build-mime-message-Be6TOi1T.js +3 -0
- package/dist/packem_shared/buildListUnsubscribe-Cdr8MvR_.js +1 -0
- package/dist/packem_shared/buildMtaStsPolicy-oEQg8y_C.js +6 -0
- package/dist/packem_shared/circuitBreakerMiddleware-D2SA_07f.js +1 -0
- package/dist/packem_shared/cloudflareEmailProvider-D4adkOjA.js +1 -0
- package/dist/packem_shared/composeMiddleware-BHwLLEzK.js +1 -0
- package/dist/packem_shared/create-logger-BQTS3f-I.js +1 -0
- package/dist/packem_shared/createSuppressionStore-CeAZKCbY.js +1 -0
- package/dist/packem_shared/createTestEmail-BM3iNznm.js +1 -0
- package/dist/packem_shared/createWorker-_-yMWcNQ.js +1 -0
- package/dist/packem_shared/dedupeMiddleware-B6ajWOTi.js +1 -0
- package/dist/packem_shared/defineInboundHandler-CnL2BzlL.js +1 -0
- package/dist/packem_shared/defineProvider-C9q-7iwt.js +1 -0
- package/dist/packem_shared/detectMimeType-Dxv4MjZ7.js +1 -0
- package/dist/packem_shared/emailMatchers-DZDkrZ_3.js +1 -0
- package/dist/packem_shared/event-bus.d-DEl3w_EW.d.ts +104 -0
- package/dist/packem_shared/extractCidReferences-BuoTREMp.js +1 -0
- package/dist/packem_shared/extractReply-BUjIBt9A.js +5 -0
- package/dist/packem_shared/failoverProvider-BgX6zfnY.js +1 -0
- package/dist/packem_shared/format-address-DTl-9O70.js +1 -0
- package/dist/packem_shared/generate-boundary-DQbzDiOI.js +1 -0
- package/dist/packem_shared/generate-message-id-gXAuMz4g.js +1 -0
- package/dist/packem_shared/headers-to-record-De1Eg951.js +1 -0
- package/dist/packem_shared/httpProvider-DJAsYSun.js +1 -0
- package/dist/packem_shared/index-yDU-1zOZ.js +11 -0
- package/dist/packem_shared/infobipProvider-oOL-ThpP.js +1 -0
- package/dist/packem_shared/injectPreheader-CF9WHZ7J.js +1 -0
- package/dist/packem_shared/inlineCss-BQ7d2Cyz.js +1 -0
- package/dist/packem_shared/isValidSigningCertUrl-Bii1AMGC.js +3 -0
- package/dist/packem_shared/loggingMiddleware-CZIiVMVp.js +1 -0
- package/dist/packem_shared/loopsProvider-BXr0KSjB.js +1 -0
- package/dist/packem_shared/mail.d-B9SSqyy0.d.ts +909 -0
- package/dist/packem_shared/{mailCrabProvider-CM_CFDca.js → mailCrabProvider-C7Ao5H9p.js} +1 -1
- package/dist/packem_shared/mailPaceProvider-DklGeGEM.js +1 -0
- package/dist/packem_shared/mailchannelsProvider-DPfQVzUd.js +1 -0
- package/dist/packem_shared/mailerSendProvider-B8iT5Uhb.js +1 -0
- package/dist/packem_shared/mailgunProvider-Ctyrs9d0.js +1 -0
- package/dist/packem_shared/mailjetProvider-v55nFDsr.js +1 -0
- package/dist/packem_shared/mailomatProvider-BCyB4Q4B.js +1 -0
- package/dist/packem_shared/mailtrapProvider-DcVw3sxR.js +1 -0
- package/dist/packem_shared/make-request-BlK_B72c.js +1 -0
- package/dist/packem_shared/mandrillProvider-gqMFMwgs.js +1 -0
- package/dist/packem_shared/mockProvider-Behywbl1.js +1 -0
- package/dist/packem_shared/netcoreProvider-XMWO_Aoa.js +1 -0
- package/dist/packem_shared/nodemailerProvider-BFHobXxt.js +1 -0
- package/dist/packem_shared/normalizeMessageId-DAx2pGe2.js +1 -0
- package/dist/packem_shared/oauth2Middleware-CodqXkyj.js +1 -0
- package/dist/packem_shared/opentelemetryProvider-ByHC01ub.js +1 -0
- package/dist/packem_shared/outlook365Provider-BoNtxqIx.js +1 -0
- package/dist/packem_shared/parseAddress-DdbViBAJ.js +1 -0
- package/dist/packem_shared/parseArfReport-Ds6S3c4J.js +6 -0
- package/dist/packem_shared/parseCloudflareInbound-C__j-oNa.js +1 -0
- package/dist/packem_shared/parseDmarcRecord-DXZ-_rF0.js +1 -0
- package/dist/packem_shared/parseMailgunInbound-BpC6uPNe.js +1 -0
- package/dist/packem_shared/parsePostmarkInbound-Co3_c6-9.js +1 -0
- package/dist/packem_shared/parseSendGridInbound-DsALoijO.js +4 -0
- package/dist/packem_shared/parseSesInbound-CH5tHIjp.js +1 -0
- package/dist/packem_shared/parseTlsReport-wPe1lIDs.js +1 -0
- package/dist/packem_shared/plunkProvider-C0LO-1E3.js +1 -0
- package/dist/packem_shared/postProcessHtml-DqKi2Ucg.js +1 -0
- package/dist/packem_shared/postalProvider-B26IqgxE.js +1 -0
- package/dist/packem_shared/postmarkProvider-DWQJv5_M.js +1 -0
- package/dist/packem_shared/provider-base-gIoUu9so.js +1 -0
- package/dist/packem_shared/provider.d-J-y6iogK.d.ts +28 -0
- package/dist/packem_shared/quoted-printable-nSGDA1tA.js +7 -0
- package/dist/packem_shared/resendProvider-DhvKVyCD.js +1 -0
- package/dist/packem_shared/retry-3pnxTuNs.js +1 -0
- package/dist/packem_shared/retryMiddleware-DbViDX4r.js +1 -0
- package/dist/packem_shared/roundRobinProvider-D1by5KGW.js +1 -0
- package/dist/packem_shared/sanitize-header-DJhgZl3y.js +1 -0
- package/dist/packem_shared/scalewayProvider-D8dmHuwZ.js +1 -0
- package/dist/packem_shared/sendGridProvider-CChhLr7s.js +1 -0
- package/dist/packem_shared/smtpProvider-x4WBN-3W.js +25 -0
- package/dist/packem_shared/sparkpostProvider-BytvwqjP.js +1 -0
- package/dist/packem_shared/sweegoProvider-7xhOvagC.js +1 -0
- package/dist/packem_shared/toEmailSnapshot-DeRqM5SJ.js +1 -0
- package/dist/packem_shared/tracer.d-MU42G1jG.d.ts +494 -0
- package/dist/packem_shared/types.d-BId55FW2.d.ts +107 -0
- package/dist/packem_shared/types.d-CmoWvdZi.d.ts +61 -0
- package/dist/packem_shared/types.d-DCkecJse.d.ts +51 -0
- package/dist/packem_shared/types.d-Mpu0HZoG.d.ts +24 -0
- package/dist/packem_shared/types.d-ejzh-xBP.d.ts +209 -0
- package/dist/packem_shared/types.d-lcJZmwRK.d.ts +69 -0
- package/dist/packem_shared/types.d-nyR1ty1Q.d.ts +9 -0
- package/dist/packem_shared/utils-BfYfPB_I.js +1 -0
- package/dist/packem_shared/validate-email-options-mCM9dVug.js +1 -0
- package/dist/packem_shared/verifyMailgunWebhook-Cwl0OD3P.js +1 -0
- package/dist/packem_shared/verifyPostmarkWebhook-C72ZvbrG.js +1 -0
- package/dist/packem_shared/verifyResendWebhook-YK2zNDXR.js +1 -0
- package/dist/packem_shared/verifySendGridWebhook-Dbwc1tfG.js +1 -0
- package/dist/packem_shared/withEvents-CCVblSqj.js +1 -0
- package/dist/packem_shared/withMetrics-DWywX_6M.js +1 -0
- package/dist/packem_shared/withRender-VP9wE5Yr.js +1 -0
- package/dist/packem_shared/withSuppression-DBaZDMAr.js +1 -0
- package/dist/packem_shared/withTelemetry-DL2qo0Hp.js +1 -0
- package/dist/packem_shared/zeptomailProvider-D3nQKXRf.js +1 -0
- package/dist/providers/ahasend/index.d.ts +36 -3
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/aws-ses/index.d.ts +47 -3
- package/dist/providers/aws-ses/index.js +1 -1
- package/dist/providers/azure/index.d.ts +52 -3
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.d.ts +65 -3
- package/dist/providers/brevo/index.js +1 -1
- package/dist/providers/cloudflare-email/index.d.ts +36 -0
- package/dist/providers/cloudflare-email/index.js +1 -0
- package/dist/providers/failover/index.d.ts +27 -3
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/http/index.d.ts +35 -3
- package/dist/providers/http/index.js +1 -1
- package/dist/providers/infobip/index.d.ts +56 -3
- package/dist/providers/infobip/index.js +1 -1
- package/dist/providers/loops/index.d.ts +47 -0
- package/dist/providers/loops/index.js +1 -0
- package/dist/providers/mailchannels/index.d.ts +26 -0
- package/dist/providers/mailchannels/index.js +1 -0
- package/dist/providers/mailcrab/index.d.ts +32 -3
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.d.ts +51 -3
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.d.ts +73 -3
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.d.ts +72 -3
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.d.ts +40 -3
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.d.ts +52 -3
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.d.ts +44 -3
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.d.ts +87 -3
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/mock/index.d.ts +12 -3
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/netcore/index.d.ts +35 -0
- package/dist/providers/netcore/index.js +1 -0
- package/dist/providers/nodemailer/index.d.ts +38 -3
- package/dist/providers/nodemailer/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +37 -3
- package/dist/providers/opentelemetry/index.js +1 -1
- package/dist/providers/outlook365/index.d.ts +48 -0
- package/dist/providers/outlook365/index.js +1 -0
- package/dist/providers/plunk/index.d.ts +38 -3
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.d.ts +48 -3
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.d.ts +60 -3
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.d.ts +51 -3
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +27 -3
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/scaleway/index.d.ts +44 -3
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.d.ts +84 -3
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.d.ts +71 -3
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sparkpost/index.d.ts +43 -0
- package/dist/providers/sparkpost/index.js +1 -0
- package/dist/providers/sweego/index.d.ts +40 -3
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.d.ts +37 -3
- package/dist/providers/zeptomail/index.js +1 -1
- package/dist/queue/bullmq-queue.d.ts +46 -0
- package/dist/queue/bullmq-queue.js +1 -0
- package/dist/queue/index.d.ts +147 -0
- package/dist/queue/index.js +1 -0
- package/dist/queue/pg-boss-queue.d.ts +41 -0
- package/dist/queue/pg-boss-queue.js +1 -0
- package/dist/queue/sqs-queue.d.ts +72 -0
- package/dist/queue/sqs-queue.js +1 -0
- package/dist/queue/unstorage-queue.d.ts +199 -0
- package/dist/queue/unstorage-queue.js +1 -0
- package/dist/render/index.d.ts +107 -0
- package/dist/render/index.js +1 -0
- package/dist/template-engines/handlebars.d.ts +23 -22
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/html-to-text.d.ts +24 -24
- package/dist/template-engines/html-to-text.js +1 -1
- package/dist/template-engines/i18n.d.ts +61 -0
- package/dist/template-engines/i18n.js +1 -0
- package/dist/template-engines/jsx-email.d.ts +11 -0
- package/dist/template-engines/jsx-email.js +1 -0
- package/dist/template-engines/liquid.d.ts +12 -0
- package/dist/template-engines/liquid.js +1 -0
- package/dist/template-engines/mjml.d.ts +10 -10
- package/dist/template-engines/mjml.js +1 -1
- package/dist/template-engines/react-email.d.ts +9 -9
- package/dist/template-engines/react-email.js +1 -1
- package/dist/template-engines/vue-email.d.ts +9 -9
- package/dist/template-engines/vue-email.js +1 -1
- package/dist/test/index.d.ts +159 -0
- package/dist/test/index.js +1 -0
- package/dist/utils/cache.d.ts +49 -48
- package/dist/utils/cache.js +1 -1
- package/dist/utils/format-email-address.d.ts +8 -7
- package/dist/utils/format-email-address.js +1 -1
- package/dist/utils/normalize-email-aliases.d.ts +20 -20
- package/dist/utils/normalize-email-aliases.js +1 -1
- package/dist/utils/parse-address.d.ts +18 -17
- package/dist/utils/parse-address.js +1 -1
- package/dist/utils/parse-eml.d.ts +22 -0
- package/dist/utils/parse-eml.js +6 -0
- package/dist/utils/result.d.ts +49 -0
- package/dist/utils/result.js +1 -0
- package/dist/utils/validation/check-feature-support.d.ts +53 -0
- package/dist/utils/validation/check-feature-support.js +1 -0
- package/dist/utils/validation/check-mx-records.d.ts +36 -35
- package/dist/utils/validation/check-mx-records.js +1 -1
- package/dist/utils/validation/disposable-email-domains.d.ts +1 -13
- package/dist/utils/validation/role-accounts.d.ts +18 -18
- package/dist/utils/validation/role-accounts.js +1 -1
- package/dist/utils/validation/validate-email.d.ts +5 -5
- package/dist/utils/validation/validate-email.js +1 -1
- package/dist/utils/validation/verify-email.d.ts +45 -42
- package/dist/utils/validation/verify-email.js +1 -1
- package/dist/utils/validation/verify-smtp.d.ts +35 -34
- package/dist/utils/validation/verify-smtp.js +4 -4
- package/dist/webhooks/index.d.ts +231 -0
- package/dist/webhooks/index.js +1 -0
- package/package.json +181 -48
- package/dist/attachment-helpers.d.ts +0 -64
- package/dist/crypto/dkim-signer.d.ts +0 -48
- package/dist/crypto/smime-encrypter.d.ts +0 -53
- package/dist/crypto/smime-signer.d.ts +0 -48
- package/dist/crypto/types.d.ts +0 -101
- package/dist/draft-mail-message.d.ts +0 -13
- package/dist/errors/email-error.d.ts +0 -17
- package/dist/errors/required-option-error.d.ts +0 -10
- package/dist/mail-message.d.ts +0 -425
- package/dist/mail.d.ts +0 -206
- package/dist/packem_shared/DkimSigner-pFd4c3fZ.js +0 -18
- package/dist/packem_shared/EmailError-zm2ffVav.js +0 -1
- package/dist/packem_shared/Mail-6Bltpy_p.js +0 -1
- package/dist/packem_shared/MailMessage-B76GPBBA.js +0 -1
- package/dist/packem_shared/RequiredOptionError-CevW3u2K.js +0 -1
- package/dist/packem_shared/SmimeEncrypter-CBevU534.js +0 -6
- package/dist/packem_shared/SmimeSigner-CObA4jzT.js +0 -8
- package/dist/packem_shared/address-formatter-Cm_E_ZMa.js +0 -1
- package/dist/packem_shared/ahaSendProvider-DlFKEQ6D.js +0 -1
- package/dist/packem_shared/attachment-processor-2rHmfa7j.js +0 -1
- package/dist/packem_shared/awsSesProvider-Ba-eVJxZ.js +0 -32
- package/dist/packem_shared/azureProvider-CQYAkgVF.js +0 -1
- package/dist/packem_shared/brevoProvider-5p6jjiK9.js +0 -1
- package/dist/packem_shared/build-mime-message-IYaUqqPJ.js +0 -2
- package/dist/packem_shared/create-logger-BiWdqFNg.js +0 -1
- package/dist/packem_shared/defineProvider-B9rSklAJ.js +0 -1
- package/dist/packem_shared/detectMimeType-S8WRsNtY.js +0 -1
- package/dist/packem_shared/failoverProvider-CAHQQueo.js +0 -1
- package/dist/packem_shared/generate-boundary-Cx8nXYS0.js +0 -1
- package/dist/packem_shared/generate-message-id-D4uA8gkj.js +0 -1
- package/dist/packem_shared/headers-to-record-Qo124ImV.js +0 -1
- package/dist/packem_shared/httpProvider-CZD6LZX3.js +0 -1
- package/dist/packem_shared/infobipProvider-CtLwrUaP.js +0 -1
- package/dist/packem_shared/mailPaceProvider-B6yKvh6z.js +0 -1
- package/dist/packem_shared/mailerSendProvider-CeeIXFnW.js +0 -1
- package/dist/packem_shared/mailgunProvider-mmjKzouh.js +0 -1
- package/dist/packem_shared/mailjetProvider-DwN6i0VA.js +0 -1
- package/dist/packem_shared/mailomatProvider-DMQmjKHT.js +0 -1
- package/dist/packem_shared/mailtrapProvider-BN3UBEQw.js +0 -1
- package/dist/packem_shared/make-request-BDzF9W9D.js +0 -1
- package/dist/packem_shared/mandrillProvider-370y7CLu.js +0 -1
- package/dist/packem_shared/mockProvider-DN5ZwutD.js +0 -1
- package/dist/packem_shared/nodemailerProvider-_w8QXMU-.js +0 -1
- package/dist/packem_shared/opentelemetryProvider-C_ZXOLSd.js +0 -1
- package/dist/packem_shared/plunkProvider-DfJumQ4U.js +0 -1
- package/dist/packem_shared/postalProvider-Bavx2FcH.js +0 -1
- package/dist/packem_shared/postmarkProvider-DFC0uvjO.js +0 -1
- package/dist/packem_shared/provider-base-Cmzx6BTO.js +0 -1
- package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +0 -1
- package/dist/packem_shared/resendProvider-CfqU7UdE.js +0 -1
- package/dist/packem_shared/roundRobinProvider-1WQnuKR8.js +0 -1
- package/dist/packem_shared/sanitize-header-wWav-Scu.js +0 -1
- package/dist/packem_shared/scalewayProvider-be1HPimL.js +0 -1
- package/dist/packem_shared/sendGridProvider-BVI1sq3n.js +0 -1
- package/dist/packem_shared/smtpProvider-BV-ufR53.js +0 -23
- package/dist/packem_shared/sweegoProvider-7419CSAq.js +0 -1
- package/dist/packem_shared/validate-email-options-DfJ7llf8.js +0 -1
- package/dist/packem_shared/zeptomailProvider-C2lh0Xmo.js +0 -1
- package/dist/providers/ahasend/provider.d.ts +0 -7
- package/dist/providers/ahasend/types.d.ts +0 -28
- package/dist/providers/aws-ses/provider.d.ts +0 -8
- package/dist/providers/aws-ses/types.d.ts +0 -38
- package/dist/providers/azure/provider.d.ts +0 -7
- package/dist/providers/azure/types.d.ts +0 -44
- package/dist/providers/brevo/provider.d.ts +0 -7
- package/dist/providers/brevo/types.d.ts +0 -57
- package/dist/providers/failover/provider.d.ts +0 -7
- package/dist/providers/failover/types.d.ts +0 -19
- package/dist/providers/http/provider.d.ts +0 -7
- package/dist/providers/http/types.d.ts +0 -27
- package/dist/providers/infobip/provider.d.ts +0 -7
- package/dist/providers/infobip/types.d.ts +0 -48
- package/dist/providers/mailcrab/provider.d.ts +0 -9
- package/dist/providers/mailcrab/types.d.ts +0 -22
- package/dist/providers/mailersend/provider.d.ts +0 -7
- package/dist/providers/mailersend/types.d.ts +0 -43
- package/dist/providers/mailgun/provider.d.ts +0 -7
- package/dist/providers/mailgun/types.d.ts +0 -65
- package/dist/providers/mailjet/provider.d.ts +0 -7
- package/dist/providers/mailjet/types.d.ts +0 -64
- package/dist/providers/mailomat/provider.d.ts +0 -7
- package/dist/providers/mailomat/types.d.ts +0 -32
- package/dist/providers/mailpace/provider.d.ts +0 -7
- package/dist/providers/mailpace/types.d.ts +0 -44
- package/dist/providers/mailtrap/provider.d.ts +0 -7
- package/dist/providers/mailtrap/types.d.ts +0 -36
- package/dist/providers/mandrill/provider.d.ts +0 -7
- package/dist/providers/mandrill/types.d.ts +0 -79
- package/dist/providers/mock/provider.d.ts +0 -8
- package/dist/providers/mock/types.d.ts +0 -50
- package/dist/providers/nodemailer/provider.d.ts +0 -7
- package/dist/providers/nodemailer/types.d.ts +0 -30
- package/dist/providers/opentelemetry/provider.d.ts +0 -8
- package/dist/providers/opentelemetry/types.d.ts +0 -31
- package/dist/providers/plunk/provider.d.ts +0 -7
- package/dist/providers/plunk/types.d.ts +0 -30
- package/dist/providers/postal/provider.d.ts +0 -7
- package/dist/providers/postal/types.d.ts +0 -40
- package/dist/providers/postmark/provider.d.ts +0 -7
- package/dist/providers/postmark/types.d.ts +0 -52
- package/dist/providers/provider.d.ts +0 -27
- package/dist/providers/resend/provider.d.ts +0 -7
- package/dist/providers/resend/types.d.ts +0 -43
- package/dist/providers/roundrobin/provider.d.ts +0 -7
- package/dist/providers/roundrobin/types.d.ts +0 -19
- package/dist/providers/scaleway/provider.d.ts +0 -7
- package/dist/providers/scaleway/types.d.ts +0 -36
- package/dist/providers/sendgrid/provider.d.ts +0 -7
- package/dist/providers/sendgrid/types.d.ts +0 -76
- package/dist/providers/smtp/provider.d.ts +0 -7
- package/dist/providers/smtp/types.d.ts +0 -63
- package/dist/providers/sweego/provider.d.ts +0 -7
- package/dist/providers/sweego/types.d.ts +0 -32
- package/dist/providers/utils/address-formatter.d.ts +0 -139
- package/dist/providers/utils/attachment-processor.d.ts +0 -58
- package/dist/providers/utils/index.d.ts +0 -4
- package/dist/providers/utils/payload-builder.d.ts +0 -78
- package/dist/providers/utils/provider-base.d.ts +0 -69
- package/dist/providers/zeptomail/provider.d.ts +0 -7
- package/dist/providers/zeptomail/types.d.ts +0 -29
- package/dist/template-engines/types.d.ts +0 -8
- package/dist/types.d.ts +0 -203
- package/dist/utils/build-mime-message.d.ts +0 -8
- package/dist/utils/create-logger.d.ts +0 -16
- package/dist/utils/format-email-addresses.d.ts +0 -8
- package/dist/utils/generate-boundary.d.ts +0 -7
- package/dist/utils/generate-message-id.d.ts +0 -6
- package/dist/utils/headers-to-record.d.ts +0 -9
- package/dist/utils/is-port-available.d.ts +0 -9
- package/dist/utils/make-request.d.ts +0 -18
- package/dist/utils/retry.d.ts +0 -10
- package/dist/utils/sanitize-header.d.ts +0 -14
- package/dist/utils/to-base64.d.ts +0 -8
- package/dist/utils/validation/validate-email-options.d.ts +0 -8
package/README.md
CHANGED
|
@@ -114,6 +114,46 @@ const message = new MailMessage().to("user@example.com").subject("Hello").html("
|
|
|
114
114
|
await mail.send(message);
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
### Capability Guard (fail-fast field support)
|
|
118
|
+
|
|
119
|
+
Every provider declares which capabilities it supports through its `features` flags (attachments, tagging, scheduling, HTML, custom headers, reply-to, templates, ...). Before a message is handed to the provider, `Mail` runs a fail-fast check: if the message uses a capability the provider has **explicitly** declared unsupported (`features[x] === false`), the send is rejected locally — no wasted network round-trip and no silent data loss.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { createMail } from "@visulima/email";
|
|
123
|
+
import { awsSesProvider } from "@visulima/email/providers/aws-ses";
|
|
124
|
+
|
|
125
|
+
// AWS SES declares `tagging: false`
|
|
126
|
+
const mail = createMail(awsSesProvider({ accessKeyId, secretAccessKey, region }));
|
|
127
|
+
|
|
128
|
+
const result = await mail.send({
|
|
129
|
+
from: { email: "noreply@example.com" },
|
|
130
|
+
subject: "Hi",
|
|
131
|
+
tags: ["promo"], // not representable by AWS SES
|
|
132
|
+
text: "Body",
|
|
133
|
+
to: { email: "user@example.com" },
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
result.success; // false
|
|
137
|
+
(result.error as { code?: string }).code; // "UNSUPPORTED_FEATURES"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Capabilities left `undefined` are treated as "unknown" and never rejected, so providers that publish a partial (or no) `features` map are never falsely blocked. The behaviour is configurable per `Mail` instance:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
createMail(provider, { featureCheck: "error" }); // default — reject unsupported fields
|
|
144
|
+
createMail(provider, { featureCheck: "warn" }); // log a warning and send anyway
|
|
145
|
+
createMail(provider, { featureCheck: "off" }); // skip the check entirely
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
You can also run the check standalone (e.g. inside a custom provider):
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { checkFeatureSupport } from "@visulima/email";
|
|
152
|
+
// or the focused entry point: "@visulima/email/validation/check-feature-support"
|
|
153
|
+
|
|
154
|
+
const { supported, violations } = checkFeatureSupport(message, provider.features);
|
|
155
|
+
```
|
|
156
|
+
|
|
117
157
|
### Creating Draft Emails
|
|
118
158
|
|
|
119
159
|
You can create draft emails in EML (RFC 822) format without sending them. The `draft()` method returns the email as an EML string with an `X-Unsent: 1` header automatically added:
|
|
@@ -159,11 +199,7 @@ const smtpMail = createMail(smtp);
|
|
|
159
199
|
const resendMail = createMail(resend);
|
|
160
200
|
|
|
161
201
|
// Send via specific provider
|
|
162
|
-
const message = new MailMessage()
|
|
163
|
-
.to("user@example.com")
|
|
164
|
-
.from("sender@example.com")
|
|
165
|
-
.subject("Hello")
|
|
166
|
-
.html("<h1>Hello World</h1>");
|
|
202
|
+
const message = new MailMessage().to("user@example.com").from("sender@example.com").subject("Hello").html("<h1>Hello World</h1>");
|
|
167
203
|
|
|
168
204
|
await resendMail.send(message);
|
|
169
205
|
```
|
|
@@ -876,6 +912,70 @@ const sendGridOptions: SendGridEmailOptions = {
|
|
|
876
912
|
await mail.send(sendGridOptions);
|
|
877
913
|
```
|
|
878
914
|
|
|
915
|
+
### SparkPost Provider
|
|
916
|
+
|
|
917
|
+
SparkPost is a high-volume email delivery service. Universal runtime (Fetch API).
|
|
918
|
+
|
|
919
|
+
```typescript
|
|
920
|
+
import { createMail, sparkpostProvider } from "@visulima/email/providers/sparkpost";
|
|
921
|
+
|
|
922
|
+
const mail = createMail(
|
|
923
|
+
sparkpostProvider({
|
|
924
|
+
apiKey: "your-sparkpost-api-key",
|
|
925
|
+
endpoint: "https://api.sparkpost.com/api/v1", // or https://api.eu.sparkpost.com/api/v1 (EU)
|
|
926
|
+
}),
|
|
927
|
+
);
|
|
928
|
+
|
|
929
|
+
await mail.send({
|
|
930
|
+
from: { email: "sender@example.com" },
|
|
931
|
+
to: { email: "user@example.com" },
|
|
932
|
+
subject: "Welcome",
|
|
933
|
+
html: "<h1>Welcome!</h1>",
|
|
934
|
+
// SparkPost-specific: campaignId, templateId, trackOpens, trackClicks
|
|
935
|
+
});
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
### Netcore Provider
|
|
939
|
+
|
|
940
|
+
Netcore (formerly Pepipost) transactional email via the Email API v5.1. Universal runtime (Fetch API).
|
|
941
|
+
|
|
942
|
+
```typescript
|
|
943
|
+
import { createMail, netcoreProvider } from "@visulima/email/providers/netcore";
|
|
944
|
+
|
|
945
|
+
const mail = createMail(netcoreProvider({ apiKey: "your-netcore-api-key" }));
|
|
946
|
+
|
|
947
|
+
await mail.send({
|
|
948
|
+
from: { email: "sender@example.com" },
|
|
949
|
+
to: { email: "user@example.com" },
|
|
950
|
+
subject: "Welcome",
|
|
951
|
+
html: "<h1>Welcome!</h1>",
|
|
952
|
+
// Netcore-specific: templateId, templateData
|
|
953
|
+
});
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
### Outlook365 Provider
|
|
957
|
+
|
|
958
|
+
Sends through Microsoft Graph `sendMail`. Universal runtime (Fetch API). Bring your own OAuth2 token (`Mail.Send` scope)
|
|
959
|
+
via `accessToken` or `getAccessToken` — no auth SDK is bundled.
|
|
960
|
+
|
|
961
|
+
```typescript
|
|
962
|
+
import { createMail, outlook365Provider } from "@visulima/email/providers/outlook365";
|
|
963
|
+
|
|
964
|
+
const mail = createMail(
|
|
965
|
+
outlook365Provider({
|
|
966
|
+
getAccessToken: async () => getGraphAccessToken(),
|
|
967
|
+
userId: "sender@contoso.com", // or "me" (default)
|
|
968
|
+
}),
|
|
969
|
+
);
|
|
970
|
+
|
|
971
|
+
await mail.send({
|
|
972
|
+
from: { email: "sender@contoso.com" },
|
|
973
|
+
to: { email: "user@example.com" },
|
|
974
|
+
subject: "Welcome",
|
|
975
|
+
html: "<h1>Welcome!</h1>",
|
|
976
|
+
});
|
|
977
|
+
```
|
|
978
|
+
|
|
879
979
|
### Plunk Provider
|
|
880
980
|
|
|
881
981
|
Plunk is a modern email platform built on top of AWS SES, offering transactional emails, automations, and broadcasts.
|
|
@@ -1033,6 +1133,9 @@ const result = await mail.send(message);
|
|
|
1033
1133
|
- **Round Robin** - Load balancing across multiple providers
|
|
1034
1134
|
- **OpenTelemetry** - OpenTelemetry instrumentation wrapper for observability
|
|
1035
1135
|
- **SendGrid** - Cloud-based email service for transactional and marketing emails
|
|
1136
|
+
- **SparkPost** - SparkPost Transmissions API
|
|
1137
|
+
- **Netcore** - Netcore (Pepipost) Email API
|
|
1138
|
+
- **Outlook365** - Microsoft Graph (Outlook365) `sendMail`
|
|
1036
1139
|
- **SMTP** - Standard SMTP protocol
|
|
1037
1140
|
- **Zeptomail** - Zeptomail email service
|
|
1038
1141
|
|
|
@@ -1063,6 +1166,9 @@ These providers work in **Node.js**, **Deno**, **Bun**, and **Cloudflare Workers
|
|
|
1063
1166
|
- ✅ **Mailomat** - Uses Fetch API
|
|
1064
1167
|
- ✅ **Sweego** - Uses Fetch API
|
|
1065
1168
|
- ✅ **SendGrid** - Uses Fetch API
|
|
1169
|
+
- ✅ **SparkPost** - Uses Fetch API
|
|
1170
|
+
- ✅ **Netcore** - Uses Fetch API
|
|
1171
|
+
- ✅ **Outlook365** - Uses Fetch API (Microsoft Graph; bring your own OAuth2 token)
|
|
1066
1172
|
- ✅ **Plunk** - Uses Fetch API
|
|
1067
1173
|
- ✅ **Mock** - In-memory provider, works everywhere
|
|
1068
1174
|
- ✅ **Failover** - Runtime depends on wrapped providers (works if all wrapped providers support the runtime)
|
|
@@ -1380,6 +1486,102 @@ normalizeEmailAliases("user+tag@gmx.com"); // "user@gmx.com"
|
|
|
1380
1486
|
normalizeEmailAliases("user@example.com"); // "user@example.com"
|
|
1381
1487
|
```
|
|
1382
1488
|
|
|
1489
|
+
## Batch Sending & Result Helpers
|
|
1490
|
+
|
|
1491
|
+
Send one message per recipient from a shared base, with optional per-recipient template rendering, via `mail.sendBatch(base, personalizations, options?)`. Every `send` returns a `Result<EmailResult>`; the `isOk`/`isErr`/`unwrap`/`unwrapOr`/`mapOk`/`tryAsync` helpers (exported from the root and `@visulima/email/utils/result`) make handling it ergonomic.
|
|
1492
|
+
|
|
1493
|
+
```typescript
|
|
1494
|
+
import { createMail, isOk, unwrapOr } from "@visulima/email";
|
|
1495
|
+
|
|
1496
|
+
const mail = createMail(provider);
|
|
1497
|
+
|
|
1498
|
+
for await (const receipt of mail.sendBatch(
|
|
1499
|
+
{ from: { email: "news@example.com" }, subject: "Hi {{name}}", html: "<p>Hello {{name}}</p>" },
|
|
1500
|
+
[{ to: { email: "a@example.com" }, data: { name: "Ada" } }],
|
|
1501
|
+
{ render: (template, data) => renderHandlebars(template, data) },
|
|
1502
|
+
)) {
|
|
1503
|
+
if (receipt.successful) console.log("sent", receipt.messageId);
|
|
1504
|
+
}
|
|
1505
|
+
```
|
|
1506
|
+
|
|
1507
|
+
See [Sending Mail](https://visulima.com/docs/package/email/getting-started/sending-mail).
|
|
1508
|
+
|
|
1509
|
+
## Middleware
|
|
1510
|
+
|
|
1511
|
+
Attach resilience middleware with `mail.use(...)`: retry (full-jitter backoff + dead-letter), rate limiting (with per-provider presets), circuit breaker, deduplication, OAuth2 token refresh, and PII-redacting logging.
|
|
1512
|
+
|
|
1513
|
+
```typescript
|
|
1514
|
+
import { createMail } from "@visulima/email";
|
|
1515
|
+
import { circuitBreakerMiddleware, RATE_LIMIT_PRESETS, rateLimitMiddleware, retryMiddleware } from "@visulima/email/middleware";
|
|
1516
|
+
|
|
1517
|
+
const mail = createMail(provider)
|
|
1518
|
+
.use(rateLimitMiddleware({ rate: RATE_LIMIT_PRESETS.resend }))
|
|
1519
|
+
.use(circuitBreakerMiddleware())
|
|
1520
|
+
.use(retryMiddleware({ retries: 3 }));
|
|
1521
|
+
```
|
|
1522
|
+
|
|
1523
|
+
See [Middleware](https://visulima.com/docs/package/email/middleware/introduction).
|
|
1524
|
+
|
|
1525
|
+
## Queue & Worker
|
|
1526
|
+
|
|
1527
|
+
Durable background sending via the `EmailQueue` interface: an in-memory `MemoryQueue`, an `UnstorageQueue` (`@visulima/email/queue/unstorage`) backed by any [unstorage](https://unstorage.unjs.io/) store (Redis/FS/KV/Postgres), and a `createWorker(...)` with bounded concurrency, retry/backoff and dead-lettering.
|
|
1528
|
+
|
|
1529
|
+
```typescript
|
|
1530
|
+
import { createMail } from "@visulima/email";
|
|
1531
|
+
import { createWorker, MemoryQueue } from "@visulima/email/queue";
|
|
1532
|
+
|
|
1533
|
+
const queue = new MemoryQueue();
|
|
1534
|
+
const mail = createMail(provider);
|
|
1535
|
+
|
|
1536
|
+
await queue.enqueue({ from: { email: "a@x.com" }, to: { email: "b@x.com" }, subject: "Hi", text: "yo" });
|
|
1537
|
+
createWorker({ queue, send: mail.send.bind(mail), concurrency: 5 }).start();
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
See [Queue](https://visulima.com/docs/package/email/queue/introduction).
|
|
1541
|
+
|
|
1542
|
+
## Webhook Verification
|
|
1543
|
+
|
|
1544
|
+
Verify provider webhook signatures with `@visulima/email/webhooks`: `verifyStandardWebhook`/`verifyResendWebhook` (Svix/Standard Webhooks), `verifyMailgunWebhook`, `verifySendGridWebhook` (ECDSA + replay window), `verifyPostmarkWebhook` (Basic Auth), and `verifySnsMessage` (AWS SES via SNS, with a tight `sns.<region>.amazonaws.com` cert allowlist). All return `{ valid, reason? }` — always pass the **raw** request body.
|
|
1545
|
+
|
|
1546
|
+
See [Webhooks](https://visulima.com/docs/package/email/webhooks/introduction).
|
|
1547
|
+
|
|
1548
|
+
## Inbound Parsing
|
|
1549
|
+
|
|
1550
|
+
Normalize inbound webhooks from Postmark, SendGrid, Mailgun, Cloudflare Email and SES into one `InboundEmail` shape, then strip quoted history with `extractReply()` (EN/DE/FR/ES/TR) and group conversations with `stitchThreads()`.
|
|
1551
|
+
|
|
1552
|
+
See [Inbound](https://visulima.com/docs/package/email/inbound/introduction).
|
|
1553
|
+
|
|
1554
|
+
## Deliverability
|
|
1555
|
+
|
|
1556
|
+
2024 bulk-sender tooling in `@visulima/email/deliverability`: RFC 8058 one-click `buildListUnsubscribe`, suppression stores (`MemorySuppressionStore` + `filterSuppressed`), and parsers for DMARC records, MTA-STS policies, TLS-RPT records/reports, and ARF feedback-loop complaints. ARC sealing (`signArc`) lives in `@visulima/email/crypto`.
|
|
1557
|
+
|
|
1558
|
+
See [Deliverability](https://visulima.com/docs/package/email/deliverability/introduction).
|
|
1559
|
+
|
|
1560
|
+
## Events & Testing
|
|
1561
|
+
|
|
1562
|
+
A unified `EmailEvent` stream (`EventBus` + `MemoryEventStore` in `@visulima/email/events`), and a test harness (`@visulima/email/test`): `createTestEmail()` plus Vitest matchers `toHaveSentTo` / `toHaveSentWithSubject` / `toHaveSentWithAttachment` / `toHaveSentMatching`.
|
|
1563
|
+
|
|
1564
|
+
See [Events](https://visulima.com/docs/package/email/events/introduction) and [Testing](https://visulima.com/docs/package/email/testing/introduction).
|
|
1565
|
+
|
|
1566
|
+
## Crypto (DKIM / S/MIME / ARC)
|
|
1567
|
+
|
|
1568
|
+
Sign and encrypt messages with `@visulima/email/crypto`: `createDkimSigner` (DKIM-Signature header), `createSmimeSigner` / `createSmimeEncrypter` (S/MIME sign and encrypt, via the optional `pkijs` + `asn1js` peers), and `signArc` / `verifyArc` for ARC sealing on forwarded mail. Attach signers/encrypters to a `MailMessage` with `.sign(...)` / `.encrypt(...)`.
|
|
1569
|
+
|
|
1570
|
+
```typescript
|
|
1571
|
+
import { MailMessage } from "@visulima/email";
|
|
1572
|
+
import { createDkimSigner } from "@visulima/email/crypto";
|
|
1573
|
+
|
|
1574
|
+
const signer = createDkimSigner({
|
|
1575
|
+
domainName: "example.com",
|
|
1576
|
+
keySelector: "default",
|
|
1577
|
+
privateKey: "file:///path/to/dkim.private.key", // or an inline PEM string
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1580
|
+
const message = new MailMessage().from({ email: "a@example.com" }).to({ email: "b@example.com" }).subject("Signed").html("<p>Hello</p>").sign(signer); // DKIM-Signature is added during build()
|
|
1581
|
+
```
|
|
1582
|
+
|
|
1583
|
+
See [Crypto](https://visulima.com/docs/package/email/crypto/introduction).
|
|
1584
|
+
|
|
1383
1585
|
## Related
|
|
1384
1586
|
|
|
1385
1587
|
## Supported Node.js Versions
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,4 +1,304 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { KeyObject } from 'node:crypto';
|
|
2
|
+
import { E as EmailOptions } from "../packem_shared/types.d-ejzh-xBP.js";
|
|
3
|
+
import { D as DkimOptions, E as EmailSigner, S as SmimeEncryptOptions, a as EmailEncrypter, b as SmimeSignOptions } from "../packem_shared/types.d-BId55FW2.js";
|
|
4
|
+
import 'node:buffer';
|
|
5
|
+
/**
|
|
6
|
+
* The signature algorithm for the ARC headers. RSA per RFC 8617, Ed25519 per RFC 8463.
|
|
7
|
+
*/
|
|
8
|
+
type ArcAlgorithm = "ed25519-sha256" | "rsa-sha256";
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link signArc}.
|
|
11
|
+
*/
|
|
12
|
+
interface ArcSealOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Signature algorithm (`a=`). `rsa-sha256` (default) or `ed25519-sha256` (RFC 8463).
|
|
15
|
+
* @default "rsa-sha256"
|
|
16
|
+
*/
|
|
17
|
+
algorithm?: ArcAlgorithm;
|
|
18
|
+
/**
|
|
19
|
+
* The `Authentication-Results` value to chain (authserv-id plus method results),
|
|
20
|
+
* e.g. `example.com; spf=pass smtp.mailfrom=...; dkim=pass header.d=...`.
|
|
21
|
+
*/
|
|
22
|
+
authenticationResults: string;
|
|
23
|
+
/**
|
|
24
|
+
* Chain validation status for the seal (`cv`). For an originating sealer (instance 1) this is
|
|
25
|
+
* always `none`.
|
|
26
|
+
* @default "none"
|
|
27
|
+
*/
|
|
28
|
+
cv?: "fail" | "none" | "pass";
|
|
29
|
+
/**
|
|
30
|
+
* The signing domain (`d`).
|
|
31
|
+
*/
|
|
32
|
+
domainName: string;
|
|
33
|
+
/**
|
|
34
|
+
* Lower-cased header names covered by the ARC-Message-Signature (`h`).
|
|
35
|
+
* @default from, to, cc, subject, date, message-id, mime-version
|
|
36
|
+
*/
|
|
37
|
+
headersToSign?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* The ARC instance number (`i`). Only `1` (originating sealer) is supported.
|
|
40
|
+
* @default 1
|
|
41
|
+
*/
|
|
42
|
+
instance?: number;
|
|
43
|
+
/**
|
|
44
|
+
* The DKIM/ARC key selector (`s`).
|
|
45
|
+
*/
|
|
46
|
+
keySelector: string;
|
|
47
|
+
/**
|
|
48
|
+
* Passphrase for an encrypted private key.
|
|
49
|
+
*/
|
|
50
|
+
passphrase?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Private key (PEM string, or a `file://` path). RSA or Ed25519 to match `algorithm`.
|
|
53
|
+
*/
|
|
54
|
+
privateKey: string;
|
|
55
|
+
/**
|
|
56
|
+
* Signature timestamp (`t`) in unix seconds. Defaults to now.
|
|
57
|
+
*/
|
|
58
|
+
timestamp?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The three ARC header fields produced for one instance.
|
|
62
|
+
*/
|
|
63
|
+
interface ArcHeaderSet {
|
|
64
|
+
"ARC-Authentication-Results": string;
|
|
65
|
+
"ARC-Message-Signature": string;
|
|
66
|
+
"ARC-Seal": string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Options for {@link verifyArc}.
|
|
70
|
+
*/
|
|
71
|
+
interface ArcVerifyOptions {
|
|
72
|
+
/**
|
|
73
|
+
* The ARC/DKIM public key for the signing domain+selector — a PEM string or a `KeyObject`. Look it
|
|
74
|
+
* up at `<selector>._domainkey.<d>` (the `p=` tag), decoded to SPKI.
|
|
75
|
+
*/
|
|
76
|
+
publicKey: KeyObject | string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The outcome of {@link verifyArc}.
|
|
80
|
+
*/
|
|
81
|
+
interface ArcVerifyResult {
|
|
82
|
+
/**
|
|
83
|
+
* Per-component verification: the ARC-Message-Signature, the ARC-Seal, and the body hash.
|
|
84
|
+
*/
|
|
85
|
+
components: {
|
|
86
|
+
ams: boolean;
|
|
87
|
+
bodyHash: boolean;
|
|
88
|
+
seal: boolean;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The chain-validation status (`cv`) from the ARC-Seal.
|
|
92
|
+
*/
|
|
93
|
+
cv?: string;
|
|
94
|
+
/**
|
|
95
|
+
* A machine-readable reason when `valid` is `false`.
|
|
96
|
+
*/
|
|
97
|
+
reason?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the whole instance verified (signature + seal + body hash).
|
|
100
|
+
*/
|
|
101
|
+
valid: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Computes the exact byte string that the ARC-Message-Signature `b=` value signs.
|
|
105
|
+
*
|
|
106
|
+
* Exposed so ARC verifiers (and tests) can re-derive the signing input.
|
|
107
|
+
* @param email The email being sealed.
|
|
108
|
+
* @param options The seal options.
|
|
109
|
+
* @returns The AMS header (without the `b=` value) and the data signed.
|
|
110
|
+
*/
|
|
111
|
+
declare const arcMessageSignatureBase: (email: EmailOptions, options: ArcSealOptions) => {
|
|
112
|
+
header: string;
|
|
113
|
+
signBase: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Computes the exact byte string that the ARC-Seal `b=` value signs (for an originating, i=1 seal).
|
|
117
|
+
*
|
|
118
|
+
* Exposed so ARC verifiers (and tests) can re-derive the signing input.
|
|
119
|
+
* @param aarValue The ARC-Authentication-Results value.
|
|
120
|
+
* @param amsValue The full ARC-Message-Signature value (including its `b=` signature).
|
|
121
|
+
* @param options The signing domain, selector, instance, timestamp and chain-validation status.
|
|
122
|
+
* @returns The ARC-Seal header (without the `b=` value) and the data signed.
|
|
123
|
+
*/
|
|
124
|
+
declare const arcSealBase: (aarValue: string, amsValue: string, options: ArcSealOptions) => {
|
|
125
|
+
header: string;
|
|
126
|
+
signBase: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Seals a message with an ARC (Authenticated Received Chain, RFC 8617) header set for an originating
|
|
130
|
+
* sealer (instance `i=1`).
|
|
131
|
+
*
|
|
132
|
+
* Adds `ARC-Authentication-Results`, `ARC-Message-Signature`, and `ARC-Seal` headers. Use this when
|
|
133
|
+
* your service forwards mail and wants downstream receivers to trust the authentication results you
|
|
134
|
+
* observed. Supports RSA (default) and Ed25519 (`algorithm: "ed25519-sha256"`, RFC 8463) keys.
|
|
135
|
+
*
|
|
136
|
+
* IMPORTANT: the body hash (`bh=`) is computed over `text` + "\n\n" + `html` with relaxed
|
|
137
|
+
* canonicalization — the same simplification as the DKIM signer. For a third-party ARC verifier to
|
|
138
|
+
* accept the seal, the body actually transmitted on the wire must canonicalize to this same value, so
|
|
139
|
+
* apply ARC at the point where the MIME body is finalized (or feed in the exact rendered body).
|
|
140
|
+
* @param email The email to seal.
|
|
141
|
+
* @param options The seal options. See {@link ArcSealOptions}.
|
|
142
|
+
* @returns The email with the ARC header set added, and the raw {@link ArcHeaderSet}.
|
|
143
|
+
* @throws {Error} When the private key cannot be loaded or signing fails.
|
|
144
|
+
*/
|
|
145
|
+
declare const signArc: (email: EmailOptions, options: ArcSealOptions) => Promise<{
|
|
146
|
+
email: EmailOptions;
|
|
147
|
+
headers: ArcHeaderSet;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Verifies an originating (i=1) ARC header set against the signing domain's public key.
|
|
151
|
+
*
|
|
152
|
+
* Re-derives the AMS and ARC-Seal signing inputs from `email` + the supplied ARC headers, recomputes
|
|
153
|
+
* the body hash, and checks all three. The public key must be the one published for the seal's
|
|
154
|
+
* `s=`/`d=` (the DKIM-style `<selector>._domainkey.<domain>` TXT `p=` value).
|
|
155
|
+
* @param email The message that was sealed (same fields used when signing).
|
|
156
|
+
* @param headers The ARC header set (or any record containing the three `ARC-*` headers).
|
|
157
|
+
* @param options Verification options. See {@link ArcVerifyOptions}.
|
|
158
|
+
* @returns The verification result. See {@link ArcVerifyResult}.
|
|
159
|
+
*/
|
|
160
|
+
declare const verifyArc: (email: EmailOptions, headers: ArcHeaderSet | Record<string, string>, options: ArcVerifyOptions) => ArcVerifyResult;
|
|
161
|
+
/**
|
|
162
|
+
* DKIM signer implementation
|
|
163
|
+
*/
|
|
164
|
+
declare class DkimSigner implements EmailSigner {
|
|
165
|
+
/**
|
|
166
|
+
* Sanitizes a display name for use in quoted email headers per RFC 5322.
|
|
167
|
+
* Removes/replaces CR, LF, tabs with space, escapes backslashes and quotes,
|
|
168
|
+
* and strips non-printable control characters.
|
|
169
|
+
* @param name The display name to sanitize.
|
|
170
|
+
* @returns The sanitized display name, or empty string if nothing remains.
|
|
171
|
+
*/
|
|
172
|
+
private static sanitizeDisplayName;
|
|
173
|
+
/**
|
|
174
|
+
* Formats an email address for use in email headers.
|
|
175
|
+
* @param address The email address object to format.
|
|
176
|
+
* @param address.email The email address string.
|
|
177
|
+
* @param address.name Optional display name for the email address.
|
|
178
|
+
* @returns The formatted email address string in RFC 5322 format.
|
|
179
|
+
*/
|
|
180
|
+
private static formatAddress;
|
|
181
|
+
/**
|
|
182
|
+
* Formats email addresses for headers.
|
|
183
|
+
* @param addresses The email address(es) to format (single or array).
|
|
184
|
+
* @returns The formatted email addresses string (comma-separated if multiple).
|
|
185
|
+
*/
|
|
186
|
+
private static formatAddresses;
|
|
187
|
+
private readonly options;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a new DKIM signer.
|
|
190
|
+
* @param options DKIM signing options.
|
|
191
|
+
*/
|
|
192
|
+
constructor(options: DkimOptions);
|
|
193
|
+
/**
|
|
194
|
+
* Signs an email message with DKIM.
|
|
195
|
+
* @param email The email options to sign.
|
|
196
|
+
* @returns The email options with DKIM signature header added.
|
|
197
|
+
* @throws {Error} When signing fails (e.g., invalid private key).
|
|
198
|
+
*/
|
|
199
|
+
sign(email: EmailOptions): Promise<EmailOptions>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Creates a DKIM signer instance.
|
|
203
|
+
* @param options DKIM signing options.
|
|
204
|
+
* @returns A new DkimSigner instance.
|
|
205
|
+
*/
|
|
206
|
+
declare const createDkimSigner: (options: DkimOptions) => DkimSigner;
|
|
207
|
+
/**
|
|
208
|
+
* S/MIME encrypter implementation using PKIjs
|
|
209
|
+
* Note: Requires pkijs and asn1js for S/MIME operations
|
|
210
|
+
* Uses Node.js crypto for all cryptographic operations
|
|
211
|
+
*/
|
|
212
|
+
declare class SmimeEncrypter implements EmailEncrypter {
|
|
213
|
+
/**
|
|
214
|
+
* Collects and normalizes all recipients (to, cc, bcc) from email options.
|
|
215
|
+
* Normalizes each to an array, extracts email addresses, and deduplicates.
|
|
216
|
+
* @param email The email options containing recipients.
|
|
217
|
+
* @returns An array of unique email addresses (strings).
|
|
218
|
+
*/
|
|
219
|
+
private static collectRecipients;
|
|
220
|
+
/**
|
|
221
|
+
* Formats an email address for use in email headers.
|
|
222
|
+
* @param address The email address to format (string or EmailAddress object).
|
|
223
|
+
* @returns The formatted email address string in RFC 5322 format.
|
|
224
|
+
*/
|
|
225
|
+
private static formatAddress;
|
|
226
|
+
/**
|
|
227
|
+
* Formats email addresses for use in email headers.
|
|
228
|
+
* @param addresses The email addresses to format (single or array, string or EmailAddress objects).
|
|
229
|
+
* @returns The formatted email addresses string (comma-separated if multiple).
|
|
230
|
+
*/
|
|
231
|
+
private static formatAddresses;
|
|
232
|
+
private readonly options;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a new S/MIME encrypter.
|
|
235
|
+
* @param options S/MIME encryption options.
|
|
236
|
+
*/
|
|
237
|
+
constructor(options: SmimeEncryptOptions);
|
|
238
|
+
/**
|
|
239
|
+
* Encrypts an email message with S/MIME.
|
|
240
|
+
* @param email The email options to encrypt.
|
|
241
|
+
* @returns The encrypted email options.
|
|
242
|
+
* @throws {Error} When encryption fails (e.g., invalid certificate).
|
|
243
|
+
*/
|
|
244
|
+
encrypt(email: EmailOptions): Promise<EmailOptions>;
|
|
245
|
+
/**
|
|
246
|
+
* Builds the email message string from email options.
|
|
247
|
+
* @param email The email options to build the message from.
|
|
248
|
+
* @returns The formatted email message as a string.
|
|
249
|
+
*/
|
|
250
|
+
private buildMessage;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates a new S/MIME encrypter instance.
|
|
254
|
+
* @param options The S/MIME encryption options.
|
|
255
|
+
* @returns A new SmimeEncrypter instance ready to encrypt emails.
|
|
256
|
+
*/
|
|
257
|
+
declare const createSmimeEncrypter: (options: SmimeEncryptOptions) => SmimeEncrypter;
|
|
258
|
+
/**
|
|
259
|
+
* S/MIME signer implementation using PKIjs
|
|
260
|
+
* Note: Requires pkijs and asn1js for S/MIME operations
|
|
261
|
+
* Uses Node.js crypto for all cryptographic operations
|
|
262
|
+
*/
|
|
263
|
+
declare class SmimeSigner implements EmailSigner {
|
|
264
|
+
/**
|
|
265
|
+
* Formats an email address for use in email headers.
|
|
266
|
+
* @param address The email address object to format.
|
|
267
|
+
* @param address.email The email address string.
|
|
268
|
+
* @param address.name Optional display name for the email address.
|
|
269
|
+
* @returns The formatted email address string in RFC 5322 format.
|
|
270
|
+
*/
|
|
271
|
+
private static formatAddress;
|
|
272
|
+
private readonly options;
|
|
273
|
+
/**
|
|
274
|
+
* Creates a new S/MIME signer.
|
|
275
|
+
* @param options S/MIME signing options.
|
|
276
|
+
*/
|
|
277
|
+
constructor(options: SmimeSignOptions);
|
|
278
|
+
/**
|
|
279
|
+
* Signs an email message with S/MIME.
|
|
280
|
+
* @param email The email options to sign.
|
|
281
|
+
* @returns The email options with S/MIME signature.
|
|
282
|
+
* @throws {Error} When signing fails (e.g., invalid certificate/key).
|
|
283
|
+
*/
|
|
284
|
+
sign(email: EmailOptions): Promise<EmailOptions>;
|
|
285
|
+
/**
|
|
286
|
+
* Builds the email message string from email options.
|
|
287
|
+
* @param email The email options to build the message from.
|
|
288
|
+
* @returns The formatted email message as a string.
|
|
289
|
+
*/
|
|
290
|
+
private buildMessage;
|
|
291
|
+
/**
|
|
292
|
+
* Formats email addresses for use in email headers.
|
|
293
|
+
* @param addresses The email addresses to format (single or array).
|
|
294
|
+
* @returns The formatted email addresses string (comma-separated if multiple).
|
|
295
|
+
*/
|
|
296
|
+
private formatAddresses;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Creates a new S/MIME signer instance.
|
|
300
|
+
* @param options The S/MIME signing options.
|
|
301
|
+
* @returns A new SmimeSigner instance ready to sign emails.
|
|
302
|
+
*/
|
|
303
|
+
declare const createSmimeSigner: (options: SmimeSignOptions) => SmimeSigner;
|
|
304
|
+
export { type ArcAlgorithm, type ArcHeaderSet, type ArcSealOptions, type ArcVerifyOptions, type ArcVerifyResult, type DkimOptions, DkimSigner, type EmailEncrypter, type EmailSigner, type SmimeEncryptOptions, SmimeEncrypter, type SmimeSignOptions, SmimeSigner, arcMessageSignatureBase, arcSealBase, createDkimSigner, createSmimeEncrypter, createSmimeSigner, signArc, verifyArc };
|
package/dist/crypto/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{arcMessageSignatureBase as m,arcSealBase as i,signArc as a,verifyArc as t}from"../packem_shared/arcMessageSignatureBase-BY4j0TxM.js";import{DkimSigner as c,createDkimSigner as n}from"../packem_shared/DkimSigner-BuSbnos1.js";import{SmimeEncrypter as g,createSmimeEncrypter as p}from"../packem_shared/SmimeEncrypter-C7usORKF.js";import{SmimeSigner as s,createSmimeSigner as x}from"../packem_shared/SmimeSigner-DgAApLPS.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};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A DKIM/SPF auth result inside a DMARC aggregate record.
|
|
3
|
+
*/
|
|
4
|
+
interface DmarcAuthResult {
|
|
5
|
+
domain?: string;
|
|
6
|
+
result?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One `<record>` row of a DMARC aggregate report.
|
|
10
|
+
*/
|
|
11
|
+
interface DmarcRecordRow {
|
|
12
|
+
/**
|
|
13
|
+
* The per-mechanism auth results.
|
|
14
|
+
*/
|
|
15
|
+
authResults: {
|
|
16
|
+
dkim: DmarcAuthResult[];
|
|
17
|
+
spf: DmarcAuthResult[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Number of messages this row represents.
|
|
21
|
+
*/
|
|
22
|
+
count: number;
|
|
23
|
+
/**
|
|
24
|
+
* The policy disposition applied (`none` / `quarantine` / `reject`).
|
|
25
|
+
*/
|
|
26
|
+
disposition?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The DKIM alignment result (`pass` / `fail`).
|
|
29
|
+
*/
|
|
30
|
+
dkim?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The `From:` header domain.
|
|
33
|
+
*/
|
|
34
|
+
headerFrom?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The source IP that sent the messages.
|
|
37
|
+
*/
|
|
38
|
+
sourceIp?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The SPF alignment result (`pass` / `fail`).
|
|
41
|
+
*/
|
|
42
|
+
spf?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A parsed DMARC aggregate (RUA) report.
|
|
46
|
+
*/
|
|
47
|
+
interface DmarcAggregateReport {
|
|
48
|
+
/**
|
|
49
|
+
* Report window start (`date_range.begin`, unix seconds as a string).
|
|
50
|
+
*/
|
|
51
|
+
dateRangeBegin?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Report window end (`date_range.end`, unix seconds as a string).
|
|
54
|
+
*/
|
|
55
|
+
dateRangeEnd?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The reporter's contact email.
|
|
58
|
+
*/
|
|
59
|
+
email?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The reporting organization.
|
|
62
|
+
*/
|
|
63
|
+
organizationName?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The published policy the report was evaluated against.
|
|
66
|
+
*/
|
|
67
|
+
policyPublished?: {
|
|
68
|
+
adkim?: string;
|
|
69
|
+
aspf?: string;
|
|
70
|
+
domain?: string;
|
|
71
|
+
p?: string;
|
|
72
|
+
pct?: number;
|
|
73
|
+
sp?: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The per-source rows.
|
|
77
|
+
*/
|
|
78
|
+
records: DmarcRecordRow[];
|
|
79
|
+
/**
|
|
80
|
+
* The unique report id.
|
|
81
|
+
*/
|
|
82
|
+
reportId?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parses a DMARC aggregate (RUA) report XML document into a structured object.
|
|
86
|
+
*
|
|
87
|
+
* Reports arrive gzipped/zipped — decompress to the XML string first. `fast-xml-parser` is an optional
|
|
88
|
+
* peer dependency (`pnpm add fast-xml-parser`), loaded only via this `./deliverability/dmarc-report`
|
|
89
|
+
* entry point so the rest of the deliverability tooling stays dependency-free.
|
|
90
|
+
* @param xml The DMARC aggregate report XML.
|
|
91
|
+
* @returns The parsed report. See {@link DmarcAggregateReport}.
|
|
92
|
+
* @throws {EmailError} When `fast-xml-parser` is not installed or the XML cannot be parsed.
|
|
93
|
+
*/
|
|
94
|
+
declare const parseDmarcReport: (xml: string) => Promise<DmarcAggregateReport>;
|
|
95
|
+
export { type DmarcAggregateReport, type DmarcAuthResult, type DmarcRecordRow, parseDmarcReport };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import l from"../packem_shared/EmailError-B-sEf3bp.js";const g=a=>a==null?[]:Array.isArray(a)?a:[a],e=a=>{if(typeof a=="string")return a;if(typeof a=="number"||typeof a=="boolean")return String(a)},c=a=>{const r=e(a);if(r===void 0)return;const s=Number(r);return Number.isNaN(s)?void 0:s},f=a=>g(a).map(r=>({domain:e(r.domain),result:e(r.result)})),h=async a=>{let r;try{({XMLParser:r}=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 l("deliverability","fast-xml-parser is not installed. Please install it: pnpm add fast-xml-parser",{cause:t}):new l("deliverability",`Failed to load fast-xml-parser: ${t.message}`,{cause:t})}let s;try{s=new r({ignoreAttributes:!0,parseTagValue:!1}).parse(a)}catch(t){throw new l("deliverability",`Failed to parse DMARC report: ${t.message}`,{cause:t})}const n=s.feedback??{},o=n.report_metadata??{},m=o.date_range??{},i=n.policy_published??{},y=g(n.record).map(t=>{const d=t.row??{},p=d.policy_evaluated??{},b=t.identifiers??{},u=t.auth_results??{};return{authResults:{dkim:f(u.dkim),spf:f(u.spf)},count:c(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(i.adkim),aspf:e(i.aspf),domain:e(i.domain),p:e(i.p),pct:c(i.pct),sp:e(i.sp)},records:y,reportId:e(o.report_id)}};export{h as parseDmarcReport};
|