@lunora/mail 1.0.0-alpha.47 → 1.0.0-alpha.49
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/dist/inbound/index.d.mts +129 -1
- package/dist/inbound/index.d.ts +129 -1
- package/dist/inbound/index.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/address-BQ5RUGdT.mjs +3 -0
- package/dist/packem_shared/consumeQueuedSend-8TXPj5o-.mjs +1 -0
- package/dist/packem_shared/createCaptureSink-CE24od5h.mjs +1 -0
- package/dist/packem_shared/createCaptureTransport-CKc6NpZR.mjs +1 -0
- package/dist/packem_shared/createCloudflareTransport-E-UdW8Dc.mjs +1 -0
- package/dist/packem_shared/createInboundEmailHandler-D2i0mEBB.mjs +1 -0
- package/dist/packem_shared/createMailer-LHgKs5yh.mjs +1 -0
- package/dist/packem_shared/createResendTransport-CG9s8iI9.mjs +1 -0
- package/dist/packem_shared/parseInboundEmail-Cxe54g-h.mjs +1 -0
- package/dist/packem_shared/provider-transport-DXmTG_xv.mjs +1 -0
- package/dist/packem_shared/renderEmail-BOUnr6i3.mjs +1 -0
- package/dist/packem_shared/shard-C0aRRoVy.mjs +1 -0
- package/dist/testing.mjs +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/address-Y4Z--6ZO.mjs +0 -3
- package/dist/packem_shared/consumeQueuedSend-CrfNFyMX.mjs +0 -1
- package/dist/packem_shared/createCaptureSink-7-YsQqS8.mjs +0 -1
- package/dist/packem_shared/createCaptureTransport-BPdMkU0O.mjs +0 -1
- package/dist/packem_shared/createCloudflareTransport-V23CVw7F.mjs +0 -1
- package/dist/packem_shared/createInboundEmailHandler-B7H4h_sK.mjs +0 -1
- package/dist/packem_shared/createMailer-BWaX1-ma.mjs +0 -1
- package/dist/packem_shared/createResendTransport-CpSJ4j7C.mjs +0 -1
- package/dist/packem_shared/parseInboundEmail-tJMs3YON.mjs +0 -1
- package/dist/packem_shared/provider-transport-BZngzyeS.mjs +0 -1
- package/dist/packem_shared/renderEmail-DM8_pWKa.mjs +0 -1
- package/dist/packem_shared/shard-CcKsuWAm.mjs +0 -1
package/dist/inbound/index.d.mts
CHANGED
|
@@ -201,4 +201,132 @@ interface DispatchToLunoraFunctionOptions<TEnv = Record<string, unknown>> {
|
|
|
201
201
|
* making any trust decision in the target function.
|
|
202
202
|
*/
|
|
203
203
|
declare const dispatchToLunoraFunction: <TEnv extends Record<string, unknown> = Record<string, unknown>>(options: DispatchToLunoraFunctionOptions<TEnv>) => InboundDispatch<TEnv>;
|
|
204
|
-
export {
|
|
204
|
+
export {
|
|
205
|
+
/**
|
|
206
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
207
|
+
*
|
|
208
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
209
|
+
* mutation/action:
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
213
|
+
*
|
|
214
|
+
* export const email = createInboundEmailHandler({
|
|
215
|
+
* parse: parseInboundEmail,
|
|
216
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
type DispatchToLunoraFunctionOptions,
|
|
221
|
+
/**
|
|
222
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
223
|
+
*
|
|
224
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
225
|
+
* mutation/action:
|
|
226
|
+
*
|
|
227
|
+
* ```ts
|
|
228
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
229
|
+
*
|
|
230
|
+
* export const email = createInboundEmailHandler({
|
|
231
|
+
* parse: parseInboundEmail,
|
|
232
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
233
|
+
* });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
type ForwardableEmailMessageLike, type InboundAttachment, type InboundAuthentication,
|
|
237
|
+
/**
|
|
238
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
239
|
+
*
|
|
240
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
241
|
+
* mutation/action:
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
245
|
+
*
|
|
246
|
+
* export const email = createInboundEmailHandler({
|
|
247
|
+
* parse: parseInboundEmail,
|
|
248
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
type InboundDispatch,
|
|
253
|
+
/**
|
|
254
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
255
|
+
*
|
|
256
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
257
|
+
* mutation/action:
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
261
|
+
*
|
|
262
|
+
* export const email = createInboundEmailHandler({
|
|
263
|
+
* parse: parseInboundEmail,
|
|
264
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
type InboundDispatchContext, type InboundEmail,
|
|
269
|
+
/**
|
|
270
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
271
|
+
*
|
|
272
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
273
|
+
* mutation/action:
|
|
274
|
+
*
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
277
|
+
*
|
|
278
|
+
* export const email = createInboundEmailHandler({
|
|
279
|
+
* parse: parseInboundEmail,
|
|
280
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
281
|
+
* });
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
type InboundEmailHandler,
|
|
285
|
+
/**
|
|
286
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
287
|
+
*
|
|
288
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
289
|
+
* mutation/action:
|
|
290
|
+
*
|
|
291
|
+
* ```ts
|
|
292
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
293
|
+
*
|
|
294
|
+
* export const email = createInboundEmailHandler({
|
|
295
|
+
* parse: parseInboundEmail,
|
|
296
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
type InboundEmailHandlerOptions,
|
|
301
|
+
/**
|
|
302
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
303
|
+
*
|
|
304
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
305
|
+
* mutation/action:
|
|
306
|
+
*
|
|
307
|
+
* ```ts
|
|
308
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
309
|
+
*
|
|
310
|
+
* export const email = createInboundEmailHandler({
|
|
311
|
+
* parse: parseInboundEmail,
|
|
312
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
type InboundVerify, type RawInboundEmail,
|
|
317
|
+
/**
|
|
318
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
319
|
+
*
|
|
320
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
321
|
+
* mutation/action:
|
|
322
|
+
*
|
|
323
|
+
* ```ts
|
|
324
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
325
|
+
*
|
|
326
|
+
* export const email = createInboundEmailHandler({
|
|
327
|
+
* parse: parseInboundEmail,
|
|
328
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
329
|
+
* });
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
type RpcEnvelope, type ShardNamespaceLike, createInboundEmailHandler, dispatchToLunoraFunction, parseInboundEmail };
|
package/dist/inbound/index.d.ts
CHANGED
|
@@ -201,4 +201,132 @@ interface DispatchToLunoraFunctionOptions<TEnv = Record<string, unknown>> {
|
|
|
201
201
|
* making any trust decision in the target function.
|
|
202
202
|
*/
|
|
203
203
|
declare const dispatchToLunoraFunction: <TEnv extends Record<string, unknown> = Record<string, unknown>>(options: DispatchToLunoraFunctionOptions<TEnv>) => InboundDispatch<TEnv>;
|
|
204
|
-
export {
|
|
204
|
+
export {
|
|
205
|
+
/**
|
|
206
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
207
|
+
*
|
|
208
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
209
|
+
* mutation/action:
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
213
|
+
*
|
|
214
|
+
* export const email = createInboundEmailHandler({
|
|
215
|
+
* parse: parseInboundEmail,
|
|
216
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
type DispatchToLunoraFunctionOptions,
|
|
221
|
+
/**
|
|
222
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
223
|
+
*
|
|
224
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
225
|
+
* mutation/action:
|
|
226
|
+
*
|
|
227
|
+
* ```ts
|
|
228
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
229
|
+
*
|
|
230
|
+
* export const email = createInboundEmailHandler({
|
|
231
|
+
* parse: parseInboundEmail,
|
|
232
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
233
|
+
* });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
type ForwardableEmailMessageLike, type InboundAttachment, type InboundAuthentication,
|
|
237
|
+
/**
|
|
238
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
239
|
+
*
|
|
240
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
241
|
+
* mutation/action:
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
245
|
+
*
|
|
246
|
+
* export const email = createInboundEmailHandler({
|
|
247
|
+
* parse: parseInboundEmail,
|
|
248
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
type InboundDispatch,
|
|
253
|
+
/**
|
|
254
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
255
|
+
*
|
|
256
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
257
|
+
* mutation/action:
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
261
|
+
*
|
|
262
|
+
* export const email = createInboundEmailHandler({
|
|
263
|
+
* parse: parseInboundEmail,
|
|
264
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
type InboundDispatchContext, type InboundEmail,
|
|
269
|
+
/**
|
|
270
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
271
|
+
*
|
|
272
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
273
|
+
* mutation/action:
|
|
274
|
+
*
|
|
275
|
+
* ```ts
|
|
276
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
277
|
+
*
|
|
278
|
+
* export const email = createInboundEmailHandler({
|
|
279
|
+
* parse: parseInboundEmail,
|
|
280
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
281
|
+
* });
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
type InboundEmailHandler,
|
|
285
|
+
/**
|
|
286
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
287
|
+
*
|
|
288
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
289
|
+
* mutation/action:
|
|
290
|
+
*
|
|
291
|
+
* ```ts
|
|
292
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
293
|
+
*
|
|
294
|
+
* export const email = createInboundEmailHandler({
|
|
295
|
+
* parse: parseInboundEmail,
|
|
296
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
type InboundEmailHandlerOptions,
|
|
301
|
+
/**
|
|
302
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
303
|
+
*
|
|
304
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
305
|
+
* mutation/action:
|
|
306
|
+
*
|
|
307
|
+
* ```ts
|
|
308
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
309
|
+
*
|
|
310
|
+
* export const email = createInboundEmailHandler({
|
|
311
|
+
* parse: parseInboundEmail,
|
|
312
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
type InboundVerify, type RawInboundEmail,
|
|
317
|
+
/**
|
|
318
|
+
* `@lunora/mail/inbound` — inbound Email Routing support.
|
|
319
|
+
*
|
|
320
|
+
* Wire a Cloudflare Email Worker entry to route received mail into a Lunora
|
|
321
|
+
* mutation/action:
|
|
322
|
+
*
|
|
323
|
+
* ```ts
|
|
324
|
+
* import { createInboundEmailHandler, parseInboundEmail, dispatchToLunoraFunction } from "@lunora/mail/inbound";
|
|
325
|
+
*
|
|
326
|
+
* export const email = createInboundEmailHandler({
|
|
327
|
+
* parse: parseInboundEmail,
|
|
328
|
+
* dispatch: dispatchToLunoraFunction({ shard: env.SHARD, functionPath: "inbound:onEmail" }),
|
|
329
|
+
* });
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
type RpcEnvelope, type ShardNamespaceLike, createInboundEmailHandler, dispatchToLunoraFunction, parseInboundEmail };
|
package/dist/inbound/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInboundEmailHandler as r,dispatchToLunoraFunction as a}from"../packem_shared/createInboundEmailHandler-
|
|
1
|
+
import{createInboundEmailHandler as r,dispatchToLunoraFunction as a}from"../packem_shared/createInboundEmailHandler-D2i0mEBB.mjs";import{parseInboundEmail as t}from"../packem_shared/parseInboundEmail-Cxe54g-h.mjs";export{r as createInboundEmailHandler,a as dispatchToLunoraFunction,t as parseInboundEmail};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCaptureTransport as a}from"./packem_shared/createCaptureTransport-
|
|
1
|
+
import{createCaptureTransport as a}from"./packem_shared/createCaptureTransport-CKc6NpZR.mjs";import{createCloudflareTransport as t}from"./packem_shared/createCloudflareTransport-E-UdW8Dc.mjs";import{default as u}from"./packem_shared/createMailer-LHgKs5yh.mjs";import{createCaptureSink as f,createMailerFromEnv as l,shouldCaptureMail as m}from"./packem_shared/createCaptureSink-CE24od5h.mjs";import{consumeQueuedSend as s,toQueuedPayload as c}from"./packem_shared/consumeQueuedSend-8TXPj5o-.mjs";import{default as i}from"./packem_shared/renderEmail-BOUnr6i3.mjs";import{default as M}from"./packem_shared/createResendTransport-CG9s8iI9.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,u as b,c,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";const d=n=>{const t={...n};return delete t.react,t},p=async(n,t)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new c("INTERNAL","@lunora/mail: queue message body must be an object");const e=t;if(typeof e.subject!="string")throw new TypeError("@lunora/mail: queue message must have a string `subject`");const m=typeof e.to=="string",y=Array.isArray(e.to)&&e.to.every(s=>typeof s=="string");if(!m&&!y)throw new c("INTERNAL","@lunora/mail: queue message `to` must be a string or string[]");const o=(s,r)=>{if(r!==void 0){if(typeof r!="string")throw new TypeError(`@lunora/mail: queue message \`${s}\` must be a string`);return r}},a=(s,r)=>{if(r!==void 0){if(typeof r=="string")return[r];if(Array.isArray(r)&&r.every(i=>typeof i=="string"))return r;throw new TypeError(`@lunora/mail: queue message \`${s}\` must be a string or string[]`)}};let u;if(e.headers!==void 0){if(!e.headers||typeof e.headers!="object"||Array.isArray(e.headers))throw new TypeError("@lunora/mail: queue message `headers` must be an object of string values");const s=Object.entries(e.headers);for(const[r,i]of s)if(typeof i!="string")throw new TypeError(`@lunora/mail: queue message header "${r}" must be a string`);u=e.headers}const f={bcc:a("bcc",e.bcc),cc:a("cc",e.cc),from:o("from",e.from),headers:u,html:o("html",e.html),replyTo:o("replyTo",e.replyTo),subject:e.subject,text:o("text",e.text),to:e.to};return n.send(f)};export{p as consumeQueuedSend,d as toQueuedPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCaptureTransport as d}from"./createCaptureTransport-CKc6NpZR.mjs";import"./createCloudflareTransport-E-UdW8Dc.mjs";import n from"./createMailer-LHgKs5yh.mjs";import{LunoraError as c}from"@lunora/errors";import{D as s,p as l}from"./shard-C0aRRoVy.mjs";import"./consumeQueuedSend-8TXPj5o-.mjs";import"./renderEmail-BOUnr6i3.mjs";import"./createResendTransport-CG9s8iI9.mjs";const E="__lunora_admin__:recordMail",p=/^(?:dev(?:elopment)?|local(?:host)?|test)$/iu,f=["CF_ENV","ENVIRONMENT","NODE_ENV","WORKER_ENV"],_=(t,e)=>{const r=t[e];if(typeof r!="string"||r==="")throw new c("INTERNAL",`@lunora/mail: missing env var \`${e}\` — set it in .dev.vars (and \`wrangler secret put ${e}\` for secrets).`);return r},N=t=>{const e=t.LUNORA_MAIL_CAPTURE;if(typeof e=="string"){const r=e.toLowerCase();if(r==="1"||r==="true")return!0;if(r==="0"||r==="false")return!1;console.warn(`@lunora/mail: unrecognized LUNORA_MAIL_CAPTURE value "${e}" — expected "1"/"true" or "0"/"false"; falling back to environment detection.`)}return f.some(r=>{const o=t[r];return typeof o=="string"&&p.test(o)})},m=(t,e=s,r)=>({record:async o=>{const i=t.SHARD,a=typeof t.LUNORA_ADMIN_TOKEN=="string"?t.LUNORA_ADMIN_TOKEN:void 0;if(i===void 0||a===void 0)return{id:"uncaptured"};try{return{id:(await l(i,{adminToken:a,envelope:{args:o,functionPath:E},jurisdiction:r,label:"@lunora/mail: recording captured mail",shardKey:e})).result?.id??"captured"}}catch(u){return console.error("@lunora/mail: failed to record captured mail into the studio inbox —",u),{id:"uncaptured"}}}}),L=(t,e={})=>{const r=_(t,"MAIL_FROM");if(N(t))return n({from:r,transport:d(m(t,e.rootShard,e.jurisdiction))});if(e.cloudflareSend)return n({cloudflareSend:e.cloudflareSend,from:r});const o=typeof t.RESEND_API_KEY=="string"?t.RESEND_API_KEY:void 0;if(o!==void 0&&o!=="")return n({apiKey:o,from:r});throw new c("INTERNAL","@lunora/mail: no transport configured — provide `cloudflareSend` (a SEND_EMAIL binding) or RESEND_API_KEY, or run in a dev environment to capture.")};export{m as createCaptureSink,L as createMailerFromEnv,N as shouldCaptureMail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=Symbol.for("@lunora/mail.captureTransport"),a=r=>r[t]===!0,s=r=>({[t]:!0,send:async o=>r.record(o)});export{t as CAPTURE_TRANSPORT_BRAND,s as createCaptureTransport,a as isCaptureTransport};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as n}from"@lunora/errors";import{cloudflareEmailProvider as l}from"@visulima/email/providers/cloudflare-email";import{r as d,t as u,i as m}from"./provider-transport-DXmTG_xv.mjs";const E=r=>{const t=l({send:r.send});return{send:async e=>{await t.initialize();const o=e.cc!==void 0&&e.cc.length>0,s=e.bcc!==void 0&&e.bcc.length>0;if(o||s)throw new n("INTERNAL","@lunora/mail: Cloudflare Email Workers does not support cc/bcc — fan out one send per recipient instead");const{first:c,list:i}=d(e.to);if(i.length>1)throw new n("INTERNAL",`@lunora/mail: Cloudflare Email Workers is single-recipient but received ${String(i.length)} \`to\` addresses — fan out one send per recipient instead`);const a=await t.sendEmail(u(e,r.from,c));return m(a)}}};export{E as createCloudflareTransport};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";import{D as d,p as u}from"./shard-C0aRRoVy.mjs";const f="message could not be processed",h=(r,e)=>{console.error("@lunora/mail/inbound: dropping message —",r),e.message.setReject(f)},g=r=>{const e=r.onError??h;return async(n,t,s)=>{const a={ctx:s,env:t,message:n};try{const o=await r.parse(n.raw);if(r.verify&&await r.verify(o,a)===!1)throw new c("INTERNAL","@lunora/mail/inbound: sender verification rejected the message");await r.dispatch(o,a)}catch(o){await e(o,a)}}},i=32768,l=r=>{let e="";for(let n=0;n<r.length;n+=i)e+=String.fromCharCode(...r.subarray(n,n+i));return btoa(e)},E=r=>r.attachments.length===0?r:{...r,attachments:r.attachments.map(e=>{const{content:n}=e;if(typeof n=="string")return e;const t=n instanceof Uint8Array?n:new Uint8Array(n);return{...e,content:l(t),encoding:"base64"}})},y=r=>{const e=r.shardKey??d,n=r.resolveArgs??(t=>E(t));return async(t,s)=>{const a=r.adminToken??(typeof s.env.LUNORA_ADMIN_TOKEN=="string"?s.env.LUNORA_ADMIN_TOKEN:void 0);if(a===void 0||a==="")throw new c("INTERNAL","@lunora/mail/inbound: missing LUNORA_ADMIN_TOKEN — cannot authorize inbound dispatch to the shard RPC.");const o={args:n(t,s),functionPath:r.functionPath,shardKey:e};await u(r.shard,{adminToken:a,envelope:o,jurisdiction:r.jurisdiction,label:`@lunora/mail/inbound: dispatch to \`${r.functionPath}\``,shardKey:e})}};export{g as createInboundEmailHandler,y as dispatchToLunoraFunction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as f}from"@lunora/errors";import{a as l,b as n}from"./address-BQ5RUGdT.mjs";import{isCaptureTransport as o}from"./createCaptureTransport-CKc6NpZR.mjs";import{createCloudflareTransport as i}from"./createCloudflareTransport-E-UdW8Dc.mjs";import{toQueuedPayload as y}from"./consumeQueuedSend-8TXPj5o-.mjs";import b from"./renderEmail-BOUnr6i3.mjs";import h from"./createResendTransport-CG9s8iI9.mjs";const w=r=>{if(r.cloudflareSend)return i({from:r.from,send:r.cloudflareSend});if(r.apiKey)return h(r.apiKey,r.from);throw new f("INTERNAL","@lunora/mail: a transport is required — pass `transport`, `cloudflareSend` (Cloudflare Email Workers, the default), or `apiKey` (Resend)")},x=r=>{if(!r.from)throw new f("INTERNAL","@lunora/mail: `from` is required");const c=r.transport??w(r),d=async e=>{let{html:a}=e,{text:u}=e;if(e.react){const t=await b(e.react);a=a??t.html,u=u??t.text}if(l("subject",e.subject),e.headers)for(const[t,s]of Object.entries(e.headers))l(`header name "${t}"`,t),l(`header "${t}" value`,s);const m=e.from??r.from;return n({bcc:e.bcc,cc:e.cc,from:m,replyTo:e.replyTo,to:e.to}),{bcc:e.bcc,cc:e.cc,from:m,headers:e.headers,html:a,replyTo:e.replyTo,subject:e.subject,text:u,to:e.to}};return{queue:async e=>{if(!r.queue){if(o(c)){const u=await d(e);return await c.send(u),{queued:!0}}throw new f("INTERNAL","@lunora/mail: `queue` binding is required for mailer.queue()")}const a=await d(e);return await r.queue.send(y(a)),{queued:!0}},send:async e=>{const a=await d(e);return c.send(a)}}};export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resendProvider as a}from"@visulima/email/providers/resend";import{r as d,t as c,i as l}from"./provider-transport-DXmTG_xv.mjs";const u=(i,s)=>{const e=a({apiKey:i});return{send:async r=>{await e.initialize();const{first:n,list:t}=d(r.to),o=await e.sendEmail(c(r,s,t.length===1?n:t));return l(o)}}};export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"postal-mime";import{a as r}from"./address-BQ5RUGdT.mjs";const s=(o,e)=>{if(e!==void 0)return r(`inbound ${o}`,e),e},m=o=>o.address!==void 0&&o.address!==""?o.name?`${o.name} <${o.address}>`:o.address:o.group?o.group.map(e=>e.address??"").filter(e=>e!=="").join(", "):o.name??"",t=(o,e)=>new RegExp(String.raw`\b${e}=([a-zA-Z]+)`,"i").exec(o)?.[1]?.toLowerCase()??null,p=o=>o===void 0||o===""?{dkim:null,dmarc:null,spf:null}:{dkim:t(o,"dkim"),dmarc:t(o,"dmarc"),spf:t(o,"spf")},b=async o=>{const e=await u.parse(o),i={};for(const n of e.headers)r(`inbound header \`${n.key}\``,n.value),i[n.key]=n.value;const c=e.headers.find(n=>n.key==="authentication-results")?.value,f=(e.to??[]).map(n=>{const a=m(n);return r("inbound to",a),a}),d=e.from?m(e.from):"";return r("inbound from",d),{attachments:e.attachments.map(n=>({content:n.content,disposition:n.disposition,...n.encoding===void 0?{}:{encoding:n.encoding},filename:n.filename,mimeType:n.mimeType})),authentication:p(c),from:d,headers:i,...e.html===void 0?{}:{html:e.html},...s("inReplyTo",e.inReplyTo)===void 0?{}:{inReplyTo:e.inReplyTo},...s("messageId",e.messageId)===void 0?{}:{messageId:e.messageId},...s("references",e.references)===void 0?{}:{references:e.references},...s("subject",e.subject)===void 0?{}:{subject:e.subject},...e.text===void 0?{}:{text:e.text},to:f}};export{b as parseInboundEmail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as o}from"@lunora/errors";import{t as n,c as s}from"./address-BQ5RUGdT.mjs";const c=e=>e instanceof Error?e.message:e==null?"send failed":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?e.toString():JSON.stringify(e)??"send failed",u=e=>{const t=n(e),[i]=t??[];if(!t||i===void 0)throw new o("INTERNAL","@lunora/mail: at least one recipient is required");return{first:i,list:t}},d=(e,t,i)=>({bcc:n(e.bcc),cc:n(e.cc),from:s(e.from??t),headers:e.headers,html:e.html,replyTo:e.replyTo?s(e.replyTo):void 0,subject:e.subject,text:e.text,to:i}),m=e=>{if(!e.success||!e.data)throw console.error(`@lunora/mail: send failed: ${c(e.error)}`),new o("INTERNAL","@lunora/mail: send failed");return{id:e.data.messageId}};export{m as i,u as r,d as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{render as r}from"@react-email/render";const n=async t=>{const[e,a]=await Promise.all([r(t,{pretty:!1}),r(t,{plainText:!0})]);return{html:e,text:a}};export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as a}from"@lunora/errors";const u="__root__",s=(t,r)=>{if(r===void 0)return t;if(typeof t.jurisdiction!="function")throw new TypeError(`@lunora/mail: Durable Object namespace does not support jurisdiction("${r}") — update @cloudflare/workers-types or remove the jurisdiction option`);return t.jurisdiction(r)},l=async(t,r)=>{const i=s(t,r.jurisdiction),e=await i.get(i.idFromName(r.shardKey)).fetch("https://shard.internal/rpc",{body:JSON.stringify(r.envelope),headers:{authorization:`Bearer ${r.adminToken}`,"content-type":"application/json"},method:"POST"});if(e.ok===!1)throw new a("INTERNAL",`${r.label} failed (HTTP ${String(e.status??"?")}).`);const o=await e.json();if(typeof o=="object"&&o!==null&&"error"in o){const{error:n}=o;if(n!=null)throw new a("INTERNAL",`${r.label} returned an error: ${JSON.stringify(n)}`)}return o};export{u as D,l as p};
|
package/dist/testing.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as
|
|
1
|
+
import{LunoraError as s}from"@lunora/errors";const r="__lunora_admin__:getCapturedMail",l="/_lunora/rpc",u=/\/$/,d=async t=>new Promise(e=>{setTimeout(e,t)}),h=t=>Array.isArray(t.to)?t.to:[t.to],m=async t=>{const e=t.fetch??globalThis.fetch,n=`${t.baseUrl.replace(u,"")}${l}`,a=await e(n,{body:JSON.stringify({args:{limit:t.limit??50},functionPath:r}),headers:{authorization:`Bearer ${t.adminToken}`,"content-type":"application/json"},method:"POST"});if(!a.ok)throw new s("INTERNAL",`@lunora/mail/testing: getCapturedMail failed (HTTP ${String(a.status)})`);return(await a.json()).result?.entries??[]},A=async t=>{const e=t.timeoutMs??1e4,n=t.pollMs??250,a=Date.now()+e;for(;;){const i=(await m(t)).find(o=>h(o).includes(t.to)&&(t.subjectMatch===void 0||o.subject.includes(t.subjectMatch)));if(i)return i;if(Date.now()>=a)throw new s("INTERNAL",`@lunora/mail/testing: no mail to "${t.to}"${t.subjectMatch===void 0?"":` matching "${t.subjectMatch}"`} within ${String(e)}ms`);await d(n)}},f=/https?:\/\/[^\s"'<>)]+/g,T=/&(?:amp|#0*38|#x0*26);/giu,g=t=>t.replaceAll(T,"&"),M=(t,e={})=>{for(const n of[t.html,t.text]){if(n===void 0)continue;const c=(n.match(f)??[]).find(i=>e.match===void 0||i.includes(e.match));if(c!==void 0)return g(c)}throw new s("INTERNAL",`@lunora/mail/testing: no link${e.match===void 0?"":` containing "${e.match}"`} found in the captured message`)};export{M as extractLink,m as listCapturedMail,A as waitForMail};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/mail",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.49",
|
|
4
4
|
"description": "Email for Lunora: Resend adapter, TSX templates, and queue-backed sends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
57
|
+
"@lunora/errors": "1.0.0-alpha.21",
|
|
58
58
|
"@react-email/render": "2.1.0",
|
|
59
|
-
"@visulima/email": "2.1.
|
|
60
|
-
"postal-mime": "2.7.
|
|
59
|
+
"@visulima/email": "2.1.8",
|
|
60
|
+
"postal-mime": "2.7.6"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": "^19.2.7"
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{LunoraError as i}from"@lunora/errors";const r=320,l=256,s=/^([^<]*)<([^>]*)>\s*$/,o=(e,a)=>{if(a.includes("\r")||a.includes(`
|
|
2
|
-
`)||a.includes(","))throw new i("INTERNAL",`@lunora/mail: address ${e} must not contain CR, LF, or comma`)},h=(e,a)=>{if(a.includes("\r")||a.includes(`
|
|
3
|
-
`))throw new i("INTERNAL",`@lunora/mail: ${e} must not contain CR or LF`)},c=(e,a)=>{if(e.length>l)throw new i("INTERNAL",`@lunora/mail: address name must be <= ${String(l)} characters`);if(a.length>r)throw new i("INTERNAL",`@lunora/mail: address email must be <= ${String(r)} characters`);return e&&o("name",e),o("email",a),e?{email:a,name:e}:{email:a}},u=e=>{const a=e.trim();if(a.length>r)throw new i("INTERNAL",`@lunora/mail: address email must be <= ${String(r)} characters`);return o("email",a),{email:a}},n=e=>{const a=s.exec(e),m=(a?.[2]??"").trim();return a&&m?c((a[1]??"").trim(),m):u(e)},t=e=>e===void 0?void 0:(Array.isArray(e)?e:[e]).map(a=>n(a)),w=e=>{t(e.to),t(e.cc),t(e.bcc),e.from!==void 0&&n(e.from),e.replyTo!==void 0&&n(e.replyTo)};export{w as f,t as i,h as m,n as o};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as c}from"@lunora/errors";const g=a=>{const t={...a};return delete t.react,t},d=async(a,t)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new c("INTERNAL","@lunora/mail: queue message body must be an object");const e=t;if(typeof e.subject!="string")throw new TypeError("@lunora/mail: queue message must have a string `subject`");const m=typeof e.to=="string",y=Array.isArray(e.to)&&e.to.every(o=>typeof o=="string");if(!m&&!y)throw new c("INTERNAL","@lunora/mail: queue message `to` must be a string or string[]");const s=(o,r)=>{if(r!==void 0){if(typeof r!="string")throw new TypeError(`@lunora/mail: queue message \`${o}\` must be a string`);return r}},u=(o,r)=>{if(r!==void 0){if(typeof r=="string")return[r];if(Array.isArray(r)&&r.every(n=>typeof n=="string"))return r;throw new TypeError(`@lunora/mail: queue message \`${o}\` must be a string or string[]`)}};let i;if(e.headers!==void 0){if(!e.headers||typeof e.headers!="object"||Array.isArray(e.headers))throw new TypeError("@lunora/mail: queue message `headers` must be an object of string values");const o=Object.entries(e.headers);for(const[r,n]of o)if(typeof n!="string")throw new TypeError(`@lunora/mail: queue message header "${r}" must be a string`);i=e.headers}const f={bcc:u("bcc",e.bcc),cc:u("cc",e.cc),from:s("from",e.from),headers:i,html:s("html",e.html),replyTo:s("replyTo",e.replyTo),subject:e.subject,text:s("text",e.text),to:e.to};return a.send(f)};export{d as consumeQueuedSend,g as toQueuedPayload};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as u}from"@lunora/errors";import{createCaptureTransport as s}from"./createCaptureTransport-BPdMkU0O.mjs";import n from"./createMailer-BWaX1-ma.mjs";import{d as l,u as c}from"./shard-CcKsuWAm.mjs";const f="__lunora_admin__:recordMail",p=/^(?:dev(?:elopment)?|local(?:host)?|test)$/iu,m=["CF_ENV","ENVIRONMENT","NODE_ENV","WORKER_ENV"],E=(e,t)=>{const r=e[t];if(typeof r!="string"||r==="")throw new u("INTERNAL",`@lunora/mail: missing env var \`${t}\` — set it in .dev.vars (and \`wrangler secret put ${t}\` for secrets).`);return r},_=e=>{const t=e.LUNORA_MAIL_CAPTURE;if(typeof t=="string"){const r=t.toLowerCase();if(r==="1"||r==="true")return!0;if(r==="0"||r==="false")return!1;console.warn(`@lunora/mail: unrecognized LUNORA_MAIL_CAPTURE value "${t}" — expected "1"/"true" or "0"/"false"; falling back to environment detection.`)}return m.some(r=>{const o=e[r];return typeof o=="string"&&p.test(o)})},N=(e,t=l,r)=>({record:async o=>{const a=e.SHARD,i=typeof e.LUNORA_ADMIN_TOKEN=="string"?e.LUNORA_ADMIN_TOKEN:void 0;if(a===void 0||i===void 0)return{id:"uncaptured"};try{return{id:(await c(a,{adminToken:i,envelope:{args:o,functionPath:f},jurisdiction:r,label:"@lunora/mail: recording captured mail",shardKey:t})).result?.id??"captured"}}catch(d){return console.error("@lunora/mail: failed to record captured mail into the studio inbox —",d),{id:"uncaptured"}}}}),I=(e,t={})=>{const r=E(e,"MAIL_FROM");if(_(e))return n({from:r,transport:s(N(e,t.rootShard,t.jurisdiction))});if(t.cloudflareSend)return n({cloudflareSend:t.cloudflareSend,from:r});const o=typeof e.RESEND_API_KEY=="string"?e.RESEND_API_KEY:void 0;if(o!==void 0&&o!=="")return n({apiKey:o,from:r});throw new u("INTERNAL","@lunora/mail: no transport configured — provide `cloudflareSend` (a SEND_EMAIL binding) or RESEND_API_KEY, or run in a dev environment to capture.")};export{N as createCaptureSink,I as createMailerFromEnv,_ as shouldCaptureMail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const a=Symbol.for("@lunora/mail.captureTransport"),t=r=>r[a]===!0,o=r=>({[a]:!0,send:async e=>r.record(e)});export{a as CAPTURE_TRANSPORT_BRAND,o as createCaptureTransport,t as isCaptureTransport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as t}from"@lunora/errors";import{cloudflareEmailProvider as l}from"@visulima/email/providers/cloudflare-email";import{o as d,c as f,f as u}from"./provider-transport-BZngzyeS.mjs";const g=o=>{const n=l({send:o.send});return{send:async e=>{await n.initialize();const i=e.cc!==void 0&&e.cc.length>0,a=e.bcc!==void 0&&e.bcc.length>0;if(i||a)throw new t("INTERNAL","@lunora/mail: Cloudflare Email Workers does not support cc/bcc — fan out one send per recipient instead");const{first:s,list:r}=d(e.to);if(r.length>1)throw new t("INTERNAL",`@lunora/mail: Cloudflare Email Workers is single-recipient but received ${String(r.length)} \`to\` addresses — fan out one send per recipient instead`);const c=await n.sendEmail(f(e,o.from,s));return u(c)}}};export{g as createCloudflareTransport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as c}from"@lunora/errors";import{u as d,d as u}from"./shard-CcKsuWAm.mjs";const h="message could not be processed",m=(t,a)=>{console.error("@lunora/mail/inbound: dropping message —",t),a.message.setReject(h)},y=t=>{const a=t.onError??m;return async(e,n,s)=>{const r={ctx:s,env:n,message:e};try{const o=await t.parse(e.raw);if(t.verify&&await t.verify(o,r)===!1)throw new c("INTERNAL","@lunora/mail/inbound: sender verification rejected the message");await t.dispatch(o,r)}catch(o){await a(o,r)}}},i=32768,l=t=>{let a="";for(let e=0;e<t.length;e+=i)a+=String.fromCharCode(...t.subarray(e,e+i));return btoa(a)},f=t=>t.attachments.length===0?t:{...t,attachments:t.attachments.map(a=>{const{content:e}=a;if(typeof e=="string")return a;const n=e instanceof Uint8Array?e:new Uint8Array(e);return{...a,content:l(n),encoding:"base64"}})},N=t=>{const a=t.shardKey??u,e=t.resolveArgs??(n=>f(n));return async(n,s)=>{const r=t.adminToken??(typeof s.env.LUNORA_ADMIN_TOKEN=="string"?s.env.LUNORA_ADMIN_TOKEN:void 0);if(r===void 0||r==="")throw new c("INTERNAL","@lunora/mail/inbound: missing LUNORA_ADMIN_TOKEN — cannot authorize inbound dispatch to the shard RPC.");const o={args:e(n,s),functionPath:t.functionPath,shardKey:a};await d(t.shard,{adminToken:r,envelope:o,jurisdiction:t.jurisdiction,label:`@lunora/mail/inbound: dispatch to \`${t.functionPath}\``,shardKey:a})}};export{y as createInboundEmailHandler,N as dispatchToLunoraFunction};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as c}from"@lunora/errors";import{m as s,f}from"./address-Y4Z--6ZO.mjs";import{isCaptureTransport as d}from"./createCaptureTransport-BPdMkU0O.mjs";import{createCloudflareTransport as l}from"./createCloudflareTransport-V23CVw7F.mjs";import{toQueuedPayload as p}from"./consumeQueuedSend-CrfNFyMX.mjs";import h from"./renderEmail-DM8_pWKa.mjs";import w from"./createResendTransport-CpSJ4j7C.mjs";const y=e=>{if(e.cloudflareSend)return l({from:e.from,send:e.cloudflareSend});if(e.apiKey)return w(e.apiKey,e.from);throw new c("INTERNAL","@lunora/mail: a transport is required — pass `transport`, `cloudflareSend` (Cloudflare Email Workers, the default), or `apiKey` (Resend)")},L=e=>{if(!e.from)throw new c("INTERNAL","@lunora/mail: `from` is required");const u=e.transport??y(e),n=async r=>{let{html:t}=r,{text:a}=r;if(r.react){const o=await h(r.react);t=t??o.html,a=a??o.text}if(s("subject",r.subject),r.headers)for(const[o,m]of Object.entries(r.headers))s(`header name "${o}"`,o),s(`header "${o}" value`,m);const i=r.from??e.from;return f({bcc:r.bcc,cc:r.cc,from:i,replyTo:r.replyTo,to:r.to}),{bcc:r.bcc,cc:r.cc,from:i,headers:r.headers,html:t,replyTo:r.replyTo,subject:r.subject,text:a,to:r.to}};return{queue:async r=>{if(!e.queue){if(d(u)){const a=await n(r);return await u.send(a),{queued:!0}}throw new c("INTERNAL","@lunora/mail: `queue` binding is required for mailer.queue()")}const t=await n(r);return await e.queue.send(p(t)),{queued:!0}},send:async r=>{const t=await n(r);return u.send(t)}}};export{L as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{resendProvider as a}from"@visulima/email/providers/resend";import{o as m,c,f as d}from"./provider-transport-BZngzyeS.mjs";const p=(o,e)=>{const t=a({apiKey:o});return{send:async r=>{await t.initialize();const{first:n,list:i}=m(r.to),s=await t.sendEmail(c(r,e,i.length===1?n:i));return d(s)}}};export{p as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import l from"postal-mime";import{m as i}from"./address-Y4Z--6ZO.mjs";const s=(n,e)=>{if(e!==void 0)return i(`inbound ${n}`,e),e},m=n=>n.address!==void 0&&n.address!==""?n.name?`${n.name} <${n.address}>`:n.address:n.group?n.group.map(e=>e.address??"").filter(e=>e!=="").join(", "):n.name??"",a=(n,e)=>new RegExp(String.raw`\b${e}=([a-zA-Z]+)`,"i").exec(n)?.[1]?.toLowerCase()??null,p=n=>n===void 0||n===""?{dkim:null,dmarc:null,spf:null}:{dkim:a(n,"dkim"),dmarc:a(n,"dmarc"),spf:a(n,"spf")},g=async n=>{const e=await l.parse(n),d={};for(const o of e.headers)i(`inbound header \`${o.key}\``,o.value),d[o.key]=o.value;const c=e.headers.find(o=>o.key==="authentication-results")?.value,u=(e.to??[]).map(o=>{const r=m(o);return i("inbound to",r),r}),t=e.from?m(e.from):"";return i("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:p(c),from:t,headers:d,...e.html===void 0?{}:{html:e.html},...s("inReplyTo",e.inReplyTo)===void 0?{}:{inReplyTo:e.inReplyTo},...s("messageId",e.messageId)===void 0?{}:{messageId:e.messageId},...s("references",e.references)===void 0?{}:{references:e.references},...s("subject",e.subject)===void 0?{}:{subject:e.subject},...e.text===void 0?{}:{text:e.text},to:u}};export{g as parseInboundEmail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as s}from"@lunora/errors";import{i,o as n}from"./address-Y4Z--6ZO.mjs";const e=r=>r instanceof Error?r.message:r==null?"send failed":typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?r.toString():JSON.stringify(r)??"send failed",c=r=>{const o=i(r),[t]=o??[];if(!o||t===void 0)throw new s("INTERNAL","@lunora/mail: at least one recipient is required");return{first:t,list:o}},f=(r,o,t)=>({bcc:i(r.bcc),cc:i(r.cc),from:n(r.from??o),headers:r.headers,html:r.html,replyTo:r.replyTo?n(r.replyTo):void 0,subject:r.subject,text:r.text,to:t}),d=r=>{if(!r.success||!r.data)throw console.error(`@lunora/mail: send failed: ${e(r.error)}`),new s("INTERNAL","@lunora/mail: send failed");return{id:r.data.messageId}};export{f as c,d as f,c as o};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{render as e}from"@react-email/render";const n=async t=>{const[r,a]=await Promise.all([e(t,{pretty:!1}),e(t,{plainText:!0})]);return{html:r,text:a}};export{n as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as a}from"@lunora/errors";const c="__root__",s=(o,r)=>{if(r===void 0)return o;if(typeof o.jurisdiction!="function")throw new TypeError(`@lunora/mail: Durable Object namespace does not support jurisdiction("${r}") — update @cloudflare/workers-types or remove the jurisdiction option`);return o.jurisdiction(r)},d=async(o,r)=>{const i=s(o,r.jurisdiction),n=await i.get(i.idFromName(r.shardKey)).fetch("https://shard.internal/rpc",{body:JSON.stringify(r.envelope),headers:{authorization:`Bearer ${r.adminToken}`,"content-type":"application/json"},method:"POST"});if(n.ok===!1)throw new a("INTERNAL",`${r.label} failed (HTTP ${String(n.status??"?")}).`);const t=await n.json();if(typeof t=="object"&&t!==null&&"error"in t){const{error:e}=t;if(e!=null)throw new a("INTERNAL",`${r.label} returned an error: ${JSON.stringify(e)}`)}return t};export{c as d,d as u};
|