@open-workspace/email 0.3.0 → 0.4.0

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.
Files changed (221) hide show
  1. package/README.md +22 -22
  2. package/alchemy/index.ts +273 -0
  3. package/drizzle/mailbox/0000_puzzling_dracula.sql +149 -0
  4. package/drizzle/mailbox/0001_mute_jack_flag.sql +12 -0
  5. package/drizzle/mailbox/meta/0000_snapshot.json +1002 -0
  6. package/drizzle/mailbox/meta/0001_snapshot.json +1002 -0
  7. package/drizzle/mailbox/meta/_journal.json +20 -0
  8. package/drizzle/mailbox/migrations.js +12 -0
  9. package/index.ts +3 -1
  10. package/migrations/{0000_email.sql → 0000_dry_moon_knight.sql} +26 -20
  11. package/migrations/meta/0000_snapshot.json +125 -109
  12. package/migrations/meta/_journal.json +2 -2
  13. package/package.json +74 -68
  14. package/shared/attachment-preview.ts +37 -27
  15. package/shared/folder-order.ts +106 -0
  16. package/shared/mail-authentication.ts +8 -3
  17. package/shared/mail-feedback.ts +18 -25
  18. package/shared/mail-headers.ts +114 -39
  19. package/shared/mail-import.ts +38 -0
  20. package/shared/mail-path.ts +42 -0
  21. package/shared/mail-received.ts +174 -31
  22. package/shared/mail-remote.ts +59 -2
  23. package/shared/mail-sender-intel.ts +22 -4
  24. package/shared/mail.ts +77 -28
  25. package/shared/module.ts +33 -0
  26. package/shared/office-preview.ts +14 -2
  27. package/shared/pdfjs-assets.ts +35 -0
  28. package/shared/permissions.ts +73 -0
  29. package/shared/webhooks.ts +41 -0
  30. package/src/admin/blocked-senders.tsx +189 -0
  31. package/src/client.tsx +97 -0
  32. package/src/lib/mail-api.ts +9 -0
  33. package/src/mail/attachment-preview-dialog.tsx +161 -0
  34. package/src/mail/blocked-senders.tsx +138 -0
  35. package/src/mail/compose-window-chrome.tsx +194 -0
  36. package/src/mail/compose-window.tsx +486 -0
  37. package/src/mail/composer-asset-bookmarks.ts +409 -0
  38. package/src/mail/composer-asset.tsx +229 -0
  39. package/src/mail/composer-attachment-list.tsx +138 -0
  40. package/src/mail/composer-editor-document.ts +65 -0
  41. package/src/mail/composer-editor.tsx +284 -0
  42. package/src/mail/composer-linked-attachment-text.ts +12 -0
  43. package/src/mail/composer-recipient-fields.tsx +165 -0
  44. package/src/mail/composer-recipients.ts +208 -0
  45. package/src/mail/composer-session.ts +562 -0
  46. package/src/mail/composer-toolbar.tsx +303 -0
  47. package/src/mail/composer-upload-client.ts +105 -0
  48. package/src/mail/composer-upload-progress.ts +53 -0
  49. package/src/mail/conversation-list.tsx +550 -0
  50. package/src/mail/conversation-loading-skeleton.tsx +119 -0
  51. package/src/mail/conversation-message.tsx +346 -0
  52. package/src/mail/conversation-reply.tsx +470 -0
  53. package/src/mail/conversation-selection-toolbar.tsx +322 -0
  54. package/src/mail/conversation-view.tsx +437 -0
  55. package/src/mail/delivery-indicator.tsx +272 -0
  56. package/src/mail/email-html-body.tsx +203 -0
  57. package/src/mail/folder-glyph.tsx +46 -0
  58. package/src/mail/folder-manager.tsx +532 -0
  59. package/src/mail/format-bytes.ts +7 -0
  60. package/src/mail/mail-app-bar.tsx +253 -0
  61. package/src/mail/mail-background.tsx +12 -0
  62. package/src/mail/mail-dock.tsx +137 -0
  63. package/src/mail/mail-folders.ts +44 -0
  64. package/src/mail/mail-layout.css +236 -0
  65. package/src/mail/mail-location.ts +73 -0
  66. package/src/mail/mail-mailbox-sheet.tsx +275 -0
  67. package/src/mail/mail-nav-rail.tsx +129 -0
  68. package/src/mail/mail-nav.tsx +324 -0
  69. package/src/mail/mail-prefetch.ts +59 -0
  70. package/src/mail/mail-primitives.tsx +66 -0
  71. package/src/mail/mail-queries.ts +209 -0
  72. package/src/mail/mail-query-cache.ts +486 -0
  73. package/src/mail/mail-seed.ts +47 -0
  74. package/src/mail/mail-shell.tsx +126 -0
  75. package/src/mail/mailbox-ai-settings.tsx +185 -0
  76. package/src/mail/mailbox-realtime.tsx +251 -0
  77. package/src/mail/mailbox-route.tsx +15 -0
  78. package/src/mail/message-actions.tsx +353 -0
  79. package/src/mail/message-attachments.tsx +200 -0
  80. package/src/mail/message-format.ts +75 -0
  81. package/src/mail/message-header.tsx +260 -0
  82. package/src/mail/message-translation.tsx +225 -0
  83. package/src/mail/original-message-sheet.tsx +619 -0
  84. package/src/mail/original-message.ts +191 -0
  85. package/src/mail/outbound-notification.ts +53 -0
  86. package/src/mail/pane-splitter.tsx +117 -0
  87. package/src/mail/pdf-preview-toolbar.tsx +152 -0
  88. package/src/mail/pdf-preview.css +44 -0
  89. package/src/mail/pdf-preview.tsx +156 -0
  90. package/src/mail/pdf-translation-layout.ts +95 -0
  91. package/src/mail/print-message.ts +92 -0
  92. package/src/mail/reader-pane.tsx +535 -0
  93. package/src/mail/recipient-combobox.tsx +335 -0
  94. package/src/mail/recipient-field-row.tsx +34 -0
  95. package/src/mail/reply-to-warning.tsx +50 -0
  96. package/src/mail/sanitize-email-html.ts +430 -0
  97. package/src/mail/sender-actions.tsx +149 -0
  98. package/src/mail/sender-authentication.tsx +485 -0
  99. package/src/mail/sender-dialogs.tsx +384 -0
  100. package/src/mail/sender-security.tsx +545 -0
  101. package/src/mail/toolbar-tooltip.tsx +29 -0
  102. package/src/mail/translation-html.ts +49 -0
  103. package/src/mail/translation-language.ts +21 -0
  104. package/src/mail/types.ts +53 -0
  105. package/src/mail/unread-document-indicator.tsx +60 -0
  106. package/src/mail/use-compose-submission.ts +208 -0
  107. package/src/mail/use-composer-attachment-preflight.ts +184 -0
  108. package/src/mail/use-composer-submission.ts +117 -0
  109. package/src/mail/use-conversation-selection.ts +186 -0
  110. package/src/mail/use-mail-controller.ts +427 -0
  111. package/src/mail/use-mail-data.ts +279 -0
  112. package/src/mail/use-mail-safety.ts +155 -0
  113. package/src/mail/use-mail-send.ts +142 -0
  114. package/src/mail/use-pdf-translation-overlay.ts +156 -0
  115. package/src/mail/use-pdf-translation.ts +100 -0
  116. package/src/mail/use-pdf-viewer.ts +215 -0
  117. package/src/mail/use-reply-submission.ts +114 -0
  118. package/src/mail/use-sanitized-email-html.ts +20 -0
  119. package/src/mail/use-visible-message-read.ts +138 -0
  120. package/src/pwa/push-subscription.ts +151 -0
  121. package/src/settings/mail-apps-page.tsx +235 -0
  122. package/src/settings/notifications-page.tsx +291 -0
  123. package/worker/admin/blocked-sender-routes.ts +166 -0
  124. package/worker/admin/schemas.ts +11 -0
  125. package/worker/bindings.d.ts +14 -10
  126. package/worker/db/schema.ts +63 -40
  127. package/worker/jmap/eventsource.ts +84 -16
  128. package/worker/jmap/methods.ts +1630 -524
  129. package/worker/jmap/push-types.ts +27 -0
  130. package/worker/jmap/push.ts +140 -56
  131. package/worker/jmap/routes.ts +366 -105
  132. package/worker/mail/access.ts +258 -21
  133. package/worker/mail/ai-classification.ts +36 -20
  134. package/worker/mail/ai-translation.ts +13 -6
  135. package/worker/mail/auth-headers.ts +395 -137
  136. package/worker/mail/bimi.ts +200 -73
  137. package/worker/mail/bootstrap.ts +79 -0
  138. package/worker/mail/capped-body.ts +36 -0
  139. package/worker/mail/classification-signals.ts +35 -25
  140. package/worker/mail/conversation-cursor.ts +30 -19
  141. package/worker/mail/delivery-events.ts +88 -62
  142. package/worker/mail/delivery-facts.ts +46 -10
  143. package/worker/mail/demo-routes.ts +34 -10
  144. package/worker/mail/doh.ts +62 -23
  145. package/worker/mail/downloads.ts +75 -40
  146. package/worker/mail/edge-cache.ts +155 -0
  147. package/worker/mail/header-metadata.ts +88 -22
  148. package/worker/mail/impersonation.ts +160 -38
  149. package/worker/mail/import-routes.ts +313 -0
  150. package/worker/mail/inbound-delivery.ts +19 -9
  151. package/worker/mail/inbound-threading.ts +18 -8
  152. package/worker/mail/inbound.ts +82 -40
  153. package/worker/mail/ip-intel.ts +110 -27
  154. package/worker/mail/isolate-cache.ts +35 -0
  155. package/worker/mail/link-domains.ts +29 -7
  156. package/worker/mail/mailbox-deletion.ts +10 -4
  157. package/worker/mail/mailbox-directory.ts +16 -6
  158. package/worker/mail/mailing-list.ts +94 -39
  159. package/worker/mail/message-security.ts +90 -15
  160. package/worker/mail/message-view.ts +18 -6
  161. package/worker/mail/office-conversion.ts +31 -9
  162. package/worker/mail/office-preview-container.ts +40 -13
  163. package/worker/mail/office-preview-queue.ts +76 -32
  164. package/worker/mail/org-domain.ts +8 -1
  165. package/worker/mail/outbound-content.ts +71 -26
  166. package/worker/mail/outbound-delivery.ts +31 -17
  167. package/worker/mail/outbound-service.ts +48 -30
  168. package/worker/mail/outbound-threading.ts +30 -17
  169. package/worker/mail/outbound.ts +97 -70
  170. package/worker/mail/outgoing-context.ts +25 -15
  171. package/worker/mail/participants.ts +44 -29
  172. package/worker/mail/push-notifications.ts +271 -173
  173. package/worker/mail/quote-parser.ts +21 -10
  174. package/worker/mail/r2-presigned-urls.ts +31 -25
  175. package/worker/mail/receive.ts +23 -11
  176. package/worker/mail/recipients.ts +6 -1
  177. package/worker/mail/remote-proxy.ts +187 -31
  178. package/worker/mail/remote-routes.ts +87 -0
  179. package/worker/mail/remote-token.ts +104 -0
  180. package/worker/mail/repeat.ts +19 -0
  181. package/worker/mail/reply-plan.ts +62 -33
  182. package/worker/mail/rfc.ts +32 -7
  183. package/worker/mail/routes.ts +870 -541
  184. package/worker/mail/safety-routes.ts +328 -200
  185. package/worker/mail/schemas.ts +84 -105
  186. package/worker/mail/search.ts +1 -0
  187. package/worker/mail/security-settings.ts +41 -9
  188. package/worker/mail/sender-intel.ts +206 -51
  189. package/worker/mail/spamhaus.ts +92 -45
  190. package/worker/mail/unsubscribe.ts +76 -18
  191. package/worker/mail/uploads.ts +126 -93
  192. package/worker/mail/webhook-source.ts +35 -12
  193. package/worker/mail/workspace-safety.ts +97 -38
  194. package/worker/mailbox/demo-html.ts +7 -7
  195. package/worker/mailbox/demo-seed.ts +10 -44
  196. package/worker/mailbox/demo.ts +595 -225
  197. package/worker/mailbox/email-index.ts +53 -0
  198. package/worker/mailbox/folder-model.ts +53 -17
  199. package/worker/mailbox/import-placement.ts +88 -0
  200. package/worker/mailbox/inbox-counts.ts +106 -0
  201. package/worker/mailbox/index.ts +1734 -721
  202. package/worker/mailbox/jmap-store.ts +139 -35
  203. package/worker/mailbox/model.ts +8 -6
  204. package/worker/mailbox/office-preview-jobs.ts +56 -25
  205. package/worker/mailbox/schema.ts +87 -66
  206. package/worker/mailbox/senders.ts +176 -70
  207. package/worker/mcp/mail-action-tools.ts +128 -87
  208. package/worker/mcp/mail-compose-tools.ts +133 -82
  209. package/worker/mcp/mail-query-tools.ts +120 -71
  210. package/worker/mcp/mail-safety-tools.ts +321 -248
  211. package/worker/mcp/schemas.ts +43 -0
  212. package/worker/mcp/tools.ts +13 -10
  213. package/worker/module.ts +43 -18
  214. package/worker/sql.d.ts +8 -0
  215. package/alchemy.ts +0 -142
  216. package/containers/office-preview/Dockerfile +0 -10
  217. package/shared/mail-rules.ts +0 -156
  218. package/worker/admin/report-routes.ts +0 -164
  219. package/worker/mail/reported-messages.ts +0 -68
  220. package/worker/mailbox/migrations.ts +0 -10
  221. package/worker/mailbox/rules.ts +0 -110
