emailengine-app 2.76.0 → 2.78.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.
Files changed (165) hide show
  1. package/.github/workflows/release.yaml +24 -19
  2. package/.github/workflows/test.yml +80 -0
  3. package/.ncurc.js +14 -2
  4. package/.release-please-manifest.json +3 -0
  5. package/CHANGELOG.md +54 -0
  6. package/README.md +1 -1
  7. package/bin/emailengine.js +1 -1
  8. package/data/google-crawlers.json +1 -1
  9. package/encrypt.js +72 -5
  10. package/lib/account/expected-identity.js +88 -0
  11. package/lib/account.js +75 -26
  12. package/lib/address-strategies.js +18 -0
  13. package/lib/api-reference/code-samples.js +194 -0
  14. package/lib/api-reference/format.js +193 -0
  15. package/lib/api-reference/index.js +222 -0
  16. package/lib/api-reference/model.js +338 -0
  17. package/lib/api-reference/schema-tree.js +366 -0
  18. package/lib/api-routes/account-routes.js +136 -39
  19. package/lib/api-routes/behavior-notes.js +57 -0
  20. package/lib/api-routes/blocklist-routes.js +9 -9
  21. package/lib/api-routes/changes-routes.js +6 -4
  22. package/lib/api-routes/chat-routes.js +3 -3
  23. package/lib/api-routes/delivery-test-routes.js +24 -6
  24. package/lib/api-routes/export-routes.js +14 -12
  25. package/lib/api-routes/gateway-routes.js +11 -11
  26. package/lib/api-routes/license-routes.js +7 -7
  27. package/lib/api-routes/mailbox-routes.js +18 -9
  28. package/lib/api-routes/message-routes.js +55 -35
  29. package/lib/api-routes/oauth2-app-routes.js +22 -16
  30. package/lib/api-routes/outbox-routes.js +7 -7
  31. package/lib/api-routes/pubsub-routes.js +3 -3
  32. package/lib/api-routes/settings-routes.js +10 -9
  33. package/lib/api-routes/stats-routes.js +3 -3
  34. package/lib/api-routes/submit-routes.js +58 -8
  35. package/lib/api-routes/template-routes.js +13 -13
  36. package/lib/api-routes/token-routes.js +15 -10
  37. package/lib/api-routes/webhook-route-routes.js +5 -5
  38. package/lib/append-list.js +3 -14
  39. package/lib/arf-detect.js +23 -1
  40. package/lib/autodetect-imap-settings.js +40 -16
  41. package/lib/base32.js +30 -0
  42. package/lib/bounce-detect.js +182 -62
  43. package/lib/consts.js +7 -0
  44. package/lib/egress-filter.js +89 -8
  45. package/lib/email-client/base-client.js +72 -82
  46. package/lib/email-client/gmail-client.js +3 -3
  47. package/lib/email-client/imap/listing-diff.js +3 -3
  48. package/lib/email-client/imap/mailbox.js +5 -69
  49. package/lib/email-client/imap-client.js +3 -2
  50. package/lib/email-client/message-builder.js +13 -13
  51. package/lib/email-client/outlook-client.js +1 -1
  52. package/lib/enum-descriptions.js +130 -0
  53. package/lib/export.js +1 -1
  54. package/lib/gateway.js +1 -1
  55. package/lib/get-raw-email.js +1 -1
  56. package/lib/imapproxy/imap-core/lib/imap-connection.js +2 -2
  57. package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
  58. package/lib/imapproxy/imap-server.js +42 -28
  59. package/lib/imapproxy/upstream-client.js +38 -0
  60. package/lib/license-beacon.js +1 -1
  61. package/lib/llm-pre-process.js +1 -1
  62. package/lib/msgpack.js +62 -0
  63. package/lib/oauth/decode-jwt-payload.js +39 -0
  64. package/lib/oauth/outlook-identity.js +61 -0
  65. package/lib/oauth/retry-setup.js +38 -0
  66. package/lib/oauth2-apps.js +10 -4
  67. package/lib/openapi/build-document.js +318 -0
  68. package/lib/openapi/index.js +95 -0
  69. package/lib/openapi/joi-schema.js +523 -0
  70. package/lib/outbox.js +66 -3
  71. package/lib/pre-process.js +1 -1
  72. package/lib/read-env-value.js +37 -0
  73. package/lib/routes-ui.js +5 -1
  74. package/lib/schemas.js +88 -17
  75. package/lib/swagger-options.js +173 -0
  76. package/lib/templates.js +1 -1
  77. package/lib/tokens.js +70 -6
  78. package/lib/tools.js +117 -48
  79. package/lib/totp.js +67 -0
  80. package/lib/ui-routes/account-routes.js +91 -15
  81. package/lib/ui-routes/admin-config-routes.js +2 -7
  82. package/lib/ui-routes/admin-entities-routes.js +3 -0
  83. package/lib/ui-routes/auth-routes.js +6 -24
  84. package/lib/ui-routes/dashboard-routes.js +2 -26
  85. package/lib/ui-routes/reference-routes.js +198 -0
  86. package/lib/ui-routes/route-helpers.js +39 -0
  87. package/lib/utils/is-email.js +34 -0
  88. package/lib/utils/to-camel-case.js +17 -0
  89. package/lib/webhook-egress.js +37 -0
  90. package/lib/webhooks.js +1 -1
  91. package/package.json +27 -31
  92. package/prepare-bundle-deps.sh +28 -0
  93. package/release-please-config.json +11 -0
  94. package/sbom.json +1 -1
  95. package/server.js +11 -3
  96. package/static/css/flyonui.css +1 -1
  97. package/static/css/public.css +3 -0
  98. package/static/css/src/app.tailwind.css +113 -0
  99. package/static/js/app.js +69 -0
  100. package/static/js/ee-client.js +238 -8
  101. package/static/js/reference.js +1021 -0
  102. package/static/js/ui.js +61 -33
  103. package/static/licenses.html +658 -1560
  104. package/translations/README.md +64 -0
  105. package/translations/de.mo +0 -0
  106. package/translations/de.po +164 -120
  107. package/translations/en.po +200 -161
  108. package/translations/et.mo +0 -0
  109. package/translations/et.po +163 -120
  110. package/translations/fr.mo +0 -0
  111. package/translations/fr.po +163 -120
  112. package/translations/ja.mo +0 -0
  113. package/translations/ja.po +163 -120
  114. package/translations/messages.pot +84 -54
  115. package/translations/nl.mo +0 -0
  116. package/translations/nl.po +164 -120
  117. package/translations/pl.mo +0 -0
  118. package/translations/pl.po +163 -120
  119. package/views/account-identity-error.hbs +34 -0
  120. package/views/accounts/edit.hbs +1 -0
  121. package/views/accounts/register/imap.hbs +12 -2
  122. package/views/config/ai.hbs +1 -1
  123. package/views/config/document-store/chat.hbs +5 -5
  124. package/views/config/document-store/index.hbs +2 -2
  125. package/views/config/document-store/pre-processing/index.hbs +1 -1
  126. package/views/config/email-processing.hbs +1 -1
  127. package/views/config/imap-proxy.hbs +1 -1
  128. package/views/config/license.hbs +1 -1
  129. package/views/config/oauth/index.hbs +3 -3
  130. package/views/config/security.hbs +1 -1
  131. package/views/config/smtp.hbs +2 -2
  132. package/views/dashboard.hbs +1 -1
  133. package/views/layout/app.hbs +43 -8
  134. package/views/oauth-scope-error.hbs +1 -1
  135. package/views/partials/oauth_form.hbs +4 -4
  136. package/views/partials/reference/anchor-link.hbs +20 -0
  137. package/views/partials/reference/disclosure.hbs +37 -0
  138. package/views/partials/reference/nav.hbs +120 -0
  139. package/views/partials/reference/operation.hbs +127 -0
  140. package/views/partials/reference/params.hbs +20 -0
  141. package/views/partials/reference/schema-node.hbs +99 -0
  142. package/views/partials/reference/schema.hbs +19 -0
  143. package/views/partials/reference/section-heading.hbs +16 -0
  144. package/views/partials/reference/token-alert.hbs +49 -0
  145. package/views/partials/reference/try-field.hbs +31 -0
  146. package/views/partials/reference/try-it.hbs +78 -0
  147. package/views/partials/side_menu.hbs +1 -1
  148. package/views/partials/ui/badge.hbs +4 -2
  149. package/views/partials/ui/page-header.hbs +1 -1
  150. package/views/partials/ui/search-input.hbs +31 -0
  151. package/views/partials/ui/setting-ref.hbs +1 -1
  152. package/views/partials/ui/stat-card.hbs +4 -2
  153. package/views/partials/ui/tab.hbs +6 -1
  154. package/views/partials/ui/tabs.hbs +2 -2
  155. package/views/reference/index.hbs +76 -0
  156. package/views/reference/redirect.hbs +49 -0
  157. package/views/reference/tag.hbs +28 -0
  158. package/views/reference/token.hbs +49 -0
  159. package/views/tokens/index.hbs +9 -1
  160. package/views/webhooks/index.hbs +3 -3
  161. package/workers/api.js +194 -302
  162. package/workers/imap.js +1 -1
  163. package/workers/submit.js +1 -1
  164. package/workers/webhooks.js +2 -13
  165. package/views/swagger/index.hbs +0 -82
