emailengine-app 2.80.1 → 2.81.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/.dockerignore +44 -0
  2. package/.github/docker-smoke-test.sh +16 -0
  3. package/.github/workflows/deploy.yml +4 -0
  4. package/.github/workflows/release.yaml +4 -0
  5. package/.github/workflows/test.yml +2 -0
  6. package/.release-please-manifest.json +1 -1
  7. package/CHANGELOG.md +39 -0
  8. package/Dockerfile +17 -9
  9. package/data/google-crawlers.json +1 -1
  10. package/docker-compose.yml +7 -1
  11. package/lib/api-routes/account-routes.js +158 -72
  12. package/lib/api-routes/permission-map.js +6 -1
  13. package/lib/autodetect-imap-settings.js +4 -4
  14. package/lib/sentry.js +13 -2
  15. package/lib/tls/provision.js +1 -1
  16. package/lib/token-permission-view.js +8 -7
  17. package/lib/tools.js +1 -0
  18. package/lib/ui-routes/account-routes.js +195 -61
  19. package/lib/ui-routes/admin-entities-routes.js +9 -9
  20. package/package.json +19 -19
  21. package/sbom.json +1 -1
  22. package/static/css/flyonui.css +1 -1
  23. package/static/css/public.css +41 -0
  24. package/static/css/src/app.tailwind.css +135 -4
  25. package/static/js/public.js +218 -0
  26. package/static/licenses.html +54 -30
  27. package/translations/README.md +4 -3
  28. package/translations/de.mo +0 -0
  29. package/translations/de.po +296 -185
  30. package/translations/en.po +220 -128
  31. package/translations/es.mo +0 -0
  32. package/translations/es.po +558 -0
  33. package/translations/et.mo +0 -0
  34. package/translations/et.po +288 -181
  35. package/translations/fr.mo +0 -0
  36. package/translations/fr.po +295 -183
  37. package/translations/it.mo +0 -0
  38. package/translations/it.po +558 -0
  39. package/translations/ja.mo +0 -0
  40. package/translations/ja.po +268 -192
  41. package/translations/locales.json +24 -0
  42. package/translations/messages.pot +142 -96
  43. package/translations/nl.mo +0 -0
  44. package/translations/nl.po +288 -175
  45. package/translations/pl.mo +0 -0
  46. package/translations/pl.po +294 -181
  47. package/translations/sv.mo +0 -0
  48. package/translations/sv.po +555 -0
  49. package/translations/tr.mo +0 -0
  50. package/translations/tr.po +555 -0
  51. package/update-info.sh +12 -6
  52. package/views/account/login-redirect.hbs +6 -5
  53. package/views/account/passkeys.hbs +6 -6
  54. package/views/account/security.hbs +2 -2
  55. package/views/accounts/account.hbs +17 -19
  56. package/views/accounts/edit.hbs +14 -14
  57. package/views/accounts/index.hbs +3 -3
  58. package/views/accounts/register/imap-server.hbs +26 -172
  59. package/views/accounts/register/validating.hbs +139 -0
  60. package/views/config/ai.hbs +14 -16
  61. package/views/config/branding.hbs +5 -5
  62. package/views/config/document-store/chat.hbs +8 -7
  63. package/views/config/document-store/index.hbs +13 -14
  64. package/views/config/document-store/mappings/index.hbs +5 -6
  65. package/views/config/document-store/mappings/new.hbs +1 -2
  66. package/views/config/document-store/pre-processing/index.hbs +4 -4
  67. package/views/config/email-processing.hbs +6 -6
  68. package/views/config/imap-proxy.hbs +6 -7
  69. package/views/config/license.hbs +8 -8
  70. package/views/config/logging.hbs +5 -7
  71. package/views/config/mcp.hbs +14 -18
  72. package/views/config/network.hbs +3 -3
  73. package/views/config/oauth/app.hbs +10 -10
  74. package/views/config/oauth/index.hbs +6 -6
  75. package/views/config/oauth/subscriptions.hbs +9 -9
  76. package/views/config/security.hbs +5 -7
  77. package/views/config/service.hbs +10 -9
  78. package/views/config/smtp.hbs +8 -11
  79. package/views/config/tls-upload.hbs +3 -3
  80. package/views/config/tls.hbs +33 -35
  81. package/views/config/webhooks.hbs +10 -13
  82. package/views/dashboard.hbs +9 -8
  83. package/views/gateways/edit.hbs +3 -3
  84. package/views/gateways/gateway.hbs +3 -3
  85. package/views/gateways/index.hbs +6 -6
  86. package/views/gateways/new.hbs +3 -3
  87. package/views/internals/index.hbs +14 -12
  88. package/views/layout/login.hbs +27 -14
  89. package/views/layout/prompt.hbs +12 -15
  90. package/views/mcp/authorize.hbs +1 -1
  91. package/views/partials/accounts_table.hbs +5 -5
  92. package/views/partials/add_account_modal.hbs +3 -3
  93. package/views/partials/address_list.hbs +4 -4
  94. package/views/partials/gateway_form.hbs +5 -5
  95. package/views/partials/mcp_account_limit.hbs +2 -2
  96. package/views/partials/oauth_config_header.hbs +2 -2
  97. package/views/partials/oauth_form.hbs +36 -41
  98. package/views/partials/public_alerts.hbs +1 -1
  99. package/views/partials/public_test_labels.hbs +15 -0
  100. package/views/partials/security_header.hbs +2 -2
  101. package/views/partials/template_form.hbs +3 -3
  102. package/views/partials/tls_security_card.hbs +4 -1
  103. package/views/partials/ui/form-field.hbs +6 -1
  104. package/views/partials/ui/setting-ref.hbs +12 -7
  105. package/views/partials/ui/stat-card.hbs +4 -1
  106. package/views/partials/ui/tabs.hbs +3 -7
  107. package/views/partials/webhook_form.hbs +9 -12
  108. package/views/reference/index.hbs +2 -2
  109. package/views/reference/token.hbs +3 -3
  110. package/views/suppression-lists/index.hbs +8 -6
  111. package/views/suppression-lists/list.hbs +13 -8
  112. package/views/templates/edit.hbs +1 -1
  113. package/views/templates/index.hbs +10 -11
  114. package/views/templates/template.hbs +4 -4
  115. package/views/tokens/index.hbs +17 -17
  116. package/views/tokens/new.hbs +18 -22
  117. package/views/webhooks/edit.hbs +1 -1
  118. package/views/webhooks/index.hbs +10 -11
  119. package/views/webhooks/new.hbs +1 -1
  120. package/views/webhooks/webhook.hbs +4 -5