@@ -1,11 +1,19 @@
1
+ import { required } from "@open-workspace/core/shared";
2
+
1
3
  import type { AuthResult, DmarcPolicy } from "../../shared/mail-authentication";
2
- import type { SenderIntel, SpamhausListing } from "../../shared/mail-sender-intel";
4
+ import type {
5
+ SenderIntel,
6
+ SpamhausListing,
7
+ } from "../../shared/mail-sender-intel";
3
8
  import { inboundHeaderMetadata } from "../mail/auth-headers";
4
9
  import { bimiObjectKey } from "../mail/bimi";
5
10
  import { DEMO_UNSUBSCRIBE_HOST } from "../mail/demo-routes";
6
- import { denseDiscoveryHtml, figmaInvoiceHtml, hirelineHtml } from "./demo-html";
11
+ import {
12
+ marginNotesHtml,
13
+ canvaslyInvoiceHtml,
14
+ hirelineHtml,
15
+ } from "./demo-html";
7
16
  import type { EmailAiClassification, MailAddress } from "./model";
8
- import type { MailRuleInput } from "./rules";
9
17
  import type { NewEmail, NewFolder } from "./schema";
10
18
 
11
19
  type DemoInput = {
@@ -40,12 +48,22 @@ type DemoAuthentication = {
40
48
  mailFrom: string;
41
49
  spf: AuthResult;
42
50
  spfHelo: AuthResult;
43
- dkim: Array<{ domain: string; selector: string; result: AuthResult; signs: string[] }>;
51
+ dkim: {
52
+ domain: string;
53
+ selector: string;
54
+ result: AuthResult;
55
+ signs: string[];
56
+ }[];
44
57
  dmarc: AuthResult;
45
58
  policy: DmarcPolicy | null;
46
59
  spamScore: number;
47
60
  /** Delivered through a forwarder that sealed an ARC set first. */
48
- forwardedVia?: { sealer: string; authservId: string; helo: string; ip: string };
61
+ forwardedVia?: {
62
+ sealer: string;
63
+ authservId: string;
64
+ helo: string;
65
+ ip: string;
66
+ };
49
67
  };
50
68
 
51
69
  /**
@@ -64,8 +82,8 @@ type DemoIntel = {
64
82
  registry?: string;
65
83
  /** As if a Spamhaus DQS key were configured. */
66
84
  spamhaus?: {
67
- zen?: Array<Pick<SpamhausListing, "code" | "list" | "severity">>;
68
- dbl?: Array<{ domain: string; code: string; list: string }>;
85
+ zen?: Pick<SpamhausListing, "code" | "list" | "severity">[];
86
+ dbl?: { domain: string; code: string; list: string }[];
69
87
  domains: string[];
70
88
  };
71
89
  /** The From domain serves the demo BIMI logo seeded next to the rows. */
@@ -95,16 +113,23 @@ function demoRawKey(id: string) {
95
113
  }
96
114
 
97
115
  function mimeAddress(address: MailAddress) {
98
- return address.name ? `"${address.name}" <${address.address}>` : address.address;
116
+ return address.name
117
+ ? `"${address.name}" <${address.address}>`
118
+ : address.address;
99
119
  }
100
120
 
101
121
  function demoToken(seed: string, length: number) {
102
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
122
+ const alphabet =
123
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
124
+
103
125
  let hash = 2_166_136_261;
126
+
104
127
  for (let index = 0; index < seed.length; index += 1) {
105
128
  hash = Math.imul(hash ^ seed.charCodeAt(index), 16_777_619) >>> 0;
106
129
  }
130
+
107
131
  let token = "";
132
+
108
133
  while (token.length < length) {
109
134
  // xorshift32 keeps the demo signatures stable between seeds and renders.
110
135
  hash ^= hash << 13;
@@ -113,13 +138,21 @@ function demoToken(seed: string, length: number) {
113
138
  hash >>>= 0;
114
139
  token += alphabet[hash % alphabet.length];
115
140
  }
141
+
116
142
  return token;
117
143
  }
118
144
 
119
145
  function spfComment(result: AuthResult, identity: string, ip: string) {
120
- if (result === "pass") return `domain of ${identity} designates ${ip} as permitted sender`;
146
+ if (result === "pass") {
147
+ return `domain of ${identity} designates ${ip} as permitted sender`;
148
+ }
149
+
121
150
  if (result === "none") return `no SPF records found for ${identity}`;
122
- if (result === "softfail") return `domain of transitioning ${identity} does not designate ${ip} as permitted sender`;
151
+
152
+ if (result === "softfail") {
153
+ return `domain of transitioning ${identity} does not designate ${ip} as permitted sender`;
154
+ }
155
+
123
156
  return `domain of ${identity} does not designate ${ip} as permitted sender`;
124
157
  }
125
158
 
@@ -129,14 +162,20 @@ function folded(prefix: string, parts: string[]) {
129
162
  }
130
163
 
131
164
  /** Cloudflare's prepended header block, topmost first, as seen on production mail. */
132
- function cloudflareHeaders(input: DemoInput, auth: DemoAuthentication, at: (offsetMs: number) => string) {
165
+ function cloudflareHeaders(
166
+ input: DemoInput,
167
+ auth: DemoAuthentication,
168
+ at: (offsetMs: number) => string
169
+ ) {
133
170
  const fromDomain = input.from.address.split("@")[1] ?? "invalid";
134
171
  const recipient = input.to[0]?.address ?? "user@demo.example";
135
172
  const instance = auth.forwardedVia ? 2 : 1;
173
+
136
174
  const results = [
137
175
  ...(auth.dkim.length
138
- ? auth.dkim.map((dkim) =>
139
- `dkim=${dkim.result} header.d=${dkim.domain} header.s=${dkim.selector} header.b=${demoToken(`${input.id}${dkim.domain}`, 8)}`
176
+ ? auth.dkim.map(
177
+ (dkim) =>
178
+ `dkim=${dkim.result} header.d=${dkim.domain} header.s=${dkim.selector} header.b=${demoToken(`${input.id}${dkim.domain}`, 8)}`
140
179
  )
141
180
  : ["dkim=none"]),
142
181
  `dmarc=${auth.dmarc} header.from=${fromDomain}${auth.policy ? ` policy.dmarc=${auth.policy}` : ""}`,
@@ -144,6 +183,7 @@ function cloudflareHeaders(input: DemoInput, auth: DemoAuthentication, at: (offs
144
183
  `spf=${auth.spf} (mx.cloudflare.net: ${spfComment(auth.spf, auth.mailFrom, auth.ip)}) smtp.mailfrom=${auth.mailFrom}`,
145
184
  `arc=${auth.forwardedVia ? "pass" : "none"} smtp.remote-ip=${auth.ip}`,
146
185
  ];
186
+
147
187
  return [
148
188
  `Received: from ${auth.helo} (${auth.ip})`,
149
189
  `\tby cloudflare-email.net (cloudflare) id ${demoToken(input.id, 12)}`,
@@ -153,7 +193,10 @@ function cloudflareHeaders(input: DemoInput, auth: DemoAuthentication, at: (offs
153
193
  `ARC-Message-Signature: i=${instance}; a=rsa-sha256; s=cf2024-1; d=cloudflare-email.net; c=relaxed/relaxed;`,
154
194
  "\th=To:Subject:From:Date:from:reply-to:cc:in-reply-to:references:list-id; bh=",
155
195
  `\t${demoToken(`${input.id}bh`, 43)}=; b=${demoToken(`${input.id}ams`, 64)}`,
156
- folded(`ARC-Authentication-Results: i=${instance}; mx.cloudflare.net`, results),
196
+ folded(
197
+ `ARC-Authentication-Results: i=${instance}; mx.cloudflare.net`,
198
+ results
199
+ ),
157
200
  `Received-SPF: ${auth.spf} (mx.cloudflare.net: ${spfComment(auth.spf, auth.mailFrom, auth.ip)})`,
158
201
  `\treceiver=mx.cloudflare.net; client-ip=${auth.ip}; envelope-from="${auth.mailFrom}"; helo=${auth.helo};`,
159
202
  folded("Authentication-Results: mx.cloudflare.net", results),
@@ -161,11 +204,17 @@ function cloudflareHeaders(input: DemoInput, auth: DemoAuthentication, at: (offs
161
204
  ];
162
205
  }
163
206
 
164
- function forwarderHeaders(input: DemoInput, auth: DemoAuthentication, at: (offsetMs: number) => string) {
207
+ function forwarderHeaders(
208
+ input: DemoInput,
209
+ auth: DemoAuthentication,
210
+ at: (offsetMs: number) => string
211
+ ) {
165
212
  const via = auth.forwardedVia;
213
+
166
214
  if (!via) return [];
167
215
  const fromDomain = input.from.address.split("@")[1] ?? "invalid";
168
216
  const original = auth.dkim.find((dkim) => dkim.domain === fromDomain);
217
+
169
218
  return [
170
219
  `ARC-Seal: i=1; a=rsa-sha256; t=1793000000; cv=none; d=${via.sealer}; s=arc-20240605;`,
171
220
  `\tb=${demoToken(`${input.id}upseal`, 64)}`,
@@ -177,7 +226,7 @@ function forwarderHeaders(input: DemoInput, auth: DemoAuthentication, at: (offse
177
226
  `dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=${fromDomain}`,
178
227
  ]),
179
228
  `Received: by 2001:db8:4864:20::62a with SMTP id ${demoToken(`${input.id}fw`, 10)};`,
180
- `\t${at(-2_000)}`,
229
+ `\t${at(-2000)}`,
181
230
  folded(`Authentication-Results: ${via.authservId}`, [
182
231
  `dkim=pass header.i=@${fromDomain} header.s=${original?.selector ?? "mail"}`,
183
232
  `spf=pass smtp.mailfrom=${input.from.address}`,
@@ -186,7 +235,7 @@ function forwarderHeaders(input: DemoInput, auth: DemoAuthentication, at: (offse
186
235
  `Received: from ${via.helo} (${via.helo} [${via.ip}])`,
187
236
  `\tby ${via.authservId} with ESMTPS id ${demoToken(`${input.id}mx`, 10)}`,
188
237
  `\tfor <${input.to[0]?.address ?? "user@demo.example"}>`,
189
- `\t(Google Transport Security); ${at(-3_000)}`,
238
+ `\t(Google Transport Security); ${at(-3000)}`,
190
239
  ];
191
240
  }
192
241
 
@@ -201,19 +250,31 @@ function dkimSignatureHeaders(input: DemoInput, auth: DemoAuthentication) {
201
250
 
202
251
  /** A plausible RFC 5322 original for the "Show original" view. */
203
252
  function demoRawMime(input: DemoInput, now: number) {
204
- const date = new Date(now - input.ageMs).toUTCString().replace("GMT", "+0000");
205
- const fromDomain = input.from.address.split("@")[1] ?? "invalid";
253
+ const date = new Date(now - input.ageMs)
254
+ .toUTCString()
255
+ .replace("GMT", "+0000");
256
+
206
257
  const at = (offsetMs: number) =>
207
- new Date(now - input.ageMs + offsetMs).toUTCString().replace("GMT", "+0000");
208
- const checks = input.checks;
258
+ new Date(now - input.ageMs + offsetMs)
259
+ .toUTCString()
260
+ .replace("GMT", "+0000");
261
+
262
+ const { checks } = input;
209
263
  const auth = checks?.authentication;
210
- const senderHops = !auth || checks?.direct || auth.forwardedVia
211
- ? []
212
- : [
213
- "Received: from app-3.internal ([10.12.4.8])",
214
- `\tby ${auth.helo} with ESMTPSA id ${input.id}-out; ${at(-4_000)}`,
215
- ];
216
- const unsubscribeId = demoToken(`${input.id}unsubscribe`, 16).replace(/[+/]/gu, "x");
264
+
265
+ const senderHops =
266
+ !auth || checks?.direct || auth.forwardedVia
267
+ ? []
268
+ : [
269
+ "Received: from app-3.internal ([10.12.4.8])",
270
+ `\tby ${auth.helo} with ESMTPSA id ${input.id}-out; ${at(-4000)}`,
271
+ ];
272
+
273
+ const unsubscribeId = demoToken(`${input.id}unsubscribe`, 16).replaceAll(
274
+ /[+/]/gu,
275
+ "x"
276
+ );
277
+
217
278
  const headers = [
218
279
  ...(auth ? cloudflareHeaders(input, auth, at) : []),
219
280
  ...(auth ? forwarderHeaders(input, auth, at) : []),
@@ -222,7 +283,9 @@ function demoRawMime(input: DemoInput, now: number) {
222
283
  `From: ${mimeAddress(input.from)}`,
223
284
  ...(input.replyTo ? [`Reply-To: ${mimeAddress(input.replyTo)}`] : []),
224
285
  `To: ${input.to.map(mimeAddress).join(", ")}`,
225
- ...(input.cc?.length ? [`Cc: ${input.cc.map(mimeAddress).join(", ")}`] : []),
286
+ ...(input.cc?.length
287
+ ? [`Cc: ${input.cc.map(mimeAddress).join(", ")}`]
288
+ : []),
226
289
  `Subject: ${input.subject}`,
227
290
  `Date: ${date}`,
228
291
  `Message-ID: ${input.messageId}`,
@@ -238,11 +301,22 @@ function demoRawMime(input: DemoInput, now: number) {
238
301
  : []),
239
302
  "MIME-Version: 1.0",
240
303
  ];
241
- const text = input.body.replace(/\n/gu, "\r\n");
304
+
305
+ const text = input.body.replaceAll("\n", "\r\n");
306
+
242
307
  if (!input.html) {
243
- return [...headers, "Content-Type: text/plain; charset=utf-8", "Content-Transfer-Encoding: 8bit", "", text, ""].join("\r\n");
308
+ return [
309
+ ...headers,
310
+ "Content-Type: text/plain; charset=utf-8",
311
+ "Content-Transfer-Encoding: 8bit",
312
+ "",
313
+ text,
314
+ "",
315
+ ].join("\r\n");
244
316
  }
317
+
245
318
  const boundary = `demo-${input.id}`;
319
+
246
320
  return [
247
321
  ...headers,
248
322
  `Content-Type: multipart/alternative; boundary="${boundary}"`,
@@ -262,14 +336,19 @@ function demoRawMime(input: DemoInput, now: number) {
262
336
  ].join("\r\n");
263
337
  }
264
338
 
265
- function demoSenderIntel(input: DemoInput, checkedAt: number): SenderIntel | null {
266
- const checks = input.checks;
339
+ function demoSenderIntel(
340
+ input: DemoInput,
341
+ checkedAt: number
342
+ ): SenderIntel | null {
343
+ const { checks } = input;
267
344
  const intel = checks?.intel;
345
+
268
346
  if (!checks || !intel) return null;
269
- const ip = checks.authentication.ip;
347
+ const { ip } = checks.authentication;
270
348
  const fromDomain = input.from.address.split("@")[1] ?? "invalid";
271
- const fcrdns = intel.ptr ? intel.fcrdns ?? true : false;
349
+ const fcrdns = intel.ptr ? (intel.fcrdns ?? true) : false;
272
350
  const helo = checks.authentication.helo.toLocaleLowerCase();
351
+
273
352
  return {
274
353
  version: 1,
275
354
  source: "demo",
@@ -281,10 +360,12 @@ function demoSenderIntel(input: DemoInput, checkedAt: number): SenderIntel | nul
281
360
  names: intel.ptr ? [intel.ptr] : [],
282
361
  confirmed: intel.ptr && fcrdns ? intel.ptr : null,
283
362
  fcrdns,
284
- generic: intel.ptr ? intel.generic ?? false : null,
363
+ generic: intel.ptr ? (intel.generic ?? false) : null,
285
364
  },
286
365
  heloMatchesPtr: intel.ptr
287
- ? helo === intel.ptr || helo.split(".").slice(-2).join(".") === intel.ptr.split(".").slice(-2).join(".")
366
+ ? helo === intel.ptr ||
367
+ helo.split(".").slice(-2).join(".") ===
368
+ intel.ptr.split(".").slice(-2).join(".")
288
369
  : null,
289
370
  network: {
290
371
  status: "ok",
@@ -299,7 +380,11 @@ function demoSenderIntel(input: DemoInput, checkedAt: number): SenderIntel | nul
299
380
  zen: {
300
381
  status: "ok",
301
382
  error: null,
302
- listings: (intel.spamhaus.zen ?? []).map((listing) => ({ zone: "zen", target: ip, ...listing })),
383
+ listings: (intel.spamhaus.zen ?? []).map((listing) => ({
384
+ zone: "zen",
385
+ target: ip,
386
+ ...listing,
387
+ })),
303
388
  },
304
389
  dbl: {
305
390
  status: "ok",
@@ -315,14 +400,22 @@ function demoSenderIntel(input: DemoInput, checkedAt: number): SenderIntel | nul
315
400
  },
316
401
  }
317
402
  : null,
318
- bimi: intel.bimi ? { domain: fromDomain, status: "ok", reason: null } : null,
403
+ bimi: intel.bimi
404
+ ? { domain: fromDomain, status: "ok", reason: null }
405
+ : null,
319
406
  };
320
407
  }
321
408
 
409
+ /** The domain of a demo address; every one has one. */
410
+ function demoDomain(address: string) {
411
+ return required(address.split("@")[1], `${address} has a domain`);
412
+ }
413
+
322
414
  function email(input: DemoInput, now: number): NewEmail {
323
415
  const timelineAt = new Date(now - input.ageMs);
324
416
  const outgoing = input.direction === "outgoing";
325
- return {
417
+
418
+ const message: NewEmail = {
326
419
  id: input.id,
327
420
  conversationId: input.conversationId,
328
421
  direction: outgoing ? "outgoing" : "incoming",
@@ -339,23 +432,14 @@ function email(input: DemoInput, now: number): NewEmail {
339
432
  bodyText: input.body,
340
433
  bodyHtmlR2Key: input.html ? demoHtmlKey(input.id) : null,
341
434
  rawMimeR2Key: input.checks ? demoRawKey(input.id) : null,
342
- // Parsed by the production parser from the same original seeded into R2.
343
- ...(input.checks
344
- ? inboundHeaderMetadata({
345
- rawHeaders: demoRawMime(input, now),
346
- fromAddress: input.from.address,
347
- envelopeFrom: input.checks.authentication.mailFrom,
348
- now: timelineAt.getTime() + 1_000,
349
- })
350
- : {}),
351
435
  envelopeFrom: input.checks?.authentication.mailFrom ?? null,
352
- envelopeTo: outgoing ? null : input.to[0]?.address ?? null,
353
- senderIntelJson: demoSenderIntel(input, timelineAt.getTime() + 1_500),
436
+ envelopeTo: outgoing ? null : (input.to[0]?.address ?? null),
437
+ senderIntelJson: demoSenderIntel(input, timelineAt.getTime() + 1500),
354
438
  aiClassificationJson: input.checks
355
439
  ? {
356
440
  source: "ai",
357
441
  model: "openai/gpt-6-luna",
358
- processedAt: timelineAt.getTime() + 2_000,
442
+ processedAt: timelineAt.getTime() + 2000,
359
443
  ...input.checks.ai,
360
444
  }
361
445
  : null,
@@ -366,65 +450,96 @@ function email(input: DemoInput, now: number): NewEmail {
366
450
  recipient: recipient.address,
367
451
  status: "delivered" as const,
368
452
  eventId: `demo_${input.id}_${index}`,
369
- eventAt: timelineAt.getTime() + 1_500,
453
+ eventAt: timelineAt.getTime() + 1500,
370
454
  smtpCode: "250",
371
455
  detail: null,
372
456
  }))
373
457
  : [],
374
458
  };
459
+
460
+ if (input.checks) {
461
+ // Parsed by the production parser from the same original seeded into R2.
462
+ Object.assign(
463
+ message,
464
+ inboundHeaderMetadata({
465
+ rawHeaders: demoRawMime(input, now),
466
+ fromAddress: input.from.address,
467
+ envelopeFrom: input.checks.authentication.mailFrom,
468
+ now: timelineAt.getTime() + 1000,
469
+ })
470
+ );
471
+ }
472
+
473
+ return message;
375
474
  }
376
475
 
377
- const ilya = { address: "ilya@demo.example", name: "Ilya Morozov" };
476
+ const sam = { address: "sam@demo.example", name: "Sam Brooks" };
378
477
  const support = { address: "support@demo.example", name: "Customer care" };
379
478
 
380
479
  function demoInputs(mailboxId: string): DemoInput[] {
381
480
  if (mailboxId === "mbx_demo_personal") {
382
481
  return [
383
- ({
482
+ {
384
483
  id: "msg_demo_01",
385
484
  conversationId: "conv_demo_launch",
386
- messageId: "<launch@linear.demo>",
387
- from: { address: "karri@linear.app", name: "Karri Saarinen" },
388
- to: [ilya],
485
+ messageId: "<launch@lumen.example>",
486
+ from: { address: "kai@lumen.example", name: "Kai Lindqvist" },
487
+ to: [sam],
389
488
  subject: "The craft behind fast software",
390
- preview: "I kept thinking about our conversation on speed and quality. The teams that move fastest rarely skip the details.",
391
- body: "Hey Ilya,\n\nI kept thinking about our conversation on speed and quality. The teams that move fastest rarely skip the details — they make the right details easier to see.\n\nHere are the notes from our design review and the three decisions we should make this week.\n\nKarri",
489
+ preview:
490
+ "I kept thinking about our conversation on speed and quality. The teams that move fastest rarely skip the details.",
491
+ body: "Hey Sam,\n\nI kept thinking about our conversation on speed and quality. The teams that move fastest rarely skip the details — they make the right details easier to see.\n\nHere are the notes from our design review and the three decisions we should make this week.\n\nKai",
392
492
  ageMs: 540_000,
393
- }),
394
- ({
493
+ },
494
+ {
395
495
  id: "msg_demo_07",
396
496
  conversationId: "conv_demo_launch",
397
497
  messageId: "<reply@openworkspace.demo>",
398
498
  direction: "outgoing",
399
- from: ilya,
400
- to: [{ address: "karri@linear.app", name: "Karri Saarinen" }],
499
+ from: sam,
500
+ to: [{ address: "kai@lumen.example", name: "Kai Lindqvist" }],
401
501
  subject: "Re: The craft behind fast software",
402
- preview: "That framing is exactly right. I turned the decisions into a smaller review doc.",
403
- body: "That framing is exactly right. I turned the decisions into a smaller review doc and will send the final version tomorrow.\n\nThanks,\nIlya",
502
+ preview:
503
+ "That framing is exactly right. I turned the decisions into a smaller review doc.",
504
+ body: "That framing is exactly right. I turned the decisions into a smaller review doc and will send the final version tomorrow.\n\nThanks,\nSam",
404
505
  ageMs: 180_000,
405
- references: ["<launch@linear.demo>"],
406
- }),
407
- ({
506
+ references: ["<launch@lumen.example>"],
507
+ },
508
+ {
408
509
  id: "msg_demo_02",
409
- conversationId: "conv_demo_cloudflare",
410
- messageId: "<workers@cloudflare.demo>",
411
- from: { address: "jessica@cloudflare.com", name: "Jessica Lee" },
412
- to: [ilya],
510
+ conversationId: "conv_demo_edgeworks",
511
+ messageId: "<workers@edgeworks.example>",
512
+ from: { address: "jessica@edgeworks.example", name: "Jessica Lee" },
513
+ to: [sam],
413
514
  cc: [{ address: "maya@demo.example", name: "Maya Chen" }],
414
515
  subject: "Your Workers architecture review",
415
- preview: "The per-mailbox SQLite design looks solid. Keeping raw MIME in R2 leaves the mailbox database focused.",
416
- body: "Hi Ilya,\n\nThe per-mailbox SQLite design looks solid. Keeping raw MIME in R2 leaves the mailbox database focused on RFC metadata and conversation state.\n\nI left a few notes on retries and idempotency below.\n\nBest,\nJessica",
516
+ preview:
517
+ "The per-mailbox SQLite design looks solid. Keeping raw MIME in R2 leaves the mailbox database focused.",
518
+ body: "Hi Sam,\n\nThe per-mailbox SQLite design looks solid. Keeping raw MIME in R2 leaves the mailbox database focused on RFC metadata and conversation state.\n\nI left a few notes on retries and idempotency below.\n\nBest,\nJessica",
417
519
  ageMs: 4_200_000,
418
520
  checks: {
419
521
  mailer: "Apple Mail (2.3826.400)",
420
- intel: { ptr: "mail-yw1-f42.google.com", asn: 15169, asName: "Google LLC", prefix: "198.51.100.0/24", country: "US" },
522
+ intel: {
523
+ ptr: "mail-yw1-f42.google.com",
524
+ asn: 15_169,
525
+ asName: "Google LLC",
526
+ prefix: "198.51.100.0/24",
527
+ country: "US",
528
+ },
421
529
  authentication: {
422
530
  ip: "198.51.100.42",
423
- helo: "smtp-out.cloudflare.com",
424
- mailFrom: "jessica@cloudflare.com",
531
+ helo: "smtp-out.edgeworks.example",
532
+ mailFrom: "jessica@edgeworks.example",
425
533
  spf: "pass",
426
534
  spfHelo: "none",
427
- dkim: [{ domain: "cloudflare.com", selector: "google", result: "pass", signs: ["from", "to", "cc", "subject", "date", "message-id"] }],
535
+ dkim: [
536
+ {
537
+ domain: "edgeworks.example",
538
+ selector: "google",
539
+ result: "pass",
540
+ signs: ["from", "to", "cc", "subject", "date", "message-id"],
541
+ },
542
+ ],
428
543
  dmarc: "pass",
429
544
  policy: "reject",
430
545
  spamScore: 0,
@@ -434,61 +549,85 @@ function demoInputs(mailboxId: string): DemoInput[] {
434
549
  spamConfidence: 0.02,
435
550
  folderId: null,
436
551
  folderConfidence: 0.12,
437
- reason: "Personal work correspondence from a known contact replying to an architecture review.",
552
+ reason:
553
+ "Personal work correspondence from a known contact replying to an architecture review.",
438
554
  },
439
555
  },
440
- }),
441
- ({
556
+ },
557
+ {
442
558
  id: "msg_demo_03",
443
559
  conversationId: "conv_demo_maya",
444
560
  messageId: "<maya-update@demo>",
445
561
  from: { address: "maya@demo.example", name: "Maya Chen" },
446
- to: [ilya],
562
+ to: [sam],
447
563
  subject: "Friday launch checklist",
448
- preview: "I grouped the remaining work into launch blockers and follow-ups. We are down to four real blockers.",
564
+ preview:
565
+ "I grouped the remaining work into launch blockers and follow-ups. We are down to four real blockers.",
449
566
  body: "I grouped the remaining work into launch blockers and follow-ups. We are down to four real blockers:\n\n1. Verify catch-all routing\n2. Run mobile QA\n3. Confirm outbound domain\n4. Write the setup guide\n\nEverything else can follow next week.",
450
567
  ageMs: 86_400_000,
451
- }),
452
- ({
568
+ },
569
+ {
453
570
  id: "msg_demo_04",
454
- conversationId: "conv_demo_vercel",
455
- messageId: "<design@vercel.demo>",
456
- from: { address: "rauno@vercel.com", name: "Rauno Freiberg" },
457
- to: [ilya],
571
+ conversationId: "conv_demo_vertex",
572
+ messageId: "<design@vertex.example>",
573
+ from: { address: "rafael@vertex.example", name: "Rafael Ortiz" },
574
+ to: [sam],
458
575
  subject: "Re: interaction details",
459
- preview: "The reduced motion version feels right now. I would keep the mailbox transition almost instant.",
576
+ preview:
577
+ "The reduced motion version feels right now. I would keep the mailbox transition almost instant.",
460
578
  body: "The reduced-motion build is ready for review. I shortened the mailbox transition and kept the composer animation subtle.\n\nThe updated interaction notes are attached to the ticket.",
461
579
  ageMs: 172_800_000,
462
- }),
463
- ({
580
+ },
581
+ {
464
582
  id: "msg_demo_05",
465
583
  conversationId: "conv_demo_weekly",
466
584
  messageId: "<weekly@paper.demo>",
467
- from: { address: "digest@dense-discovery.com", name: "Dense Discovery" },
468
- to: [ilya],
585
+ from: { address: "digest@margin-notes.example", name: "Margin Notes" },
586
+ to: [sam],
469
587
  subject: "Issue 341 — tools for thought",
470
- preview: "A small collection of thoughtful products, strange links, and ideas worth carrying into the weekend.",
588
+ preview:
589
+ "A small collection of thoughtful products, strange links, and ideas worth carrying into the weekend.",
471
590
  body: "A small collection of thoughtful products, strange links, and ideas worth carrying into the weekend.\n\nThis week: humane inboxes, local-first databases, and why fast tools feel calm.",
472
591
  ageMs: 259_200_000,
473
- html: denseDiscoveryHtml,
592
+ html: marginNotesHtml,
474
593
  checks: {
475
594
  mailer: "Campaigner 4.2",
476
- intel: { ptr: "mta-7.campaigner-mail.example", asn: 64500, asName: "Campaigner Mail Services", prefix: "203.0.113.0/25", country: "CA" },
477
- list: { id: "weekly.dense-discovery.com" },
595
+ intel: {
596
+ ptr: "mta-7.campaigner-mail.example",
597
+ asn: 64_500,
598
+ asName: "Campaigner Mail Services",
599
+ prefix: "203.0.113.0/25",
600
+ country: "CA",
601
+ },
602
+ list: { id: "weekly.margin-notes.example" },
478
603
  authentication: {
479
604
  ip: "203.0.113.24",
480
605
  helo: "mta-7.campaigner-mail.example",
481
- mailFrom: "bounce-341-8812@mail.dense-discovery.com",
606
+ mailFrom: "bounce-341-8812@mail.margin-notes.example",
482
607
  spf: "pass",
483
608
  spfHelo: "none",
484
609
  dkim: [
485
610
  {
486
- domain: "dense-discovery.com",
611
+ domain: "margin-notes.example",
487
612
  selector: "cm1",
488
613
  result: "pass",
489
- signs: ["from", "to", "subject", "date", "message-id", "list-id", "list-unsubscribe", "list-unsubscribe-post"],
614
+ signs: [
615
+ "from",
616
+ "to",
617
+ "subject",
618
+ "date",
619
+ "message-id",
620
+ "list-id",
621
+ "list-unsubscribe",
622
+ "list-unsubscribe-post",
623
+ ],
624
+ },
625
+ {
626
+ domain: "campaigner-mail.example",
627
+ selector: "esp",
628
+ result: "pass",
629
+ signs: ["from", "to", "subject", "date"],
490
630
  },
491
- { domain: "campaigner-mail.example", selector: "esp", result: "pass", signs: ["from", "to", "subject", "date"] },
492
631
  ],
493
632
  dmarc: "pass",
494
633
  policy: "quarantine",
@@ -499,36 +638,44 @@ function demoInputs(mailboxId: string): DemoInput[] {
499
638
  spamConfidence: 0.07,
500
639
  folderId: null,
501
640
  folderConfidence: 0.22,
502
- reason: "Newsletter you subscribed to, with a working unsubscribe link and consistent sender.",
641
+ reason:
642
+ "Newsletter you subscribed to, with a working unsubscribe link and consistent sender.",
503
643
  },
504
644
  },
505
- }),
506
- ({
645
+ },
646
+ {
507
647
  id: "msg_demo_06",
508
648
  conversationId: "conv_demo_invoice",
509
- messageId: "<invoice@figma.demo>",
510
- from: { address: "billing@figma.com", name: "Figma" },
511
- to: [ilya],
649
+ messageId: "<invoice@canvasly.example>",
650
+ from: { address: "billing@canvasly.example", name: "Canvasly" },
651
+ to: [sam],
512
652
  subject: "Your July invoice",
513
653
  preview: "Your invoice is ready. No action is required.",
514
654
  body: "Your July invoice is ready. No action is required. You can find billing details in your workspace settings.",
515
655
  ageMs: 432_000_000,
516
- html: figmaInvoiceHtml,
517
- }),
518
- ({
656
+ html: canvaslyInvoiceHtml,
657
+ },
658
+ {
519
659
  id: "msg_demo_13",
520
660
  conversationId: "conv_demo_hiring",
521
661
  messageId: "<position-closed@hireline.example>",
522
662
  from: { address: "notifications@hireline.example", name: "Hireline" },
523
- to: [ilya],
663
+ to: [sam],
524
664
  subject: "This position is closed",
525
- preview: "You applied for Senior Frontend Engineer at Northwind Labs. The employer has closed this position.",
665
+ preview:
666
+ "You applied for Senior Frontend Engineer at Northwind Labs. The employer has closed this position.",
526
667
  body: "This position is closed\n\nYou applied for Senior Frontend Engineer at Northwind Labs. The employer has closed this position.\n\nWe picked a few similar roles that match your profile. Good luck with your search!",
527
668
  ageMs: 302_400_000,
528
669
  html: hirelineHtml,
529
670
  checks: {
530
671
  mailer: "Hireline Notifier",
531
- intel: { ptr: "out-12.sendhub-mail.example", asn: 64501, asName: "SendHub Inc.", prefix: "203.0.113.64/26", country: "US" },
672
+ intel: {
673
+ ptr: "out-12.sendhub-mail.example",
674
+ asn: 64_501,
675
+ asName: "SendHub Inc.",
676
+ prefix: "203.0.113.64/26",
677
+ country: "US",
678
+ },
532
679
  list: { id: "alerts.hireline.example" },
533
680
  // Sent through an ESP on its own domain, with no DMARC record for
534
681
  // hireline.example: nothing ties the message to the From domain.
@@ -538,7 +685,14 @@ function demoInputs(mailboxId: string): DemoInput[] {
538
685
  mailFrom: "bounces+7731@sendhub-mail.example",
539
686
  spf: "pass",
540
687
  spfHelo: "pass",
541
- dkim: [{ domain: "sendhub-mail.example", selector: "s1", result: "pass", signs: ["from", "to", "subject", "date", "list-unsubscribe"] }],
688
+ dkim: [
689
+ {
690
+ domain: "sendhub-mail.example",
691
+ selector: "s1",
692
+ result: "pass",
693
+ signs: ["from", "to", "subject", "date", "list-unsubscribe"],
694
+ },
695
+ ],
542
696
  dmarc: "none",
543
697
  policy: null,
544
698
  spamScore: 1,
@@ -548,33 +702,48 @@ function demoInputs(mailboxId: string): DemoInput[] {
548
702
  spamConfidence: 0.18,
549
703
  folderId: null,
550
704
  folderConfidence: 0.31,
551
- reason: "Automated job-board notification about an application you submitted.",
705
+ reason:
706
+ "Automated job-board notification about an application you submitted.",
552
707
  },
553
708
  },
554
- }),
555
- ({
709
+ },
710
+ {
556
711
  id: "msg_demo_14",
557
712
  conversationId: "conv_demo_offsite",
558
713
  messageId: "<offsite-venues@northwind.example>",
559
714
  from: { address: "priya@northwind.example", name: "Priya Nair" },
560
- to: [ilya],
715
+ to: [sam],
561
716
  subject: "Venue shortlist for the offsite",
562
- preview: "I narrowed the offsite venues down to three. All of them can host 40 people and have a quiet room for workshops.",
563
- body: "Hi Ilya,\n\nI narrowed the offsite venues down to three. All of them can host 40 people and have a quiet room for workshops.\n\nCould you pick your favourite by Thursday? I will book it the same day.\n\nPriya",
717
+ preview:
718
+ "I narrowed the offsite venues down to three. All of them can host 40 people and have a quiet room for workshops.",
719
+ body: "Hi Sam,\n\nI narrowed the offsite venues down to three. All of them can host 40 people and have a quiet room for workshops.\n\nCould you pick your favourite by Thursday? I will book it the same day.\n\nPriya",
564
720
  ageMs: 12_600_000,
565
721
  checks: {
566
722
  mailer: "Mozilla Thunderbird 140.2",
567
- intel: { ptr: "mail-sor-f69.google.com", asn: 15169, asName: "Google LLC", prefix: "198.51.100.0/24", country: "US" },
568
- // Sent to Ilya's old address and forwarded by Gmail: SPF now checks
723
+ intel: {
724
+ ptr: "mail-sor-f69.google.com",
725
+ asn: 15_169,
726
+ asName: "Google LLC",
727
+ prefix: "198.51.100.0/24",
728
+ country: "US",
729
+ },
730
+ // Sent to Sam's old address and forwarded by Gmail: SPF now checks
569
731
  // Gmail's forwarding envelope, while the original DKIM signature and
570
732
  // Gmail's ARC seal survive.
571
733
  authentication: {
572
734
  ip: "198.51.100.113",
573
735
  helo: "mail-sor-f69.google.com",
574
- mailFrom: "ilya.old+caf_=ilya=demo.example@gmail.com",
736
+ mailFrom: "sam.old+caf_=sam=demo.example@gmail.com",
575
737
  spf: "pass",
576
738
  spfHelo: "pass",
577
- dkim: [{ domain: "northwind.example", selector: "nw2026", result: "pass", signs: ["from", "to", "subject", "date", "message-id"] }],
739
+ dkim: [
740
+ {
741
+ domain: "northwind.example",
742
+ selector: "nw2026",
743
+ result: "pass",
744
+ signs: ["from", "to", "subject", "date", "message-id"],
745
+ },
746
+ ],
578
747
  dmarc: "pass",
579
748
  policy: "quarantine",
580
749
  spamScore: 0,
@@ -590,32 +759,48 @@ function demoInputs(mailboxId: string): DemoInput[] {
590
759
  spamConfidence: 0.03,
591
760
  folderId: null,
592
761
  folderConfidence: 0.1,
593
- reason: "A colleague asking for a decision on offsite venues, forwarded from another inbox.",
762
+ reason:
763
+ "A colleague asking for a decision on offsite venues, forwarded from another inbox.",
594
764
  },
595
765
  },
596
- }),
597
- ({
766
+ },
767
+ {
598
768
  id: "msg_demo_15",
599
769
  conversationId: "conv_demo_favour",
600
770
  messageId: "<favour-4471@freemail.example>",
601
771
  // An outsider borrowing a colleague's name from a freemail account.
602
772
  from: { address: "maya.chen.desk@freemail.example", name: "Maya Chen" },
603
- to: [ilya],
773
+ to: [sam],
604
774
  subject: "Quick favour before my next meeting",
605
- preview: "Are you at your desk? I need you to handle a small purchase for a client today and I can't take calls.",
606
- body: "Hi Ilya,\n\nAre you at your desk? I need you to handle a small purchase for a client today and I can't take calls — I'm in back-to-back meetings.\n\nReply here as soon as you see this and I'll send the details.\n\nMaya",
775
+ preview:
776
+ "Are you at your desk? I need you to handle a small purchase for a client today and I can't take calls.",
777
+ body: "Hi Sam,\n\nAre you at your desk? I need you to handle a small purchase for a client today and I can't take calls — I'm in back-to-back meetings.\n\nReply here as soon as you see this and I'll send the details.\n\nMaya",
607
778
  ageMs: 1_500_000,
608
779
  checks: {
609
780
  direct: true,
610
781
  mailer: "Freemail Webmail 9.4",
611
- intel: { ptr: "smtp-out-3.freemail.example", asn: 64502, asName: "Freemail Networks B.V.", prefix: "198.51.100.128/25", country: "NL", registry: "ripencc" },
782
+ intel: {
783
+ ptr: "smtp-out-3.freemail.example",
784
+ asn: 64_502,
785
+ asName: "Freemail Networks B.V.",
786
+ prefix: "198.51.100.128/25",
787
+ country: "NL",
788
+ registry: "ripencc",
789
+ },
612
790
  authentication: {
613
791
  ip: "198.51.100.177",
614
792
  helo: "smtp-out-3.freemail.example",
615
793
  mailFrom: "maya.chen.desk@freemail.example",
616
794
  spf: "pass",
617
795
  spfHelo: "pass",
618
- dkim: [{ domain: "freemail.example", selector: "fm1", result: "pass", signs: ["from", "to", "subject", "date", "message-id"] }],
796
+ dkim: [
797
+ {
798
+ domain: "freemail.example",
799
+ selector: "fm1",
800
+ result: "pass",
801
+ signs: ["from", "to", "subject", "date", "message-id"],
802
+ },
803
+ ],
619
804
  dmarc: "pass",
620
805
  policy: "reject",
621
806
  spamScore: 1,
@@ -625,32 +810,43 @@ function demoInputs(mailboxId: string): DemoInput[] {
625
810
  spamConfidence: 0.62,
626
811
  folderId: null,
627
812
  folderConfidence: 0,
628
- reason: "Urgent favour request from a free webmail account that uses a colleague's name; possible impersonation.",
813
+ reason:
814
+ "Urgent favour request from a free webmail account that uses a colleague's name; possible impersonation.",
629
815
  },
630
816
  },
631
- }),
632
- ({
817
+ },
818
+ {
633
819
  id: "msg_demo_16",
634
820
  conversationId: "conv_demo_password",
635
821
  messageId: "<expiry-20931@demo-examp1e.com>",
636
- from: { address: "it-support@demo-examp1e.com", name: "IT Service Desk" },
637
- to: [ilya],
822
+ from: {
823
+ address: "it-support@demo-examp1e.com",
824
+ name: "IT Service Desk",
825
+ },
826
+ to: [sam],
638
827
  subject: "Action required: your mailbox password expires today",
639
- preview: "Your password for ilya@demo.example expires in 4 hours. Keep your current password to avoid losing access.",
640
- body: "Your password for ilya@demo.example expires in 4 hours.\n\nKeep your current password to avoid losing access to mail and files:\nhttps://demo-examp1e.com/account/keep-password?u=ilya\n\nIT Service Desk",
828
+ preview:
829
+ "Your password for sam@demo.example expires in 4 hours. Keep your current password to avoid losing access.",
830
+ body: "Your password for sam@demo.example expires in 4 hours.\n\nKeep your current password to avoid losing access to mail and files:\nhttps://demo-examp1e.com/account/keep-password?u=sam\n\nIT Service Desk",
641
831
  ageMs: 3_000_000,
642
832
  checks: {
643
833
  direct: true,
644
834
  mailer: "PHPMailer 6.9",
645
835
  intel: {
646
836
  ptr: "vps-2207.cheap-cloud.example",
647
- asn: 64503,
837
+ asn: 64_503,
648
838
  asName: "Cheap Cloud VPS",
649
839
  prefix: "203.0.113.192/26",
650
840
  country: "RU",
651
841
  registry: "ripencc",
652
842
  spamhaus: {
653
- dbl: [{ domain: "demo-examp1e.com", code: "127.0.1.4", list: "DBL phishing domain" }],
843
+ dbl: [
844
+ {
845
+ domain: "demo-examp1e.com",
846
+ code: "127.0.1.4",
847
+ list: "DBL phishing domain",
848
+ },
849
+ ],
654
850
  domains: ["demo-examp1e.com"],
655
851
  },
656
852
  },
@@ -670,30 +866,46 @@ function demoInputs(mailboxId: string): DemoInput[] {
670
866
  spamConfidence: 0.71,
671
867
  folderId: null,
672
868
  folderConfidence: 0,
673
- reason: "Password-expiry notice from demo-examp1e.com, a lookalike of the workspace domain, with a credential link.",
869
+ reason:
870
+ "Password-expiry notice from demo-examp1e.com, a lookalike of the workspace domain, with a credential link.",
674
871
  },
675
872
  },
676
- }),
677
- ({
873
+ },
874
+ {
678
875
  id: "msg_demo_17",
679
876
  conversationId: "conv_demo_meetup",
680
877
  messageId: "<meetup-intro@harborlight.example>",
681
878
  from: { address: "elena@harborlight.example", name: "Elena Petrova" },
682
- to: [ilya],
879
+ to: [sam],
683
880
  subject: "Intro: design systems meetup in November",
684
- preview: "Priya mentioned you have been rebuilding your mail client. Would you give a 15-minute talk at our meetup?",
685
- body: "Hi Ilya,\n\nPriya mentioned you have been rebuilding your mail client from scratch. We run a small design systems meetup and would love a 15-minute talk in November.\n\nNo slides needed — a live demo is perfect.\n\nElena",
881
+ preview:
882
+ "Priya mentioned you have been rebuilding your mail client. Would you give a 15-minute talk at our meetup?",
883
+ body: "Hi Sam,\n\nPriya mentioned you have been rebuilding your mail client from scratch. We run a small design systems meetup and would love a 15-minute talk in November.\n\nNo slides needed — a live demo is perfect.\n\nElena",
686
884
  ageMs: 6_000_000,
687
885
  checks: {
688
886
  mailer: "Mozilla Thunderbird 140.2",
689
- intel: { ptr: "mx-out.harborlight.example", asn: 64504, asName: "Harborlight Studio", prefix: "198.51.100.0/27", country: "PT", registry: "ripencc" },
887
+ intel: {
888
+ ptr: "mx-out.harborlight.example",
889
+ asn: 64_504,
890
+ asName: "Harborlight Studio",
891
+ prefix: "198.51.100.0/27",
892
+ country: "PT",
893
+ registry: "ripencc",
894
+ },
690
895
  authentication: {
691
896
  ip: "198.51.100.12",
692
897
  helo: "mx-out.harborlight.example",
693
898
  mailFrom: "elena@harborlight.example",
694
899
  spf: "pass",
695
900
  spfHelo: "pass",
696
- dkim: [{ domain: "harborlight.example", selector: "hl", result: "pass", signs: ["from", "to", "subject", "date", "message-id"] }],
901
+ dkim: [
902
+ {
903
+ domain: "harborlight.example",
904
+ selector: "hl",
905
+ result: "pass",
906
+ signs: ["from", "to", "subject", "date", "message-id"],
907
+ },
908
+ ],
697
909
  dmarc: "pass",
698
910
  policy: "quarantine",
699
911
  spamScore: 0,
@@ -703,31 +915,50 @@ function demoInputs(mailboxId: string): DemoInput[] {
703
915
  spamConfidence: 0.04,
704
916
  folderId: null,
705
917
  folderConfidence: 0.08,
706
- reason: "A personal speaking invitation that references a mutual colleague.",
918
+ reason:
919
+ "A personal speaking invitation that references a mutual colleague.",
707
920
  },
708
921
  },
709
- }),
710
- ({
922
+ },
923
+ {
711
924
  id: "msg_demo_18",
712
925
  conversationId: "conv_demo_receipt",
713
926
  messageId: "<receipt-1031@orbitalcloud.example>",
714
- from: { address: "billing@orbitalcloud.example", name: "Orbital Cloud" },
715
- to: [ilya],
927
+ from: {
928
+ address: "billing@orbitalcloud.example",
929
+ name: "Orbital Cloud",
930
+ },
931
+ to: [sam],
716
932
  subject: "Your October receipt",
717
- preview: "Thanks for your payment of $48.00 for the Team plan. Your next invoice is due on November 30.",
933
+ preview:
934
+ "Thanks for your payment of $48.00 for the Team plan. Your next invoice is due on November 30.",
718
935
  body: "Thanks for your payment of $48.00 for the Team plan.\n\nReceipt OC-1031 · Paid with card ending 4242\nYour next invoice is due on November 30.\n\nOrbital Cloud Billing",
719
936
  ageMs: 20_000_000,
720
937
  checks: {
721
938
  direct: true,
722
939
  mailer: "Orbital Billing",
723
- intel: { ptr: "o12.mail.orbitalcloud.example", asn: 64505, asName: "Orbital Cloud Inc.", prefix: "203.0.113.0/26", country: "US", bimi: true },
940
+ intel: {
941
+ ptr: "o12.mail.orbitalcloud.example",
942
+ asn: 64_505,
943
+ asName: "Orbital Cloud Inc.",
944
+ prefix: "203.0.113.0/26",
945
+ country: "US",
946
+ bimi: true,
947
+ },
724
948
  authentication: {
725
949
  ip: "203.0.113.12",
726
950
  helo: "o12.mail.orbitalcloud.example",
727
951
  mailFrom: "bounces@mail.orbitalcloud.example",
728
952
  spf: "pass",
729
953
  spfHelo: "pass",
730
- dkim: [{ domain: "orbitalcloud.example", selector: "oc2026", result: "pass", signs: ["from", "to", "subject", "date", "message-id"] }],
954
+ dkim: [
955
+ {
956
+ domain: "orbitalcloud.example",
957
+ selector: "oc2026",
958
+ result: "pass",
959
+ signs: ["from", "to", "subject", "date", "message-id"],
960
+ },
961
+ ],
731
962
  dmarc: "pass",
732
963
  policy: "reject",
733
964
  spamScore: 0,
@@ -737,31 +968,53 @@ function demoInputs(mailboxId: string): DemoInput[] {
737
968
  spamConfidence: 0.02,
738
969
  folderId: null,
739
970
  folderConfidence: 0.15,
740
- reason: "Payment receipt from a service the mailbox already pays for, fully authenticated.",
971
+ reason:
972
+ "Payment receipt from a service the mailbox already pays for, fully authenticated.",
741
973
  },
742
974
  },
743
- }),
744
- ({
975
+ },
976
+ {
745
977
  id: "msg_demo_19",
746
978
  conversationId: "conv_demo_bank_details",
747
979
  messageId: "<inv-2207-update@paydesk-mailer.example>",
748
- from: { address: "accounts@northwind-supplies.example", name: "Northwind Supplies Accounts" },
749
- replyTo: { address: "northwind.accounts@quickmail.example", name: "Northwind Supplies Accounts" },
750
- to: [ilya],
980
+ from: {
981
+ address: "accounts@northwind-supplies.example",
982
+ name: "Northwind Supplies Accounts",
983
+ },
984
+ replyTo: {
985
+ address: "northwind.accounts@quickmail.example",
986
+ name: "Northwind Supplies Accounts",
987
+ },
988
+ to: [sam],
751
989
  subject: "Updated bank details for invoice INV-2207",
752
- preview: "Our bank has changed. Please send the payment for INV-2207 to the new account below by end of day.",
990
+ preview:
991
+ "Our bank has changed. Please send the payment for INV-2207 to the new account below by end of day.",
753
992
  body: "Hello,\n\nOur bank has changed after an internal audit. Please send the payment for invoice INV-2207 (€18,400.00) to the new account below by end of day, and reply to confirm once it is done.\n\nIBAN: XX00 0000 0000 0000 0000 00\nReference: INV-2207\n\nKind regards,\nAccounts team",
754
993
  ageMs: 1_800_000,
755
994
  checks: {
756
995
  mailer: "PayDesk Mailer 3.1",
757
- intel: { ptr: "smtp-4.paydesk-mailer.example", asn: 64506, asName: "PayDesk Mailer Ltd", prefix: "198.51.100.128/26", country: "NL", registry: "ripencc" },
996
+ intel: {
997
+ ptr: "smtp-4.paydesk-mailer.example",
998
+ asn: 64_506,
999
+ asName: "PayDesk Mailer Ltd",
1000
+ prefix: "198.51.100.128/26",
1001
+ country: "NL",
1002
+ registry: "ripencc",
1003
+ },
758
1004
  authentication: {
759
1005
  ip: "198.51.100.140",
760
1006
  helo: "smtp-4.paydesk-mailer.example",
761
1007
  mailFrom: "bounce-2207@paydesk-mailer.example",
762
1008
  spf: "pass",
763
1009
  spfHelo: "pass",
764
- dkim: [{ domain: "paydesk-mailer.example", selector: "pd1", result: "pass", signs: ["from", "to", "subject", "date", "reply-to"] }],
1010
+ dkim: [
1011
+ {
1012
+ domain: "paydesk-mailer.example",
1013
+ selector: "pd1",
1014
+ result: "pass",
1015
+ signs: ["from", "to", "subject", "date", "reply-to"],
1016
+ },
1017
+ ],
765
1018
  dmarc: "none",
766
1019
  policy: null,
767
1020
  spamScore: 2,
@@ -771,34 +1024,102 @@ function demoInputs(mailboxId: string): DemoInput[] {
771
1024
  spamConfidence: 0.58,
772
1025
  folderId: null,
773
1026
  folderConfidence: 0,
774
- reason: "Payment redirection request whose replies go to a free-mail address; possible invoice fraud.",
1027
+ reason:
1028
+ "Payment redirection request whose replies go to a free-mail address; possible invoice fraud.",
775
1029
  },
776
1030
  },
777
- }),
1031
+ },
778
1032
  ];
779
1033
  }
780
1034
 
781
1035
  if (mailboxId === "mbx_demo_support") {
782
1036
  return [
783
- ({ id: "msg_demo_08", conversationId: "conv_demo_customer1", messageId: "<help1@customer.demo>", from: { address: "noah@northstar.studio", name: "Noah Williams" }, to: [support], subject: "Can we use our own sending domain?", preview: "We are evaluating the product for our studio and need mail to come from our existing domain.", body: "Hi team,\n\nWe are evaluating the product for our studio and need mail to come from our existing domain. Is that supported, and which DNS records do we need to add?\n\nThanks,\nNoah", ageMs: 900_000 }),
784
- ({ id: "msg_demo_09", conversationId: "conv_demo_customer2", messageId: "<help2@customer.demo>", from: { address: "amina@harbor.so", name: "Amina Okafor" }, to: [support], subject: "Importing an existing mailbox", preview: "Is there a recommended path for importing a few years of historical email?", body: "Hello,\n\nIs there a recommended path for importing a few years of historical email? We have roughly 18 GB and would like to preserve threads if possible.\n\nAmina", ageMs: 7_200_000 }),
785
- ({ id: "msg_demo_10", conversationId: "conv_demo_customer3", messageId: "<help3@customer.demo>", from: { address: "lea@atelier.fr", name: "Léa Martin" }, to: [support], subject: "Shared inbox notifications", preview: "Could each person choose which shared mailboxes should send browser notifications?", body: "Bonjour,\n\nCould each person choose which shared mailboxes should send browser notifications? We have support and press addresses, but not everyone needs both.\n\nMerci,\nLéa", ageMs: 97_200_000 }),
786
- ({ id: "msg_demo_11", conversationId: "conv_demo_customer3", messageId: "<support-reply@demo>", direction: "outgoing", from: support, to: [{ address: "lea@atelier.fr", name: "Léa Martin" }], subject: "Re: Shared inbox notifications", preview: "Yes — notification preferences are per person and per mailbox.", body: "Hi Léa,\n\nYes — notification preferences are per person and per mailbox. You can stay in the shared inbox without receiving every browser notification.\n\nBest,\nMaya", ageMs: 90_000_000, references: ["<help3@customer.demo>"] }),
787
- ({ id: "msg_demo_12", conversationId: "conv_demo_spam", messageId: "<promo@spam.demo>", from: { address: "offers@growth-hack.invalid", name: "Growth Network" }, to: [support], subject: "10x your pipeline overnight", preview: "One weird trick your competitors do not want you to know.", body: "One weird trick your competitors do not want you to know.", ageMs: 345_600_000,
1037
+ {
1038
+ id: "msg_demo_08",
1039
+ conversationId: "conv_demo_customer1",
1040
+ messageId: "<help1@customer.demo>",
1041
+ from: { address: "noah@northstar.example", name: "Noah Williams" },
1042
+ to: [support],
1043
+ subject: "Can we use our own sending domain?",
1044
+ preview:
1045
+ "We are evaluating the product for our studio and need mail to come from our existing domain.",
1046
+ body: "Hi team,\n\nWe are evaluating the product for our studio and need mail to come from our existing domain. Is that supported, and which DNS records do we need to add?\n\nThanks,\nNoah",
1047
+ ageMs: 900_000,
1048
+ },
1049
+ {
1050
+ id: "msg_demo_09",
1051
+ conversationId: "conv_demo_customer2",
1052
+ messageId: "<help2@customer.demo>",
1053
+ from: { address: "amina@harbor.example", name: "Amina Okafor" },
1054
+ to: [support],
1055
+ subject: "Importing an existing mailbox",
1056
+ preview:
1057
+ "Is there a recommended path for importing a few years of historical email?",
1058
+ body: "Hello,\n\nIs there a recommended path for importing a few years of historical email? We have roughly 18 GB and would like to preserve threads if possible.\n\nAmina",
1059
+ ageMs: 7_200_000,
1060
+ },
1061
+ {
1062
+ id: "msg_demo_10",
1063
+ conversationId: "conv_demo_customer3",
1064
+ messageId: "<help3@customer.demo>",
1065
+ from: { address: "lea@atelier.example", name: "Léa Martin" },
1066
+ to: [support],
1067
+ subject: "Shared inbox notifications",
1068
+ preview:
1069
+ "Could each person choose which shared mailboxes should send browser notifications?",
1070
+ body: "Bonjour,\n\nCould each person choose which shared mailboxes should send browser notifications? We have support and press addresses, but not everyone needs both.\n\nMerci,\nLéa",
1071
+ ageMs: 97_200_000,
1072
+ },
1073
+ {
1074
+ id: "msg_demo_11",
1075
+ conversationId: "conv_demo_customer3",
1076
+ messageId: "<support-reply@demo>",
1077
+ direction: "outgoing",
1078
+ from: support,
1079
+ to: [{ address: "lea@atelier.example", name: "Léa Martin" }],
1080
+ subject: "Re: Shared inbox notifications",
1081
+ preview:
1082
+ "Yes — notification preferences are per person and per mailbox.",
1083
+ body: "Hi Léa,\n\nYes — notification preferences are per person and per mailbox. You can stay in the shared inbox without receiving every browser notification.\n\nBest,\nMaya",
1084
+ ageMs: 90_000_000,
1085
+ references: ["<help3@customer.demo>"],
1086
+ },
1087
+ {
1088
+ id: "msg_demo_12",
1089
+ conversationId: "conv_demo_spam",
1090
+ messageId: "<promo@spam.demo>",
1091
+ from: { address: "offers@growth-hack.invalid", name: "Growth Network" },
1092
+ to: [support],
1093
+ subject: "10x your pipeline overnight",
1094
+ preview: "One weird trick your competitors do not want you to know.",
1095
+ body: "One weird trick your competitors do not want you to know.",
1096
+ ageMs: 345_600_000,
788
1097
  checks: {
789
1098
  direct: true,
790
1099
  intel: {
791
1100
  ptr: "77-2-0-192.dyn.broadband-pool.example",
792
1101
  fcrdns: false,
793
1102
  generic: true,
794
- asn: 64511,
1103
+ asn: 64_511,
795
1104
  asName: "Bulk Hosting Ltd",
796
1105
  prefix: "192.0.2.0/24",
797
1106
  country: "SC",
798
1107
  registry: "afrinic",
799
1108
  spamhaus: {
800
- zen: [{ code: "127.0.0.4", list: "XBL (compromised host)", severity: "abuse" }],
801
- dbl: [{ domain: "growth-hack.invalid", code: "127.0.1.2", list: "DBL spam domain" }],
1109
+ zen: [
1110
+ {
1111
+ code: "127.0.0.4",
1112
+ list: "XBL (compromised host)",
1113
+ severity: "abuse",
1114
+ },
1115
+ ],
1116
+ dbl: [
1117
+ {
1118
+ domain: "growth-hack.invalid",
1119
+ code: "127.0.1.2",
1120
+ list: "DBL spam domain",
1121
+ },
1122
+ ],
802
1123
  domains: ["growth-hack.invalid"],
803
1124
  },
804
1125
  },
@@ -808,7 +1129,14 @@ function demoInputs(mailboxId: string): DemoInput[] {
808
1129
  mailFrom: "offers@growth-hack.invalid",
809
1130
  spf: "softfail",
810
1131
  spfHelo: "none",
811
- dkim: [{ domain: "bulk-sender.example", selector: "default", result: "pass", signs: ["from", "subject", "date"] }],
1132
+ dkim: [
1133
+ {
1134
+ domain: "bulk-sender.example",
1135
+ selector: "default",
1136
+ result: "pass",
1137
+ signs: ["from", "subject", "date"],
1138
+ },
1139
+ ],
812
1140
  dmarc: "fail",
813
1141
  policy: "none",
814
1142
  spamScore: 5,
@@ -818,14 +1146,36 @@ function demoInputs(mailboxId: string): DemoInput[] {
818
1146
  spamConfidence: 0.97,
819
1147
  folderId: null,
820
1148
  folderConfidence: 0,
821
- reason: "Unsolicited bulk promotion with exaggerated claims from a sender that fails SPF and DMARC.",
1149
+ reason:
1150
+ "Unsolicited bulk promotion with exaggerated claims from a sender that fails SPF and DMARC.",
822
1151
  },
823
- } }),
824
- ({ id: "msg_demo_20", conversationId: "conv_demo_quota", messageId: "<quota-77@mail-quota-alerts.example>", from: { address: "admin@mail-quota-alerts.example", name: "Mailbox Administrator" }, to: [support], subject: "Your mailbox storage is full", preview: "Incoming messages are being held. Verify your account within 24 hours to release them.", body: "Your mailbox storage is full.\n\n14 incoming messages are being held. Verify your account within 24 hours to release them:\nhttps://mail-quota-alerts.example/verify?box=support\n\nMailbox Administrator", ageMs: 5_400_000,
1152
+ },
1153
+ },
1154
+ {
1155
+ id: "msg_demo_20",
1156
+ conversationId: "conv_demo_quota",
1157
+ messageId: "<quota-77@mail-quota-alerts.example>",
1158
+ from: {
1159
+ address: "admin@mail-quota-alerts.example",
1160
+ name: "Mailbox Administrator",
1161
+ },
1162
+ to: [support],
1163
+ subject: "Your mailbox storage is full",
1164
+ preview:
1165
+ "Incoming messages are being held. Verify your account within 24 hours to release them.",
1166
+ body: "Your mailbox storage is full.\n\n14 incoming messages are being held. Verify your account within 24 hours to release them:\nhttps://mail-quota-alerts.example/verify?box=support\n\nMailbox Administrator",
1167
+ ageMs: 5_400_000,
825
1168
  checks: {
826
1169
  direct: true,
827
1170
  mailer: "PHPMailer 6.9",
828
- intel: { ptr: null, asn: 64509, asName: "Anon VPS Hosting", prefix: "192.0.2.128/25", country: "PA", registry: "lacnic" },
1171
+ intel: {
1172
+ ptr: null,
1173
+ asn: 64_509,
1174
+ asName: "Anon VPS Hosting",
1175
+ prefix: "192.0.2.128/25",
1176
+ country: "PA",
1177
+ registry: "lacnic",
1178
+ },
829
1179
  authentication: {
830
1180
  ip: "192.0.2.201",
831
1181
  helo: "localhost",
@@ -842,9 +1192,11 @@ function demoInputs(mailboxId: string): DemoInput[] {
842
1192
  spamConfidence: 0.91,
843
1193
  folderId: null,
844
1194
  folderConfidence: 0,
845
- reason: "Credential-harvesting storage warning from an unauthenticated sender with a verification link.",
1195
+ reason:
1196
+ "Credential-harvesting storage warning from an unauthenticated sender with a verification link.",
846
1197
  },
847
- } }),
1198
+ },
1199
+ },
848
1200
  ];
849
1201
  }
850
1202
 
@@ -852,43 +1204,59 @@ function demoInputs(mailboxId: string): DemoInput[] {
852
1204
  }
853
1205
 
854
1206
  /** A tiny self-made logo for the fictional orbitalcloud.example (SVG Tiny PS). */
855
- const orbitalCloudLogo = '<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny-ps" viewBox="0 0 64 64"><title>Orbital Cloud</title><rect width="64" height="64" fill="#1e3a8a"/><circle cx="32" cy="32" r="11" fill="#f8fafc"/><ellipse cx="32" cy="32" rx="23" ry="8" fill="none" stroke="#7dd3fc" stroke-width="3" transform="rotate(-24 32 32)"/><circle cx="51" cy="24" r="3.5" fill="#fbbf24"/></svg>';
1207
+ const orbitalCloudLogo =
1208
+ '<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny-ps" viewBox="0 0 64 64"><title>Orbital Cloud</title><rect width="64" height="64" fill="#1e3a8a"/><circle cx="32" cy="32" r="11" fill="#f8fafc"/><ellipse cx="32" cy="32" rx="23" ry="8" fill="none" stroke="#7dd3fc" stroke-width="3" transform="rotate(-24 32 32)"/><circle cx="51" cy="24" r="3.5" fill="#fbbf24"/></svg>';
856
1209
 
857
1210
  /**
858
1211
  * Earlier correspondence the demo implies but does not seed as messages, so
859
1212
  * known contacts do not all read as first-time senders.
860
1213
  */
861
1214
  export function demoMailboxSenders(mailboxId: string, now = Date.now()) {
862
- const known = (address: string, messageCount: number, outboundCount: number, firstSeenDaysAgo: number) => ({
1215
+ const known = (
1216
+ address: string,
1217
+ messageCount: number,
1218
+ outboundCount: number,
1219
+ firstSeenDaysAgo: number
1220
+ ) => ({
863
1221
  address,
864
- domain: address.split("@")[1]!,
1222
+ domain: demoDomain(address),
865
1223
  firstSeenAt: new Date(now - firstSeenDaysAgo * 86_400_000),
866
1224
  lastSeenAt: new Date(now - 7 * 86_400_000),
867
1225
  messageCount,
868
1226
  outboundCount,
869
1227
  lastOutboundAt: outboundCount ? new Date(now - 10 * 86_400_000) : null,
870
1228
  });
1229
+
871
1230
  if (mailboxId === "mbx_demo_personal") {
872
1231
  return [
873
- known("jessica@cloudflare.com", 6, 4, 210),
874
- known("rauno@vercel.com", 9, 7, 400),
875
- known("digest@dense-discovery.com", 40, 0, 300),
876
- known("billing@figma.com", 12, 0, 365),
1232
+ known("jessica@edgeworks.example", 6, 4, 210),
1233
+ known("rafael@vertex.example", 9, 7, 400),
1234
+ known("digest@margin-notes.example", 40, 0, 300),
1235
+ known("billing@canvasly.example", 12, 0, 365),
877
1236
  known("notifications@hireline.example", 5, 0, 60),
878
1237
  known("priya@northwind.example", 14, 11, 500),
879
1238
  known("billing@orbitalcloud.example", 9, 0, 280),
880
1239
  known("accounts@northwind-supplies.example", 4, 2, 150),
881
1240
  // Blocked before the demo starts: future mail from the domain goes to Spam.
882
- { address: "@prize-center.example", domain: "prize-center.example", blockedAt: new Date(now - 20 * 86_400_000) },
1241
+ {
1242
+ address: "@prize-center.example",
1243
+ domain: "prize-center.example",
1244
+ blockedAt: new Date(now - 20 * 86_400_000),
1245
+ },
883
1246
  ];
884
1247
  }
1248
+
885
1249
  if (mailboxId === "mbx_demo_support") {
886
- return [known("amina@harbor.so", 2, 1, 30)];
1250
+ return [known("amina@harbor.example", 2, 1, 30)];
887
1251
  }
1252
+
888
1253
  return [];
889
1254
  }
890
1255
 
891
- export function demoMailboxEmails(mailboxId: string, now = Date.now()): NewEmail[] {
1256
+ export function demoMailboxEmails(
1257
+ mailboxId: string,
1258
+ now = Date.now()
1259
+ ): NewEmail[] {
892
1260
  return demoInputs(mailboxId).map((input) => email(input, now));
893
1261
  }
894
1262
 
@@ -896,24 +1264,43 @@ export function demoMailboxEmails(mailboxId: string, now = Date.now()): NewEmail
896
1264
  export function demoMailboxObjects(mailboxId: string, now = Date.now()) {
897
1265
  return demoInputs(mailboxId).flatMap((input) => [
898
1266
  ...(input.html
899
- ? [{ key: demoHtmlKey(input.id), body: input.html, contentType: "text/html; charset=utf-8" }]
1267
+ ? [
1268
+ {
1269
+ key: demoHtmlKey(input.id),
1270
+ body: input.html,
1271
+ contentType: "text/html; charset=utf-8",
1272
+ },
1273
+ ]
900
1274
  : []),
901
1275
  ...(input.checks
902
- ? [{ key: demoRawKey(input.id), body: demoRawMime(input, now), contentType: "message/rfc822" }]
1276
+ ? [
1277
+ {
1278
+ key: demoRawKey(input.id),
1279
+ body: demoRawMime(input, now),
1280
+ contentType: "message/rfc822",
1281
+ },
1282
+ ]
903
1283
  : []),
904
1284
  ...(input.checks?.intel?.bimi
905
- ? [{
906
- key: bimiObjectKey(input.from.address.split("@")[1]!),
907
- body: orbitalCloudLogo,
908
- contentType: "image/svg+xml",
909
- customMetadata: { status: "ok", checkedAt: String(now), reason: "" },
910
- }]
1285
+ ? [
1286
+ {
1287
+ key: bimiObjectKey(demoDomain(input.from.address)),
1288
+ body: orbitalCloudLogo,
1289
+ contentType: "image/svg+xml",
1290
+ customMetadata: {
1291
+ status: "ok",
1292
+ checkedAt: String(now),
1293
+ reason: "",
1294
+ },
1295
+ },
1296
+ ]
911
1297
  : []),
912
1298
  ]);
913
1299
  }
914
1300
 
915
1301
  export function demoMailboxFolders(mailboxId: string): NewFolder[] {
916
1302
  if (mailboxId !== "mbx_demo_personal") return [];
1303
+
917
1304
  return [
918
1305
  {
919
1306
  id: "Product",
@@ -931,6 +1318,7 @@ export function demoMailboxFolders(mailboxId: string): NewFolder[] {
931
1318
  export function demoMailboxConversationState(mailboxId: string) {
932
1319
  // Conversations the security actions move are reset on every demo login.
933
1320
  const inbox = { mailboxState: "active" as const, folderId: null };
1321
+
934
1322
  if (mailboxId === "mbx_demo_personal") {
935
1323
  return [
936
1324
  { id: "conv_demo_weekly", ...inbox },
@@ -939,40 +1327,22 @@ export function demoMailboxConversationState(mailboxId: string) {
939
1327
  { id: "conv_demo_hiring", ...inbox },
940
1328
  { id: "conv_demo_receipt", ...inbox },
941
1329
  { id: "conv_demo_maya", folderId: "Product" },
942
- { id: "conv_demo_vercel", folderId: "Pitch Decks" },
1330
+ { id: "conv_demo_vertex", folderId: "Pitch Decks" },
943
1331
  { id: "conv_demo_invoice", mailboxState: "archive" as const },
944
1332
  ];
945
1333
  }
1334
+
946
1335
  if (mailboxId === "mbx_demo_support") {
947
1336
  return [
948
1337
  { id: "conv_demo_spam", mailboxState: "spam" as const },
949
1338
  { id: "conv_demo_quota", mailboxState: "spam" as const },
950
1339
  ];
951
1340
  }
952
- return [];
953
- }
954
1341
 
955
- /** One filter so the Rules tab has something to show; it applies to new mail only. */
956
- export function demoMailboxRules(mailboxId: string): Array<MailRuleInput & { id: string }> {
957
- if (mailboxId !== "mbx_demo_personal") return [];
958
- return [{
959
- id: "rul_demo_hireline",
960
- name: "Job alerts",
961
- enabled: true,
962
- conditions: { from: "@hireline.example" },
963
- actions: { archive: true, markRead: true },
964
- }];
1342
+ return [];
965
1343
  }
966
1344
 
967
1345
  /** Message ids whose report labels a demo login clears. */
968
1346
  export function demoMailboxEmailIds(mailboxId: string) {
969
1347
  return demoInputs(mailboxId).map((input) => input.id);
970
1348
  }
971
-
972
- /** A phishing report waiting in Administration → Reported messages. */
973
- export const demoReportedMessage = {
974
- id: "rpt_demo_quota",
975
- mailboxId: "mbx_demo_support",
976
- emailId: "msg_demo_20",
977
- reportLabel: "phishing" as const,
978
- };