@lunora/mail 1.0.0-alpha.140 → 1.0.0-alpha.142
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.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{createCaptureSink-C489s13k.mjs → createCaptureSink-BCAMuG4n.mjs} +1 -1
- package/dist/packem_shared/{createInboundEmailHandler-BeWkwqF2.mjs → createInboundEmailHandler-ByzpfcEI.mjs} +1 -1
- package/dist/packem_shared/shard-Bgo7dYFl.mjs +1 -0
- package/package.json +5 -4
- package/dist/packem_shared/shard-C5t-b7FX.mjs +0 -1
package/dist/inbound/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInboundEmailHandler as n,dispatchToLunoraFunction as r}from"../packem_shared/createInboundEmailHandler-
|
|
1
|
+
import{createInboundEmailHandler as n,dispatchToLunoraFunction as r}from"../packem_shared/createInboundEmailHandler-ByzpfcEI.mjs";import{authenticatesFrom as t,parseInboundEmail as i}from"../packem_shared/authenticatesFrom-UBe_EgRT.mjs";export{t as authenticatesFrom,n as createInboundEmailHandler,r as dispatchToLunoraFunction,i as parseInboundEmail};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertValidIdempotencyKey as o}from"./packem_shared/assertValidIdempotencyKey-CyJq0nZq.mjs";import{createCaptureTransport as t}from"./packem_shared/createCaptureTransport-DZhMUmaI.mjs";import{createCloudflareTransport as p}from"./packem_shared/createCloudflareTransport-Dxjf_b6q.mjs";import{default as m}from"./packem_shared/createMailer-Cv1B9wYq.mjs";import{createCaptureSink as u,createMailerFromEnv as f,shouldCaptureMail as s}from"./packem_shared/createCaptureSink-
|
|
1
|
+
import{assertValidIdempotencyKey as o}from"./packem_shared/assertValidIdempotencyKey-CyJq0nZq.mjs";import{createCaptureTransport as t}from"./packem_shared/createCaptureTransport-DZhMUmaI.mjs";import{createCloudflareTransport as p}from"./packem_shared/createCloudflareTransport-Dxjf_b6q.mjs";import{default as m}from"./packem_shared/createMailer-Cv1B9wYq.mjs";import{createCaptureSink as u,createMailerFromEnv as f,shouldCaptureMail as s}from"./packem_shared/createCaptureSink-BCAMuG4n.mjs";import{consumeQueuedSend as c,toQueuedPayload as x}from"./packem_shared/consumeQueuedSend-BwNGdlaG.mjs";import{default as E}from"./packem_shared/renderEmail-xypKDdux.mjs";import{default as C}from"./packem_shared/createResendTransport-CsJfCLAP.mjs";import{MailSendError as T,isOutcomeUnknownMailError as k,isRetryableMailError as Q}from"./packem_shared/MailSendError-BYih5mnM.mjs";export{T as MailSendError,o as assertValidIdempotencyKey,c as consumeQueuedSend,u as createCaptureSink,t as createCaptureTransport,p as createCloudflareTransport,m as createMailer,f as createMailerFromEnv,C as createResendTransport,k as isOutcomeUnknownMailError,Q as isRetryableMailError,E as renderEmail,s as shouldCaptureMail,x as toQueuedPayload};
|
package/dist/packem_shared/{createCaptureSink-C489s13k.mjs → createCaptureSink-BCAMuG4n.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./assertValidIdempotencyKey-CyJq0nZq.mjs";import{createCaptureTransport as c}from"./createCaptureTransport-DZhMUmaI.mjs";import"./createCloudflareTransport-Dxjf_b6q.mjs";import s from"./createMailer-Cv1B9wYq.mjs";import{LunoraError as l}from"@lunora/errors";import{D as m,a as p,p as E}from"./shard-
|
|
1
|
+
import"./assertValidIdempotencyKey-CyJq0nZq.mjs";import{createCaptureTransport as c}from"./createCaptureTransport-DZhMUmaI.mjs";import"./createCloudflareTransport-Dxjf_b6q.mjs";import s from"./createMailer-Cv1B9wYq.mjs";import{LunoraError as l}from"@lunora/errors";import{D as m,a as p,p as E}from"./shard-Bgo7dYFl.mjs";import"./consumeQueuedSend-BwNGdlaG.mjs";import"./renderEmail-xypKDdux.mjs";import"./createResendTransport-CsJfCLAP.mjs";import"./MailSendError-BYih5mnM.mjs";const _="__lunora_admin__:recordMail",N=/^(?:dev(?:elopment)?|local(?:host)?|test)$/iu,f=["CF_ENV","ENVIRONMENT","NODE_ENV","WORKER_ENV"],R=(e,r)=>{const o=e[r];if(typeof o!="string"||o==="")throw new l("INTERNAL",`@lunora/mail: missing env var \`${r}\` — set it in .dev.vars (and \`wrangler secret put ${r}\` for secrets).`);return o},A=e=>{const r=e.LUNORA_MAIL_CAPTURE;if(typeof r=="string"){const t=r.toLowerCase();if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;console.warn(`@lunora/mail: unrecognized LUNORA_MAIL_CAPTURE value "${r}" — expected "1"/"true" or "0"/"false"; falling back to environment detection.`)}const o=f.map(t=>e[t]).filter(t=>typeof t=="string"&&t!=="");return o.length>0&&o.every(t=>N.test(t))};let u=!1;const T=(e,r=m,o)=>({record:async t=>{const i=e.SHARD,a=typeof e.LUNORA_ADMIN_TOKEN=="string"?e.LUNORA_ADMIN_TOKEN:void 0;if(i===void 0||a===void 0)return u||(u=!0,console.warn("@lunora/mail: capturing mail but there is nowhere to record it — the `SHARD` binding and/or `LUNORA_ADMIN_TOKEN` is missing, so every captured message is discarded. Set both to see mail in the studio inbox, or set LUNORA_MAIL_CAPTURE=0 to deliver for real.")),{id:"uncaptured"};const d=p(i,o);try{return{id:(await E(d,{adminToken:a,envelope:{args:t,functionPath:_},label:"@lunora/mail: recording captured mail",shardKey:r})).result?.id??"captured"}}catch(n){return console.error("@lunora/mail: failed to record captured mail into the studio inbox —",n),{id:"uncaptured"}}}}),v=(e,r={})=>{const o=R(e,"MAIL_FROM");if(A(e))return s({from:o,queue:r.queue,sendTimeoutMs:r.sendTimeoutMs,transport:c(T(e,r.rootShard,r.jurisdiction))});const{cloudflareSend:t}=r,i=typeof e.RESEND_API_KEY=="string"&&e.RESEND_API_KEY!==""?e.RESEND_API_KEY:void 0;return s({apiKey:i,cloudflareSend:t,from:o,queue:r.queue,sendTimeoutMs:r.sendTimeoutMs})};export{T as createCaptureSink,v as createMailerFromEnv,A as shouldCaptureMail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as c}from"@lunora/errors";import{D as l,p as f,a as w}from"./shard-
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";import{D as l,p as f,a as w}from"./shard-Bgo7dYFl.mjs";const E=r=>{let n="";for(let e=0;e<r.length;e+=32768)n+=String.fromCharCode(...r.subarray(e,e+32768));return btoa(n)},b="message could not be processed",y=10*1024*1024,h=(r,n)=>{console.error("@lunora/mail/inbound: dropping message —",r),n.message.setReject(b)},m=r=>r===!0||r===void 0,A=(r,n)=>{if(typeof r.rawSize!="number"||!Number.isFinite(r.rawSize))throw new c("INTERNAL","@lunora/mail/inbound: message has no rawSize, so its size cannot be checked against maxRawBytes");if(r.rawSize>n)throw new c("INTERNAL",`@lunora/mail/inbound: message is ${String(r.rawSize)} bytes, over the ${String(n)}-byte limit (maxRawBytes)`)},S=r=>{const n=r.onError??h,t=r.maxRawBytes??y;if(!Number.isFinite(t)||t<=0)throw new c("INTERNAL","@lunora/mail/inbound: `maxRawBytes` must be a positive, finite number of bytes");return async(e,a,i)=>{const o={ctx:i,env:a,message:e};let u;try{if(A(e,t),u=await r.parse(e.raw),r.verify){const s=await r.verify(u,o);if(!m(s))throw new c("INTERNAL","@lunora/mail/inbound: sender verification rejected the message")}}catch(s){await n(s,o);return}try{await r.dispatch(u,o)}catch(s){if(r.onError)try{await r.onError(s,o)}catch(d){console.error("@lunora/mail/inbound: onError threw while reporting a dispatch failure —",d)}if(r.retain)try{await r.retain(u,o,s);return}catch(d){console.error("@lunora/mail/inbound: retain failed to take ownership of the message —",d)}h(s,o)}}},g=4*1024*1024,N=/={1,2}$/,R=(r,n)=>{if(n!=="base64")return new TextEncoder().encode(r).byteLength;const t=N.exec(r)?.[0].length??0;return Math.floor(r.length*3/4)-t},T=r=>{if(r.attachments.length===0)return r;let n=0;return{...r,attachments:r.attachments.map(t=>{const{content:e}=t,a=typeof e=="string"?R(e,t.encoding):e.byteLength;if(n+a>g)return{...t,content:"",encoding:"base64",truncated:!0};if(n+=a,typeof e=="string")return t;const i=e instanceof Uint8Array?e:new Uint8Array(e);return{...t,content:E(i),encoding:"base64"}})}},v=r=>{const n=r.shardKey??l,t=r.resolveArgs??(e=>T(e));return async(e,a)=>{const i=r.adminToken??(typeof a.env.LUNORA_ADMIN_TOKEN=="string"?a.env.LUNORA_ADMIN_TOKEN:void 0);if(i===void 0||i==="")throw new c("INTERNAL","@lunora/mail/inbound: missing LUNORA_ADMIN_TOKEN — cannot authorize inbound dispatch to the shard RPC.");const o={args:t(e,a),functionPath:r.functionPath,shardKey:n};await f(w(r.shard,r.jurisdiction),{adminToken:i,envelope:o,label:`@lunora/mail/inbound: dispatch to \`${r.functionPath}\``,shardKey:n})}};export{S as createInboundEmailHandler,v as dispatchToLunoraFunction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as s}from"@lunora/errors";import{encodeWire as a}from"@lunora/wire";const c=Symbol.for("lunora:app-jurisdiction"),d=globalThis,l=()=>d[c],f="__root__",h=(t,r)=>{const e=l();if(r!==void 0&&e!==void 0&&r!==e)throw new TypeError(`@lunora/mail: jurisdiction "${r}" contradicts the app's declared jurisdiction "${e}" — drop the option; mail follows the schema's \`.jurisdiction()\``);const o=r??e;if(o===void 0)return t;if(typeof t.jurisdiction!="function")throw new TypeError(`@lunora/mail: Durable Object namespace does not support jurisdiction("${o}") — update @cloudflare/workers-types or remove the jurisdiction`);return t.jurisdiction(o)},y=async(t,r)=>{const o=await t.get(t.idFromName(r.shardKey)).fetch("https://shard.internal/rpc",{body:JSON.stringify({...r.envelope,args:r.envelope.args===void 0?void 0:a(r.envelope.args)}),headers:{authorization:`Bearer ${r.adminToken}`,"content-type":"application/json","x-lunora-system":"1"},method:"POST"});if(o.ok===!1)throw new s("INTERNAL",`${r.label} failed (HTTP ${String(o.status??"?")}).`);const i=await o.json();if(typeof i=="object"&&i!==null&&"error"in i){const{error:n}=i;if(n!=null)throw new s("INTERNAL",`${r.label} returned an error: ${JSON.stringify(n)}`)}return i};export{f as D,h as a,y as p};
|
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.142",
|
|
4
4
|
"description": "Email for Lunora: Resend adapter, TSX templates, and queue-backed sends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -55,9 +55,10 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"
|
|
58
|
+
"@lunora/wire": "^1.0.0-alpha.7",
|
|
59
|
+
"@react-email/render": "2.3.1",
|
|
60
|
+
"@visulima/email": "4.2.1",
|
|
61
|
+
"postal-mime": "4.2.1"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"react": "^19.2.7"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as s}from"@lunora/errors";const a=Symbol.for("lunora:app-jurisdiction"),c=globalThis,l=()=>c[a],u="__root__",p=(t,o)=>{const e=l();if(o!==void 0&&e!==void 0&&o!==e)throw new TypeError(`@lunora/mail: jurisdiction "${o}" contradicts the app's declared jurisdiction "${e}" — drop the option; mail follows the schema's \`.jurisdiction()\``);const r=o??e;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`);return t.jurisdiction(r)},f=async(t,o)=>{const r=await t.get(t.idFromName(o.shardKey)).fetch("https://shard.internal/rpc",{body:JSON.stringify(o.envelope),headers:{authorization:`Bearer ${o.adminToken}`,"content-type":"application/json","x-lunora-system":"1"},method:"POST"});if(r.ok===!1)throw new s("INTERNAL",`${o.label} failed (HTTP ${String(r.status??"?")}).`);const i=await r.json();if(typeof i=="object"&&i!==null&&"error"in i){const{error:n}=i;if(n!=null)throw new s("INTERNAL",`${o.label} returned an error: ${JSON.stringify(n)}`)}return i};export{u as D,p as a,f as p};
|