emailengine-app 2.79.2 → 2.79.4

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/lib/account.js CHANGED
@@ -26,18 +26,19 @@ const settings = require('./settings');
26
26
  const { buildRetentionPolicy } = require('./queue-retention');
27
27
  const { isDocumentStoreEnabled, documentStoreFeatureEnabled } = require('./document-store');
28
28
  const redisScanDelete = require('./redis-scan-delete');
29
- const { extractMultiValues } = require('./redis-operations');
29
+ const { extractMultiValues, createTransaction } = require('./redis-operations');
30
30
  const outbox = require('./outbox');
31
31
  const tokens = require('./tokens');
32
32
  const { customAlphabet } = require('nanoid');
33
33
  const Lock = require('ioredfour');
34
34
  const { redis } = require('./db');
35
35
  const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 16);
36
- const { REDIS_PREFIX, ACCOUNT_DELETED_NOTIFY } = require('./consts');
36
+ const { REDIS_PREFIX, ACCOUNT_DELETED_NOTIFY, AUTH_FAILURE_DISABLED_FIELD } = require('./consts');
37
37
  const { messageWebSafeHtml, webSafeTextResponse, applyWebSafeHtmlOptions } = require('./web-safe-html');
38
38
  const { checkAccountScopes: checkScopes } = require('./oauth/scope-checker');
39
39
  const { ACCOUNT_STATES, ERROR_STATES, calculateEffectiveState, validateAccountState, getDisplayState, formatLastError } = require('./account/account-state');
40
40
  const { decodeStoredMailboxEntry } = require('./email-client/imap/listing-diff');
41
+ const { readImapData } = require('./account/imap-data');
41
42
 
42
43
  // Shared Lock instance to prevent Redis connection leak (one subscriber per Lock instance)
43
44
  // Previously, each Account created its own Lock, causing ~30k connections with 30k accounts
