emailengine-app 2.77.0 → 2.79.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 (189) hide show
  1. package/.github/workflows/test.yml +80 -0
  2. package/.ncurc.js +23 -13
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +60 -0
  5. package/bin/emailengine.js +1 -1
  6. package/config/e2e.toml +2 -1
  7. package/config/test.toml +2 -1
  8. package/data/google-crawlers.json +1 -1
  9. package/encrypt.js +1 -1
  10. package/lib/account/expected-identity.js +88 -0
  11. package/lib/account.js +145 -61
  12. package/lib/api-reference/format.js +105 -4
  13. package/lib/api-reference/index.js +24 -7
  14. package/lib/api-reference/model.js +148 -21
  15. package/lib/api-reference/schema-tree.js +282 -28
  16. package/lib/api-routes/account-routes.js +99 -36
  17. package/lib/api-routes/behavior-notes.js +3 -0
  18. package/lib/api-routes/blocklist-routes.js +21 -47
  19. package/lib/api-routes/chat-routes.js +10 -12
  20. package/lib/api-routes/delivery-test-routes.js +6 -26
  21. package/lib/api-routes/export-routes.js +2 -0
  22. package/lib/api-routes/gateway-routes.js +52 -11
  23. package/lib/api-routes/license-routes.js +2 -0
  24. package/lib/api-routes/mailbox-routes.js +29 -26
  25. package/lib/api-routes/message-routes.js +27 -21
  26. package/lib/api-routes/oauth2-app-routes.js +11 -29
  27. package/lib/api-routes/operation-impact.js +80 -0
  28. package/lib/api-routes/outbox-routes.js +15 -5
  29. package/lib/api-routes/permission-map.js +397 -0
  30. package/lib/api-routes/route-helpers.js +223 -9
  31. package/lib/api-routes/route-metadata.js +28 -0
  32. package/lib/api-routes/settings-routes.js +30 -25
  33. package/lib/api-routes/stats-routes.js +2 -2
  34. package/lib/api-routes/submit-routes.js +53 -31
  35. package/lib/api-routes/template-routes.js +3 -0
  36. package/lib/api-routes/token-routes.js +319 -33
  37. package/lib/api-routes/webhook-route-routes.js +14 -4
  38. package/lib/append-list.js +3 -14
  39. package/lib/arf-detect.js +23 -1
  40. package/lib/auth-token.js +80 -8
  41. package/lib/autodetect-imap-settings.js +40 -16
  42. package/lib/base32.js +30 -0
  43. package/lib/bounce-detect.js +182 -62
  44. package/lib/consts.js +10 -0
  45. package/lib/db.js +20 -2
  46. package/lib/delivery-error.js +30 -1
  47. package/lib/egress-filter.js +89 -8
  48. package/lib/email-client/base-client.js +35 -113
  49. package/lib/email-client/gmail-client.js +22 -13
  50. package/lib/email-client/imap/listing-diff.js +3 -3
  51. package/lib/email-client/imap/mailbox.js +28 -93
  52. package/lib/email-client/imap/subconnection.js +10 -7
  53. package/lib/email-client/imap/sync-operations.js +46 -46
  54. package/lib/email-client/imap-client.js +39 -28
  55. package/lib/email-client/message-builder.js +15 -15
  56. package/lib/email-client/notification-handler.js +1 -1
  57. package/lib/email-client/outlook/graph-api.js +10 -4
  58. package/lib/email-client/outlook-client.js +54 -55
  59. package/lib/email-client/smtp-pool-manager.js +1 -1
  60. package/lib/enum-descriptions.js +92 -2
  61. package/lib/export.js +2 -2
  62. package/lib/field-usage.js +133 -0
  63. package/lib/gateway.js +2 -2
  64. package/lib/get-raw-email.js +1 -1
  65. package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
  66. package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
  67. package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
  68. package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
  69. package/lib/imapproxy/imap-core/lib/imap-connection.js +17 -7
  70. package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
  71. package/lib/imapproxy/imap-server.js +40 -10
  72. package/lib/license-beacon.js +5 -10
  73. package/lib/lists.js +49 -1
  74. package/lib/llm-pre-process.js +6 -6
  75. package/lib/logger.js +5 -1
  76. package/lib/metrics-collector.js +2 -2
  77. package/lib/msgpack.js +62 -0
  78. package/lib/oauth/decode-jwt-payload.js +39 -0
  79. package/lib/oauth/gmail.js +9 -12
  80. package/lib/oauth/mail-ru.js +5 -7
  81. package/lib/oauth/outlook-identity.js +61 -0
  82. package/lib/oauth/outlook.js +9 -9
  83. package/lib/oauth/pubsub/google.js +25 -10
  84. package/lib/oauth/retry-setup.js +38 -0
  85. package/lib/oauth/scope-checker.js +1 -1
  86. package/lib/oauth2-apps.js +224 -295
  87. package/lib/openapi/build-document.js +15 -7
  88. package/lib/openapi/joi-schema.js +20 -0
  89. package/lib/outbox.js +145 -14
  90. package/lib/pre-process.js +9 -9
  91. package/lib/queue-stats.js +49 -0
  92. package/lib/read-env-value.js +37 -0
  93. package/lib/reconnection-manager.js +2 -2
  94. package/lib/rewrite-text-nodes.js +4 -3
  95. package/lib/routes-ui.js +4 -0
  96. package/lib/schemas.js +223 -155
  97. package/lib/settings.js +84 -5
  98. package/lib/sub-script.js +2 -1
  99. package/lib/swagger-options.js +2 -1
  100. package/lib/templates.js +5 -5
  101. package/lib/threads.js +2 -2
  102. package/lib/token-audit-log.js +208 -0
  103. package/lib/token-permission-view.js +219 -0
  104. package/lib/token-permissions.js +172 -0
  105. package/lib/tokens.js +100 -16
  106. package/lib/tools.js +259 -85
  107. package/lib/totp.js +67 -0
  108. package/lib/ui-routes/account-routes.js +122 -26
  109. package/lib/ui-routes/admin-config-routes.js +20 -17
  110. package/lib/ui-routes/admin-entities-routes.js +66 -22
  111. package/lib/ui-routes/auth-routes.js +36 -48
  112. package/lib/ui-routes/export-routes.js +10 -4
  113. package/lib/ui-routes/oauth-config-routes.js +5 -5
  114. package/lib/ui-routes/reference-routes.js +11 -8
  115. package/lib/ui-routes/route-helpers.js +79 -2
  116. package/lib/ui-routes/settings-page.js +1 -1
  117. package/lib/ui-routes/smtp-test-routes.js +1 -1
  118. package/lib/ui-routes/suppression-list-routes.js +294 -0
  119. package/lib/ui-routes/unsubscribe-routes.js +19 -29
  120. package/lib/utils/is-email.js +34 -0
  121. package/lib/utils/network.js +2 -2
  122. package/lib/utils/to-camel-case.js +17 -0
  123. package/lib/web-safe-html.js +1 -1
  124. package/lib/webhook-egress.js +37 -0
  125. package/lib/webhook-routing.js +80 -0
  126. package/lib/webhooks.js +21 -15
  127. package/package.json +26 -27
  128. package/sbom.json +1 -0
  129. package/server.js +81 -42
  130. package/static/css/flyonui.css +1 -1
  131. package/static/css/public.css +3 -0
  132. package/static/css/src/app.tailwind.css +159 -9
  133. package/static/js/app.js +69 -0
  134. package/static/js/reference.js +741 -10
  135. package/static/js/ui.js +43 -0
  136. package/static/licenses.html +698 -1590
  137. package/translations/README.md +64 -0
  138. package/translations/de.mo +0 -0
  139. package/translations/de.po +164 -120
  140. package/translations/en.po +200 -161
  141. package/translations/et.mo +0 -0
  142. package/translations/et.po +163 -120
  143. package/translations/fr.mo +0 -0
  144. package/translations/fr.po +163 -120
  145. package/translations/ja.mo +0 -0
  146. package/translations/ja.po +163 -120
  147. package/translations/messages.pot +94 -64
  148. package/translations/nl.mo +0 -0
  149. package/translations/nl.po +164 -120
  150. package/translations/pl.mo +0 -0
  151. package/translations/pl.po +163 -120
  152. package/views/account-identity-error.hbs +34 -0
  153. package/views/accounts/account.hbs +69 -7
  154. package/views/accounts/browse.hbs +18 -35
  155. package/views/accounts/edit.hbs +1 -0
  156. package/views/accounts/register/imap.hbs +12 -2
  157. package/views/config/logging.hbs +6 -0
  158. package/views/config/oauth/app.hbs +0 -2
  159. package/views/config/security.hbs +13 -0
  160. package/views/layout/app.hbs +29 -5
  161. package/views/oauth-scope-error.hbs +1 -1
  162. package/views/partials/oauth_form.hbs +0 -15
  163. package/views/partials/reference/disclosure.hbs +8 -2
  164. package/views/partials/reference/nav.hbs +36 -9
  165. package/views/partials/reference/operation.hbs +48 -14
  166. package/views/partials/reference/params.hbs +17 -1
  167. package/views/partials/reference/schema-node.hbs +112 -54
  168. package/views/partials/reference/schema-tools.hbs +25 -0
  169. package/views/partials/reference/token-alert.hbs +35 -10
  170. package/views/partials/reference/try-it.hbs +84 -11
  171. package/views/partials/side_menu.hbs +1 -0
  172. package/views/partials/ui/checkbox.hbs +2 -2
  173. package/views/partials/ui/tabs.hbs +7 -1
  174. package/views/reference/index.hbs +1 -1
  175. package/views/reference/token.hbs +4 -0
  176. package/views/suppression-lists/index.hbs +85 -0
  177. package/views/suppression-lists/list.hbs +87 -0
  178. package/views/templates/index.hbs +8 -2
  179. package/views/tokens/index.hbs +31 -4
  180. package/views/tokens/new.hbs +324 -2
  181. package/workers/api.js +299 -140
  182. package/workers/documents.js +46 -26
  183. package/workers/export.js +20 -8
  184. package/workers/imap-proxy.js +2 -2
  185. package/workers/imap.js +13 -7
  186. package/workers/smtp.js +13 -7
  187. package/workers/submit.js +41 -31
  188. package/workers/webhooks.js +60 -37
  189. package/lib/feature-flags.js +0 -48