package/.dockerignore ADDED
@@ -0,0 +1,44 @@
1
+ # The Dockerfile copies an explicit allowlist of paths, so this mostly just keeps the build context
2
+ # from being sent to the daemon - locally that is node_modules and the several hundred megabytes of
3
+ # built binaries in ee-dist. The `**` rules below are the exception: those paths sit inside directories
4
+ # the Dockerfile does copy, so they change what ends up in the image as well.
5
+ #
6
+ # Deliberately a denylist rather than "ignore everything, then un-ignore what is copied": a new COPY
7
+ # in the Dockerfile should just work, not fail on a file this list forgot to let through.
8
+
9
+ .git
10
+ .github
11
+ node_modules
12
+
13
+ # Build outputs and test artifacts
14
+ ee-dist
15
+ dist
16
+ test-results
17
+ blob-report
18
+ playwright-report
19
+ coverage
20
+
21
+ # Not part of the runtime image
22
+ test
23
+ examples
24
+ screenshots
25
+ scripts
26
+ systemd
27
+ manual-test
28
+
29
+ # Local environment, secrets and editor state. keylog.txt is a TLS key log (npm run dev writes one);
30
+ # it is gitignored, but nothing else would keep it out of the context and the layer cache.
31
+ .env*
32
+ keylog.txt
33
+ *.heapsnapshot
34
+ *.cpuprofile
35
+ *.heapprofile
36
+ core.*
37
+ .claude
38
+ .vscode
39
+ .idea
40
+
41
+ # Anchored at every level, not just the root: these turn up inside directories that ARE copied
42
+ # (static/.DS_Store was shipping in the image).
43
+ **/.DS_Store
44
+ **/*.log
@@ -42,4 +42,20 @@ for cmd in scan encrypt; do
42
42
  fi
43
43
  done
44
44
 
45
+ # The image has to be able to say which commit it was built from. update-info.sh writes an empty
46
+ # commit rather than failing when EE_COMMIT_HASH is missing, and the Dockerfile requires the arg
47
+ # precisely so that cannot happen - but the Dockerfile's check is a source-level one, and this is the
48
+ # only place the built artifact is asked the question directly. Also catches the commit being right in
49
+ # the Dockerfile and wrong in the image, e.g. a stale layer replayed from the build cache.
50
+ commit=$(docker run --rm --entrypoint node "$image" -p "require('/emailengine/version-info.json').commit" 2>&1) && rc=0 || rc=$?
51
+
52
+ if [ "$rc" -ne 0 ]; then
53
+ echo "::error::could not read version-info.json from the image"
54
+ printf '%s\n' "$commit"
55
+ status=1
56
+ elif [ -z "${commit//[[:space:]]/}" ] || [ "$commit" = "undefined" ]; then
57
+ echo "::error::the image reports no commit hash - it was built without a usable EE_COMMIT_HASH build arg"
58
+ status=1
59
+ fi
60
+
45
61
  exit $status
@@ -115,6 +115,8 @@ jobs:
115
115
  platforms: ${{ matrix.platform }}
116
116
  load: true
117
117
  tags: emailengine:smoke-test
118
+ build-args: |
119
+ EE_COMMIT_HASH=${{ github.sha }}
118
120
  # Without a cache backend BuildKit starts cold on every run: setup-buildx-action
119
121
  # creates a fresh builder on an ephemeral runner. The scope is per-architecture so
120
122
  # the two legs cannot evict each other's entries.
@@ -136,6 +138,8 @@ jobs:
136
138
  outputs: type=image,"name=docker.io/${{ github.repository }},ghcr.io/${{ github.repository }}",push-by-digest=true,name-canonical=true,push=true
137
139
  cache-from: type=gha,scope=${{ matrix.arch }}
138
140
  cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
141
+ build-args: |
142
+ EE_COMMIT_HASH=${{ github.sha }}
139
143
 
140
144
  - name: Export digest
141
145
  run: |
@@ -116,6 +116,8 @@ jobs:
116
116
  load: true
117
117
  tags: emailengine:smoke-test
118
118
  cache-from: type=gha,scope=${{ matrix.arch }}
119
+ build-args: |
120
+ EE_COMMIT_HASH=${{ github.sha }}
119
121
 
120
122
  - name: Smoke test the CLI inside the image
121
123
  run: bash .github/docker-smoke-test.sh emailengine:smoke-test
@@ -133,6 +135,8 @@ jobs:
133
135
  outputs: type=image,"name=docker.io/${{ github.repository }},ghcr.io/${{ github.repository }}",push-by-digest=true,name-canonical=true,push=true
134
136
  cache-from: type=gha,scope=${{ matrix.arch }}
135
137
  cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
138
+ build-args: |
139
+ EE_COMMIT_HASH=${{ github.sha }}
136
140
 
137
141
  - name: Export digest
138
142
  run: |
@@ -159,6 +159,8 @@ jobs:
159
159
  platforms: linux/amd64
160
160
  load: true
161
161
  tags: emailengine:scan
162
+ build-args: |
163
+ EE_COMMIT_HASH=${{ github.sha }}
162
164
 
163
165
  - name: Scan for known vulnerabilities
164
166
  uses: aquasecurity/trivy-action@v0.36.0
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "2.80.1"
2
+ ".": "2.81.1"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.81.1](https://github.com/postalsys/emailengine/compare/v2.81.0...v2.81.1) (2026-09-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * update dependencies to latest versions ([cd8b72c](https://github.com/postalsys/emailengine/commit/cd8b72c21aa07f8437aa0aebaccbbb40c7ea9c0a))
9
+
10
+ ## [2.81.0](https://github.com/postalsys/emailengine/compare/v2.80.1...v2.81.0) (2026-09-13)
11
+
12
+
13
+ ### Features
14
+
15
+ * **autodiscovery:** let the API carry credentials and the hosted form skip the settings step ([f78b62e](https://github.com/postalsys/emailengine/commit/f78b62ec910899f7de83fbc972a44858f024b6ac))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **api:** skip the server settings step by default for minted setup links ([2c43c60](https://github.com/postalsys/emailengine/commit/2c43c6075614e9765160628a49d1e97f0f94f1c6))
21
+ * **deps:** move the packages that pin nodemailer onto 10.0.9 and dedupe the tree ([db2abd8](https://github.com/postalsys/emailengine/commit/db2abd80319f9ab61406b1d222e357ffbd9ec8b0))
22
+ * **deps:** update bull-board and simplewebauthn ([66ab196](https://github.com/postalsys/emailengine/commit/66ab196f623041a048b32817ad28352e97b3b336))
23
+ * **deps:** update joi-messages to 1.1.3 for the Joi 18 validation messages ([c62b34c](https://github.com/postalsys/emailengine/commit/c62b34cc56fd9ca221cdf1e990ac6145c7536236))
24
+ * **deps:** update nodemailer to 10.0.8 across the packages that pin it ([6dc08f7](https://github.com/postalsys/emailengine/commit/6dc08f7ae47db4a7f537d8a13c3004aa9983a690))
25
+ * **docker:** bump the node:24-alpine base image digest ([7e6808b](https://github.com/postalsys/emailengine/commit/7e6808be64cc099611746492c71fad2b701bdfcf))
26
+ * **docker:** health-check the container over 127.0.0.1, not localhost ([31ab205](https://github.com/postalsys/emailengine/commit/31ab2051ca22d2da45c2079f6581babbdebb0659))
27
+ * **docker:** pass the commit hash as a build arg instead of reading a branch ref ([c2c03c8](https://github.com/postalsys/emailengine/commit/c2c03c884ce061ad215ae612eaaafef00bf513ba))
28
+ * **i18n:** fill the empty plural forms in the certificate count ([d51803d](https://github.com/postalsys/emailengine/commit/d51803d89125f962235d05cac5c2f5a1e80900e2))
29
+ * **i18n:** improve translation wording and consistency ([576e692](https://github.com/postalsys/emailengine/commit/576e6924432beef0d0261a578494d703cf04d397))
30
+ * **i18n:** translate the remaining hosted form labels and refresh the catalogs ([b04784c](https://github.com/postalsys/emailengine/commit/b04784ce7eed212b324b4e4dd39a9afcafd47da3))
31
+ * **sentry:** report the release with its package prefix so Sentry can order versions ([7bda29f](https://github.com/postalsys/emailengine/commit/7bda29fdeb6b59bade892570971c0ca12f892a44))
32
+ * **sso:** stop the forced-SSO hand-off flashing the login page before it leaves ([9e64618](https://github.com/postalsys/emailengine/commit/9e646188feaced2ea77342abd4e6de49ad6ed169))
33
+ * **test:** fail a stalled test run instead of waiting for the CI job to be killed ([9631512](https://github.com/postalsys/emailengine/commit/9631512af363dd0b33b28f4c2ce4e2f996042b9d))
34
+ * **test:** follow the admin copy pass into the two specs it broke ([1524368](https://github.com/postalsys/emailengine/commit/1524368de4b49a176b4338e810503bdca08fac3d))
35
+ * **test:** force the test runner to exit so one leaked handle cannot hang a tier ([bbdccdb](https://github.com/postalsys/emailengine/commit/bbdccdb6af747ff96ee70ce688c275886d528d8c))
36
+ * **translations:** add Spanish, Italian and Turkish for the public UI ([d2089c3](https://github.com/postalsys/emailengine/commit/d2089c3c6ab0a4b0c49e2d76a4fa62dc642bdd58))
37
+ * **translations:** add Swedish for the public UI ([048c086](https://github.com/postalsys/emailengine/commit/048c0869b1645548be61cb77c0149963a8ac21af))
38
+ * **ui:** make the admin copy consistent and say what each screen actually does ([d7bb57d](https://github.com/postalsys/emailengine/commit/d7bb57d949c8836c6946d3a9f53d3147e3e89ccb))
39
+ * **ui:** make the admin pages read on a phone and stop badges printing over their neighbours ([46e6d49](https://github.com/postalsys/emailengine/commit/46e6d49424a55bb31bbcfe01e759e29484965642))
40
+ * **ui:** refine admin form labels and guidance ([eaa7d00](https://github.com/postalsys/emailengine/commit/eaa7d0060f771136c0f248b8e906a628ce98795b))
41
+
3
42
  ## [2.80.1](https://github.com/postalsys/emailengine/compare/v2.80.0...v2.80.1) (2026-09-10)
4
43
 
5
44
 
package/Dockerfile CHANGED
@@ -11,7 +11,7 @@
11
11
  # here; the runtime stage below copies out only the finished tree, so npm and its dependencies never
12
12
  # reach the published image. npm accounted for 38 of the 59 HIGH/CRITICAL findings in the old image
13
13
  # (a vendored tar, pacote, sigstore, minimatch) and nothing at runtime ever invokes it.
14
- FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf AS builder
14
+ FROM node:24-alpine@sha256:50c8e8ca1d27439048670df5883f32d57cf81cff6233222c893fd0d9884cbd81 AS builder
15
15
 
16
16
  ARG BUILDPLATFORM
17
17
  ARG TARGETPLATFORM
@@ -55,18 +55,26 @@ COPY sbom.json sbom.json
55
55
  COPY scan.js scan.js
56
56
  COPY server.js server.js
57
57
 
58
- RUN mkdir -p .git/refs/heads
59
- COPY .git/refs/heads/master .git/refs/heads/master
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.
58
+ # The commit hash is passed in rather than read out of the build context, which used to be
59
+ # `COPY .git/refs/heads/master` and tied the build to one branch name. See
60
+ # test/docker-commit-hash-guardrail-test.js for the full account.
61
+ #
62
+ # Declared HERE and not up with the other ARGs: an ARG's value is part of the cache key of every RUN
63
+ # below it, so moving this above `npm ci` makes the install layer miss on every single commit.
64
+ ARG EE_COMMIT_HASH
65
+
66
+ # version-info.json is generated here and the script is dropped again, so it does not end up in the
67
+ # runtime image. The `:?` check is the whole enforcement that a commit was supplied: update-info.sh
68
+ # deliberately falls through to an empty commit rather than failing, because its non-Docker callers
69
+ # (render.yaml, the deploy workflow) do not all have one to give. Here it is required, so a build that
70
+ # forgets the arg fails loudly instead of shipping an image that cannot say what it is built from.
63
71
  COPY update-info.sh update-info.sh
64
- RUN chmod +x ./update-info.sh \
72
+ RUN : "${EE_COMMIT_HASH:?EE_COMMIT_HASH build arg is required, e.g. --build-arg EE_COMMIT_HASH=\$(git rev-parse HEAD)}" \
65
73
  && ./update-info.sh \
66
- && rm -rf .git update-info.sh
74
+ && rm -f update-info.sh
67
75
 
68
76
  # Runtime stage.
69
- FROM node:24-alpine@sha256:e67514e5d0f6c46656005e1b693b2ec9d52e80b641307de684d4a015ba7a4eaf
77
+ FROM node:24-alpine@sha256:50c8e8ca1d27439048670df5883f32d57cf81cff6233222c893fd0d9884cbd81
70
78
 
71
79
  # `apk upgrade` patches the Alpine packages that the base image itself lags on - at the time of
72
80
  # writing node:24-alpine still carries an openssl below 3.5.8-r0. dumb-init reaps zombies as PID 1.
@@ -1,5 +1,5 @@
1
1
  {
2
- "creationTime": "2026-09-10T14:45:44.000000",
2
+ "creationTime": "2026-09-14T14:46:42.000000",
3
3
  "prefixes": [
4
4
  {
5
5
  "ipv6Prefix": "2001:4860:4801:2008::/64"
@@ -48,7 +48,13 @@ services:
48
48
  EENGINE_WORKERS: ${EENGINE_WORKERS:-4}
49
49
 
50
50
  healthcheck:
51
- test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:3000/health']
51
+ # 127.0.0.1 and not localhost: the image is Alpine, so this is BusyBox wget on musl.
52
+ # musl returns ::1 first for localhost (both are in the container's /etc/hosts) and
53
+ # BusyBox wget connects to that one address without falling back to the next, while
54
+ # EmailEngine listens on 0.0.0.0, which is IPv4 only. Through localhost the check can
55
+ # only ever report "connection refused", so the container stays unhealthy for good and
56
+ # anything chained behind `depends_on: service_healthy` waits forever.
57
+ test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://127.0.0.1:3000/health']
52
58
  interval: ${HEALTHCHECK_INTERVAL:-30s}
53
59
  timeout: ${HEALTHCHECK_TIMEOUT:-10s}
54
60
  retries: ${HEALTHCHECK_RETRIES:-3}
@@ -67,6 +67,82 @@ const verifyResultSchema = (proto, responseTextExample) =>
67
67
  .label(`Verify${proto}ResponseText`)
68
68
  }).label(`Verify${proto}Result`);
69
69
 
70
+ // The answer autodiscovery gives, shared by GET and POST /v1/autoconfig. One definition rather than
71
+ // two identical inline copies: the OpenAPI converter collapses structurally identical labelled
72
+ // schemas into a single component, so the two routes publish one `DiscoveredEmailSettings` type.
73
+ // One discovered server block. The IMAP and SMTP halves carry the same fields and differ only in
74
+ // their examples and their (historically inconsistent) label, so they are built rather than written
75
+ // out twice - the same reason verifyResultSchema above is a factory.
76
+ const discoveredServerSchema = (proto, label, hostExample, portExample) =>
77
+ Joi.object({
78
+ auth: Joi.object({
79
+ user: Joi.string().max(256).example('myuser@gmail.com').description('Account username')
80
+ }).label('DetectedAuthenticationInfo'),
81
+
82
+ host: Joi.string().hostname().example(hostExample).description('Hostname to connect to'),
83
+ port: Joi.number()
84
+ .integer()
85
+ .min(1)
86
+ .max(64 * 1024)
87
+ .example(portExample)
88
+ .description('Service port number'),
89
+ secure: Joi.boolean().default(false).example(true).description(`Should connection use TLS. Usually true for port ${portExample}`)
90
+ })
91
+ .allow(false)
92
+ .description(`Discovered ${proto} settings. False if ${proto} settings were not found`)
93
+ .label(label);
94
+
95
+ const discoveredEmailSettingsSchema = Joi.object({
96
+ imap: discoveredServerSchema('IMAP', 'ResolvedServerSettings', 'imap.gmail.com', 993),
97
+ smtp: discoveredServerSchema('SMTP', 'DiscoveredServerSettings', 'smtp.gmail.com', 465),
98
+ appPassword: Joi.object({
99
+ required: Joi.boolean().example(true).description('Whether the provider requires an app password'),
100
+ provider: Joi.string().example('Gmail').description('Provider name'),
101
+ instructions: Joi.string()
102
+ .example('Use an app password instead of the regular account password')
103
+ .description('Instructions for setting up an app password')
104
+ })
105
+ .unknown()
106
+ .description('App password requirements for the provider, if known')
107
+ .label('DiscoveredAppPasswordInfo'),
108
+ _source: Joi.string().example('srv').description('Source for the detected info')
109
+ }).label('DiscoveredEmailSettings');
110
+
111
+ // Address to discover settings for. Same field on the GET query and the POST payload.
112
+ const autodiscoverEmailSchema = Joi.string()
113
+ .email()
114
+ .required()
115
+ .example('sender@example.com')
116
+ .description('Email address to discover email settings for')
117
+ .label('EmailAddress');
118
+
119
+ // Shared by both autoconfig routes, which answer the same question and publish the same contract -
120
+ // including the empty result, which is the normal answer for an address whose domain describes no
121
+ // mail server anywhere. Credentials are optional and only ever reach an autodiscovery endpoint that
122
+ // refuses to answer anonymously (lib/autodetect-imap-settings.js).
123
+ const runAutoconfig = async (request, email, credentials) => {
124
+ try {
125
+ return await autodetectImapSettings(email, request.app.gt, credentials);
126
+ } catch (err) {
127
+ // autodiscovery fails routinely for unknown domains and the handler answers with a
128
+ // regular "not found" response, so this is not an operator-visible failure
129
+ request.logger.debug({ msg: 'API request failed', err });
130
+ if (Boom.isBoom(err)) {
131
+ throw err;
132
+ }
133
+ return { imap: false, smtp: false, _source: 'unknown' };
134
+ }
135
+ };
136
+
137
+ const AUTOCONFIG_RESPONSES = apiResponses(
138
+ 'Returns the discovered IMAP and SMTP settings for the address, or empty values when nothing could be resolved.',
139
+ 400,
140
+ 401,
141
+ 403,
142
+ 429,
143
+ 500
144
+ );
145
+
70
146
  /**
71
147
  * Validates that delegation fields are only used with OAuth2 accounts.
72
148
  */