@@ -51,6 +52,54 @@ const defaultLock = new Lock({
51
52
  const ACCOUNT_UPDATE_LOCK_TTL = 10 * 1000;
52
53
  const ACCOUNT_UPDATE_LOCK_WAIT = 5 * 1000;
53
54
 
55
+ /**
56
+ * What an incoming account payload asks of `imap.disabled`.
57
+ *
58
+ * Must be read before persistUpdate() merges a `partial` payload into the stored object, which
59
+ * would otherwise pull `disabled` in from the old blob and make every partial update look like a
60
+ * decision about the flag.
61
+ *
62
+ * @param {Object} accountData - Account fields about to be written
63
+ * @returns {Boolean|null} What the payload sets the flag to, or null when it says nothing about it
64
+ */
65
+ function imapDisabledIntent(accountData) {
66
+ if (!accountData.imap || typeof accountData.imap !== 'object' || !('disabled' in accountData.imap)) {
67
+ return null;
68
+ }
69
+ return !!accountData.imap.disabled;
70
+ }
71
+
72
+ /**
73
+ * Whether syncing was switched off for an account, by either route.
74
+ *
75
+ * @param {Object} accountData - An unserialized account
76
+ * @returns {Boolean} True when `imap.disabled` is set
77
+ */
78
+ function isImapDisabled(accountData) {
79
+ return !!(accountData && accountData.imap && accountData.imap.disabled);
80
+ }
81
+
82
+ /**
83
+ * When the auth-failure safety net switched an account off, as opposed to the operator doing it.
84
+ *
85
+ * The single answer to "is this account parked", used by every surface that reports one: the API
86
+ * field, the admin state badge, the page alert, and the reconnect dispatches in create()/update().
87
+ *
88
+ * Both halves of the test matter. The marker can outlive the flag - an operator re-enables the
89
+ * account by hand and the stale marker is only retired on the next recovery pass - so reading it
90
+ * alone would report a healthy, syncing account as switched off. And re-authorizing a healthy
91
+ * account must not trigger the reconnect that un-parking one does.
92
+ *
93
+ * @param {Object} accountData - An unserialized account, carrying `_authFailureDisabledAt`
94
+ * @returns {String|null} ISO timestamp of the disable, or null when the safety net did not park it
95
+ */
96
+ function authFailureDisabledAt(accountData) {
97
+ if (!accountData || !accountData._authFailureDisabledAt || !isImapDisabled(accountData)) {
98
+ return null;
99
+ }
100
+ return accountData._authFailureDisabledAt;
101
+ }
102
+
54
103
  class Account {
55
104
  constructor(options) {
56
105
  this.redis = options.redis;
@@ -302,6 +351,10 @@ class Account {
302
351
 
303
352
  syncTime: accountData.sync,
304
353
 
354
+ // Lets a caller find every account the safety net parked without opening each one.
355
+ // Omitted rather than null when it did not, like the optional fields above.
356
+ authFailureDisabledAt: authFailureDisabledAt(accountData) || undefined,
357
+
305
358
  lastError: formatLastError(accountData),
306
359
 
307
360
  delegationError: accountData.delegationError || undefined
@@ -349,6 +402,15 @@ class Account {
349
402
  unserializeAccountData(accountData) {
350
403
  const result = {};
351
404
 
405
+ // The loop below drops every `_`-prefixed field, which is what keeps the auth-failure marker
406
+ // out of API responses - but the state label and the recovery paths both need it, and it is
407
+ // already in every hash read. Carry it across explicitly, under a name that is NOT the
408
+ // stored field's: a loaded account fed back through serializeAccountData then cannot
409
+ // resurrect a marker that has since been retired.
410
+ if (accountData[AUTH_FAILURE_DISABLED_FIELD]) {
411
+ result._authFailureDisabledAt = accountData[AUTH_FAILURE_DISABLED_FIELD];
412
+ }
413
+
352
414
  const counters = {};
353
415
 
354
416
  Object.keys(accountData).forEach(key => {
@@ -820,6 +882,9 @@ class Account {
820
882
  * @returns {Promise<Object>} `{ account }`
821
883
  */
822
884
  async update(accountData, { reauthorized = false } = {}) {
885
+ // Captured before persistUpdate() merges a `partial` payload into the stored object
886
+ const disabledIntent = imapDisabledIntent(accountData);
887
+
823
888
  const lock = this.getLock();
824
889
  const lockKey = `account:update:${accountData.account}`;
825
890
  let updateLock;
@@ -849,7 +914,7 @@ class Account {
849
914
  }
850
915
  }
851
916
 
852
- await this.dispatchPostUpdateCommands(accountData, oldAccountData, reauthorized);
917
+ await this.dispatchPostUpdateCommands(accountData, oldAccountData, reauthorized, disabledIntent);
853
918
 
854
919
  return {
855
920
  account: this.account
@@ -976,9 +1041,11 @@ class Account {
976
1041
  * @param {Object} accountData - The fields that were just written
977
1042
  * @param {Object} oldAccountData - The account as it was before the write
978
1043
  * @param {boolean} reauthorized - Whether the caller supplied fresh operator credentials
1044
+ * @param {Boolean|null} disabledIntent - What the payload asked of `imap.disabled`, read before
1045
+ * persistUpdate() merged it
979
1046
  * @returns {Promise<void>} Resolves once the dispatch has been attempted
980
1047
  */
981
- async dispatchPostUpdateCommands(accountData, oldAccountData, reauthorized) {
1048
+ async dispatchPostUpdateCommands(accountData, oldAccountData, reauthorized, disabledIntent) {
982
1049
  let reconnectRequested = false;
983
1050
 
984
1051
  if ('imap' in accountData && !reconnectRequested) {
@@ -1024,29 +1091,43 @@ class Account {
1024
1091
  }
1025
1092
  }
1026
1093
 
1027
- // When OAuth2 credentials are re-authorized for an account that is currently in a
1028
- // non-operational error state, trigger a full reconnect so syncing resumes without a
1029
- // manual "Reconnect".
1030
- //
1031
- // Requires explicit `reauthorized` intent from the caller. Account state cannot be used
1032
- // to infer it: unattended token renewal persists through update() as well, and it runs
1033
- // while the stored state is still the error state, so a state-only gate re-fired on every
1034
- // renewal and dispatched cmd:'reconnect'. That rebuilt the client, discarding its backoff,
1035
- // and invalidateAccessToken() forced the next cycle to renew again - latching a reconnect
1094
+ // Whether this update carries OAuth2 credentials the operator just re-authorized. The
1095
+ // `reauthorized` intent has to be explicit: account state cannot be used to infer it,
1096
+ // because unattended token renewal persists through update() as well, and it runs while
1097
+ // the stored state is still the error state. A state-only gate re-fired on every renewal
1098
+ // and dispatched cmd:'reconnect'. That rebuilt the client, discarding its backoff, and
1099
+ // invalidateAccessToken() forced the next cycle to renew again - latching a reconnect
1036
1100
  // loop that pinned the CPU at ~100%.
1037
- if (
1101
+ const oauth2Reauthorized =
1038
1102
  reauthorized &&
1039
- !reconnectRequested &&
1040
- accountData.oauth2?.accessToken &&
1041
- (accountData.oauth2.accessToken !== oldAccountData.oauth2?.accessToken ||
1042
- accountData.oauth2.refreshToken !== oldAccountData.oauth2?.refreshToken) &&
1043
- ERROR_STATES.includes(oldAccountData.state)
1044
- ) {
1103
+ !!accountData.oauth2?.accessToken &&
1104
+ (accountData.oauth2.accessToken !== oldAccountData.oauth2?.accessToken || accountData.oauth2.refreshToken !== oldAccountData.oauth2?.refreshToken);
1105
+
1106
+ // A reconnect cannot resume an account the auth-failure safety net has switched off, so
1107
+ // settle that first. For a password account the operator clears the flag by saving new IMAP
1108
+ // settings, but an OAuth2 account has none to save - the re-authorization IS the fix, and
1109
+ // without this the account stays off until somebody hand-edits it through the API.
1110
+ //
1111
+ // The lift is deliberately NOT gated on the account state, unlike the reconnect below: a
1112
+ // parked account does not sit in an error state, it reports `unset` (persisted on every
1113
+ // init for Gmail API and Outlook accounts), so by the time the operator re-authorizes, the
1114
+ // error state the old gate required is long gone.
1115
+ await this.resolveAuthFailureDisable(disabledIntent, oldAccountData, oauth2Reauthorized);
1116
+
1117
+ // Re-authorization for an account that is currently non-operational triggers a full
1118
+ // reconnect so syncing resumes without a manual "Reconnect". Being switched off is such a
1119
+ // state, and one the account cannot leave on its own. Read off the account as it stood
1120
+ // before the write, for the same reason as in create().
1121
+ const wasParked = !!authFailureDisabledAt(oldAccountData);
1122
+
1123
+ if (oauth2Reauthorized && !reconnectRequested && (ERROR_STATES.includes(oldAccountData.state) || wasParked)) {
1045
1124
  this.logger.info({
1046
- msg: 'OAuth2 credentials re-authorized for account in error state, requesting reconnect',
1125
+ msg: 'OAuth2 credentials re-authorized for non-operational account, requesting reconnect',
1047
1126
  account: this.account,
1048
- state: oldAccountData.state
1127
+ state: oldAccountData.state,
1128
+ wasParked
1049
1129
  });
1130
+
1050
1131
  if (typeof this.call === 'function') {
1051
1132
  try {
1052
1133
  await this.call({
@@ -1089,6 +1170,98 @@ class Account {
1089
1170
  return id;
1090
1171
  }
1091
1172
 
1173
+ /**
1174
+ * Resolves the auth-failure disable against an account write that has just been persisted.
1175
+ *
1176
+ * @param {Boolean|null} disabledIntent - What the write asked of `imap.disabled`, from
1177
+ * imapDisabledIntent(), read before any partial merge
1178
+ * @param {Object} oldAccountData - The account as it stood before the write
1179
+ * @param {Boolean} mayLift - Whether this write is an explicit re-authorization, the only kind
1180
+ * that may resume a parked account on its own
1181
+ * @returns {Promise<Boolean>} True when this call re-enabled the account
1182
+ */
1183
+ async resolveAuthFailureDisable(disabledIntent, oldAccountData, mayLift) {
1184
+ if (disabledIntent === true) {
1185
+ // The write asks for IMAP to stay off, so there is nothing to lift. It takes ownership
1186
+ // of the flag only when it is what turned it on: the admin edit form submits its
1187
+ // "Disable IMAP" checkbox on every save, pre-checked from the stored flag, so treating
1188
+ // that restatement as a decision would let an unrelated save silently convert an
1189
+ // automatic park into a deliberate one - taking the page alert, the state badge and
1190
+ // "Resume syncing" with it, and leaving the account unrecoverable by re-authorization.
1191
+ if (!isImapDisabled(oldAccountData)) {
1192
+ await this.redis.hdel(this.getAccountKey(), AUTH_FAILURE_DISABLED_FIELD);
1193
+ }
1194
+ return false;
1195
+ }
1196
+
1197
+ // An explicit `disabled: false` has already re-enabled the account by itself, and the call
1198
+ // below retires the marker it leaves behind. Anything else may only lift a park when the
1199
+ // operator actually re-authorized.
1200
+ if (disabledIntent === false || mayLift) {
1201
+ return await this.clearAuthFailureDisable();
1202
+ }
1203
+
1204
+ return false;
1205
+ }
1206
+
1207
+ /**
1208
+ * Re-enables an account that setErrorState() switched off after a run of authentication
1209
+ * failures. Called whenever fresh credentials arrive for the account, and by the admin UI's
1210
+ * "Resume syncing" action.
1211
+ *
1212
+ * Only ever lifts the safety net's own disable, never the operator's send-only switch - see
1213
+ * AUTH_FAILURE_DISABLED_FIELD for why the two need telling apart.
1214
+ *
1215
+ * Reads the stored values rather than trusting the copy loaded before the update, because the
1216
+ * same update may have rewritten the `imap` field.
1217
+ *
1218
+ * @returns {Promise<Boolean>} True when a disable flag was actually lifted
1219
+ */
1220
+ async clearAuthFailureDisable() {
1221
+ const accountKey = this.getAccountKey();
1222
+
1223
+ const [disabledAt, imapInfo] = await this.redis.hmget(accountKey, AUTH_FAILURE_DISABLED_FIELD, 'imap');
1224
+ if (!disabledAt) {
1225
+ // Either never parked, or an operator has already dealt with it. Not ours to lift.
1226
+ return false;
1227
+ }
1228
+
1229
+ const { imapData, invalid } = await readImapData(this.redis, accountKey, this.logger, imapInfo);
1230
+ if (invalid) {
1231
+ // Leave an unreadable configuration alone rather than replacing it with a bare flag.
1232
+ return false;
1233
+ }
1234
+
1235
+ if (!imapData || !imapData.disabled) {
1236
+ // The flag is already gone - an operator re-enabled the account by hand, or a full
1237
+ // `imap` rewrite dropped it. Retire the marker so it cannot authorize lifting a
1238
+ // later, deliberate disable.
1239
+ await this.redis.hdel(accountKey, AUTH_FAILURE_DISABLED_FIELD);
1240
+ return false;
1241
+ }
1242
+
1243
+ imapData.disabled = false;
1244
+
1245
+ // hSetExists rather than hset, so a concurrent account delete cannot be resurrected as a
1246
+ // hash holding nothing but this flag. Same reason disableAfterAuthFailures() writes it
1247
+ // that way.
1248
+ const clearTxn = createTransaction(this.redis, { logger: this.logger });
1249
+ clearTxn.add('hSetExists', accountKey, 'imap', JSON.stringify(imapData));
1250
+ clearTxn.add('hdel', accountKey, AUTH_FAILURE_DISABLED_FIELD);
1251
+ const { error } = await clearTxn.exec();
1252
+
1253
+ if (error) {
1254
+ // Report what happened rather than a lifted flag the caller would follow with a
1255
+ // reconnect into an account that is still switched off.
1256
+ this.logger.error({ msg: 'Failed to re-enable IMAP for account', account: this.account, err: error });
1257
+ return false;
1258
+ }
1259
+
1260
+ this.logger.info({ msg: 'Re-enabled IMAP for account after re-authorization', account: this.account, disabledAt });
1261
+
1262
+ return true;
1263
+ }
1264
+
1092
1265
  async create(accountData) {
1093
1266
  this.account = accountData.account;
1094
1267
  if (this.account === null) {
@@ -1172,8 +1345,17 @@ class Account {
1172
1345
  // existing user
1173
1346
  state = 'existing';
1174
1347
 
1348
+ // The account as it stood before the hmset above, from the snapshot the same pipeline
1349
+ // took. Read twice below - for the provider rebinding and for the recovery dispatch -
1350
+ // so it is unserialized once, outside the guard that only covers the rebinding.
1351
+ let oldAccountData = {};
1352
+ try {
1353
+ oldAccountData = this.unserializeAccountData(result[0][1]);
1354
+ } catch (err) {
1355
+ this.logger.error({ msg: 'Failed to read the stored account', account: this.account, err });
1356
+ }
1357
+
1175
1358
  try {
1176
- let oldAccountData = this.unserializeAccountData(result[0][1]);
1177
1359
  if (oldAccountData?.oauth2?.provider && oldAccountData?.oauth2?.auth?.user && oldAccountData.oauth2.provider !== accountData.oauth2?.provider) {
1178
1360
  // remove previous entry if provider was updated
1179
1361
  await this.redis.hdel(`${REDIS_PREFIX}oapp:h:${oldAccountData.oauth2.provider}`, oldAccountData.oauth2.auth?.user?.toLowerCase());
@@ -1182,22 +1364,36 @@ class Account {
1182
1364
  // ignore
1183
1365
  }
1184
1366
 
1367
+ // Re-registration is the operator supplying fresh credentials, and for an account the
1368
+ // auth-failure safety net has switched off it is the whole fix: the hosted
1369
+ // authentication form and POST /v1/account both land here, and neither has any other
1370
+ // way to reach the flag. Without this an OAuth2 account stayed parked no matter how
1371
+ // many times it was re-authorized, because create() writes no `imap` field of its own
1372
+ // and the synthesized `{"disabled":true}` blob survived untouched.
1373
+ //
1374
+ // The reconnect is decided by what was stored BEFORE this write, not by whether the
1375
+ // flag ended up lifted: a payload asking for IMAP to stay off lifts nothing, and either
1376
+ // way the account was not connecting and this write is what changed that.
1377
+ const wasParked = !!authFailureDisabledAt(oldAccountData);
1378
+ await this.resolveAuthFailureDisable(imapDisabledIntent(accountData), oldAccountData, true);
1379
+
1185
1380
  const oldState = result[0][1].state;
1186
- if (ERROR_STATES.includes(oldState)) {
1187
- // Re-registration of an account that was in a non-operational error state (the
1188
- // interactive OAuth re-auth redirect and the IMAP re-credentials form both land here).
1381
+ if (ERROR_STATES.includes(oldState) || wasParked) {
1382
+ // Re-registration of an account that is not operational (the interactive OAuth
1383
+ // re-auth redirect and the IMAP re-credentials form both land here).
1189
1384
  // cmd:'update' only calls reconnect() on the existing client instance, which cannot
1190
1385
  // switch client type (IMAP to API or back) and is a no-op against a torn-down
1191
1386
  // connection, so syncing would not resume without a manual "Reconnect". cmd:'reconnect'
1192
1387
  // closes and re-assigns a fresh client of the correct provider type. assignConnection
1193
1388
  // sets the state to "connecting" before any network work, so this cannot loop.
1194
- // Gated on the error state alone (unlike update(), which also requires the oauth2
1195
- // token to have changed): create() runs only on explicit re-registration, never on
1196
- // routine token renewal, so there is no healthy-account churn to suppress here.
1389
+ // Needs no credential-change check (unlike update()): create() runs only on explicit
1390
+ // re-registration, never on routine token renewal, so there is no healthy-account
1391
+ // churn to suppress here.
1197
1392
  this.logger.info({
1198
- msg: 'Account re-created while in error state, requesting full reconnect',
1393
+ msg: 'Account re-created while not operational, requesting full reconnect',
1199
1394
  account: this.account,
1200
- state: oldState
1395
+ state: oldState,
1396
+ wasParked
1201
1397
  });
1202
1398
  try {
1203
1399
  await this.call({
@@ -2586,18 +2782,38 @@ class Account {
2586
2782
  );
2587
2783
  }
2588
2784
 
2785
+ /**
2786
+ * Requests a fresh connection for the account.
2787
+ *
2788
+ * Answers false rather than reporting a reconnect it knows will not happen. A reconnect
2789
+ * rebuilds the client, but init() checks the auth-failure disable before it dials out and
2790
+ * returns without connecting, so for a parked account the dispatch is a no-op - and saying
2791
+ * "reconnecting" to a caller whose account then stays offline is worse than saying no.
2792
+ * Recovering it takes fresh credentials, or the admin UI's "Resume syncing".
2793
+ *
2794
+ * @param {Object} data
2795
+ * @param {Boolean} data.reconnect - Only reconnect when true
2796
+ * @returns {Promise<Boolean>} Whether a reconnect was actually requested
2797
+ */
2589
2798
  async requestReconnect(data) {
2590
- await this.loadAccountData(this.account, false);
2799
+ const accountData = await this.loadAccountData(this.account, false);
2591
2800
 
2592
- if (data.reconnect) {
2593
- await this.call({
2594
- cmd: 'reconnect',
2595
- account: this.account,
2596
- timeout: this.timeout
2597
- });
2598
- return true;
2801
+ if (!data.reconnect) {
2802
+ return false;
2599
2803
  }
2600
- return false;
2804
+
2805
+ const disabledAt = authFailureDisabledAt(accountData);
2806
+ if (disabledAt) {
2807
+ this.logger.info({ msg: 'Skipped reconnect request for an account that is switched off', account: this.account, disabledAt });
2808
+ return false;
2809
+ }
2810
+
2811
+ await this.call({
2812
+ cmd: 'reconnect',
2813
+ account: this.account,
2814
+ timeout: this.timeout
2815
+ });
2816
+ return true;
2601
2817
  }
2602
2818
 
2603
2819
  async requestSync(data) {
@@ -3119,4 +3335,4 @@ async function accountSummary(redis, account) {
3119
3335
  return { account, name: name || '', email: email || '', state: state || 'init' };
3120
3336
  }
3121
3337
 
3122
- module.exports = { Account, accountExists, accountsExist, accountSummary };
3338
+ module.exports = { Account, accountExists, accountsExist, accountSummary, authFailureDisabledAt };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const crypto = require('crypto');
4
4
  const { redis } = require('../db');
5
- const { Account } = require('../account');
5
+ const { Account, authFailureDisabledAt } = require('../account');
6
6
  const getSecret = require('../get-secret');
7
7
  const { oauth2Apps, SERVICE_ACCOUNT_PROVIDERS } = require('../oauth2-apps');
8
8
  const settings = require('../settings');
@@ -888,6 +888,7 @@ async function init(args) {
888
888
  counters: accountCountersSchema,
889
889
 
890
890
  syncTime: Joi.date().iso().example('2021-02-17T13:43:18.860Z').description('Last sync time (IMAP accounts only)'),
891
+ authFailureDisabledAt: accountSchemas.authFailureDisabledAt,
891
892
  lastError: lastErrorSchema.allow(null),
892
893
  delegationError: Joi.string()
893
894
  .example('Delegated account was not found')
@@ -1033,6 +1034,9 @@ async function init(args) {
1033
1034
  result.lastError = accountData.state === 'connected' ? null : accountData.lastErrorState;
1034
1035
  }
1035
1036
 
1037
+ // Stated rather than inferred; see the field's description in lib/schemas.js
1038
+ result.authFailureDisabledAt = authFailureDisabledAt(accountData);
1039
+
1036
1040
  if (accountData.counters) {
1037
1041
  result.counters = accountData.counters;
1038
1042
  }
@@ -1110,6 +1114,8 @@ async function init(args) {
1110
1114
 
1111
1115
  imapIndexer: accountSchemas.imapIndexer,
1112
1116
 
1117
+ authFailureDisabledAt: accountSchemas.authFailureDisabledAt,
1118
+
1113
1119
  subconnections: accountSchemas.subconnections,
1114
1120
 
1115
1121
  webhooks: Joi.string()
package/lib/consts.js CHANGED
@@ -133,6 +133,18 @@ module.exports = {
133
133
  // IF IMAP authentications fail more than provided value, then disable IMAP for the account
134
134
  DEFAULT_MAX_IMAP_AUTH_FAILURE_TIME: 3 * 24 * 3600 * 1000, // 3 days
135
135
 
136
+ // Account hash field recording that the auth-failure safety net, rather than the operator, is
137
+ // what set `imap.disabled`. The two are the same flag - every connection gate already reads it -
138
+ // so without this marker nothing could tell an account parked after repeated authentication
139
+ // failures from one an operator deliberately made send-only, and the recovery paths would
140
+ // silently start syncing a mailbox somebody had switched off on purpose.
141
+ //
142
+ // Its value is the ISO timestamp of the disable. The leading underscore is the convention for a
143
+ // field unserializeAccountData() does not surface under its own name, so it can never ride an
144
+ // account object out into an API response or the OpenAPI document; what a loaded account does
145
+ // carry is the separate, read-only `_authFailureDisabledAt`.
146
+ AUTH_FAILURE_DISABLED_FIELD: '_authFailureDisabled',
147
+
136
148
  REDIS_PREFIX: ((process.env.EENGINE_REDIS_PREFIX || '').toString().trim() + ':').replace(/^:/, ''),
137
149
 
138
150
  REDIS_BATCH_DELETE_SIZE: 1000,