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
package/.ncurc.js
CHANGED
|
@@ -11,10 +11,27 @@ module.exports = {
|
|
|
11
11
|
// is a major we are deliberately soaking. Using 'minor' instead of a blanket reject so these
|
|
12
12
|
// still receive security/patch updates within the safe major instead of being frozen at one
|
|
13
13
|
// exact version. Verified against Node 20 (Docker) 2026-06-17.
|
|
14
|
+
//
|
|
15
|
+
// `pino` is capped harder than the rest, at 'patch', because the break arrived in a MINOR and a
|
|
16
|
+
// major cap would not have stopped it. See its entry below.
|
|
14
17
|
target: name =>
|
|
15
|
-
|
|
18
|
+
name === 'pino'
|
|
19
|
+
? 'patch'
|
|
20
|
+
: ['nanoid', 'gettext-parser', 'xgettext-template', 'chai', 'undici', 'marked', '@sentry/node-core', 'he'].includes(name)
|
|
21
|
+
? 'minor'
|
|
22
|
+
: 'latest',
|
|
23
|
+
// pino - held on 10.3.x. 10.4.0 took PR #2294, which makes lib/caller.js prefer
|
|
24
|
+
// util.getCallSites() over the Error.prepareStackTrace dance. Inside a pkg
|
|
25
|
+
// binary that API aborts the PROCESS, not the call: V8 fails the CHECK in
|
|
26
|
+
// Script::GetPositionInfo() for a script that has no position info in the
|
|
27
|
+
// snapshot, and the binary dies on startup with SIGTRAP (exit 133) before
|
|
28
|
+
// main() does anything. `emailengine --version` is enough to trigger it.
|
|
29
|
+
// Reproduced on node24-macos-arm64 and caught by the linux-x64 binary build
|
|
30
|
+
// job, which exists for exactly this. Nothing in EmailEngine calls the API:
|
|
31
|
+
// pino reaches it whenever a logger is constructed. Lift only once a pino
|
|
32
|
+
// release guards the getCallSites path, or pkg ships position info for
|
|
33
|
+
// snapshotted scripts, and only with a binary built and run to prove it.
|
|
16
34
|
// nanoid - 4.x dropped the CommonJS require export (ESM-only)
|
|
17
|
-
// ical.js - 2.x is ESM-only
|
|
18
35
|
// gettext-parser - 8.x is ESM-only
|
|
19
36
|
// xgettext-template - 6.x is ESM-only (translation build tool)
|
|
20
37
|
// chai - 5.x is ESM-only (only used by the vendored imap-core tests)
|
|
@@ -23,10 +40,20 @@ module.exports = {
|
|
|
23
40
|
// marked - 16.x dropped the CommonJS build (ESM-only, needs require(esm)/Node >=20.19); 15.x is the
|
|
24
41
|
// last require()-compatible line. 15.0.12 verified on Node 20-24 and in a yao/pkg node24 build.
|
|
25
42
|
// Permanent while the Node 20 floor above stands.
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
43
|
+
// he - 2.x is ESM-only (exports only src/he.mjs) and requires Node >=22; require('he') throws
|
|
44
|
+
// ERR_REQUIRE_ESM on Node 20 before 20.19. 1.2.0 is the last CommonJS release. mailparser,
|
|
45
|
+
// which reaches EmailEngine through the same require, rejects 2.x for the same reason.
|
|
46
|
+
// @sentry/node-core - held on the 10.x line for the reasons @sentry/node (which it replaced, through its
|
|
47
|
+
// `light` entry) was held there: @sentry/node 11.x requires Node >=20.19 (the DigitalOcean
|
|
48
|
+
// images are not guaranteed to be on a 20.x that new), and it depends on
|
|
49
|
+
// @sentry/bundler-plugins, which pulls the 16 MB Sentry CLI (package `sentry`, licensed
|
|
50
|
+
// FSL-1.1-Apache-2.0, not an OSI license) into the runtime tree and the pkg bundle. The
|
|
51
|
+
// node-core line is versioned in step with @sentry/node, so lift this only once an 11.x
|
|
52
|
+
// of node-core exists and has been checked against both points.
|
|
53
|
+
//
|
|
54
|
+
// ical.js was capped at 1.x here as "2.x is ESM-only", which was never true: every 2.x ships a CommonJS
|
|
55
|
+
// build behind exports.require. Moved to 2.x on 2026-09-28; it is also what resolves a DTSTART against
|
|
56
|
+
// the VTIMEZONE embedded in the same invite (1.x read such a value in the server's own zone).
|
|
30
57
|
//
|
|
31
58
|
// bullmq was capped at 5.x until 2026-08-17, when both stated reasons had expired. Now on 6.x, which
|
|
32
59
|
// moves cron-parser off the deprecated 4.9.0 onto 5.x - but not off luxon, which cron-parser depends
|
|
@@ -42,10 +69,6 @@ module.exports = {
|
|
|
42
69
|
// bump still needs a look at the generated document: test/openapi-golden-test.js fails if joi's
|
|
43
70
|
// describe() output changes shape.
|
|
44
71
|
reject: [
|
|
45
|
-
// 8.16+ pulls apache-arrow (ESM) into the pkg bundle; 9.x drops it but is a major bump for
|
|
46
|
-
// the deprecated, default-off Document Store. Even the 8.19 minor is unsafe to bundle.
|
|
47
|
-
'@elastic/elasticsearch',
|
|
48
|
-
|
|
49
72
|
// @asamuzakjp/css-color >=4.1.2 pulls in @csstools/* v4 which are pure ESM and break pkg bundling
|
|
50
73
|
// (transitive via @postalsys/email-text-tools -> jsdom -> cssstyle; also pinned in package.json "overrides").
|
|
51
74
|
'@asamuzakjp/css-color'
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.82.1](https://github.com/postalsys/emailengine/compare/v2.82.0...v2.82.1) (2026-10-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* carry the GatewayNotFound code in the 404 response body ([43af659](https://github.com/postalsys/emailengine/commit/43af65915bc6daa77bbf1612860eb40e62ed93ef))
|
|
9
|
+
* check every PTR record when filtering scanner opens and clicks ([ebcd78b](https://github.com/postalsys/emailengine/commit/ebcd78b7957c925b5dc454415f7d9706b17d4a21))
|
|
10
|
+
* classify a wrapped transport failure as the outage it is ([a8d63a8](https://github.com/postalsys/emailengine/commit/a8d63a841fcdb55faa619656bb43d2008c0ce3e2))
|
|
11
|
+
* correct the descriptions and comments that disagreed with the behavior ([dcdc3e9](https://github.com/postalsys/emailengine/commit/dcdc3e9b994ab137afe5769790d8c9cd5a227233))
|
|
12
|
+
* declare the token-request fields the error record actually carries ([23fd0e4](https://github.com/postalsys/emailengine/commit/23fd0e4f8ad2de79bb251cc72eefb2736f1a541e))
|
|
13
|
+
* **deps:** hold pino at 10.3.x, which 10.4.0 made unbundlable ([4c4e7e3](https://github.com/postalsys/emailengine/commit/4c4e7e32bfde6a079bce796a15b2b85f6374c312))
|
|
14
|
+
* **deps:** update @sentry/node-core, pino, eslint and supertest ([9c5b9d5](https://github.com/postalsys/emailengine/commit/9c5b9d51c7a1e8ffd11adecd5181c9b4461bb34c))
|
|
15
|
+
* **deps:** update imapflow, mailparser, nodemailer and smtp-server ([ef14661](https://github.com/postalsys/emailengine/commit/ef1466115acc3dc727e1b46b08fd194dd3f90beb))
|
|
16
|
+
* **deps:** update imapflow, nodemailer, mailparser and the libbase64 chain ([9c8971e](https://github.com/postalsys/emailengine/commit/9c8971e345cfada10f875ca1086ea010b10ada91))
|
|
17
|
+
* describe hasMore the way both backends behave ([8b0bc19](https://github.com/postalsys/emailengine/commit/8b0bc19b32adf8fdb3c5095551ad75417430ba8a))
|
|
18
|
+
* document progress.networkRouting where the outbox entry carries it ([593e390](https://github.com/postalsys/emailengine/commit/593e390e38964e8f57359b421a2d2825a50be1cb))
|
|
19
|
+
* follow an autodiscovery in-response redirect anonymously ([554068e](https://github.com/postalsys/emailengine/commit/554068e322bc7f2daf67ad1841900c420e9d3da1))
|
|
20
|
+
* hold MCP text results to the result cap, newest-first for a log ([d44c648](https://github.com/postalsys/emailengine/commit/d44c64834bf86b36ee0ffe4cdd56da96a8733718))
|
|
21
|
+
* let POST /v1/gateway generate the gateway id ([6901349](https://github.com/postalsys/emailengine/commit/6901349bcfb25fe2c3995a1c0d2a8fe54fd10ba7))
|
|
22
|
+
* let the CLI issue the mcp-manage scope, with explicit grants ([84565d1](https://github.com/postalsys/emailengine/commit/84565d149d7661390c8c75e8a737fa14a628f238))
|
|
23
|
+
* make the export retention and per-message size limits settable ([c6e6930](https://github.com/postalsys/emailengine/commit/c6e6930d6619ae8ceb96a70ac151707db86de7d6))
|
|
24
|
+
* move the nextAttempt retry timing into the module that owns the job phase ([24defb8](https://github.com/postalsys/emailengine/commit/24defb839c725f0f6abdee3bd7f08a395f92aa77))
|
|
25
|
+
* name the token endpoint when a credential request cannot reach it ([a0748bc](https://github.com/postalsys/emailengine/commit/a0748bc61943f107fdaf18d01cf02e9f1b899c8b))
|
|
26
|
+
* offer all five special-use folder overrides on the account form ([d7faa2d](https://github.com/postalsys/emailengine/commit/d7faa2d6a39984fb4ccbf0e41026abcc279aec13))
|
|
27
|
+
* offer the Gmail API base scope to a service-account app ([fc23ea2](https://github.com/postalsys/emailengine/commit/fc23ea2a39142c0cb561d687b4d0be862068a6bc))
|
|
28
|
+
* **outlook:** recover messages whose Graph notification was silently dropped ([f0ea5c1](https://github.com/postalsys/emailengine/commit/f0ea5c19fd6835d23a6665c1431bc3f0a054dde2))
|
|
29
|
+
* perform the autodiscovery steps that name another endpoint ([83a4f6c](https://github.com/postalsys/emailengine/commit/83a4f6cd43ad523062acfed4674a0e8bde194891))
|
|
30
|
+
* print the api.proxy default the server actually applies ([c611661](https://github.com/postalsys/emailengine/commit/c6116611b607dd0e7011e3ed93eefaa45e80c4f4))
|
|
31
|
+
* read EENGINE_WORKERS_EXPORT, which the Workers page already named ([f397492](https://github.com/postalsys/emailengine/commit/f397492cbfd6a05a55b31ce1c1e0518f6a7e7743))
|
|
32
|
+
* read every EENGINE_ variable through the one helper ([b58bfec](https://github.com/postalsys/emailengine/commit/b58bfeccfc18ff39ec841e4e737a4a1299cc499d))
|
|
33
|
+
* record a delivery failure the SMTP error table cannot describe ([01d749f](https://github.com/postalsys/emailengine/commit/01d749f7c3d67d54af0a5abbdfab0f52ec69e233))
|
|
34
|
+
* report a parked IMAP account as an IMAP account ([0be8f56](https://github.com/postalsys/emailengine/commit/0be8f568719143919c2fa67300969a300050a15c))
|
|
35
|
+
* run the Docker Compose command setup-production.sh checked for ([e0e7272](https://github.com/postalsys/emailengine/commit/e0e7272bd481ca5ce6362ee559fdaca04f3730b1))
|
|
36
|
+
* say that a Graph subscription failure is what connectError can mean ([a073622](https://github.com/postalsys/emailengine/commit/a0736226cdb4b7ef59bbb6f1b9221035575280f7))
|
|
37
|
+
* say what happens to the workers when there is no active license ([0b97e05](https://github.com/postalsys/emailengine/commit/0b97e056bda19904b385b8441c5c72eca74d8392))
|
|
38
|
+
* say what makes an OAuth2 app API-based ([d54f8eb](https://github.com/postalsys/emailengine/commit/d54f8eb51ada78844418ee0d09509339f8a2f2ae))
|
|
39
|
+
* say when a file-backed secret resolves differently than it used to ([f4712fa](https://github.com/postalsys/emailengine/commit/f4712fa1b58608a4141f0b3e8c9c7231307db477))
|
|
40
|
+
* stop a failed quota lookup from failing the account it belongs to ([dd45dac](https://github.com/postalsys/emailengine/commit/dd45dac933dbb11f27eb2ad41b6eba2ca2e4985d))
|
|
41
|
+
* stop advertising verify_oauth2_app to an account-bound MCP credential ([441dc3f](https://github.com/postalsys/emailengine/commit/441dc3f00b3290355e49e295795c36b576fe2f04))
|
|
42
|
+
* stop the account form wiping the folder overrides it does not show ([fc3d5eb](https://github.com/postalsys/emailengine/commit/fc3d5eb7ccc74ef3d3a2d01416fce0641828ef1a))
|
|
43
|
+
* strip skipped scopes on every Microsoft cloud, not just the global one ([d74ab26](https://github.com/postalsys/emailengine/commit/d74ab260347424d9cd3b95954ddd09a18a06d513))
|
|
44
|
+
* tighten the MCP account binding, result cap, outbox retry time and CLI scopes ([a54a448](https://github.com/postalsys/emailengine/commit/a54a448294b17eaa84635ffc1ebb6e7f03561b37))
|
|
45
|
+
* verify the hd claim for a Workspace-only OAuth2 application ([5fbb322](https://github.com/postalsys/emailengine/commit/5fbb3228d634f65dab654bd9370d54611e2f0981))
|
|
46
|
+
|
|
47
|
+
## [2.82.0](https://github.com/postalsys/emailengine/compare/v2.81.2...v2.82.0) (2026-10-01)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* check incoming mail in code before the AI reads it, and pick the model from a list that says what each is for ([cf6f3a6](https://github.com/postalsys/emailengine/commit/cf6f3a6fda2d7c67a7f178b9c10e5014fc497e48))
|
|
53
|
+
* deliver the AI summary as the model returned it, and count its usage ([854ef18](https://github.com/postalsys/emailengine/commit/854ef18f1f8969bdcabe34b5a3a99c6ee2fc71e8))
|
|
54
|
+
* remove embeddings generation ([f4ddd90](https://github.com/postalsys/emailengine/commit/f4ddd908326bf6489ebbbdbf3421a291043ce8f0))
|
|
55
|
+
* remove the Document Store ([56df159](https://github.com/postalsys/emailengine/commit/56df159e4838d7b3052dadb8c30d8ac1e85f4e12))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Bug Fixes
|
|
59
|
+
|
|
60
|
+
* assert the literal cap on the continuations sent before the refusal ([1aa24dc](https://github.com/postalsys/emailengine/commit/1aa24dc9d6cbd2a2b8b33b4dc8f5fd328ab435bb))
|
|
61
|
+
* close the findings of the 2026-09-28 codebase audit ([2db748f](https://github.com/postalsys/emailengine/commit/2db748fc9879d577d3a9634fd6676149c91c1219))
|
|
62
|
+
* count announced literals against the IMAP proxy cap at continuation time ([51b73d2](https://github.com/postalsys/emailengine/commit/51b73d2f498e2d1fcd85861104ad89f65f184879))
|
|
63
|
+
* **deps:** update libmime, mailsplit, imapflow, mailparser and email-ai-tools ([943d2f5](https://github.com/postalsys/emailengine/commit/943d2f5891a88ff040fc2b7b3eb590c16cc498c6))
|
|
64
|
+
* **deps:** update nodemailer, smtp-server, mailparser, email-content and email-ai-tools ([af7aa9f](https://github.com/postalsys/emailengine/commit/af7aa9f5a46fb20409c9d8a3bd64be63c6593700))
|
|
65
|
+
* drop the trusted authentication servers setting from the AI page ([0b01c7e](https://github.com/postalsys/emailengine/commit/0b01c7e04c80e4dc60bf3bcf6b11e3114e9bd9ff))
|
|
66
|
+
* **imap:** measure the stale view quiet period from the UIDNEXT the primary knows ([a3044a1](https://github.com/postalsys/emailengine/commit/a3044a1ddbdae50298ebc3f61a909102360548dd))
|
|
67
|
+
* **imap:** reconnect a primary connection whose view of the main mailbox stopped moving ([442955c](https://github.com/postalsys/emailengine/commit/442955c41ef2f0fa4898e089056d2ee9fa7a2fdd))
|
|
68
|
+
* match the model picker's search term by term and rank the answers ([632754e](https://github.com/postalsys/emailengine/commit/632754e3e2110431caedb6f6ba391a3367b58df9))
|
|
69
|
+
* **outlook:** keep draft replies threaded on MS Graph accounts ([1ec3c6a](https://github.com/postalsys/emailengine/commit/1ec3c6a1485ee4fd649060e6fd2f137b01d87975))
|
|
70
|
+
* read the browse page session token from its hidden input in the e2e spec ([eea4a58](https://github.com/postalsys/emailengine/commit/eea4a58d5d15779c322fa52b9cc03b14284f2104))
|
|
71
|
+
* update ImapFlow to 2.2.1 ([a007b46](https://github.com/postalsys/emailengine/commit/a007b46ab68add12486ad11e6bef84db53777974))
|
|
72
|
+
* use only FIPS-approved primitives, so an instance runs on a host whose OpenSSL is in FIPS mode ([5070de0](https://github.com/postalsys/emailengine/commit/5070de07d5ac4c64bfa252766b965e9602407497))
|
|
73
|
+
|
|
3
74
|
## [2.81.2](https://github.com/postalsys/emailengine/compare/v2.81.1...v2.81.2) (2026-09-27)
|
|
4
75
|
|
|
5
76
|
|
package/DOCKER_DEPLOYMENT.md
CHANGED
|
@@ -156,13 +156,11 @@ server {
|
|
|
156
156
|
proxy_read_timeout 600;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
proxy_set_header Connection "upgrade";
|
|
165
|
-
}
|
|
159
|
+
# No extra location is needed for the live updates. EmailEngine streams account state changes as
|
|
160
|
+
# Server-Sent Events over the ordinary path (/v1/changes and the admin UI's own stream) and sends
|
|
161
|
+
# `X-Accel-Buffering: no` with them, which nginx honours, so the events are not held in a buffer.
|
|
162
|
+
# The read timeout above does apply to them: an idle feed is cut after 600s. A browser EventSource
|
|
163
|
+
# reconnects on its own; a /v1/changes consumer written by hand has to do the same.
|
|
166
164
|
}
|
|
167
165
|
|
|
168
166
|
server {
|
|
@@ -288,8 +286,9 @@ docker-compose logs --tail=50 emailengine
|
|
|
288
286
|
#### Rollback if Needed
|
|
289
287
|
|
|
290
288
|
```bash
|
|
291
|
-
# Specify previous version in .env
|
|
292
|
-
|
|
289
|
+
# Specify previous version in .env. The published image tags carry the `v` prefix the git tags
|
|
290
|
+
# carry (v2.82.0, v2.82, v2, latest), so a bare 2.40.0 resolves to no image at all.
|
|
291
|
+
EMAILENGINE_VERSION=v2.40.0
|
|
293
292
|
docker-compose up -d --no-deps emailengine
|
|
294
293
|
```
|
|
295
294
|
|
|
@@ -392,9 +391,11 @@ docker-compose logs --tail=100 emailengine
|
|
|
392
391
|
#### Performance Issues
|
|
393
392
|
|
|
394
393
|
```bash
|
|
395
|
-
# Enable debug logging
|
|
396
|
-
|
|
397
|
-
|
|
394
|
+
# Enable debug logging. The level is read from the environment at startup, so it has to be set on
|
|
395
|
+
# the container rather than exported inside it - `exec ... export` sets it in a shell that then
|
|
396
|
+
# exits, and `restart` reuses the container's existing environment either way.
|
|
397
|
+
echo 'EENGINE_LOG_LEVEL=debug' >> .env
|
|
398
|
+
docker-compose up -d --no-deps --force-recreate emailengine
|
|
398
399
|
|
|
399
400
|
# Check slow operations
|
|
400
401
|
docker-compose exec redis redis-cli -a "$REDIS_PASSWORD" SLOWLOG GET 10
|
package/Dockerfile
CHANGED
|
@@ -98,6 +98,8 @@ USER emailengineuser
|
|
|
98
98
|
|
|
99
99
|
ENV EENGINE_HOST=0.0.0.0
|
|
100
100
|
ENV EENGINE_API_PROXY=true
|
|
101
|
+
# The pure JavaScript msgpackr decoder is what the pkg binary uses, so npm and Docker installs decode the same way and no native addon is loaded
|
|
102
|
+
ENV MSGPACKR_NATIVE_ACCELERATION_DISABLED=true
|
|
101
103
|
|
|
102
104
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
|
103
105
|
CMD ["node", "/emailengine/server.js"]
|
package/bin/emailengine.js
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
/* eslint global-require: 0 */
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
+
// No native addons (CLAUDE.md "Pure JavaScript only"): keep msgpackr, loaded through bullmq by
|
|
6
|
+
// lib/db below, off its optional node-gyp decoder. server.js sets the same for a direct start.
|
|
7
|
+
process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED = 'true';
|
|
8
|
+
|
|
5
9
|
const packageData = require('../package.json');
|
|
6
10
|
const fs = require('fs');
|
|
7
11
|
const pathlib = require('path');
|
|
8
12
|
const settings = require('../lib/settings');
|
|
9
13
|
const { checkLicense } = require('../lib/tools');
|
|
10
|
-
const pbkdf2 = require('
|
|
11
|
-
const {
|
|
14
|
+
const pbkdf2 = require('../lib/pbkdf2-phc');
|
|
15
|
+
const { generateWebhookTable } = require('../lib/consts');
|
|
12
16
|
const { Account } = require('../lib/account');
|
|
13
17
|
const getSecret = require('../lib/get-secret');
|
|
14
18
|
const { redis } = require('../lib/db');
|
|
@@ -59,7 +63,13 @@ const COMMANDS = {
|
|
|
59
63
|
description: 'Create a new access token',
|
|
60
64
|
options: [
|
|
61
65
|
{ name: '--description, -d', description: 'Token description', type: 'string' },
|
|
62
|
-
{
|
|
66
|
+
{
|
|
67
|
+
name: '--scope, -s',
|
|
68
|
+
description:
|
|
69
|
+
'Access scope, repeatable: "*", "api", "metrics", "smtp", "imap-proxy", "mcp-manage" or "mcp". An MCP scope requires an access level after a colon ("mcp-manage:observe", levels observe/operate/administer; "mcp:read", levels read/mail/full), and cannot be combined with the others',
|
|
70
|
+
type: 'string',
|
|
71
|
+
default: '*'
|
|
72
|
+
},
|
|
63
73
|
{ name: '--account, -a', description: 'Limit token to specific account', type: 'string' }
|
|
64
74
|
]
|
|
65
75
|
},
|
|
@@ -116,10 +126,13 @@ const GLOBAL_OPTIONS = [
|
|
|
116
126
|
group: 'API server'
|
|
117
127
|
},
|
|
118
128
|
{
|
|
129
|
+
// The effective default, not the flag's own: server.js seeds the enableApiProxy setting to true
|
|
130
|
+
// when neither --api.proxy nor EENGINE_API_PROXY is given, which is the historical behavior.
|
|
131
|
+
// Printing the option's default told operators the header was ignored unless they opted in.
|
|
119
132
|
name: '--api.proxy',
|
|
120
133
|
description: 'Trust X-Forwarded-For from the reverse proxy in front of the API (restrict the peers with EENGINE_API_PROXY_ADDRESSES)',
|
|
121
134
|
type: 'boolean',
|
|
122
|
-
default:
|
|
135
|
+
default: true,
|
|
123
136
|
group: 'API server'
|
|
124
137
|
},
|
|
125
138
|
{ name: '--api.tls.certPath', description: 'Path to the TLS certificate; setting it serves the API over HTTPS', type: 'string', group: 'API server' },
|
|
@@ -133,13 +146,6 @@ const GLOBAL_OPTIONS = [
|
|
|
133
146
|
{ name: '--smtp.port', description: 'SMTP server port', type: 'number', default: 2525, group: 'SMTP server' },
|
|
134
147
|
{ name: '--smtp.proxy', description: 'Enable HAProxy PROXY protocol', type: 'boolean', default: false, group: 'SMTP server' },
|
|
135
148
|
{ name: '--smtp.maxMessageSize', description: 'Maximum email size', type: 'number/string', default: '25M', group: 'SMTP server' },
|
|
136
|
-
{
|
|
137
|
-
name: '--documentStore.enabled',
|
|
138
|
-
description: 'Enable the deprecated Document Store (ElasticSearch) feature',
|
|
139
|
-
type: 'boolean',
|
|
140
|
-
default: false,
|
|
141
|
-
group: 'Document Store (deprecated)'
|
|
142
|
-
},
|
|
143
149
|
{
|
|
144
150
|
name: '--mcp.enabled',
|
|
145
151
|
description: 'Register the MCP endpoint at /mcp (the mcpEnabled runtime setting still has to be turned on)',
|
|
@@ -386,11 +392,7 @@ function run() {
|
|
|
386
392
|
}
|
|
387
393
|
|
|
388
394
|
let updatePassword = async () => {
|
|
389
|
-
let passwordHash = await pbkdf2.hash(password
|
|
390
|
-
iterations: PDKDF2_ITERATIONS,
|
|
391
|
-
saltSize: PDKDF2_SALT_SIZE,
|
|
392
|
-
digest: PDKDF2_DIGEST
|
|
393
|
-
});
|
|
395
|
+
let passwordHash = await pbkdf2.hash(password);
|
|
394
396
|
|
|
395
397
|
let authData = await settings.get('authData');
|
|
396
398
|
|
|
@@ -520,22 +522,82 @@ function run() {
|
|
|
520
522
|
switch (tokensCmd) {
|
|
521
523
|
case 'issue':
|
|
522
524
|
{
|
|
523
|
-
|
|
524
|
-
|
|
525
|
+
const { MCP_SECTIONS, mcpGrantsFor, mcpLevel } = require('../lib/token-permission-view');
|
|
526
|
+
|
|
527
|
+
// The two MCP scopes, by the name typed on the command line. A token
|
|
528
|
+
// holding one of them always carries the pair list of a named access
|
|
529
|
+
// level, exactly as the admin form and the consent prompt mint it: a
|
|
530
|
+
// credential issued for the tools of today must not grow to include a
|
|
531
|
+
// tool shipped next release. The level is appended to the scope with a
|
|
532
|
+
// colon (`--scope mcp-manage:observe`) and is REQUIRED: there is no
|
|
533
|
+
// consent prompt here to show what a level allows, and the one thing an
|
|
534
|
+
// implicit default must not do is pick the widest one.
|
|
535
|
+
const mcpScopes = new Map(Object.entries(MCP_SECTIONS).map(([key, section]) => [section.scope, { key, section }]));
|
|
536
|
+
|
|
537
|
+
let allowedScopes = ['*', 'api', 'metrics', 'smtp', 'imap-proxy'].concat([...mcpScopes.keys()]);
|
|
538
|
+
let requestedScopes = []
|
|
525
539
|
.concat(argv.scope || [])
|
|
526
540
|
.concat(argv.s || [])
|
|
527
541
|
.map(entry => (entry || '').toString().toLowerCase());
|
|
528
542
|
|
|
529
|
-
if (!
|
|
530
|
-
|
|
543
|
+
if (!requestedScopes.length) {
|
|
544
|
+
requestedScopes = ['*'];
|
|
531
545
|
}
|
|
532
546
|
|
|
533
|
-
|
|
547
|
+
let scopes = [];
|
|
548
|
+
let mcpChoice = {};
|
|
549
|
+
|
|
550
|
+
for (let entry of requestedScopes) {
|
|
551
|
+
let separator = entry.indexOf(':');
|
|
552
|
+
let scope = separator < 0 ? entry : entry.slice(0, separator);
|
|
553
|
+
let level = separator < 0 ? null : entry.slice(separator + 1);
|
|
554
|
+
|
|
534
555
|
if (!allowedScopes.includes(scope)) {
|
|
535
556
|
console.error(`Unknown scope: ${scope}`);
|
|
536
557
|
console.error(`Allowed scopes: "${allowedScopes.join('", "')}"`);
|
|
537
558
|
process.exit(1);
|
|
538
559
|
}
|
|
560
|
+
|
|
561
|
+
if (!mcpScopes.has(scope)) {
|
|
562
|
+
if (level !== null) {
|
|
563
|
+
console.error(`Scope "${scope}" does not take an access level`);
|
|
564
|
+
process.exit(1);
|
|
565
|
+
}
|
|
566
|
+
scopes.push(scope);
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const { key, section } = mcpScopes.get(scope);
|
|
571
|
+
// mcpLevel() is the shared vocabulary, and it answers null both for a
|
|
572
|
+
// name the section does not have and for `none` - which is what makes
|
|
573
|
+
// `--scope mcp:none`, asking for a scope and declining it in the same
|
|
574
|
+
// breath, an error here rather than a token that grants nothing
|
|
575
|
+
if (!mcpLevel(section, level)) {
|
|
576
|
+
const levelNames = section.levels.map(sectionLevel => sectionLevel.value).join('", "');
|
|
577
|
+
console.error(
|
|
578
|
+
level === null
|
|
579
|
+
? `Scope "${scope}" needs an access level, as "${scope}:<level>"`
|
|
580
|
+
: `Unknown ${scope} access level: ${level}`
|
|
581
|
+
);
|
|
582
|
+
console.error(`Allowed levels: "${levelNames}"`);
|
|
583
|
+
process.exit(1);
|
|
584
|
+
}
|
|
585
|
+
mcpChoice[key] = level;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
let permissions;
|
|
589
|
+
if (Object.keys(mcpChoice).length) {
|
|
590
|
+
// The admin form hides the level editor as soon as a non-MCP scope is
|
|
591
|
+
// ticked, because one permissions record covers the whole token and a
|
|
592
|
+
// level's pair list would narrow the REST API too. There is no way to
|
|
593
|
+
// type a custom record here, so the combination is refused rather
|
|
594
|
+
// than silently resolved one way or the other.
|
|
595
|
+
if (scopes.length) {
|
|
596
|
+
console.error(`An MCP scope cannot be combined with "${scopes.join('", "')}" on the command line`);
|
|
597
|
+
console.error('Issue separate tokens, or use POST /v1/tokens to set an explicit permissions record');
|
|
598
|
+
process.exit(1);
|
|
599
|
+
}
|
|
600
|
+
({ scopes, permissions } = mcpGrantsFor(mcpChoice));
|
|
539
601
|
}
|
|
540
602
|
|
|
541
603
|
let description = (argv.description || argv.d || '').toString();
|
|
@@ -548,6 +610,7 @@ function run() {
|
|
|
548
610
|
account,
|
|
549
611
|
description,
|
|
550
612
|
scopes,
|
|
613
|
+
permissions,
|
|
551
614
|
nolog: true
|
|
552
615
|
})
|
|
553
616
|
.then(token => {
|
|
@@ -581,7 +644,13 @@ function run() {
|
|
|
581
644
|
case 'import':
|
|
582
645
|
{
|
|
583
646
|
let rawToken = (argv.token || argv.t || '').toString();
|
|
584
|
-
let tokenData
|
|
647
|
+
let tokenData;
|
|
648
|
+
try {
|
|
649
|
+
tokenData = msgpack.decode(Buffer.from(rawToken, 'base64url'));
|
|
650
|
+
} catch (err) {
|
|
651
|
+
console.error(`Unable to decode token data: ${err.message}`);
|
|
652
|
+
return process.exit(1);
|
|
653
|
+
}
|
|
585
654
|
tokens
|
|
586
655
|
.setRawData(tokenData)
|
|
587
656
|
.then(result => {
|
|
@@ -600,8 +669,12 @@ function run() {
|
|
|
600
669
|
break;
|
|
601
670
|
|
|
602
671
|
default:
|
|
603
|
-
|
|
604
|
-
|
|
672
|
+
// Nothing else would end the process: the Redis connection opened on load
|
|
673
|
+
// kept it running with no output
|
|
674
|
+
console.error(tokensCmd ? `Unknown tokens command: ${tokensCmd}` : 'A tokens command is required');
|
|
675
|
+
console.error('');
|
|
676
|
+
console.error(generateCommandHelp('tokens'));
|
|
677
|
+
return process.exit(1);
|
|
605
678
|
}
|
|
606
679
|
}
|
|
607
680
|
break;
|
|
@@ -703,10 +776,17 @@ function run() {
|
|
|
703
776
|
}
|
|
704
777
|
break;
|
|
705
778
|
|
|
706
|
-
|
|
779
|
+
case '':
|
|
707
780
|
// run normally
|
|
708
781
|
require('../server');
|
|
709
782
|
break;
|
|
783
|
+
|
|
784
|
+
default:
|
|
785
|
+
// A mistyped command used to start the server instead
|
|
786
|
+
console.error(`Unknown command: ${cmd}`);
|
|
787
|
+
console.error('');
|
|
788
|
+
console.error('Run "emailengine help" to see available commands.');
|
|
789
|
+
return process.exit(1);
|
|
710
790
|
}
|
|
711
791
|
}
|
|
712
792
|
|
package/config/default.toml
CHANGED
|
@@ -46,11 +46,6 @@ proxy = false # Set to true if using HAProxy with send-proxy option
|
|
|
46
46
|
#maxMessageSize = "25M" # maximum message size accepted by SMTP server (default: 25MB)
|
|
47
47
|
#maxClients = 100 # concurrent SMTP server connections; excess connections are refused with a 421 (default: 100)
|
|
48
48
|
|
|
49
|
-
[documentStore]
|
|
50
|
-
# Deprecated Document Store (ElasticSearch) feature. Disabled by default; the worker and
|
|
51
|
-
# all document-store API/UI endpoints are only available when this is enabled.
|
|
52
|
-
enabled = false
|
|
53
|
-
|
|
54
49
|
[mcp]
|
|
55
50
|
# MCP (Model Context Protocol) endpoint at /mcp. This deployment-level gate controls whether
|
|
56
51
|
# the endpoint exists in the route table at all; the runtime on/off switch is the mcpEnabled
|
package/config/test.toml
CHANGED
package/encrypt.js
CHANGED
|
@@ -13,8 +13,10 @@ try {
|
|
|
13
13
|
|
|
14
14
|
const { redis } = require('./lib/db');
|
|
15
15
|
const config = require('@zone-eu/wild-config');
|
|
16
|
-
const {
|
|
16
|
+
const { reencrypt } = require('./lib/encrypt');
|
|
17
17
|
const { encryptedKeys } = require('./lib/settings');
|
|
18
|
+
const { ENCRYPTED_ACCOUNT_FIELDS } = require('./lib/account');
|
|
19
|
+
const { ENCRYPTED_ROUTE_FIELDS } = require('./lib/webhooks');
|
|
18
20
|
const getSecret = require('./lib/get-secret');
|
|
19
21
|
const msgpack = require('./lib/msgpack');
|
|
20
22
|
|
|
@@ -24,47 +26,7 @@ const { TLS_KEY } = require('./lib/tls/store');
|
|
|
24
26
|
|
|
25
27
|
const DECRYPT_PASSWORDS = [].concat(config.decrypt || []);
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
let lastErr = false;
|
|
29
|
-
let decrypted = value;
|
|
30
|
-
|
|
31
|
-
for (let password of DECRYPT_PASSWORDS) {
|
|
32
|
-
try {
|
|
33
|
-
decrypted = decrypt(value, password);
|
|
34
|
-
if (password === encryptSecret) {
|
|
35
|
-
// nothing was changed
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
break;
|
|
39
|
-
} catch (err) {
|
|
40
|
-
lastErr = err;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let parsed = parseEncryptedData(decrypted);
|
|
45
|
-
if (parsed.format !== 'cleartext') {
|
|
46
|
-
// was not able to decrypt
|
|
47
|
-
if (encryptSecret) {
|
|
48
|
-
try {
|
|
49
|
-
decrypted = decrypt(value, encryptSecret);
|
|
50
|
-
// did not throw, so the value is already encrypted with the new password
|
|
51
|
-
return value;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
// ignore
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
throw lastErr || new Error('Could not decrypt encrypted password');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (encryptSecret) {
|
|
61
|
-
// encrypt
|
|
62
|
-
return encrypt(decrypted, encryptSecret);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// return plaintext
|
|
66
|
-
return decrypted;
|
|
67
|
-
}
|
|
29
|
+
const processSecret = (value, encryptSecret) => reencrypt(value, DECRYPT_PASSWORDS, encryptSecret);
|
|
68
30
|
|
|
69
31
|
async function main() {
|
|
70
32
|
console.error('EmailEngine account encryption tool');
|
|
@@ -163,6 +125,23 @@ async function main() {
|
|
|
163
125
|
}
|
|
164
126
|
}
|
|
165
127
|
|
|
128
|
+
// The credential-bearing fields stored as plain strings (webhooksCustomHeaders is its JSON
|
|
129
|
+
// encoding); '' is a cleared marker and stays as it is
|
|
130
|
+
for (let key of ENCRYPTED_ACCOUNT_FIELDS) {
|
|
131
|
+
if (!accountData[key] || typeof accountData[key] !== 'string') {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
let value = await processSecret(accountData[key], encryptSecret);
|
|
136
|
+
if (value !== accountData[key]) {
|
|
137
|
+
updates[key] = value;
|
|
138
|
+
updated = true;
|
|
139
|
+
}
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(`Could not process "${key}" for ${account}. Check decryption secrets.`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
166
145
|
if (updated) {
|
|
167
146
|
let result = await redis.hmset(`${REDIS_PREFIX}iad:${account}`, updates);
|
|
168
147
|
if (result === 'OK') {
|
|
@@ -249,6 +228,55 @@ async function main() {
|
|
|
249
228
|
|
|
250
229
|
console.log(`Updated ${updatedApps}/${apps.length} OAuth2 apps`);
|
|
251
230
|
|
|
231
|
+
// Custom webhook routes: the target URL and the custom header list inside each route's msgpack
|
|
232
|
+
// meta entry. A route written before these were encrypted holds the headers as an array, which
|
|
233
|
+
// is converted to the JSON string form lib/webhooks.js stores.
|
|
234
|
+
let updatedRoutes = 0;
|
|
235
|
+
let routes = await redis.smembers(`${REDIS_PREFIX}wh:i`);
|
|
236
|
+
for (let route of routes) {
|
|
237
|
+
let metaBuf = await redis.hgetBuffer(`${REDIS_PREFIX}wh:c`, `${route}:meta`);
|
|
238
|
+
if (!metaBuf) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let meta;
|
|
243
|
+
try {
|
|
244
|
+
meta = msgpack.decode(metaBuf);
|
|
245
|
+
} catch (err) {
|
|
246
|
+
console.log(`Webhook route ${route}: failed to parse`);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
let routeUpdated = false;
|
|
252
|
+
for (let key of ENCRYPTED_ROUTE_FIELDS) {
|
|
253
|
+
let stored = Array.isArray(meta[key]) ? JSON.stringify(meta[key]) : meta[key];
|
|
254
|
+
if (!stored || typeof stored !== 'string') {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
let value = await processSecret(stored, encryptSecret);
|
|
258
|
+
if (value !== meta[key]) {
|
|
259
|
+
meta[key] = value;
|
|
260
|
+
routeUpdated = true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (routeUpdated) {
|
|
265
|
+
let result = await redis.hmset(`${REDIS_PREFIX}wh:c`, { [`${route}:meta`]: msgpack.encode(meta) });
|
|
266
|
+
if (result === 'OK') {
|
|
267
|
+
console.log(`Webhook route ${route}: updated`);
|
|
268
|
+
} else {
|
|
269
|
+
console.log(`Webhook route ${route}: Unexpected response from DB: ${result}`);
|
|
270
|
+
}
|
|
271
|
+
updatedRoutes++;
|
|
272
|
+
}
|
|
273
|
+
} catch (err) {
|
|
274
|
+
console.error(`Could not process encrypted values for webhook route ${route}. Check decryption secrets.`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
console.log(`Updated ${updatedRoutes}/${routes.length} webhook routes`);
|
|
279
|
+
|
|
252
280
|
// TLS private keys managed by @postalsys/certs. These live in the module's own hash, not in the
|
|
253
281
|
// EmailEngine settings hash, so they need their own pass - without it a rotation leaves the ACME
|
|
254
282
|
// account key and every domain key readable only with the old secret, and TLS fails on the next
|
package/getswagger.sh
CHANGED
|
@@ -4,10 +4,6 @@ set -e
|
|
|
4
4
|
|
|
5
5
|
export EENGINE_PORT=5678
|
|
6
6
|
|
|
7
|
-
# Keep the deprecated Document Store endpoints in the generated spec; they are only
|
|
8
|
-
# registered when the feature is enabled.
|
|
9
|
-
export EENGINE_DOCUMENT_STORE_ENABLED=true
|
|
10
|
-
|
|
11
7
|
# refuse to run if something is already listening on the port, otherwise the
|
|
12
8
|
# polling loop below would silently fetch swagger.json from a stale instance
|
|
13
9
|
if (exec 3<>"/dev/tcp/127.0.0.1/${EENGINE_PORT}") 2>/dev/null; then
|