@@ -1512,6 +1588,7 @@ async function init(args) {
1512
1588
  subconnections: request.payload.subconnections,
1513
1589
  redirectUrl: request.payload.redirectUrl,
1514
1590
  delegated: request.payload.delegated,
1591
+ skipServerSettings: request.payload.skipServerSettings,
1515
1592
  path: request.payload.path && !request.payload.path.includes('*') ? request.payload.path : null,
1516
1593
  // identify request
1517
1594
  n: crypto.randomBytes(NONCE_BYTES).toString('base64url'),
@@ -1564,6 +1641,7 @@ async function init(args) {
1564
1641
  description: 'Generate authentication link',
1565
1642
  notes: [
1566
1643
  'Generates a redirect link to the hosted authentication form',
1644
+ 'An IMAP setup completes without asking the user for mail server settings whenever EmailEngine can discover and verify them from the address and password alone. Set `skipServerSettings` to false to always show that step.',
1567
1645
  'If `expectedEmail` is set and the user completes the form as a different identity, the setup is rejected before any credentials are stored. The user stays on EmailEngine, which names both addresses and offers to restart the setup, so the browser is never redirected to `redirectUrl`.'
1568
1646
  ],
1569
1647
  tags: ['api', 'Account'],
@@ -1623,6 +1701,15 @@ async function init(args) {
1623
1701
  .default(false)
1624
1702
  .description('If true, configures this account as a shared mailbox. Currently supported by MS365 OAuth2 accounts'),
1625
1703
 
1704
+ skipServerSettings: Joi.boolean()
1705
+ .empty('')
1706
+ .truthy('Y', 'true', '1')
1707
+ .falsy('N', 'false', 0)
1708
+ .default(true)
1709
+ .description(
1710
+ 'If true, the mail server settings step is skipped whenever the IMAP and SMTP settings for the address can both be discovered and verified with the password the user enters. The step is still shown if discovery or verification does not fully succeed. Set to false to always ask the user for the server settings. Applies to the IMAP setup path only.'
1711
+ ),
1712
+
1626
1713
  syncFrom: accountSchemas.syncFrom,
1627
1714
  notifyFrom: accountSchemas.notifyFrom,
1628
1715
 
@@ -1798,18 +1885,7 @@ async function init(args) {
1798
1885
  path: '/v1/autoconfig',
1799
1886
 
1800
1887
  async handler(request) {
1801
- try {
1802
- let serverSettings = await autodetectImapSettings(request.query.email, request.app.gt);
1803
- return serverSettings;
1804
- } catch (err) {
1805
- // autodiscovery fails routinely for unknown domains and the handler answers with a
1806
- // regular "not found" response, so this is not an operator-visible failure
1807
- request.logger.debug({ msg: 'API request failed', err });
1808
- if (Boom.isBoom(err)) {
1809
- throw err;
1810
- }
1811
- return { imap: false, smtp: false, _source: 'unknown' };
1812
- }
1888
+ return await runAutoconfig(request, request.query.email);
1813
1889
  },
1814
1890
 
1815
1891
  options: {
@@ -1826,14 +1902,7 @@ async function init(args) {
1826
1902
  openWorld: true
1827
1903
  },
1828
1904
  openapi: {
1829
- responses: apiResponses(
1830
- 'Returns the discovered IMAP and SMTP settings for the address, or empty values when nothing could be resolved.',
1831
- 400,
1832
- 401,
1833
- 403,
1834
- 429,
1835
- 500
1836
- )
1905
+ responses: AUTOCONFIG_RESPONSES
1837
1906
  }
1838
1907
  },
1839
1908
 
@@ -1852,63 +1921,80 @@ async function init(args) {
1852
1921
  failAction,
1853
1922
 
1854
1923
  query: Joi.object({
1855
- email: Joi.string()
1856
- .email()
1857
- .required()
1858
- .example('sender@example.com')
1859
- .description('Email address to discover email settings for')
1860
- .label('EmailAddress')
1924
+ email: autodiscoverEmailSchema
1861
1925
  }).label('AutodiscoverQuery')
1862
1926
  },
1863
1927
 
1864
1928
  response: {
1865
- schema: Joi.object({
1866
- imap: Joi.object({
1867
- auth: Joi.object({
1868
- user: Joi.string().max(256).example('myuser@gmail.com').description('Account username')
1869
- }).label('DetectedAuthenticationInfo'),
1870
-
1871
- host: Joi.string().hostname().example('imap.gmail.com').description('Hostname to connect to'),
1872
- port: Joi.number()
1873
- .integer()
1874
- .min(1)
1875
- .max(64 * 1024)
1876
- .example(993)
1877
- .description('Service port number'),
1878
- secure: Joi.boolean().default(false).example(true).description('Should connection use TLS. Usually true for port 993')
1879
- })
1880
- .allow(false)
1881
- .description('Discovered IMAP settings. False if IMAP settings were not found')
1882
- .label('ResolvedServerSettings'),
1883
- smtp: Joi.object({
1884
- auth: Joi.object({
1885
- user: Joi.string().max(256).example('myuser@gmail.com').description('Account username')
1886
- }).label('DetectedAuthenticationInfo'),
1887
-
1888
- host: Joi.string().hostname().example('smtp.gmail.com').description('Hostname to connect to'),
1889
- port: Joi.number()
1890
- .integer()
1891
- .min(1)
1892
- .max(64 * 1024)
1893
- .example(465)
1894
- .description('Service port number'),
1895
- secure: Joi.boolean().default(false).example(true).description('Should connection use TLS. Usually true for port 465')
1896
- })
1897
- .allow(false)
1898
- .description('Discovered SMTP settings. False if SMTP settings were not found')
1899
- .label('DiscoveredServerSettings'),
1900
- appPassword: Joi.object({
1901
- required: Joi.boolean().example(true).description('Whether the provider requires an app password'),
1902
- provider: Joi.string().example('Gmail').description('Provider name'),
1903
- instructions: Joi.string()
1904
- .example('Use an app password instead of the regular account password')
1905
- .description('Instructions for setting up an app password')
1929
+ schema: discoveredEmailSettingsSchema,
1930
+ failAction: 'log'
1931
+ }
1932
+ }
1933
+ });
1934
+
1935
+ server.route({
1936
+ method: 'POST',
1937
+ path: '/v1/autoconfig',
1938
+
1939
+ async handler(request) {
1940
+ // The credentials are offered to the autodiscovery host only after that host has refused
1941
+ // an anonymous request with a Basic challenge over https, and only to the origin that
1942
+ // issued it (lib/autodetect-imap-settings.js runAutodiscovery). Every other resolver
1943
+ // stays anonymous, so an address that resolves without a password answers the same here
1944
+ // as it does on the GET.
1945
+ return await runAutoconfig(request, request.payload.email, request.payload.auth);
1946
+ },
1947
+
1948
+ options: {
1949
+ description: 'Discover Email settings with credentials',
1950
+ notes: [
1951
+ 'Try to discover IMAP and SMTP settings for an email account, optionally authenticating against an autodiscovery server that refuses to answer anonymously',
1952
+ "Hosted Exchange answers autodiscovery only for an authenticated request, which is why this endpoint exists alongside `GET /v1/autoconfig`. The password is sent to the autodiscovery host named by the address domain's own DNS records, and only after that host has asked for it with a Basic challenge over HTTPS."
1953
+ ],
1954
+ tags: ['api', 'Settings'],
1955
+
1956
+ // Deliberately not exposed as an MCP tool. `autodiscover_settings` (the GET) covers
1957
+ // discovery for an agent; this one takes a mailbox password as an argument, which is not
1958
+ // something to put in a tool manifest for a model to fill in.
1959
+ plugins: {
1960
+ openapi: {
1961
+ 'x-ee-impact': IMPACT.READONLY,
1962
+ responses: AUTOCONFIG_RESPONSES
1963
+ }
1964
+ },
1965
+
1966
+ auth: {
1967
+ strategy: 'api-token',
1968
+ mode: 'required'
1969
+ },
1970
+ cors: CORS_CONFIG,
1971
+
1972
+ validate: {
1973
+ options: {
1974
+ stripUnknown: false,
1975
+ abortEarly: false,
1976
+ convert: true
1977
+ },
1978
+ failAction,
1979
+
1980
+ payload: Joi.object({
1981
+ email: autodiscoverEmailSchema,
1982
+ auth: Joi.object({
1983
+ user: Joi.string()
1984
+ .empty('')
1985
+ .trim()
1986
+ .max(1024)
1987
+ .example('myuser@gmail.com')
1988
+ .description('Username for the autodiscovery request. Defaults to the email address.'),
1989
+ pass: Joi.string().max(1024).required().example('verysecret').description('Password for the mailbox')
1906
1990
  })
1907
- .unknown()
1908
- .description('App password requirements for the provider, if known')
1909
- .label('DiscoveredAppPasswordInfo'),
1910
- _source: Joi.string().example('srv').description('Source for the detected info')
1911
- }).label('DiscoveredEmailSettings'),
1991
+ .description('Credentials to offer if the autodiscovery server refuses to answer anonymously')
1992
+ .label('AutodiscoverCredentials')
1993
+ }).label('AutodiscoverRequest')
1994
+ },
1995
+
1996
+ response: {
1997
+ schema: discoveredEmailSettingsSchema,
1912
1998
  failAction: 'log'
1913
1999
  }
1914
2000
  }
@@ -564,7 +564,12 @@ const GROUP_ROUTES = {
564
564
  'POST /v1/authentication/form',
565
565
 
566
566
  // Connects to a supplied host with supplied credentials
567
- 'POST /v1/verifyAccount'
567
+ 'POST /v1/verifyAccount',
568
+
569
+ // Offers supplied credentials to the autodiscovery host the address domain's own DNS names,
570
+ // which is why it sits here and not with the credential-free `GET /v1/autoconfig` under
571
+ // diagnostics. It stores nothing, so it is still a read.
572
+ 'POST /v1/autoconfig'
568
573
  ],
569
574
 
570
575
  // Everything that hands out a lasting credential or reads one back. This block is the safety
@@ -1138,10 +1138,10 @@ async function resolver(email, gt, credentials) {
1138
1138
  * @param {Object} gt - gettext instance, for the app-password hints
1139
1139
  * @param {Object} [credentials] - `{ user, pass }` for the mailbox. Only used to answer an
1140
1140
  * autodiscovery endpoint that refuses to respond anonymously, which is how hosted Exchange
1141
- * behaves; every other resolver is unauthenticated. The hosted setup form is the one caller that
1142
- * holds a password, so it is the one that passes this. `GET /v1/autoconfig` takes the address in
1143
- * a query string and can never carry one, which is why an Exchange domain stays unresolvable
1144
- * there - deliberately, rather than for want of a credential-carrying endpoint.
1141
+ * behaves; every other resolver is unauthenticated. The callers that hold a password pass it:
1142
+ * the hosted setup form, and `POST /v1/autoconfig` for an integrator running its own form.
1143
+ * `GET /v1/autoconfig` takes the address in a query string, where a password must never go, so
1144
+ * it stays anonymous and an Exchange domain stays unresolvable there - use the POST instead.
1145
1145
  * @returns {Promise<Object>} `{ imap, smtp, _source }`, plus `appPassword` where one applies
1146
1146
  */
1147
1147
  async function autodetectImapSettings(email, gt, credentials) {
package/lib/sentry.js CHANGED
@@ -12,6 +12,17 @@ let Sentry;
12
12
  let workerName;
13
13
  let activeDsn = false;
14
14
 
15
+ // Sentry only orders a project's releases by semver when the version carries a package prefix:
16
+ // Release.is_semver_version() refuses anything without an "@", and the server then falls back to
17
+ // ordering by the date each version was first seen. EmailEngine reported a bare "2.79.6", so an
18
+ // instance that met 2.79.8 before 2.79.6 sorted the older release as the newer one, and
19
+ // "resolve in release" reopened the issue it had just closed.
20
+ //
21
+ // The prefix is the npm package name, not the "@postalsys/emailengine-app" licence identifier
22
+ // used elsewhere: Relay rejects a scoped name outright ("bad characters in release name"), which
23
+ // would leave the release unparseable rather than merely unordered.
24
+ const SENTRY_RELEASE = `${packageData.name}@${packageData.version}`;
25
+
15
26
  // Sentry's own transport speaks Node http/https and knows only the http_proxy environment
16
27
  // variables (HTTP proxies, no SOCKS), so a proxy configured in EmailEngine would not cover error
17
28
  // reports. Deliveries go through the shared dispatcher instead, read at send time so a proxy
@@ -50,7 +61,7 @@ function startSentry(dsn) {
50
61
 
51
62
  Sentry.init({
52
63
  dsn,
53
- release: packageData.version,
64
+ release: SENTRY_RELEASE,
54
65
  transport: makeTransport,
55
66
  // Error capture only: skip the OpenTelemetry setup and the default
56
67
  // integrations that patch http/fetch/console on hot paths. Sentry's own
@@ -176,4 +187,4 @@ function initSentry(worker) {
176
187
  setImmediate(checkSettings);
177
188
  }
178
189
 
179
- module.exports = { initSentry, makeTransport };
190
+ module.exports = { initSentry, makeTransport, SENTRY_RELEASE };
@@ -420,7 +420,7 @@ async function requestProvisioning(opts) {
420
420
  if (mode !== 'acme') {
421
421
  reason = 'Automatic certificates are switched off for this instance';
422
422
  } else if (!eligible.includes(hostname)) {
423
- reason = `Let's Encrypt can not validate ${hostname}. Automatic certificates need a public domain name.`;
423
+ reason = `Let's Encrypt cannot validate ${hostname}. Automatic certificates need a public domain name.`;
424
424
  } else if (inFlight.has(hostname)) {
425
425
  // Already ordering. Saying so beats silently starting a second order, and beats
426
426
  // overwriting the state the running order is reporting through.
@@ -159,13 +159,14 @@ const MCP_SECTIONS = {
159
159
  label: 'Observe',
160
160
  hint: 'Recommended. Read accounts, settings, queues, OAuth2 applications, gateways, tokens and logs. Cannot change anything.',
161
161
  caveat: 'It cannot change anything, create tokens or read stored credentials. Connection logs name folders and subjects, and the token audit log records who read which account.',
162
- // Less read/provisioning, which is only POST /v1/verifyAccount: a connection to a
163
- // host the caller names, authenticated with credentials the caller supplies. The
164
- // other reads that leave the instance (autodiscovery, the OAuth2 application
165
- // check) go where the caller's own domain or a stored record points; this one is
166
- // a port and password probe for whatever network the instance sits on, which a
167
- // level sold as unable to change anything must not be. test/mcp-tools-test.js
168
- // pins the pair to that one route, so the group is the whole of the exclusion.
162
+ // Less read/provisioning, which is POST /v1/verifyAccount and POST /v1/autoconfig:
163
+ // both take credentials the caller supplies and offer them to a host the caller's
164
+ // input decides. The other reads that leave the instance (the credential-free
165
+ // GET /v1/autoconfig, the OAuth2 application check) go where the caller's own
166
+ // domain or a stored record points and carry no password; these two are a port and
167
+ // password probe for whatever network the instance sits on, which a level sold as
168
+ // unable to change anything must not be. test/mcp-tools-test.js pins the pair to
169
+ // those routes, so the group is the whole of the exclusion.
169
170
  pairs: pairsOf(MCP_SCOPES.manage, grant => grant.action === ACTION.READ && grant.group !== GROUP.PROVISIONING)
170
171
  },
171
172
  {
package/lib/tools.js CHANGED
@@ -2286,6 +2286,7 @@ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV3QUiYsp13nD9suD1/ZkEXnuMoSg
2286
2286
  subconnections: opts.subconnections && opts.subconnections.length ? opts.subconnections : null,
2287
2287
  redirectUrl: opts.redirectUrl,
2288
2288
  delegated: opts.delegated,
2289
+ skipServerSettings: opts.skipServerSettings,
2289
2290
  path: opts.path,
2290
2291
  n: opts.n,
2291
2292
  t: opts.t