@@ -21,31 +21,36 @@ jobs:
21
21
  patch: ${{ steps.release.outputs.patch }}
22
22
  release_created: ${{ steps.release.outputs.release_created }}
23
23
  steps:
24
+ # Configured through release-please-config.json (manifest mode) rather than a
25
+ # `release-type` input here - the two are mutually exclusive, and only the config
26
+ # file can set `draft`, which the action exposes no input for. The release is drafted
27
+ # so users never see a version whose binaries do not exist yet, and `force-tag-creation`
28
+ # makes the tag anyway: GitHub withholds the tag for a draft, and upload.sh builds
29
+ # from the tag (falling back to HEAD behind an interactive prompt without it).
24
30
  - uses: googleapis/release-please-action@v4
25
31
  id: release
26
- with:
27
- release-type: node
28
-
29
- # The logic below handles the npm publication:
30
- - uses: actions/checkout@v6
31
- # these if statements ensure that a publication only occurs when
32
- # a new release is created:
33
- if: ${{ steps.release.outputs.release_created }}
34
-
35
- - uses: actions/setup-node@v6
36
- with:
37
- node-version: 24
38
- registry-url: "https://registry.npmjs.org"
39
- if: ${{ steps.release.outputs.release_created }}
40
-
41
- - run: npm install
42
- if: ${{ steps.release.outputs.release_created }}
43
32
 
