emailengine-app 2.79.8 → 2.80.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/.github/dependabot.yml +22 -0
- package/.github/workflows/test.yml +39 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +69 -0
- package/DOCKER_DEPLOYMENT.md +6 -7
- package/Dockerfile +35 -11
- package/config/default.toml +7 -2
- package/copy-static-files.sh +23 -5
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +43 -0
- package/lib/account/account-state.js +62 -0
- package/lib/account.js +60 -3
- package/lib/api-routes/account-routes.js +20 -0
- package/lib/api-routes/bull-board-routes.js +3 -2
- package/lib/api-routes/index.js +1 -1
- package/lib/api-routes/route-helpers.js +8 -0
- package/lib/api-routes/settings-routes.js +17 -2
- package/lib/auth-token.js +73 -2
- package/lib/autodetect-imap-settings.js +379 -69
- package/lib/cert-handler.js +62 -0
- package/lib/consts.js +58 -7
- package/lib/db.js +12 -0
- package/lib/egress-fetch.js +145 -0
- package/lib/email-client/base-client.js +234 -66
- package/lib/email-client/credential-errors.js +118 -0
- package/lib/email-client/gmail/gmail-api.js +2 -1
- package/lib/email-client/gmail-client.js +70 -64
- package/lib/email-client/imap/connection-errors.js +52 -0
- package/lib/email-client/imap/listing-diff.js +47 -6
- package/lib/email-client/imap/mailbox.js +457 -379
- package/lib/email-client/imap/subconnection.js +15 -11
- package/lib/email-client/imap/sync-operations.js +46 -59
- package/lib/email-client/imap-client.js +136 -95
- package/lib/email-client/message-builder.js +11 -11
- package/lib/email-client/outlook/graph-api.js +2 -1
- package/lib/email-client/outlook-client.js +219 -106
- package/lib/export.js +35 -2
- package/lib/handlebars-helpers.js +129 -0
- package/lib/imap-proxy-auth.js +96 -21
- package/lib/imapproxy/imap-core/README.md +1 -0
- package/lib/imapproxy/imap-core/lib/tls-options.js +5 -46
- package/lib/imapproxy/imap-server.js +56 -66
- package/lib/lua/h-del-if-equals.lua +39 -0
- package/lib/lua/h-set-if-equals.lua +39 -0
- package/lib/openapi/index.js +3 -0
- package/lib/outbox.js +28 -3
- package/lib/rate-limit.js +23 -4
- package/lib/routes-ui.js +4 -34
- package/lib/schemas.js +42 -3
- package/lib/security-headers.js +411 -0
- package/lib/sentry.js +36 -4
- package/lib/smtp-auth.js +86 -7
- package/lib/tls/context.js +376 -0
- package/lib/tls/der.js +223 -0
- package/lib/tls/provision.js +555 -0
- package/lib/tls/self-signed.js +282 -0
- package/lib/tls/status.js +431 -0
- package/lib/tls/store.js +666 -0
- package/lib/tools.js +337 -147
- package/lib/ui-routes/account-routes.js +47 -33
- package/lib/ui-routes/admin-config-routes.js +22 -1
- package/lib/ui-routes/auth-routes.js +16 -1
- package/lib/ui-routes/export-routes.js +4 -0
- package/lib/ui-routes/internals-routes.js +3 -5
- package/lib/ui-routes/mcp-consent-routes.js +7 -0
- package/lib/ui-routes/network-config-routes.js +58 -48
- package/lib/ui-routes/route-helpers.js +24 -8
- package/lib/ui-routes/smtp-test-routes.js +7 -0
- package/lib/ui-routes/tls-config-routes.js +581 -0
- package/lib/utils/mailbox-path.js +51 -0
- package/lib/utils/severity.js +31 -0
- package/lib/webhook-egress.js +5 -0
- package/package.json +21 -24
- package/sbom.json +1 -1
- package/server.js +53 -36
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +11 -0
- package/static/js/ace/css/ace.css +1462 -0
- package/static/js/ace/css/kuroir-1.png +0 -0
- package/static/js/ace/css/kuroir-2.png +0 -0
- package/static/js/ace/css/main-1.png +0 -0
- package/static/js/ace/css/main-10.svg +4 -0
- package/static/js/ace/css/main-11.svg +5 -0
- package/static/js/ace/css/main-12.svg +4 -0
- package/static/js/ace/css/main-13.png +0 -0
- package/static/js/ace/css/main-14.png +0 -0
- package/static/js/ace/css/main-15.png +0 -0
- package/static/js/ace/css/main-16.png +0 -0
- package/static/js/ace/css/main-17.png +0 -0
- package/static/js/ace/css/main-18.png +0 -0
- package/static/js/ace/css/main-19.png +0 -0
- package/static/js/ace/css/main-2.png +0 -0
- package/static/js/ace/css/main-20.png +0 -0
- package/static/js/ace/css/main-21.png +0 -0
- package/static/js/ace/css/main-22.png +0 -0
- package/static/js/ace/css/main-23.png +0 -0
- package/static/js/ace/css/main-24.png +0 -0
- package/static/js/ace/css/main-25.svg +1 -0
- package/static/js/ace/css/main-26.png +0 -0
- package/static/js/ace/css/main-3.png +0 -0
- package/static/js/ace/css/main-4.png +0 -0
- package/static/js/ace/css/main-5.svg +7 -0
- package/static/js/ace/css/main-6.svg +9 -0
- package/static/js/ace/css/main-7.svg +7 -0
- package/static/js/ace/css/main-8.svg +9 -0
- package/static/js/ace/css/main-9.svg +6 -0
- package/static/js/ace/css/theme/kuroir.css +78 -0
- package/static/js/ace/css/theme/tomorrow_night.css +128 -0
- package/static/js/ace/css/theme/tomorrow_night_eighties.css +128 -0
- package/static/js/ace/css/theme/xcode.css +106 -0
- package/static/js/ace/css/tomorrow_night-1.png +0 -0
- package/static/js/ace/css/tomorrow_night-2.png +0 -0
- package/static/js/ace/css/tomorrow_night_eighties-1.png +0 -0
- package/static/js/ace/css/tomorrow_night_eighties-2.png +0 -0
- package/static/js/ace/css/xcode-1.png +0 -0
- package/static/js/ace/css/xcode-2.png +0 -0
- package/static/js/app.js +34 -0
- package/static/js/ee-client.js +256 -102
- package/static/js/public.js +13 -2
- package/static/js/ui.js +40 -25
- package/static/licenses.html +393 -1282
- package/static/vendor/simplewebauthn/browser.min.js +2 -2
- package/translations/messages.pot +203 -157
- package/views/account/login-redirect.hbs +22 -0
- package/views/accounts/account.hbs +15 -37
- package/views/accounts/browse.hbs +3 -1
- package/views/accounts/edit.hbs +1 -1
- package/views/accounts/register/imap-server.hbs +1 -1
- package/views/config/ai.hbs +1 -1
- package/views/config/branding.hbs +2 -2
- package/views/config/document-store/chat.hbs +1 -1
- package/views/config/document-store/index.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -4
- package/views/config/license.hbs +1 -1
- package/views/config/mcp.hbs +1 -1
- package/views/config/network.hbs +14 -16
- package/views/config/oauth/app.hbs +2 -2
- package/views/config/service.hbs +1 -1
- package/views/config/smtp.hbs +1 -4
- package/views/config/tls-upload.hbs +81 -0
- package/views/config/tls.hbs +492 -0
- package/views/config/webhooks.hbs +2 -2
- package/views/error.hbs +4 -2
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +3 -11
- package/views/mcp/authorize.hbs +1 -1
- package/views/partials/ace_assets.hbs +13 -0
- package/views/partials/add_account_modal.hbs +1 -1
- package/views/partials/address_list.hbs +4 -4
- package/views/partials/filter_editor_js.hbs +2 -2
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/oauth_form.hbs +1 -1
- package/views/partials/public_theme_init.hbs +1 -1
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/template_form.hbs +2 -2
- package/views/partials/test_send.hbs +7 -4
- package/views/partials/theme_init.hbs +1 -1
- package/views/partials/tls_security_card.hbs +25 -53
- package/views/partials/ui/alert-banner.hbs +3 -2
- package/views/partials/ui/badge.hbs +6 -2
- package/views/partials/ui/btn.hbs +5 -2
- package/views/partials/ui/details.hbs +2 -2
- package/views/partials/webhooks_editor_functions.hbs +1 -1
- package/views/reference/redirect.hbs +1 -1
- package/views/templates/template.hbs +2 -2
- package/views/tokens/new.hbs +1 -1
- package/views/unsubscribe.hbs +1 -1
- package/views/webhooks/webhook.hbs +2 -2
- package/workers/api.js +131 -242
- package/workers/export.js +1 -5
- package/workers/imap-proxy.js +4 -1
- package/workers/imap.js +1 -3
- package/workers/smtp.js +59 -83
- package/workers/submit.js +6 -12
- package/workers/webhooks.js +6 -17
- package/static/front/EmailEngine_logo_horiz.png +0 -0
- package/static/front/EmailEngine_logo_vert.png +0 -0
- package/static/front/index.html +0 -57
- package/static/front/logo.png +0 -0
- package/static/vendor/handlebars/handlebars.min-v4.7.9.js +0 -29
- package/views/partials/tls_security_js.hbs +0 -64
- package/views/partials/tls_security_modal.hbs +0 -22
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
updates:
|
|
4
|
+
# The Node base image is the one dependency that goes stale without any diff to review, which is
|
|
5
|
+
# how it ended up 19 months behind. This entry exists to keep the digest current, nothing else.
|
|
6
|
+
- package-ecosystem: docker
|
|
7
|
+
directory: /
|
|
8
|
+
schedule:
|
|
9
|
+
interval: weekly
|
|
10
|
+
commit-message:
|
|
11
|
+
# `fix:` rather than `chore:`, so a base image bump reaches users through the release notes
|
|
12
|
+
# instead of being filtered out of them
|
|
13
|
+
prefix: fix
|
|
14
|
+
# Digest updates only. The Node major is a deliberate choice that has to stay in step with the
|
|
15
|
+
# CI matrix, the pkg targets and the deploy workflow, and it tracks Active LTS rather than
|
|
16
|
+
# Current - left unignored, the first run proposed 24-alpine to 26-alpine, which is exactly the
|
|
17
|
+
# drift this entry is meant to prevent. Moving the major is a manual decision.
|
|
18
|
+
ignore:
|
|
19
|
+
- dependency-name: node
|
|
20
|
+
update-types:
|
|
21
|
+
- version-update:semver-major
|
|
22
|
+
- version-update:semver-minor
|
|
@@ -135,6 +135,45 @@ jobs:
|
|
|
135
135
|
#
|
|
136
136
|
# One target, unsigned, uncompressed. Signing and notarization need Apple credentials and
|
|
137
137
|
# stay on the release machine; neither has any bearing on whether the bundle can be built.
|
|
138
|
+
# The image ships an OS and a Node runtime we do not build, so its vulnerabilities arrive on
|
|
139
|
+
# someone else's schedule rather than in a diff. Nothing watched that before, and the base pin
|
|
140
|
+
# sat unmoved for 19 months while 21 Alpine CVEs accumulated behind it.
|
|
141
|
+
#
|
|
142
|
+
# Scoped to fixed HIGH/CRITICAL on purpose. An unfixed upstream CVE is not actionable here and
|
|
143
|
+
# would block unrelated work at random; once a fix exists, a rebuild picks it up through
|
|
144
|
+
# `apk upgrade`, or the base pin needs moving - both of which are on us.
|
|
145
|
+
docker_scan:
|
|
146
|
+
name: Docker Image Scan
|
|
147
|
+
if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
|
|
148
|
+
runs-on: ubuntu-24.04
|
|
149
|
+
timeout-minutes: 20
|
|
150
|
+
steps:
|
|
151
|
+
- uses: actions/checkout@v6
|
|
152
|
+
|
|
153
|
+
# Single arch: the findings are properties of the base image and the lockfile, neither of
|
|
154
|
+
# which differs per architecture, so scanning both legs would only double the runtime.
|
|
155
|
+
- name: Build the image
|
|
156
|
+
uses: docker/build-push-action@v7
|
|
157
|
+
with:
|
|
158
|
+
context: .
|
|
159
|
+
platforms: linux/amd64
|
|
160
|
+
load: true
|
|
161
|
+
tags: emailengine:scan
|
|
162
|
+
|
|
163
|
+
- name: Scan for known vulnerabilities
|
|
164
|
+
uses: aquasecurity/trivy-action@v0.36.0
|
|
165
|
+
with:
|
|
166
|
+
image-ref: emailengine:scan
|
|
167
|
+
scanners: vuln
|
|
168
|
+
severity: HIGH,CRITICAL
|
|
169
|
+
ignore-unfixed: true
|
|
170
|
+
exit-code: '1'
|
|
171
|
+
format: table
|
|
172
|
+
env:
|
|
173
|
+
# Trivy pulls its database from ghcr.io and is rate limited unauthenticated
|
|
174
|
+
TRIVY_USERNAME: ${{ github.actor }}
|
|
175
|
+
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
|
176
|
+
|
|
138
177
|
pkg_build:
|
|
139
178
|
name: Binary Build (linux-x64, unsigned)
|
|
140
179
|
if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.80.0](https://github.com/postalsys/emailengine/compare/v2.79.9...v2.80.0) (2026-09-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **tls:** manage certificates on their own page, with a real self-signed fallback ([42a1546](https://github.com/postalsys/emailengine/commit/42a154616fdb63b7c3c38de89cffd73110a45526))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **accounts:** keep the authentication server's status out of API and IMAP proxy answers ([79264b0](https://github.com/postalsys/emailengine/commit/79264b0ce471b0dcbc6764e7b1b51b637d2b49f7))
|
|
14
|
+
* **accounts:** stop a credential-service blip from flooding auth webhooks ([51f4f35](https://github.com/postalsys/emailengine/commit/51f4f35c95b6527a9c93ef30eda8b55c629369fc))
|
|
15
|
+
* **admin:** let the account page re-authenticate an OAuth2 account again ([56245f7](https://github.com/postalsys/emailengine/commit/56245f7224eaa998143773a6847d83a9cb39b108))
|
|
16
|
+
* **admin:** stop forced SSO from silently swallowing admin form submissions ([9653c2d](https://github.com/postalsys/emailengine/commit/9653c2db2c1ed6ef0557396b673b2b8a32c94af0))
|
|
17
|
+
* **api:** reload the TLS listeners only when a settings write changed a value ([b2052ac](https://github.com/postalsys/emailengine/commit/b2052acb52cec2063b66af00dab94246edcfffeb))
|
|
18
|
+
* **autodiscovery:** keep a usable server entry when a hostless sibling follows it ([3796668](https://github.com/postalsys/emailengine/commit/37966686762ce7435314e8da25d7ba26add42c6f))
|
|
19
|
+
* **autodiscovery:** make Exchange autodiscovery work at all ([271d85c](https://github.com/postalsys/emailengine/commit/271d85c76349c5ee7259dd18da9d4a132caee0c1))
|
|
20
|
+
* **autodiscovery:** stop a result that names no server from ending a lookup ([e698c3c](https://github.com/postalsys/emailengine/commit/e698c3c2737f464e1d10be2099fb18a8640c7708))
|
|
21
|
+
* **deps:** update @bull-board/api and @bull-board/hapi to 9.9.0 ([14720fb](https://github.com/postalsys/emailengine/commit/14720fbd84a58d405119f865715a672f9b319091))
|
|
22
|
+
* **deps:** update @postalsys/certs to 1.2.1 ([eb2c958](https://github.com/postalsys/emailengine/commit/eb2c9580e2437a317eeea8742ddf9af5c88434e5))
|
|
23
|
+
* **deps:** update @postalsys/certs to 1.3.0 ([08c2d1b](https://github.com/postalsys/emailengine/commit/08c2d1b27ed4aa13bb8130a611dfa73ab164d82b))
|
|
24
|
+
* **gmail:** clear a stale watch failure once push is no longer configured ([b5884fe](https://github.com/postalsys/emailengine/commit/b5884fe886260cb6578db91a7425a37be7261f34))
|
|
25
|
+
* **gmail:** report no watch for an account whose application has no Pub/Sub app ([7e53a20](https://github.com/postalsys/emailengine/commit/7e53a20c45017e8a6484910507ecfd72c0ef75c6))
|
|
26
|
+
* **gmail:** stop a dead Pub/Sub watch from being invisible and self-perpetuating ([206e17d](https://github.com/postalsys/emailengine/commit/206e17da9c74ce10146df51ba40db7dab94aa273))
|
|
27
|
+
* **imap:** announce a folder that appeared while the primary was down ([2afd207](https://github.com/postalsys/emailengine/commit/2afd2070d69e6bb3b791a06a8a14b40ea0696641))
|
|
28
|
+
* **imap:** announce the deletion of a tracked folder missing from the stored listing ([2ead02f](https://github.com/postalsys/emailengine/commit/2ead02f858ac3472f1e86a2984d6fdaf0163a33f))
|
|
29
|
+
* **imap:** answer a malformed message identifier instead of throwing at it ([9be0c9c](https://github.com/postalsys/emailengine/commit/9be0c9ca12a2e7c960b25eb971e405756a766ab6))
|
|
30
|
+
* **imap:** collect the connection-closed error and the attachment download ([8d0e589](https://github.com/postalsys/emailengine/commit/8d0e58946b47054aaac626ec72b0a59ad0f0682a))
|
|
31
|
+
* **imap:** keep a folder found by a pass that could not register it ([0971a4d](https://github.com/postalsys/emailengine/commit/0971a4dee15c7d10dc31f02b5e01e67bb8192e3d))
|
|
32
|
+
* **imap:** match configured folder paths against the spelling the server reports ([328e56a](https://github.com/postalsys/emailengine/commit/328e56a3684530b94b056abbf25d7881417cd470))
|
|
33
|
+
* **imap:** restore the first-sync backfill and the return to the main mailbox ([b0b229c](https://github.com/postalsys/emailengine/commit/b0b229c12f41a0a8313462bafc638e22020673f0))
|
|
34
|
+
* **imap:** stop a disconnect mid-sync from announcing a message without its images ([fab2c15](https://github.com/postalsys/emailengine/commit/fab2c1560a1782e708967afb8bf916bd5e634574))
|
|
35
|
+
* **imap:** stop a read-only folder listing from swallowing the mailboxNew event ([ab76f0d](https://github.com/postalsys/emailengine/commit/ab76f0ddc77bbcc321d1cb207695a2d4e145ecba))
|
|
36
|
+
* **imap:** stop the duplicate mailboxDeleted and the dropped inbox counters ([edd0b0c](https://github.com/postalsys/emailengine/commit/edd0b0cf9e7d2073ab7623bcd6e7fe60bf5dc4c1))
|
|
37
|
+
* **outlook:** keep retrying a subscription the fast retries gave up on ([9583780](https://github.com/postalsys/emailengine/commit/9583780427310e9acdbdbf8351edfc7d5e97bf3d))
|
|
38
|
+
* **outlook:** report an account that can no longer subscribe to changes ([9da07ad](https://github.com/postalsys/emailengine/commit/9da07adc5f9b21aab827f609c6ae1cb98120cdbe))
|
|
39
|
+
* **outlook:** stop a subscription recovery from dropping a newer failure ([bd613fe](https://github.com/postalsys/emailengine/commit/bd613fe829bfa0dd51875752d584947ed623956f))
|
|
40
|
+
* **outlook:** take a subscription report back when the subscription is healthy, keep it across a login ([9bccba8](https://github.com/postalsys/emailengine/commit/9bccba8537c3da969588a0b720b8f5fa2413b3d5))
|
|
41
|
+
* **tls:** let an operator point ACME at a different CA without editing source ([13b382f](https://github.com/postalsys/emailengine/commit/13b382f6e501a3ec34985b3dd3f0c4c542d8716f))
|
|
42
|
+
* **tls:** order a first certificate only for a listener that would serve it ([950185f](https://github.com/postalsys/emailengine/commit/950185fbaed09f050020f136d6673f4e4cf83fc8))
|
|
43
|
+
* **tls:** read the failed renewal from the certificate library instead of inferring it ([c0e4bfd](https://github.com/postalsys/emailengine/commit/c0e4bfd167b3783dcb9d25db9b83a15208779d53))
|
|
44
|
+
* **tls:** redesign the certificates page around what each listener serves ([7dc42ba](https://github.com/postalsys/emailengine/commit/7dc42ba524f91310a36d991d7535e8a0837d6537))
|
|
45
|
+
* **tls:** replace the abandoned ACME stack and ask the CA when to renew ([9364eeb](https://github.com/postalsys/emailengine/commit/9364eebb30921675f3b3f95a03de66504e9ef342))
|
|
46
|
+
* **tls:** report a failed renewal, converge concurrent self-signed replacement ([b1ac9e3](https://github.com/postalsys/emailengine/commit/b1ac9e3102827036a717de695f5c24697f51c5b3))
|
|
47
|
+
* **tls:** report a half-set ACME override, drop the unused listener restart ([fe7771e](https://github.com/postalsys/emailengine/commit/fe7771eb38e2d8cdfb62353d1375d0b52df90eac))
|
|
48
|
+
* **tls:** say plainly that the API listener serves HTTP by default ([31e75ae](https://github.com/postalsys/emailengine/commit/31e75ae8f0a124890b6727e733cdaa17ddda5ec4))
|
|
49
|
+
* **tls:** serve an encrypted operator key, keep the listener settings on reload ([75d16d9](https://github.com/postalsys/emailengine/commit/75d16d93527606708cf0b19ba89288f54382b4e6))
|
|
50
|
+
* **tls:** stop a repeated request from starting a second order, report the listener's own state ([845d4e7](https://github.com/postalsys/emailengine/commit/845d4e7729ff05c8e042607c4639b2c808f88d10))
|
|
51
|
+
|
|
52
|
+
## [2.79.9](https://github.com/postalsys/emailengine/compare/v2.79.8...v2.79.9) (2026-09-07)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Bug Fixes
|
|
56
|
+
|
|
57
|
+
* **admin-ui:** remove the unreferenced static landing page ([eea5024](https://github.com/postalsys/emailengine/commit/eea5024e701d9633d1d19e14fc16f9512b73327f))
|
|
58
|
+
* **admin-ui:** render the delivery-test and address-list fragments server-side ([4443c32](https://github.com/postalsys/emailengine/commit/4443c3211c76548ac00041752b22ce52b4e6f479))
|
|
59
|
+
* **deps:** collapse the duplicate nodemailer copies onto version 10 ([661a2ed](https://github.com/postalsys/emailengine/commit/661a2ed29325e775ecdbd86861428e1bf26c45a4))
|
|
60
|
+
* **deps:** update dependencies ([2f32929](https://github.com/postalsys/emailengine/commit/2f32929fe2624a393516701aad48b41a13b78c8e))
|
|
61
|
+
* **deps:** update dependencies and collapse the duplicate nodemailer copies ([09553a3](https://github.com/postalsys/emailengine/commit/09553a35817b3da040eca8fa3795ed5b9dcf470a))
|
|
62
|
+
* **deps:** update dependencies and drop the message browser stylesheet exception ([1933e5d](https://github.com/postalsys/emailengine/commit/1933e5d9952fab26fbd3f4a630adfc0ca341717a))
|
|
63
|
+
* **deps:** update dependencies, picking up the dispatcher options of certs and email-ai-tools ([28ecf49](https://github.com/postalsys/emailengine/commit/28ecf499362d02bcfb7c7811e12757093e856667))
|
|
64
|
+
* **docker:** move the image to Node 24 and drop npm from the runtime layer ([ad190d3](https://github.com/postalsys/emailengine/commit/ad190d34972004216a612d25f32403054bd5639e))
|
|
65
|
+
* **proxy:** route every outbound HTTP request through the global proxy ([2ac1fb6](https://github.com/postalsys/emailengine/commit/2ac1fb65bb2db9143747cb160e4c3dc5e8b89086))
|
|
66
|
+
* refuse to start below Node 20, the floor package.json declares ([1bf24eb](https://github.com/postalsys/emailengine/commit/1bf24eb5988164236ced87f64a528b12ac9af9f3))
|
|
67
|
+
* **security:** require a nonce on stylesheets and tag the machine-facing routes ([cbcd4cb](https://github.com/postalsys/emailengine/commit/cbcd4cb16896aac91bce0c58feb112d809828cd5))
|
|
68
|
+
* **security:** send a nonce-based Content-Security-Policy and the remaining security headers ([4f2900e](https://github.com/postalsys/emailengine/commit/4f2900e5de6d6aeac2333d774ea3977793f99e22))
|
|
69
|
+
* **security:** vet autodiscovery egress, throttle proxy logins and add response headers ([74856cf](https://github.com/postalsys/emailengine/commit/74856cf64a0231ee7e38bbfb140639e29632aaa9))
|
|
70
|
+
* **submit:** drop an outbox entry that does not decode to a message ([e7e6618](https://github.com/postalsys/emailengine/commit/e7e6618ec31032c3d88c2bec3f89ffa70c13970d))
|
|
71
|
+
|
|
3
72
|
## [2.79.8](https://github.com/postalsys/emailengine/compare/v2.79.7...v2.79.8) (2026-09-02)
|
|
4
73
|
|
|
5
74
|
|
package/DOCKER_DEPLOYMENT.md
CHANGED
|
@@ -137,10 +137,10 @@ server {
|
|
|
137
137
|
ssl_certificate_key /path/to/privkey.pem;
|
|
138
138
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
139
139
|
|
|
140
|
-
# Security
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
# EmailEngine sends its own security headers (Content-Security-Policy, X-Frame-Options,
|
|
141
|
+
# X-Content-Type-Options, Referrer-Policy, Permissions-Policy), and Strict-Transport-Security
|
|
142
|
+
# once the service URL setting is https. Do not add them here as well: a second copy of a
|
|
143
|
+
# header is at best redundant and, for Content-Security-Policy, the two are both enforced.
|
|
144
144
|
|
|
145
145
|
location / {
|
|
146
146
|
proxy_pass http://127.0.0.1:3000;
|
|
@@ -177,12 +177,11 @@ server {
|
|
|
177
177
|
```caddyfile
|
|
178
178
|
emailengine.example.com {
|
|
179
179
|
reverse_proxy localhost:3000
|
|
180
|
-
header Strict-Transport-Security "max-age=31536000"
|
|
181
|
-
header X-Frame-Options "SAMEORIGIN"
|
|
182
|
-
header X-Content-Type-Options "nosniff"
|
|
183
180
|
}
|
|
184
181
|
```
|
|
185
182
|
|
|
183
|
+
EmailEngine sets the security headers itself (see the note in the Nginx example), so the Caddyfile needs no `header` lines.
|
|
184
|
+
|
|
186
185
|
### Step 3: Firewall Configuration
|
|
187
186
|
|
|
188
187
|
```bash
|
package/Dockerfile
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Pinned by tag AND digest: the digest is what actually gets pulled, so a rebuild of an old commit
|
|
2
|
+
# resolves the same Node layer, and the tag next to it keeps the line readable and lets Dependabot
|
|
3
|
+
# parse it (it does not follow an ARG-defined image). Both stages must stay on the same pin.
|
|
4
|
+
#
|
|
5
|
+
# The pin has to be moved deliberately - it sat on node:22.13.1-alpine for 19 months, which is how
|
|
6
|
+
# the image ended up shipping 21 unpatched Alpine CVEs. `apk upgrade` below covers the drift between
|
|
7
|
+
# pin bumps, and the docker_scan job in .github/workflows/test.yml fails the build once a fix for a
|
|
8
|
+
# HIGH/CRITICAL exists but is not picked up.
|
|
9
|
+
|
|
10
|
+
# Build stage. Everything that needs a package manager, a shell or a writable source tree happens
|
|
11
|
+
# here; the runtime stage below copies out only the finished tree, so npm and its dependencies never
|
|
12
|
+
# reach the published image. npm accounted for 38 of the 59 HIGH/CRITICAL findings in the old image
|
|
13
|
+
# (a vendored tar, pacote, sigstore, minimatch) and nothing at runtime ever invokes it.
|
|
14
|
+
FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS builder
|
|
3
15
|
|
|
4
16
|
ARG BUILDPLATFORM
|
|
5
17
|
ARG TARGETPLATFORM
|
|
@@ -12,11 +24,6 @@ RUN printf "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \
|
|
|
12
24
|
&& printf "With uname -s : " && uname -s \
|
|
13
25
|
&& printf "and uname -m : " && uname -mm
|
|
14
26
|
|
|
15
|
-
RUN apk add --no-cache dumb-init
|
|
16
|
-
|
|
17
|
-
# Create a non-root user and group
|
|
18
|
-
RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegroup
|
|
19
|
-
|
|
20
27
|
WORKDIR /emailengine
|
|
21
28
|
|
|
22
29
|
# Install dependencies before copying any source. npm ci is by far the slowest step in this
|
|
@@ -51,12 +58,29 @@ COPY server.js server.js
|
|
|
51
58
|
RUN mkdir -p .git/refs/heads
|
|
52
59
|
COPY .git/refs/heads/master .git/refs/heads/master
|
|
53
60
|
|
|
61
|
+
# version-info.json is generated here and the inputs are dropped again, so neither the git ref nor
|
|
62
|
+
# the script itself ends up in the runtime image.
|
|
54
63
|
COPY update-info.sh update-info.sh
|
|
55
|
-
RUN chmod +x ./update-info.sh
|
|
56
|
-
|
|
64
|
+
RUN chmod +x ./update-info.sh \
|
|
65
|
+
&& ./update-info.sh \
|
|
66
|
+
&& rm -rf .git update-info.sh
|
|
67
|
+
|
|
68
|
+
# Runtime stage.
|
|
69
|
+
FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf
|
|
70
|
+
|
|
71
|
+
# `apk upgrade` patches the Alpine packages that the base image itself lags on - at the time of
|
|
72
|
+
# writing node:24-alpine still carries an openssl below 3.5.8-r0. dumb-init reaps zombies as PID 1.
|
|
73
|
+
# npm is removed outright: it is a build-time tool, and leaving it in only adds scan surface.
|
|
74
|
+
RUN apk add --no-cache dumb-init \
|
|
75
|
+
&& apk upgrade --no-cache \
|
|
76
|
+
&& rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx
|
|
77
|
+
|
|
78
|
+
# Create a non-root user and group
|
|
79
|
+
RUN addgroup -S emailenginegroup && adduser -S emailengineuser -G emailenginegroup
|
|
80
|
+
|
|
81
|
+
WORKDIR /emailengine
|
|
57
82
|
|
|
58
|
-
|
|
59
|
-
RUN chown -R emailengineuser:emailenginegroup /emailengine
|
|
83
|
+
COPY --from=builder --chown=emailengineuser:emailenginegroup /emailengine /emailengine
|
|
60
84
|
|
|
61
85
|
RUN node -e "console.log('node arch: ' + os.arch())"
|
|
62
86
|
RUN node -e "console.log(process.versions)"
|
package/config/default.toml
CHANGED
|
@@ -27,7 +27,12 @@ maxSize = "5M" # maximum size of an attachment when submitting or uploading
|
|
|
27
27
|
#maxBodySize = "50M" # maximum size of an API request body
|
|
28
28
|
#maxPayloadTimeout = "10s" # how long to wait for a request body to arrive
|
|
29
29
|
#proxy = false # trust X-Forwarded-For from a reverse proxy (restrict the peers with EENGINE_API_PROXY_ADDRESSES)
|
|
30
|
-
#
|
|
30
|
+
#cspMode = "enforce" # Content-Security-Policy delivery: "enforce", "report-only" (violations are only reported to the browser console) or "off"
|
|
31
|
+
# Serve the API over HTTPS by pointing at a certificate and key. Anything left unset falls back to
|
|
32
|
+
# what EmailEngine manages itself (an uploaded certificate, a Let's Encrypt one, or a self-signed
|
|
33
|
+
# certificate), so this section is only needed to pin a specific certificate here.
|
|
34
|
+
# The SMTP server and the IMAP proxy take the same values through EENGINE_SMTP_TLS_* and
|
|
35
|
+
# EENGINE_IMAPPROXY_TLS_* (use the _FILE suffix to read one from a file).
|
|
31
36
|
#[api.tls]
|
|
32
37
|
#certPath = "/path/to/cert.pem"
|
|
33
38
|
#keyPath = "/path/to/key.pem"
|
|
@@ -36,7 +41,7 @@ maxSize = "5M" # maximum size of an attachment when submitting or uploading
|
|
|
36
41
|
enabled = false
|
|
37
42
|
port = 2525
|
|
38
43
|
host = "127.0.0.1"
|
|
39
|
-
secret = "" # client password,
|
|
44
|
+
secret = "" # shared client password; when unset, clients authenticate with an API token that has the "smtp" scope
|
|
40
45
|
proxy = false # Set to true if using HAProxy with send-proxy option
|
|
41
46
|
#maxMessageSize = "25M" # maximum message size accepted by SMTP server (default: 25MB)
|
|
42
47
|
#maxClients = 100 # concurrent SMTP server connections; excess connections are refused with a 421 (default: 100)
|
package/copy-static-files.sh
CHANGED
|
@@ -13,11 +13,6 @@ cp node_modules/ace-builds/src-min/mode-html.js static/js/ace/
|
|
|
13
13
|
cp node_modules/ace-builds/src-min/mode-json.js static/js/ace/
|
|
14
14
|
cp node_modules/ace-builds/src-min/mode-javascript.js static/js/ace/
|
|
15
15
|
cp node_modules/ace-builds/src-min/mode-markdown.js static/js/ace/
|
|
16
|
-
cp node_modules/ace-builds/src-min/theme-xcode.js static/js/ace/
|
|
17
|
-
cp node_modules/ace-builds/src-min/theme-kuroir.js static/js/ace/
|
|
18
|
-
# dark-theme counterparts applied by uiAceEditor/uiAcePreview (static/js/ui.js)
|
|
19
|
-
cp node_modules/ace-builds/src-min/theme-tomorrow_night.js static/js/ace/
|
|
20
|
-
cp node_modules/ace-builds/src-min/theme-tomorrow_night_eighties.js static/js/ace/
|
|
21
16
|
cp node_modules/ace-builds/src-min/worker-html.js static/js/ace/
|
|
22
17
|
cp node_modules/ace-builds/src-min/worker-json.js static/js/ace/
|
|
23
18
|
cp node_modules/ace-builds/src-min/worker-javascript.js static/js/ace/
|
|
@@ -25,8 +20,31 @@ cp node_modules/ace-builds/src-min/snippets/javascript.js static/js/ace/snippets
|
|
|
25
20
|
cp node_modules/ace-builds/src-min/snippets/markdown.js static/js/ace/snippets
|
|
26
21
|
cp node_modules/ace-builds/src-min/ext-searchbox.js static/js/ace/ext-searchbox.js
|
|
27
22
|
|
|
23
|
+
# ACE stylesheets, linked by views/partials/ace_assets.hbs. That partial also puts ACE in
|
|
24
|
+
# strict-CSP mode, so it injects no <style> elements of its own and the admin
|
|
25
|
+
# Content-Security-Policy can require a nonce on every stylesheet.
|
|
26
|
+
mkdir -p static/js/ace/css/theme
|
|
27
|
+
cp node_modules/ace-builds/css/ace.css static/js/ace/css/
|
|
28
|
+
|
|
29
|
+
# The light/dark pairs uiAceEditor and uiAcePreview switch between (static/js/ui.js). Each theme
|
|
30
|
+
# needs its module (for the cssClass and isDark ACE reads from it) and its stylesheet.
|
|
31
|
+
for theme in xcode kuroir tomorrow_night tomorrow_night_eighties; do
|
|
32
|
+
cp node_modules/ace-builds/src-min/theme-$theme.js static/js/ace/
|
|
33
|
+
cp node_modules/ace-builds/css/theme/$theme.css static/js/ace/css/theme/
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
# The images the sheets reference. Both bases land in css/ - ace.css uses ./, a theme uses ../ -
|
|
37
|
+
# so one pass over the copied sheets covers them.
|
|
38
|
+
for image in $(grep -oh 'url("[^"]*")' static/js/ace/css/ace.css static/js/ace/css/theme/*.css | sed 's/^url("//; s/")$//; s/^\.\.\///; s/^\.\///' | sort -u); do
|
|
39
|
+
cp node_modules/ace-builds/css/$image static/js/ace/css/
|
|
40
|
+
done
|
|
41
|
+
|
|
28
42
|
cp node_modules/\@postalsys/ee-client/index.js static/js/ee-client.js
|
|
29
43
|
|
|
44
|
+
# SimpleWebAuthn browser bundle, kept at the same version as @simplewebauthn/server (the
|
|
45
|
+
# devDependency exists only to be vendored here; login-passkey.js and passkey-register.js load it)
|
|
46
|
+
cp node_modules/\@simplewebauthn/browser/dist/bundle/index.umd.min.js static/vendor/simplewebauthn/browser.min.js
|
|
47
|
+
|
|
30
48
|
# FlyonUI browser bundle (vendored like ace above; committed and bundled by pkg)
|
|
31
49
|
cp node_modules/flyonui/flyonui.js static/js/flyonui.js
|
|
32
50
|
|
package/encrypt.js
CHANGED
|
@@ -20,6 +20,7 @@ const msgpack = require('./lib/msgpack');
|
|
|
20
20
|
|
|
21
21
|
const { REDIS_PREFIX, ENCRYPTED_APP_KEYS } = require('./lib/consts');
|
|
22
22
|
const { Settings: CertSettings } = require('@postalsys/certs/lib/settings');
|
|
23
|
+
const { TLS_KEY } = require('./lib/tls/store');
|
|
23
24
|
|
|
24
25
|
const DECRYPT_PASSWORDS = [].concat(config.decrypt || []);
|
|
25
26
|
|
|
@@ -310,6 +311,48 @@ async function main() {
|
|
|
310
311
|
}
|
|
311
312
|
|
|
312
313
|
console.log(`Updated ${updatedCerts} TLS private keys`);
|
|
314
|
+
|
|
315
|
+
// TLS material EmailEngine manages itself: the certificate an operator uploaded through the
|
|
316
|
+
// admin UI, and the self-signed certificate a listener falls back to. Both live in the `tls`
|
|
317
|
+
// hash as JSON with an encrypted `privateKey` field, and both need the same pass - an uploaded
|
|
318
|
+
// certificate that could not be decrypted after a rotation would take the listener down at the
|
|
319
|
+
// next restart, and there is no way to regenerate one.
|
|
320
|
+
let updatedTlsRecords = 0;
|
|
321
|
+
let tlsKey = TLS_KEY;
|
|
322
|
+
let tlsEntries = await redis.hgetall(tlsKey);
|
|
323
|
+
for (let field of Object.keys(tlsEntries || {})) {
|
|
324
|
+
let record;
|
|
325
|
+
try {
|
|
326
|
+
record = JSON.parse(tlsEntries[field]);
|
|
327
|
+
} catch (err) {
|
|
328
|
+
console.log(`TLS entry ${field}: failed to parse`);
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!record || !record.privateKey) {
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
let updated = await processSecret(record.privateKey, encryptSecret);
|
|
338
|
+
if (updated === record.privateKey) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
record.privateKey = updated;
|
|
342
|
+
|
|
343
|
+
let result = await redis.hmset(tlsKey, { [field]: JSON.stringify(record) });
|
|
344
|
+
if (result === 'OK') {
|
|
345
|
+
console.log(`TLS entry ${field}: updated`);
|
|
346
|
+
} else {
|
|
347
|
+
console.log(`TLS entry ${field}: Unexpected response from DB: ${result}`);
|
|
348
|
+
}
|
|
349
|
+
updatedTlsRecords++;
|
|
350
|
+
} catch (err) {
|
|
351
|
+
console.error(`Could not process "${field}". Check decryption secrets.`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
console.log(`Updated ${updatedTlsRecords} stored TLS certificates`);
|
|
313
356
|
}
|
|
314
357
|
|
|
315
358
|
main()
|
|
@@ -188,6 +188,67 @@ async function resetStateCount(redis, account, state) {
|
|
|
188
188
|
return result >= 0;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
// A stored timestamp is only as good as whatever wrote it: a corrupt or hand-edited record must
|
|
192
|
+
// degrade to null rather than fail the response schema and 500 the endpoint
|
|
193
|
+
function isoOrNull(date) {
|
|
194
|
+
return date && date.toString() !== 'Invalid Date' ? date.toISOString() : null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The state of a Gmail account's Pub/Sub watch, for whoever has to answer "is push working right
|
|
199
|
+
* now". Derived rather than stored: the account keeps the last successful arm (`lastWatch`,
|
|
200
|
+
* `watchResponse`, `watchExpiration`) and the last failure (`watchFailure`) as separate records,
|
|
201
|
+
* and neither answers the question on its own.
|
|
202
|
+
*
|
|
203
|
+
* Everything here is a timestamp or an enum EmailEngine produced, and nothing the provider wrote is
|
|
204
|
+
* quoted. The stored failure carries plenty that is: `req.response` is Google's body verbatim, and
|
|
205
|
+
* `err` is `formatTokenError()` output whenever the failure was a token fetch, which interpolates
|
|
206
|
+
* the provider's `error_description`. GET /v1/account/{id} is reachable by an account-bound tenant
|
|
207
|
+
* token, by an MCP token whose contents reach an LLM, and by a session token that lives in page
|
|
208
|
+
* HTML, so the reason a watch failed stays on the account page - behind an admin session, reading
|
|
209
|
+
* the stored record directly.
|
|
210
|
+
*
|
|
211
|
+
* A dead watch is not an error state: the Gmail client keeps syncing on its fallback poller, so
|
|
212
|
+
* mail is delayed rather than lost. That is why this is a field to read and not a webhook.
|
|
213
|
+
*
|
|
214
|
+
* @param {Object} accountData - Account data object
|
|
215
|
+
* @returns {Object|null} Watch state, or null for an account that has never armed one
|
|
216
|
+
*/
|
|
217
|
+
function formatGmailWatch(accountData) {
|
|
218
|
+
if (!accountData || (!accountData.watchResponse && !accountData.watchFailure)) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Push is configured on the linked application. An account whose application has no Pub/Sub
|
|
223
|
+
// app has no watch to report, whatever an earlier configuration left behind: the Gmail client
|
|
224
|
+
// clears that record when it next arms a watch, but a send-only or parked account never
|
|
225
|
+
// arms one, and its months-old failure would otherwise read as the current state.
|
|
226
|
+
if (accountData._app && !accountData._app.pubSubApp) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const failure = accountData.watchFailure;
|
|
231
|
+
|
|
232
|
+
// The response of the arm that is actually live wins. `watchExpiration` rides the default
|
|
233
|
+
// serializer branch, which skips a null, so a success that carried no expiration leaves the
|
|
234
|
+
// previous arm's number in place and preferring it would report a lapsed watch as active
|
|
235
|
+
const expiration = (accountData.watchResponse && accountData.watchResponse.expiration) || accountData.watchExpiration;
|
|
236
|
+
const expires = isoOrNull(expiration && new Date(Number(expiration)));
|
|
237
|
+
|
|
238
|
+
// The failure carries its own attempt time because a failed renewal no longer moves lastWatch -
|
|
239
|
+
// doing so used to buy a broken watch a full day of silence, whatever the retry timer wanted
|
|
240
|
+
const lastCheck = (failure && isoOrNull(failure.time && new Date(failure.time))) || isoOrNull(accountData.lastWatch && new Date(accountData.lastWatch));
|
|
241
|
+
|
|
242
|
+
let state = 'expired';
|
|
243
|
+
if (failure) {
|
|
244
|
+
state = 'error';
|
|
245
|
+
} else if (expires && new Date(expires) > new Date()) {
|
|
246
|
+
state = 'active';
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return { state, lastCheck, expires };
|
|
250
|
+
}
|
|
251
|
+
|
|
191
252
|
/**
|
|
192
253
|
* Formats the last error for API responses
|
|
193
254
|
* Returns null if account is connected or no error exists
|
|
@@ -246,6 +307,7 @@ module.exports = {
|
|
|
246
307
|
setLastErrorState,
|
|
247
308
|
clearLastErrorState,
|
|
248
309
|
formatLastError,
|
|
310
|
+
formatGmailWatch,
|
|
249
311
|
|
|
250
312
|
// State counters
|
|
251
313
|
getStateCount,
|
package/lib/account.js
CHANGED
|
@@ -39,6 +39,7 @@ const { checkAccountScopes: checkScopes } = require('./oauth/scope-checker');
|
|
|
39
39
|
const { ACCOUNT_STATES, ERROR_STATES, calculateEffectiveState, validateAccountState, getDisplayState, formatLastError } = require('./account/account-state');
|
|
40
40
|
const { decodeStoredMailboxEntry } = require('./email-client/imap/listing-diff');
|
|
41
41
|
const { readImapData } = require('./account/imap-data');
|
|
42
|
+
const { isTransientCredentialError, credentialErrorStatus } = require('./email-client/credential-errors');
|
|
42
43
|
|
|
43
44
|
// Shared Lock instance to prevent Redis connection leak (one subscriber per Lock instance)
|
|
44
45
|
// Previously, each Account created its own Lock, causing ~30k connections with 30k accounts
|
|
@@ -1739,7 +1740,12 @@ class Account {
|
|
|
1739
1740
|
if (entry.status) {
|
|
1740
1741
|
delete entry.status.path;
|
|
1741
1742
|
}
|
|
1742
|
-
|
|
1743
|
+
// Keyed the way the stored listing is keyed, because that is what the lookup
|
|
1744
|
+
// below uses. A server that spells the inbox "Inbox" reports it that way in
|
|
1745
|
+
// every LIST response while the stored hash holds the case-folded "INBOX", so
|
|
1746
|
+
// an unnormalized key silently dropped the live counters for the one folder
|
|
1747
|
+
// every account has.
|
|
1748
|
+
mailboxListingMap.set(normalizePath(entry.path), entry);
|
|
1743
1749
|
}
|
|
1744
1750
|
}
|
|
1745
1751
|
|
|
@@ -3141,6 +3147,8 @@ class Account {
|
|
|
3141
3147
|
async invalidateAccessToken() {
|
|
3142
3148
|
let accountData = await this.loadAccountData(this.account, false);
|
|
3143
3149
|
if (accountData.oauth2) {
|
|
3150
|
+
// Rewinding the expiry is the whole encoding of "invalidated", and isAccessTokenInvalidated()
|
|
3151
|
+
// below is its decoder: change one and change the other
|
|
3144
3152
|
accountData.oauth2.expires = new Date(Date.now() - 24 * 3600 * 1000).toISOString();
|
|
3145
3153
|
await this.update({ account: accountData.account, oauth2: accountData.oauth2 });
|
|
3146
3154
|
this.logger.info({ msg: 'Invalidated the OAuth2 access token', account: this.account, expires: accountData.oauth2.expires });
|
|
@@ -3160,7 +3168,33 @@ class Account {
|
|
|
3160
3168
|
if (await useAuthServerForOAuth2(accountData.oauth2, this.logger, { account: this.account, target: 'api' })) {
|
|
3161
3169
|
// resolve credentials
|
|
3162
3170
|
|
|
3163
|
-
let authData
|
|
3171
|
+
let authData;
|
|
3172
|
+
try {
|
|
3173
|
+
authData = await resolveCredentials(this.account, 'api');
|
|
3174
|
+
} catch (err) {
|
|
3175
|
+
// The authentication server's own HTTP status must not become EmailEngine's, which
|
|
3176
|
+
// is why resolveCredentials() keeps it in an `authRequest` record rather than on
|
|
3177
|
+
// err.statusCode. It is translated into a status of EmailEngine's own here:
|
|
3178
|
+
// returning it verbatim told an API client holding a perfectly valid EmailEngine
|
|
3179
|
+
// token that its token was rejected (401) or that the account does not exist (404).
|
|
3180
|
+
let transient = isTransientCredentialError(err);
|
|
3181
|
+
|
|
3182
|
+
this.logger.error({
|
|
3183
|
+
msg: 'Failed to resolve credentials from the authentication server',
|
|
3184
|
+
account: this.account,
|
|
3185
|
+
target: 'api',
|
|
3186
|
+
status: credentialErrorStatus(err) || undefined,
|
|
3187
|
+
transient,
|
|
3188
|
+
err
|
|
3189
|
+
});
|
|
3190
|
+
|
|
3191
|
+
let error = Boom.boomify(err, { statusCode: transient ? 503 : 403 });
|
|
3192
|
+
error.output.payload.code = transient ? 'AuthServerUnavailable' : 'AuthServerError';
|
|
3193
|
+
if (!transient) {
|
|
3194
|
+
error.output.payload.authenticationFailed = true;
|
|
3195
|
+
}
|
|
3196
|
+
throw error;
|
|
3197
|
+
}
|
|
3164
3198
|
|
|
3165
3199
|
return {
|
|
3166
3200
|
account: accountData.account,
|
|
@@ -3369,4 +3403,27 @@ async function accountSummary(redis, account) {
|
|
|
3369
3403
|
return { account, name: name || '', email: email || '', state: state || 'init' };
|
|
3370
3404
|
}
|
|
3371
3405
|
|
|
3372
|
-
|
|
3406
|
+
/**
|
|
3407
|
+
* Tells whether an account's access token was invalidated by Account#invalidateAccessToken().
|
|
3408
|
+
*
|
|
3409
|
+
* The invalidation rewinds `expires` by a day and leaves `generated` alone, so the token reads
|
|
3410
|
+
* as a validity window that ends before it starts. A live token can never have that shape (a
|
|
3411
|
+
* renewal writes both fields from the same clock), which makes the inversion the marker.
|
|
3412
|
+
*
|
|
3413
|
+
* @param {Object} oauth2 - The parsed oauth2 record of an account (dates as Date objects)
|
|
3414
|
+
* @returns {boolean}
|
|
3415
|
+
*/
|
|
3416
|
+
function isAccessTokenInvalidated(oauth2) {
|
|
3417
|
+
return !!(oauth2 && oauth2.expires && oauth2.generated && oauth2.expires < oauth2.generated);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
module.exports = {
|
|
3421
|
+
Account,
|
|
3422
|
+
accountExists,
|
|
3423
|
+
accountsExist,
|
|
3424
|
+
accountSummary,
|
|
3425
|
+
authFailureDisabledAt,
|
|
3426
|
+
isAuthFailureDisabled,
|
|
3427
|
+
isOperatorDisabled,
|
|
3428
|
+
isAccessTokenInvalidated
|
|
3429
|
+
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const crypto = require('crypto');
|
|
4
4
|
const { redis } = require('../db');
|
|
5
5
|
const { Account, accountExists, authFailureDisabledAt } = require('../account');
|
|
6
|
+
const { formatGmailWatch } = require('../account/account-state');
|
|
6
7
|
const getSecret = require('../get-secret');
|
|
7
8
|
const { oauth2Apps, SERVICE_ACCOUNT_PROVIDERS } = require('../oauth2-apps');
|
|
8
9
|
const settings = require('../settings');
|
|
@@ -1034,6 +1035,11 @@ async function init(args) {
|
|
|
1034
1035
|
result.lastError = accountData.state === 'connected' ? null : accountData.lastErrorState;
|
|
1035
1036
|
}
|
|
1036
1037
|
|
|
1038
|
+
let gmailWatch = formatGmailWatch(accountData);
|
|
1039
|
+
if (gmailWatch) {
|
|
1040
|
+
result.gmailWatch = gmailWatch;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1037
1043
|
// Stated rather than inferred; see the field's description in lib/schemas.js
|
|
1038
1044
|
result.authFailureDisabledAt = authFailureDisabledAt(accountData);
|
|
1039
1045
|
|
|
@@ -1177,6 +1183,20 @@ async function init(args) {
|
|
|
1177
1183
|
.description('Information about the last SMTP connection attempt. Null when no SMTP connection has been attempted')
|
|
1178
1184
|
.label('SMTPInfoStatus'),
|
|
1179
1185
|
|
|
1186
|
+
gmailWatch: Joi.object({
|
|
1187
|
+
state: Joi.string()
|
|
1188
|
+
.valid('active', 'expired', 'error')
|
|
1189
|
+
.example('active')
|
|
1190
|
+
.description('Whether the Pub/Sub watch is armed, lapsed, or failed to renew')
|
|
1191
|
+
.label('AccountGmailWatchState'),
|
|
1192
|
+
lastCheck: Joi.date().iso().allow(null).example('2021-07-08T07:06:34.336Z').description('When the watch was last renewed or attempted'),
|
|
1193
|
+
expires: Joi.date().iso().allow(null).example('2021-07-15T07:06:34.336Z').description('When the current watch lapses')
|
|
1194
|
+
})
|
|
1195
|
+
.description(
|
|
1196
|
+
'State of the Gmail Pub/Sub watch (Gmail API accounts only). A watch that is not active does not stop the account syncing - the client falls back to polling, so new mail is delayed rather than lost. Why a renewal failed is shown on the account page rather than here, because that text is written by the provider'
|
|
1197
|
+
)
|
|
1198
|
+
.label('AccountGmailWatch'),
|
|
1199
|
+
|
|
1180
1200
|
syncError: Joi.object({
|
|
1181
1201
|
path: Joi.string().example('INBOX').description('Mailbox folder path where the error occurred'),
|
|
1182
1202
|
time: Joi.date().iso().example('2021-07-08T07:06:34.336Z').description('When the error occurred'),
|
|
@@ -4,6 +4,7 @@ const { createBullBoard } = require('@bull-board/api');
|
|
|
4
4
|
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
|
|
5
5
|
const { HapiAdapter } = require('@bull-board/hapi');
|
|
6
6
|
const { notifyQueue, submitQueue, documentsQueue } = require('../db');
|
|
7
|
+
const { BULL_BOARD_BASE_PATH } = require('../consts');
|
|
7
8
|
|
|
8
9
|
async function init(args) {
|
|
9
10
|
const { server } = args;
|
|
@@ -51,9 +52,9 @@ async function init(args) {
|
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
54
|
|
|
54
|
-
serverAdapter.setBasePath(
|
|
55
|
+
serverAdapter.setBasePath(BULL_BOARD_BASE_PATH);
|
|
55
56
|
await server.register(serverAdapter.registerPlugin(), {
|
|
56
|
-
routes: { prefix:
|
|
57
|
+
routes: { prefix: BULL_BOARD_BASE_PATH }
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
|
package/lib/api-routes/index.js
CHANGED
|
@@ -128,7 +128,7 @@ async function registerApiRoutes(args) {
|
|
|
128
128
|
await mailboxRoutes({ server, call, CORS_CONFIG, FLAG_SORT_ORDER });
|
|
129
129
|
|
|
130
130
|
// setup settings routes
|
|
131
|
-
await settingsRoutes({ server, notify, CORS_CONFIG });
|
|
131
|
+
await settingsRoutes({ server, call, notify, CORS_CONFIG });
|
|
132
132
|
|
|
133
133
|
// setup stats route
|
|
134
134
|
await statsRoutes({ server, call, CORS_CONFIG });
|