emailengine-app 2.85.0 → 2.86.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 +24 -6
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +74 -0
- package/Dockerfile +14 -1
- package/ENVIRONMENT.md +139 -0
- package/README.md +1 -1
- package/config/default.toml +2 -0
- package/copy-static-files.sh +4 -2
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +4 -3
- package/lib/account-assignment.js +19 -0
- package/lib/account.js +194 -165
- package/lib/api-error-codes.js +49 -0
- package/lib/api-reference/model.js +6 -1
- package/lib/api-routes/account-routes.js +78 -26
- package/lib/api-routes/blocklist-routes.js +68 -2
- package/lib/api-routes/delivery-test-routes.js +1 -1
- package/lib/api-routes/gateway-routes.js +82 -10
- package/lib/api-routes/index.js +4 -0
- package/lib/api-routes/license-routes.js +2 -2
- package/lib/api-routes/mailbox-routes.js +3 -3
- package/lib/api-routes/message-routes.js +15 -7
- package/lib/api-routes/oauth2-app-routes.js +15 -8
- package/lib/api-routes/outbox-routes.js +77 -66
- package/lib/api-routes/permission-map.js +55 -6
- package/lib/api-routes/scoped-routes.js +74 -0
- package/lib/api-routes/settings-routes.js +11 -4
- package/lib/api-routes/stats-routes.js +5 -1
- package/lib/api-routes/submit-routes.js +4 -3
- package/lib/api-routes/template-routes.js +7 -6
- package/lib/api-routes/token-routes.js +11 -5
- package/lib/api-routes/webhook-delivery-routes.js +262 -0
- package/lib/api-routes/webhook-route-routes.js +119 -4
- package/lib/calendar-event.js +81 -1
- package/lib/consts.js +38 -46
- package/lib/db.js +14 -6
- package/lib/delivery-error.js +6 -0
- package/lib/deprecations.js +270 -0
- package/lib/email-client/base-client.js +130 -156
- package/lib/email-client/fallback-poll.js +62 -0
- package/lib/email-client/gmail-client.js +51 -11
- package/lib/email-client/imap/adaptive-idle-store.js +73 -0
- package/lib/email-client/imap/adaptive-idle.js +278 -0
- package/lib/email-client/imap/connection-errors.js +14 -1
- package/lib/email-client/imap/idle-settings.js +31 -5
- package/lib/email-client/imap/listing-diff.js +37 -0
- package/lib/email-client/imap/mailbox.js +372 -226
- package/lib/email-client/imap/subconnection.js +7 -29
- package/lib/email-client/imap/sync-operations.js +220 -127
- package/lib/email-client/imap-client.js +227 -163
- package/lib/email-client/message-builder.js +14 -79
- package/lib/email-client/outlook-client.js +372 -338
- package/lib/email-client/smtp-pool-manager.js +16 -13
- package/lib/email-client/sync-state-fields.js +19 -0
- package/lib/encrypt.js +157 -41
- package/lib/enum-descriptions.js +3 -1
- package/lib/env-setting-overrides.js +288 -0
- package/lib/export-worker.js +751 -0
- package/lib/export.js +64 -15
- package/lib/gateway.js +17 -1
- package/lib/get-raw-email.js +25 -107
- package/lib/health.js +75 -0
- package/lib/lock-run.js +119 -0
- package/lib/logger-consts.js +48 -0
- package/lib/logger.js +1 -1
- package/lib/lua/z-head-scores.lua +28 -0
- package/lib/network-errors.js +1 -1
- package/lib/node-version.js +24 -0
- package/lib/notify-attachments.js +20 -1
- package/lib/oauth2-apps.js +630 -655
- package/lib/outbox.js +184 -54
- package/lib/parse-message.js +3 -3
- package/lib/privileged-settings.js +2 -2
- package/lib/queue-browser/definitions.js +11 -0
- package/lib/queue-browser/index.js +68 -19
- package/lib/queue-job-actions.js +18 -1
- package/lib/queue-retention.js +48 -12
- package/lib/queue-stats.js +11 -2
- package/lib/read-env-value.js +3 -0
- package/lib/redis-memory-warnings.js +99 -0
- package/lib/redis-reconnect.js +29 -0
- package/lib/request-timing.js +23 -0
- package/lib/respawn-backoff.js +35 -0
- package/lib/rewrite-text-nodes.js +19 -59
- package/lib/schemas.js +163 -39
- package/lib/settings.js +6 -2
- package/lib/smtp-auth.js +19 -1
- package/lib/thread-diagnostics.js +18 -1
- package/lib/tls/provision.js +6 -3
- package/lib/token-audit-log.js +19 -20
- package/lib/token-permission-view.js +4 -3
- package/lib/tools.js +8 -41
- package/lib/ui-routes/admin-config-routes.js +64 -90
- package/lib/ui-routes/admin-entities-routes.js +2 -14
- package/lib/ui-routes/imap-idle-field.js +1 -1
- package/lib/ui-routes/outlook-subscription-view.js +1 -1
- package/lib/ui-routes/overridable-fields.js +84 -0
- package/lib/ui-routes/queue-routes.js +8 -5
- package/lib/ui-routes/settings-page.js +6 -0
- package/lib/utils/decode-headers.js +3 -12
- package/lib/utils/filter-empty.js +20 -0
- package/lib/utils/int-setting.js +48 -0
- package/lib/utils/tracking-settings.js +35 -0
- package/lib/web-safe-html.js +18 -105
- package/lib/webhook-delivery.js +461 -0
- package/lib/webhook-failures.js +132 -0
- package/lib/webhook-request.js +29 -1
- package/lib/webhook-routing.js +30 -1
- package/lib/webhook-test.js +88 -0
- package/lib/webhooks.js +54 -41
- package/lib/worker-rpc-error.js +2 -1
- package/package.json +21 -20
- package/sbom.json +304 -382
- package/server.js +149 -76
- package/static/js/ace/ace.js +1 -1
- package/static/licenses.html +21 -31
- package/translations/messages.pot +26 -26
- package/views/config/security.hbs +22 -0
- package/views/config/service.hbs +44 -0
- package/views/config/webhooks.hbs +36 -0
- package/views/partials/queue_retention_note.hbs +12 -8
- package/views/partials/ui/env-managed-alert.hbs +16 -7
- package/workers/api.js +102 -28
- package/workers/export.js +16 -631
- package/workers/imap.js +13 -0
- package/workers/smtp.js +9 -11
- package/workers/webhooks.js +18 -432
- package/lib/email-client/outlook-fallback-poll.js +0 -30
|
@@ -42,7 +42,8 @@ const {
|
|
|
42
42
|
ENUM_DESCRIPTIONS,
|
|
43
43
|
apiBoolean,
|
|
44
44
|
mailboxAddressSchema,
|
|
45
|
-
accountProxySchema
|
|
45
|
+
accountProxySchema,
|
|
46
|
+
verifyResultSchema
|
|
46
47
|
} = require('../schemas');
|
|
47
48
|
|
|
48
49
|
const { REDIS_PREFIX, MAX_FORM_TTL, NONCE_BYTES, MCP_MAX_PAGE_SIZE, OUTLOOK_SYNC_MAX_LOOKBACK } = require('../consts');
|
|
@@ -57,28 +58,6 @@ const accountOauth2ScopesSchema = Joi.array()
|
|
|
57
58
|
.description('OAuth2 scopes granted for this account')
|
|
58
59
|
.label('AccountOauth2Scopes');
|
|
59
60
|
|
|
60
|
-
// Per-protocol result block for the account verification response - the IMAP and SMTP results
|
|
61
|
-
// carry the same fields built by verifyAccountInfo, only labels, wording, and the server
|
|
62
|
-
// response example differ
|
|
63
|
-
const verifyResultSchema = (proto, responseTextExample) =>
|
|
64
|
-
Joi.object({
|
|
65
|
-
success: Joi.boolean().example(true).description(`Was ${proto.toUpperCase()} account verified`).label(`Verify${proto}Success`),
|
|
66
|
-
error: Joi.string()
|
|
67
|
-
.example('Something went wrong')
|
|
68
|
-
.description(`Error messages for ${proto.toUpperCase()} verification. Only present if success=false`)
|
|
69
|
-
.label(`Verify${proto}Error`),
|
|
70
|
-
code: Joi.string().example('ERR_SSL_WRONG_VERSION_NUMBER').description('Error code. Only present if success=false').label(`Verify${proto}Code`),
|
|
71
|
-
statusCode: Joi.number()
|
|
72
|
-
.integer()
|
|
73
|
-
.example(500)
|
|
74
|
-
.description('HTTP-style status code for the error. Only present if success=false')
|
|
75
|
-
.label(`Verify${proto}StatusCode`),
|
|
76
|
-
responseText: Joi.string()
|
|
77
|
-
.example(responseTextExample)
|
|
78
|
-
.description('Server response for the failed verification. Only present if success=false')
|
|
79
|
-
.label(`Verify${proto}ResponseText`)
|
|
80
|
-
}).label(`Verify${proto}Result`);
|
|
81
|
-
|
|
82
61
|
// The answer autodiscovery gives, shared by GET and POST /v1/autoconfig. One definition rather than
|
|
83
62
|
// two identical inline copies: the OpenAPI converter collapses structurally identical labelled
|
|
84
63
|
// schemas into a single component, so the two routes publish one `DiscoveredEmailSettings` type.
|
|
@@ -1073,7 +1052,7 @@ function registerListAccounts(server, args) {
|
|
|
1073
1052
|
|
|
1074
1053
|
options: {
|
|
1075
1054
|
description: 'List accounts',
|
|
1076
|
-
notes: 'Lists registered
|
|
1055
|
+
notes: 'Lists the email accounts registered on this instance, one page at a time, with their connection state.',
|
|
1077
1056
|
tags: ['api', 'Account'],
|
|
1078
1057
|
|
|
1079
1058
|
plugins: {
|
|
@@ -1548,7 +1527,8 @@ function registerGetAccount(server, args) {
|
|
|
1548
1527
|
state: Joi.string()
|
|
1549
1528
|
.valid('creating', 'created', 'renewing', 'error')
|
|
1550
1529
|
.description('Subscription state')
|
|
1551
|
-
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.pubsubState })
|
|
1530
|
+
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.pubsubState })
|
|
1531
|
+
.label('OutlookSubscriptionStateName'),
|
|
1552
1532
|
time: Joi.number().example(1625727994336).description('Timestamp of last state change'),
|
|
1553
1533
|
error: Joi.string()
|
|
1554
1534
|
.allow(null)
|
|
@@ -1559,9 +1539,11 @@ function registerGetAccount(server, args) {
|
|
|
1559
1539
|
})
|
|
1560
1540
|
.unknown()
|
|
1561
1541
|
.description('Current subscription state')
|
|
1542
|
+
.label('OutlookSubscriptionState')
|
|
1562
1543
|
})
|
|
1563
1544
|
.unknown()
|
|
1564
|
-
.description('Microsoft Graph subscription details (Outlook accounts only)')
|
|
1545
|
+
.description('Microsoft Graph subscription details (Outlook accounts only)')
|
|
1546
|
+
.label('OutlookSubscription'),
|
|
1565
1547
|
|
|
1566
1548
|
lastError: lastErrorSchema.allow(null)
|
|
1567
1549
|
}).label('AccountResponse'),
|
|
@@ -1730,6 +1712,12 @@ function registerGetServerSignatures(server, args) {
|
|
|
1730
1712
|
tags: ['api', 'Account'],
|
|
1731
1713
|
|
|
1732
1714
|
plugins: {
|
|
1715
|
+
mcp: {
|
|
1716
|
+
name: 'get_server_signatures',
|
|
1717
|
+
title: 'Get account signatures',
|
|
1718
|
+
description:
|
|
1719
|
+
'List the email signatures configured on the account at the provider, to append to a message composed for it. Only Gmail API accounts report signatures; for other accounts the list is empty.'
|
|
1720
|
+
},
|
|
1733
1721
|
openapi: {
|
|
1734
1722
|
responses: apiResponses('Returns the signatures configured on the account, as reported by the provider.', 400, 401, 403, 404, 429, 500)
|
|
1735
1723
|
}
|
|
@@ -2018,6 +2006,69 @@ function registerGetLogs(server, args) {
|
|
|
2018
2006
|
});
|
|
2019
2007
|
}
|
|
2020
2008
|
|
|
2009
|
+
function registerDeleteLogs(server, args) {
|
|
2010
|
+
const { CORS_CONFIG } = args;
|
|
2011
|
+
|
|
2012
|
+
server.route({
|
|
2013
|
+
method: 'DELETE',
|
|
2014
|
+
path: '/v1/logs/{account}',
|
|
2015
|
+
|
|
2016
|
+
async handler(request) {
|
|
2017
|
+
try {
|
|
2018
|
+
if (!(await accountExists(redis, request.params.account))) {
|
|
2019
|
+
throw Boom.notFound('Account record was not found for requested ID');
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
const accountObject = new Account({ redis, account: request.params.account });
|
|
2023
|
+
const deleted = await redis.del(accountObject.getLogKey());
|
|
2024
|
+
request.logger.info({ msg: 'Cleared account logs', account: request.params.account });
|
|
2025
|
+
|
|
2026
|
+
return { deleted: !!deleted };
|
|
2027
|
+
} catch (err) {
|
|
2028
|
+
handleError(request, err);
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
options: {
|
|
2032
|
+
description: 'Clear stored logs for an account',
|
|
2033
|
+
notes: 'Removes every stored log entry of the account. Logging continues if it is enabled for the account or the instance.',
|
|
2034
|
+
tags: ['api', 'Logs'],
|
|
2035
|
+
|
|
2036
|
+
auth: {
|
|
2037
|
+
strategy: 'api-token',
|
|
2038
|
+
mode: 'required'
|
|
2039
|
+
},
|
|
2040
|
+
cors: CORS_CONFIG,
|
|
2041
|
+
|
|
2042
|
+
plugins: {
|
|
2043
|
+
openapi: {
|
|
2044
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
2045
|
+
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
2046
|
+
}
|
|
2047
|
+
},
|
|
2048
|
+
|
|
2049
|
+
validate: {
|
|
2050
|
+
options: {
|
|
2051
|
+
stripUnknown: false,
|
|
2052
|
+
abortEarly: false,
|
|
2053
|
+
convert: true
|
|
2054
|
+
},
|
|
2055
|
+
failAction,
|
|
2056
|
+
|
|
2057
|
+
params: Joi.object({
|
|
2058
|
+
account: accountIdSchema.required()
|
|
2059
|
+
}).label('DeleteLogsRequest')
|
|
2060
|
+
},
|
|
2061
|
+
|
|
2062
|
+
response: {
|
|
2063
|
+
schema: Joi.object({
|
|
2064
|
+
deleted: apiBoolean().default(true).description('False when there were no stored log entries to remove')
|
|
2065
|
+
}).label('DeleteLogsResponse'),
|
|
2066
|
+
failAction: 'log'
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2021
2072
|
function registerVerifyAccount(server, args) {
|
|
2022
2073
|
const { CORS_CONFIG } = args;
|
|
2023
2074
|
|
|
@@ -2244,6 +2295,7 @@ async function init(args) {
|
|
|
2244
2295
|
registerGetServerSignatures(server, args);
|
|
2245
2296
|
registerAuthenticationForm(server, args);
|
|
2246
2297
|
registerGetLogs(server, args);
|
|
2298
|
+
registerDeleteLogs(server, args);
|
|
2247
2299
|
registerVerifyAccount(server, args);
|
|
2248
2300
|
registerGetAutoconfig(server, args);
|
|
2249
2301
|
registerPostAutoconfig(server, args);
|
|
@@ -7,7 +7,7 @@ const { Account } = require('../account');
|
|
|
7
7
|
const getSecret = require('../get-secret');
|
|
8
8
|
const { lists } = require('../lists');
|
|
9
9
|
const { failAction } = require('../tools');
|
|
10
|
-
const { handleError } = require('./route-helpers');
|
|
10
|
+
const { handleError, throwNotFound } = require('./route-helpers');
|
|
11
11
|
const { accountIdSchema, blocklistListIdSchema, apiResponses, apiBoolean, mailboxAddressSchema } = require('../schemas');
|
|
12
12
|
const { IMPACT } = require('./operation-impact');
|
|
13
13
|
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
@@ -109,7 +109,7 @@ function registerGetBlocklist(server, args) {
|
|
|
109
109
|
|
|
110
110
|
options: {
|
|
111
111
|
description: 'List blocklist entries',
|
|
112
|
-
notes: '
|
|
112
|
+
notes: 'Lists the addresses on a suppression list, one page at a time, with why and when each was added.',
|
|
113
113
|
tags: ['api', 'Blocklists'],
|
|
114
114
|
|
|
115
115
|
plugins: {
|
|
@@ -351,9 +351,75 @@ function registerRemoveFromBlocklist(server, args) {
|
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
function registerDeleteBlocklist(server, args) {
|
|
355
|
+
const { CORS_CONFIG } = args;
|
|
356
|
+
|
|
357
|
+
server.route({
|
|
358
|
+
method: 'DELETE',
|
|
359
|
+
path: '/v1/blocklists/{listId}',
|
|
360
|
+
|
|
361
|
+
async handler(request) {
|
|
362
|
+
try {
|
|
363
|
+
if (!(await lists.deleteList(request.params.listId))) {
|
|
364
|
+
throwNotFound('Requested blocklist was not found');
|
|
365
|
+
}
|
|
366
|
+
return { deleted: true };
|
|
367
|
+
} catch (err) {
|
|
368
|
+
handleError(request, err);
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
options: {
|
|
372
|
+
description: 'Delete a blocklist',
|
|
373
|
+
notes: 'Deletes a whole suppression list with every address on it. Messages sent with this list ID are delivered to all recipients again.',
|
|
374
|
+
tags: ['api', 'Blocklists'],
|
|
375
|
+
|
|
376
|
+
plugins: {
|
|
377
|
+
mcp: {
|
|
378
|
+
name: 'delete_blocklist',
|
|
379
|
+
title: 'Delete suppression list',
|
|
380
|
+
description:
|
|
381
|
+
'Delete a whole suppression list with every address on it, so messages sent with that list id reach all recipients again. Confirm with the user before calling this.'
|
|
382
|
+
},
|
|
383
|
+
openapi: {
|
|
384
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
385
|
+
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
auth: {
|
|
390
|
+
strategy: 'api-token',
|
|
391
|
+
mode: 'required'
|
|
392
|
+
},
|
|
393
|
+
cors: CORS_CONFIG,
|
|
394
|
+
|
|
395
|
+
validate: {
|
|
396
|
+
options: {
|
|
397
|
+
stripUnknown: false,
|
|
398
|
+
abortEarly: false,
|
|
399
|
+
convert: true
|
|
400
|
+
},
|
|
401
|
+
failAction,
|
|
402
|
+
|
|
403
|
+
params: Joi.object({
|
|
404
|
+
listId: blocklistListIdSchema
|
|
405
|
+
}).label('BlocklistListRequest')
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
response: {
|
|
409
|
+
schema: Joi.object({
|
|
410
|
+
deleted: apiBoolean().default(true).description('Was the list deleted')
|
|
411
|
+
}).label('DeleteBlocklistListResponse'),
|
|
412
|
+
failAction: 'log'
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
354
418
|
async function init(args) {
|
|
355
419
|
const { server } = args;
|
|
356
420
|
|
|
421
|
+
registerDeleteBlocklist(server, args);
|
|
422
|
+
|
|
357
423
|
registerListBlocklists(server, args);
|
|
358
424
|
registerGetBlocklist(server, args);
|
|
359
425
|
registerAddToBlocklist(server, args);
|
|
@@ -290,7 +290,7 @@ function registerCheckDeliveryTest(server, args) {
|
|
|
290
290
|
},
|
|
291
291
|
options: {
|
|
292
292
|
description: 'Check test status',
|
|
293
|
-
notes: '
|
|
293
|
+
notes: 'Returns the result of a delivery test started with the delivery test endpoint: whether the test message arrived, and the authentication results it arrived with.',
|
|
294
294
|
tags: ['api', 'Delivery Test'],
|
|
295
295
|
|
|
296
296
|
plugins: {
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
4
|
const { redis } = require('../db');
|
|
5
|
-
const { Gateway } = require('../gateway');
|
|
5
|
+
const { Gateway, gatewaySmtpConfig } = require('../gateway');
|
|
6
6
|
const getSecret = require('../get-secret');
|
|
7
|
-
const { failAction } = require('../tools');
|
|
7
|
+
const { failAction, verifyAccountInfo } = require('../tools');
|
|
8
8
|
const { handleError, maskSecrets, MASKED, MASK_NOTE } = require('./route-helpers');
|
|
9
|
-
const { apiResponses, apiBoolean, formBoolean, requireTlsSchema } = require('../schemas');
|
|
9
|
+
const { apiResponses, apiBoolean, formBoolean, requireTlsSchema, verifyResultSchema, listQuerySchema } = require('../schemas');
|
|
10
10
|
const { ENUM_DESCRIPTIONS } = require('../enum-descriptions');
|
|
11
11
|
const { IMPACT } = require('./operation-impact');
|
|
12
12
|
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
@@ -18,7 +18,7 @@ const gatewayRequireTlsSchema = requireTlsSchema('GatewayRequireTLS', formBoolea
|
|
|
18
18
|
|
|
19
19
|
const gatewayLastErrorSchema = Joi.object({
|
|
20
20
|
created: Joi.number().integer().example(1623868624153).description('Timestamp of the error as milliseconds from epoch'),
|
|
21
|
-
status: Joi.string().valid('error').example('error').description('Status of the last delivery attempt'),
|
|
21
|
+
status: Joi.string().valid('error').example('error').description('Status of the last delivery attempt').label('GatewayErrorStatus'),
|
|
22
22
|
response: Joi.string().example('535 Authentication failed').description('SMTP server response for the failed delivery'),
|
|
23
23
|
responseCode: Joi.number().integer().example(535).description('SMTP response code'),
|
|
24
24
|
code: Joi.string().example('EAUTH').description('Error type identifier'),
|
|
@@ -46,7 +46,7 @@ function registerListGateways(server, args) {
|
|
|
46
46
|
try {
|
|
47
47
|
let gatewayObject = new Gateway({ redis, gateway: request.params.gateway, call, secret: await getSecret() });
|
|
48
48
|
|
|
49
|
-
const listing = await gatewayObject.listGateways(request.query.page, request.query.pageSize);
|
|
49
|
+
const listing = await gatewayObject.listGateways(request.query.page, request.query.pageSize, request.query.query);
|
|
50
50
|
|
|
51
51
|
for (const entry of listing.gateways || []) {
|
|
52
52
|
maskSecrets(entry);
|
|
@@ -60,7 +60,7 @@ function registerListGateways(server, args) {
|
|
|
60
60
|
|
|
61
61
|
options: {
|
|
62
62
|
description: 'List gateways',
|
|
63
|
-
notes: 'Lists
|
|
63
|
+
notes: 'Lists the stored SMTP gateways, one page at a time, with their delivery counters and last error. Passwords are not included.',
|
|
64
64
|
tags: ['api', 'SMTP Gateway'],
|
|
65
65
|
|
|
66
66
|
plugins: {
|
|
@@ -99,7 +99,8 @@ function registerListGateways(server, args) {
|
|
|
99
99
|
.example(0)
|
|
100
100
|
.description('Page number (zero indexed, so use 0 for first page)')
|
|
101
101
|
.label('PageNumber'),
|
|
102
|
-
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize')
|
|
102
|
+
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize'),
|
|
103
|
+
query: listQuerySchema('gateway ID, name, host or username', 'GatewaysListQuery')
|
|
103
104
|
}).label('GatewaysFilter')
|
|
104
105
|
},
|
|
105
106
|
|
|
@@ -272,7 +273,7 @@ function registerCreateGateway(server, args) {
|
|
|
272
273
|
|
|
273
274
|
options: {
|
|
274
275
|
description: 'Register new gateway',
|
|
275
|
-
notes: '
|
|
276
|
+
notes: "Stores an SMTP relay that messages can be sent through instead of the account's own SMTP server, by naming it as `gateway` when submitting.",
|
|
276
277
|
tags: ['api', 'SMTP Gateway'],
|
|
277
278
|
|
|
278
279
|
plugins: {
|
|
@@ -378,7 +379,7 @@ function registerUpdateGateway(server, args) {
|
|
|
378
379
|
},
|
|
379
380
|
options: {
|
|
380
381
|
description: 'Update gateway info',
|
|
381
|
-
notes: '
|
|
382
|
+
notes: 'Changes the stored settings of an SMTP gateway. Fields left out of the request keep their stored values, the password included.',
|
|
382
383
|
tags: ['api', 'SMTP Gateway'],
|
|
383
384
|
|
|
384
385
|
plugins: {
|
|
@@ -471,7 +472,7 @@ function registerDeleteGateway(server, args) {
|
|
|
471
472
|
},
|
|
472
473
|
options: {
|
|
473
474
|
description: 'Remove SMTP gateway',
|
|
474
|
-
notes: '
|
|
475
|
+
notes: 'Deletes a stored SMTP gateway. Messages queued for it fail to deliver.',
|
|
475
476
|
tags: ['api', 'SMTP Gateway'],
|
|
476
477
|
|
|
477
478
|
plugins: {
|
|
@@ -516,6 +517,76 @@ function registerDeleteGateway(server, args) {
|
|
|
516
517
|
});
|
|
517
518
|
}
|
|
518
519
|
|
|
520
|
+
function registerVerifyGateway(server, args) {
|
|
521
|
+
const { CORS_CONFIG } = args;
|
|
522
|
+
|
|
523
|
+
server.route({
|
|
524
|
+
method: 'POST',
|
|
525
|
+
path: '/v1/gateway/{gateway}/verify',
|
|
526
|
+
|
|
527
|
+
async handler(request) {
|
|
528
|
+
try {
|
|
529
|
+
let gatewayObject = new Gateway({ redis, gateway: request.params.gateway, secret: await getSecret() });
|
|
530
|
+
let gatewayData = await gatewayObject.loadGatewayData();
|
|
531
|
+
|
|
532
|
+
// Only ever with the stored settings: the stored password goes to the host it was
|
|
533
|
+
// stored for, and nowhere a request could name
|
|
534
|
+
let verifyResult = await verifyAccountInfo(
|
|
535
|
+
redis,
|
|
536
|
+
{ smtp: gatewaySmtpConfig(gatewayData) },
|
|
537
|
+
request.logger.child({ gateway: request.params.gateway, action: 'verify-gateway' })
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
return verifyResult.smtp;
|
|
541
|
+
} catch (err) {
|
|
542
|
+
handleError(request, err);
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
options: {
|
|
546
|
+
description: 'Verify SMTP gateway',
|
|
547
|
+
notes: 'Connects to the SMTP server of a stored gateway with its stored settings and credentials, and reports whether the connection and the authentication succeeded. Nothing is sent and nothing is stored.',
|
|
548
|
+
tags: ['api', 'SMTP Gateway'],
|
|
549
|
+
|
|
550
|
+
plugins: {
|
|
551
|
+
mcp: {
|
|
552
|
+
name: 'verify_gateway',
|
|
553
|
+
title: 'Check SMTP gateway',
|
|
554
|
+
description:
|
|
555
|
+
'Check that a stored SMTP gateway still connects and authenticates, with its stored settings and credentials. Nothing is sent or changed. Use it when deliveries through the gateway fail.'
|
|
556
|
+
},
|
|
557
|
+
openapi: {
|
|
558
|
+
'x-ee-impact': IMPACT.READONLY,
|
|
559
|
+
responses: apiResponses('Returns the result of the connection check.', 400, 401, 403, 404, 429, 500)
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
auth: {
|
|
564
|
+
strategy: 'api-token',
|
|
565
|
+
mode: 'required'
|
|
566
|
+
},
|
|
567
|
+
cors: CORS_CONFIG,
|
|
568
|
+
|
|
569
|
+
validate: {
|
|
570
|
+
options: {
|
|
571
|
+
stripUnknown: false,
|
|
572
|
+
abortEarly: false,
|
|
573
|
+
convert: true
|
|
574
|
+
},
|
|
575
|
+
failAction,
|
|
576
|
+
|
|
577
|
+
params: Joi.object({
|
|
578
|
+
gateway: Joi.string().max(256).required().example('example').description('Gateway ID')
|
|
579
|
+
}).label('VerifyGatewayRequest')
|
|
580
|
+
},
|
|
581
|
+
|
|
582
|
+
response: {
|
|
583
|
+
schema: verifyResultSchema('Smtp', '535 Authentication failed'),
|
|
584
|
+
failAction: 'log'
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
519
590
|
async function init(args) {
|
|
520
591
|
const { server } = args;
|
|
521
592
|
|
|
@@ -524,6 +595,7 @@ async function init(args) {
|
|
|
524
595
|
registerCreateGateway(server, args);
|
|
525
596
|
registerUpdateGateway(server, args);
|
|
526
597
|
registerDeleteGateway(server, args);
|
|
598
|
+
registerVerifyGateway(server, args);
|
|
527
599
|
}
|
|
528
600
|
|
|
529
601
|
module.exports = init;
|
package/lib/api-routes/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const statsRoutes = require('./stats-routes');
|
|
|
24
24
|
const licenseRoutes = require('./license-routes');
|
|
25
25
|
const outboxRoutes = require('./outbox-routes');
|
|
26
26
|
const webhookRouteRoutes = require('./webhook-route-routes');
|
|
27
|
+
const webhookDeliveryRoutes = require('./webhook-delivery-routes');
|
|
27
28
|
const oauth2AppRoutes = require('./oauth2-app-routes');
|
|
28
29
|
const gatewayRoutes = require('./gateway-routes');
|
|
29
30
|
const deliveryTestRoutes = require('./delivery-test-routes');
|
|
@@ -130,6 +131,9 @@ async function registerApiRoutes(args) {
|
|
|
130
131
|
// setup webhook route management routes
|
|
131
132
|
await webhookRouteRoutes({ server, CORS_CONFIG });
|
|
132
133
|
|
|
134
|
+
// setup failed webhook delivery routes
|
|
135
|
+
await webhookDeliveryRoutes({ server, CORS_CONFIG });
|
|
136
|
+
|
|
133
137
|
// setup OAuth2 application routes
|
|
134
138
|
await oauth2AppRoutes({ server, call, CORS_CONFIG, OAuth2ProviderSchema });
|
|
135
139
|
|
|
@@ -28,7 +28,7 @@ async function init(args) {
|
|
|
28
28
|
},
|
|
29
29
|
options: {
|
|
30
30
|
description: 'Request license info',
|
|
31
|
-
notes: '
|
|
31
|
+
notes: 'Returns the license this instance runs with: whether one is active, who it was issued to and when it expires.',
|
|
32
32
|
tags: ['api', 'License'],
|
|
33
33
|
|
|
34
34
|
plugins: {
|
|
@@ -74,7 +74,7 @@ async function init(args) {
|
|
|
74
74
|
},
|
|
75
75
|
options: {
|
|
76
76
|
description: 'Remove license',
|
|
77
|
-
notes: '
|
|
77
|
+
notes: 'Removes the active license. The instance continues without one.',
|
|
78
78
|
tags: ['api', 'License'],
|
|
79
79
|
|
|
80
80
|
plugins: {
|
|
@@ -75,7 +75,7 @@ function registerListMailboxes(server, args) {
|
|
|
75
75
|
|
|
76
76
|
options: {
|
|
77
77
|
description: 'List mailboxes',
|
|
78
|
-
notes: 'Lists
|
|
78
|
+
notes: 'Lists every folder of the account with its path, special-use flag and subscription state, and optionally its message counters.',
|
|
79
79
|
tags: ['api', 'Mailbox'],
|
|
80
80
|
|
|
81
81
|
plugins: {
|
|
@@ -157,7 +157,7 @@ function registerCreateMailbox(server, args) {
|
|
|
157
157
|
|
|
158
158
|
options: {
|
|
159
159
|
description: 'Create mailbox',
|
|
160
|
-
notes: '
|
|
160
|
+
notes: 'Creates a folder at the given path, a missing parent folder included. The path can be given as a list of names, which the server joins with its own separator.',
|
|
161
161
|
tags: ['api', 'Mailbox'],
|
|
162
162
|
|
|
163
163
|
plugins: {
|
|
@@ -333,7 +333,7 @@ function registerDeleteMailbox(server, args) {
|
|
|
333
333
|
|
|
334
334
|
options: {
|
|
335
335
|
description: 'Delete mailbox',
|
|
336
|
-
notes: '
|
|
336
|
+
notes: 'Deletes a folder together with every message in it.',
|
|
337
337
|
tags: ['api', 'Mailbox'],
|
|
338
338
|
|
|
339
339
|
plugins: {
|
|
@@ -122,7 +122,7 @@ function registerGetMessageSource(server, args) {
|
|
|
122
122
|
},
|
|
123
123
|
options: {
|
|
124
124
|
description: 'Download raw message',
|
|
125
|
-
notes: '
|
|
125
|
+
notes: 'Streams the raw RFC 822 source of the message as the server stores it, headers and MIME parts included.',
|
|
126
126
|
tags: ['api', 'Message'],
|
|
127
127
|
|
|
128
128
|
auth: {
|
|
@@ -132,6 +132,14 @@ function registerGetMessageSource(server, args) {
|
|
|
132
132
|
cors: CORS_CONFIG,
|
|
133
133
|
|
|
134
134
|
plugins: {
|
|
135
|
+
mcp: {
|
|
136
|
+
name: 'get_message_source',
|
|
137
|
+
title: 'Get raw message source',
|
|
138
|
+
description:
|
|
139
|
+
'Download the raw RFC 822 source of one message, headers and MIME parts included, returned inline as a base64 resource. Use get_message for the parsed message; this is for inspecting headers such as authentication results, or forwarding the original. Fails above 1 MB.',
|
|
140
|
+
binary: true,
|
|
141
|
+
resourceUriTemplate: 'emailengine://account/{account}/message/{message}/source'
|
|
142
|
+
},
|
|
135
143
|
openapi: {
|
|
136
144
|
produces: ['message/rfc822'],
|
|
137
145
|
responses: apiResponses('Returns the raw RFC822 message source.', 400, 401, 403, 404, 429, 500, 503)
|
|
@@ -390,11 +398,11 @@ function registerUploadMessage(server, args) {
|
|
|
390
398
|
.single()
|
|
391
399
|
.description('List of addresses')
|
|
392
400
|
.example([{ address: 'recipient@example.com' }])
|
|
393
|
-
.label('
|
|
401
|
+
.label('UploadToAddressList'),
|
|
394
402
|
|
|
395
|
-
cc: Joi.array().items(addressSchema).single().description('List of addresses').label('
|
|
403
|
+
cc: Joi.array().items(addressSchema).single().description('List of addresses').label('UploadAddressList'),
|
|
396
404
|
|
|
397
|
-
bcc: Joi.array().items(addressSchema).single().description('List of addresses').label('
|
|
405
|
+
bcc: Joi.array().items(addressSchema).single().description('List of addresses').label('UploadAddressList'),
|
|
398
406
|
|
|
399
407
|
subject: Joi.string()
|
|
400
408
|
.allow('')
|
|
@@ -704,7 +712,7 @@ function registerMoveMessage(server, args) {
|
|
|
704
712
|
},
|
|
705
713
|
options: {
|
|
706
714
|
description: 'Move a message to a specified folder',
|
|
707
|
-
notes: 'Moves a message to
|
|
715
|
+
notes: 'Moves a message to another folder of the same account. When the server reports it, the response carries the ID the message has in the target folder, which can differ from the one it had.',
|
|
708
716
|
tags: ['api', 'Message'],
|
|
709
717
|
|
|
710
718
|
plugins: {
|
|
@@ -1087,7 +1095,7 @@ function registerListMessages(server, args) {
|
|
|
1087
1095
|
},
|
|
1088
1096
|
options: {
|
|
1089
1097
|
description: 'List messages in a folder',
|
|
1090
|
-
notes: 'Lists messages
|
|
1098
|
+
notes: 'Lists the messages of one folder, newest first, one page at a time. Each entry carries the envelope, flags and labels, not the message body; use the message endpoint for the content.',
|
|
1091
1099
|
tags: ['api', 'Message'],
|
|
1092
1100
|
|
|
1093
1101
|
plugins: {
|
|
@@ -1304,7 +1312,7 @@ function registerGetMessageText(server, args) {
|
|
|
1304
1312
|
},
|
|
1305
1313
|
options: {
|
|
1306
1314
|
description: 'Retrieve message text',
|
|
1307
|
-
notes: '
|
|
1315
|
+
notes: 'Returns the plain text and HTML content of a message by the text ID from the message details, decoded to UTF-8.',
|
|
1308
1316
|
tags: ['api', 'Message'],
|
|
1309
1317
|
|
|
1310
1318
|
plugins: {
|
|
@@ -16,11 +16,13 @@ const {
|
|
|
16
16
|
apiResponses,
|
|
17
17
|
ENUM_DESCRIPTIONS,
|
|
18
18
|
apiBoolean,
|
|
19
|
-
formBoolean
|
|
19
|
+
formBoolean,
|
|
20
|
+
listQuerySchema
|
|
20
21
|
} = require('../schemas');
|
|
21
22
|
const { handleError, throwNotFound, flattenOAuthAppMeta, assertNoAttachedIdentity, MASKED } = require('./route-helpers');
|
|
22
23
|
const { ENCRYPTED_APP_KEYS, MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
23
24
|
const { IMPACT } = require('./operation-impact');
|
|
25
|
+
const { deprecated } = require('../deprecations');
|
|
24
26
|
|
|
25
27
|
// Stored fields that are returned on OAuth2 application objects in addition to the basic fields
|
|
26
28
|
const oauth2AppExtraFields = {
|
|
@@ -62,7 +64,7 @@ function registerListOAuth2Apps(server, ctx) {
|
|
|
62
64
|
|
|
63
65
|
async handler(request) {
|
|
64
66
|
try {
|
|
65
|
-
let response = await oauth2Apps.list(request.query.page, request.query.pageSize);
|
|
67
|
+
let response = await oauth2Apps.list(request.query.page, request.query.pageSize, { query: request.query.query });
|
|
66
68
|
|
|
67
69
|
for (let app of response.apps) {
|
|
68
70
|
for (let secretKey of ENCRYPTED_APP_KEYS) {
|
|
@@ -90,7 +92,7 @@ function registerListOAuth2Apps(server, ctx) {
|
|
|
90
92
|
|
|
91
93
|
options: {
|
|
92
94
|
description: 'List OAuth2 applications',
|
|
93
|
-
notes: 'Lists
|
|
95
|
+
notes: 'Lists the stored OAuth2 applications, one page at a time. Client secrets and keys are not included.',
|
|
94
96
|
tags: ['api', 'OAuth2 Applications'],
|
|
95
97
|
|
|
96
98
|
plugins: {
|
|
@@ -129,8 +131,9 @@ function registerListOAuth2Apps(server, ctx) {
|
|
|
129
131
|
.example(0)
|
|
130
132
|
.description('Page number (zero indexed, so use 0 for first page)')
|
|
131
133
|
.label('PageNumber'),
|
|
132
|
-
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize')
|
|
133
|
-
|
|
134
|
+
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize'),
|
|
135
|
+
query: listQuerySchema('ID, name, description, client ID, service account or Pub/Sub names', 'OAuth2AppsListQuery')
|
|
136
|
+
}).label('OAuth2AppsFilter')
|
|
134
137
|
},
|
|
135
138
|
|
|
136
139
|
response: {
|
|
@@ -539,7 +542,11 @@ function registerUpdateOAuth2App(server, ctx) {
|
|
|
539
542
|
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.azureCloud })
|
|
540
543
|
.label('AzureCloud'),
|
|
541
544
|
|
|
542
|
-
tenant
|
|
545
|
+
// The admin form's way of naming a directory tenant (authority 'tenant' plus this
|
|
546
|
+
// value). Over the API the tenant ID goes into authority itself
|
|
547
|
+
tenant: deprecated(Joi.string().trim().empty('').max(1024).example('f8cdef31-a31e-4b4a-93e4-5f571e91255a'), 'tenant').label(
|
|
548
|
+
'Directorytenant'
|
|
549
|
+
),
|
|
543
550
|
|
|
544
551
|
redirectUrl: Joi.string()
|
|
545
552
|
.allow('', null, false)
|
|
@@ -585,7 +592,7 @@ function registerDeleteOAuth2App(server, ctx) {
|
|
|
585
592
|
},
|
|
586
593
|
options: {
|
|
587
594
|
description: 'Remove OAuth2 application',
|
|
588
|
-
notes: '
|
|
595
|
+
notes: 'Deletes a stored OAuth2 application. Accounts that authenticate through it can no longer connect.',
|
|
589
596
|
tags: ['api', 'OAuth2 Applications'],
|
|
590
597
|
|
|
591
598
|
plugins: {
|
|
@@ -709,7 +716,7 @@ function registerVerifyOAuth2App(server, ctx) {
|
|
|
709
716
|
Joi.object({
|
|
710
717
|
id: Joi.string().example('signJwt').description('Step identifier'),
|
|
711
718
|
label: Joi.string().example('Sign assertion (signJwt)').description('Human readable step name'),
|
|
712
|
-
status: Joi.string().valid('ok', 'fail', 'skip').example('ok').description('Step outcome'),
|
|
719
|
+
status: Joi.string().valid('ok', 'fail', 'skip').example('ok').description('Step outcome').label('OAuth2VerifyStepStatus'),
|
|
713
720
|
message: Joi.string().allow(null).example('Assertion signed via IAM signJwt').description('Outcome detail'),
|
|
714
721
|
hint: Joi.string()
|
|
715
722
|
.example('Grant roles/iam.serviceAccountTokenCreator to the workload principal')
|