emailengine-app 2.79.3 → 2.79.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy.yml +17 -1
- package/.github/workflows/release.yaml +17 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +17 -0
- package/lib/account/auth-failure-backfill.js +176 -0
- package/lib/account/imap-data.js +74 -0
- package/lib/account.js +315 -108
- package/lib/api-routes/account-routes.js +7 -1
- package/lib/consts.js +23 -0
- package/lib/email-client/base-client.js +61 -31
- package/lib/email-client/gmail-client.js +6 -0
- package/lib/email-client/outlook-client.js +7 -0
- package/lib/enum-descriptions.js +1 -1
- package/lib/schemas.js +11 -1
- package/lib/ui-routes/account-routes.js +90 -7
- package/lib/ui-routes/dashboard-routes.js +22 -0
- package/lib/ui-routes/route-helpers.js +11 -5
- package/package.json +1 -1
- package/server.js +10 -0
- package/views/accounts/account.hbs +47 -2
- package/views/legal.hbs +1 -1
|
@@ -149,7 +149,9 @@ jobs:
|
|
|
149
149
|
name: digests-${{ matrix.arch }}
|
|
150
150
|
path: /tmp/digests/*
|
|
151
151
|
if-no-files-found: error
|
|
152
|
-
|
|
152
|
+
# Long enough for "Re-run failed jobs" on a later working day to still find the
|
|
153
|
+
# digest of the leg that passed; the check below refuses to publish without it
|
|
154
|
+
retention-days: 7
|
|
153
155
|
|
|
154
156
|
docker-manifest:
|
|
155
157
|
name: Publish Docker Manifest
|
|
@@ -168,6 +170,20 @@ jobs:
|
|
|
168
170
|
pattern: digests-*
|
|
169
171
|
merge-multiple: true
|
|
170
172
|
|
|
173
|
+
# One digest file per platform in the build matrix. With fail-fast off, one leg can
|
|
174
|
+
# push its digest while the other fails, and a re-run that finds only the surviving
|
|
175
|
+
# artifact (or none, once they expire) would otherwise publish a single-platform
|
|
176
|
+
# manifest list under every tag as if it were complete.
|
|
177
|
+
- name: Check that every platform produced a digest
|
|
178
|
+
working-directory: /tmp/digests
|
|
179
|
+
run: |
|
|
180
|
+
count=$(ls -1 | wc -l)
|
|
181
|
+
if [ "$count" -ne 2 ]; then
|
|
182
|
+
echo "Expected 2 digests (linux/amd64, linux/arm64), found $count:"
|
|
183
|
+
ls -1
|
|
184
|
+
exit 1
|
|
185
|
+
fi
|
|
186
|
+
|
|
171
187
|
- name: Set up Docker Buildx
|
|
172
188
|
uses: docker/setup-buildx-action@v4
|
|
173
189
|
|
|
@@ -146,7 +146,9 @@ jobs:
|
|
|
146
146
|
name: digests-${{ matrix.arch }}
|
|
147
147
|
path: /tmp/digests/*
|
|
148
148
|
if-no-files-found: error
|
|
149
|
-
|
|
149
|
+
# Long enough for "Re-run failed jobs" on a later working day to still find the
|
|
150
|
+
# digest of the leg that passed; the check below refuses to publish without it
|
|
151
|
+
retention-days: 7
|
|
150
152
|
|
|
151
153
|
publish_docker_manifest:
|
|
152
154
|
name: Publish Tagged Docker Manifest
|
|
@@ -164,6 +166,20 @@ jobs:
|
|
|
164
166
|
pattern: digests-*
|
|
165
167
|
merge-multiple: true
|
|
166
168
|
|
|
169
|
+
# One digest file per platform in the build matrix. With fail-fast off, one leg can
|
|
170
|
+
# push its digest while the other fails, and a re-run that finds only the surviving
|
|
171
|
+
# artifact (or none, once they expire) would otherwise publish a single-platform
|
|
172
|
+
# manifest list under every tag as if it were complete.
|
|
173
|
+
- name: Check that every platform produced a digest
|
|
174
|
+
working-directory: /tmp/digests
|
|
175
|
+
run: |
|
|
176
|
+
count=$(ls -1 | wc -l)
|
|
177
|
+
if [ "$count" -ne 2 ]; then
|
|
178
|
+
echo "Expected 2 digests (linux/amd64, linux/arm64), found $count:"
|
|
179
|
+
ls -1
|
|
180
|
+
exit 1
|
|
181
|
+
fi
|
|
182
|
+
|
|
167
183
|
- name: Set up Docker Buildx
|
|
168
184
|
uses: docker/setup-buildx-action@v4
|
|
169
185
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.79.5](https://github.com/postalsys/emailengine/compare/v2.79.4...v2.79.5) (2026-08-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **accounts:** bring back the OAuth2 accounts 2.79.3 switched off ([e55520c](https://github.com/postalsys/emailengine/commit/e55520c8a669677a5af3e4ed726ecc0e329ad84a))
|
|
9
|
+
* **accounts:** close the gaps in the auth-failure park for OAuth2 accounts ([6a015b6](https://github.com/postalsys/emailengine/commit/6a015b6ba10a1e6a39575fa96539d311c00aa958))
|
|
10
|
+
|
|
11
|
+
## [2.79.4](https://github.com/postalsys/emailengine/compare/v2.79.3...v2.79.4) (2026-08-25)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **accounts:** let re-authorization bring back an account the safety net switched off ([b4f04f5](https://github.com/postalsys/emailengine/commit/b4f04f54ce37342c69bbcda65f8b5eb1a331423c))
|
|
17
|
+
* **accounts:** report a switched-off account, and stop pretending to reconnect it ([6c19ea2](https://github.com/postalsys/emailengine/commit/6c19ea2cf05ea49d212b8fdbcd12aa9d8a6e36f5))
|
|
18
|
+
* **admin:** serve the SBOM download from the admin surface ([96aa63e](https://github.com/postalsys/emailengine/commit/96aa63ee1aaa409d1f279b4fffa89e1e04317484))
|
|
19
|
+
|
|
3
20
|
## [2.79.3](https://github.com/postalsys/emailengine/compare/v2.79.2...v2.79.3) (2026-08-24)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// One-time bridge for the OAuth2 accounts 2.79.3 switched off and 2.79.4 cannot recognise.
|
|
4
|
+
//
|
|
5
|
+
// 2.79.3 extended the auth-failure safety net to OAuth2 accounts, which until then it had skipped in
|
|
6
|
+
// silence, and its release note predicted the result: on upgrade, every account whose refresh token
|
|
7
|
+
// had already been dead for longer than the threshold was parked in one burst. It recorded that park
|
|
8
|
+
// as `imap.disabled` and nothing else.
|
|
9
|
+
//
|
|
10
|
+
// 2.79.4 then gave the automatic park its own provenance marker, because `imap.disabled` is also the
|
|
11
|
+
// operator's deliberate send-only switch and the two must not share one boolean. Every recovery and
|
|
12
|
+
// reporting surface reads the marker: the API's `authFailureDisabledAt`, the account page's
|
|
13
|
+
// "Syncing was switched off" alert and its "Resume syncing" action, the listing's state badge, the
|
|
14
|
+
// reconnect refusal, and - the one that matters here - the lift that re-authorization performs
|
|
15
|
+
// through Account.create() and Account.update().
|
|
16
|
+
//
|
|
17
|
+
// So an account parked during the roughly nineteen hours 2.79.3 was the current release reads as one
|
|
18
|
+
// the operator switched off on purpose. Re-authorizing it, through the hosted authentication form or
|
|
19
|
+
// POST /v1/account, reports success and lifts nothing. That is unrecoverable rather than merely
|
|
20
|
+
// wrong for an OAuth2 account: its page renders no IMAP settings card, so there is no disable
|
|
21
|
+
// checkbox to clear, and "Resume syncing" is marker-gated like everything else.
|
|
22
|
+
//
|
|
23
|
+
// The signature is therefore the synthesized blob 2.79.3 wrote for exactly that population, not the
|
|
24
|
+
// park in general: the bare flag, an OAuth2 credential, and an authentication error beside them
|
|
25
|
+
// (see isLegacyPark() for why the error is not required to be the park's own text). A password
|
|
26
|
+
// account carries a real IMAP configuration and has been wearing this same threshold error state
|
|
27
|
+
// since v2.46.0 (2024-08-28), where the safety net first shipped; it is deliberately not matched,
|
|
28
|
+
// because it was never stuck - clearing its checkbox is an explicit `disabled: false`, which is not
|
|
29
|
+
// marker-gated - and matching it would stamp accounts nobody has touched in two years with a park
|
|
30
|
+
// time of today.
|
|
31
|
+
//
|
|
32
|
+
// The true park time is not recoverable, since 2.79.3 stored none, so the marker holds the time of
|
|
33
|
+
// this run and the log says so. It overstates how recently the account stopped syncing, by however
|
|
34
|
+
// long the instance sat on 2.79.3, and that is the only cost of making it recoverable.
|
|
35
|
+
//
|
|
36
|
+
// Retire this once no supported upgrade path starts below 2.79.4. Until then a completion key says
|
|
37
|
+
// it has run, because a successful backfill leaves nothing behind to re-detect. An instance rolled
|
|
38
|
+
// back onto 2.79.3 afterwards, or a 2.79.3 sibling still parking accounts on the same Redis during a
|
|
39
|
+
// rolling upgrade, would leave a second batch that the key then hides; re-arming means deleting
|
|
40
|
+
// BACKFILL_KEY and restarting.
|
|
41
|
+
|
|
42
|
+
const { redis } = require('../db');
|
|
43
|
+
const logger = require('../logger');
|
|
44
|
+
const { parseImapData } = require('./imap-data');
|
|
45
|
+
const { REDIS_PREFIX, AUTH_FAILURE_DISABLED_FIELD, AUTH_FAILURE_DISABLED_LEGACY_DESCRIPTION } = require('../consts');
|
|
46
|
+
|
|
47
|
+
// Marks the backfill as done for this Redis. Value is the ISO time of the run.
|
|
48
|
+
const BACKFILL_KEY = `${REDIS_PREFIX}migration:authFailureDisabled`;
|
|
49
|
+
|
|
50
|
+
// Accounts read per pipeline. Large installs hold tens of thousands, and sequential reads would
|
|
51
|
+
// stall startup; matches the chunking oauth2Apps.migrateLegacyApps() uses for its own backfill.
|
|
52
|
+
const CHUNK_SIZE = 500;
|
|
53
|
+
|
|
54
|
+
// Fields the scan reads per account, in the order isLegacyPark() destructures them
|
|
55
|
+
const SCAN_FIELDS = ['imap', AUTH_FAILURE_DISABLED_FIELD, 'lastErrorState', 'oauth2'];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether an account hash carries the park 2.79.3 wrote for an OAuth2 account.
|
|
59
|
+
*
|
|
60
|
+
* @param {Array} row - The SCAN_FIELDS values as stored, any of them null
|
|
61
|
+
* @returns {Boolean} True when the marker should be backfilled for this account
|
|
62
|
+
*/
|
|
63
|
+
function isLegacyPark([imapInfo, marker, errorStateInfo, oauth2Info]) {
|
|
64
|
+
// Ordered cheapest first, so a healthy fleet is rejected without parsing anything. A successful
|
|
65
|
+
// connection deletes lastErrorState outright, and only an OAuth2 credential could have been
|
|
66
|
+
// parked into an `imap` blob the account does not otherwise own.
|
|
67
|
+
if (marker || !imapInfo || !errorStateInfo || !oauth2Info) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { imapData } = parseImapData(imapInfo);
|
|
72
|
+
|
|
73
|
+
// The whole blob 2.79.3 synthesized was the flag. A `host` means a real IMAP configuration that
|
|
74
|
+
// the operator can re-enable from the account page, which is the population deliberately left
|
|
75
|
+
// out; anything that did not parse to a usable object was never written by the safety net.
|
|
76
|
+
if (!imapData || imapData.disabled !== true || imapData.host) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let errorState;
|
|
81
|
+
try {
|
|
82
|
+
errorState = JSON.parse(errorStateInfo);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The threshold text is what 2.79.3 wrote at the park, and it does not always survive: a parked
|
|
88
|
+
// account still serves send requests and, for Gmail, push notifications, and each of those runs
|
|
89
|
+
// the same failing token refresh through setErrorState(), which overwrites the stored error with
|
|
90
|
+
// the refresh failure that caused the park. That failure carries a serverResponseCode
|
|
91
|
+
// ('TokenGenerationError', 'OauthRenewError') where the park text carries none, so either shape
|
|
92
|
+
// counts. The operator's send-only switch is still told apart by what sits beside the bare
|
|
93
|
+
// flag: a deliberately switched-off account has no reason to carry a coded authentication error.
|
|
94
|
+
return !!errorState && (errorState.description === AUTH_FAILURE_DISABLED_LEGACY_DESCRIPTION || !!errorState.serverResponseCode);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Backfills AUTH_FAILURE_DISABLED_FIELD onto the OAuth2 accounts 2.79.3 parked, so the 2.79.4
|
|
99
|
+
* recovery paths can see them.
|
|
100
|
+
*
|
|
101
|
+
* No lock, unlike oauth2Apps.migrateLegacyApps(): every write here is an idempotent set of the same
|
|
102
|
+
* field on an account already carrying the signature, so two instances sharing one Redis can both
|
|
103
|
+
* run it and the worst that happens is the scan being done twice. Taking a lock would cost every
|
|
104
|
+
* instance a permanent second Redis connection - ioredfour duplicates one for its subscriber and
|
|
105
|
+
* offers no way to close it - to serialize something that does not need serializing.
|
|
106
|
+
*
|
|
107
|
+
* @param {Object} [opts] - Overrides for tests; the defaults are the shared clients
|
|
108
|
+
* @param {Object} [opts.redis] - ioredis client, carrying the hSetExists custom command
|
|
109
|
+
* @param {Object} [opts.logger] - Logger
|
|
110
|
+
* @returns {Promise<Number>} How many accounts were backfilled
|
|
111
|
+
*/
|
|
112
|
+
async function backfillAuthFailureDisabled(opts = {}) {
|
|
113
|
+
const { redis: client = redis, logger: log = logger } = opts;
|
|
114
|
+
|
|
115
|
+
// The common case is an instance that never ran 2.79.3, and this is the whole cost for it
|
|
116
|
+
if (await client.exists(BACKFILL_KEY)) {
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const stamp = new Date().toISOString();
|
|
121
|
+
const accounts = await client.smembers(`${REDIS_PREFIX}ia:accounts`);
|
|
122
|
+
|
|
123
|
+
// One write pipeline for the whole scan rather than one per chunk: matches are a small subset by
|
|
124
|
+
// definition, and a round trip per chunk would double what the scan costs at startup.
|
|
125
|
+
const writeReq = client.pipeline();
|
|
126
|
+
let queued = 0;
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < accounts.length; i += CHUNK_SIZE) {
|
|
129
|
+
const chunk = accounts.slice(i, i + CHUNK_SIZE);
|
|
130
|
+
|
|
131
|
+
const readReq = client.pipeline();
|
|
132
|
+
for (const account of chunk) {
|
|
133
|
+
readReq.hmget(`${REDIS_PREFIX}iad:${account}`, ...SCAN_FIELDS);
|
|
134
|
+
}
|
|
135
|
+
const rows = await readReq.exec();
|
|
136
|
+
|
|
137
|
+
for (let j = 0; j < chunk.length; j++) {
|
|
138
|
+
const [err, row] = rows[j];
|
|
139
|
+
if (err || !row || !isLegacyPark(row)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
// hSetExists rather than hset, for the same reason the safety net writes it that way: an
|
|
143
|
+
// account deleted between the read above and this write must not come back as a hash
|
|
144
|
+
// holding nothing but a marker.
|
|
145
|
+
writeReq.hSetExists(`${REDIS_PREFIX}iad:${chunk[j]}`, AUTH_FAILURE_DISABLED_FIELD, stamp);
|
|
146
|
+
queued++;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Counted from the replies rather than from what was queued: hSetExists writes nothing to an
|
|
151
|
+
// account deleted since the read, and a marker the log claims but Redis does not hold would send
|
|
152
|
+
// whoever reads that number looking for accounts that are still invisible.
|
|
153
|
+
let backfilled = 0;
|
|
154
|
+
if (queued) {
|
|
155
|
+
const results = await writeReq.exec();
|
|
156
|
+
backfilled = (results || []).filter(([err, written]) => !err && written).length;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Written last, so a crash mid-scan re-enters and repeats it. Every write is idempotent, so
|
|
160
|
+
// repeating costs nothing.
|
|
161
|
+
await client.set(BACKFILL_KEY, stamp);
|
|
162
|
+
|
|
163
|
+
if (queued) {
|
|
164
|
+
log.info({
|
|
165
|
+
msg: 'Backfilled the auth-failure disable marker for accounts switched off by an earlier version',
|
|
166
|
+
accounts: backfilled,
|
|
167
|
+
skipped: queued - backfilled,
|
|
168
|
+
disabledAt: stamp,
|
|
169
|
+
note: 'the recorded time is when this ran, not when the accounts were switched off'
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return backfilled;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
module.exports = { backfillAuthFailureDisabled, isLegacyPark, BACKFILL_KEY };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Decides what a stored `imap` blob is, without reading it.
|
|
5
|
+
*
|
|
6
|
+
* Split out from readImapData() so a caller that already holds the raw field, and cannot await or
|
|
7
|
+
* afford a log line per account, still shares the one definition of a usable blob. The scan in
|
|
8
|
+
* auth-failure-backfill.js is that caller.
|
|
9
|
+
*
|
|
10
|
+
* @param {String} imapInfo - The raw field as stored
|
|
11
|
+
* @param {Object} [logger] - Logger for a blob that cannot be used; silent when omitted
|
|
12
|
+
* @returns {{imapData: Object|null, invalid: Boolean}} See readImapData()
|
|
13
|
+
*/
|
|
14
|
+
function parseImapData(imapInfo, logger) {
|
|
15
|
+
if (!imapInfo) {
|
|
16
|
+
return { imapData: null, invalid: false };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let imapData;
|
|
20
|
+
try {
|
|
21
|
+
imapData = JSON.parse(imapInfo);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
logger?.error({ msg: 'Failed parsing IMAP data', err });
|
|
24
|
+
return { imapData: null, invalid: true };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// `null` parses fine and is an absent blob, which is what it is. So is `false`: it is what POST
|
|
28
|
+
// and PUT /v1/account store when the payload says there is no IMAP access to configure
|
|
29
|
+
// (`imap: false`), the documented way to register an OAuth2 account without one. Reporting it
|
|
30
|
+
// as unreadable would exempt exactly those accounts from the safety net and log an error on
|
|
31
|
+
// every init.
|
|
32
|
+
if (imapData === null || imapData === false) {
|
|
33
|
+
return { imapData: null, invalid: false };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Parsing is not enough: every caller goes on to read or set `disabled` on what comes back, and
|
|
37
|
+
// a blob that parsed to a scalar throws on the assignment while one that parsed to an array
|
|
38
|
+
// takes the flag and loses it again at the next JSON.stringify. Only an object is usable, so a
|
|
39
|
+
// stored value that is anything else counts as unreadable and is left alone rather than
|
|
40
|
+
// replaced with a bare flag.
|
|
41
|
+
if (typeof imapData !== 'object' || Array.isArray(imapData)) {
|
|
42
|
+
logger?.error({ msg: 'Unexpected IMAP data type', type: Array.isArray(imapData) ? 'array' : typeof imapData });
|
|
43
|
+
return { imapData: null, invalid: true };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { imapData, invalid: false };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Reads an account's stored `imap` blob.
|
|
51
|
+
*
|
|
52
|
+
* Three call sites need it before, or instead of, a full account load: the connection gate that
|
|
53
|
+
* asks whether syncing is switched off, the safety net that switches it off, and the recovery path
|
|
54
|
+
* that switches it back on. They all have to treat an unreadable blob the same way - rewriting one
|
|
55
|
+
* that does not parse would replace the account's IMAP configuration with a bare flag - so the
|
|
56
|
+
* decision lives here rather than in three copies of the same try/catch.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} redis - ioredis client
|
|
59
|
+
* @param {String} accountKey - Redis key of the account hash
|
|
60
|
+
* @param {Object} logger - Logger for the parse failure
|
|
61
|
+
* @param {String} [imapInfo] - The raw field when the caller has already read it, to save a round trip
|
|
62
|
+
* @returns {Promise<{imapData: Object|null, invalid: Boolean}>} The parsed blob, or null with
|
|
63
|
+
* `invalid` telling an absent field (an OAuth2 account has none) apart from an unreadable one.
|
|
64
|
+
* Unreadable covers anything the callers cannot use, not only text that fails to parse
|
|
65
|
+
*/
|
|
66
|
+
async function readImapData(redis, accountKey, logger, imapInfo) {
|
|
67
|
+
if (imapInfo === undefined) {
|
|
68
|
+
imapInfo = await redis.hget(accountKey, 'imap');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return parseImapData(imapInfo, logger);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = { readImapData, parseImapData };
|