@visulima/email 1.0.0-alpha.34 → 1.0.0-alpha.35
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 +19 -0
- package/README.md +77 -0
- package/dist/crypto/index.d.ts +160 -3
- 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 +11 -734
- 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-A0nTVOo0.js +1 -0
- package/dist/packem_shared/DkimSigner-dKZ45Csc.js +18 -0
- package/dist/packem_shared/Mail-B2QII2P9.js +1 -0
- package/dist/packem_shared/{MailMessage-BvaH5tZZ.js → MailMessage-DB1zaWfM.js} +1 -1
- package/dist/packem_shared/MemoryEventStore-BEKPxa-I.js +1 -0
- package/dist/packem_shared/MemoryQueue-C-CtRRG7.js +1 -0
- package/dist/packem_shared/MemorySuppressionStore-BKY1FrA1.js +1 -0
- package/dist/packem_shared/RATE_LIMIT_PRESETS-DQF78mdO.js +1 -0
- package/dist/packem_shared/{SmimeEncrypter-ZhHEgDwY.js → SmimeEncrypter-BirIsrip.js} +2 -2
- package/dist/packem_shared/{SmimeSigner-CYSVF6ez.js → SmimeSigner-CkyaShTs.js} +2 -2
- package/dist/packem_shared/addDarkModeSupport-Ys9U2-GH.js +1 -0
- package/dist/packem_shared/address-formatter-CnPg51_n.js +1 -0
- package/dist/packem_shared/ahaSendProvider-yuqYMW0n.js +1 -0
- package/dist/packem_shared/arcMessageSignatureBase-Cpdnv-H8.js +17 -0
- package/dist/packem_shared/attachment-processor-CFUC3V45.js +1 -0
- package/dist/packem_shared/azureProvider-CK_Wuw4r.js +1 -0
- package/dist/packem_shared/brevoProvider-CNwuzzBA.js +1 -0
- package/dist/packem_shared/build-mime-message-D8WEZejb.js +3 -0
- package/dist/packem_shared/buildListUnsubscribe-CIbz0rtk.js +1 -0
- package/dist/packem_shared/circuitBreakerMiddleware-B7DlzZSG.js +1 -0
- package/dist/packem_shared/cloudflareEmailProvider-C-G821Hg.js +1 -0
- package/dist/packem_shared/composeMiddleware-CkEhbDjL.js +1 -0
- package/dist/packem_shared/createTestEmail-hHdtgmUM.js +1 -0
- package/dist/packem_shared/createWorker-Nkc1GHet.js +1 -0
- package/dist/packem_shared/dedupeMiddleware-JeJbff46.js +1 -0
- package/dist/packem_shared/{detectMimeType-bo5oxfnt.js → detectMimeType-B4QMh7k8.js} +1 -1
- package/dist/packem_shared/emailMatchers-CLANeU71.js +1 -0
- package/dist/packem_shared/event-bus.d-DEl3w_EW.d.ts +104 -0
- package/dist/packem_shared/extractReply-CCWnNRWe.js +5 -0
- package/dist/packem_shared/filterSuppressed-DntqRV0q.js +1 -0
- package/dist/packem_shared/format-address-Cv6uWTS5.js +1 -0
- package/dist/packem_shared/infobipProvider-DdV62IAG.js +1 -0
- package/dist/packem_shared/injectPreheader-BxPjb0eJ.js +1 -0
- package/dist/packem_shared/inlineCss-BLaEi337.js +1 -0
- package/dist/packem_shared/isValidSigningCertUrl-CF_KuCAi.js +3 -0
- package/dist/packem_shared/loggingMiddleware-CyHzn37U.js +1 -0
- package/dist/packem_shared/loopsProvider-DSedSU3q.js +1 -0
- package/dist/packem_shared/mail.d-LmrdSngG.d.ts +861 -0
- package/dist/packem_shared/{mailCrabProvider-B7H6HwWu.js → mailCrabProvider-xSLhA1CY.js} +1 -1
- package/dist/packem_shared/mailPaceProvider-CWBIjvvJ.js +1 -0
- package/dist/packem_shared/mailchannelsProvider-zKcunGDQ.js +1 -0
- package/dist/packem_shared/mailerSendProvider-BEvPlBKB.js +1 -0
- package/dist/packem_shared/mailgunProvider-CfQAINTC.js +1 -0
- package/dist/packem_shared/mailjetProvider-DEfKptWc.js +1 -0
- package/dist/packem_shared/mailomatProvider-D5sHlxZh.js +1 -0
- package/dist/packem_shared/mailtrapProvider-DwgMKakk.js +1 -0
- package/dist/packem_shared/mandrillProvider-CdGjO3Td.js +1 -0
- package/dist/packem_shared/normalizeMessageId-B_9mXlh4.js +1 -0
- package/dist/packem_shared/oauth2Middleware-B1xz58iP.js +1 -0
- package/dist/packem_shared/parseAddress-CrYOac3K.js +1 -0
- package/dist/packem_shared/parseArfReport-CUHb8WVj.js +6 -0
- package/dist/packem_shared/parseCloudflareInbound-BGgH5u7M.js +1 -0
- package/dist/packem_shared/parseDmarcRecord-DjNqCMZc.js +1 -0
- package/dist/packem_shared/parseInbound-BP-gEjhh.js +1 -0
- package/dist/packem_shared/parseMailgunInbound-C3sZ1TiH.js +1 -0
- package/dist/packem_shared/parseMtaStsPolicy-rFOOVXXK.js +6 -0
- package/dist/packem_shared/parsePostmarkInbound-C0Ttfroo.js +1 -0
- package/dist/packem_shared/parseSendGridInbound-BkvaoYRl.js +4 -0
- package/dist/packem_shared/parseSesInbound-BFS--T8X.js +1 -0
- package/dist/packem_shared/parseTlsRptRecord-DnLwAWsk.js +1 -0
- package/dist/packem_shared/plunkProvider-BIhMU2b5.js +1 -0
- package/dist/packem_shared/postProcessHtml-C73e0b9H.js +1 -0
- package/dist/packem_shared/postalProvider-CmmbCZSi.js +1 -0
- package/dist/packem_shared/postmarkProvider-i9u0h26U.js +1 -0
- package/dist/packem_shared/provider-base-BpHE_uK8.js +1 -0
- package/dist/packem_shared/{provider.d-DcfYeGJJ.d.ts → provider.d-J-y6iogK.d.ts} +1 -1
- package/dist/packem_shared/{readFile-BAVMZg5e-C4whBIPd.js → readFile-BkNfutxp-BS8Q2183.js} +1 -1
- package/dist/packem_shared/resendProvider-BNduBn0w.js +1 -0
- package/dist/packem_shared/retry-UPd8F62N.js +1 -0
- package/dist/packem_shared/retryMiddleware-DHespsU2.js +1 -0
- package/dist/packem_shared/rewriteCidLinks-B-Sd5XHs.js +1 -0
- package/dist/packem_shared/scalewayProvider-8gb4sIOB.js +1 -0
- package/dist/packem_shared/sendGridProvider-CayLXvPO.js +1 -0
- package/dist/packem_shared/smtpProvider-DoXVsN4p.js +24 -0
- package/dist/packem_shared/sweegoProvider-C0g9Ajdn.js +1 -0
- package/dist/packem_shared/toEmailSnapshot-CYpMmnAA.js +1 -0
- package/dist/packem_shared/tracer.d-MU42G1jG.d.ts +494 -0
- package/dist/packem_shared/{types.d-CNnnk-Ya.d.ts → types.d-BId55FW2.d.ts} +6 -1
- package/dist/packem_shared/types.d-BMpI2UXj.d.ts +51 -0
- package/dist/packem_shared/types.d-CmoWvdZi.d.ts +61 -0
- package/dist/packem_shared/types.d-Mpu0HZoG.d.ts +24 -0
- package/dist/packem_shared/{types.d-wwpgA3to.d.ts → types.d-ejzh-xBP.d.ts} +6 -1
- package/dist/packem_shared/types.d-lcJZmwRK.d.ts +69 -0
- package/dist/packem_shared/utils-BwolsGlK.js +1 -0
- package/dist/packem_shared/verifyMailgunWebhook-Df7n2Quh.js +1 -0
- package/dist/packem_shared/verifyPostmarkWebhook-D_eXt_Lq.js +1 -0
- package/dist/packem_shared/verifySendGridWebhook-XOSj5yTe.js +1 -0
- package/dist/packem_shared/verifyStandardWebhook-DdUTlIVh.js +1 -0
- package/dist/packem_shared/withEvents-Q9bwpCFG.js +1 -0
- package/dist/packem_shared/withMetrics-BPs3Kdxn.js +1 -0
- package/dist/packem_shared/withRender-DQM2zbbI.js +1 -0
- package/dist/packem_shared/withSuppression-DfjV_tbI.js +1 -0
- package/dist/packem_shared/withTelemetry-CsQsv1DV.js +1 -0
- package/dist/packem_shared/zeptomailProvider-BIbHieGJ.js +1 -0
- package/dist/providers/ahasend/index.d.ts +3 -3
- package/dist/providers/ahasend/index.js +1 -1
- package/dist/providers/aws-ses/index.d.ts +3 -3
- package/dist/providers/azure/index.d.ts +3 -3
- package/dist/providers/azure/index.js +1 -1
- package/dist/providers/brevo/index.d.ts +3 -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 +3 -3
- package/dist/providers/http/index.d.ts +3 -3
- package/dist/providers/infobip/index.d.ts +3 -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 +3 -3
- package/dist/providers/mailcrab/index.js +1 -1
- package/dist/providers/mailersend/index.d.ts +3 -3
- package/dist/providers/mailersend/index.js +1 -1
- package/dist/providers/mailgun/index.d.ts +3 -3
- package/dist/providers/mailgun/index.js +1 -1
- package/dist/providers/mailjet/index.d.ts +3 -3
- package/dist/providers/mailjet/index.js +1 -1
- package/dist/providers/mailomat/index.d.ts +3 -3
- package/dist/providers/mailomat/index.js +1 -1
- package/dist/providers/mailpace/index.d.ts +3 -3
- package/dist/providers/mailpace/index.js +1 -1
- package/dist/providers/mailtrap/index.d.ts +3 -3
- package/dist/providers/mailtrap/index.js +1 -1
- package/dist/providers/mandrill/index.d.ts +3 -3
- package/dist/providers/mandrill/index.js +1 -1
- package/dist/providers/mock/index.d.ts +6 -53
- package/dist/providers/nodemailer/index.d.ts +3 -3
- package/dist/providers/opentelemetry/index.d.ts +3 -495
- package/dist/providers/plunk/index.d.ts +3 -3
- package/dist/providers/plunk/index.js +1 -1
- package/dist/providers/postal/index.d.ts +3 -3
- package/dist/providers/postal/index.js +1 -1
- package/dist/providers/postmark/index.d.ts +3 -3
- package/dist/providers/postmark/index.js +1 -1
- package/dist/providers/resend/index.d.ts +3 -3
- package/dist/providers/resend/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +3 -3
- package/dist/providers/scaleway/index.d.ts +3 -3
- package/dist/providers/scaleway/index.js +1 -1
- package/dist/providers/sendgrid/index.d.ts +3 -3
- package/dist/providers/sendgrid/index.js +1 -1
- package/dist/providers/smtp/index.d.ts +3 -3
- package/dist/providers/smtp/index.js +1 -1
- package/dist/providers/sweego/index.d.ts +3 -3
- package/dist/providers/sweego/index.js +1 -1
- package/dist/providers/zeptomail/index.d.ts +3 -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 +148 -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 +81 -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/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/test/index.d.ts +159 -0
- package/dist/test/index.js +1 -0
- package/dist/utils/format-email-address.d.ts +1 -1
- package/dist/utils/format-email-address.js +1 -1
- package/dist/utils/parse-address.d.ts +1 -1
- package/dist/utils/result.d.ts +49 -0
- package/dist/utils/result.js +1 -0
- package/dist/utils/validation/check-feature-support.d.ts +1 -1
- package/dist/webhooks/index.d.ts +231 -0
- package/dist/webhooks/index.js +1 -0
- package/package.json +115 -3
- package/dist/packem_shared/DkimSigner-CT2DSHD1.js +0 -18
- package/dist/packem_shared/Mail-BWSWWq6m.js +0 -1
- package/dist/packem_shared/address-formatter-Cm_E_ZMa.js +0 -1
- package/dist/packem_shared/ahaSendProvider-DOAAW65O.js +0 -1
- package/dist/packem_shared/attachment-processor-DsmIomKc.js +0 -1
- package/dist/packem_shared/azureProvider-EkNYKAiF.js +0 -1
- package/dist/packem_shared/brevoProvider-CkR4U4RD.js +0 -1
- package/dist/packem_shared/build-mime-message-6xstxaUV.js +0 -2
- package/dist/packem_shared/infobipProvider-BhTsWi7e.js +0 -1
- package/dist/packem_shared/mailPaceProvider-DRt6Z9Hr.js +0 -1
- package/dist/packem_shared/mailerSendProvider-Dx_iHInH.js +0 -1
- package/dist/packem_shared/mailgunProvider-ChkLGZZW.js +0 -1
- package/dist/packem_shared/mailjetProvider-BMRhNe6H.js +0 -1
- package/dist/packem_shared/mailomatProvider-CydV-JB6.js +0 -1
- package/dist/packem_shared/mailtrapProvider-CuAfJWDr.js +0 -1
- package/dist/packem_shared/mandrillProvider-BBeLbaw0.js +0 -1
- package/dist/packem_shared/plunkProvider-BQyjG6YT.js +0 -1
- package/dist/packem_shared/postalProvider-DPHQ620q.js +0 -1
- package/dist/packem_shared/postmarkProvider-bMTC2gdJ.js +0 -1
- package/dist/packem_shared/provider-base-Cmzx6BTO.js +0 -1
- package/dist/packem_shared/resendProvider-Cns1tvF5.js +0 -1
- package/dist/packem_shared/scalewayProvider-O1dHz7iJ.js +0 -1
- package/dist/packem_shared/sendGridProvider-DmywC-eT.js +0 -1
- package/dist/packem_shared/smtpProvider-Unjao_fn.js +0 -23
- package/dist/packem_shared/sweegoProvider-D086G6xG.js +0 -1
- package/dist/packem_shared/zeptomailProvider-DKKEpEsW.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## @visulima/email [1.0.0-alpha.35](https://github.com/visulima/visulima/compare/@visulima/email@1.0.0-alpha.34...@visulima/email@1.0.0-alpha.35) (2026-06-04)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **email:** inbound, webhooks, deliverability, middleware, queue, events, testing + ARC/i18n/batch ([#671](https://github.com/visulima/visulima/issues/671)) ([2ca23f2](https://github.com/visulima/visulima/commit/2ca23f27ecc5064d693c16bd3f44ccaeaf050888))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **email:** 5 bug fixes ([4e87c42](https://github.com/visulima/visulima/commit/4e87c429a56d68d7a0a09325484ed299ffe6493c))
|
|
10
|
+
* **lint:** clear pre-existing eslint rot across packages ([#674](https://github.com/visulima/visulima/issues/674)) ([5354253](https://github.com/visulima/visulima/commit/5354253b163bd50bcefaf8a3fddf831bdb5df32b))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* **@visulima/disposable-email-domains:** upgraded to 1.0.0-alpha.16
|
|
16
|
+
* **@visulima/error:** upgraded to 6.0.0-alpha.32
|
|
17
|
+
* **@visulima/fs:** upgraded to 5.0.0-alpha.30
|
|
18
|
+
* **@visulima/path:** upgraded to 3.0.0-alpha.12
|
|
19
|
+
|
|
1
20
|
## @visulima/email [1.0.0-alpha.34](https://github.com/visulima/visulima/compare/@visulima/email@1.0.0-alpha.33...@visulima/email@1.0.0-alpha.34) (2026-06-02)
|
|
2
21
|
|
|
3
22
|
### Features
|
package/README.md
CHANGED
|
@@ -1416,6 +1416,83 @@ normalizeEmailAliases("user+tag@gmx.com"); // "user@gmx.com"
|
|
|
1416
1416
|
normalizeEmailAliases("user@example.com"); // "user@example.com"
|
|
1417
1417
|
```
|
|
1418
1418
|
|
|
1419
|
+
## Batch Sending & Result Helpers
|
|
1420
|
+
|
|
1421
|
+
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.
|
|
1422
|
+
|
|
1423
|
+
```typescript
|
|
1424
|
+
import { createMail, isOk, unwrapOr } from "@visulima/email";
|
|
1425
|
+
|
|
1426
|
+
const mail = createMail(provider);
|
|
1427
|
+
|
|
1428
|
+
for await (const receipt of mail.sendBatch(
|
|
1429
|
+
{ from: { email: "news@example.com" }, subject: "Hi {{name}}", html: "<p>Hello {{name}}</p>" },
|
|
1430
|
+
[{ to: { email: "a@example.com" }, data: { name: "Ada" } }],
|
|
1431
|
+
{ render: (template, data) => renderHandlebars(template, data) },
|
|
1432
|
+
)) {
|
|
1433
|
+
if (receipt.successful) console.log("sent", receipt.messageId);
|
|
1434
|
+
}
|
|
1435
|
+
```
|
|
1436
|
+
|
|
1437
|
+
See [Sending Mail](https://visulima.com/docs/package/email/getting-started/sending-mail).
|
|
1438
|
+
|
|
1439
|
+
## Middleware
|
|
1440
|
+
|
|
1441
|
+
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.
|
|
1442
|
+
|
|
1443
|
+
```typescript
|
|
1444
|
+
import { createMail } from "@visulima/email";
|
|
1445
|
+
import { circuitBreakerMiddleware, RATE_LIMIT_PRESETS, rateLimitMiddleware, retryMiddleware } from "@visulima/email/middleware";
|
|
1446
|
+
|
|
1447
|
+
const mail = createMail(provider)
|
|
1448
|
+
.use(rateLimitMiddleware({ rate: RATE_LIMIT_PRESETS.resend }))
|
|
1449
|
+
.use(circuitBreakerMiddleware())
|
|
1450
|
+
.use(retryMiddleware({ retries: 3 }));
|
|
1451
|
+
```
|
|
1452
|
+
|
|
1453
|
+
See [Middleware](https://visulima.com/docs/package/email/middleware/introduction).
|
|
1454
|
+
|
|
1455
|
+
## Queue & Worker
|
|
1456
|
+
|
|
1457
|
+
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.
|
|
1458
|
+
|
|
1459
|
+
```typescript
|
|
1460
|
+
import { createMail } from "@visulima/email";
|
|
1461
|
+
import { createWorker, MemoryQueue } from "@visulima/email/queue";
|
|
1462
|
+
|
|
1463
|
+
const queue = new MemoryQueue();
|
|
1464
|
+
const mail = createMail(provider);
|
|
1465
|
+
|
|
1466
|
+
await queue.enqueue({ from: { email: "a@x.com" }, to: { email: "b@x.com" }, subject: "Hi", text: "yo" });
|
|
1467
|
+
createWorker({ queue, send: mail.send.bind(mail), concurrency: 5 }).start();
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
See [Queue](https://visulima.com/docs/package/email/queue/introduction).
|
|
1471
|
+
|
|
1472
|
+
## Webhook Verification
|
|
1473
|
+
|
|
1474
|
+
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.
|
|
1475
|
+
|
|
1476
|
+
See [Webhooks](https://visulima.com/docs/package/email/webhooks/introduction).
|
|
1477
|
+
|
|
1478
|
+
## Inbound Parsing
|
|
1479
|
+
|
|
1480
|
+
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()`.
|
|
1481
|
+
|
|
1482
|
+
See [Inbound](https://visulima.com/docs/package/email/inbound/introduction).
|
|
1483
|
+
|
|
1484
|
+
## Deliverability
|
|
1485
|
+
|
|
1486
|
+
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`.
|
|
1487
|
+
|
|
1488
|
+
See [Deliverability](https://visulima.com/docs/package/email/deliverability/introduction).
|
|
1489
|
+
|
|
1490
|
+
## Events & Testing
|
|
1491
|
+
|
|
1492
|
+
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`.
|
|
1493
|
+
|
|
1494
|
+
See [Events](https://visulima.com/docs/package/email/events/introduction) and [Testing](https://visulima.com/docs/package/email/testing/introduction).
|
|
1495
|
+
|
|
1419
1496
|
## Related
|
|
1420
1497
|
|
|
1421
1498
|
## Supported Node.js Versions
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,7 +1,164 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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";
|
|
3
4
|
import 'node:buffer';
|
|
4
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
|
+
/**
|
|
5
162
|
* DKIM signer implementation
|
|
6
163
|
*/
|
|
7
164
|
declare class DkimSigner implements EmailSigner {
|
|
@@ -144,4 +301,4 @@ declare class SmimeSigner implements EmailSigner {
|
|
|
144
301
|
* @returns A new SmimeSigner instance ready to sign emails.
|
|
145
302
|
*/
|
|
146
303
|
declare const createSmimeSigner: (options: SmimeSignOptions) => SmimeSigner;
|
|
147
|
-
export { type DkimOptions, DkimSigner, type EmailEncrypter, type EmailSigner, type SmimeEncryptOptions, SmimeEncrypter, type SmimeSignOptions, SmimeSigner, createDkimSigner, createSmimeEncrypter, createSmimeSigner };
|
|
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-Cpdnv-H8.js";import{DkimSigner as c,createDkimSigner as n}from"../packem_shared/DkimSigner-dKZ45Csc.js";import{SmimeEncrypter as g,createSmimeEncrypter as p}from"../packem_shared/SmimeEncrypter-BirIsrip.js";import{SmimeSigner as s,createSmimeSigner as x}from"../packem_shared/SmimeSigner-CkyaShTs.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
|
+
var R=Object.defineProperty;var f=(e,t)=>R(e,"name",{value:t,configurable:!0});import m from"../packem_shared/EmailError-zm2ffVav.js";var v=Object.defineProperty,o=f((e,t)=>v(e,"name",{value:t,configurable:!0}),"a");const b=o(e=>e==null?[]:Array.isArray(e)?e:[e],"toArray"),r=o(e=>{if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)},"asString"),g=o(e=>{const t=r(e);if(t===void 0)return;const i=Number(t);return Number.isNaN(i)?void 0:i},"asNumber"),y=o(e=>b(e).map(t=>({domain:r(t.domain),result:r(t.result)})),"toAuthResults"),k=o(async e=>{let t;try{({XMLParser:t}=await import("fast-xml-parser"))}catch(a){throw a instanceof Error&&(a.code==="ERR_MODULE_NOT_FOUND"||a.message.includes("Cannot find module")||a.message.includes("Cannot find package"))?new m("deliverability","fast-xml-parser is not installed. Please install it: pnpm add fast-xml-parser",{cause:a}):new m("deliverability",`Failed to load fast-xml-parser: ${a.message}`,{cause:a})}let i;try{i=new t({ignoreAttributes:!0,parseTagValue:!1}).parse(e)}catch(a){throw new m("deliverability",`Failed to parse DMARC report: ${a.message}`,{cause:a})}const d=i.feedback??{},n=d.report_metadata??{},u=n.date_range??{},s=d.policy_published??{},h=b(d.record).map(a=>{const p=a.row??{},l=p.policy_evaluated??{},_=a.identifiers??{},c=a.auth_results??{};return{authResults:{dkim:y(c.dkim),spf:y(c.spf)},count:g(p.count)??0,disposition:r(l.disposition),dkim:r(l.dkim),headerFrom:r(_.header_from),sourceIp:r(p.source_ip),spf:r(l.spf)}});return{dateRangeBegin:r(u.begin),dateRangeEnd:r(u.end),email:r(n.email),organizationName:r(n.org_name),policyPublished:{adkim:r(s.adkim),aspf:r(s.aspf),domain:r(s.domain),p:r(s.p),pct:g(s.pct),sp:r(s.sp)},records:h,reportId:r(n.report_id)}},"parseDmarcReport");export{k as parseDmarcReport};
|