@lunora/mail 1.0.0-alpha.121 → 1.0.0-alpha.122
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
CHANGED
|
@@ -14,6 +14,8 @@ interface InboundAttachment {
|
|
|
14
14
|
filename: string | null;
|
|
15
15
|
/** Declared MIME type (e.g. `image/png`). */
|
|
16
16
|
mimeType: string;
|
|
17
|
+
/** Binary content dropped because the forwarded envelope exceeded the attachment byte budget. */
|
|
18
|
+
truncated?: boolean;
|
|
17
19
|
}
|
|
18
20
|
/** One reported `method=result [ptype.property=value]` clause of an `Authentication-Results` header. */
|
|
19
21
|
interface InboundAuthResult {
|
package/dist/inbound/index.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ interface InboundAttachment {
|
|
|
14
14
|
filename: string | null;
|
|
15
15
|
/** Declared MIME type (e.g. `image/png`). */
|
|
16
16
|
mimeType: string;
|
|
17
|
+
/** Binary content dropped because the forwarded envelope exceeded the attachment byte budget. */
|
|
18
|
+
truncated?: boolean;
|
|
17
19
|
}
|
|
18
20
|
/** One reported `method=result [ptype.property=value]` clause of an `Authentication-Results` header. */
|
|
19
21
|
interface InboundAuthResult {
|
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-CixBJpmc.mjs";import{authenticatesFrom as t,parseInboundEmail as i}from"../packem_shared/authenticatesFrom-BOX-Paur.mjs";export{t as authenticatesFrom,n as createInboundEmailHandler,r as dispatchToLunoraFunction,i as parseInboundEmail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as u}from"@lunora/errors";import{D as h,p as l,a as f}from"./shard-C5t-b7FX.mjs";const E=r=>{let e="";for(let n=0;n<r.length;n+=32768)e+=String.fromCharCode(...r.subarray(n,n+32768));return btoa(e)},g="message could not be processed",d=(r,e)=>{console.error("@lunora/mail/inbound: dropping message —",r),e.message.setReject(g)},y=r=>r===!0||r===void 0,R=r=>{const e=r.onError??d;return async(t,n,a)=>{const o={ctx:a,env:n,message:t};let s;try{if(s=await r.parse(t.raw),r.verify){const i=await r.verify(s,o);if(!y(i))throw new u("INTERNAL","@lunora/mail/inbound: sender verification rejected the message")}}catch(i){await e(i,o);return}try{await r.dispatch(s,o)}catch(i){if(r.onError)try{await r.onError(i,o)}catch(c){console.error("@lunora/mail/inbound: onError threw while reporting a dispatch failure —",c)}if(r.retain)try{await r.retain(s,o,i);return}catch(c){console.error("@lunora/mail/inbound: retain failed to take ownership of the message —",c)}d(i,o)}}},A=4*1024*1024,b=/={1,2}$/,w=(r,e)=>{if(e!=="base64")return new TextEncoder().encode(r).byteLength;const t=b.exec(r)?.[0].length??0;return Math.floor(r.length*3/4)-t},N=r=>{if(r.attachments.length===0)return r;let e=0;return{...r,attachments:r.attachments.map(t=>{const{content:n}=t,a=typeof n=="string"?w(n,t.encoding):n.byteLength;if(e+a>A)return{...t,content:"",encoding:"base64",truncated:!0};if(e+=a,typeof n=="string")return t;const o=n instanceof Uint8Array?n:new Uint8Array(n);return{...t,content:E(o),encoding:"base64"}})}},_=r=>{const e=r.shardKey??h,t=r.resolveArgs??(n=>N(n));return async(n,a)=>{const o=r.adminToken??(typeof a.env.LUNORA_ADMIN_TOKEN=="string"?a.env.LUNORA_ADMIN_TOKEN:void 0);if(o===void 0||o==="")throw new u("INTERNAL","@lunora/mail/inbound: missing LUNORA_ADMIN_TOKEN — cannot authorize inbound dispatch to the shard RPC.");const s={args:t(n,a),functionPath:r.functionPath,shardKey:e};await l(f(r.shard,r.jurisdiction),{adminToken:o,envelope:s,label:`@lunora/mail/inbound: dispatch to \`${r.functionPath}\``,shardKey:e})}};export{R as createInboundEmailHandler,_ as dispatchToLunoraFunction};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as d}from"@lunora/errors";import{D as h,p as l,a as f}from"./shard-C5t-b7FX.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)},m="message could not be processed",u=(r,n)=>{console.error("@lunora/mail/inbound: dropping message —",r),n.message.setReject(m)},y=r=>r===!0||r===void 0,N=r=>{const n=r.onError??u;return async(t,e,c)=>{const a={ctx:c,env:e,message:t};let i;try{if(i=await r.parse(t.raw),r.verify){const o=await r.verify(i,a);if(!y(o))throw new d("INTERNAL","@lunora/mail/inbound: sender verification rejected the message")}}catch(o){await n(o,a);return}try{await r.dispatch(i,a)}catch(o){if(r.onError)try{await r.onError(o,a)}catch(s){console.error("@lunora/mail/inbound: onError threw while reporting a dispatch failure —",s)}if(r.retain)try{await r.retain(i,a,o);return}catch(s){console.error("@lunora/mail/inbound: retain failed to take ownership of the message —",s)}u(o,a)}}},g=r=>r.attachments.length===0?r:{...r,attachments:r.attachments.map(n=>{const{content:t}=n;if(typeof t=="string")return n;const e=t instanceof Uint8Array?t:new Uint8Array(t);return{...n,content:E(e),encoding:"base64"}})},b=r=>{const n=r.shardKey??h,t=r.resolveArgs??(e=>g(e));return async(e,c)=>{const a=r.adminToken??(typeof c.env.LUNORA_ADMIN_TOKEN=="string"?c.env.LUNORA_ADMIN_TOKEN:void 0);if(a===void 0||a==="")throw new d("INTERNAL","@lunora/mail/inbound: missing LUNORA_ADMIN_TOKEN — cannot authorize inbound dispatch to the shard RPC.");const i={args:t(e,c),functionPath:r.functionPath,shardKey:n};await l(f(r.shard,r.jurisdiction),{adminToken:a,envelope:i,label:`@lunora/mail/inbound: dispatch to \`${r.functionPath}\``,shardKey:n})}};export{N as createInboundEmailHandler,b as dispatchToLunoraFunction};
|