@agenticmail/core 0.2.26

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.
@@ -0,0 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
@@ -0,0 +1,39 @@
1
+ import "./chunk-3RG5ZIWI.js";
2
+
3
+ // src/gateway/email-worker-template.ts
4
+ var EMAIL_WORKER_SCRIPT = `
5
+ export default {
6
+ async email(message, env, ctx) {
7
+ // Read the raw RFC822 stream into an ArrayBuffer, then base64-encode
8
+ // because the inbound endpoint expects base64 in the rawEmail field.
9
+ const arrayBuf = await new Response(message.raw).arrayBuffer();
10
+ const bytes = new Uint8Array(arrayBuf);
11
+ let binary = '';
12
+ for (let i = 0; i < bytes.length; i++) {
13
+ binary += String.fromCharCode(bytes[i]);
14
+ }
15
+ const rawEmail = btoa(binary);
16
+
17
+ const response = await fetch(env.INBOUND_URL, {
18
+ method: 'POST',
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ 'X-Inbound-Secret': env.INBOUND_SECRET,
22
+ },
23
+ body: JSON.stringify({
24
+ from: message.from,
25
+ to: message.to,
26
+ rawEmail,
27
+ }),
28
+ });
29
+
30
+ if (!response.ok) {
31
+ // Log but don't reject \u2014 rejecting causes bounce-back to sender
32
+ console.error('AgenticMail inbound webhook failed:', response.status, await response.text());
33
+ }
34
+ },
35
+ };
36
+ `;
37
+ export {
38
+ EMAIL_WORKER_SCRIPT
39
+ };