@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.
- package/README.md +22 -22
- package/alchemy/index.ts +273 -0
- package/drizzle/mailbox/0000_puzzling_dracula.sql +149 -0
- package/drizzle/mailbox/0001_mute_jack_flag.sql +12 -0
- package/drizzle/mailbox/meta/0000_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/0001_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/_journal.json +20 -0
- package/drizzle/mailbox/migrations.js +12 -0
- package/index.ts +3 -1
- package/migrations/{0000_email.sql → 0000_dry_moon_knight.sql} +26 -20
- package/migrations/meta/0000_snapshot.json +125 -109
- package/migrations/meta/_journal.json +2 -2
- package/package.json +74 -68
- package/shared/attachment-preview.ts +37 -27
- package/shared/folder-order.ts +106 -0
- package/shared/mail-authentication.ts +8 -3
- package/shared/mail-feedback.ts +18 -25
- package/shared/mail-headers.ts +114 -39
- package/shared/mail-import.ts +38 -0
- package/shared/mail-path.ts +42 -0
- package/shared/mail-received.ts +174 -31
- package/shared/mail-remote.ts +59 -2
- package/shared/mail-sender-intel.ts +22 -4
- package/shared/mail.ts +77 -28
- package/shared/module.ts +33 -0
- package/shared/office-preview.ts +14 -2
- package/shared/pdfjs-assets.ts +35 -0
- package/shared/permissions.ts +73 -0
- package/shared/webhooks.ts +41 -0
- package/src/admin/blocked-senders.tsx +189 -0
- package/src/client.tsx +97 -0
- package/src/lib/mail-api.ts +9 -0
- package/src/mail/attachment-preview-dialog.tsx +161 -0
- package/src/mail/blocked-senders.tsx +138 -0
- package/src/mail/compose-window-chrome.tsx +194 -0
- package/src/mail/compose-window.tsx +486 -0
- package/src/mail/composer-asset-bookmarks.ts +409 -0
- package/src/mail/composer-asset.tsx +229 -0
- package/src/mail/composer-attachment-list.tsx +138 -0
- package/src/mail/composer-editor-document.ts +65 -0
- package/src/mail/composer-editor.tsx +284 -0
- package/src/mail/composer-linked-attachment-text.ts +12 -0
- package/src/mail/composer-recipient-fields.tsx +165 -0
- package/src/mail/composer-recipients.ts +208 -0
- package/src/mail/composer-session.ts +562 -0
- package/src/mail/composer-toolbar.tsx +303 -0
- package/src/mail/composer-upload-client.ts +105 -0
- package/src/mail/composer-upload-progress.ts +53 -0
- package/src/mail/conversation-list.tsx +550 -0
- package/src/mail/conversation-loading-skeleton.tsx +119 -0
- package/src/mail/conversation-message.tsx +346 -0
- package/src/mail/conversation-reply.tsx +470 -0
- package/src/mail/conversation-selection-toolbar.tsx +322 -0
- package/src/mail/conversation-view.tsx +437 -0
- package/src/mail/delivery-indicator.tsx +272 -0
- package/src/mail/email-html-body.tsx +203 -0
- package/src/mail/folder-glyph.tsx +46 -0
- package/src/mail/folder-manager.tsx +532 -0
- package/src/mail/format-bytes.ts +7 -0
- package/src/mail/mail-app-bar.tsx +253 -0
- package/src/mail/mail-background.tsx +12 -0
- package/src/mail/mail-dock.tsx +137 -0
- package/src/mail/mail-folders.ts +44 -0
- package/src/mail/mail-layout.css +236 -0
- package/src/mail/mail-location.ts +73 -0
- package/src/mail/mail-mailbox-sheet.tsx +275 -0
- package/src/mail/mail-nav-rail.tsx +129 -0
- package/src/mail/mail-nav.tsx +324 -0
- package/src/mail/mail-prefetch.ts +59 -0
- package/src/mail/mail-primitives.tsx +66 -0
- package/src/mail/mail-queries.ts +209 -0
- package/src/mail/mail-query-cache.ts +486 -0
- package/src/mail/mail-seed.ts +47 -0
- package/src/mail/mail-shell.tsx +126 -0
- package/src/mail/mailbox-ai-settings.tsx +185 -0
- package/src/mail/mailbox-realtime.tsx +251 -0
- package/src/mail/mailbox-route.tsx +15 -0
- package/src/mail/message-actions.tsx +353 -0
- package/src/mail/message-attachments.tsx +200 -0
- package/src/mail/message-format.ts +75 -0
- package/src/mail/message-header.tsx +260 -0
- package/src/mail/message-translation.tsx +225 -0
- package/src/mail/original-message-sheet.tsx +619 -0
- package/src/mail/original-message.ts +191 -0
- package/src/mail/outbound-notification.ts +53 -0
- package/src/mail/pane-splitter.tsx +117 -0
- package/src/mail/pdf-preview-toolbar.tsx +152 -0
- package/src/mail/pdf-preview.css +44 -0
- package/src/mail/pdf-preview.tsx +156 -0
- package/src/mail/pdf-translation-layout.ts +95 -0
- package/src/mail/print-message.ts +92 -0
- package/src/mail/reader-pane.tsx +535 -0
- package/src/mail/recipient-combobox.tsx +335 -0
- package/src/mail/recipient-field-row.tsx +34 -0
- package/src/mail/reply-to-warning.tsx +50 -0
- package/src/mail/sanitize-email-html.ts +430 -0
- package/src/mail/sender-actions.tsx +149 -0
- package/src/mail/sender-authentication.tsx +485 -0
- package/src/mail/sender-dialogs.tsx +384 -0
- package/src/mail/sender-security.tsx +545 -0
- package/src/mail/toolbar-tooltip.tsx +29 -0
- package/src/mail/translation-html.ts +49 -0
- package/src/mail/translation-language.ts +21 -0
- package/src/mail/types.ts +53 -0
- package/src/mail/unread-document-indicator.tsx +60 -0
- package/src/mail/use-compose-submission.ts +208 -0
- package/src/mail/use-composer-attachment-preflight.ts +184 -0
- package/src/mail/use-composer-submission.ts +117 -0
- package/src/mail/use-conversation-selection.ts +186 -0
- package/src/mail/use-mail-controller.ts +427 -0
- package/src/mail/use-mail-data.ts +279 -0
- package/src/mail/use-mail-safety.ts +155 -0
- package/src/mail/use-mail-send.ts +142 -0
- package/src/mail/use-pdf-translation-overlay.ts +156 -0
- package/src/mail/use-pdf-translation.ts +100 -0
- package/src/mail/use-pdf-viewer.ts +215 -0
- package/src/mail/use-reply-submission.ts +114 -0
- package/src/mail/use-sanitized-email-html.ts +20 -0
- package/src/mail/use-visible-message-read.ts +138 -0
- package/src/pwa/push-subscription.ts +151 -0
- package/src/settings/mail-apps-page.tsx +235 -0
- package/src/settings/notifications-page.tsx +291 -0
- package/worker/admin/blocked-sender-routes.ts +166 -0
- package/worker/admin/schemas.ts +11 -0
- package/worker/bindings.d.ts +14 -10
- package/worker/db/schema.ts +63 -40
- package/worker/jmap/eventsource.ts +84 -16
- package/worker/jmap/methods.ts +1630 -524
- package/worker/jmap/push-types.ts +27 -0
- package/worker/jmap/push.ts +140 -56
- package/worker/jmap/routes.ts +366 -105
- package/worker/mail/access.ts +258 -21
- package/worker/mail/ai-classification.ts +36 -20
- package/worker/mail/ai-translation.ts +13 -6
- package/worker/mail/auth-headers.ts +395 -137
- package/worker/mail/bimi.ts +200 -73
- package/worker/mail/bootstrap.ts +79 -0
- package/worker/mail/capped-body.ts +36 -0
- package/worker/mail/classification-signals.ts +35 -25
- package/worker/mail/conversation-cursor.ts +30 -19
- package/worker/mail/delivery-events.ts +88 -62
- package/worker/mail/delivery-facts.ts +46 -10
- package/worker/mail/demo-routes.ts +34 -10
- package/worker/mail/doh.ts +62 -23
- package/worker/mail/downloads.ts +75 -40
- package/worker/mail/edge-cache.ts +155 -0
- package/worker/mail/header-metadata.ts +88 -22
- package/worker/mail/impersonation.ts +160 -38
- package/worker/mail/import-routes.ts +313 -0
- package/worker/mail/inbound-delivery.ts +19 -9
- package/worker/mail/inbound-threading.ts +18 -8
- package/worker/mail/inbound.ts +82 -40
- package/worker/mail/ip-intel.ts +110 -27
- package/worker/mail/isolate-cache.ts +35 -0
- package/worker/mail/link-domains.ts +29 -7
- package/worker/mail/mailbox-deletion.ts +10 -4
- package/worker/mail/mailbox-directory.ts +16 -6
- package/worker/mail/mailing-list.ts +94 -39
- package/worker/mail/message-security.ts +90 -15
- package/worker/mail/message-view.ts +18 -6
- package/worker/mail/office-conversion.ts +31 -9
- package/worker/mail/office-preview-container.ts +40 -13
- package/worker/mail/office-preview-queue.ts +76 -32
- package/worker/mail/org-domain.ts +8 -1
- package/worker/mail/outbound-content.ts +71 -26
- package/worker/mail/outbound-delivery.ts +31 -17
- package/worker/mail/outbound-service.ts +48 -30
- package/worker/mail/outbound-threading.ts +30 -17
- package/worker/mail/outbound.ts +97 -70
- package/worker/mail/outgoing-context.ts +25 -15
- package/worker/mail/participants.ts +44 -29
- package/worker/mail/push-notifications.ts +271 -173
- package/worker/mail/quote-parser.ts +21 -10
- package/worker/mail/r2-presigned-urls.ts +31 -25
- package/worker/mail/receive.ts +23 -11
- package/worker/mail/recipients.ts +6 -1
- package/worker/mail/remote-proxy.ts +187 -31
- package/worker/mail/remote-routes.ts +87 -0
- package/worker/mail/remote-token.ts +104 -0
- package/worker/mail/repeat.ts +19 -0
- package/worker/mail/reply-plan.ts +62 -33
- package/worker/mail/rfc.ts +32 -7
- package/worker/mail/routes.ts +870 -541
- package/worker/mail/safety-routes.ts +328 -200
- package/worker/mail/schemas.ts +84 -105
- package/worker/mail/search.ts +1 -0
- package/worker/mail/security-settings.ts +41 -9
- package/worker/mail/sender-intel.ts +206 -51
- package/worker/mail/spamhaus.ts +92 -45
- package/worker/mail/unsubscribe.ts +76 -18
- package/worker/mail/uploads.ts +126 -93
- package/worker/mail/webhook-source.ts +35 -12
- package/worker/mail/workspace-safety.ts +97 -38
- package/worker/mailbox/demo-html.ts +7 -7
- package/worker/mailbox/demo-seed.ts +10 -44
- package/worker/mailbox/demo.ts +595 -225
- package/worker/mailbox/email-index.ts +53 -0
- package/worker/mailbox/folder-model.ts +53 -17
- package/worker/mailbox/import-placement.ts +88 -0
- package/worker/mailbox/inbox-counts.ts +106 -0
- package/worker/mailbox/index.ts +1734 -721
- package/worker/mailbox/jmap-store.ts +139 -35
- package/worker/mailbox/model.ts +8 -6
- package/worker/mailbox/office-preview-jobs.ts +56 -25
- package/worker/mailbox/schema.ts +87 -66
- package/worker/mailbox/senders.ts +176 -70
- package/worker/mcp/mail-action-tools.ts +128 -87
- package/worker/mcp/mail-compose-tools.ts +133 -82
- package/worker/mcp/mail-query-tools.ts +120 -71
- package/worker/mcp/mail-safety-tools.ts +321 -248
- package/worker/mcp/schemas.ts +43 -0
- package/worker/mcp/tools.ts +13 -10
- package/worker/module.ts +43 -18
- package/worker/sql.d.ts +8 -0
- package/alchemy.ts +0 -142
- package/containers/office-preview/Dockerfile +0 -10
- package/shared/mail-rules.ts +0 -156
- package/worker/admin/report-routes.ts +0 -164
- package/worker/mail/reported-messages.ts +0 -68
- package/worker/mailbox/migrations.ts +0 -10
- package/worker/mailbox/rules.ts +0 -110
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { cn } from "@open-workspace/core/ui";
|
|
2
|
+
import { ShieldAlert, ShieldCheck, ShieldQuestion } from "lucide-react";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
AuthResult,
|
|
7
|
+
InboundAuthentication,
|
|
8
|
+
ListUnsubscribe,
|
|
9
|
+
SenderVerdict,
|
|
10
|
+
SenderVerdictReason,
|
|
11
|
+
UpstreamAuthenticationClaim,
|
|
12
|
+
} from "../../shared/mail-authentication";
|
|
13
|
+
|
|
14
|
+
const AUTHENTICATION_DOCS =
|
|
15
|
+
"https://developers.cloudflare.com/email-service/concepts/email-authentication/";
|
|
16
|
+
|
|
17
|
+
type Tone = "pass" | "fail" | "warn" | "neutral";
|
|
18
|
+
|
|
19
|
+
function resultTone(
|
|
20
|
+
value: AuthResult | "pass" | "fail" | "none" | null | undefined
|
|
21
|
+
): Tone {
|
|
22
|
+
if (value === "pass") return "pass";
|
|
23
|
+
|
|
24
|
+
if (value === "fail" || value === "permerror") return "fail";
|
|
25
|
+
|
|
26
|
+
if (value === "softfail" || value === "temperror") return "warn";
|
|
27
|
+
|
|
28
|
+
return "neutral";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function Verdict({ tone, children }: { tone: Tone; children: ReactNode }) {
|
|
32
|
+
return (
|
|
33
|
+
<span
|
|
34
|
+
className={cn(
|
|
35
|
+
"inline-flex h-5 items-center rounded-full px-2 text-[11px] font-semibold tracking-wide whitespace-nowrap",
|
|
36
|
+
tone === "pass" && "bg-success/12 text-success",
|
|
37
|
+
tone === "fail" && "bg-destructive/12 text-destructive",
|
|
38
|
+
tone === "warn" && "bg-warning/18 text-amber-800 dark:text-amber-300",
|
|
39
|
+
tone === "neutral" && "bg-muted text-muted-foreground"
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</span>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function CheckRow({
|
|
48
|
+
label,
|
|
49
|
+
result,
|
|
50
|
+
href,
|
|
51
|
+
children,
|
|
52
|
+
}: {
|
|
53
|
+
label: string;
|
|
54
|
+
result: AuthResult | "pass" | "fail" | "none" | null;
|
|
55
|
+
href: string;
|
|
56
|
+
children?: ReactNode;
|
|
57
|
+
}) {
|
|
58
|
+
return (
|
|
59
|
+
<div className="grid grid-cols-[3.75rem_4.75rem_minmax(0,1fr)] items-baseline gap-x-3 py-2.5">
|
|
60
|
+
<dt className="text-muted-foreground text-xs font-medium">
|
|
61
|
+
<a
|
|
62
|
+
href={href}
|
|
63
|
+
target="_blank"
|
|
64
|
+
rel="noreferrer"
|
|
65
|
+
className="hover:text-foreground hover:underline"
|
|
66
|
+
>
|
|
67
|
+
{label}
|
|
68
|
+
</a>
|
|
69
|
+
</dt>
|
|
70
|
+
<dd>
|
|
71
|
+
<Verdict tone={resultTone(result)}>
|
|
72
|
+
{result ? result.toUpperCase() : "N/A"}
|
|
73
|
+
</Verdict>
|
|
74
|
+
</dd>
|
|
75
|
+
<dd className="min-w-0 text-xs leading-5 [overflow-wrap:anywhere] max-sm:col-span-2 max-sm:col-start-2 max-sm:mt-1">
|
|
76
|
+
{children}
|
|
77
|
+
</dd>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function Muted({ children }: { children: ReactNode }) {
|
|
83
|
+
return <span className="text-muted-foreground">{children}</span>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function Mono({ children }: { children: ReactNode }) {
|
|
87
|
+
return <span className="font-mono text-[11.5px]">{children}</span>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const verdictCopy: Record<SenderVerdict, { title: string; tone: Tone }> =
|
|
91
|
+
{
|
|
92
|
+
verified: { title: "Verified sender", tone: "pass" },
|
|
93
|
+
unverified: { title: "Partially verified", tone: "neutral" },
|
|
94
|
+
suspicious: { title: "Unverified sender", tone: "warn" },
|
|
95
|
+
unavailable: { title: "Not checked", tone: "neutral" },
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
function verdictExplanation(
|
|
99
|
+
reason: SenderVerdictReason,
|
|
100
|
+
fromDomain: string | null
|
|
101
|
+
) {
|
|
102
|
+
const domain = fromDomain ?? "the sender's domain";
|
|
103
|
+
|
|
104
|
+
switch (reason) {
|
|
105
|
+
case "dmarc_pass": {
|
|
106
|
+
return `DMARC passed: ${domain} authorized this message.`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
case "aligned_dkim": {
|
|
110
|
+
return `Signed by ${domain}. The domain publishes no DMARC policy.`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
case "forwarded_arc": {
|
|
114
|
+
return "The message was forwarded. The forwarder recorded passing results before the change.";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
case "dmarc_fail": {
|
|
118
|
+
return `DMARC failed: nothing proves this message came from ${domain}.`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case "no_aligned_pass": {
|
|
122
|
+
return `Neither the signature nor the sending server belongs to ${domain}.`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case "partial": {
|
|
126
|
+
return `Some checks passed, but ${domain} does not publish a DMARC policy to confirm them.`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
case "not_cloudflare": {
|
|
130
|
+
return "This message did not arrive through Cloudflare Email Routing, so no receiver checks were recorded.";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
case "missing_results": {
|
|
134
|
+
return "Cloudflare did not report authentication results for this message.";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
default: {
|
|
138
|
+
const unexpected: never = reason;
|
|
139
|
+
throw new Error(`Unknown sender verdict reason: ${String(unexpected)}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function VerdictSummary({
|
|
145
|
+
authentication,
|
|
146
|
+
}: {
|
|
147
|
+
authentication: InboundAuthentication;
|
|
148
|
+
}) {
|
|
149
|
+
const copy = verdictCopy[authentication.verdict];
|
|
150
|
+
|
|
151
|
+
const Icon =
|
|
152
|
+
copy.tone === "pass"
|
|
153
|
+
? ShieldCheck
|
|
154
|
+
: copy.tone === "warn"
|
|
155
|
+
? ShieldAlert
|
|
156
|
+
: ShieldQuestion;
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<div className="border-border bg-surface-sunken/60 mb-1 flex items-start gap-2.5 rounded-lg border p-3">
|
|
160
|
+
<span
|
|
161
|
+
className={cn(
|
|
162
|
+
"grid size-7 shrink-0 place-items-center rounded-full",
|
|
163
|
+
copy.tone === "pass" && "bg-success/12 text-success",
|
|
164
|
+
copy.tone === "warn" &&
|
|
165
|
+
"bg-warning/18 text-amber-700 dark:text-amber-300",
|
|
166
|
+
copy.tone === "neutral" && "bg-muted text-muted-foreground"
|
|
167
|
+
)}
|
|
168
|
+
>
|
|
169
|
+
<Icon className="size-3.5" />
|
|
170
|
+
</span>
|
|
171
|
+
<div className="min-w-0 text-xs leading-5">
|
|
172
|
+
<p className="text-[13px] font-semibold">{copy.title}</p>
|
|
173
|
+
<p className="text-muted-foreground">
|
|
174
|
+
{verdictExplanation(
|
|
175
|
+
authentication.verdictReason,
|
|
176
|
+
authentication.fromDomain
|
|
177
|
+
)}
|
|
178
|
+
</p>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function listFormat(items: string[]) {
|
|
185
|
+
return new Intl.ListFormat("en", {
|
|
186
|
+
style: "long",
|
|
187
|
+
type: "conjunction",
|
|
188
|
+
}).format(items);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function claimSummary(claim: UpstreamAuthenticationClaim) {
|
|
192
|
+
return (
|
|
193
|
+
[
|
|
194
|
+
claim.spf && `SPF ${claim.spf}`,
|
|
195
|
+
claim.dkim && `DKIM ${claim.dkim}`,
|
|
196
|
+
claim.dmarc && `DMARC ${claim.dmarc}`,
|
|
197
|
+
]
|
|
198
|
+
.filter(Boolean)
|
|
199
|
+
.join(", ") || "no results"
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function SpfRow({ authentication }: { authentication: InboundAuthentication }) {
|
|
204
|
+
const { spf, spfHelo, remoteIp } = authentication;
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<CheckRow
|
|
208
|
+
label="SPF"
|
|
209
|
+
result={spf?.result ?? null}
|
|
210
|
+
href={`${AUTHENTICATION_DOCS}#spf-sender-policy-framework`}
|
|
211
|
+
>
|
|
212
|
+
{spf ? (
|
|
213
|
+
<>
|
|
214
|
+
{remoteIp && (
|
|
215
|
+
<>
|
|
216
|
+
with IP <Mono>{remoteIp}</Mono>{" "}
|
|
217
|
+
</>
|
|
218
|
+
)}
|
|
219
|
+
{spf.domain && (
|
|
220
|
+
<Muted>
|
|
221
|
+
· mailed-by {spf.domain}
|
|
222
|
+
{spf.aligned ? " (aligned)" : " (not aligned)"}
|
|
223
|
+
</Muted>
|
|
224
|
+
)}
|
|
225
|
+
{spfHelo && (
|
|
226
|
+
<div className="text-muted-foreground text-[11px]">
|
|
227
|
+
HELO {spfHelo.domain ?? authentication.helo ?? "check"}:{" "}
|
|
228
|
+
{spfHelo.result}
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
</>
|
|
232
|
+
) : (
|
|
233
|
+
<Muted>Not reported</Muted>
|
|
234
|
+
)}
|
|
235
|
+
</CheckRow>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function DkimRow({
|
|
240
|
+
authentication,
|
|
241
|
+
}: {
|
|
242
|
+
authentication: InboundAuthentication;
|
|
243
|
+
}) {
|
|
244
|
+
const signatures = [...authentication.dkim].sort(
|
|
245
|
+
(left, right) =>
|
|
246
|
+
Number(right.result === "pass") - Number(left.result === "pass") ||
|
|
247
|
+
Number(right.aligned) - Number(left.aligned)
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const primary = signatures[0];
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<CheckRow
|
|
254
|
+
label="DKIM"
|
|
255
|
+
result={primary?.result ?? "none"}
|
|
256
|
+
href={`${AUTHENTICATION_DOCS}#dkim-domainkeys-identified-mail`}
|
|
257
|
+
>
|
|
258
|
+
{primary ? (
|
|
259
|
+
<ul className="space-y-0.5">
|
|
260
|
+
{signatures.map((signature, index) => (
|
|
261
|
+
<li key={`${signature.domain}-${index}`}>
|
|
262
|
+
{index === 0
|
|
263
|
+
? "with domain "
|
|
264
|
+
: signature.result === "pass"
|
|
265
|
+
? "Also signed by "
|
|
266
|
+
: `${signature.result.toUpperCase()}: signed by `}
|
|
267
|
+
<span className="font-medium">{signature.domain}</span>{" "}
|
|
268
|
+
<Muted>
|
|
269
|
+
(
|
|
270
|
+
{[
|
|
271
|
+
signature.selector && `selector ${signature.selector}`,
|
|
272
|
+
signature.aligned ? "aligned" : "not aligned",
|
|
273
|
+
]
|
|
274
|
+
.filter(Boolean)
|
|
275
|
+
.join(", ")}
|
|
276
|
+
)
|
|
277
|
+
</Muted>
|
|
278
|
+
</li>
|
|
279
|
+
))}
|
|
280
|
+
</ul>
|
|
281
|
+
) : (
|
|
282
|
+
<Muted>The message was not signed</Muted>
|
|
283
|
+
)}
|
|
284
|
+
</CheckRow>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function DmarcRow({
|
|
289
|
+
authentication,
|
|
290
|
+
}: {
|
|
291
|
+
authentication: InboundAuthentication;
|
|
292
|
+
}) {
|
|
293
|
+
const { dmarc } = authentication;
|
|
294
|
+
const href = `${AUTHENTICATION_DOCS}#dmarc-domain-based-message-authentication-reporting--conformance`;
|
|
295
|
+
|
|
296
|
+
if (!dmarc) {
|
|
297
|
+
return (
|
|
298
|
+
<CheckRow label="DMARC" result={null} href={href}>
|
|
299
|
+
<Muted>Not reported</Muted>
|
|
300
|
+
</CheckRow>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const via = dmarc.alignedVia.map((method) => method.toUpperCase());
|
|
305
|
+
|
|
306
|
+
return (
|
|
307
|
+
<CheckRow label="DMARC" result={dmarc.result} href={href}>
|
|
308
|
+
{dmarc.result === "none" && !dmarc.policy ? (
|
|
309
|
+
<Muted>
|
|
310
|
+
{dmarc.headerFrom ?? "The domain"} publishes no DMARC policy
|
|
311
|
+
</Muted>
|
|
312
|
+
) : (
|
|
313
|
+
<>
|
|
314
|
+
{dmarc.policy && (
|
|
315
|
+
<>
|
|
316
|
+
policy <span className="font-medium">{dmarc.policy}</span>
|
|
317
|
+
</>
|
|
318
|
+
)}
|
|
319
|
+
{via.length > 0 && <Muted> · aligned via {listFormat(via)}</Muted>}
|
|
320
|
+
{dmarc.policy === "none" && (
|
|
321
|
+
<div className="text-muted-foreground text-[11px]">
|
|
322
|
+
Monitoring only: the domain does not ask receivers to reject
|
|
323
|
+
failures.
|
|
324
|
+
</div>
|
|
325
|
+
)}
|
|
326
|
+
</>
|
|
327
|
+
)}
|
|
328
|
+
</CheckRow>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function ArcRow({ authentication }: { authentication: InboundAuthentication }) {
|
|
333
|
+
const { arc } = authentication;
|
|
334
|
+
const href = "https://www.rfc-editor.org/rfc/rfc8617.html";
|
|
335
|
+
|
|
336
|
+
if (!arc || (arc.result === "none" && arc.chainLength <= 1)) {
|
|
337
|
+
return (
|
|
338
|
+
<CheckRow label="ARC" result="none" href={href}>
|
|
339
|
+
<Muted>No forwarding chain</Muted>
|
|
340
|
+
</CheckRow>
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const sealers = arc.sealers.flatMap((sealer) =>
|
|
345
|
+
sealer.domain ? [sealer.domain] : []
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
return (
|
|
349
|
+
<CheckRow label="ARC" result={arc.result} href={href}>
|
|
350
|
+
{sealers.length > 0 && (
|
|
351
|
+
<>
|
|
352
|
+
Forwarded via{" "}
|
|
353
|
+
<span className="font-medium">{listFormat(sealers)}</span>
|
|
354
|
+
</>
|
|
355
|
+
)}
|
|
356
|
+
{arc.result === "fail" && (
|
|
357
|
+
<div className="text-destructive">
|
|
358
|
+
The forwarding chain is broken; earlier results cannot be trusted.
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
{arc.oldest && (
|
|
362
|
+
<div className="text-muted-foreground text-[11px]">
|
|
363
|
+
Before forwarding: {claimSummary(arc.oldest)} · reported by{" "}
|
|
364
|
+
{arc.oldest.authservId}, chain verified by Cloudflare
|
|
365
|
+
</div>
|
|
366
|
+
)}
|
|
367
|
+
</CheckRow>
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function SpamScore({ score }: { score: number | null }) {
|
|
372
|
+
if (score === null) return null;
|
|
373
|
+
|
|
374
|
+
return (
|
|
375
|
+
<div className="grid grid-cols-[3.75rem_4.75rem_minmax(0,1fr)] items-baseline gap-x-3 py-2.5">
|
|
376
|
+
<dt className="text-muted-foreground text-xs font-medium">Spam</dt>
|
|
377
|
+
<dd>
|
|
378
|
+
<Verdict tone={score >= 3 ? "warn" : "neutral"}>{score} / 5</Verdict>
|
|
379
|
+
</dd>
|
|
380
|
+
<dd className="text-muted-foreground text-xs leading-5 max-sm:col-span-2 max-sm:col-start-2 max-sm:mt-1">
|
|
381
|
+
Cloudflare spam score (X-CF-SpamH-Score). Experimental; not used to
|
|
382
|
+
filter mail.
|
|
383
|
+
</dd>
|
|
384
|
+
</div>
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Gmail-style SPF / DKIM / DMARC / ARC lines from the trusted Cloudflare results. */
|
|
389
|
+
export function SenderAuthentication({
|
|
390
|
+
authentication,
|
|
391
|
+
}: {
|
|
392
|
+
authentication: InboundAuthentication | null;
|
|
393
|
+
}) {
|
|
394
|
+
if (!authentication) {
|
|
395
|
+
return (
|
|
396
|
+
<p className="text-muted-foreground text-xs">
|
|
397
|
+
Authentication results are not available for this message.
|
|
398
|
+
</p>
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const unavailable = authentication.verdict === "unavailable";
|
|
403
|
+
|
|
404
|
+
return (
|
|
405
|
+
<div>
|
|
406
|
+
<VerdictSummary authentication={authentication} />
|
|
407
|
+
{!unavailable && (
|
|
408
|
+
<dl className="divide-border divide-y">
|
|
409
|
+
<SpfRow authentication={authentication} />
|
|
410
|
+
<DkimRow authentication={authentication} />
|
|
411
|
+
<DmarcRow authentication={authentication} />
|
|
412
|
+
<ArcRow authentication={authentication} />
|
|
413
|
+
<SpamScore score={authentication.spamScore} />
|
|
414
|
+
</dl>
|
|
415
|
+
)}
|
|
416
|
+
{unavailable && authentication.spamScore !== null && (
|
|
417
|
+
<dl>
|
|
418
|
+
<SpamScore score={authentication.spamScore} />
|
|
419
|
+
</dl>
|
|
420
|
+
)}
|
|
421
|
+
{(authentication.ignoredCloudflareClaims > 0 ||
|
|
422
|
+
authentication.upstream.length > 0) && (
|
|
423
|
+
<div className="border-border text-muted-foreground mt-2 space-y-1 border-t pt-2.5 text-[11px] leading-4">
|
|
424
|
+
{authentication.ignoredCloudflareClaims > 0 && (
|
|
425
|
+
<p className="text-amber-800 dark:text-amber-300">
|
|
426
|
+
Ignored {authentication.ignoredCloudflareClaims} header
|
|
427
|
+
{authentication.ignoredCloudflareClaims === 1 ? "" : "s"} below
|
|
428
|
+
Cloudflare's block that claimed to come from Cloudflare.
|
|
429
|
+
</p>
|
|
430
|
+
)}
|
|
431
|
+
{authentication.upstream.map((claim, index) => (
|
|
432
|
+
<p key={index}>
|
|
433
|
+
Reported by {claim.authservId} (unverified, added before
|
|
434
|
+
Cloudflare): {claimSummary(claim)}
|
|
435
|
+
</p>
|
|
436
|
+
))}
|
|
437
|
+
</div>
|
|
438
|
+
)}
|
|
439
|
+
{authentication.trustedHeader && (
|
|
440
|
+
<details className="group mt-2 text-[11px]">
|
|
441
|
+
<summary className="text-muted-foreground hover:text-foreground cursor-pointer select-none">
|
|
442
|
+
Trusted Authentication-Results header
|
|
443
|
+
</summary>
|
|
444
|
+
<pre className="bg-surface-sunken ring-border mt-1.5 overflow-x-auto rounded-md p-2.5 font-mono text-[10.5px] leading-[1.55] [overflow-wrap:anywhere] whitespace-pre-wrap ring-1">
|
|
445
|
+
{authentication.trustedHeader.replaceAll(/;\s*/gu, ";\n ")}
|
|
446
|
+
</pre>
|
|
447
|
+
</details>
|
|
448
|
+
)}
|
|
449
|
+
</div>
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const unsubscribeReasons: Record<
|
|
454
|
+
NonNullable<ListUnsubscribe["reason"]>,
|
|
455
|
+
string
|
|
456
|
+
> = {
|
|
457
|
+
"invalid-uri": "the header has no valid link or address",
|
|
458
|
+
"no-https": "only an email address is offered",
|
|
459
|
+
"no-post": "the sender did not opt in to one-click (RFC 8058)",
|
|
460
|
+
unsigned: "no passing DKIM signature covers the header",
|
|
461
|
+
unaligned: "the covering signature does not belong to the sender's domain",
|
|
462
|
+
"post-not-signed": "the signature does not cover List-Unsubscribe-Post",
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export function unsubscribeSummary(value: ListUnsubscribe) {
|
|
466
|
+
const methods: string[] = [];
|
|
467
|
+
|
|
468
|
+
if (value.httpsUrl) methods.push("link");
|
|
469
|
+
|
|
470
|
+
if (value.mailto) methods.push("email");
|
|
471
|
+
|
|
472
|
+
if (value.oneClick) {
|
|
473
|
+
return `One-click (RFC 8058)${value.mailto ? ", email" : ""}`;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const listed = listFormat(methods);
|
|
477
|
+
|
|
478
|
+
const offered = methods.length
|
|
479
|
+
? `${listed.charAt(0).toUpperCase()}${listed.slice(1)}`
|
|
480
|
+
: "Not usable";
|
|
481
|
+
|
|
482
|
+
return value.reason
|
|
483
|
+
? `${offered} · no one-click: ${unsubscribeReasons[value.reason]}`
|
|
484
|
+
: offered;
|
|
485
|
+
}
|