44
33
  publish:
45
34
  name: Publish NPM package
46
35
  runs-on: ubuntu-latest
47
36
  needs: release_please
48
- if: ${{needs.release_please.outputs.release_created}}
37
+ # Fires as soon as release-please creates the release, which it does even though the
38
+ # release is a draft - `release_created` reports the release object, not its visibility.
39
+ #
40
+ # Deliberately NOT deferred until the draft is published. Doing that would mean waiting
41
+ # on a `release` event, and that event only exists because upload.sh publishes with a
42
+ # real user's credentials: draft releases raise no event, and one raised inside Actions
43
+ # by GITHUB_TOKEN never triggers a workflow. Several conditions all having to hold for a
44
+ # publish to happen makes the failure mode a silent non-publication, discovered late.
45
+ # Publishing here is one workflow run with nothing to choreograph.
46
+ #
47
+ # Publishing before the binaries exist is not shipping something broken: the npm package
48
+ # is the Node source and works on its own - it does not carry the pkg binaries, so it
49
+ # does not depend on the part of a release that can fail late.
50
+ #
51
+ # This job also has to stay in this file: npm trusted publishing (OIDC, which is why
52
+ # there is no token secret) is bound to the repository AND the workflow filename.
53
+ if: needs.release_please.outputs.release_created
49
54
  permissions:
50
55
  contents: read
51
56
  id-token: write
@@ -62,7 +67,7 @@ jobs:
62
67
  name: Publish Tagged Docker Image
63
68
  runs-on: ubuntu-latest
64
69
  needs: release_please
65
- if: ${{needs.release_please.outputs.release_created}}
70
+ if: needs.release_please.outputs.release_created
66
71
  # Multi-arch builds run the arm64 leg under QEMU emulation, which can
67
72
  # hang indefinitely on a misbehaving step. A normal build finishes in
68
73
  # ~4 minutes, so fail fast instead of burning the 6-hour default limit.
@@ -126,6 +126,86 @@ jobs:
126
126
  env:
127
127
  EENGINE_DOVECOT_PLATFORM: linux/amd64
128
128
 