@@ -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
@@ -1,26 +1,36 @@
1
1
  module.exports = {
2
2
  upgrade: true,
3
+ // Node 20 is a hard runtime floor, not a preference. The DigitalOcean one-click images run
4
+ // EmailEngine on Node 20 and ship an upgrade script for EmailEngine but none for Node, so those
5
+ // installs keep self-updating on a runtime that never moves; raising the floor breaks them on
6
+ // their next upgrade. Node 20 being EOL upstream, and CI and the pkg targets being on Node 24,
7
+ // do not lift this. Treat "needs Node >20" as a permanent reject.
8
+ //
3
9
  // Packages capped inside their current major: the next major is ESM-only (this codebase is
4
- // CommonJS and is bundled into a binary with pkg) or it breaks a peer dependency. Using 'minor'
5
- // instead of a blanket reject so these still receive security/patch updates within the safe
6
- // major instead of being frozen at one exact version. Verified against Node 20 (Docker) 2026-06-17.
7
- target: name =>
8
- ['nanoid', 'ical.js', 'gettext-parser', 'xgettext-template', 'chai', 'undici', 'marked', 'bullmq', 'ioredis'].includes(name) ? 'minor' : 'latest',
10
+ // CommonJS and is bundled into a binary with pkg), needs a Node newer than the floor above, or
11
+ // is a major we are deliberately soaking. Using 'minor' instead of a blanket reject so these
12
+ // still receive security/patch updates within the safe major instead of being frozen at one
13
+ // exact version. Verified against Node 20 (Docker) 2026-06-17.
14
+ target: name => (['nanoid', 'ical.js', 'gettext-parser', 'xgettext-template', 'chai', 'undici', 'marked'].includes(name) ? 'minor' : 'latest'),
9
15
  // nanoid - 4.x dropped the CommonJS require export (ESM-only)
10
16
  // ical.js - 2.x is ESM-only
11
17
  // gettext-parser - 8.x is ESM-only
12
18
  // xgettext-template - 6.x is ESM-only (translation build tool)
13
19
  // chai - 5.x is ESM-only (only used by the vendored imap-core tests)
14
- // undici - 8.x requires Node >=22.19 and crashes at require() on Node 20; EmailEngine supports Node 20+
20
+ // undici - 8.x requires Node >=22.19 and crashes at require() on Node 20. Permanent while the
21
+ // Node 20 floor above stands.
15
22
  // marked - 16.x dropped the CommonJS build (ESM-only, needs require(esm)/Node >=20.19); 15.x is the
16
23
  // 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
+ // Permanent while the Node 20 floor above stands.
25
+ //
26
+ // bullmq was capped at 5.x until 2026-08-17, when both stated reasons had expired. Now on 6.x, which
27
+ // moves cron-parser off the deprecated 4.9.0 onto 5.x - but not off luxon, which cron-parser depends
28
+ // on in both majors.
29
+ //
30
+ // ioredis was capped at 5.x for the same span, held there BY the bullmq cap (bullmq 5 carried ioredis
31
+ // as a direct dependency; 6.x demoted it to an optional peer, which dissolved the coupling). Now on
32
+ // 6.x, whose one breaking change is that it speaks RESP3 by default - taken as-is, since RESP3 was
33
+ // verified against everything here that could plausibly differ (see the commit that made the move).
24
34
  //
25
35
  // joi used to be capped here because hapi-swagger peer-required 17.x. That dependency is gone
26
36
  // (the OpenAPI document is generated by lib/openapi/ now), so joi may move majors again. A major
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "2.77.0"
2
+ ".": "2.79.0"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.79.0](https://github.com/postalsys/emailengine/compare/v2.78.0...v2.79.0) (2026-08-18)
4
+
5
+
6
+ ### Features
7
+
8
+ * **lists:** add suppression list management to the admin UI ([d684030](https://github.com/postalsys/emailengine/commit/d6840305a3dc0940f248c12e650e068aed866e28))
9
+ * **lists:** link suppression entries to the subscription management page ([b4e1d49](https://github.com/postalsys/emailengine/commit/b4e1d49ff105d95f24462b8ceb0f80b453378cc9))
10
+ * **oauth2:** migrate legacy settings-based OAuth2 apps into the app registry ([4aeb7f5](https://github.com/postalsys/emailengine/commit/4aeb7f5bee45d0ec32ab17d72252bf8d13b57018))
11
+ * **reference:** confirm irreversible Try it requests before running them ([546c32e](https://github.com/postalsys/emailengine/commit/546c32e352a70061ae188c59f54b78933d2bde20))
12
+ * **reference:** edit Try it request bodies in a JSON editor ([dbd38e8](https://github.com/postalsys/emailengine/commit/dbd38e857f16a1ce28c86a32a9105b0e5cb36ca6))
13
+ * **reference:** make large schemas readable in the API reference ([9874821](https://github.com/postalsys/emailengine/commit/9874821288f543d531af757366eced663b738705))
14
+ * **reference:** show an example value and usage guidance for every field ([c974f19](https://github.com/postalsys/emailengine/commit/c974f19e393c6d7519c3599b772a58a898f7c4ce))
15
+ * **reference:** warn in Try it only where running the request has a consequence ([4f53d02](https://github.com/postalsys/emailengine/commit/4f53d02d068f88707419aaffecee6618b2f0bd71))
16
+ * **sentry:** enable error reporting by default for trial licenses ([9c918bc](https://github.com/postalsys/emailengine/commit/9c918bcb9cbb45113c1006db649a6fbf871c6c81))
17
+ * **tokens:** granular access token permissions ([#633](https://github.com/postalsys/emailengine/issues/633)) ([f30bf0a](https://github.com/postalsys/emailengine/commit/f30bf0a838958f64a057afe8f44767a0b3de306a))
18
+ * **webhooks:** show the effective webhook routing on the account page ([0cdbbff](https://github.com/postalsys/emailengine/commit/0cdbbffacfc19ed7af2ef200061edd7e06930b26))
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **deps:** move to ioredis 6 ([da4904a](https://github.com/postalsys/emailengine/commit/da4904aba141f7fffeef2200a726254994ae3f9b))
24
+ * **deps:** override deepmerge-ts to clear GHSA-ggr8-5vv4-36mx ([#635](https://github.com/postalsys/emailengine/issues/635)) ([6d68432](https://github.com/postalsys/emailengine/commit/6d6843217ee5246e150e66307e2c2bae94fbc89b))
25
+ * **deps:** refresh dependencies and dedupe node-html-parser ([5502c04](https://github.com/postalsys/emailengine/commit/5502c0467da52eb2d285c1a057818d6c0eb7694e))
26
+ * **logging:** standardize log levels and keep credentials out of error logs ([a229bdc](https://github.com/postalsys/emailengine/commit/a229bdca3b8662338db889568fa132503c5e89c9))
27
+ * **queues:** move to BullMQ 6 and fix outbox paging ([eba0761](https://github.com/postalsys/emailengine/commit/eba0761f162c2561bab81460b481743e42ab4608))
28
+ * **reference:** count the minted token's expiry down while the page is open ([356dfd0](https://github.com/postalsys/emailengine/commit/356dfd0ac9178bcd2ad007f351c2ded3af0936ce))
29
+ * **ui:** share the confirm dialog helper and stop the reference page scrolling sideways ([994ddec](https://github.com/postalsys/emailengine/commit/994ddec7d42c91c1a7ea5167cfe5ee6df689b4d2))
30
+ * **ui:** stop partial blocks from losing content wrapped in a bare condition ([0887172](https://github.com/postalsys/emailengine/commit/0887172c4fe18d23c8a3bd9f9d26249fc7551a9a))
31
+
32
+ ## [2.78.0](https://github.com/postalsys/emailengine/compare/v2.77.0...v2.78.0) (2026-08-12)
33
+
34
+
35
+ ### Features
36
+
37
+ * **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)
38
+ * **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))
39
+ * **admin:** mark the operation being read in the API reference sidebar ([700eab7](https://github.com/postalsys/emailengine/commit/700eab7716bec0362b73bf5e8f498be971071e7e))
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * **accounts:** let a wrong-account setup be retried instead of bouncing it back ([4cd6ac4](https://github.com/postalsys/emailengine/commit/4cd6ac4d0b935244accc55b1f9abb41cf906a2dc))
45
+ * **accounts:** remove the messages an account had queued when it is deleted ([ba6897f](https://github.com/postalsys/emailengine/commit/ba6897f4a5966a1a0dcddd7c514a3804e31591c4))
46
+ * **auth:** replace unmaintained speakeasy and base32.js with in-house implementations ([9abaaaa](https://github.com/postalsys/emailengine/commit/9abaaaa4cfd1869788238db80860bbbb77694ed3))
47
+ * **bounces:** read every block of a delivery-status body ([a99878e](https://github.com/postalsys/emailengine/commit/a99878eaf2970b36a7cc0ac50a725292405c6ab3))
48
+ * **bounces:** report every delivery-status field and describe one recipient ([71300c3](https://github.com/postalsys/emailengine/commit/71300c3fcf72065764857b1e90f43626b5e258e7))
49
+ * **deps:** replace deprecated msgpack5 with @msgpack/msgpack behind a compatibility wrapper ([9c40ebc](https://github.com/postalsys/emailengine/commit/9c40ebcc5b61993dad3f6979caab8cb8632b6ad0))
50
+ * **deps:** replace stagnant xml2js with fast-xml-parser in IMAP settings autodetection ([bfd6ec5](https://github.com/postalsys/emailengine/commit/bfd6ec5e7f0925fd3b0fb16a2a7490aa2cb14c27))
51
+ * **deps:** update dependencies (libmime 5.4.2, nodemailer 9.0.5, imapflow 1.6.6) ([abd8034](https://github.com/postalsys/emailengine/commit/abd8034d1e365c5e523a361a0379649fa9c6c29c))
52
+ * **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))
53
+ * **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))
54
+ * **deps:** update our own packages so the tree carries one copy of each ([4a6e79f](https://github.com/postalsys/emailengine/commit/4a6e79fcaf2d11a35870e557c4a8e6756d05b4b4))
55
+ * **oauth2:** fall back to stored credentials when useAuthServer is set but no auth server is configured ([cd460b0](https://github.com/postalsys/emailengine/commit/cd460b056673c5b148760ba25b670c4e75f1f344))
56
+ * **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))
57
+
58
+
59
+ ### Performance Improvements
60
+
61
+ * **accounts:** unlink the account keys instead of deleting them inline ([ec11210](https://github.com/postalsys/emailengine/commit/ec11210a750021c1ccbf2df3637816974c0f995c))
62
+
3
63
  ## [2.77.0](https://github.com/postalsys/emailengine/compare/v2.76.0...v2.77.0) (2026-08-03)
4
64
 
5
65
 
@@ -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
package/config/e2e.toml CHANGED
@@ -12,7 +12,8 @@
12
12
  settings = '''
13
13
  {
14
14
  "serviceUrl": "https://e2e.emailengine.app/",
15
- "ignoreMailCertErrors": true
15
+ "ignoreMailCertErrors": true,
16
+ "sentryEnabled": false
16
17
  }
17
18
  '''
18
19
 
package/config/test.toml CHANGED
@@ -14,7 +14,8 @@ settings = '''
14
14
  ],
15
15
  "serviceUrl": "http://127.0.0.1:7077",
16
16
  "ignoreMailCertErrors": true,
17
- "serviceSecret": "a cat"
17
+ "serviceSecret": "a cat",
18
+ "sentryEnabled": false
18
19
  }
19
20
  '''
20
21
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "creationTime": "2026-07-31T14:45:52.000000",
2
+ "creationTime": "2026-08-14T14:46:51.000000",
3
3
  "prefixes": [
4
4
  {
5
5
  "ipv6Prefix": "2001:4860:4801:2008::/64"
package/encrypt.js CHANGED
@@ -16,7 +16,7 @@ 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
21
  const { REDIS_PREFIX, ENCRYPTED_APP_KEYS } = require('./lib/consts');
22
22
  const { Settings: CertSettings } = require('@postalsys/certs/lib/settings');
@@ -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 };