@lunora/mail 1.0.0-alpha.7 → 1.0.0-alpha.71
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/LICENSE.md +6 -0
- package/dist/inbound/index.d.mts +322 -78
- package/dist/inbound/index.d.ts +322 -78
- package/dist/inbound/index.mjs +1 -2
- package/dist/index.d.mts +122 -94
- package/dist/index.d.ts +122 -94
- package/dist/index.mjs +1 -7
- package/dist/packem_shared/address-soPj2Z0j.mjs +3 -0
- package/dist/packem_shared/authenticatesFrom-xpKAFMRN.mjs +1 -0
- package/dist/packem_shared/capture-transport.d-BD67fxbB.d.mts +130 -0
- package/dist/packem_shared/capture-transport.d-BD67fxbB.d.ts +130 -0
- package/dist/packem_shared/consumeQueuedSend-CRfALnCU.mjs +1 -0
- package/dist/packem_shared/createCaptureSink-CeV0DSsT.mjs +1 -0
- package/dist/packem_shared/createCaptureTransport-CKc6NpZR.mjs +1 -0
- package/dist/packem_shared/createCloudflareTransport-DpfCxn16.mjs +1 -0
- package/dist/packem_shared/createInboundEmailHandler-Bh10YPyJ.mjs +1 -0
- package/dist/packem_shared/createMailer-CjQmT7Ln.mjs +1 -0
- package/dist/packem_shared/createResendTransport-DDkOitck.mjs +1 -0
- package/dist/packem_shared/provider-transport-CR4w-R0A.mjs +1 -0
- package/dist/packem_shared/renderEmail-BOUnr6i3.mjs +1 -0
- package/dist/packem_shared/shard-CRhAKK93.mjs +1 -0
- package/dist/packem_shared/shard.d-DVADjmEJ.d.mts +29 -0
- package/dist/packem_shared/shard.d-DVADjmEJ.d.ts +29 -0
- package/dist/testing.d.mts +9 -9
- package/dist/testing.d.ts +9 -9
- package/dist/testing.mjs +1 -63
- package/package.json +5 -5
- package/dist/packem_shared/address-vSUAVU2T.mjs +0 -64
- package/dist/packem_shared/capture-transport.d-ChnhdPO2.d.mts +0 -117
- package/dist/packem_shared/capture-transport.d-ChnhdPO2.d.ts +0 -117
- package/dist/packem_shared/consumeQueuedSend-B9hTDOZ6.mjs +0 -77
- package/dist/packem_shared/createCaptureSink-Di-5AJUs.mjs +0 -65
- package/dist/packem_shared/createCaptureTransport-Crz_8822.mjs +0 -11
- package/dist/packem_shared/createCloudflareTransport-DXh1nUNi.mjs +0 -28
- package/dist/packem_shared/createInboundEmailHandler-BW_s0-Vc.mjs +0 -84
- package/dist/packem_shared/createMailer-B4Z_Cgiu.mjs +0 -81
- package/dist/packem_shared/createResendTransport-CMQWjZoi.mjs +0 -16
- package/dist/packem_shared/parseInboundEmail-6lafQBT1.mjs +0 -72
- package/dist/packem_shared/provider-transport-C0xHi3oy.mjs +0 -48
- package/dist/packem_shared/renderEmail-hyS1bpVP.mjs +0 -8
- package/dist/packem_shared/shard-CJ-TvmfT.mjs +0 -13
- package/dist/packem_shared/shard.d-CL2Lmliv.d.mts +0 -39
- package/dist/packem_shared/shard.d-CL2Lmliv.d.ts +0 -39
package/dist/index.d.mts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { M as MailTransport, L as LunoraMailOptions, a as Mailer, b as MailboxSink, S as SendOptions } from "./packem_shared/capture-transport.d-
|
|
2
|
-
export { type C as CapturedMail, type Q as QueueLike, type c as SendPayload, d as createCaptureTransport } from "./packem_shared/capture-transport.d-
|
|
3
|
-
import { D as DurableObjectJurisdiction } from "./packem_shared/shard.d-
|
|
1
|
+
import { M as MailTransport, L as LunoraMailOptions, a as Mailer, b as MailboxSink, S as SendOptions } from "./packem_shared/capture-transport.d-BD67fxbB.mjs";
|
|
2
|
+
export { type C as CapturedMail, type Q as QueueLike, type c as SendPayload, d as createCaptureTransport } from "./packem_shared/capture-transport.d-BD67fxbB.mjs";
|
|
3
|
+
import { D as DurableObjectJurisdiction } from "./packem_shared/shard.d-DVADjmEJ.mjs";
|
|
4
4
|
import { ReactElement } from 'react';
|
|
5
5
|
/**
|
|
6
|
-
* Sends a raw RFC 822 message through a Worker's Email send binding. The Workers
|
|
7
|
-
* runtime owns the binding, so the caller supplies this thin callback — keeping
|
|
8
|
-
* `@lunora/mail` free of a `cloudflare:email` import and unit-testable. Wire it
|
|
9
|
-
* in your project as:
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* send: async (from, to, raw) => {
|
|
13
|
-
* const { EmailMessage } = await import("cloudflare:email");
|
|
14
|
-
* await env.SEND_EMAIL.send(new EmailMessage(from, to, raw));
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
6
|
+
* Sends a raw RFC 822 message through a Worker's Email send binding. The Workers
|
|
7
|
+
* runtime owns the binding, so the caller supplies this thin callback — keeping
|
|
8
|
+
* `@lunora/mail` free of a `cloudflare:email` import and unit-testable. Wire it
|
|
9
|
+
* in your project as:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* send: async (from, to, raw) => {
|
|
13
|
+
* const { EmailMessage } = await import("cloudflare:email");
|
|
14
|
+
* await env.SEND_EMAIL.send(new EmailMessage(from, to, raw));
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
18
|
type CloudflareSend = (from: string, to: string, raw: string) => Promise<void>;
|
|
19
19
|
interface CloudflareTransportOptions {
|
|
20
20
|
/** Default sender used when a `SendOptions.from` isn't supplied. */
|
|
@@ -23,34 +23,34 @@ interface CloudflareTransportOptions {
|
|
|
23
23
|
send: CloudflareSend;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Build the default Cloudflare Email Workers transport via `@visulima/email`.
|
|
27
|
-
* Cloudflare's `send_email` binding is **single-recipient** and only delivers to
|
|
28
|
-
* **verified Email Routing destination addresses**, and the underlying provider
|
|
29
|
-
* rejects any `cc`/`bcc` or a non-single `to` outright. So this enforces a single
|
|
30
|
-
* `to` recipient (throwing a clear error instead of silently dropping the rest)
|
|
31
|
-
* and rejects `cc`/`bcc` rather than forwarding them into a generic "send failed".
|
|
32
|
-
* Multi-recipient transactional mail must fan out one send per recipient at the
|
|
33
|
-
* call site. In dev the capture transport intercepts before this runs, so the
|
|
34
|
-
* verified-address constraint never bites the dev loop.
|
|
35
|
-
*/
|
|
26
|
+
* Build the default Cloudflare Email Workers transport via `@visulima/email`.
|
|
27
|
+
* Cloudflare's `send_email` binding is **single-recipient** and only delivers to
|
|
28
|
+
* **verified Email Routing destination addresses**, and the underlying provider
|
|
29
|
+
* rejects any `cc`/`bcc` or a non-single `to` outright. So this enforces a single
|
|
30
|
+
* `to` recipient (throwing a clear error instead of silently dropping the rest)
|
|
31
|
+
* and rejects `cc`/`bcc` rather than forwarding them into a generic "send failed".
|
|
32
|
+
* Multi-recipient transactional mail must fan out one send per recipient at the
|
|
33
|
+
* call site. In dev the capture transport intercepts before this runs, so the
|
|
34
|
+
* verified-address constraint never bites the dev loop.
|
|
35
|
+
*/
|
|
36
36
|
declare const createCloudflareTransport: (options: CloudflareTransportOptions) => MailTransport;
|
|
37
37
|
/**
|
|
38
|
-
* Create a mailer bound to a transport.
|
|
39
|
-
*
|
|
40
|
-
* SECURITY — recipient policy and HTML content are the caller's responsibility.
|
|
41
|
-
* The mailer fully blocks header/CRLF/comma injection in addresses
|
|
42
|
-
* (`assertSafeAddresses` / `assertSafeHeaderValue`), but it does NOT decide WHO
|
|
43
|
-
* you may send to or WHAT HTML you render.
|
|
44
|
-
*
|
|
45
|
-
* Open relay: derive `to`/`cc`/`bcc` from server-trusted state, never from raw
|
|
46
|
-
* request input, and prefer a fixed/allowlisted `from` — sending to an arbitrary
|
|
47
|
-
* user-supplied address turns your deployment into a spam relay.
|
|
48
|
-
*
|
|
49
|
-
* Template XSS / content injection: treat template HTML like any other HTML sink
|
|
50
|
-
* — never interpolate untrusted data into raw markup (or a
|
|
51
|
-
* `dangerouslySetInnerHTML`-style template) without escaping. The mailer sends
|
|
52
|
-
* whatever HTML you hand it verbatim.
|
|
53
|
-
*/
|
|
38
|
+
* Create a mailer bound to a transport.
|
|
39
|
+
*
|
|
40
|
+
* SECURITY — recipient policy and HTML content are the caller's responsibility.
|
|
41
|
+
* The mailer fully blocks header/CRLF/comma injection in addresses
|
|
42
|
+
* (`assertSafeAddresses` / `assertSafeHeaderValue`), but it does NOT decide WHO
|
|
43
|
+
* you may send to or WHAT HTML you render.
|
|
44
|
+
*
|
|
45
|
+
* Open relay: derive `to`/`cc`/`bcc` from server-trusted state, never from raw
|
|
46
|
+
* request input, and prefer a fixed/allowlisted `from` — sending to an arbitrary
|
|
47
|
+
* user-supplied address turns your deployment into a spam relay.
|
|
48
|
+
*
|
|
49
|
+
* Template XSS / content injection: treat template HTML like any other HTML sink
|
|
50
|
+
* — never interpolate untrusted data into raw markup (or a
|
|
51
|
+
* `dangerouslySetInnerHTML`-style template) without escaping. The mailer sends
|
|
52
|
+
* whatever HTML you hand it verbatim.
|
|
53
|
+
*/
|
|
54
54
|
declare const createMailer: (options: LunoraMailOptions) => Mailer;
|
|
55
55
|
/** A Worker `env` projected as a plain record (vars, secrets, and bindings are `unknown`-valued). */
|
|
56
56
|
type MailEnv = Record<string, unknown>;
|
|
@@ -59,39 +59,39 @@ interface FromEnvOptions {
|
|
|
59
59
|
/** RFC 822 send callback bound to the Worker's `send_email` binding (Cloudflare default transport). */
|
|
60
60
|
cloudflareSend?: CloudflareSend;
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
* Pin the captured-mail inbox shard to a Cloudflare data-residency
|
|
63
|
+
* jurisdiction. Pass the same value as the worker's `jurisdiction` so the
|
|
64
|
+
* dev inbox co-resides with app data. Omit for the un-pinned global namespace.
|
|
65
|
+
*/
|
|
66
66
|
jurisdiction?: DurableObjectJurisdiction;
|
|
67
67
|
/** Shard the captured-mail inbox lives on; override if your worker sets a custom `defaultShardKey`. */
|
|
68
68
|
rootShard?: string;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Whether outbound mail should be captured (into the studio inbox) rather than
|
|
72
|
-
* delivered. Explicit `LUNORA_MAIL_CAPTURE` (`"1"`/`"true"` vs `"0"`/`"false"`)
|
|
73
|
-
* always wins; unset, capture is on only in a development environment. It does
|
|
74
|
-
* NOT fall back to "no SEND_EMAIL binding ⇒ capture" — a production deploy that
|
|
75
|
-
* forgot the binding must fail loudly on send, not silently swallow mail.
|
|
76
|
-
*/
|
|
71
|
+
* Whether outbound mail should be captured (into the studio inbox) rather than
|
|
72
|
+
* delivered. Explicit `LUNORA_MAIL_CAPTURE` (`"1"`/`"true"` vs `"0"`/`"false"`)
|
|
73
|
+
* always wins; unset, capture is on only in a development environment. It does
|
|
74
|
+
* NOT fall back to "no SEND_EMAIL binding ⇒ capture" — a production deploy that
|
|
75
|
+
* forgot the binding must fail loudly on send, not silently swallow mail.
|
|
76
|
+
*/
|
|
77
77
|
declare const shouldCaptureMail: (env: MailEnv) => boolean;
|
|
78
78
|
/**
|
|
79
|
-
* Build the {@link MailboxSink} that records a captured message into the studio's
|
|
80
|
-
* root-shard inbox via the reserved `recordMail` admin RPC — the same
|
|
81
|
-
* worker→root-shard path the runtime uses for auth events. Best-effort: without
|
|
82
|
-
* the `SHARD` binding or `LUNORA_ADMIN_TOKEN` it returns a sentinel id so a send
|
|
83
|
-
* never fails for lack of somewhere to record.
|
|
84
|
-
*/
|
|
79
|
+
* Build the {@link MailboxSink} that records a captured message into the studio's
|
|
80
|
+
* root-shard inbox via the reserved `recordMail` admin RPC — the same
|
|
81
|
+
* worker→root-shard path the runtime uses for auth events. Best-effort: without
|
|
82
|
+
* the `SHARD` binding or `LUNORA_ADMIN_TOKEN` it returns a sentinel id so a send
|
|
83
|
+
* never fails for lack of somewhere to record — but it says so first (see below).
|
|
84
|
+
*/
|
|
85
85
|
declare const createCaptureSink: (env: MailEnv, rootShard?: string, jurisdiction?: DurableObjectJurisdiction) => MailboxSink;
|
|
86
86
|
/**
|
|
87
|
-
* Build a {@link Mailer} from a Worker `env`. In a dev environment every send is
|
|
88
|
-
* captured into the studio's Mail inbox; otherwise it delivers via the supplied
|
|
89
|
-
* `cloudflareSend` (the `SEND_EMAIL` binding) or, failing that, `RESEND_API_KEY`.
|
|
90
|
-
* Throws when neither a capture context nor a real transport is available, so a
|
|
91
|
-
* misconfigured production deploy fails loudly instead of silently dropping mail.
|
|
92
|
-
*
|
|
93
|
-
* `MAIL_FROM` is required (the default sender).
|
|
94
|
-
*/
|
|
87
|
+
* Build a {@link Mailer} from a Worker `env`. In a dev environment every send is
|
|
88
|
+
* captured into the studio's Mail inbox; otherwise it delivers via the supplied
|
|
89
|
+
* `cloudflareSend` (the `SEND_EMAIL` binding) or, failing that, `RESEND_API_KEY`.
|
|
90
|
+
* Throws when neither a capture context nor a real transport is available, so a
|
|
91
|
+
* misconfigured production deploy fails loudly instead of silently dropping mail.
|
|
92
|
+
*
|
|
93
|
+
* `MAIL_FROM` is required (the default sender).
|
|
94
|
+
*/
|
|
95
95
|
declare const createMailerFromEnv: (env: MailEnv, options?: FromEnvOptions) => Mailer;
|
|
96
96
|
/** Serializable representation of a `SendOptions` payload — drops the `react` field. */
|
|
97
97
|
interface QueuedSend {
|
|
@@ -100,51 +100,79 @@ interface QueuedSend {
|
|
|
100
100
|
from?: string;
|
|
101
101
|
headers?: Record<string, string>;
|
|
102
102
|
html?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Stable dedup key, minted at enqueue time by `createMailer(...).queue()` — see
|
|
105
|
+
* `SendOptions.idempotencyKey`. Carried through untouched by `consumeQueuedSend`;
|
|
106
|
+
* a consumer wanting exactly-once delivery dedupes against its own store using it.
|
|
107
|
+
*/
|
|
108
|
+
idempotencyKey?: string;
|
|
103
109
|
replyTo?: string;
|
|
104
110
|
subject: string;
|
|
105
111
|
text?: string;
|
|
106
112
|
to: string | string[];
|
|
107
113
|
}
|
|
108
114
|
/**
|
|
109
|
-
* Narrow a `SendOptions` to its serializable `QueuedSend` shape by dropping the
|
|
110
|
-
* non-cloneable `react` field. React elements are not structured-cloneable, so
|
|
111
|
-
* the queue body must carry only the pre-rendered html/text and scalar fields.
|
|
112
|
-
*/
|
|
115
|
+
* Narrow a `SendOptions` to its serializable `QueuedSend` shape by dropping the
|
|
116
|
+
* non-cloneable `react` field. React elements are not structured-cloneable, so
|
|
117
|
+
* the queue body must carry only the pre-rendered html/text and scalar fields.
|
|
118
|
+
*/
|
|
113
119
|
declare const toQueuedPayload: (options: SendOptions) => QueuedSend;
|
|
114
120
|
/**
|
|
115
|
-
* Helper used by Queue consumers: rehydrate a `QueuedSend` payload and forward
|
|
116
|
-
* to a configured `Mailer.send()`. Use this inside your Worker's `queue()`
|
|
117
|
-
* handler.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
|
|
121
|
+
* Helper used by Queue consumers: rehydrate a `QueuedSend` payload and forward
|
|
122
|
+
* to a configured `Mailer.send()`. Use this inside your Worker's `queue()`
|
|
123
|
+
* handler.
|
|
124
|
+
*
|
|
125
|
+
* DEDUPE IS THE CONSUMER'S JOB, and this helper does not do it. The payload's
|
|
126
|
+
* `idempotencyKey` was minted once at enqueue time so it survives redelivery, but
|
|
127
|
+
* nothing downstream reads it: no transport forwards it to the provider (Resend
|
|
128
|
+
* dedupes on an `Idempotency-Key` REQUEST header, which the provider client offers
|
|
129
|
+
* no hook for — its `headers` field becomes message headers in the body). A
|
|
130
|
+
* consumer that only acks is correct for the failure the ack covers and sends a
|
|
131
|
+
* duplicate for the one it does not: the provider accepted the message and the
|
|
132
|
+
* worker died before acking.
|
|
133
|
+
*
|
|
134
|
+
* The recipe below NARROWS that window; it does not close it, and nothing on
|
|
135
|
+
* this path can. The mark is written after the provider accepted the message, so
|
|
136
|
+
* a crash in between still redelivers and resends, and a KV read is eventually
|
|
137
|
+
* consistent — a redelivery seconds later can miss a mark that was written.
|
|
138
|
+
* Delivery is at-least-once end to end. An app that must not double-send needs a
|
|
139
|
+
* strongly-consistent mark taken BEFORE the send (a Durable Object or D1 row
|
|
140
|
+
* claimed by this key, released on failure), and even then the send-then-crash
|
|
141
|
+
* window is only ever traded for a send-that-may-not-have-happened one.
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* export default {
|
|
145
|
+
* queue: async (batch, env) => {
|
|
146
|
+
* const mailer = createMailer({ apiKey: env.RESEND_API_KEY, from: "..." });
|
|
147
|
+
* for (const message of batch.messages) {
|
|
148
|
+
* const { idempotencyKey } = message.body;
|
|
149
|
+
* if (await env.SENT.get(idempotencyKey)) { message.ack(); continue; }
|
|
150
|
+
* await consumeQueuedSend(mailer, message.body);
|
|
151
|
+
* await env.SENT.put(idempotencyKey, "1", { expirationTtl: 86_400 });
|
|
152
|
+
* message.ack();
|
|
153
|
+
* }
|
|
154
|
+
* },
|
|
155
|
+
* };
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
130
158
|
declare const consumeQueuedSend: (mailer: Mailer, payload: unknown) => Promise<{
|
|
131
159
|
id: string;
|
|
132
160
|
}>;
|
|
133
161
|
/**
|
|
134
|
-
* Render a React element to an HTML/text pair suitable for inlining into a
|
|
135
|
-
* provider payload. Wraps `@react-email/render` so we can swap to
|
|
136
|
-
* `@visulima/email`'s react-email template engine without touching callers.
|
|
137
|
-
*/
|
|
162
|
+
* Render a React element to an HTML/text pair suitable for inlining into a
|
|
163
|
+
* provider payload. Wraps `@react-email/render` so we can swap to
|
|
164
|
+
* `@visulima/email`'s react-email template engine without touching callers.
|
|
165
|
+
*/
|
|
138
166
|
declare const renderEmail: (element: ReactElement) => Promise<{
|
|
139
167
|
html: string;
|
|
140
168
|
text: string;
|
|
141
169
|
}>;
|
|
142
170
|
/**
|
|
143
|
-
* Build a Resend-backed transport via `@visulima/email`. Wraps the provider's
|
|
144
|
-
* `sendEmail()` into the minimal `{ send(payload) -> { id } }` shape the rest of
|
|
145
|
-
* `@lunora/mail` consumes. Kept reachable as a named export so a project that
|
|
146
|
-
* prefers Resend over the Cloudflare default can pass
|
|
147
|
-
* `transport: createResendTransport(apiKey, from)` to `createMailer`.
|
|
148
|
-
*/
|
|
171
|
+
* Build a Resend-backed transport via `@visulima/email`. Wraps the provider's
|
|
172
|
+
* `sendEmail()` into the minimal `{ send(payload) -> { id } }` shape the rest of
|
|
173
|
+
* `@lunora/mail` consumes. Kept reachable as a named export so a project that
|
|
174
|
+
* prefers Resend over the Cloudflare default can pass
|
|
175
|
+
* `transport: createResendTransport(apiKey, from)` to `createMailer`.
|
|
176
|
+
*/
|
|
149
177
|
declare const createResendTransport: (apiKey: string, defaultFrom: string) => MailTransport;
|
|
150
178
|
export { type CloudflareSend, type CloudflareTransportOptions, type FromEnvOptions, type LunoraMailOptions, type MailEnv, type MailTransport, type MailboxSink, type Mailer, type QueuedSend, type SendOptions, consumeQueuedSend, createCaptureSink, createCloudflareTransport, createMailer, createMailerFromEnv, createResendTransport, renderEmail, shouldCaptureMail, toQueuedPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { M as MailTransport, L as LunoraMailOptions, a as Mailer, b as MailboxSink, S as SendOptions } from "./packem_shared/capture-transport.d-
|
|
2
|
-
export { type C as CapturedMail, type Q as QueueLike, type c as SendPayload, d as createCaptureTransport } from "./packem_shared/capture-transport.d-
|
|
3
|
-
import { D as DurableObjectJurisdiction } from "./packem_shared/shard.d-
|
|
1
|
+
import { M as MailTransport, L as LunoraMailOptions, a as Mailer, b as MailboxSink, S as SendOptions } from "./packem_shared/capture-transport.d-BD67fxbB.js";
|
|
2
|
+
export { type C as CapturedMail, type Q as QueueLike, type c as SendPayload, d as createCaptureTransport } from "./packem_shared/capture-transport.d-BD67fxbB.js";
|
|
3
|
+
import { D as DurableObjectJurisdiction } from "./packem_shared/shard.d-DVADjmEJ.js";
|
|
4
4
|
import { ReactElement } from 'react';
|
|
5
5
|
/**
|
|
6
|
-
* Sends a raw RFC 822 message through a Worker's Email send binding. The Workers
|
|
7
|
-
* runtime owns the binding, so the caller supplies this thin callback — keeping
|
|
8
|
-
* `@lunora/mail` free of a `cloudflare:email` import and unit-testable. Wire it
|
|
9
|
-
* in your project as:
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* send: async (from, to, raw) => {
|
|
13
|
-
* const { EmailMessage } = await import("cloudflare:email");
|
|
14
|
-
* await env.SEND_EMAIL.send(new EmailMessage(from, to, raw));
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
6
|
+
* Sends a raw RFC 822 message through a Worker's Email send binding. The Workers
|
|
7
|
+
* runtime owns the binding, so the caller supplies this thin callback — keeping
|
|
8
|
+
* `@lunora/mail` free of a `cloudflare:email` import and unit-testable. Wire it
|
|
9
|
+
* in your project as:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* send: async (from, to, raw) => {
|
|
13
|
+
* const { EmailMessage } = await import("cloudflare:email");
|
|
14
|
+
* await env.SEND_EMAIL.send(new EmailMessage(from, to, raw));
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
18
|
type CloudflareSend = (from: string, to: string, raw: string) => Promise<void>;
|
|
19
19
|
interface CloudflareTransportOptions {
|
|
20
20
|
/** Default sender used when a `SendOptions.from` isn't supplied. */
|
|
@@ -23,34 +23,34 @@ interface CloudflareTransportOptions {
|
|
|
23
23
|
send: CloudflareSend;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Build the default Cloudflare Email Workers transport via `@visulima/email`.
|
|
27
|
-
* Cloudflare's `send_email` binding is **single-recipient** and only delivers to
|
|
28
|
-
* **verified Email Routing destination addresses**, and the underlying provider
|
|
29
|
-
* rejects any `cc`/`bcc` or a non-single `to` outright. So this enforces a single
|
|
30
|
-
* `to` recipient (throwing a clear error instead of silently dropping the rest)
|
|
31
|
-
* and rejects `cc`/`bcc` rather than forwarding them into a generic "send failed".
|
|
32
|
-
* Multi-recipient transactional mail must fan out one send per recipient at the
|
|
33
|
-
* call site. In dev the capture transport intercepts before this runs, so the
|
|
34
|
-
* verified-address constraint never bites the dev loop.
|
|
35
|
-
*/
|
|
26
|
+
* Build the default Cloudflare Email Workers transport via `@visulima/email`.
|
|
27
|
+
* Cloudflare's `send_email` binding is **single-recipient** and only delivers to
|
|
28
|
+
* **verified Email Routing destination addresses**, and the underlying provider
|
|
29
|
+
* rejects any `cc`/`bcc` or a non-single `to` outright. So this enforces a single
|
|
30
|
+
* `to` recipient (throwing a clear error instead of silently dropping the rest)
|
|
31
|
+
* and rejects `cc`/`bcc` rather than forwarding them into a generic "send failed".
|
|
32
|
+
* Multi-recipient transactional mail must fan out one send per recipient at the
|
|
33
|
+
* call site. In dev the capture transport intercepts before this runs, so the
|
|
34
|
+
* verified-address constraint never bites the dev loop.
|
|
35
|
+
*/
|
|
36
36
|
declare const createCloudflareTransport: (options: CloudflareTransportOptions) => MailTransport;
|
|
37
37
|
/**
|
|
38
|
-
* Create a mailer bound to a transport.
|
|
39
|
-
*
|
|
40
|
-
* SECURITY — recipient policy and HTML content are the caller's responsibility.
|
|
41
|
-
* The mailer fully blocks header/CRLF/comma injection in addresses
|
|
42
|
-
* (`assertSafeAddresses` / `assertSafeHeaderValue`), but it does NOT decide WHO
|
|
43
|
-
* you may send to or WHAT HTML you render.
|
|
44
|
-
*
|
|
45
|
-
* Open relay: derive `to`/`cc`/`bcc` from server-trusted state, never from raw
|
|
46
|
-
* request input, and prefer a fixed/allowlisted `from` — sending to an arbitrary
|
|
47
|
-
* user-supplied address turns your deployment into a spam relay.
|
|
48
|
-
*
|
|
49
|
-
* Template XSS / content injection: treat template HTML like any other HTML sink
|
|
50
|
-
* — never interpolate untrusted data into raw markup (or a
|
|
51
|
-
* `dangerouslySetInnerHTML`-style template) without escaping. The mailer sends
|
|
52
|
-
* whatever HTML you hand it verbatim.
|
|
53
|
-
*/
|
|
38
|
+
* Create a mailer bound to a transport.
|
|
39
|
+
*
|
|
40
|
+
* SECURITY — recipient policy and HTML content are the caller's responsibility.
|
|
41
|
+
* The mailer fully blocks header/CRLF/comma injection in addresses
|
|
42
|
+
* (`assertSafeAddresses` / `assertSafeHeaderValue`), but it does NOT decide WHO
|
|
43
|
+
* you may send to or WHAT HTML you render.
|
|
44
|
+
*
|
|
45
|
+
* Open relay: derive `to`/`cc`/`bcc` from server-trusted state, never from raw
|
|
46
|
+
* request input, and prefer a fixed/allowlisted `from` — sending to an arbitrary
|
|
47
|
+
* user-supplied address turns your deployment into a spam relay.
|
|
48
|
+
*
|
|
49
|
+
* Template XSS / content injection: treat template HTML like any other HTML sink
|
|
50
|
+
* — never interpolate untrusted data into raw markup (or a
|
|
51
|
+
* `dangerouslySetInnerHTML`-style template) without escaping. The mailer sends
|
|
52
|
+
* whatever HTML you hand it verbatim.
|
|
53
|
+
*/
|
|
54
54
|
declare const createMailer: (options: LunoraMailOptions) => Mailer;
|
|
55
55
|
/** A Worker `env` projected as a plain record (vars, secrets, and bindings are `unknown`-valued). */
|
|
56
56
|
type MailEnv = Record<string, unknown>;
|
|
@@ -59,39 +59,39 @@ interface FromEnvOptions {
|
|
|
59
59
|
/** RFC 822 send callback bound to the Worker's `send_email` binding (Cloudflare default transport). */
|
|
60
60
|
cloudflareSend?: CloudflareSend;
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
* Pin the captured-mail inbox shard to a Cloudflare data-residency
|
|
63
|
+
* jurisdiction. Pass the same value as the worker's `jurisdiction` so the
|
|
64
|
+
* dev inbox co-resides with app data. Omit for the un-pinned global namespace.
|
|
65
|
+
*/
|
|
66
66
|
jurisdiction?: DurableObjectJurisdiction;
|
|
67
67
|
/** Shard the captured-mail inbox lives on; override if your worker sets a custom `defaultShardKey`. */
|
|
68
68
|
rootShard?: string;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Whether outbound mail should be captured (into the studio inbox) rather than
|
|
72
|
-
* delivered. Explicit `LUNORA_MAIL_CAPTURE` (`"1"`/`"true"` vs `"0"`/`"false"`)
|
|
73
|
-
* always wins; unset, capture is on only in a development environment. It does
|
|
74
|
-
* NOT fall back to "no SEND_EMAIL binding ⇒ capture" — a production deploy that
|
|
75
|
-
* forgot the binding must fail loudly on send, not silently swallow mail.
|
|
76
|
-
*/
|
|
71
|
+
* Whether outbound mail should be captured (into the studio inbox) rather than
|
|
72
|
+
* delivered. Explicit `LUNORA_MAIL_CAPTURE` (`"1"`/`"true"` vs `"0"`/`"false"`)
|
|
73
|
+
* always wins; unset, capture is on only in a development environment. It does
|
|
74
|
+
* NOT fall back to "no SEND_EMAIL binding ⇒ capture" — a production deploy that
|
|
75
|
+
* forgot the binding must fail loudly on send, not silently swallow mail.
|
|
76
|
+
*/
|
|
77
77
|
declare const shouldCaptureMail: (env: MailEnv) => boolean;
|
|
78
78
|
/**
|
|
79
|
-
* Build the {@link MailboxSink} that records a captured message into the studio's
|
|
80
|
-
* root-shard inbox via the reserved `recordMail` admin RPC — the same
|
|
81
|
-
* worker→root-shard path the runtime uses for auth events. Best-effort: without
|
|
82
|
-
* the `SHARD` binding or `LUNORA_ADMIN_TOKEN` it returns a sentinel id so a send
|
|
83
|
-
* never fails for lack of somewhere to record.
|
|
84
|
-
*/
|
|
79
|
+
* Build the {@link MailboxSink} that records a captured message into the studio's
|
|
80
|
+
* root-shard inbox via the reserved `recordMail` admin RPC — the same
|
|
81
|
+
* worker→root-shard path the runtime uses for auth events. Best-effort: without
|
|
82
|
+
* the `SHARD` binding or `LUNORA_ADMIN_TOKEN` it returns a sentinel id so a send
|
|
83
|
+
* never fails for lack of somewhere to record — but it says so first (see below).
|
|
84
|
+
*/
|
|
85
85
|
declare const createCaptureSink: (env: MailEnv, rootShard?: string, jurisdiction?: DurableObjectJurisdiction) => MailboxSink;
|
|
86
86
|
/**
|
|
87
|
-
* Build a {@link Mailer} from a Worker `env`. In a dev environment every send is
|
|
88
|
-
* captured into the studio's Mail inbox; otherwise it delivers via the supplied
|
|
89
|
-
* `cloudflareSend` (the `SEND_EMAIL` binding) or, failing that, `RESEND_API_KEY`.
|
|
90
|
-
* Throws when neither a capture context nor a real transport is available, so a
|
|
91
|
-
* misconfigured production deploy fails loudly instead of silently dropping mail.
|
|
92
|
-
*
|
|
93
|
-
* `MAIL_FROM` is required (the default sender).
|
|
94
|
-
*/
|
|
87
|
+
* Build a {@link Mailer} from a Worker `env`. In a dev environment every send is
|
|
88
|
+
* captured into the studio's Mail inbox; otherwise it delivers via the supplied
|
|
89
|
+
* `cloudflareSend` (the `SEND_EMAIL` binding) or, failing that, `RESEND_API_KEY`.
|
|
90
|
+
* Throws when neither a capture context nor a real transport is available, so a
|
|
91
|
+
* misconfigured production deploy fails loudly instead of silently dropping mail.
|
|
92
|
+
*
|
|
93
|
+
* `MAIL_FROM` is required (the default sender).
|
|
94
|
+
*/
|
|
95
95
|
declare const createMailerFromEnv: (env: MailEnv, options?: FromEnvOptions) => Mailer;
|
|
96
96
|
/** Serializable representation of a `SendOptions` payload — drops the `react` field. */
|
|
97
97
|
interface QueuedSend {
|
|
@@ -100,51 +100,79 @@ interface QueuedSend {
|
|
|
100
100
|
from?: string;
|
|
101
101
|
headers?: Record<string, string>;
|
|
102
102
|
html?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Stable dedup key, minted at enqueue time by `createMailer(...).queue()` — see
|
|
105
|
+
* `SendOptions.idempotencyKey`. Carried through untouched by `consumeQueuedSend`;
|
|
106
|
+
* a consumer wanting exactly-once delivery dedupes against its own store using it.
|
|
107
|
+
*/
|
|
108
|
+
idempotencyKey?: string;
|
|
103
109
|
replyTo?: string;
|
|
104
110
|
subject: string;
|
|
105
111
|
text?: string;
|
|
106
112
|
to: string | string[];
|
|
107
113
|
}
|
|
108
114
|
/**
|
|
109
|
-
* Narrow a `SendOptions` to its serializable `QueuedSend` shape by dropping the
|
|
110
|
-
* non-cloneable `react` field. React elements are not structured-cloneable, so
|
|
111
|
-
* the queue body must carry only the pre-rendered html/text and scalar fields.
|
|
112
|
-
*/
|
|
115
|
+
* Narrow a `SendOptions` to its serializable `QueuedSend` shape by dropping the
|
|
116
|
+
* non-cloneable `react` field. React elements are not structured-cloneable, so
|
|
117
|
+
* the queue body must carry only the pre-rendered html/text and scalar fields.
|
|
118
|
+
*/
|
|
113
119
|
declare const toQueuedPayload: (options: SendOptions) => QueuedSend;
|
|
114
120
|
/**
|
|
115
|
-
* Helper used by Queue consumers: rehydrate a `QueuedSend` payload and forward
|
|
116
|
-
* to a configured `Mailer.send()`. Use this inside your Worker's `queue()`
|
|
117
|
-
* handler.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
|
|
121
|
+
* Helper used by Queue consumers: rehydrate a `QueuedSend` payload and forward
|
|
122
|
+
* to a configured `Mailer.send()`. Use this inside your Worker's `queue()`
|
|
123
|
+
* handler.
|
|
124
|
+
*
|
|
125
|
+
* DEDUPE IS THE CONSUMER'S JOB, and this helper does not do it. The payload's
|
|
126
|
+
* `idempotencyKey` was minted once at enqueue time so it survives redelivery, but
|
|
127
|
+
* nothing downstream reads it: no transport forwards it to the provider (Resend
|
|
128
|
+
* dedupes on an `Idempotency-Key` REQUEST header, which the provider client offers
|
|
129
|
+
* no hook for — its `headers` field becomes message headers in the body). A
|
|
130
|
+
* consumer that only acks is correct for the failure the ack covers and sends a
|
|
131
|
+
* duplicate for the one it does not: the provider accepted the message and the
|
|
132
|
+
* worker died before acking.
|
|
133
|
+
*
|
|
134
|
+
* The recipe below NARROWS that window; it does not close it, and nothing on
|
|
135
|
+
* this path can. The mark is written after the provider accepted the message, so
|
|
136
|
+
* a crash in between still redelivers and resends, and a KV read is eventually
|
|
137
|
+
* consistent — a redelivery seconds later can miss a mark that was written.
|
|
138
|
+
* Delivery is at-least-once end to end. An app that must not double-send needs a
|
|
139
|
+
* strongly-consistent mark taken BEFORE the send (a Durable Object or D1 row
|
|
140
|
+
* claimed by this key, released on failure), and even then the send-then-crash
|
|
141
|
+
* window is only ever traded for a send-that-may-not-have-happened one.
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* export default {
|
|
145
|
+
* queue: async (batch, env) => {
|
|
146
|
+
* const mailer = createMailer({ apiKey: env.RESEND_API_KEY, from: "..." });
|
|
147
|
+
* for (const message of batch.messages) {
|
|
148
|
+
* const { idempotencyKey } = message.body;
|
|
149
|
+
* if (await env.SENT.get(idempotencyKey)) { message.ack(); continue; }
|
|
150
|
+
* await consumeQueuedSend(mailer, message.body);
|
|
151
|
+
* await env.SENT.put(idempotencyKey, "1", { expirationTtl: 86_400 });
|
|
152
|
+
* message.ack();
|
|
153
|
+
* }
|
|
154
|
+
* },
|
|
155
|
+
* };
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
130
158
|
declare const consumeQueuedSend: (mailer: Mailer, payload: unknown) => Promise<{
|
|
131
159
|
id: string;
|
|
132
160
|
}>;
|
|
133
161
|
/**
|
|
134
|
-
* Render a React element to an HTML/text pair suitable for inlining into a
|
|
135
|
-
* provider payload. Wraps `@react-email/render` so we can swap to
|
|
136
|
-
* `@visulima/email`'s react-email template engine without touching callers.
|
|
137
|
-
*/
|
|
162
|
+
* Render a React element to an HTML/text pair suitable for inlining into a
|
|
163
|
+
* provider payload. Wraps `@react-email/render` so we can swap to
|
|
164
|
+
* `@visulima/email`'s react-email template engine without touching callers.
|
|
165
|
+
*/
|
|
138
166
|
declare const renderEmail: (element: ReactElement) => Promise<{
|
|
139
167
|
html: string;
|
|
140
168
|
text: string;
|
|
141
169
|
}>;
|
|
142
170
|
/**
|
|
143
|
-
* Build a Resend-backed transport via `@visulima/email`. Wraps the provider's
|
|
144
|
-
* `sendEmail()` into the minimal `{ send(payload) -> { id } }` shape the rest of
|
|
145
|
-
* `@lunora/mail` consumes. Kept reachable as a named export so a project that
|
|
146
|
-
* prefers Resend over the Cloudflare default can pass
|
|
147
|
-
* `transport: createResendTransport(apiKey, from)` to `createMailer`.
|
|
148
|
-
*/
|
|
171
|
+
* Build a Resend-backed transport via `@visulima/email`. Wraps the provider's
|
|
172
|
+
* `sendEmail()` into the minimal `{ send(payload) -> { id } }` shape the rest of
|
|
173
|
+
* `@lunora/mail` consumes. Kept reachable as a named export so a project that
|
|
174
|
+
* prefers Resend over the Cloudflare default can pass
|
|
175
|
+
* `transport: createResendTransport(apiKey, from)` to `createMailer`.
|
|
176
|
+
*/
|
|
149
177
|
declare const createResendTransport: (apiKey: string, defaultFrom: string) => MailTransport;
|
|
150
178
|
export { type CloudflareSend, type CloudflareTransportOptions, type FromEnvOptions, type LunoraMailOptions, type MailEnv, type MailTransport, type MailboxSink, type Mailer, type QueuedSend, type SendOptions, consumeQueuedSend, createCaptureSink, createCloudflareTransport, createMailer, createMailerFromEnv, createResendTransport, renderEmail, shouldCaptureMail, toQueuedPayload };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createCloudflareTransport } from './packem_shared/createCloudflareTransport-DXh1nUNi.mjs';
|
|
3
|
-
export { default as createMailer } from './packem_shared/createMailer-B4Z_Cgiu.mjs';
|
|
4
|
-
export { createCaptureSink, createMailerFromEnv, shouldCaptureMail } from './packem_shared/createCaptureSink-Di-5AJUs.mjs';
|
|
5
|
-
export { consumeQueuedSend, toQueuedPayload } from './packem_shared/consumeQueuedSend-B9hTDOZ6.mjs';
|
|
6
|
-
export { default as renderEmail } from './packem_shared/renderEmail-hyS1bpVP.mjs';
|
|
7
|
-
export { default as createResendTransport } from './packem_shared/createResendTransport-CMQWjZoi.mjs';
|
|
1
|
+
import{createCaptureTransport as a}from"./packem_shared/createCaptureTransport-CKc6NpZR.mjs";import{createCloudflareTransport as t}from"./packem_shared/createCloudflareTransport-DpfCxn16.mjs";import{default as u}from"./packem_shared/createMailer-CjQmT7Ln.mjs";import{createCaptureSink as f,createMailerFromEnv as l,shouldCaptureMail as m}from"./packem_shared/createCaptureSink-CeV0DSsT.mjs";import{consumeQueuedSend as s,toQueuedPayload as c}from"./packem_shared/consumeQueuedSend-CRfALnCU.mjs";import{default as i}from"./packem_shared/renderEmail-BOUnr6i3.mjs";import{default as M}from"./packem_shared/createResendTransport-DDkOitck.mjs";export{s as consumeQueuedSend,f as createCaptureSink,a as createCaptureTransport,t as createCloudflareTransport,u as createMailer,l as createMailerFromEnv,M as createResendTransport,i as renderEmail,m as shouldCaptureMail,c as toQueuedPayload};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{LunoraError as t}from"@lunora/errors";const n=320,a=256,d=/^([^<]*)<([^>]*)>\s*$/,i=(r,s)=>{if(s.includes("\r")||s.includes(`
|
|
2
|
+
`)||s.includes(","))throw new t("INTERNAL",`@lunora/mail: address ${r} must not contain CR, LF, or comma`)},f=(r,s)=>{if(s.includes("\r")||s.includes(`
|
|
3
|
+
`))throw new t("INTERNAL",`@lunora/mail: ${r} must not contain CR or LF`)},m=(r,s)=>{if(r.length>a)throw new t("INTERNAL",`@lunora/mail: address name must be <= ${String(a)} characters`);if(s.length>n)throw new t("INTERNAL",`@lunora/mail: address email must be <= ${String(n)} characters`);return r&&i("name",r),i("email",s),r?{email:s,name:r}:{email:s}},A=r=>{const s=r.trim();if(s.length>n)throw new t("INTERNAL",`@lunora/mail: address email must be <= ${String(n)} characters`);return i("email",s),{email:s}},c=r=>{const s=d.exec(r),e=(s?.[2]??"").trim();return s&&e?m((s[1]??"").trim(),e):A(r)},o=r=>r===void 0?void 0:(Array.isArray(r)?r:[r]).map(e=>c(e)),u=r=>{o(r.to),o(r.cc),o(r.bcc),r.from!==void 0&&c(r.from),r.replyTo!==void 0&&c(r.replyTo)};export{f as a,c as b,u as c,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from"postal-mime";import{a as c}from"./address-soPj2Z0j.mjs";const d=(s,e)=>{if(e!==void 0)return c(`inbound ${s}`,e),e},u=s=>s.address!==void 0&&s.address!==""?s.name?`${s.name} <${s.address}>`:s.address:s.group?s.group.map(e=>e.address??"").filter(e=>e!=="").join(", "):s.name??"",l=/"(?:[^"\\]|\\.)*(?:"|$)|\((?:[^()\\]|\\.)*(?:\)|$)/g,g=s=>s.replaceAll(l,e=>e.startsWith('"')?e.replaceAll(/[;=]/gu," "):" "),m=(s,e,r)=>{const i=g(s).matchAll(new RegExp(String.raw`(?:^|;)\s*${e}\s*(?:/\s*\d+\s*)?=\s*([a-z]+)([^;]*)`,"gi")),a=new RegExp(String.raw`\b${r.split(".").join(String.raw`\s*\.\s*`)}\s*=\s*"?([^\s;"]+)`,"i");return[...i].map(t=>{const n=a.exec(t[2]??"")?.[1];return{domain:n===void 0?null:n.slice(n.lastIndexOf("@")+1).toLowerCase(),result:(t[1]??"").toLowerCase()}})},v=s=>s===void 0||s===""?{dkim:[],dmarc:[],spf:[]}:{dkim:m(s,"dkim","header.d"),dmarc:m(s,"dmarc","header.from"),spf:m(s,"spf","smtp.mailfrom")},I=async s=>{const e=await p.parse(s),r={};for(const o of e.headers)c(`inbound header \`${o.key}\``,o.value),r[o.key]=o.value;const i=e.headers.find(o=>o.key==="authentication-results")?.value,a=(e.to??[]).map(o=>{const f=u(o);return c("inbound to",f),f}),t=e.from?u(e.from):"";return c("inbound from",t),{attachments:e.attachments.map(o=>({content:o.content,disposition:o.disposition,...o.encoding===void 0?{}:{encoding:o.encoding},filename:o.filename,mimeType:o.mimeType})),authentication:v(i),from:t,headers:r,...e.html===void 0?{}:{html:e.html},...d("inReplyTo",e.inReplyTo)===void 0?{}:{inReplyTo:e.inReplyTo},...d("messageId",e.messageId)===void 0?{}:{messageId:e.messageId},...d("references",e.references)===void 0?{}:{references:e.references},...d("subject",e.subject)===void 0?{}:{subject:e.subject},...e.text===void 0?{}:{text:e.text},to:a}},h=/<([^<>]*)>$/,x=s=>{const e=h.exec(s)?.[1]??s,r=e.indexOf("@");if(!(r===-1||r!==e.lastIndexOf("@")))return e.slice(r+1).trim().toLowerCase()},$=s=>{const e=x(s.from);if(e===void 0)return!1;const r=n=>n.some(o=>o.result==="pass"&&o.domain===e),{dkim:i,dmarc:a,spf:t}=s.authentication;return r(a)||r(t)||r(i)};export{$ as authenticatesFrom,I as parseInboundEmail};
|