129
+ # Nothing else in CI bundles a binary, so pkg failures used to surface only when a release
130
+ # was cut by hand on a Mac - the one place they are most expensive and least expected. Two
131
+ # landed in a single day: a local helper named `require` in lib/openapi/ that pkg's module
132
+ # walker choked on (undetectable by any test, since it runs correctly under Node), and a
133
+ # dependency shipping a 0-byte ESM entry point that esbuild transformed to nothing. The
134
+ # first sat undetected for four days and would have broken the next release outright.
135
+ #
136
+ # One target, unsigned, uncompressed. Signing and notarization need Apple credentials and
137
+ # stay on the release machine; neither has any bearing on whether the bundle can be built.
138
+ pkg_build:
139
+ name: Binary Build (linux-x64, unsigned)
140
+ if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
141
+ timeout-minutes: 20
142
+ runs-on: ubuntu-24.04
143
+ services:
144
+ redis:
145
+ image: redis
146
+ options: >-
147
+ --health-cmd "redis-cli ping"
148
+ --health-interval 10s
149
+ --health-timeout 5s
150
+ --health-retries 5
151
+ ports:
152
+ - 6379:6379
153
+ steps:
154
+ - uses: actions/checkout@v6
155
+ - name: Use Node.js 24
156
+ uses: actions/setup-node@v6
157
+ with:
158
+ node-version: 24
159
+ cache: npm
160
+
161
+ # Unpinned on purpose, matching upload.sh: releases are built with whatever pkg is
162
+ # current, so a pkg regression should fail here rather than mid-release.
163
+ - name: Install pkg
164
+ run: npm install -g @yao-pkg/pkg
165
+
166
+ # The real production tree rather than a dev install. That distinction matters: the
167
+ # empty-ESM-file failure only exists under `npm ci --omit=dev`, and
168
+ # prepare-bundle-deps.sh, which works around it, only runs from this script.
169
+ - name: Build the production source tree
170
+ run: npm run build-source
171
+
172
+ # Uncompressed - Brotli is minutes of CPU that changes nothing about the module
173
+ # resolution this job exists to exercise. `--output` ignores the `outputPath` in
174
+ # package.json, so it names the directory itself; ee-dist is already gitignored,
175
+ # which keeps a stray 260 MB binary out of the way when running this locally.
176
+ - name: Bundle a binary
177
+ run: |
178
+ mkdir -p ee-dist
179
+ pkg --target node24-linux-x64 --output ee-dist/emailengine-ci package.json
180
+
181
+ - name: Smoke test the CLI
182
+ run: |
183
+ ./ee-dist/emailengine-ci --version
184
+ ./ee-dist/emailengine-ci help > /dev/null
185
+
186
+ # Booting reaches past what the CLI touches: workers, and the views, static files and
187
+ # lua scripts that are bundled as pkg assets rather than resolved as modules, so a
188
+ # missing asset shows up here instead of in a released binary.
189
+ - name: Boot the binary and check it serves
190
+ env:
191
+ EENGINE_REDIS: redis://127.0.0.1:6379/12
192
+ EENGINE_PORT: 7311
193
+ EENGINE_HOST: 127.0.0.1
194
+ EENGINE_LOG_LEVEL: error
195
+ run: |
196
+ ./ee-dist/emailengine-ci &
197
+ for i in $(seq 1 60); do
198
+ if curl -fsS http://127.0.0.1:7311/health >/dev/null 2>&1; then
199
+ echo "binary booted and served /health"
200
+ curl -fsS -o /dev/null http://127.0.0.1:7311/swagger.json
201
+ echo "generated document served"
202
+ exit 0
203
+ fi
204
+ sleep 2
205
+ done
206
+ echo "binary never became healthy" >&2
207
+ exit 1
208
+
129
209
  integration:
130
210
  name: Integration Tests
131
211
  if: ${{ !startsWith(github.ref_name, 'release-please--') && !startsWith(github.head_ref, 'release-please--') }}
