emailengine-app 2.84.2 → 2.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ncurc.js +5 -3
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +33 -0
- package/Dockerfile +6 -0
- package/README.md +1 -1
- package/bin/emailengine.js +434 -408
- package/copy-static-files.sh +39 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16562 -0
- package/eslint.config.js +81 -99
- package/lib/account.js +36 -5
- package/lib/api-reference/format.js +4 -3
- package/lib/api-routes/account-routes.js +177 -12
- package/lib/api-routes/blocklist-routes.js +23 -2
- package/lib/api-routes/delivery-test-routes.js +26 -3
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +28 -2
- package/lib/api-routes/mailbox-routes.js +41 -2
- package/lib/api-routes/message-routes.js +97 -3
- package/lib/api-routes/oauth2-app-routes.js +48 -15
- package/lib/api-routes/outbox-routes.js +45 -11
- package/lib/api-routes/permission-map.js +12 -1
- package/lib/api-routes/settings-routes.js +23 -2
- package/lib/api-routes/submit-routes.js +336 -309
- package/lib/api-routes/template-routes.js +38 -2
- package/lib/api-routes/token-routes.js +142 -96
- package/lib/api-routes/webhook-route-routes.js +13 -2
- package/lib/bounce-detect.js +397 -205
- package/lib/consts.js +5 -4
- package/lib/email-client/base-client.js +10 -31
- package/lib/email-client/gmail-client.js +9 -11
- package/lib/email-client/imap/mailbox.js +3 -19
- package/lib/email-client/imap/subconnection.js +1 -1
- package/lib/email-client/imap-client.js +1 -1
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/gateway.js +2 -3
- package/lib/hapi-request-logger.js +107 -0
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/mcp/tools.js +37 -8
- package/lib/notify-attachments.js +17 -0
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +1 -1
- package/lib/pbkdf2-phc.js +1 -1
- package/lib/schemas.js +1 -1
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +46 -0
- package/lib/timezones.js +109 -0
- package/lib/token-permission-view.js +3 -3
- package/lib/tools.js +40 -10
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +475 -454
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +88 -10
- package/lib/ui-routes/admin-entities-routes.js +91 -7
- package/lib/ui-routes/auth-routes.js +90 -38
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/oauth-config-routes.js +124 -82
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/murmurhash3.js +66 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/version.js +74 -0
- package/lib/webhook-routing.js +27 -0
- package/lib/webhooks.js +41 -6
- package/package.json +27 -29
- package/sbom.json +7980 -1
- package/server.js +634 -441
- package/static/licenses.html +181 -1006
- package/translations/messages.pot +62 -63
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +2 -2
- package/views/config/service.hbs +3 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +738 -583
- package/workers/export.js +1 -1
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +16 -32
package/eslint.config.js
CHANGED
|
@@ -1,112 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Shared lint baseline for the Postal Systems / Nodemailer packages: eslint:recommended
|
|
4
|
+
// plus the rules of the retired eslint-config-nodemailer, with formatting left to Prettier.
|
|
5
|
+
// Keep this file identical across repos except for the "Repo-specific" block at the end.
|
|
6
|
+
|
|
1
7
|
const js = require('@eslint/js');
|
|
8
|
+
const prettier = require('eslint-config-prettier');
|
|
9
|
+
const globals = require('globals');
|
|
2
10
|
|
|
3
11
|
module.exports = [
|
|
4
12
|
{
|
|
5
|
-
ignores: ['node_modules/**', 'ee-dist/**', 'static/**']
|
|
13
|
+
ignores: ['node_modules/**', 'coverage/**', 'dist/**', 'ee-dist/**', 'static/**']
|
|
6
14
|
},
|
|
7
15
|
js.configs.recommended,
|
|
8
16
|
{
|
|
17
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
9
18
|
languageOptions: {
|
|
10
|
-
ecmaVersion:
|
|
19
|
+
ecmaVersion: 2022,
|
|
11
20
|
sourceType: 'commonjs',
|
|
12
|
-
globals: {
|
|
13
|
-
// Node.js globals
|
|
14
|
-
Buffer: 'readonly',
|
|
15
|
-
__dirname: 'readonly',
|
|
16
|
-
__filename: 'readonly',
|
|
17
|
-
console: 'readonly',
|
|
18
|
-
exports: 'writable',
|
|
19
|
-
global: 'readonly',
|
|
20
|
-
module: 'writable',
|
|
21
|
-
process: 'readonly',
|
|
22
|
-
require: 'readonly',
|
|
23
|
-
BigInt: 'readonly',
|
|
24
|
-
setImmediate: 'readonly',
|
|
25
|
-
clearImmediate: 'readonly',
|
|
26
|
-
setTimeout: 'readonly',
|
|
27
|
-
clearTimeout: 'readonly',
|
|
28
|
-
setInterval: 'readonly',
|
|
29
|
-
clearInterval: 'readonly',
|
|
30
|
-
AbortController: 'readonly',
|
|
31
|
-
AbortSignal: 'readonly',
|
|
32
|
-
URL: 'readonly',
|
|
33
|
-
URLSearchParams: 'readonly',
|
|
34
|
-
structuredClone: 'readonly',
|
|
35
|
-
// Test globals
|
|
36
|
-
it: 'readonly',
|
|
37
|
-
describe: 'readonly',
|
|
38
|
-
before: 'readonly',
|
|
39
|
-
after: 'readonly',
|
|
40
|
-
beforeEach: 'readonly',
|
|
41
|
-
afterEach: 'readonly'
|
|
42
|
-
}
|
|
21
|
+
globals: { ...globals.node }
|
|
43
22
|
},
|
|
44
|
-
files: ['**/*.js'],
|
|
45
23
|
rules: {
|
|
46
|
-
|
|
47
|
-
'no-
|
|
48
|
-
'
|
|
49
|
-
|
|
50
|
-
'
|
|
51
|
-
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'no-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'nonblock-statement-body-position': 'off',
|
|
85
|
-
'object-curly-newline': 'off',
|
|
86
|
-
'object-curly-spacing': 'off',
|
|
87
|
-
'object-property-newline': 'off',
|
|
88
|
-
'one-var-declaration-per-line': 'off',
|
|
89
|
-
'operator-linebreak': 'off',
|
|
90
|
-
'padded-blocks': 'off',
|
|
91
|
-
'padding-line-between-statements': 'off',
|
|
92
|
-
'quote-props': 'off',
|
|
93
|
-
quotes: 'off',
|
|
94
|
-
'rest-spread-spacing': 'off',
|
|
95
|
-
semi: 'off',
|
|
96
|
-
'semi-spacing': 'off',
|
|
97
|
-
'semi-style': 'off',
|
|
98
|
-
'space-before-blocks': 'off',
|
|
99
|
-
'space-before-function-paren': 'off',
|
|
100
|
-
'space-in-parens': 'off',
|
|
101
|
-
'space-infix-ops': 'off',
|
|
102
|
-
'space-unary-ops': 'off',
|
|
103
|
-
'switch-colon-spacing': 'off',
|
|
104
|
-
'template-curly-spacing': 'off',
|
|
105
|
-
'template-tag-spacing': 'off',
|
|
106
|
-
'unicode-bom': 'off',
|
|
107
|
-
'wrap-iife': 'off',
|
|
108
|
-
'wrap-regex': 'off',
|
|
109
|
-
'yield-star-spacing': 'off'
|
|
24
|
+
'no-await-in-loop': 'error',
|
|
25
|
+
'no-div-regex': 'error',
|
|
26
|
+
strict: ['error', 'global'],
|
|
27
|
+
eqeqeq: 'error',
|
|
28
|
+
'dot-notation': 'error',
|
|
29
|
+
curly: 'error',
|
|
30
|
+
'no-unused-expressions': ['error', { allowShortCircuit: true }],
|
|
31
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
|
|
32
|
+
'handle-callback-err': 'error',
|
|
33
|
+
'no-new': 'error',
|
|
34
|
+
'new-cap': 'error',
|
|
35
|
+
'no-eval': 'error',
|
|
36
|
+
'no-invalid-this': 'error',
|
|
37
|
+
radix: ['error', 'always'],
|
|
38
|
+
'no-use-before-define': ['error', 'nofunc'],
|
|
39
|
+
'callback-return': ['error', ['callback', 'cb', 'done']],
|
|
40
|
+
'no-redeclare': 'error',
|
|
41
|
+
'block-scoped-var': 'error',
|
|
42
|
+
'no-sequences': 'error',
|
|
43
|
+
'no-throw-literal': 'error',
|
|
44
|
+
'no-useless-call': 'error',
|
|
45
|
+
'no-useless-concat': 'error',
|
|
46
|
+
'no-void': 'error',
|
|
47
|
+
yoda: 'error',
|
|
48
|
+
'no-var': 'error',
|
|
49
|
+
'no-bitwise': 'error',
|
|
50
|
+
'no-lonely-if': 'error',
|
|
51
|
+
'arrow-body-style': ['error', 'as-needed'],
|
|
52
|
+
'prefer-arrow-callback': 'error',
|
|
53
|
+
'object-shorthand': 'error',
|
|
54
|
+
'prefer-spread': 'error',
|
|
55
|
+
'no-prototype-builtins': 'off'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
files: ['test/**'],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
globals: { ...globals.node, ...globals.mocha }
|
|
110
62
|
}
|
|
111
|
-
}
|
|
63
|
+
},
|
|
64
|
+
// Repo-specific: overrides go here, each with a one-line reason
|
|
65
|
+
{
|
|
66
|
+
// The vendored imap-core suite (lib/imapproxy/imap-core/test) is mocha-shaped and lives outside test/
|
|
67
|
+
files: ['lib/imapproxy/imap-core/test/**'],
|
|
68
|
+
languageOptions: {
|
|
69
|
+
globals: { ...globals.node, ...globals.mocha }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
rules: {
|
|
74
|
+
// 524 violations: workers and sync loops await sequentially on purpose (ordering, backpressure, rate limits)
|
|
75
|
+
'no-await-in-loop': 'off',
|
|
76
|
+
// 264 violations: 256 unused catch bindings (optional catch binding would churn 100+ files) and 8 named
|
|
77
|
+
// parameters kept for documented interfaces (base-class stubs, provider overrides, test doubles)
|
|
78
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^_', args: 'none', caughtErrors: 'none' }],
|
|
79
|
+
// 48 violations: IMAP/MIME parsers, crypto, flag masks and hashing need bitwise operators
|
|
80
|
+
'no-bitwise': 'off',
|
|
81
|
+
// 20 violations: closures and hoisted helpers referencing later module-level bindings, fixing means reordering modules
|
|
82
|
+
'no-use-before-define': 'off',
|
|
83
|
+
// 13 violations: SCREAMING_CASE factory constants, the TLS SNICallback option and node:test's lowercase spec reporter class
|
|
84
|
+
'new-cap': 'off',
|
|
85
|
+
// 11 violations: Handlebars helpers and test stubs use the call-site this by design
|
|
86
|
+
'no-invalid-this': 'off',
|
|
87
|
+
// 10 violations: stream transform callbacks followed by other statements, rewriting them risks changing flow
|
|
88
|
+
'callback-return': 'off',
|
|
89
|
+
// 9 violations, all deliberate x == null / x != null checks that cover both null and undefined
|
|
90
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
prettier
|
|
112
94
|
];
|
package/lib/account.js
CHANGED
|
@@ -25,10 +25,9 @@ const { ownAccountKeyFilter } = require('./account/own-account-key');
|
|
|
25
25
|
const { extractMultiValues, createTransaction } = require('./redis-operations');
|
|
26
26
|
const outbox = require('./outbox');
|
|
27
27
|
const tokens = require('./tokens');
|
|
28
|
-
const {
|
|
28
|
+
const { randomId } = require('./utils/random-id');
|
|
29
29
|
const Lock = require('ioredfour');
|
|
30
30
|
const { redis } = require('./db');
|
|
31
|
-
const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 16);
|
|
32
31
|
const { REDIS_PREFIX, AUTH_FAILURE_DISABLED_FIELD, AUTH_FAILURE_DISABLED_LEGACY_DESCRIPTION } = require('./consts');
|
|
33
32
|
const { webSafeTextResponse, applyWebSafeHtmlOptions } = require('./web-safe-html');
|
|
34
33
|
const { checkAccountScopes: checkScopes } = require('./oauth/scope-checker');
|
|
@@ -1329,7 +1328,7 @@ class Account {
|
|
|
1329
1328
|
let id;
|
|
1330
1329
|
let retries = 0;
|
|
1331
1330
|
while (retries++ < 20) {
|
|
1332
|
-
id =
|
|
1331
|
+
id = randomId();
|
|
1333
1332
|
let alreadyExists = await this.redis.hexists(`${REDIS_PREFIX}iad:${id}`, 'account');
|
|
1334
1333
|
if (alreadyExists) {
|
|
1335
1334
|
id = false;
|
|
@@ -1387,7 +1386,7 @@ class Account {
|
|
|
1387
1386
|
*
|
|
1388
1387
|
* @returns {Promise<Boolean>} True when a disable flag was actually lifted
|
|
1389
1388
|
*/
|
|
1390
|
-
async clearAuthFailureDisable() {
|
|
1389
|
+
async clearAuthFailureDisable(trigger) {
|
|
1391
1390
|
const accountKey = this.getAccountKey();
|
|
1392
1391
|
|
|
1393
1392
|
const [disabledAt, imapInfo] = await this.redis.hmget(accountKey, AUTH_FAILURE_DISABLED_FIELD, 'imap');
|
|
@@ -1427,7 +1426,39 @@ class Account {
|
|
|
1427
1426
|
return false;
|
|
1428
1427
|
}
|
|
1429
1428
|
|
|
1430
|
-
|
|
1429
|
+
// `trigger` is 'resume' for the "Resume syncing" action, which retries the stored credentials
|
|
1430
|
+
this.logger.info({
|
|
1431
|
+
msg:
|
|
1432
|
+
trigger === 'resume'
|
|
1433
|
+
? 'Resumed an account that was switched off after authentication failures'
|
|
1434
|
+
: 'Re-enabled IMAP for account after re-authorization',
|
|
1435
|
+
account: this.account,
|
|
1436
|
+
disabledAt
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
return true;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* "Resume syncing": turns an account back on after the auth-failure safety net switched it
|
|
1444
|
+
* off, and asks its worker to connect it again. The one implementation behind the admin UI
|
|
1445
|
+
* action and PUT /v1/account/{account}/resume.
|
|
1446
|
+
*
|
|
1447
|
+
* Lifts nothing but the safety net's own disable (see clearAuthFailureDisable), so it cannot
|
|
1448
|
+
* be used to undo an operator's deliberate send-only switch.
|
|
1449
|
+
*
|
|
1450
|
+
* @returns {Promise<Boolean>} True when the account was switched off and has been resumed,
|
|
1451
|
+
* false when there was no such disable to lift
|
|
1452
|
+
*/
|
|
1453
|
+
async resumeAfterAuthFailure() {
|
|
1454
|
+
if (!(await this.clearAuthFailureDisable('resume'))) {
|
|
1455
|
+
return false;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// The flag is already lifted, so the account is no longer parked whatever the dispatch
|
|
1459
|
+
// does. Losing it only delays the connection until the next periodic reconnect, which is
|
|
1460
|
+
// why notifyWorker() logs a failure rather than throwing it.
|
|
1461
|
+
await this.notifyWorker('reconnect');
|
|
1431
1462
|
|
|
1432
1463
|
return true;
|
|
1433
1464
|
}
|
|
@@ -50,9 +50,10 @@ function formatDescription(text) {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
// Bare URLs, skipping ones already inside an href="..." emitted above
|
|
53
|
-
html = html.replace(
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
html = html.replace(
|
|
54
|
+
/(^|[\s(])(https?:\/\/[^\s<>"')]+)/g,
|
|
55
|
+
(match, prefix, url) => `${prefix}<a href="${url}" target="_blank" rel="noopener noreferrer" class="link link-primary">${url}</a>`
|
|
56
|
+
);
|
|
56
57
|
|
|
57
58
|
return html
|
|
58
59
|
.split(/\n{2,}/)
|
|
@@ -166,18 +166,8 @@ function validateDelegationFields(payload) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
const {
|
|
171
|
-
server,
|
|
172
|
-
call,
|
|
173
|
-
oauth2Schema: oauth2SchemaArg,
|
|
174
|
-
imapSchema: imapSchemaArg,
|
|
175
|
-
smtpSchema: smtpSchemaArg,
|
|
176
|
-
CORS_CONFIG,
|
|
177
|
-
AccountTypeSchema,
|
|
178
|
-
OAuth2ProviderSchema,
|
|
179
|
-
metrics
|
|
180
|
-
} = args;
|
|
169
|
+
function registerCreateAccount(server, args) {
|
|
170
|
+
const { call, oauth2Schema: oauth2SchemaArg, imapSchema: imapSchemaArg, smtpSchema: smtpSchemaArg, CORS_CONFIG } = args;
|
|
181
171
|
|
|
182
172
|
// POST /v1/account - Create account
|
|
183
173
|
server.route({
|
|
@@ -429,6 +419,10 @@ async function init(args) {
|
|
|
429
419
|
}
|
|
430
420
|
}
|
|
431
421
|
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function registerUpdateAccount(server, args) {
|
|
425
|
+
const { call, CORS_CONFIG } = args;
|
|
432
426
|
|
|
433
427
|
// PUT /v1/account/{account} - Update account
|
|
434
428
|
server.route({
|
|
@@ -586,6 +580,10 @@ async function init(args) {
|
|
|
586
580
|
}
|
|
587
581
|
}
|
|
588
582
|
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function registerAccountReconnect(server, args) {
|
|
586
|
+
const { call, CORS_CONFIG } = args;
|
|
589
587
|
|
|
590
588
|
// PUT /v1/account/{account}/reconnect - Request reconnect
|
|
591
589
|
server.route({
|
|
@@ -666,6 +664,108 @@ async function init(args) {
|
|
|
666
664
|
}
|
|
667
665
|
}
|
|
668
666
|
});
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function registerAccountResume(server, args) {
|
|
670
|
+
const { call, CORS_CONFIG } = args;
|
|
671
|
+
|
|
672
|
+
// PUT /v1/account/{account}/resume - Resume an account switched off after authentication failures
|
|
673
|
+
server.route({
|
|
674
|
+
method: 'PUT',
|
|
675
|
+
path: '/v1/account/{account}/resume',
|
|
676
|
+
|
|
677
|
+
async handler(request) {
|
|
678
|
+
let accountObject = new Account({
|
|
679
|
+
redis,
|
|
680
|
+
account: request.params.account,
|
|
681
|
+
call,
|
|
682
|
+
secret: await getSecret(),
|
|
683
|
+
timeout: request.headers['x-ee-timeout']
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
try {
|
|
687
|
+
// 404 for an unknown account rather than the 409 below, which would read as "this
|
|
688
|
+
// account exists and is running"
|
|
689
|
+
await accountObject.loadAccountData(request.params.account, false);
|
|
690
|
+
|
|
691
|
+
if (!(await accountObject.resumeAfterAuthFailure())) {
|
|
692
|
+
// The same answer the admin UI gives, as a state refusal: an account that was
|
|
693
|
+
// never parked, or that an operator already re-enabled, has nothing to resume,
|
|
694
|
+
// and an operator's own send-only switch is not lifted from here
|
|
695
|
+
let err = new Error('This account was not switched off by EmailEngine after authentication failures, so there is nothing to resume');
|
|
696
|
+
err.code = 'NotSwitchedOff';
|
|
697
|
+
err.statusCode = 409;
|
|
698
|
+
throw err;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
return { resumed: true };
|
|
702
|
+
} catch (err) {
|
|
703
|
+
handleError(request, err);
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
options: {
|
|
707
|
+
description: 'Resume syncing',
|
|
708
|
+
notes: [
|
|
709
|
+
'Turns an account back on after EmailEngine switched it off following repeated authentication failures (`authFailureDisabledAt` on the account), and requests a reconnect. The same action as "Resume syncing" in the admin UI. Only lifts that automatic switch: an account that was not switched off by EmailEngine, including one an operator set to send-only, answers 409 with `code` NotSwitchedOff. If the stored credentials are still refused, the account is switched off again after the next run of failures, so fix the credentials first.',
|
|
710
|
+
BEHAVIOR.SCHEDULED_ON_WORKER
|
|
711
|
+
],
|
|
712
|
+
tags: ['api', 'Account'],
|
|
713
|
+
|
|
714
|
+
plugins: {
|
|
715
|
+
mcp: {
|
|
716
|
+
name: 'resume_account',
|
|
717
|
+
title: 'Resume account',
|
|
718
|
+
description:
|
|
719
|
+
'Turn an account back on after EmailEngine switched it off following repeated authentication failures, and reconnect it. list_accounts and get_account show such an account with authFailureDisabledAt set. ' +
|
|
720
|
+
'Use once the cause is fixed (a changed password, a revoked or expired authorization): with the same credentials still refused, the account is switched off again after the next run of failures. ' +
|
|
721
|
+
'An account that EmailEngine did not switch off has nothing to resume, and the call fails saying so.'
|
|
722
|
+
},
|
|
723
|
+
openapi: {
|
|
724
|
+
'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
|
|
725
|
+
responses: apiResponses(
|
|
726
|
+
'Returns an acknowledgement. The account is switched back on and a reconnect is requested, not completed - watch the account state for the result.',
|
|
727
|
+
400,
|
|
728
|
+
401,
|
|
729
|
+
403,
|
|
730
|
+
404,
|
|
731
|
+
409,
|
|
732
|
+
429,
|
|
733
|
+
500
|
|
734
|
+
)
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
|
|
738
|
+
auth: {
|
|
739
|
+
strategy: 'api-token',
|
|
740
|
+
mode: 'required'
|
|
741
|
+
},
|
|
742
|
+
cors: CORS_CONFIG,
|
|
743
|
+
|
|
744
|
+
validate: {
|
|
745
|
+
options: {
|
|
746
|
+
stripUnknown: false,
|
|
747
|
+
abortEarly: false,
|
|
748
|
+
convert: true
|
|
749
|
+
},
|
|
750
|
+
failAction,
|
|
751
|
+
|
|
752
|
+
params: Joi.object({
|
|
753
|
+
account: accountIdSchema.required()
|
|
754
|
+
})
|
|
755
|
+
},
|
|
756
|
+
|
|
757
|
+
response: {
|
|
758
|
+
schema: Joi.object({
|
|
759
|
+
resumed: Joi.boolean().example(true).description('The account was switched back on and a reconnect was requested')
|
|
760
|
+
}).label('AccountResumeResponse'),
|
|
761
|
+
failAction: 'log'
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function registerAccountSync(server, args) {
|
|
768
|
+
const { call, CORS_CONFIG } = args;
|
|
669
769
|
|
|
670
770
|
// PUT /v1/account/{account}/sync - Request syncing
|
|
671
771
|
server.route({
|
|
@@ -755,6 +855,10 @@ async function init(args) {
|
|
|
755
855
|
}
|
|
756
856
|
}
|
|
757
857
|
});
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function registerDeleteAccount(server, args) {
|
|
861
|
+
const { call, CORS_CONFIG } = args;
|
|
758
862
|
|
|
759
863
|
// DELETE /v1/account/{account} - Remove account
|
|
760
864
|
server.route({
|
|
@@ -842,6 +946,10 @@ async function init(args) {
|
|
|
842
946
|
}
|
|
843
947
|
}
|
|
844
948
|
});
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function registerAccountFlush(server, args) {
|
|
952
|
+
const { call, CORS_CONFIG } = args;
|
|
845
953
|
|
|
846
954
|
// PUT /v1/account/{account}/flush - Request account flush
|
|
847
955
|
server.route({
|
|
@@ -929,6 +1037,10 @@ async function init(args) {
|
|
|
929
1037
|
}
|
|
930
1038
|
}
|
|
931
1039
|
});
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function registerListAccounts(server, args) {
|
|
1043
|
+
const { call, CORS_CONFIG, AccountTypeSchema } = args;
|
|
932
1044
|
|
|
933
1045
|
// GET /v1/accounts - List accounts
|
|
934
1046
|
server.route({
|
|
@@ -1068,6 +1180,10 @@ async function init(args) {
|
|
|
1068
1180
|
}
|
|
1069
1181
|
}
|
|
1070
1182
|
});
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function registerGetAccount(server, args) {
|
|
1186
|
+
const { call, CORS_CONFIG, AccountTypeSchema } = args;
|
|
1071
1187
|
|
|
1072
1188
|
// GET /v1/account/{account} - Get account info
|
|
1073
1189
|
server.route({
|
|
@@ -1453,6 +1569,10 @@ async function init(args) {
|
|
|
1453
1569
|
}
|
|
1454
1570
|
}
|
|
1455
1571
|
});
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function registerGetAccountOAuthToken(server, args) {
|
|
1575
|
+
const { call, CORS_CONFIG, OAuth2ProviderSchema, metrics } = args;
|
|
1456
1576
|
|
|
1457
1577
|
server.route({
|
|
1458
1578
|
method: 'GET',
|
|
@@ -1580,6 +1700,10 @@ async function init(args) {
|
|
|
1580
1700
|
}
|
|
1581
1701
|
}
|
|
1582
1702
|
});
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
function registerGetServerSignatures(server, args) {
|
|
1706
|
+
const { call, CORS_CONFIG } = args;
|
|
1583
1707
|
|
|
1584
1708
|
server.route({
|
|
1585
1709
|
method: 'GET',
|
|
@@ -1651,6 +1775,10 @@ async function init(args) {
|
|
|
1651
1775
|
}
|
|
1652
1776
|
}
|
|
1653
1777
|
});
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
function registerAuthenticationForm(server, args) {
|
|
1781
|
+
const { CORS_CONFIG } = args;
|
|
1654
1782
|
|
|
1655
1783
|
server.route({
|
|
1656
1784
|
method: 'POST',
|
|
@@ -1819,6 +1947,10 @@ async function init(args) {
|
|
|
1819
1947
|
}
|
|
1820
1948
|
}
|
|
1821
1949
|
});
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
function registerGetLogs(server, args) {
|
|
1953
|
+
const { CORS_CONFIG } = args;
|
|
1822
1954
|
|
|
1823
1955
|
server.route({
|
|
1824
1956
|
method: 'GET',
|
|
@@ -1884,6 +2016,10 @@ async function init(args) {
|
|
|
1884
2016
|
}
|
|
1885
2017
|
}
|
|
1886
2018
|
});
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
function registerVerifyAccount(server, args) {
|
|
2022
|
+
const { CORS_CONFIG } = args;
|
|
1887
2023
|
|
|
1888
2024
|
server.route({
|
|
1889
2025
|
method: 'POST',
|
|
@@ -1962,6 +2098,10 @@ async function init(args) {
|
|
|
1962
2098
|
}
|
|
1963
2099
|
}
|
|
1964
2100
|
});
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
function registerGetAutoconfig(server, args) {
|
|
2104
|
+
const { CORS_CONFIG } = args;
|
|
1965
2105
|
|
|
1966
2106
|
server.route({
|
|
1967
2107
|
method: 'GET',
|
|
@@ -2014,6 +2154,10 @@ async function init(args) {
|
|
|
2014
2154
|
}
|
|
2015
2155
|
}
|
|
2016
2156
|
});
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
function registerPostAutoconfig(server, args) {
|
|
2160
|
+
const { CORS_CONFIG } = args;
|
|
2017
2161
|
|
|
2018
2162
|
server.route({
|
|
2019
2163
|
method: 'POST',
|
|
@@ -2084,4 +2228,25 @@ async function init(args) {
|
|
|
2084
2228
|
});
|
|
2085
2229
|
}
|
|
2086
2230
|
|
|
2231
|
+
async function init(args) {
|
|
2232
|
+
const { server } = args;
|
|
2233
|
+
|
|
2234
|
+
registerCreateAccount(server, args);
|
|
2235
|
+
registerUpdateAccount(server, args);
|
|
2236
|
+
registerAccountReconnect(server, args);
|
|
2237
|
+
registerAccountResume(server, args);
|
|
2238
|
+
registerAccountSync(server, args);
|
|
2239
|
+
registerDeleteAccount(server, args);
|
|
2240
|
+
registerAccountFlush(server, args);
|
|
2241
|
+
registerListAccounts(server, args);
|
|
2242
|
+
registerGetAccount(server, args);
|
|
2243
|
+
registerGetAccountOAuthToken(server, args);
|
|
2244
|
+
registerGetServerSignatures(server, args);
|
|
2245
|
+
registerAuthenticationForm(server, args);
|
|
2246
|
+
registerGetLogs(server, args);
|
|
2247
|
+
registerVerifyAccount(server, args);
|
|
2248
|
+
registerGetAutoconfig(server, args);
|
|
2249
|
+
registerPostAutoconfig(server, args);
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2087
2252
|
module.exports = init;
|
|
@@ -12,8 +12,8 @@ const { accountIdSchema, blocklistListIdSchema, apiResponses, apiBoolean, mailbo
|
|
|
12
12
|
const { IMPACT } = require('./operation-impact');
|
|
13
13
|
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const {
|
|
15
|
+
function registerListBlocklists(server, args) {
|
|
16
|
+
const { CORS_CONFIG } = args;
|
|
17
17
|
|
|
18
18
|
server.route({
|
|
19
19
|
method: 'GET',
|
|
@@ -90,6 +90,10 @@ async function init(args) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function registerGetBlocklist(server, args) {
|
|
96
|
+
const { CORS_CONFIG } = args;
|
|
93
97
|
|
|
94
98
|
server.route({
|
|
95
99
|
method: 'GET',
|
|
@@ -182,6 +186,10 @@ async function init(args) {
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function registerAddToBlocklist(server, args) {
|
|
192
|
+
const { call, CORS_CONFIG } = args;
|
|
185
193
|
|
|
186
194
|
server.route({
|
|
187
195
|
method: 'POST',
|
|
@@ -266,6 +274,10 @@ async function init(args) {
|
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
276
|
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function registerRemoveFromBlocklist(server, args) {
|
|
280
|
+
const { CORS_CONFIG } = args;
|
|
269
281
|
|
|
270
282
|
server.route({
|
|
271
283
|
method: 'DELETE',
|
|
@@ -339,4 +351,13 @@ async function init(args) {
|
|
|
339
351
|
});
|
|
340
352
|
}
|
|
341
353
|
|
|
354
|
+
async function init(args) {
|
|
355
|
+
const { server } = args;
|
|
356
|
+
|
|
357
|
+
registerListBlocklists(server, args);
|
|
358
|
+
registerGetBlocklist(server, args);
|
|
359
|
+
registerAddToBlocklist(server, args);
|
|
360
|
+
registerRemoveFromBlocklist(server, args);
|
|
361
|
+
}
|
|
362
|
+
|
|
342
363
|
module.exports = init;
|