emailengine-app 2.87.0 → 2.87.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ncurc.js +2 -4
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +19 -0
- package/Dockerfile +3 -4
- package/bin/emailengine.js +2 -4
- package/bin/healthcheck.js +20 -0
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +3 -7
- package/lib/account/auth-failure-backfill.js +3 -2
- package/lib/account/expected-identity.js +2 -2
- package/lib/account.js +9 -8
- package/lib/api-listener.js +40 -0
- package/lib/api-token-auth.js +406 -0
- package/lib/autodetect-imap-settings.js +36 -3
- package/lib/consts.js +5 -0
- package/lib/email-client/base-client.js +23 -107
- package/lib/email-client/gmail-client.js +7 -4
- package/lib/email-client/imap/mailbox.js +89 -96
- package/lib/email-client/imap/sync-operations.js +13 -6
- package/lib/email-client/imap-client.js +28 -7
- package/lib/email-client/new-message-steps.js +162 -0
- package/lib/email-client/outlook-client.js +4 -2
- package/lib/env-setting-overrides.js +6 -2
- package/lib/export-worker.js +3 -2
- package/lib/export.js +43 -4
- package/lib/get-boolean.js +38 -0
- package/lib/health-probe.js +71 -0
- package/lib/imapproxy/imap-server.js +4 -55
- package/lib/net-tos-guard.js +42 -0
- package/lib/oauth2-apps.js +2 -1
- package/lib/read-env-value.js +19 -7
- package/lib/redis-keys.js +19 -0
- package/lib/redis-operations.js +7 -3
- package/lib/security-headers.js +18 -0
- package/lib/session-default.js +50 -0
- package/lib/settings.js +2 -1
- package/lib/stream-encrypt.js +71 -20
- package/lib/sub-script.js +8 -2
- package/lib/submit-lock.js +84 -0
- package/lib/submit-processor.js +283 -0
- package/lib/templates.js +6 -3
- package/lib/tls/context.js +2 -16
- package/lib/tools.js +8 -30
- package/lib/utils/redis-errors.js +44 -0
- package/lib/webhook-delivery.js +3 -4
- package/lib/worker-rpc-error.js +10 -5
- package/lib/worker-rpc.js +138 -0
- package/package.json +17 -19
- package/sbom.json +370 -1446
- package/server.js +6 -5
- package/static/css/flyonui.css +2 -2
- package/static/licenses.html +253 -1366
- package/translations/messages.pot +16 -16
- package/workers/api.js +41 -465
- package/workers/export.js +14 -55
- package/workers/imap-proxy.js +5 -18
- package/workers/imap.js +27 -49
- package/workers/smtp.js +7 -69
- package/workers/submit.js +21 -279
- package/workers/webhooks.js +7 -72
package/.ncurc.js
CHANGED
|
@@ -53,7 +53,8 @@ module.exports = {
|
|
|
53
53
|
// from the CommonJS rule); the Node requirement does, since the tooling has to
|
|
54
54
|
// run on the Node 20 floor too.
|
|
55
55
|
// undici - 8.x requires Node >=22.19 and crashes at require() on Node 20. Permanent while the
|
|
56
|
-
// Node 20 floor above stands.
|
|
56
|
+
// Node 20 floor above stands. lib/net-tos-guard.js covers a 7.x crash 8.x fixed
|
|
57
|
+
// itself (unguarded setTypeOfService); remove it with the upgrade.
|
|
57
58
|
// marked - 16.x dropped the CommonJS build (ESM-only, needs require(esm)/Node >=20.19); 15.x is the
|
|
58
59
|
// last require()-compatible line. 15.0.12 verified on Node 20-24 and in a yao/pkg node24 build.
|
|
59
60
|
// Permanent: an ESM-only release cannot be bundled by pkg, whatever the Node floor.
|
|
@@ -91,9 +92,6 @@ module.exports = {
|
|
|
91
92
|
// bump still needs a look at the generated document: test/openapi-golden-test.js fails if joi's
|
|
92
93
|
// describe() output changes shape.
|
|
93
94
|
reject: [
|
|
94
|
-
// @asamuzakjp/css-color >=4.1.2 pulls in @csstools/* v4 which are pure ESM and break pkg bundling
|
|
95
|
-
// (transitive via @postalsys/email-text-tools -> jsdom -> cssstyle; also pinned in package.json "overrides").
|
|
96
|
-
'@asamuzakjp/css-color'
|
|
97
95
|
// Not a direct dependency, so nothing here moves it: the "overrides" entry in package.json
|
|
98
96
|
// lifts cheerio from the 1.0.0 that juice 11 (via @postalsys/email-text-tools) pins exactly,
|
|
99
97
|
// which drags in a second copy of undici (6.x) next to ours. cheerio 1.2.0 shares our undici
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.87.1](https://github.com/postalsys/emailengine/compare/v2.87.0...v2.87.1) (2026-11-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* bind export encryption chunks to their position in the file ([c138b61](https://github.com/postalsys/emailengine/commit/c138b6145ad0dab33b92d8d5f1571ffd32fc96c3))
|
|
9
|
+
* export recovery ownership and sent-marker durability (2.87.1 review) ([5c24113](https://github.com/postalsys/emailengine/commit/5c2411311ee1652ed4580fd53d40f0fdc81bd7f4))
|
|
10
|
+
* keep the sent marker until the submit job is recorded as completed ([aecf19f](https://github.com/postalsys/emailengine/commit/aecf19f6ac7a431f87441102e3302228ab1728ad))
|
|
11
|
+
* make the Docker health check follow the API's TLS setting, port and bind address ([957dec0](https://github.com/postalsys/emailengine/commit/957dec0923ab359355761bd531d6d08003a3dd05))
|
|
12
|
+
* never fail an export another export worker is still running ([74d1755](https://github.com/postalsys/emailengine/commit/74d1755aa2fec63565bae64fcad55153e5294c5d))
|
|
13
|
+
* read the TLS mode from <Encryption> in Exchange autodiscover answers ([5a1b7e9](https://github.com/postalsys/emailengine/commit/5a1b7e9e3df33a38b65b80447e6628a8e908223e))
|
|
14
|
+
* report a template id with an out-of-range timestamp as not found ([ac043db](https://github.com/postalsys/emailengine/commit/ac043db8d1540a025d8143d1d261cf3d2f1400cb))
|
|
15
|
+
* set text.hasMore when an IMAP text part is cut at maxBytes ([f070b5e](https://github.com/postalsys/emailengine/commit/f070b5ea91ad3763936c975a302a23d20d768e69))
|
|
16
|
+
* share the worker RPC, token check and new-message steps instead of copies ([ac4cf28](https://github.com/postalsys/emailengine/commit/ac4cf28ae3925bcf4a01373f3c05d51a5c4da8f3))
|
|
17
|
+
* standalone fixes for new-folder ids, Redis-refused work, duplicate sends, CLI password and queued exports ([#685](https://github.com/postalsys/emailengine/issues/685)) ([8e934c0](https://github.com/postalsys/emailengine/commit/8e934c0cf9cda2e33cfbdb7a42cfe2a77172523d))
|
|
18
|
+
* update dependencies ([56df020](https://github.com/postalsys/emailengine/commit/56df02073fb6a76e984531710fd97fee0163e58b))
|
|
19
|
+
* update dependencies ([25ee28f](https://github.com/postalsys/emailengine/commit/25ee28fc5bd5623c4b73b55e0890c027832825cf))
|
|
20
|
+
* update dependencies (bullmq 6.5.4, fast-xml-parser 5.12.0) ([5624ee1](https://github.com/postalsys/emailengine/commit/5624ee1844c6ed2f377bbbe7161f21f035d7c943))
|
|
21
|
+
|
|
3
22
|
## [2.87.0](https://github.com/postalsys/emailengine/compare/v2.86.0...v2.87.0) (2026-10-29)
|
|
4
23
|
|
|
5
24
|
|
package/Dockerfile
CHANGED
|
@@ -114,11 +114,10 @@ EXPOSE 3000
|
|
|
114
114
|
|
|
115
115
|
# The liveness check: answers while the process can serve HTTP, without waiting on Redis or the
|
|
116
116
|
# workers, so an orchestrator restarts the container only when restarting can help. Readiness
|
|
117
|
-
# (workers and Redis) is /health/ready, for whatever routes traffic to it.
|
|
118
|
-
#
|
|
119
|
-
# EmailEngine listens on IPv4. Shell form so a changed EENGINE_PORT (or PORT) is followed.
|
|
117
|
+
# (workers and Redis) is /health/ready, for whatever routes traffic to it. A Node script rather than
|
|
118
|
+
# wget so the probe follows the API's own port, bind address and TLS switch (lib/health-probe.js).
|
|
120
119
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
121
|
-
CMD
|
|
120
|
+
CMD ["node", "/emailengine/bin/healthcheck.js"]
|
|
122
121
|
|
|
123
122
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
|
124
123
|
CMD ["node", "/emailengine/server.js"]
|
package/bin/emailengine.js
CHANGED
|
@@ -412,10 +412,8 @@ function runPassword() {
|
|
|
412
412
|
let returnValue = argv.hash || argv.r ? Buffer.from(res.passwordHash).toString('base64url') : res.password;
|
|
413
413
|
process.stdout.write(returnValue);
|
|
414
414
|
// The password is stored, and every existing session is ended by the
|
|
415
|
-
// version bump;
|
|
416
|
-
//
|
|
417
|
-
// keeps serving the admin pages without one until it is restarted
|
|
418
|
-
process.stderr.write('\nRestart running EmailEngine instances for the new password to take effect\n');
|
|
415
|
+
// version bump; a running instance that had no password asks for a login
|
|
416
|
+
// from its next admin request on (lib/session-default.js)
|
|
419
417
|
return process.exit(0);
|
|
420
418
|
})
|
|
421
419
|
.catch(err => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// The Docker image's HEALTHCHECK: exits 0 when the API answers /health/live, 1 otherwise. See
|
|
5
|
+
// lib/health-probe.js.
|
|
6
|
+
|
|
7
|
+
// Resolve `.env` and `config/` against the application root, in the same order as server.js
|
|
8
|
+
process.chdir(require('path').join(__dirname, '..'));
|
|
9
|
+
require('dotenv').config({ quiet: true });
|
|
10
|
+
|
|
11
|
+
const config = require('@zone-eu/wild-config');
|
|
12
|
+
const { probeTarget, probe } = require('../lib/health-probe');
|
|
13
|
+
|
|
14
|
+
const target = probeTarget(config.api || {});
|
|
15
|
+
|
|
16
|
+
probe(target).then(result => {
|
|
17
|
+
const url = `${target.protocol}://${target.host}:${target.port}`;
|
|
18
|
+
process.stdout.write(result.ok ? `${url} is live\n` : `${url} is not live: ${result.error || `HTTP ${result.statusCode}`}\n`);
|
|
19
|
+
process.exit(result.ok ? 0 : 1);
|
|
20
|
+
});
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Please pull this list from, and only from https://publicsuffix.org/list/public_suffix_list.dat,
|
|
6
6
|
// rather than any other VCS sites. Pulling from any other URL is not guaranteed to be supported.
|
|
7
7
|
|
|
8
|
-
// VERSION: 2026-10-
|
|
9
|
-
// COMMIT:
|
|
8
|
+
// VERSION: 2026-10-31_14-17-28_UTC
|
|
9
|
+
// COMMIT: 73f8cc701c084fe07d888ec552b2f0b53281a674
|
|
10
10
|
|
|
11
11
|
// Instructions on pulling and using this list can be found at https://publicsuffix.org/list/.
|
|
12
12
|
|
|
@@ -6812,7 +6812,7 @@ org.zw
|
|
|
6812
6812
|
|
|
6813
6813
|
// newGTLDs
|
|
6814
6814
|
|
|
6815
|
-
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2026-10-
|
|
6815
|
+
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2026-10-30T19:51:02Z
|
|
6816
6816
|
// This list is auto-generated, don't edit it manually.
|
|
6817
6817
|
// aaa : American Automobile Association, Inc.
|
|
6818
6818
|
// https://www.iana.org/domains/root/db/aaa.html
|
|
@@ -8498,10 +8498,6 @@ healthcare
|
|
|
8498
8498
|
// https://www.iana.org/domains/root/db/help.html
|
|
8499
8499
|
help
|
|
8500
8500
|
|
|
8501
|
-
// helsinki : City of Helsinki
|
|
8502
|
-
// https://www.iana.org/domains/root/db/helsinki.html
|
|
8503
|
-
helsinki
|
|
8504
|
-
|
|
8505
8501
|
// here : Charleston Road Registry Inc.
|
|
8506
8502
|
// https://www.iana.org/domains/root/db/here.html
|
|
8507
8503
|
here
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
// rolling upgrade, would leave a second batch that the key then hides; re-arming means deleting
|
|
40
40
|
// BACKFILL_KEY and restarting.
|
|
41
41
|
|
|
42
|
+
const { accountDataKey } = require('../redis-keys');
|
|
42
43
|
const { redis } = require('../db');
|
|
43
44
|
const logger = require('../logger');
|
|
44
45
|
const { parseImapData } = require('./imap-data');
|
|
@@ -130,7 +131,7 @@ async function backfillAuthFailureDisabled(opts = {}) {
|
|
|
130
131
|
|
|
131
132
|
const readReq = client.pipeline();
|
|
132
133
|
for (const account of chunk) {
|
|
133
|
-
readReq.hmget(
|
|
134
|
+
readReq.hmget(accountDataKey(account), ...SCAN_FIELDS);
|
|
134
135
|
}
|
|
135
136
|
const rows = await readReq.exec();
|
|
136
137
|
|
|
@@ -142,7 +143,7 @@ async function backfillAuthFailureDisabled(opts = {}) {
|
|
|
142
143
|
// hSetExists rather than hset, for the same reason the safety net writes it that way: an
|
|
143
144
|
// account deleted between the read above and this write must not come back as a hash
|
|
144
145
|
// holding nothing but a marker.
|
|
145
|
-
writeReq.hSetExists(
|
|
146
|
+
writeReq.hSetExists(accountDataKey(chunk[j]), AUTH_FAILURE_DISABLED_FIELD, stamp);
|
|
146
147
|
queued++;
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { accountDataKey } = require('../redis-keys');
|
|
4
4
|
|
|
5
5
|
// An account can carry an expected identity: the address that must own it, set by an authenticated API
|
|
6
6
|
// caller through `expectedEmail` on POST /v1/authentication/form, POST /v1/account or
|
|
@@ -82,7 +82,7 @@ async function resolveExpectedIdentity(redis, opts) {
|
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
return normalizeEmail(await redis.hget(
|
|
85
|
+
return normalizeEmail(await redis.hget(accountDataKey(account), 'expectedEmail')) || null;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
module.exports = { normalizeEmail, matchesExpectedIdentity, pendingSetupExpectation, resolveExpectedIdentity };
|
package/lib/account.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { accountDataKey } = require('./redis-keys');
|
|
3
4
|
const logger = require('./logger');
|
|
4
5
|
const Boom = require('@hapi/boom');
|
|
5
6
|
const msgpack = require('./msgpack');
|
|
@@ -368,7 +369,7 @@ class Account {
|
|
|
368
369
|
let delegatedAccount = await resolveDelegatedAccount(this.redis, accountData.account);
|
|
369
370
|
if (delegatedAccount) {
|
|
370
371
|
accountData.delegatedAccount = delegatedAccount;
|
|
371
|
-
let delegatedAccountRow = await this.redis.hgetall(
|
|
372
|
+
let delegatedAccountRow = await this.redis.hgetall(accountDataKey(delegatedAccount));
|
|
372
373
|
let delegatedAccountData = this.unserializeAccountData(delegatedAccountRow, { skipDecrypt: true });
|
|
373
374
|
if (delegatedAccountData.oauth2 && delegatedAccountData.oauth2.provider) {
|
|
374
375
|
let app;
|
|
@@ -443,7 +444,7 @@ class Account {
|
|
|
443
444
|
}
|
|
444
445
|
|
|
445
446
|
getAccountKey() {
|
|
446
|
-
return
|
|
447
|
+
return accountDataKey(this.account);
|
|
447
448
|
}
|
|
448
449
|
|
|
449
450
|
getMailboxListKey() {
|
|
@@ -1024,7 +1025,7 @@ class Account {
|
|
|
1024
1025
|
let delegatedAccount = await resolveDelegatedAccount(this.redis, accountData.account);
|
|
1025
1026
|
if (delegatedAccount) {
|
|
1026
1027
|
accountData.delegatedAccount = delegatedAccount;
|
|
1027
|
-
let delegatedAccountRow = await this.redis.hgetall(
|
|
1028
|
+
let delegatedAccountRow = await this.redis.hgetall(accountDataKey(delegatedAccount));
|
|
1028
1029
|
let delegatedAccountData = this.unserializeAccountData(delegatedAccountRow, { skipDecrypt: true });
|
|
1029
1030
|
if (delegatedAccountData.oauth2 && delegatedAccountData.oauth2.provider) {
|
|
1030
1031
|
let app = await oauth2Apps.get(delegatedAccountData.oauth2.provider);
|
|
@@ -1396,7 +1397,7 @@ class Account {
|
|
|
1396
1397
|
let retries = 0;
|
|
1397
1398
|
while (retries++ < 20) {
|
|
1398
1399
|
id = randomId();
|
|
1399
|
-
let alreadyExists = await this.redis.hexists(
|
|
1400
|
+
let alreadyExists = await this.redis.hexists(accountDataKey(id), 'account');
|
|
1400
1401
|
if (alreadyExists) {
|
|
1401
1402
|
id = false;
|
|
1402
1403
|
} else {
|
|
@@ -2802,7 +2803,7 @@ class Account {
|
|
|
2802
2803
|
let delegatedAccount = await resolveDelegatedAccount(this.redis, accountData.account);
|
|
2803
2804
|
if (delegatedAccount) {
|
|
2804
2805
|
accountData.delegatedAccount = delegatedAccount;
|
|
2805
|
-
let delegatedAccountRow = await this.redis.hgetall(
|
|
2806
|
+
let delegatedAccountRow = await this.redis.hgetall(accountDataKey(delegatedAccount));
|
|
2806
2807
|
let delegatedAccountData = this.unserializeAccountData(delegatedAccountRow, { skipDecrypt: true });
|
|
2807
2808
|
if (delegatedAccountData?.oauth2?.provider) {
|
|
2808
2809
|
let app = await oauth2Apps.get(delegatedAccountData.oauth2.provider);
|
|
@@ -3011,7 +3012,7 @@ const DEFERRED_CHANGE_BATCH = 100;
|
|
|
3011
3012
|
// the mandatory marker field of the account hash (the same idiom the notify worker and
|
|
3012
3013
|
// genId() rely on), so its presence is the canonical "this account exists" signal.
|
|
3013
3014
|
async function accountExists(redis, account) {
|
|
3014
|
-
return (await redis.hexists(
|
|
3015
|
+
return (await redis.hexists(accountDataKey(account), 'account')) === 1;
|
|
3015
3016
|
}
|
|
3016
3017
|
|
|
3017
3018
|
/**
|
|
@@ -3031,7 +3032,7 @@ async function accountsExist(redis, accounts) {
|
|
|
3031
3032
|
|
|
3032
3033
|
let pipeline = redis.pipeline();
|
|
3033
3034
|
for (let account of accounts) {
|
|
3034
|
-
pipeline = pipeline.hexists(
|
|
3035
|
+
pipeline = pipeline.hexists(accountDataKey(account), 'account');
|
|
3035
3036
|
}
|
|
3036
3037
|
|
|
3037
3038
|
// A pipeline reports a per-command failure in its results rather than rejecting, and
|
|
@@ -3060,7 +3061,7 @@ async function accountSummary(redis, account) {
|
|
|
3060
3061
|
}
|
|
3061
3062
|
|
|
3062
3063
|
// `account` is the existence marker (see accountExists); the rest are optional on a record
|
|
3063
|
-
let [exists, name, email, state] = await redis.hmget(
|
|
3064
|
+
let [exists, name, email, state] = await redis.hmget(accountDataKey(account), 'account', 'name', 'email', 'state');
|
|
3064
3065
|
if (!exists) {
|
|
3065
3066
|
return null;
|
|
3066
3067
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Where and how the API listens, resolved from the environment and the config file. One copy for
|
|
4
|
+
// every process that needs the answer: the main thread and the API worker build the listener from
|
|
5
|
+
// it, the certificate reconciler asks whether it serves TLS, and the Docker health check
|
|
6
|
+
// (lib/health-probe.js) probes it. Kept to leaf modules so the health check can load it without
|
|
7
|
+
// reaching Redis, which lib/tools.js and lib/settings.js do as they load.
|
|
8
|
+
|
|
9
|
+
const config = require('@zone-eu/wild-config');
|
|
10
|
+
const { readEnvValue, hasEnvValue } = require('./read-env-value');
|
|
11
|
+
const { getBoolean } = require('./get-boolean');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Object} [api] - The `[api]` section of the configuration
|
|
15
|
+
* @returns {number|undefined} EENGINE_PORT, then PORT, then `[api] port`
|
|
16
|
+
*/
|
|
17
|
+
function apiPort(api = config.api || {}) {
|
|
18
|
+
return (hasEnvValue('EENGINE_PORT') && Number(readEnvValue('EENGINE_PORT'))) || (hasEnvValue('PORT') && Number(readEnvValue('PORT'))) || api.port;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Object} [api] - The `[api]` section of the configuration
|
|
23
|
+
* @returns {string|undefined} EENGINE_HOST, then `[api] host`
|
|
24
|
+
*/
|
|
25
|
+
function apiHost(api = config.api || {}) {
|
|
26
|
+
return readEnvValue('EENGINE_HOST') || api.host;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether, and how, the API listener serves TLS: EENGINE_API_TLS and `[api.tls]`.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} [api] - The `[api]` section of the configuration
|
|
33
|
+
* @returns {Object|false} The `[api.tls]` options to build the listener from, or false when the
|
|
34
|
+
* API serves plain HTTP
|
|
35
|
+
*/
|
|
36
|
+
function apiTlsConfig(api = config.api || {}) {
|
|
37
|
+
return hasEnvValue('EENGINE_API_TLS') ? getBoolean(readEnvValue('EENGINE_API_TLS')) && (api.tls || {}) : api.tls || false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { apiPort, apiHost, apiTlsConfig };
|