emailengine-app 2.81.2 → 2.82.1
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/.ncurc.js +33 -10
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +71 -0
- package/DOCKER_DEPLOYMENT.md +13 -12
- package/Dockerfile +2 -0
- package/bin/emailengine.js +105 -25
- package/config/default.toml +0 -5
- package/config/test.toml +0 -5
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +70 -42
- package/getswagger.sh +0 -4
- package/lib/account/account-state.js +2 -110
- package/lib/account/expected-identity.js +1 -1
- package/lib/account-assignment.js +138 -1
- package/lib/account.js +289 -869
- package/lib/api-reference/index.js +2 -3
- package/lib/api-reference/schema-tree.js +53 -3
- package/lib/api-routes/account-binding.js +58 -0
- package/lib/api-routes/account-routes.js +65 -37
- package/lib/api-routes/behavior-notes.js +4 -0
- package/lib/api-routes/blocklist-routes.js +2 -2
- package/lib/api-routes/bull-board-routes.js +1 -6
- package/lib/api-routes/export-routes.js +2 -22
- package/lib/api-routes/gateway-routes.js +15 -16
- package/lib/api-routes/index.js +1 -13
- package/lib/api-routes/mailbox-routes.js +2 -7
- package/lib/api-routes/mcp-oauth-routes.js +2 -1
- package/lib/api-routes/mcp-routes.js +7 -7
- package/lib/api-routes/message-routes.js +50 -238
- package/lib/api-routes/mint-bounds.js +110 -0
- package/lib/api-routes/oauth2-app-routes.js +23 -32
- package/lib/api-routes/operation-impact.js +1 -1
- package/lib/api-routes/outbox-routes.js +3 -3
- package/lib/api-routes/permission-map.js +1 -7
- package/lib/api-routes/route-helpers.js +11 -5
- package/lib/api-routes/settings-routes.js +20 -21
- package/lib/api-routes/stats-routes.js +1 -1
- package/lib/api-routes/submit-routes.js +17 -18
- package/lib/api-routes/template-routes.js +4 -9
- package/lib/api-routes/token-routes.js +28 -6
- package/lib/api-token-scheme.js +71 -0
- package/lib/arf-detect.js +33 -6
- package/lib/auth-token.js +44 -24
- package/lib/autodetect-imap-settings.js +305 -123
- package/lib/bounce-detect.js +25 -16
- package/lib/calendar-event.js +78 -0
- package/lib/consts.js +54 -5
- package/lib/create-imap-client.js +24 -0
- package/lib/db.js +77 -30
- package/lib/delivery-error.js +70 -2
- package/lib/egress-fetch.js +54 -3
- package/lib/egress-filter.js +11 -0
- package/lib/email-client/api-retry.js +147 -0
- package/lib/email-client/base-client.js +383 -536
- package/lib/email-client/credential-errors.js +21 -5
- package/lib/email-client/gmail/gmail-api.js +38 -125
- package/lib/email-client/gmail/send-request.js +1 -1
- package/lib/email-client/gmail-client.js +77 -51
- package/lib/email-client/imap/mailbox.js +158 -324
- package/lib/email-client/imap/stale-view.js +109 -0
- package/lib/email-client/imap/subconnection.js +46 -9
- package/lib/email-client/imap/sync-operations.js +5 -37
- package/lib/email-client/imap-client.js +190 -65
- package/lib/email-client/message-builder.js +50 -25
- package/lib/email-client/notification-handler.js +5 -219
- package/lib/email-client/outlook/graph-api.js +147 -126
- package/lib/email-client/outlook/send-request.js +10 -4
- package/lib/email-client/outlook-client.js +389 -463
- package/lib/email-client/smtp-pool-manager.js +3 -2
- package/lib/encrypt.js +184 -19
- package/lib/enum-descriptions.js +6 -3
- package/lib/export.js +141 -41
- package/lib/gateway.js +25 -6
- package/lib/get-raw-email.js +26 -44
- package/lib/get-secret.js +1 -21
- package/lib/handlebars-helpers.js +31 -10
- package/lib/imap-proxy-auth.js +13 -29
- package/lib/imapproxy/imap-core/README.md +1 -0
- package/lib/imapproxy/imap-core/lib/handler/imap-parser.js +12 -0
- package/lib/imapproxy/imap-core/lib/imap-command.js +74 -10
- package/lib/imapproxy/imap-core/lib/imap-connection.js +9 -1
- package/lib/imapproxy/imap-core/lib/imap-server.js +112 -26
- package/lib/imapproxy/imap-core/lib/imap-stream.js +41 -1
- package/lib/imapproxy/imap-core/lib/imap-tools.js +10 -2
- package/lib/imapproxy/imap-core/lib/indexer/indexer.js +4 -2
- package/lib/imapproxy/imap-server.js +17 -177
- package/lib/imapproxy/proxy-handoff.js +235 -0
- package/lib/imapproxy/response-error.js +33 -0
- package/lib/imapproxy/upstream-client.js +2 -2
- package/lib/license-beacon.js +3 -9
- package/lib/llm-pre-process.js +182 -43
- package/lib/logger.js +1 -1
- package/lib/lua/ee-export-queue-add.lua +39 -0
- package/lib/lua/ee-get-idempotency.lua +15 -3
- package/lib/lua/ee-release-attempts.lua +23 -0
- package/lib/lua/ee-reserve-attempts.lua +42 -0
- package/lib/lua/h-set-bigger.lua +12 -2
- package/lib/lua/s-list-accounts.lua +6 -3
- package/lib/mcp/index.js +1 -2
- package/lib/mcp/listen.js +221 -18
- package/lib/mcp/oauth.js +44 -5
- package/lib/mcp/resources.js +8 -2
- package/lib/mcp/tools.js +108 -36
- package/lib/message-port-stream.js +64 -6
- package/lib/oauth/external-account-signer.js +16 -13
- package/lib/oauth/gmail.js +64 -32
- package/lib/oauth/mail-ru.js +24 -17
- package/lib/oauth/outlook.js +53 -40
- package/lib/oauth/pubsub/google.js +38 -2
- package/lib/oauth/scope-checker.js +39 -8
- package/lib/oauth/scope-list.js +55 -0
- package/lib/oauth/token-fetch.js +47 -0
- package/lib/oauth/verify-app.js +2 -2
- package/lib/oauth2-apps.js +154 -90
- package/lib/openapi/build-document.js +1 -1
- package/lib/openapi/joi-schema.js +78 -9
- package/lib/outbox.js +2 -7
- package/lib/parse-message.js +21 -0
- package/lib/payload-examples-webhooks.json +4 -7
- package/lib/pbkdf2-phc.js +101 -0
- package/lib/privileged-settings.js +0 -14
- package/lib/queue-retention.js +4 -2
- package/lib/rate-limit.js +54 -15
- package/lib/read-env-value.js +33 -2
- package/lib/redis-scan-delete.js +56 -29
- package/lib/redis-url.js +3 -1
- package/lib/respawn-backoff.js +5 -4
- package/lib/response-stream.js +25 -4
- package/lib/rewrite-text-nodes.js +27 -40
- package/lib/routes-ui.js +0 -5
- package/lib/schemas.js +180 -253
- package/lib/sentry.js +21 -5
- package/lib/settings.js +58 -59
- package/lib/smtp-auth.js +6 -2
- package/lib/smtp-message-processor.js +28 -7
- package/lib/sso.js +7 -3
- package/lib/stream-encrypt.js +14 -13
- package/lib/swagger-options.js +3 -1
- package/lib/tls/provision.js +69 -3
- package/lib/tls/store.js +14 -1
- package/lib/token-audit-log.js +3 -2
- package/lib/tools.js +114 -53
- package/lib/totp.js +16 -1
- package/lib/ui-routes/account-routes.js +67 -70
- package/lib/ui-routes/admin-config-routes.js +111 -134
- package/lib/ui-routes/admin-entities-routes.js +101 -191
- package/lib/ui-routes/ai-options.js +104 -0
- package/lib/ui-routes/auth-routes.js +98 -18
- package/lib/ui-routes/export-routes.js +3 -23
- package/lib/ui-routes/internals-routes.js +12 -9
- package/lib/ui-routes/network-config-routes.js +8 -18
- package/lib/ui-routes/oauth-config-routes.js +83 -228
- package/lib/ui-routes/route-helpers.js +63 -67
- package/lib/ui-routes/special-use-paths.js +33 -0
- package/lib/ui-routes/unsubscribe-routes.js +2 -2
- package/lib/utils/decode-headers.js +32 -5
- package/lib/utils/header-map.js +62 -1
- package/lib/utils/network.js +11 -17
- package/lib/web-safe-html.js +77 -4
- package/lib/webhook-request.js +9 -1
- package/lib/webhook-routing.js +27 -1
- package/lib/webhooks.js +120 -43
- package/lib/worker-rpc-error.js +43 -2
- package/list-generate.js +13 -2
- package/package.json +38 -46
- package/sbom.json +1 -1
- package/scripts/refresh-test-tokens.js +42 -14
- package/server.js +338 -292
- package/setup-production.sh +16 -7
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +7 -8
- package/static/js/ee-client.js +145 -70
- package/static/js/ui.js +350 -154
- package/static/licenses.html +349 -1740
- package/translations/messages.pot +129 -111
- package/views/account-workspace-error.hbs +30 -0
- package/views/accounts/account.hbs +9 -4
- package/views/accounts/browse.hbs +10 -4
- package/views/accounts/edit.hbs +11 -2
- package/views/config/ai.hbs +49 -41
- package/views/config/oauth/app.hbs +2 -1
- package/views/dashboard.hbs +18 -16
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +0 -22
- package/views/layout/login.hbs +2 -1
- package/views/partials/filter_editor_js.hbs +4 -3
- package/views/partials/gmail_api_scopes.hbs +16 -0
- package/views/partials/oauth_form.hbs +67 -94
- package/views/partials/oauth_pubsub_app_select.hbs +43 -0
- package/views/partials/scope_info.hbs +14 -23
- package/views/partials/side_menu.hbs +0 -4
- package/views/partials/ui/account-picker.hbs +6 -32
- package/views/partials/ui/model-picker.hbs +31 -0
- package/views/partials/ui/pagination.hbs +6 -1
- package/views/partials/ui/picker.hbs +47 -0
- package/views/unsubscribe.hbs +1 -1
- package/workers/api.js +82 -47
- package/workers/export.js +55 -60
- package/workers/imap.js +132 -49
- package/workers/submit.js +5 -6
- package/workers/webhooks.js +46 -27
- package/.githooks/pre-commit +0 -80
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/contributing.md +0 -17
- package/.github/dependabot.yml +0 -22
- package/.github/docker-smoke-test.sh +0 -61
- package/.github/workflows/deploy.yml +0 -215
- package/.github/workflows/e2e.yml +0 -55
- package/.github/workflows/release.yaml +0 -217
- package/.github/workflows/test.yml +0 -307
- package/lib/api-routes/chat-routes.js +0 -535
- package/lib/document-store.js +0 -75
- package/lib/es.js +0 -757
- package/lib/generate-text-preview.js +0 -61
- package/lib/imapproxy/imap-core/memory-notifier.js +0 -129
- package/lib/pre-process.js +0 -196
- package/lib/threads.js +0 -155
- package/lib/ui-routes/document-store-routes.js +0 -806
- package/playwright.config.js +0 -47
- package/views/config/document-store/chat.hbs +0 -286
- package/views/config/document-store/index.hbs +0 -146
- package/views/config/document-store/mappings/index.hbs +0 -108
- package/views/config/document-store/mappings/new.hbs +0 -68
- package/views/config/document-store/pre-processing/index.hbs +0 -103
- package/views/partials/document_store_header.hbs +0 -30
- package/workers/documents.js +0 -1128
|
@@ -11,18 +11,7 @@
|
|
|
11
11
|
{{/if}}
|
|
12
12
|
|
|
13
13
|
{{#if baseScopesApi}}
|
|
14
|
-
|
|
15
|
-
{{#unless disabledScopes.Gmail_Modify}}
|
|
16
|
-
<li><code>"https://www.googleapis.com/auth/gmail.modify"</code></li>
|
|
17
|
-
{{else}}
|
|
18
|
-
{{#if isSendOnlyGmail}}
|
|
19
|
-
<li><code>"https://www.googleapis.com/auth/gmail.send"</code></li>
|
|
20
|
-
{{else}}
|
|
21
|
-
<li><code>"https://www.googleapis.com/auth/gmail.readonly"</code></li>
|
|
22
|
-
<li><code>"https://www.googleapis.com/auth/gmail.labels"</code></li>
|
|
23
|
-
{{/if}}
|
|
24
|
-
{{/unless}}
|
|
25
|
-
|
|
14
|
+
{{> gmail_api_scopes}}
|
|
26
15
|
{{/if}}
|
|
27
16
|
|
|
28
17
|
{{#if baseScopesPubsub}}
|
|
@@ -31,15 +20,6 @@
|
|
|
31
20
|
|
|
32
21
|
</ul>
|
|
33
22
|
|
|
34
|
-
{{#if isSendOnlyGmail}}
|
|
35
|
-
<div class="alert alert-soft alert-warning mt-4 block">
|
|
36
|
-
<strong>Send-only account limitation:</strong> Messages sent through this app cannot be tracked by EmailEngine.
|
|
37
|
-
The Gmail API modifies the Message-ID header when sending emails, and without read permissions,
|
|
38
|
-
EmailEngine cannot resolve the new Message-ID assigned by Gmail. Delivery status and bounce
|
|
39
|
-
notifications may not be accurately associated with the sent message.
|
|
40
|
-
</div>
|
|
41
|
-
{{/if}}
|
|
42
|
-
|
|
43
23
|
<div>Read about setting up the OAuth2 project in Google Cloud from
|
|
44
24
|
|
|
45
25
|
{{#if baseScopesImap}}
|
|
@@ -68,9 +48,9 @@
|
|
|
68
48
|
{{/if}}
|
|
69
49
|
|
|
70
50
|
{{#if baseScopesApi}}
|
|
71
|
-
<div>
|
|
51
|
+
<div>The service account's domain-wide delegation <strong>must</strong> list the following scopes:</div>
|
|
72
52
|
<ul class="list-disc ps-6 my-2">
|
|
73
|
-
|
|
53
|
+
{{> gmail_api_scopes}}
|
|
74
54
|
</ul>
|
|
75
55
|
{{/if}}
|
|
76
56
|
|
|
@@ -142,3 +122,14 @@
|
|
|
142
122
|
available for your <a href="https://oauth.mail.ru/app/" target="_blank" rel="noopener noreferrer"
|
|
143
123
|
referrerpolicy="no-referrer" class="link link-animated">OAuth2 apps</a> by default.</div>
|
|
144
124
|
{{/if}}
|
|
125
|
+
|
|
126
|
+
{{!-- A send-only app is only ever an API-based Gmail app, whichever of the two providers it is, so this
|
|
127
|
+
needs no provider guard - see isSendOnlyGmailApp() in lib/oauth/scope-checker.js. --}}
|
|
128
|
+
{{#if isSendOnlyGmail}}
|
|
129
|
+
<div class="alert alert-soft alert-warning mt-4 block">
|
|
130
|
+
<strong>Send-only account limitation:</strong> Messages sent through this app cannot be tracked by EmailEngine.
|
|
131
|
+
The Gmail API modifies the Message-ID header when sending emails, and without read permissions,
|
|
132
|
+
EmailEngine cannot resolve the new Message-ID assigned by Gmail. Delivery status and bounce
|
|
133
|
+
notifications may not be accurately associated with the sent message.
|
|
134
|
+
</div>
|
|
135
|
+
{{/if}}
|
|
@@ -34,10 +34,6 @@
|
|
|
34
34
|
{{> ui/menu-item href="/admin/config/imap-proxy" label="IMAP Proxy" active=menuConfigImapProxy}}
|
|
35
35
|
{{> ui/menu-item href="/admin/config/branding" label="Branding" active=menuConfigBranding}}
|
|
36
36
|
{{> ui/menu-item href="/admin/config/logging" label="Logging" active=menuConfigLogging}}
|
|
37
|
-
|
|
38
|
-
{{#if showDocumentStore}}
|
|
39
|
-
{{> ui/menu-item href="/admin/config/document-store" label="Document Store" active=menuConfigDocumentStore}}
|
|
40
|
-
{{/if}}
|
|
41
37
|
{{/ui/menu-section}}
|
|
42
38
|
|
|
43
39
|
{{> ui/menu-item href="/admin/config/license" label="License" icon="icon-[tabler--license] size-4.5"
|
|
@@ -6,17 +6,13 @@
|
|
|
6
6
|
part of an id, a name or an address, pick from the suggestions, and the box is replaced by a
|
|
7
7
|
card naming the account that was picked, with a button to clear it again.
|
|
8
8
|
|
|
9
|
-
The posted value stays a plain account id in a hidden input carrying the given id, so a page
|
|
10
|
-
that already reads or watches that field keeps working - static/js/ui.js fires `input` and
|
|
11
|
-
`change` on it whenever the choice changes, exactly as typing into a text field would.
|
|
12
|
-
|
|
13
9
|
Suggestions come from GET /admin/accounts/suggestions; the card is painted by ui.js from the
|
|
14
10
|
same JSON shape, so a server-rendered selection and a just-picked one cannot look different.
|
|
15
11
|
|
|
16
12
|
Hand-rolled rather than FlyonUI's HSComboBox, which the vendored bundle does carry: that
|
|
17
13
|
component renders items from template strings, and every field on a row here (a display name,
|
|
18
14
|
an address) arrives from a mail provider, so the rows are built as text nodes instead. The
|
|
19
|
-
hidden-id-plus-card shape is not one of its modes either.
|
|
15
|
+
hidden-id-plus-card shape is not one of its modes either. The markup is ui/picker.
|
|
20
16
|
{{> ui/account-picker id="account" label="Account" value=values.account selected=selectedAccount}}
|
|
21
17
|
Params:
|
|
22
18
|
id - hidden input id, also the default posted name and what page scripts read (required)
|
|
@@ -30,30 +26,8 @@
|
|
|
30
26
|
account looks like)
|
|
31
27
|
placeholder - search box placeholder (optional)
|
|
32
28
|
--}}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<input type="hidden" id="{{id}}" name="{{#if name}}{{name}}{{else}}{{id}}{{/if}}" {{#if value}}value="{{value}}" {{/if}}>
|
|
39
|
-
|
|
40
|
-
{{!-- The picked account. Empty until ui.js paints it, and hidden whenever nothing is picked. --}}
|
|
41
|
-
<div class="ee-account-picker-card hidden" data-picker-card></div>
|
|
42
|
-
|
|
43
|
-
<div class="ee-account-picker-search" data-picker-search>
|
|
44
|
-
<div class="input{{#if error}} is-invalid{{/if}}">
|
|
45
|
-
<span class="icon-[tabler--search] text-base-content/60 my-auto me-2 size-4 shrink-0"></span>
|
|
46
|
-
<input type="text" class="grow" id="{{id}}-search" role="combobox" aria-expanded="false" aria-autocomplete="list"
|
|
47
|
-
aria-controls="{{id}}-results" autocomplete="off" data-lpignore="true"
|
|
48
|
-
placeholder="{{#if placeholder}}{{placeholder}}{{else}}Search by name, address or account id{{/if}}">
|
|
49
|
-
</div>
|
|
50
|
-
<div class="ee-account-picker-results hidden" id="{{id}}-results" role="listbox" data-picker-results></div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
{{#if error}}
|
|
54
|
-
<span class="helper-text text-error">{{error}}</span>
|
|
55
|
-
{{/if}}
|
|
56
|
-
{{#if hint}}
|
|
57
|
-
<span class="helper-text">{{hint}}</span>
|
|
58
|
-
{{/if}}
|
|
59
|
-
</div>
|
|
29
|
+
{{#if placeholder}}
|
|
30
|
+
{{> ui/picker kind="account" id=id name=name label=label hint=hint error=error value=value selected=selected placeholder=placeholder}}
|
|
31
|
+
{{else}}
|
|
32
|
+
{{> ui/picker kind="account" id=id name=name label=label hint=hint error=error value=value selected=selected placeholder="Search by name, address or account id"}}
|
|
33
|
+
{{/if}}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
ui/model-picker - the "which model" field of the AI page.
|
|
3
|
+
|
|
4
|
+
A provider lists dozens of models, most of them unsuited to reading mail, and a <select> of
|
|
5
|
+
bare names was a wall nobody could choose from. This is the account picker's shape over a list
|
|
6
|
+
the page already holds: type any part of a name, an id or a note ("gpt 6", "6 luna" and
|
|
7
|
+
"cheap" all work, matched term by term and ranked with the id counting most), pick from the
|
|
8
|
+
suggestions, and the box is replaced by a card naming the model, what it is for, and its id.
|
|
9
|
+
Every entry carries a one-line note and the recommended ones are listed first, so the sane
|
|
10
|
+
choice is also the easy one. The first entry is "Default", which follows the library's
|
|
11
|
+
built-in model across upgrades.
|
|
12
|
+
|
|
13
|
+
The list travels in the data-models attribute and can be replaced after a refresh with
|
|
14
|
+
window.uiModelPickerSetModels(); the card is painted from the entry the value names. The
|
|
15
|
+
markup is ui/picker.
|
|
16
|
+
{{> ui/model-picker id="openAiModel" models=openAiModels value=values.openAiModel}}
|
|
17
|
+
Params:
|
|
18
|
+
id - hidden input id, also the default posted name and what page scripts read (required)
|
|
19
|
+
name - posted field name (defaults to id)
|
|
20
|
+
label - field label (optional)
|
|
21
|
+
hint - muted helper text under the control (optional)
|
|
22
|
+
error - validation error message (optional)
|
|
23
|
+
value - current model name, empty for the default (optional)
|
|
24
|
+
models - the list: {id, name, description, recommended} entries, "Default" first (required)
|
|
25
|
+
placeholder - search box placeholder (optional)
|
|
26
|
+
--}}
|
|
27
|
+
{{#if placeholder}}
|
|
28
|
+
{{> ui/picker kind="model" id=id name=name label=label hint=hint error=error value=value models=models placeholder=placeholder}}
|
|
29
|
+
{{else}}
|
|
30
|
+
{{> ui/picker kind="model" id=id name=name label=label hint=hint error=error value=value models=models placeholder="Search models by name or id"}}
|
|
31
|
+
{{/if}}
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
showPaging - falsy when there is only one page; suppresses all output
|
|
9
9
|
prevPage - URL of the previous page, falsy when on the first page
|
|
10
10
|
nextPage - URL of the next page, falsy when on the last page
|
|
11
|
-
pageLinks - array of { url, title, active }
|
|
11
|
+
pageLinks - array of { url, title, active }, or { gap: true } where pages are
|
|
12
|
+
left out (windowedPageLinks in lib/ui-routes/route-helpers.js)
|
|
12
13
|
--}}
|
|
13
14
|
{{#if showPaging}}
|
|
14
15
|
<div class="card-footer border-base-content/10 border-t px-6 py-4">
|
|
@@ -20,7 +21,11 @@
|
|
|
20
21
|
{{/if}}
|
|
21
22
|
|
|
22
23
|
{{#each pageLinks}}
|
|
24
|
+
{{#if gap}}
|
|
25
|
+
<span class="join-item btn btn-soft btn-sm btn-disabled" aria-hidden="true">…</span>
|
|
26
|
+
{{else}}
|
|
23
27
|
<a class="join-item btn btn-sm {{#if active}}btn-primary{{else}}btn-soft{{/if}}" href="{{url}}">{{title}}</a>
|
|
28
|
+
{{/if}}
|
|
24
29
|
{{/each}}
|
|
25
30
|
|
|
26
31
|
{{#if nextPage}}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
ui/picker - a search box that becomes a card: the shared markup behind ui/account-picker and
|
|
3
|
+
ui/model-picker, which are the two faces a page asks for by name. static/js/ui.js wires every
|
|
4
|
+
[data-picker] element with the adapter its kind names (see uiPickerAdapters there).
|
|
5
|
+
|
|
6
|
+
The posted value stays a plain id in a hidden input carrying the given id, so a page that
|
|
7
|
+
already reads or watches that field keeps working - ui.js fires `input` and `change` on it
|
|
8
|
+
whenever the choice changes, exactly as typing into a text field would.
|
|
9
|
+
|
|
10
|
+
Params:
|
|
11
|
+
kind - "account" or "model" (required)
|
|
12
|
+
id - hidden input id, also the default posted name and what page scripts read (required)
|
|
13
|
+
name - posted field name (defaults to id)
|
|
14
|
+
label - field label (optional)
|
|
15
|
+
hint - muted helper text under the control (optional)
|
|
16
|
+
error - validation error message (optional)
|
|
17
|
+
value - current id (optional)
|
|
18
|
+
selected - the entry for `value`, when the server resolved it (optional)
|
|
19
|
+
models - the list for the model kind: {id, name, description, recommended} entries
|
|
20
|
+
placeholder - search box placeholder (required; the wrappers supply the default of their kind)
|
|
21
|
+
--}}
|
|
22
|
+
<div class="w-full">
|
|
23
|
+
{{#if label}}
|
|
24
|
+
<label class="label-text" for="{{id}}-search">{{label}}</label>
|
|
25
|
+
{{/if}}
|
|
26
|
+
<div data-picker="{{kind}}" data-input="{{id}}" {{#if models}}data-models="{{json models}}" {{/if}}{{#if selected}}data-selected="{{json selected}}" {{/if}}>
|
|
27
|
+
<input type="hidden" id="{{id}}" name="{{#if name}}{{name}}{{else}}{{id}}{{/if}}" {{#if value}}value="{{value}}" {{/if}}>
|
|
28
|
+
|
|
29
|
+
{{!-- The picked entry. Empty until ui.js paints it, and hidden whenever nothing is picked. --}}
|
|
30
|
+
<div class="ee-account-picker-card hidden" data-picker-card></div>
|
|
31
|
+
|
|
32
|
+
<div class="ee-account-picker-search" data-picker-search>
|
|
33
|
+
<div class="input{{#if error}} is-invalid{{/if}}">
|
|
34
|
+
<span class="icon-[tabler--search] text-base-content/60 my-auto me-2 size-4 shrink-0"></span>
|
|
35
|
+
<input type="text" class="grow" id="{{id}}-search" role="combobox" aria-expanded="false" aria-autocomplete="list"
|
|
36
|
+
aria-controls="{{id}}-results" autocomplete="off" data-lpignore="true" placeholder="{{placeholder}}">
|
|
37
|
+
</div>
|
|
38
|
+
<div class="ee-account-picker-results hidden" id="{{id}}-results" role="listbox" data-picker-results></div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
{{#if error}}
|
|
42
|
+
<span class="helper-text text-error">{{error}}</span>
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#if hint}}
|
|
45
|
+
<span class="helper-text">{{hint}}</span>
|
|
46
|
+
{{/if}}
|
|
47
|
+
</div>
|
package/views/unsubscribe.hbs
CHANGED
|
@@ -9,7 +9,7 @@ the "subscription resumed" state. --}}
|
|
|
9
9
|
<p>{{_ "Your email address was unsubscribed." templateLocale }}</p>
|
|
10
10
|
|
|
11
11
|
<p>{{_ "Was this a mistake? Click <a%s>here</a> to re-subscribe." templateLocale
|
|
12
|
-
" id='resubscribe-link' href='#' class='ee-link'"}}</p>
|
|
12
|
+
(markup " id='resubscribe-link' href='#' class='ee-link'")}}</p>
|
|
13
13
|
|
|
14
14
|
{{!-- autofocus on the dialog keeps showModal() from focusing (and drawing a
|
|
15
15
|
focus ring on) the corner close button --}}
|
package/workers/api.js
CHANGED
|
@@ -8,7 +8,8 @@ const logger = require('../lib/logger');
|
|
|
8
8
|
const Path = require('path');
|
|
9
9
|
const Gettext = require('@postalsys/gettext');
|
|
10
10
|
const { loadTranslations, gt, joiLocales, locales } = require('../lib/translations');
|
|
11
|
-
const { accountStateLabel, formatServerState, identityErrorView, isClientError } = require('../lib/ui-routes/route-helpers');
|
|
11
|
+
const { accountStateLabel, formatServerState, identityErrorView, workspaceErrorView, isClientError } = require('../lib/ui-routes/route-helpers');
|
|
12
|
+
const { boundRouteBinding } = require('../lib/api-routes/account-binding');
|
|
12
13
|
const util = require('util');
|
|
13
14
|
const { webhooks: Webhooks } = require('../lib/webhooks');
|
|
14
15
|
const { lists } = require('../lib/lists');
|
|
@@ -69,7 +70,7 @@ const { buildRetrySetup } = require('../lib/oauth/retry-setup');
|
|
|
69
70
|
const { matchesExpectedIdentity, pendingSetupExpectation, resolveExpectedIdentity } = require('../lib/account/expected-identity');
|
|
70
71
|
|
|
71
72
|
const handlebars = require('handlebars');
|
|
72
|
-
const
|
|
73
|
+
const { apiTokenScheme, SCHEME_NAME: API_TOKEN_SCHEME } = require('../lib/api-token-scheme');
|
|
73
74
|
const tokens = require('../lib/tokens');
|
|
74
75
|
const tokenPermissions = require('../lib/token-permissions');
|
|
75
76
|
const { mcpFeatureEnabled } = require('../lib/mcp');
|
|
@@ -78,12 +79,11 @@ const tokenAuditLog = require('../lib/token-audit-log');
|
|
|
78
79
|
const { routeGrant, perRequestSurfaceAdmits, sessionTokenAdmits } = require('../lib/api-routes/permission-map');
|
|
79
80
|
const { mcpOptions } = require('../lib/api-routes/route-metadata');
|
|
80
81
|
|
|
81
|
-
const { redis
|
|
82
|
+
const { redis } = require('../lib/db');
|
|
82
83
|
const { Account } = require('../lib/account');
|
|
83
84
|
const settings = require('../lib/settings');
|
|
84
85
|
|
|
85
86
|
const getSecret = require('../lib/get-secret');
|
|
86
|
-
const { getESClient, documentStoreFeatureEnabled } = require('../lib/document-store');
|
|
87
87
|
|
|
88
88
|
const sso = require('../lib/sso');
|
|
89
89
|
|
|
@@ -110,7 +110,8 @@ const {
|
|
|
110
110
|
DEFAULT_EENGINE_TIMEOUT,
|
|
111
111
|
DEFAULT_MAX_ATTACHMENT_SIZE,
|
|
112
112
|
MAX_FORM_TTL,
|
|
113
|
-
NONCE_BYTES
|
|
113
|
+
NONCE_BYTES,
|
|
114
|
+
LAST_DOCUMENT_STORE_VERSION
|
|
114
115
|
} = consts;
|
|
115
116
|
|
|
116
117
|
const registerApiRoutes = require('../lib/api-routes');
|
|
@@ -133,7 +134,7 @@ const SUPPORTED_LOCALES = locales.map(locale => locale.locale);
|
|
|
133
134
|
|
|
134
135
|
const FLAG_SORT_ORDER = ['\\Inbox', '\\Flagged', '\\Sent', '\\Drafts', '\\All', '\\Archive', '\\Junk', '\\Trash'];
|
|
135
136
|
|
|
136
|
-
const { GMAIL_SCOPES, OPENID_SCOPES } = require('../lib/oauth/gmail');
|
|
137
|
+
const { GMAIL_SCOPES, OPENID_SCOPES, workspaceDomainOf } = require('../lib/oauth/gmail');
|
|
137
138
|
const { MAIL_RU_SCOPES } = require('../lib/oauth/mail-ru');
|
|
138
139
|
|
|
139
140
|
const GMAIL_SCOPE_DESCRIPTIONS = {
|
|
@@ -590,7 +591,6 @@ const init = async () => {
|
|
|
590
591
|
}
|
|
591
592
|
|
|
592
593
|
let assertPreconditionResult;
|
|
593
|
-
server.decorate('toolkit', 'getESClient', async (...args) => await getESClient(...args));
|
|
594
594
|
|
|
595
595
|
// A read-only view of the certificate store for routes. Ordering a certificate is the
|
|
596
596
|
// reconciler's job - it owns the state a page follows, the retry pacing and the listener
|
|
@@ -787,10 +787,10 @@ const init = async () => {
|
|
|
787
787
|
cors: !!CORS_CONFIG
|
|
788
788
|
};
|
|
789
789
|
|
|
790
|
-
|
|
790
|
+
server.auth.scheme(API_TOKEN_SCHEME, apiTokenScheme);
|
|
791
791
|
|
|
792
792
|
// Authentication for API calls
|
|
793
|
-
server.auth.strategy('api-token',
|
|
793
|
+
server.auth.strategy('api-token', API_TOKEN_SCHEME, {
|
|
794
794
|
allowQueryToken: true, // optional, false by default
|
|
795
795
|
validate: async (request, token /*, h*/) => {
|
|
796
796
|
let disableTokens = await settings.get('disableTokens');
|
|
@@ -885,7 +885,7 @@ const init = async () => {
|
|
|
885
885
|
tokenData = await tokens.get(token, false, { log: !request.app.mcpInternal, remoteAddress: request.app.ip });
|
|
886
886
|
} catch (err) {
|
|
887
887
|
// A thrown Boom reaches the client the way the scope and permission refusals
|
|
888
|
-
// below do (
|
|
888
|
+
// below do (the api-token scheme does not catch it), so the reason travels as a
|
|
889
889
|
// machine-readable code - UnknownToken, ExpiredToken, InvalidToken - while the
|
|
890
890
|
// message stays the generic one the scheme itself would have sent. The scheme
|
|
891
891
|
// name keeps the WWW-Authenticate header the plugin's own refusal carries.
|
|
@@ -1008,25 +1008,23 @@ const init = async () => {
|
|
|
1008
1008
|
|
|
1009
1009
|
let accountIdSource;
|
|
1010
1010
|
|
|
1011
|
-
//
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
break;
|
|
1026
|
-
}
|
|
1011
|
+
// Routes that carry an account component somewhere other than their URL params, named
|
|
1012
|
+
// by lib/api-routes/account-binding.js. The table is shared with the MCP tool registry,
|
|
1013
|
+
// which has to advertise exactly the tools a bound credential can actually call; the
|
|
1014
|
+
// resolution of each kind stays here, where the request is.
|
|
1015
|
+
switch (boundRouteBinding(request.method, request.route.path)) {
|
|
1016
|
+
case 'query':
|
|
1017
|
+
// `/v1/tokens` is in the table because it replaced
|
|
1018
|
+
// GET /v1/tokens/account/{account}, which carried the account in the path and so
|
|
1019
|
+
// reached a bound token's own tokens through the default branch below - as its
|
|
1020
|
+
// deprecated alias registration still does. Both stay under the same rule as
|
|
1021
|
+
// everything else: the argument has to name the token's own account, and
|
|
1022
|
+
// omitting it still refuses, because a bound credential must not enumerate the
|
|
1023
|
+
// instance.
|
|
1024
|
+
accountIdSource = queryAccount;
|
|
1027
1025
|
break;
|
|
1028
1026
|
|
|
1029
|
-
case '
|
|
1027
|
+
case 'record': {
|
|
1030
1028
|
let isAccountTemplate =
|
|
1031
1029
|
request.params.template && (await redis.sismember(`${REDIS_PREFIX}tpl:${tokenData.account}:i`, request.params.template));
|
|
1032
1030
|
if (isAccountTemplate) {
|
|
@@ -1035,15 +1033,10 @@ const init = async () => {
|
|
|
1035
1033
|
break;
|
|
1036
1034
|
}
|
|
1037
1035
|
|
|
1038
|
-
case '
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
request.app.enforceAccount = tokenData.account;
|
|
1042
|
-
accountIdSource = tokenData.account;
|
|
1043
|
-
break;
|
|
1044
|
-
}
|
|
1036
|
+
case 'token':
|
|
1037
|
+
request.app.enforceAccount = tokenData.account;
|
|
1038
|
+
accountIdSource = tokenData.account;
|
|
1045
1039
|
break;
|
|
1046
|
-
}
|
|
1047
1040
|
|
|
1048
1041
|
default:
|
|
1049
1042
|
accountIdSource = request.params && request.params.account;
|
|
@@ -2337,6 +2330,11 @@ const init = async () => {
|
|
|
2337
2330
|
// fills this in; one that does not leaves it empty, and an empty list fails the check closed.
|
|
2338
2331
|
const providerIdentities = [];
|
|
2339
2332
|
|
|
2333
|
+
// The Workspace or Cloud organization domain the provider reported, for an application
|
|
2334
|
+
// restricted to Google Workspace accounts. Only the Gmail case fills it in; the
|
|
2335
|
+
// restriction is a Google setting and no other provider has the notion.
|
|
2336
|
+
let workspaceDomain = null;
|
|
2337
|
+
|
|
2340
2338
|
// The token to revoke if the setup is rejected after the code was already exchanged, set by
|
|
2341
2339
|
// each provider case because the token response is scoped to the switch. Prefer the refresh
|
|
2342
2340
|
// token: revoking either invalidates the grant, but the access token may already be expired.
|
|
@@ -2406,6 +2404,10 @@ const init = async () => {
|
|
|
2406
2404
|
request.logger.info({ msg: 'Extracted user info from ID token', userEmail, userName });
|
|
2407
2405
|
}
|
|
2408
2406
|
|
|
2407
|
+
// Back channel, so this is the claim the restriction can actually be enforced on;
|
|
2408
|
+
// the hd argument on the authorization URL only filters the chooser Google shows
|
|
2409
|
+
workspaceDomain = workspaceDomainOf(idTokenPayload);
|
|
2410
|
+
|
|
2409
2411
|
// If ID token didn't provide email, fall back to Gmail API profile endpoint
|
|
2410
2412
|
// This should rarely happen since we now request openid/email/profile scopes
|
|
2411
2413
|
if (!userEmail) {
|
|
@@ -2654,6 +2656,38 @@ const init = async () => {
|
|
|
2654
2656
|
blobExpectation: pendingSetupExpectation(accountData, accountMeta)
|
|
2655
2657
|
});
|
|
2656
2658
|
|
|
2659
|
+
// "Accept only Google Workspace accounts" used to be advisory: generateAuthUrl() sets hd=*,
|
|
2660
|
+
// which filters the account chooser Google shows and nothing else, so a link assembled
|
|
2661
|
+
// without that argument - or a user who switches account inside the chooser - completed the
|
|
2662
|
+
// setup with a consumer account. The hosted-domain claim of the ID token is checked here
|
|
2663
|
+
// instead, and a token that names no domain is refused rather than trusted: for the Gmail
|
|
2664
|
+
// provider the OpenID scopes are always requested (GmailOauth's constructor adds them), so
|
|
2665
|
+
// a missing claim means the account has no Workspace domain, not that the claim was never
|
|
2666
|
+
// asked for.
|
|
2667
|
+
if (oauth2App.googleWorkspaceAccounts && oauth2App.provider === 'gmail' && !workspaceDomain) {
|
|
2668
|
+
request.logger.warn({
|
|
2669
|
+
msg: 'OAuth2 sign-in used a personal account for a Workspace-only application',
|
|
2670
|
+
account: accountData.account,
|
|
2671
|
+
provider: oauth2App.provider
|
|
2672
|
+
});
|
|
2673
|
+
|
|
2674
|
+
// The code was already exchanged, so we are holding a grant we will never use. Best
|
|
2675
|
+
// effort, and the same duck-typing guard as the identity mismatch below.
|
|
2676
|
+
if (grantToken && typeof oAuth2Client.revokeToken === 'function') {
|
|
2677
|
+
try {
|
|
2678
|
+
await oAuth2Client.revokeToken(grantToken);
|
|
2679
|
+
} catch (err) {
|
|
2680
|
+
request.logger.warn({ msg: 'Failed to revoke the OAuth2 grant after a Workspace check', err });
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
// select_account for the same reason as the identity mismatch: they are signed in to the
|
|
2685
|
+
// account that just failed, and without it Google would hand back the same one
|
|
2686
|
+
const retryUrl = await startOAuthRetry(accountData.email, 'select_account consent');
|
|
2687
|
+
|
|
2688
|
+
return workspaceErrorView(request, h, { actualEmail: providerIdentities[0], retryUrl });
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2657
2691
|
if (expectedEmail && !matchesExpectedIdentity(expectedEmail, providerIdentities)) {
|
|
2658
2692
|
// Neither address is logged: the expectation and the authenticated identity both belong to
|
|
2659
2693
|
// the end user, and this line is the one record of a failed attempt. Note the provider
|
|
@@ -2818,7 +2852,6 @@ const init = async () => {
|
|
|
2818
2852
|
server,
|
|
2819
2853
|
call,
|
|
2820
2854
|
notify,
|
|
2821
|
-
documentsQueue,
|
|
2822
2855
|
metrics,
|
|
2823
2856
|
CORS_CONFIG,
|
|
2824
2857
|
FLAG_SORT_ORDER,
|
|
@@ -2826,7 +2859,6 @@ const init = async () => {
|
|
|
2826
2859
|
MAX_ATTACHMENT_SIZE,
|
|
2827
2860
|
MAX_BODY_SIZE,
|
|
2828
2861
|
MAX_PAYLOAD_TIMEOUT,
|
|
2829
|
-
documentStoreFeatureEnabled,
|
|
2830
2862
|
mcpFeatureEnabled,
|
|
2831
2863
|
oauth2Schema,
|
|
2832
2864
|
imapSchema,
|
|
@@ -2871,7 +2903,10 @@ const init = async () => {
|
|
|
2871
2903
|
layoutPath: './views/layout',
|
|
2872
2904
|
partialsPath: './views/partials',
|
|
2873
2905
|
|
|
2874
|
-
|
|
2906
|
+
// Uncached, vision re-reads and re-registers every partial with synchronous fs calls on
|
|
2907
|
+
// each render, blocking the worker that also serves /v1. Only development wants live
|
|
2908
|
+
// template edits.
|
|
2909
|
+
isCached: process.env.NODE_ENV !== 'development',
|
|
2875
2910
|
|
|
2876
2911
|
async context(request) {
|
|
2877
2912
|
// The three reads are independent, and this runs on every admin page render. The
|
|
@@ -2911,7 +2946,11 @@ const init = async () => {
|
|
|
2911
2946
|
tract,
|
|
2912
2947
|
templateHeader: embeddedTemplateHeader,
|
|
2913
2948
|
templateHtmlHead: embeddedTemplateHtmlHead,
|
|
2914
|
-
|
|
2949
|
+
// The Document Store was removed in 2.82.0. The setting that switched it on is
|
|
2950
|
+
// read raw off the settings hash (it is no longer in the settings schema), so an
|
|
2951
|
+
// instance upgraded with the feature still on is told where it went instead of
|
|
2952
|
+
// losing it quietly
|
|
2953
|
+
documentStoreEnabled: documentStoreRemoved,
|
|
2915
2954
|
serviceUrl,
|
|
2916
2955
|
language,
|
|
2917
2956
|
locale,
|
|
@@ -2923,10 +2962,6 @@ const init = async () => {
|
|
|
2923
2962
|
let systemAlerts = [];
|
|
2924
2963
|
let authData;
|
|
2925
2964
|
|
|
2926
|
-
// Deprecated Document Store: enabled in settings but unavailable because EmailEngine
|
|
2927
|
-
// was not started with the document store gate (--documentStore.enabled / EENGINE_DOCUMENT_STORE_ENABLED).
|
|
2928
|
-
let documentStoreUnavailable = !documentStoreFeatureEnabled && !!showDocumentStore;
|
|
2929
|
-
|
|
2930
2965
|
switch (request.auth.artifacts && request.auth.artifacts.provider) {
|
|
2931
2966
|
case 'okta': {
|
|
2932
2967
|
let profile = request.auth.artifacts.profile || {};
|
|
@@ -3049,12 +3084,12 @@ const init = async () => {
|
|
|
3049
3084
|
});
|
|
3050
3085
|
}
|
|
3051
3086
|
|
|
3052
|
-
if (
|
|
3087
|
+
if (documentStoreRemoved) {
|
|
3053
3088
|
systemAlerts.push({
|
|
3054
3089
|
url: '/admin',
|
|
3055
3090
|
level: 'danger',
|
|
3056
3091
|
icon: 'icon-[tabler--database]',
|
|
3057
|
-
message: `The Document Store
|
|
3092
|
+
message: `The Document Store has been removed from EmailEngine. Downgrade to v${LAST_DOCUMENT_STORE_VERSION} if you still need it.`
|
|
3058
3093
|
});
|
|
3059
3094
|
}
|
|
3060
3095
|
|
|
@@ -3091,8 +3126,8 @@ const init = async () => {
|
|
|
3091
3126
|
embeddedTemplateHeader,
|
|
3092
3127
|
embeddedTemplateHtmlHead,
|
|
3093
3128
|
currentYear: new Date().getFullYear(),
|
|
3094
|
-
|
|
3095
|
-
|
|
3129
|
+
documentStoreRemoved,
|
|
3130
|
+
lastDocumentStoreVersion: LAST_DOCUMENT_STORE_VERSION,
|
|
3096
3131
|
updateBrowserInfo: !serviceUrl || !language || !timezone,
|
|
3097
3132
|
|
|
3098
3133
|
// Suppress large banner warnings when EENGINE_DISABLE_SETUP_WARNINGS is set
|