package/.ncurc.js CHANGED
@@ -4,8 +4,8 @@ module.exports = {
4
4
  // CommonJS and is bundled into a binary with pkg) or it breaks a peer dependency. Using 'minor'
5
5
  // instead of a blanket reject so these still receive security/patch updates within the safe
6
6
  // major instead of being frozen at one exact version. Verified against Node 20 (Docker) 2026-06-17.
7
- target: name => (['joi', 'nanoid', 'ical.js', 'gettext-parser', 'xgettext-template', 'chai', 'undici', 'marked'].includes(name) ? 'minor' : 'latest'),
8
- // joi - hapi-swagger (repo archived 2026-02-04) peer-requires joi 17.x; permanent ceiling
7
+ target: name =>
8
+ ['nanoid', 'ical.js', 'gettext-parser', 'xgettext-template', 'chai', 'undici', 'marked', 'bullmq', 'ioredis'].includes(name) ? 'minor' : 'latest',
9
9
  // nanoid - 4.x dropped the CommonJS require export (ESM-only)
10
10
  // ical.js - 2.x is ESM-only
11
11
  // gettext-parser - 8.x is ESM-only
@@ -14,6 +14,18 @@ module.exports = {
14
14
  // undici - 8.x requires Node >=22.19 and crashes at require() on Node 20; EmailEngine supports Node 20+
15
15
  // marked - 16.x dropped the CommonJS build (ESM-only, needs require(esm)/Node >=20.19); 15.x is the
16
16
  // last require()-compatible line. 15.0.12 verified on Node 20-24 and in a yao/pkg node24 build.
17
+ // bullmq - 6.x drops ioredis entirely, and @bull-board/api still peer-requires bullmq ^5.79.2, so the
18
+ // install fails outright (ERESOLVE) on the queue browser we mount at /admin/bull-board.
19
+ // Lift when bull-board ships bullmq 6 support.
20
+ // ioredis - 6.x is held back BY the bullmq cap above, not on its own merits. lib/db.js creates the
21
+ // client and hands it to bullmq as `connection` for all four queues, while bullmq 5 pins
22
+ // ioredis 5.11.1 as a direct dependency - so bumping ours to 6 would drive bullmq 5's
23
+ // internals with a client it was not written against. These two move together.
24
+ //
25
+ // joi used to be capped here because hapi-swagger peer-required 17.x. That dependency is gone
26
+ // (the OpenAPI document is generated by lib/openapi/ now), so joi may move majors again. A major
27
+ // bump still needs a look at the generated document: test/openapi-golden-test.js fails if joi's
28
+ // describe() output changes shape.
17
29
  reject: [
18
30
  // 8.16+ pulls apache-arrow (ESM) into the pkg bundle; 9.x drops it but is a major bump for
19
31
  // the deprecated, default-off Document Store. Even the 8.19 minor is unsafe to bundle.
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "2.78.0"
3
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.78.0](https://github.com/postalsys/emailengine/compare/v2.77.0...v2.78.0) (2026-08-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * **accounts:** pin an account to an expected email identity ([a64bb60](https://github.com/postalsys/emailengine/commit/a64bb6009163bed0835cb3f8342e5d0ec20549b3)), closes [#626](https://github.com/postalsys/emailengine/issues/626)
9
+ * **admin-ui:** keep the access-token banner in view and make the reference nav usable on a phone ([a4bb55f](https://github.com/postalsys/emailengine/commit/a4bb55f7a416a74c65b50a0b69879b5b21915711))
10
+ * **admin:** mark the operation being read in the API reference sidebar ([700eab7](https://github.com/postalsys/emailengine/commit/700eab7716bec0362b73bf5e8f498be971071e7e))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **accounts:** let a wrong-account setup be retried instead of bouncing it back ([4cd6ac4](https://github.com/postalsys/emailengine/commit/4cd6ac4d0b935244accc55b1f9abb41cf906a2dc))
16
+ * **accounts:** remove the messages an account had queued when it is deleted ([ba6897f](https://github.com/postalsys/emailengine/commit/ba6897f4a5966a1a0dcddd7c514a3804e31591c4))
17
+ * **auth:** replace unmaintained speakeasy and base32.js with in-house implementations ([9abaaaa](https://github.com/postalsys/emailengine/commit/9abaaaa4cfd1869788238db80860bbbb77694ed3))
18
+ * **bounces:** read every block of a delivery-status body ([a99878e](https://github.com/postalsys/emailengine/commit/a99878eaf2970b36a7cc0ac50a725292405c6ab3))
19
+ * **bounces:** report every delivery-status field and describe one recipient ([71300c3](https://github.com/postalsys/emailengine/commit/71300c3fcf72065764857b1e90f43626b5e258e7))
20
+ * **deps:** replace deprecated msgpack5 with @msgpack/msgpack behind a compatibility wrapper ([9c40ebc](https://github.com/postalsys/emailengine/commit/9c40ebcc5b61993dad3f6979caab8cb8632b6ad0))
21
+ * **deps:** replace stagnant xml2js with fast-xml-parser in IMAP settings autodetection ([bfd6ec5](https://github.com/postalsys/emailengine/commit/bfd6ec5e7f0925fd3b0fb16a2a7490aa2cb14c27))
22
+ * **deps:** update dependencies (libmime 5.4.2, nodemailer 9.0.5, imapflow 1.6.6) ([abd8034](https://github.com/postalsys/emailengine/commit/abd8034d1e365c5e523a361a0379649fa9c6c29c))
23
+ * **deps:** update email-text-tools and email-ai-tools to pull in patched dompurify (GHSA-55q2-fjhq-7xh7) ([148130f](https://github.com/postalsys/emailengine/commit/148130ff55680287fcd3902b5b5ff0ba9f4881de))
24
+ * **deps:** update imapflow to 1.7.0, certs to 1.0.17, templates to 2.0.2 ([cafae8c](https://github.com/postalsys/emailengine/commit/cafae8ca7b2429547bc60cf2932077af24bfa356))
25
+ * **deps:** update our own packages so the tree carries one copy of each ([4a6e79f](https://github.com/postalsys/emailengine/commit/4a6e79fcaf2d11a35870e557c4a8e6756d05b4b4))
26
+ * **oauth2:** fall back to stored credentials when useAuthServer is set but no auth server is configured ([cd460b0](https://github.com/postalsys/emailengine/commit/cd460b056673c5b148760ba25b670c4e75f1f344))
27
+ * **webhooks:** bind the egress check to the address actually connected to ([#631](https://github.com/postalsys/emailengine/issues/631)) ([2d68b37](https://github.com/postalsys/emailengine/commit/2d68b37a1d186c7f9894e4b1425c1c52870c7cb5))
28
+
29
+
30
+ ### Performance Improvements
31
+
32
+ * **accounts:** unlink the account keys instead of deleting them inline ([ec11210](https://github.com/postalsys/emailengine/commit/ec11210a750021c1ccbf2df3637816974c0f995c))
33
+
34
+ ## [2.77.0](https://github.com/postalsys/emailengine/compare/v2.76.0...v2.77.0) (2026-08-03)
35
+
36
+
37
+ ### Features
38
+
39
+ * **admin:** make the API reference searchable by field name and linkable per property ([65acf52](https://github.com/postalsys/emailengine/commit/65acf52a79d0002d7cd7cec7e2466f17dea06f13))
40
+ * **admin:** retire the bundled swagger-ui page ([34eb957](https://github.com/postalsys/emailengine/commit/34eb9579b19211b678283d2af62fee7c876ba6f0))
41
+ * **admin:** server-rendered API reference at /admin/reference ([2ae59f9](https://github.com/postalsys/emailengine/commit/2ae59f9377f0f651324e9fbed65970ffaf72c3f5))
42
+ * **api:** document success responses, enum values and per-operation behavior ([bbe36e6](https://github.com/postalsys/emailengine/commit/bbe36e6d0a2c9fb36fc1fb00fdd5f1d7b5d3cc0d))
43
+ * **api:** generate the OpenAPI document without hapi-swagger ([4a87b29](https://github.com/postalsys/emailengine/commit/4a87b2953d136cbc1f9e44786c7dab2d3ce1cc34))
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * **api:** declare the success response for streaming and binary endpoints ([633362e](https://github.com/postalsys/emailengine/commit/633362e14924ee57709d18405794577285cf287f))
49
+ * **assignment:** do not 500 when an account is created before the first worker is ready ([7c8e5df](https://github.com/postalsys/emailengine/commit/7c8e5dfaf8e06458b124b5c740a1ad917ff76f94))
50
+ * **deps:** update dependencies (@postalsys/ee-client 1.7.0) ([9c440b2](https://github.com/postalsys/emailengine/commit/9c440b2c4e94f975267a0562022bdebc86524c9f))
51
+ * **encrypt:** rotate every stored secret, not just the ones the tool remembered ([35a2cc0](https://github.com/postalsys/emailengine/commit/35a2cc0886c718945f94989799aeef7cda1db8f3))
52
+ * **imapproxy:** keep an error sink on the upstream proxy connection ([653259d](https://github.com/postalsys/emailengine/commit/653259d7e5a9558489eccea1ead8c50856274dd2))
53
+ * **oauth2:** honor useAuthServer on the IMAP and SMTP paths ([0c5c43d](https://github.com/postalsys/emailengine/commit/0c5c43da4b4190bba4e41ecbfa4c24b2e8627397))
54
+ * **openapi:** do not shadow require() in the schema converter ([a63bf90](https://github.com/postalsys/emailengine/commit/a63bf90435eef459513e78f7ed549607923d428a))
55
+ * **tokens:** reap expired tokens from the listing, not only on use ([2564831](https://github.com/postalsys/emailengine/commit/2564831d1b533b26a0c07dabd981a01a36c21e08))
56
+
3
57
  ## [2.76.0](https://github.com/postalsys/emailengine/compare/v2.75.0...v2.76.0) (2026-07-29)
4
58
 
5
59
 
package/README.md CHANGED
@@ -58,7 +58,7 @@ A headless email client application that provides access to IMAP, SMTP, Gmail AP
58
58
 
59
59
  - [Documentation](https://learn.emailengine.app/)
60
60
  - [API Reference](https://learn.emailengine.app/docs/api/emailengine-api)
61
- - OpenAPI specification for Postman and code generators: every instance serves its own at `/swagger.json`, or use the hosted copy at [emailengine.dev/swagger.json](https://emailengine.dev/swagger.json)
61
+ - OpenAPI specification for Postman and code generators: every instance serves its own at `/swagger.json`. To work against a specific version instead, download [the copy published with each release](https://go.emailengine.app/swagger.json) - it describes exactly the release it ships with, while [emailengine.dev/swagger.json](https://emailengine.dev/swagger.json) tracks the latest build.
62
62
 
63
63
  ## Configuring EmailEngine
64
64
 
@@ -14,7 +14,7 @@ const getSecret = require('../lib/get-secret');
14
14
  const { redis } = require('../lib/db');
15
15
 
16
16
  const argv = require('minimist')(process.argv.slice(2));
17
- const msgpack = require('msgpack5')();
17
+ const msgpack = require('../lib/msgpack');
18
18
  const crypto = require('crypto');
19
19
 
20
20
  // Command definitions for dynamic help generation
@@ -1,5 +1,5 @@
1
1
  {
2
- "creationTime": "2026-07-29T14:46:26.000000",
2
+ "creationTime": "2026-08-11T14:47:00.000000",
3
3
  "prefixes": [
4
4
  {
5
5
  "ipv6Prefix": "2001:4860:4801:2008::/64"
package/encrypt.js CHANGED
@@ -16,9 +16,10 @@ const config = require('@zone-eu/wild-config');
16
16
  const { encrypt, decrypt, parseEncryptedData } = require('./lib/encrypt');
17
17
  const { encryptedKeys } = require('./lib/settings');
18
18
  const getSecret = require('./lib/get-secret');
19
- const msgpack = require('msgpack5')();
19
+ const msgpack = require('./lib/msgpack');
20
20
 
21
- const { REDIS_PREFIX } = require('./lib/consts');
21
+ const { REDIS_PREFIX, ENCRYPTED_APP_KEYS } = require('./lib/consts');
22
+ const { Settings: CertSettings } = require('@postalsys/certs/lib/settings');
22
23
 
23
24
  const DECRYPT_PASSWORDS = [].concat(config.decrypt || []);
24
25
 
@@ -175,7 +176,10 @@ async function main() {
175
176
  console.log(`Updated ${updatedAccounts}/${accounts.length} accounts`);
176
177
 
177
178
  let updatedGateways = 0;
178
- let gateways = await redis.smembers(`${REDIS_PREFIX}ia:gateways`);
179
+ // NB: the index set is `gateways`, not `ia:gateways` - see lib/gateway.js. Reading the wrong
180
+ // key made this loop report `0/0` on every rotation while leaving gateway passwords encrypted
181
+ // with the old secret.
182
+ let gateways = await redis.smembers(`${REDIS_PREFIX}gateways`);
179
183
  for (let gateway of gateways) {
180
184
  let pass = await redis.hget(`${REDIS_PREFIX}gateway:${gateway}`, 'pass');
181
185
  if (!pass) {
@@ -218,7 +222,7 @@ async function main() {
218
222
 
219
223
  try {
220
224
  let appUpdated = false;
221
- for (let key of ['clientSecret', 'serviceKey', 'accessToken']) {
225
+ for (let key of ENCRYPTED_APP_KEYS) {
222
226
  if (entry[key]) {
223
227
  let value = await processSecret(entry[key], encryptSecret);
224
228
  if (value !== entry[key]) {
@@ -238,11 +242,74 @@ async function main() {
238
242
  updatedApps++;
239
243
  }
240
244
  } catch (err) {
241
- console.error(`Could not process "pass" for OAuth2 App ${app}. Check decryption secrets.`);
245
+ console.error(`Could not process encrypted values for OAuth2 App ${app}. Check decryption secrets.`);
242
246
  }
243
247
  }
244
248
 
245
249
  console.log(`Updated ${updatedApps}/${apps.length} OAuth2 apps`);
250
+
251
+ // TLS private keys managed by @postalsys/certs. These live in the module's own hash, not in the
252
+ // EmailEngine settings hash, so they need their own pass - without it a rotation leaves the ACME
253
+ // account key and every domain key readable only with the old secret, and TLS fails on the next
254
+ // renewal with no self-healing path. Every field in that hash is msgpack encoded; only the ACME
255
+ // account's `privateKey` and the `domain:<name>:privateKey` entries hold encrypted values.
256
+ let updatedCerts = 0;
257
+ // Ask the library for the key instead of rebuilding it here: the namespace it is constructed
258
+ // with is `${REDIS_PREFIX}`, and it appends its own separator, so the hash is
259
+ // `certs:settings` unprefixed but `<prefix>::certs:settings` when EENGINE_REDIS_PREFIX is set.
260
+ let certsKey = CertSettings.create({ namespace: `${REDIS_PREFIX}` }).getKey('settings');
261
+ let certEntries = await redis.hgetallBuffer(certsKey);
262
+ for (let field of Object.keys(certEntries || {})) {
263
+ let isAcmeAccount = /^account:/.test(field);
264
+ let isDomainKey = /^domain:.*:privateKey$/.test(field);
265
+ if (!isAcmeAccount && !isDomainKey) {
266
+ continue;
267
+ }
268
+
269
+ let entry;
270
+ try {
271
+ entry = msgpack.decode(certEntries[field]);
272
+ } catch (err) {
273
+ console.log(`Certificate entry ${field}: failed to parse`);
274
+ continue;
275
+ }
276
+
277
+ try {
278
+ let value;
279
+ if (isAcmeAccount) {
280
+ if (!entry || !entry.privateKey) {
281
+ continue;
282
+ }
283
+ let updated = await processSecret(entry.privateKey, encryptSecret);
284
+ if (updated === entry.privateKey) {
285
+ continue;
286
+ }
287
+ entry.privateKey = updated;
288
+ value = entry;
289
+ } else {
290
+ if (!entry) {
291
+ continue;
292
+ }
293
+ let updated = await processSecret(entry, encryptSecret);
294
+ if (updated === entry) {
295
+ continue;
296
+ }
297
+ value = updated;
298
+ }
299
+
300
+ let result = await redis.hmset(certsKey, { [field]: msgpack.encode(value) });
301
+ if (result === 'OK') {
302
+ console.log(`Certificate entry ${field}: updated`);
303
+ } else {
304
+ console.log(`Certificate entry ${field}: Unexpected response from DB: ${result}`);
305
+ }
306
+ updatedCerts++;
307
+ } catch (err) {
308
+ console.error(`Could not process "${field}". Check decryption secrets.`);
309
+ }
310
+ }
311
+
312
+ console.log(`Updated ${updatedCerts} TLS private keys`);
246
313
  }
247
314
 
248
315
  main()
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ const { REDIS_PREFIX } = require('../consts');
4
+
5
+ // An account can carry an expected identity: the address that must own it, set by an authenticated API
6
+ // caller through `expectedEmail` on POST /v1/authentication/form, POST /v1/account or
7
+ // PUT /v1/account/{account}. Every interactive setup checks it before writing credentials.
8
+ //
9
+ // How strong that is depends on the arm, and the difference is not cosmetic. On OAuth2 the provider
10
+ // vouches for the identity, so the pin genuinely stops someone binding a different mailbox. On IMAP the
11
+ // only evidence is what was typed into the form: the submitted address is checked, but the credentials
12
+ // beside it are a separate field, so a hand-crafted POST can still register the pinned address against a
13
+ // mailbox it does not own. The IMAP guarantee is therefore "the account is registered under the expected
14
+ // address", not "the account holds that mailbox". Do not restate it more strongly than that.
15
+ //
16
+ // Everything the two arms must agree on lives here - where the expectation is read from, which one wins,
17
+ // and what counts as a match - because the arms are 1500 lines apart in different workers and any of
18
+ // those drifting is a silently weaker constraint. How a rejection is PRESENTED is deliberately not here:
19
+ // both arms render views/account-identity-error.hbs, but only each arm knows where "try again" leads.
20
+ //
21
+ // What counts as EVIDENCE is the one thing each arm supplies itself, because it genuinely differs:
22
+ //
23
+ // OAuth2 - the addresses the provider returned over a back-channel. Caller-supplied hints
24
+ // (accountData.email, oauth2.auth.delegatedUser) are excluded on purpose, so for a delegated
25
+ // or shared mailbox the expectation must name the authenticating principal, not the mailbox.
26
+ // IMAP - the address submitted on the form. The credentials still have to authenticate against the
27
+ // server, but nothing proves the address belongs to that mailbox, so the guarantee is the
28
+ // weaker "the account is registered under the expected address".
29
+
30
+ function normalizeEmail(value) {
31
+ return typeof value === 'string' ? value.trim().toLowerCase() : '';
32
+ }
33
+
34
+ // Fails closed: an empty expectation is not a licence to skip the check (callers must not call it in that
35
+ // case), and an empty or unusable identity list means we learned nothing about who authenticated, which
36
+ // is a rejection rather than a pass. That also makes a future provider that forgets to collect its
37
+ // identities reject setups instead of silently admitting them.
38
+ function matchesExpectedIdentity(expectedEmail, identities) {
39
+ const expected = normalizeEmail(expectedEmail);
40
+ if (!expected || !Array.isArray(identities)) {
41
+ return false;
42
+ }
43
+
44
+ return identities.some(identity => normalizeEmail(identity) === expected);
45
+ }
46
+
47
+ // The expectation that applies to a setup: the one carried by the signed form blob, or failing that the
48
+ // one already pinned to the account it targets.
49
+ //
50
+ // The blob wins because it is a deliberate re-statement by the authenticated caller, and that is what
51
+ // gives a legitimate mailbox migration a way through. A blob carrying none (an older link, or the admin
52
+ // re-authenticate blob) inherits the stored pin instead of clearing it, which is what makes the
53
+ // constraint outlive the single link that introduced it.
54
+ //
55
+ // Redis is read lazily, only on that fallback: a pinned link would otherwise pay a round trip for a value
56
+ // it always discards. Reads the field directly rather than through Account.loadAccountData(), which
57
+ // hgetalls and decrypts the whole record - same single-field pattern as getAccountState().
58
+ // The expectation carried by a pending OAuth2 setup, whichever of the two shapes it arrives in.
59
+ //
60
+ // Both are written by the server for an authenticated caller and stored under a random nonce, so they are
61
+ // equally trustworthy - they differ only because two entry points build the pending record differently.
62
+ // The hosted form (lib/ui-routes/account-routes.js) copies the field into `_meta` alongside redirectUrl;
63
+ // POST /v1/account with oauth2.authorize stores the request payload as-is and rebuilds `_meta` from
64
+ // scratch, leaving the field at the top level. Reading only `_meta` silently skipped the check on that
65
+ // second path - on the very setup that decides which mailbox the account gets bound to - while still
66
+ // persisting the pin afterwards, so the constraint looked active when it had never run.
67
+ function pendingSetupExpectation(accountData, accountMeta) {
68
+ return (accountMeta && accountMeta.expectedEmail) || (accountData && accountData.expectedEmail) || null;
69
+ }
70
+
71
+ // Returns the normalized form, so what gets persisted back onto the account does not depend on which
72
+ // branch produced it or on how the caller happened to capitalize the address.
73
+ async function resolveExpectedIdentity(redis, opts) {
74
+ const { account, blobExpectation } = opts || {};
75
+
76
+ const fromBlob = normalizeEmail(blobExpectation);
77
+ if (fromBlob) {
78
+ return fromBlob;
79
+ }
80
+
81
+ if (!account) {
82
+ return null;
83
+ }
84
+
85
+ return normalizeEmail(await redis.hget(`${REDIS_PREFIX}iad:${account}`, 'expectedEmail')) || null;
86
+ }
87
+
88
+ module.exports = { normalizeEmail, matchesExpectedIdentity, pendingSetupExpectation, resolveExpectedIdentity };