emailengine-app 2.84.1 → 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/.dockerignore +6 -0
- package/.ncurc.js +5 -3
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +61 -0
- package/Dockerfile +8 -2
- package/README.md +1 -1
- package/bin/emailengine.js +444 -403
- package/copy-static-files.sh +39 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16562 -0
- package/docker-compose.yml +1 -1
- package/eslint.config.js +81 -99
- package/lib/account/own-account-key.js +42 -0
- package/lib/account-assignment.js +1 -33
- package/lib/account.js +68 -24
- package/lib/add-trackers.js +11 -4
- package/lib/api-reference/format.js +4 -3
- package/lib/api-routes/account-routes.js +244 -26
- 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 +37 -5
- package/lib/api-routes/mailbox-routes.js +41 -2
- package/lib/api-routes/message-routes.js +104 -4
- package/lib/api-routes/mint-bounds.js +11 -0
- 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/route-helpers.js +125 -3
- package/lib/api-routes/settings-routes.js +23 -2
- package/lib/api-routes/submit-routes.js +338 -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/auth-token.js +23 -10
- package/lib/bounce-detect.js +414 -210
- package/lib/consts.js +39 -4
- package/lib/create-imap-client.js +41 -2
- package/lib/email-client/base-client.js +30 -41
- package/lib/email-client/gmail-client.js +30 -18
- package/lib/email-client/imap/mailbox.js +13 -23
- package/lib/email-client/imap/response-metrics.js +75 -0
- package/lib/email-client/imap/subconnection.js +1 -1
- package/lib/email-client/imap-client.js +6 -3
- package/lib/email-client/message-builder.js +7 -2
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/email-client/outlook/graph-api.js +17 -2
- package/lib/email-client/outlook-client.js +6 -3
- package/lib/email-client/smtp-pool-manager.js +6 -0
- package/lib/encrypt.js +9 -0
- package/lib/export.js +3 -1
- package/lib/gateway.js +2 -3
- package/lib/get-raw-email.js +4 -2
- package/lib/hapi-request-logger.js +107 -0
- package/lib/imap-proxy-auth.js +14 -1
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +1 -0
- package/lib/imapproxy/imap-core/lib/commands/login.js +1 -0
- package/lib/imapproxy/imap-core/lib/imap-command.js +86 -43
- package/lib/imapproxy/imap-core/lib/imap-stream.js +58 -13
- package/lib/imapproxy/imap-core/lib/indexer/indexer.js +3 -1
- package/lib/mcp/listen.js +10 -1
- package/lib/mcp/tools.js +37 -8
- package/lib/notify-attachments.js +17 -0
- package/lib/oauth/external-account-config.js +3 -1
- package/lib/oauth/gmail.js +21 -48
- package/lib/oauth/mail-ru.js +5 -38
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/outlook.js +26 -44
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +1 -1
- package/lib/pbkdf2-phc.js +19 -2
- package/lib/privileged-settings.js +6 -3
- package/lib/redis-scan-delete.js +15 -1
- package/lib/schemas.js +79 -33
- package/lib/settings.js +13 -1
- package/lib/smtp-auth.js +23 -0
- 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 +285 -66
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +491 -491
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +98 -48
- package/lib/ui-routes/admin-entities-routes.js +113 -31
- package/lib/ui-routes/auth-routes.js +137 -62
- package/lib/ui-routes/connection-security-form.js +74 -0
- package/lib/ui-routes/form-lists.js +46 -0
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/mcp-consent-routes.js +5 -1
- package/lib/ui-routes/oauth-config-routes.js +133 -100
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/sign-in-helpers.js +59 -0
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/ui-routes/unsubscribe-routes.js +6 -3
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/map-concurrent.js +36 -0
- package/lib/utils/murmurhash3.js +66 -0
- package/lib/utils/network.js +28 -0
- package/lib/utils/provider-id.js +27 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/require-tls.js +33 -0
- package/lib/utils/version.js +74 -0
- package/lib/web-safe-html.js +5 -6
- package/lib/webhook-penalty.js +75 -0
- package/lib/webhook-routing.js +49 -2
- package/lib/webhooks.js +41 -6
- package/package.json +37 -39
- package/sbom.json +7980 -1
- package/server.js +659 -455
- package/static/js/ace/ace.js +1 -1
- package/static/js/ace/mode-handlebars.js +1 -1
- package/static/js/ace/mode-html.js +1 -1
- package/static/js/ace/mode-javascript.js +1 -1
- package/static/js/ace/mode-markdown.js +1 -1
- package/static/js/ace/worker-html.js +1 -1
- package/static/js/ace/worker-javascript.js +1 -1
- package/static/js/ace/worker-json.js +1 -1
- package/static/js/ee-client.js +5 -0
- package/static/licenses.html +191 -1016
- package/translations/messages.pot +70 -71
- package/views/account/security.hbs +10 -0
- package/views/accounts/account.hbs +11 -11
- package/views/accounts/edit.hbs +6 -2
- 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/gateway_form.hbs +3 -1
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +780 -585
- package/workers/export.js +1 -1
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +54 -34
- package/config/test.toml +0 -46
- package/install.sh +0 -428
- package/setup-production.sh +0 -215
- package/systemd/emailengine.service +0 -97
- package/systemd/nginx-proxy.conf +0 -77
|
@@ -11,7 +11,16 @@ const { autodetectImapSettings } = require('../autodetect-imap-settings');
|
|
|
11
11
|
const Boom = require('@hapi/boom');
|
|
12
12
|
const Joi = require('joi');
|
|
13
13
|
const { failAction, getSignedFormData, getLogs, verifyAccountInfo } = require('../tools');
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
handleError,
|
|
16
|
+
maskSecrets,
|
|
17
|
+
assertNoNetworkOverride,
|
|
18
|
+
assertNoIdentityRetarget,
|
|
19
|
+
isRestrictedCredential,
|
|
20
|
+
isBoundCredential,
|
|
21
|
+
MASKED,
|
|
22
|
+
MASK_NOTE
|
|
23
|
+
} = require('./route-helpers');
|
|
15
24
|
|
|
16
25
|
const {
|
|
17
26
|
settingsSchema,
|
|
@@ -157,18 +166,8 @@ function validateDelegationFields(payload) {
|
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
168
|
|
|
160
|
-
|
|
161
|
-
const {
|
|
162
|
-
server,
|
|
163
|
-
call,
|
|
164
|
-
oauth2Schema: oauth2SchemaArg,
|
|
165
|
-
imapSchema: imapSchemaArg,
|
|
166
|
-
smtpSchema: smtpSchemaArg,
|
|
167
|
-
CORS_CONFIG,
|
|
168
|
-
AccountTypeSchema,
|
|
169
|
-
OAuth2ProviderSchema,
|
|
170
|
-
metrics
|
|
171
|
-
} = args;
|
|
169
|
+
function registerCreateAccount(server, args) {
|
|
170
|
+
const { call, oauth2Schema: oauth2SchemaArg, imapSchema: imapSchemaArg, smtpSchema: smtpSchemaArg, CORS_CONFIG } = args;
|
|
172
171
|
|
|
173
172
|
// POST /v1/account - Create account
|
|
174
173
|
server.route({
|
|
@@ -255,6 +254,12 @@ async function init(args) {
|
|
|
255
254
|
// Validate delegation fields are only used with OAuth2 provider
|
|
256
255
|
validateDelegationFields(request.payload);
|
|
257
256
|
|
|
257
|
+
// A narrowed provisioning token may register accounts, but not one that borrows
|
|
258
|
+
// another account's stored credential. Naming the mailbox of a new account on an
|
|
259
|
+
// application-credentials app is what registering one is, so unlike the update
|
|
260
|
+
// route this one does not ask which app the account is on
|
|
261
|
+
await assertNoIdentityRetarget(request);
|
|
262
|
+
|
|
258
263
|
let result = await accountObject.create(request.payload);
|
|
259
264
|
return result;
|
|
260
265
|
} catch (err) {
|
|
@@ -414,6 +419,10 @@ async function init(args) {
|
|
|
414
419
|
}
|
|
415
420
|
}
|
|
416
421
|
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function registerUpdateAccount(server, args) {
|
|
425
|
+
const { call, CORS_CONFIG } = args;
|
|
417
426
|
|
|
418
427
|
// PUT /v1/account/{account} - Update account
|
|
419
428
|
server.route({
|
|
@@ -437,6 +446,22 @@ async function init(args) {
|
|
|
437
446
|
// Validate delegation fields are only used with OAuth2 provider
|
|
438
447
|
validateDelegationFields(request.payload);
|
|
439
448
|
|
|
449
|
+
// Nor may a bound or narrowed token make this account authenticate as another one:
|
|
450
|
+
// delegation borrows another account's token, and on an application-credentials
|
|
451
|
+
// app the user field alone selects the mailbox. The app is looked up only when the
|
|
452
|
+
// payload names a user and the credential is one the rule applies to.
|
|
453
|
+
await assertNoIdentityRetarget(request, {
|
|
454
|
+
isServiceApp: async () => {
|
|
455
|
+
let provider = request.payload.oauth2.provider;
|
|
456
|
+
if (!provider) {
|
|
457
|
+
let accountData = await accountObject.loadAccountData();
|
|
458
|
+
provider = accountData.oauth2 && accountData.oauth2.provider;
|
|
459
|
+
}
|
|
460
|
+
let app = provider ? await oauth2Apps.get(provider) : null;
|
|
461
|
+
return !!(app && SERVICE_ACCOUNT_PROVIDERS.has(app.provider));
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
440
465
|
// Credentials in this payload came from an API client, so a credential change here
|
|
441
466
|
// can mean the account was re-authorized - the only caller allowed to arm the
|
|
442
467
|
// reconnect gate in update().
|
|
@@ -555,6 +580,10 @@ async function init(args) {
|
|
|
555
580
|
}
|
|
556
581
|
}
|
|
557
582
|
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function registerAccountReconnect(server, args) {
|
|
586
|
+
const { call, CORS_CONFIG } = args;
|
|
558
587
|
|
|
559
588
|
// PUT /v1/account/{account}/reconnect - Request reconnect
|
|
560
589
|
server.route({
|
|
@@ -635,6 +664,108 @@ async function init(args) {
|
|
|
635
664
|
}
|
|
636
665
|
}
|
|
637
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;
|
|
638
769
|
|
|
639
770
|
// PUT /v1/account/{account}/sync - Request syncing
|
|
640
771
|
server.route({
|
|
@@ -724,6 +855,10 @@ async function init(args) {
|
|
|
724
855
|
}
|
|
725
856
|
}
|
|
726
857
|
});
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function registerDeleteAccount(server, args) {
|
|
861
|
+
const { call, CORS_CONFIG } = args;
|
|
727
862
|
|
|
728
863
|
// DELETE /v1/account/{account} - Remove account
|
|
729
864
|
server.route({
|
|
@@ -811,6 +946,10 @@ async function init(args) {
|
|
|
811
946
|
}
|
|
812
947
|
}
|
|
813
948
|
});
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function registerAccountFlush(server, args) {
|
|
952
|
+
const { call, CORS_CONFIG } = args;
|
|
814
953
|
|
|
815
954
|
// PUT /v1/account/{account}/flush - Request account flush
|
|
816
955
|
server.route({
|
|
@@ -898,6 +1037,10 @@ async function init(args) {
|
|
|
898
1037
|
}
|
|
899
1038
|
}
|
|
900
1039
|
});
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function registerListAccounts(server, args) {
|
|
1043
|
+
const { call, CORS_CONFIG, AccountTypeSchema } = args;
|
|
901
1044
|
|
|
902
1045
|
// GET /v1/accounts - List accounts
|
|
903
1046
|
server.route({
|
|
@@ -1037,6 +1180,10 @@ async function init(args) {
|
|
|
1037
1180
|
}
|
|
1038
1181
|
}
|
|
1039
1182
|
});
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function registerGetAccount(server, args) {
|
|
1186
|
+
const { call, CORS_CONFIG, AccountTypeSchema } = args;
|
|
1040
1187
|
|
|
1041
1188
|
// GET /v1/account/{account} - Get account info
|
|
1042
1189
|
server.route({
|
|
@@ -1422,6 +1569,10 @@ async function init(args) {
|
|
|
1422
1569
|
}
|
|
1423
1570
|
}
|
|
1424
1571
|
});
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function registerGetAccountOAuthToken(server, args) {
|
|
1575
|
+
const { call, CORS_CONFIG, OAuth2ProviderSchema, metrics } = args;
|
|
1425
1576
|
|
|
1426
1577
|
server.route({
|
|
1427
1578
|
method: 'GET',
|
|
@@ -1444,19 +1595,37 @@ async function init(args) {
|
|
|
1444
1595
|
});
|
|
1445
1596
|
|
|
1446
1597
|
try {
|
|
1447
|
-
|
|
1598
|
+
// Account data stores the OAuth2 app ID as the provider value; the app is looked
|
|
1599
|
+
// up once here, for the refusal below and the rename after the token is fetched
|
|
1600
|
+
let accountData = await accountObject.loadAccountData();
|
|
1601
|
+
let provider = accountData.oauth2 && accountData.oauth2.provider;
|
|
1602
|
+
let oauth2App = provider ? await oauth2Apps.get(provider) : null;
|
|
1603
|
+
|
|
1604
|
+
// A client-credentials token is the whole tenant's, not this account's: with it
|
|
1605
|
+
// the caller reads every mailbox the application was granted. A credential
|
|
1606
|
+
// admitted to one account, or narrowed below the full API, is therefore refused
|
|
1607
|
+
// it, whatever the setting above says. The admin interface and an unrestricted,
|
|
1608
|
+
// unbound token still get it. Only Graph: a Gmail service account mints its token
|
|
1609
|
+
// per user, with the mailbox as the JWT's subject, so that token is the account's
|
|
1610
|
+
// own and SERVICE_ACCOUNT_PROVIDERS would be the wrong list here
|
|
1611
|
+
if (oauth2App && oauth2App.provider === 'outlookService' && (isBoundCredential(request) || isRestrictedCredential(request))) {
|
|
1612
|
+
let error = Boom.forbidden(
|
|
1613
|
+
'A token with restricted permissions can not read the access token of an account that authenticates with application credentials'
|
|
1614
|
+
);
|
|
1615
|
+
error.output.payload.code = 'ApplicationCredentialToken';
|
|
1616
|
+
throw error;
|
|
1617
|
+
}
|
|
1448
1618
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
//
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
tokenData.provider = oauth2App.provider;
|
|
1619
|
+
const tokenData = await accountObject.getActiveAccessTokenData(accountData);
|
|
1620
|
+
|
|
1621
|
+
// Resolve the app ID to the provider name and expose the app ID separately.
|
|
1622
|
+
// Migrated legacy app IDs equal their provider name, so the lookup is a no-op
|
|
1623
|
+
// rename for these.
|
|
1624
|
+
if (tokenData.provider && oauth2App) {
|
|
1625
|
+
if (oauth2App.id !== oauth2App.provider) {
|
|
1626
|
+
tokenData.app = oauth2App.id;
|
|
1459
1627
|
}
|
|
1628
|
+
tokenData.provider = oauth2App.provider;
|
|
1460
1629
|
}
|
|
1461
1630
|
|
|
1462
1631
|
// Record metric if token was actually refreshed (not cached)
|
|
@@ -1531,6 +1700,10 @@ async function init(args) {
|
|
|
1531
1700
|
}
|
|
1532
1701
|
}
|
|
1533
1702
|
});
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
function registerGetServerSignatures(server, args) {
|
|
1706
|
+
const { call, CORS_CONFIG } = args;
|
|
1534
1707
|
|
|
1535
1708
|
server.route({
|
|
1536
1709
|
method: 'GET',
|
|
@@ -1545,7 +1718,7 @@ async function init(args) {
|
|
|
1545
1718
|
timeout: request.headers['x-ee-timeout']
|
|
1546
1719
|
});
|
|
1547
1720
|
try {
|
|
1548
|
-
return await accountObject.listSignatures(
|
|
1721
|
+
return await accountObject.listSignatures();
|
|
1549
1722
|
} catch (err) {
|
|
1550
1723
|
handleError(request, err);
|
|
1551
1724
|
}
|
|
@@ -1577,7 +1750,11 @@ async function init(args) {
|
|
|
1577
1750
|
failAction,
|
|
1578
1751
|
params: Joi.object({
|
|
1579
1752
|
account: accountIdSchema.required()
|
|
1580
|
-
})
|
|
1753
|
+
}),
|
|
1754
|
+
// The route takes no query arguments. Declared so that an unexpected one is
|
|
1755
|
+
// refused rather than silently reaching the handler (every /v1 GET route
|
|
1756
|
+
// declares its query, see test/api-routes-table-test.js)
|
|
1757
|
+
query: Joi.object({})
|
|
1581
1758
|
},
|
|
1582
1759
|
|
|
1583
1760
|
response: {
|
|
@@ -1598,6 +1775,10 @@ async function init(args) {
|
|
|
1598
1775
|
}
|
|
1599
1776
|
}
|
|
1600
1777
|
});
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
function registerAuthenticationForm(server, args) {
|
|
1781
|
+
const { CORS_CONFIG } = args;
|
|
1601
1782
|
|
|
1602
1783
|
server.route({
|
|
1603
1784
|
method: 'POST',
|
|
@@ -1766,6 +1947,10 @@ async function init(args) {
|
|
|
1766
1947
|
}
|
|
1767
1948
|
}
|
|
1768
1949
|
});
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
function registerGetLogs(server, args) {
|
|
1953
|
+
const { CORS_CONFIG } = args;
|
|
1769
1954
|
|
|
1770
1955
|
server.route({
|
|
1771
1956
|
method: 'GET',
|
|
@@ -1831,6 +2016,10 @@ async function init(args) {
|
|
|
1831
2016
|
}
|
|
1832
2017
|
}
|
|
1833
2018
|
});
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
function registerVerifyAccount(server, args) {
|
|
2022
|
+
const { CORS_CONFIG } = args;
|
|
1834
2023
|
|
|
1835
2024
|
server.route({
|
|
1836
2025
|
method: 'POST',
|
|
@@ -1909,6 +2098,10 @@ async function init(args) {
|
|
|
1909
2098
|
}
|
|
1910
2099
|
}
|
|
1911
2100
|
});
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
function registerGetAutoconfig(server, args) {
|
|
2104
|
+
const { CORS_CONFIG } = args;
|
|
1912
2105
|
|
|
1913
2106
|
server.route({
|
|
1914
2107
|
method: 'GET',
|
|
@@ -1961,6 +2154,10 @@ async function init(args) {
|
|
|
1961
2154
|
}
|
|
1962
2155
|
}
|
|
1963
2156
|
});
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
function registerPostAutoconfig(server, args) {
|
|
2160
|
+
const { CORS_CONFIG } = args;
|
|
1964
2161
|
|
|
1965
2162
|
server.route({
|
|
1966
2163
|
method: 'POST',
|
|
@@ -2031,4 +2228,25 @@ async function init(args) {
|
|
|
2031
2228
|
});
|
|
2032
2229
|
}
|
|
2033
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
|
+
|
|
2034
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;
|
|
@@ -14,8 +14,8 @@ const BEHAVIOR = require('./behavior-notes');
|
|
|
14
14
|
const { handleError } = require('./route-helpers');
|
|
15
15
|
const { IMPACT } = require('./operation-impact');
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
const {
|
|
17
|
+
function registerCreateDeliveryTest(server, args) {
|
|
18
|
+
const { call, CORS_CONFIG, SMTP_TEST_HOST } = args;
|
|
19
19
|
|
|
20
20
|
server.route({
|
|
21
21
|
method: 'POST',
|
|
@@ -129,6 +129,18 @@ ${now}`,
|
|
|
129
129
|
tags: ['api', 'Delivery Test'],
|
|
130
130
|
|
|
131
131
|
plugins: {
|
|
132
|
+
mcp: {
|
|
133
|
+
name: 'create_delivery_test',
|
|
134
|
+
title: 'Start delivery test',
|
|
135
|
+
description:
|
|
136
|
+
"Send a test message from the account to a probe address of EmailEngine's delivery test service, to see how its mail is received: whether it arrives and its SPF, DKIM and DMARC results. " +
|
|
137
|
+
'Returns a deliveryTest id; check_delivery_test reads the result from it, which takes a minute or so to be ready. check_delivery_test is a management tool, so a credential with mail access alone can start a test but not read it.',
|
|
138
|
+
// Picking an SMTP gateway is left to the REST API, as it is for send_message.
|
|
139
|
+
// Pinned to none rather than just hidden: the handler reads the field off a
|
|
140
|
+
// payload, so the call has to carry one
|
|
141
|
+
omit: ['gateway'],
|
|
142
|
+
force: { gateway: null }
|
|
143
|
+
},
|
|
132
144
|
openapi: {
|
|
133
145
|
'x-ee-impact': IMPACT.SENDS,
|
|
134
146
|
'x-ee-behavior': [BEHAVIOR.BACKGROUND_JOB],
|
|
@@ -188,6 +200,10 @@ ${now}`,
|
|
|
188
200
|
}
|
|
189
201
|
}
|
|
190
202
|
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function registerCheckDeliveryTest(server, args) {
|
|
206
|
+
const { CORS_CONFIG, SMTP_TEST_HOST } = args;
|
|
191
207
|
|
|
192
208
|
server.route({
|
|
193
209
|
method: 'GET',
|
|
@@ -282,7 +298,7 @@ ${now}`,
|
|
|
282
298
|
name: 'check_delivery_test',
|
|
283
299
|
title: 'Check delivery test',
|
|
284
300
|
description:
|
|
285
|
-
'Check the result of a delivery test started over the REST API: whether the probe message arrived, and its SPF, DKIM and DMARC results.'
|
|
301
|
+
'Check the result of a delivery test started by create_delivery_test or over the REST API: whether the probe message arrived, and its SPF, DKIM and DMARC results.'
|
|
286
302
|
},
|
|
287
303
|
openapi: {
|
|
288
304
|
responses: apiResponses(
|
|
@@ -347,4 +363,11 @@ ${now}`,
|
|
|
347
363
|
});
|
|
348
364
|
}
|
|
349
365
|
|
|
366
|
+
async function init(args) {
|
|
367
|
+
const { server } = args;
|
|
368
|
+
|
|
369
|
+
registerCreateDeliveryTest(server, args);
|
|
370
|
+
registerCheckDeliveryTest(server, args);
|
|
371
|
+
}
|
|
372
|
+
|
|
350
373
|
module.exports = init;
|
|
@@ -9,8 +9,8 @@ const { handleError } = require('./route-helpers');
|
|
|
9
9
|
const BEHAVIOR = require('./behavior-notes');
|
|
10
10
|
const { IMPACT } = require('./operation-impact');
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const {
|
|
12
|
+
function registerCreateExport(server, args) {
|
|
13
|
+
const { CORS_CONFIG } = args;
|
|
14
14
|
|
|
15
15
|
server.route({
|
|
16
16
|
method: 'POST',
|
|
@@ -74,6 +74,10 @@ async function init(args) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function registerGetExport(server, args) {
|
|
80
|
+
const { CORS_CONFIG } = args;
|
|
77
81
|
|
|
78
82
|
server.route({
|
|
79
83
|
method: 'GET',
|
|
@@ -128,6 +132,10 @@ async function init(args) {
|
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function registerDownloadExport(server, args) {
|
|
138
|
+
const { CORS_CONFIG } = args;
|
|
131
139
|
|
|
132
140
|
server.route({
|
|
133
141
|
method: 'GET',
|
|
@@ -188,6 +196,10 @@ async function init(args) {
|
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function registerDeleteExport(server, args) {
|
|
202
|
+
const { CORS_CONFIG } = args;
|
|
191
203
|
|
|
192
204
|
server.route({
|
|
193
205
|
method: 'DELETE',
|
|
@@ -245,6 +257,10 @@ async function init(args) {
|
|
|
245
257
|
}
|
|
246
258
|
}
|
|
247
259
|
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function registerListExports(server, args) {
|
|
263
|
+
const { CORS_CONFIG } = args;
|
|
248
264
|
|
|
249
265
|
server.route({
|
|
250
266
|
method: 'GET',
|
|
@@ -311,4 +327,14 @@ async function init(args) {
|
|
|
311
327
|
});
|
|
312
328
|
}
|
|
313
329
|
|
|
330
|
+
async function init(args) {
|
|
331
|
+
const { server } = args;
|
|
332
|
+
|
|
333
|
+
registerCreateExport(server, args);
|
|
334
|
+
registerGetExport(server, args);
|
|
335
|
+
registerDownloadExport(server, args);
|
|
336
|
+
registerDeleteExport(server, args);
|
|
337
|
+
registerListExports(server, args);
|
|
338
|
+
}
|
|
339
|
+
|
|
314
340
|
module.exports = init;
|