@open-workspace/email 0.2.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 +23 -20
- 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_dry_moon_knight.sql +77 -0
- package/migrations/meta/0000_snapshot.json +248 -106
- 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 +78 -26
- 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 +90 -34
- package/worker/jmap/eventsource.ts +169 -0
- package/worker/jmap/methods.ts +1716 -361
- package/worker/jmap/push-types.ts +27 -0
- package/worker/jmap/push.ts +207 -0
- package/worker/jmap/routes.ts +448 -86
- 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 +84 -52
- 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 +283 -171
- 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 +871 -542
- package/worker/mail/safety-routes.ts +329 -202
- 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 +153 -91
- 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 +597 -227
- 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 +1761 -737
- package/worker/mailbox/jmap-store.ts +139 -35
- package/worker/mailbox/model.ts +7 -14
- 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 -126
- package/containers/office-preview/Dockerfile +0 -10
- package/migrations/0000_email.sql +0 -53
- 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/legacy-migrations.ts +0 -41
- package/worker/mailbox/migrations.ts +0 -10
- package/worker/mailbox/rules.ts +0 -110
package/package.json
CHANGED
|
@@ -1,93 +1,99 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-workspace/email",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Team mail for OpenWorkspace: personal and shared inboxes, mailing lists, previews, safety, and AI.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"alchemy",
|
|
7
|
+
"cloudflare",
|
|
8
|
+
"email",
|
|
9
|
+
"jmap",
|
|
10
|
+
"self-hosted",
|
|
11
|
+
"workers"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://openworkspace.dev",
|
|
5
14
|
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
15
|
"repository": {
|
|
8
16
|
"type": "git",
|
|
9
17
|
"url": "git+https://github.com/iivankin/openworkspace.git",
|
|
10
18
|
"directory": "packages/email"
|
|
11
19
|
},
|
|
12
|
-
"
|
|
20
|
+
"files": [
|
|
21
|
+
"index.ts",
|
|
22
|
+
"alchemy",
|
|
23
|
+
"src",
|
|
24
|
+
"worker",
|
|
25
|
+
"shared",
|
|
26
|
+
"migrations",
|
|
27
|
+
"drizzle",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
13
32
|
"exports": {
|
|
14
33
|
".": "./index.ts",
|
|
15
|
-
"./alchemy": "./alchemy.ts",
|
|
34
|
+
"./alchemy": "./alchemy/index.ts",
|
|
35
|
+
"./client": "./src/client.tsx",
|
|
16
36
|
"./*": "./*"
|
|
17
37
|
},
|
|
18
38
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"effect": "4.0.7"
|
|
39
|
+
"dev": "ALLOW_MOCK_AUTH=true alchemy dev dev/alchemy.run.ts",
|
|
40
|
+
"test": "bun run test:unit && bun run test:stack",
|
|
41
|
+
"test:unit": "bun test ./test/unit",
|
|
42
|
+
"test:stack": "bun test --preload ./test/stack/setup.ts --timeout 60000 ./test/stack",
|
|
43
|
+
"test:e2e": "playwright test -c test/e2e --project=desktop && playwright test -c test/e2e --project=mobile",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json && tsc -p test/tsconfig.json && tsc -p test/e2e/tsconfig.json",
|
|
45
|
+
"db:generate": "drizzle-kit generate && drizzle-kit generate --config=drizzle.mailbox.config.ts"
|
|
27
46
|
},
|
|
28
47
|
"dependencies": {
|
|
29
48
|
"@hono/zod-validator": "0.9.1",
|
|
30
|
-
"@mmmike/web-push": "1.
|
|
31
|
-
"@modelcontextprotocol/server": "2.
|
|
49
|
+
"@mmmike/web-push": "1.5.0",
|
|
50
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
51
|
+
"@tanstack/react-query": "5.107.1",
|
|
52
|
+
"@tiptap/extension-placeholder": "3.33.1",
|
|
53
|
+
"@tiptap/pm": "3.33.1",
|
|
54
|
+
"@tiptap/react": "3.33.1",
|
|
55
|
+
"@tiptap/starter-kit": "3.33.1",
|
|
32
56
|
"aws4fetch": "1.0.20",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
57
|
+
"date-fns": "4.4.0",
|
|
58
|
+
"dompurify": "3.4.17",
|
|
59
|
+
"drizzle-orm": "0.45.4",
|
|
60
|
+
"hono": "4.13.17",
|
|
35
61
|
"html-to-text": "10.0.1",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
62
|
+
"lucide-react": "1.71.0",
|
|
63
|
+
"pdfjs-dist": "6.5.438",
|
|
64
|
+
"postal-mime": "4.2.1",
|
|
65
|
+
"react": "19.3.1",
|
|
66
|
+
"react-router": "8.5.1",
|
|
67
|
+
"sonner": "2.0.8",
|
|
68
|
+
"tldts": "7.4.21",
|
|
69
|
+
"zod": "4.6.7"
|
|
39
70
|
},
|
|
40
71
|
"devDependencies": {
|
|
41
|
-
"@alchemy.run/cloudflare": "2.0.0-beta.
|
|
42
|
-
"@
|
|
43
|
-
"@effect/platform-bun": "4.
|
|
44
|
-
"@effect/platform-node": "4.
|
|
45
|
-
"@open-workspace/core": "0.
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@tiptap/extension-image": "3.30.5",
|
|
49
|
-
"@tiptap/extension-placeholder": "3.30.5",
|
|
50
|
-
"@tiptap/pm": "3.30.5",
|
|
51
|
-
"@tiptap/react": "3.30.5",
|
|
52
|
-
"@tiptap/starter-kit": "3.30.5",
|
|
72
|
+
"@alchemy.run/cloudflare": "2.0.0-beta.85",
|
|
73
|
+
"@alchemy.run/test": "2.0.0-beta.85",
|
|
74
|
+
"@effect/platform-bun": "4.1.3",
|
|
75
|
+
"@effect/platform-node": "4.1.3",
|
|
76
|
+
"@open-workspace/core": "0.4.0",
|
|
77
|
+
"@open-workspace/create": "0.4.0",
|
|
78
|
+
"@types/bun": "1.4.4",
|
|
53
79
|
"@types/html-to-text": "9.0.4",
|
|
54
|
-
"@types/node": "26.
|
|
55
|
-
"@types/react": "19.
|
|
56
|
-
"@types/react-dom": "19.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"effect": "4.0.7",
|
|
65
|
-
"lucide-react": "1.38.0",
|
|
66
|
-
"pdfjs-dist": "6.3.289",
|
|
67
|
-
"react": "19.2.8",
|
|
68
|
-
"react-dom": "19.2.8",
|
|
69
|
-
"react-router": "8.3.1",
|
|
70
|
-
"sonner": "2.0.8",
|
|
71
|
-
"tailwind-merge": "3.6.0",
|
|
80
|
+
"@types/node": "26.6.6",
|
|
81
|
+
"@types/react": "19.3.0",
|
|
82
|
+
"@types/react-dom": "19.3.0",
|
|
83
|
+
"ai": "7.0.166",
|
|
84
|
+
"alchemy": "2.0.0-beta.85",
|
|
85
|
+
"drizzle-kit": "0.31.11",
|
|
86
|
+
"effect": "4.1.3",
|
|
87
|
+
"openid-client": "6.8.9",
|
|
88
|
+
"playwright": "1.65.0",
|
|
89
|
+
"standardwebhooks": "1.1.1",
|
|
72
90
|
"typescript": "7.0.2",
|
|
73
|
-
"vite": "8.
|
|
91
|
+
"vite": "8.3.7"
|
|
74
92
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
"containers",
|
|
82
|
-
"README.md",
|
|
83
|
-
"LICENSE"
|
|
84
|
-
],
|
|
85
|
-
"keywords": [
|
|
86
|
-
"cloudflare",
|
|
87
|
-
"workers",
|
|
88
|
-
"email",
|
|
89
|
-
"jmap",
|
|
90
|
-
"self-hosted",
|
|
91
|
-
"alchemy"
|
|
92
|
-
]
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"@alchemy.run/cloudflare": "2.0.0-beta.85",
|
|
95
|
+
"@open-workspace/core": "0.4.0",
|
|
96
|
+
"alchemy": "2.0.0-beta.85",
|
|
97
|
+
"effect": "4.1.3"
|
|
98
|
+
}
|
|
93
99
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isComposerInlineImageContentType } from "./mail";
|
|
2
|
-
import { officePreviewExtension
|
|
2
|
+
import { officePreviewExtension } from "./office-preview";
|
|
3
|
+
import type { PdfPreviewStatus } from "./office-preview";
|
|
3
4
|
|
|
4
5
|
const TEXT_TYPES = new Set([
|
|
5
6
|
"text/plain",
|
|
@@ -13,25 +14,25 @@ const TEXT_TYPES = new Set([
|
|
|
13
14
|
"application/yaml",
|
|
14
15
|
]);
|
|
15
16
|
|
|
16
|
-
const EXTENSION_TYPES
|
|
17
|
-
pdf
|
|
18
|
-
png
|
|
19
|
-
jpg
|
|
20
|
-
jpeg
|
|
21
|
-
gif
|
|
22
|
-
webp
|
|
23
|
-
avif
|
|
24
|
-
bmp
|
|
25
|
-
txt
|
|
26
|
-
log
|
|
27
|
-
md
|
|
28
|
-
csv
|
|
29
|
-
tsv
|
|
30
|
-
json
|
|
31
|
-
xml
|
|
32
|
-
yaml
|
|
33
|
-
yml
|
|
34
|
-
|
|
17
|
+
const EXTENSION_TYPES = new Map([
|
|
18
|
+
["pdf", "application/pdf"],
|
|
19
|
+
["png", "image/png"],
|
|
20
|
+
["jpg", "image/jpeg"],
|
|
21
|
+
["jpeg", "image/jpeg"],
|
|
22
|
+
["gif", "image/gif"],
|
|
23
|
+
["webp", "image/webp"],
|
|
24
|
+
["avif", "image/avif"],
|
|
25
|
+
["bmp", "image/bmp"],
|
|
26
|
+
["txt", "text/plain"],
|
|
27
|
+
["log", "text/plain"],
|
|
28
|
+
["md", "text/markdown"],
|
|
29
|
+
["csv", "text/csv"],
|
|
30
|
+
["tsv", "text/tab-separated-values"],
|
|
31
|
+
["json", "application/json"],
|
|
32
|
+
["xml", "application/xml"],
|
|
33
|
+
["yaml", "application/yaml"],
|
|
34
|
+
["yml", "application/yaml"],
|
|
35
|
+
]);
|
|
35
36
|
|
|
36
37
|
export function attachmentPreview(file: {
|
|
37
38
|
filename: string;
|
|
@@ -44,24 +45,33 @@ export function attachmentPreview(file: {
|
|
|
44
45
|
if (file.pdfPreviewStatus && officePreviewExtension(file.filename)) {
|
|
45
46
|
return { kind: "pdf", contentType: "application/pdf" };
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
|
|
49
|
+
let contentType =
|
|
50
|
+
file.contentType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
51
|
+
|
|
48
52
|
if (!contentType || contentType === "application/octet-stream") {
|
|
49
53
|
const extension = file.filename.split(".").at(-1)?.toLowerCase() ?? "";
|
|
50
|
-
contentType =
|
|
54
|
+
contentType = EXTENSION_TYPES.get(extension) ?? "";
|
|
51
55
|
}
|
|
56
|
+
|
|
52
57
|
if (contentType === "application/pdf") return { kind: "pdf", contentType };
|
|
58
|
+
|
|
53
59
|
if (
|
|
54
|
-
isComposerInlineImageContentType(contentType)
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
isComposerInlineImageContentType(contentType) ||
|
|
61
|
+
contentType === "image/avif" ||
|
|
62
|
+
contentType === "image/bmp"
|
|
57
63
|
) {
|
|
58
64
|
return { kind: "image", contentType };
|
|
59
65
|
}
|
|
66
|
+
|
|
60
67
|
if (TEXT_TYPES.has(contentType)) {
|
|
61
|
-
const charset =
|
|
62
|
-
|
|
68
|
+
const charset =
|
|
69
|
+
/;\s*charset\s*=\s*"?([a-zA-Z0-9_-]+)/iu.exec(file.contentType)?.[1] ??
|
|
70
|
+
"utf-8";
|
|
71
|
+
|
|
63
72
|
// XML and other structured text must never execute as same-origin documents.
|
|
64
73
|
return { kind: "text", contentType: `text/plain; charset=${charset}` };
|
|
65
74
|
}
|
|
75
|
+
|
|
66
76
|
return null;
|
|
67
77
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One order for every folder of a mailbox. Inbox is pinned first; the system
|
|
3
|
+
* folders after it can be placed anywhere among the person's own folders.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** System folders that take part in the order; Inbox is always first. */
|
|
7
|
+
export const MOVABLE_SYSTEM_FOLDER_IDS = [
|
|
8
|
+
"sent",
|
|
9
|
+
"archive",
|
|
10
|
+
"spam",
|
|
11
|
+
"trash",
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
export type SystemFolderId =
|
|
15
|
+
| "inbox"
|
|
16
|
+
| (typeof MOVABLE_SYSTEM_FOLDER_IDS)[number];
|
|
17
|
+
|
|
18
|
+
/** Where the system folders sit until someone moves them: before any custom folder. */
|
|
19
|
+
export const DEFAULT_SYSTEM_FOLDER_ORDER = {
|
|
20
|
+
inbox: 0,
|
|
21
|
+
sent: 10,
|
|
22
|
+
archive: 20,
|
|
23
|
+
spam: 30,
|
|
24
|
+
trash: 40,
|
|
25
|
+
} satisfies Record<SystemFolderId, number>;
|
|
26
|
+
|
|
27
|
+
function isSystemFolderId(id: string): id is SystemFolderId {
|
|
28
|
+
return Object.hasOwn(DEFAULT_SYSTEM_FOLDER_ORDER, id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The default position of a system folder by id; undefined for custom folders. */
|
|
32
|
+
export function defaultSystemFolderOrder(id: string) {
|
|
33
|
+
return isSystemFolderId(id) ? DEFAULT_SYSTEM_FOLDER_ORDER[id] : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The gap between neighbours, so a folder created later can go after the last. */
|
|
37
|
+
export const FOLDER_ORDER_STEP = 10;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether `folderIds` is a complete order of the movable folders: every
|
|
41
|
+
* movable system folder and custom folder exactly once, and never Inbox.
|
|
42
|
+
*/
|
|
43
|
+
export function isCompleteFolderOrder(
|
|
44
|
+
folderIds: readonly string[],
|
|
45
|
+
customFolderIds: readonly string[]
|
|
46
|
+
) {
|
|
47
|
+
const expected = new Set<string>([
|
|
48
|
+
...MOVABLE_SYSTEM_FOLDER_IDS,
|
|
49
|
+
...customFolderIds,
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
folderIds.length === expected.size &&
|
|
54
|
+
new Set(folderIds).size === folderIds.length &&
|
|
55
|
+
folderIds.every((id) => expected.has(id))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The stored position of each folder in a complete order, after Inbox's 0. */
|
|
60
|
+
export function folderOrderPositions(folderIds: readonly string[]) {
|
|
61
|
+
return folderIds.map((id, index) => ({
|
|
62
|
+
id,
|
|
63
|
+
sortOrder: (index + 1) * FOLDER_ORDER_STEP,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type Orderable = { id: string; name: string; sortOrder: number };
|
|
68
|
+
|
|
69
|
+
/** Folders in display order: Inbox first, then by position, ties by name. */
|
|
70
|
+
export function sortFolders<T extends Orderable>(folders: readonly T[]): T[] {
|
|
71
|
+
return [...folders].sort(
|
|
72
|
+
(left, right) =>
|
|
73
|
+
Number(right.id === "inbox") - Number(left.id === "inbox") ||
|
|
74
|
+
left.sortOrder - right.sortOrder ||
|
|
75
|
+
left.name.localeCompare(right.name)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The order after moving one folder a step up (-1) or down (+1), as the ids
|
|
81
|
+
* the reorder API takes (every folder but Inbox); null when it can't move.
|
|
82
|
+
*/
|
|
83
|
+
export function moveFolderInOrder<T extends Orderable>(
|
|
84
|
+
folders: readonly T[],
|
|
85
|
+
folderId: string,
|
|
86
|
+
direction: -1 | 1
|
|
87
|
+
) {
|
|
88
|
+
const ids = sortFolders(folders)
|
|
89
|
+
.map((folder) => folder.id)
|
|
90
|
+
.filter((id) => id !== "inbox");
|
|
91
|
+
|
|
92
|
+
const index = ids.indexOf(folderId);
|
|
93
|
+
const target = index + direction;
|
|
94
|
+
|
|
95
|
+
const moving = ids[index];
|
|
96
|
+
const neighbour = ids[target];
|
|
97
|
+
|
|
98
|
+
if (index === -1 || moving === undefined || neighbour === undefined) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
ids[index] = neighbour;
|
|
103
|
+
ids[target] = moving;
|
|
104
|
+
|
|
105
|
+
return ids;
|
|
106
|
+
}
|
|
@@ -14,6 +14,7 @@ export const authResults = [
|
|
|
14
14
|
"permerror",
|
|
15
15
|
"policy",
|
|
16
16
|
] as const;
|
|
17
|
+
|
|
17
18
|
export type AuthResult = (typeof authResults)[number];
|
|
18
19
|
|
|
19
20
|
export type DmarcPolicy = "none" | "quarantine" | "reject";
|
|
@@ -46,7 +47,11 @@ export type ArcSealer = {
|
|
|
46
47
|
cv: string | null;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
|
-
export type SenderVerdict =
|
|
50
|
+
export type SenderVerdict =
|
|
51
|
+
| "verified"
|
|
52
|
+
| "unverified"
|
|
53
|
+
| "suspicious"
|
|
54
|
+
| "unavailable";
|
|
50
55
|
|
|
51
56
|
export type SenderVerdictReason =
|
|
52
57
|
| "dmarc_pass"
|
|
@@ -78,7 +83,7 @@ export type InboundAuthentication = {
|
|
|
78
83
|
result: AuthResult;
|
|
79
84
|
headerFrom: string | null;
|
|
80
85
|
policy: DmarcPolicy | null;
|
|
81
|
-
alignedVia:
|
|
86
|
+
alignedVia: ("spf" | "dkim")[];
|
|
82
87
|
} | null;
|
|
83
88
|
arc: {
|
|
84
89
|
result: "pass" | "fail" | "none";
|
|
@@ -131,7 +136,7 @@ export type MessageSecurity = {
|
|
|
131
136
|
via: string | null;
|
|
132
137
|
/** Organization that forwarded the message to this mailbox, when evident. */
|
|
133
138
|
forwardedVia: string | null;
|
|
134
|
-
/** The From domain is not one of this workspace's domains. */
|
|
139
|
+
/** The From domain is not one of this workspace's mail domains. */
|
|
135
140
|
external: boolean;
|
|
136
141
|
listUnsubscribe: ListUnsubscribe | null;
|
|
137
142
|
/** Most serious first; the reader merges them into one banner. */
|
package/shared/mail-feedback.ts
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* records, as returned with every incoming message.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type FeedbackLabel = ReportKind | "not_spam";
|
|
6
|
+
/** What a person said about a sender: "Report spam" or "Not spam". */
|
|
7
|
+
export type FeedbackLabel = "spam" | "not_spam";
|
|
9
8
|
|
|
10
9
|
export type SenderBlock = {
|
|
11
10
|
/** The stored pattern: an address, or `@domain` for the whole domain. */
|
|
@@ -42,26 +41,8 @@ export type Unsubscription = {
|
|
|
42
41
|
at: number;
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/** Point-in-time copy of what the reporter saw, kept with an admin report. */
|
|
48
|
-
export type ReportSnapshot = {
|
|
49
|
-
fromName: string | null;
|
|
50
|
-
replyTo: string[];
|
|
51
|
-
to: string[];
|
|
52
|
-
verdict: string;
|
|
53
|
-
verdictReason: string;
|
|
54
|
-
warnings: string[];
|
|
55
|
-
spamScore: number | null;
|
|
56
|
-
ip: string | null;
|
|
57
|
-
network: string | null;
|
|
58
|
-
country: string | null;
|
|
59
|
-
ai: { spam: boolean; spamConfidence: number; reason: string } | null;
|
|
60
|
-
linkDomains: string[];
|
|
61
|
-
preview: string;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const DOMAIN_PATTERN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9-]{2,63}$/u;
|
|
44
|
+
const DOMAIN_PATTERN =
|
|
45
|
+
/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9-]{2,63}$/u;
|
|
65
46
|
|
|
66
47
|
/**
|
|
67
48
|
* Normalizes a block entry: `alex@x.com` stays an address, `x.com` and
|
|
@@ -69,13 +50,20 @@ const DOMAIN_PATTERN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9-]{2,
|
|
|
69
50
|
*/
|
|
70
51
|
export function normalizeBlockPattern(value: string) {
|
|
71
52
|
const input = value.trim().toLocaleLowerCase();
|
|
53
|
+
|
|
72
54
|
if (input.length > 320) return null;
|
|
73
55
|
const at = input.lastIndexOf("@");
|
|
56
|
+
|
|
74
57
|
if (at > 0) {
|
|
75
58
|
const domain = input.slice(at + 1);
|
|
76
|
-
|
|
59
|
+
|
|
60
|
+
return DOMAIN_PATTERN.test(domain) && !/[\s<>,;"]/u.test(input.slice(0, at))
|
|
61
|
+
? input
|
|
62
|
+
: null;
|
|
77
63
|
}
|
|
64
|
+
|
|
78
65
|
const domain = at === 0 ? input.slice(1) : input;
|
|
66
|
+
|
|
79
67
|
return DOMAIN_PATTERN.test(domain) ? `@${domain}` : null;
|
|
80
68
|
}
|
|
81
69
|
|
|
@@ -83,8 +71,13 @@ export function normalizeBlockPattern(value: string) {
|
|
|
83
71
|
export function blockPatternsFor(address: string) {
|
|
84
72
|
const value = address.trim().toLocaleLowerCase();
|
|
85
73
|
const at = value.lastIndexOf("@");
|
|
74
|
+
|
|
86
75
|
if (at <= 0) return [];
|
|
87
76
|
const labels = value.slice(at + 1).split(".");
|
|
88
|
-
|
|
77
|
+
|
|
78
|
+
const domains = labels
|
|
79
|
+
.slice(0, -1)
|
|
80
|
+
.map((_, index) => `@${labels.slice(index).join(".")}`);
|
|
81
|
+
|
|
89
82
|
return [value, ...domains];
|
|
90
83
|
}
|