emailengine-app 2.77.0 → 2.79.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/.github/workflows/test.yml +80 -0
- package/.ncurc.js +23 -13
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +60 -0
- package/bin/emailengine.js +1 -1
- package/config/e2e.toml +2 -1
- package/config/test.toml +2 -1
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +1 -1
- package/lib/account/expected-identity.js +88 -0
- package/lib/account.js +145 -61
- package/lib/api-reference/format.js +105 -4
- package/lib/api-reference/index.js +24 -7
- package/lib/api-reference/model.js +148 -21
- package/lib/api-reference/schema-tree.js +282 -28
- package/lib/api-routes/account-routes.js +99 -36
- package/lib/api-routes/behavior-notes.js +3 -0
- package/lib/api-routes/blocklist-routes.js +21 -47
- package/lib/api-routes/chat-routes.js +10 -12
- package/lib/api-routes/delivery-test-routes.js +6 -26
- package/lib/api-routes/export-routes.js +2 -0
- package/lib/api-routes/gateway-routes.js +52 -11
- package/lib/api-routes/license-routes.js +2 -0
- package/lib/api-routes/mailbox-routes.js +29 -26
- package/lib/api-routes/message-routes.js +27 -21
- package/lib/api-routes/oauth2-app-routes.js +11 -29
- package/lib/api-routes/operation-impact.js +80 -0
- package/lib/api-routes/outbox-routes.js +15 -5
- package/lib/api-routes/permission-map.js +397 -0
- package/lib/api-routes/route-helpers.js +223 -9
- package/lib/api-routes/route-metadata.js +28 -0
- package/lib/api-routes/settings-routes.js +30 -25
- package/lib/api-routes/stats-routes.js +2 -2
- package/lib/api-routes/submit-routes.js +53 -31
- package/lib/api-routes/template-routes.js +3 -0
- package/lib/api-routes/token-routes.js +319 -33
- package/lib/api-routes/webhook-route-routes.js +14 -4
- package/lib/append-list.js +3 -14
- package/lib/arf-detect.js +23 -1
- package/lib/auth-token.js +80 -8
- package/lib/autodetect-imap-settings.js +40 -16
- package/lib/base32.js +30 -0
- package/lib/bounce-detect.js +182 -62
- package/lib/consts.js +10 -0
- package/lib/db.js +20 -2
- package/lib/delivery-error.js +30 -1
- package/lib/egress-filter.js +89 -8
- package/lib/email-client/base-client.js +35 -113
- package/lib/email-client/gmail-client.js +22 -13
- package/lib/email-client/imap/listing-diff.js +3 -3
- package/lib/email-client/imap/mailbox.js +28 -93
- package/lib/email-client/imap/subconnection.js +10 -7
- package/lib/email-client/imap/sync-operations.js +46 -46
- package/lib/email-client/imap-client.js +39 -28
- package/lib/email-client/message-builder.js +15 -15
- package/lib/email-client/notification-handler.js +1 -1
- package/lib/email-client/outlook/graph-api.js +10 -4
- package/lib/email-client/outlook-client.js +54 -55
- package/lib/email-client/smtp-pool-manager.js +1 -1
- package/lib/enum-descriptions.js +92 -2
- package/lib/export.js +2 -2
- package/lib/field-usage.js +133 -0
- package/lib/gateway.js +2 -2
- package/lib/get-raw-email.js +1 -1
- package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
- package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
- package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
- package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
- package/lib/imapproxy/imap-core/lib/imap-connection.js +17 -7
- package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
- package/lib/imapproxy/imap-server.js +40 -10
- package/lib/license-beacon.js +5 -10
- package/lib/lists.js +49 -1
- package/lib/llm-pre-process.js +6 -6
- package/lib/logger.js +5 -1
- package/lib/metrics-collector.js +2 -2
- package/lib/msgpack.js +62 -0
- package/lib/oauth/decode-jwt-payload.js +39 -0
- package/lib/oauth/gmail.js +9 -12
- package/lib/oauth/mail-ru.js +5 -7
- package/lib/oauth/outlook-identity.js +61 -0
- package/lib/oauth/outlook.js +9 -9
- package/lib/oauth/pubsub/google.js +25 -10
- package/lib/oauth/retry-setup.js +38 -0
- package/lib/oauth/scope-checker.js +1 -1
- package/lib/oauth2-apps.js +224 -295
- package/lib/openapi/build-document.js +15 -7
- package/lib/openapi/joi-schema.js +20 -0
- package/lib/outbox.js +145 -14
- package/lib/pre-process.js +9 -9
- package/lib/queue-stats.js +49 -0
- package/lib/read-env-value.js +37 -0
- package/lib/reconnection-manager.js +2 -2
- package/lib/rewrite-text-nodes.js +4 -3
- package/lib/routes-ui.js +4 -0
- package/lib/schemas.js +223 -155
- package/lib/settings.js +84 -5
- package/lib/sub-script.js +2 -1
- package/lib/swagger-options.js +2 -1
- package/lib/templates.js +5 -5
- package/lib/threads.js +2 -2
- package/lib/token-audit-log.js +208 -0
- package/lib/token-permission-view.js +219 -0
- package/lib/token-permissions.js +172 -0
- package/lib/tokens.js +100 -16
- package/lib/tools.js +259 -85
- package/lib/totp.js +67 -0
- package/lib/ui-routes/account-routes.js +122 -26
- package/lib/ui-routes/admin-config-routes.js +20 -17
- package/lib/ui-routes/admin-entities-routes.js +66 -22
- package/lib/ui-routes/auth-routes.js +36 -48
- package/lib/ui-routes/export-routes.js +10 -4
- package/lib/ui-routes/oauth-config-routes.js +5 -5
- package/lib/ui-routes/reference-routes.js +11 -8
- package/lib/ui-routes/route-helpers.js +79 -2
- package/lib/ui-routes/settings-page.js +1 -1
- package/lib/ui-routes/smtp-test-routes.js +1 -1
- package/lib/ui-routes/suppression-list-routes.js +294 -0
- package/lib/ui-routes/unsubscribe-routes.js +19 -29
- package/lib/utils/is-email.js +34 -0
- package/lib/utils/network.js +2 -2
- package/lib/utils/to-camel-case.js +17 -0
- package/lib/web-safe-html.js +1 -1
- package/lib/webhook-egress.js +37 -0
- package/lib/webhook-routing.js +80 -0
- package/lib/webhooks.js +21 -15
- package/package.json +26 -27
- package/sbom.json +1 -0
- package/server.js +81 -42
- package/static/css/flyonui.css +1 -1
- package/static/css/public.css +3 -0
- package/static/css/src/app.tailwind.css +159 -9
- package/static/js/app.js +69 -0
- package/static/js/reference.js +741 -10
- package/static/js/ui.js +43 -0
- package/static/licenses.html +698 -1590
- package/translations/README.md +64 -0
- package/translations/de.mo +0 -0
- package/translations/de.po +164 -120
- package/translations/en.po +200 -161
- package/translations/et.mo +0 -0
- package/translations/et.po +163 -120
- package/translations/fr.mo +0 -0
- package/translations/fr.po +163 -120
- package/translations/ja.mo +0 -0
- package/translations/ja.po +163 -120
- package/translations/messages.pot +94 -64
- package/translations/nl.mo +0 -0
- package/translations/nl.po +164 -120
- package/translations/pl.mo +0 -0
- package/translations/pl.po +163 -120
- package/views/account-identity-error.hbs +34 -0
- package/views/accounts/account.hbs +69 -7
- package/views/accounts/browse.hbs +18 -35
- package/views/accounts/edit.hbs +1 -0
- package/views/accounts/register/imap.hbs +12 -2
- package/views/config/logging.hbs +6 -0
- package/views/config/oauth/app.hbs +0 -2
- package/views/config/security.hbs +13 -0
- package/views/layout/app.hbs +29 -5
- package/views/oauth-scope-error.hbs +1 -1
- package/views/partials/oauth_form.hbs +0 -15
- package/views/partials/reference/disclosure.hbs +8 -2
- package/views/partials/reference/nav.hbs +36 -9
- package/views/partials/reference/operation.hbs +48 -14
- package/views/partials/reference/params.hbs +17 -1
- package/views/partials/reference/schema-node.hbs +112 -54
- package/views/partials/reference/schema-tools.hbs +25 -0
- package/views/partials/reference/token-alert.hbs +35 -10
- package/views/partials/reference/try-it.hbs +84 -11
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/ui/checkbox.hbs +2 -2
- package/views/partials/ui/tabs.hbs +7 -1
- package/views/reference/index.hbs +1 -1
- package/views/reference/token.hbs +4 -0
- package/views/suppression-lists/index.hbs +85 -0
- package/views/suppression-lists/list.hbs +87 -0
- package/views/templates/index.hbs +8 -2
- package/views/tokens/index.hbs +31 -4
- package/views/tokens/new.hbs +324 -2
- package/workers/api.js +299 -140
- package/workers/documents.js +46 -26
- package/workers/export.js +20 -8
- package/workers/imap-proxy.js +2 -2
- package/workers/imap.js +13 -7
- package/workers/smtp.js +13 -7
- package/workers/submit.js +41 -31
- package/workers/webhooks.js +60 -37
- package/lib/feature-flags.js +0 -48
|
@@ -5,8 +5,10 @@ const { redis } = require('../db');
|
|
|
5
5
|
const { Gateway } = require('../gateway');
|
|
6
6
|
const getSecret = require('../get-secret');
|
|
7
7
|
const { failAction } = require('../tools');
|
|
8
|
-
const { handleError } = require('./route-helpers');
|
|
8
|
+
const { handleError, maskSecrets, MASKED, MASK_NOTE } = require('./route-helpers');
|
|
9
9
|
const { apiResponses } = require('../schemas');
|
|
10
|
+
const { ENUM_DESCRIPTIONS } = require('../enum-descriptions');
|
|
11
|
+
const { IMPACT } = require('./operation-impact');
|
|
10
12
|
|
|
11
13
|
// Gateways store SMTP delivery errors, not OAuth2 errors, so the error shape differs from the
|
|
12
14
|
// account-level lastErrorSchema
|
|
@@ -18,7 +20,12 @@ const gatewayLastErrorSchema = Joi.object({
|
|
|
18
20
|
code: Joi.string().example('EAUTH').description('Error type identifier'),
|
|
19
21
|
command: Joi.string().example('AUTH PLAIN').description('SMTP command that failed'),
|
|
20
22
|
description: Joi.string().example('Authentication failed').description('Error description'),
|
|
21
|
-
networkRouting: Joi.object()
|
|
23
|
+
networkRouting: Joi.object()
|
|
24
|
+
.unknown()
|
|
25
|
+
.allow(null)
|
|
26
|
+
.example({ localAddress: '198.51.100.24', name: 'relay.example.com' })
|
|
27
|
+
.description('Network routing information for the delivery attempt')
|
|
28
|
+
.label('GatewayErrorNetworkRouting')
|
|
22
29
|
})
|
|
23
30
|
.unknown()
|
|
24
31
|
.description('Information about the last failed delivery attempt using this gateway')
|
|
@@ -35,7 +42,13 @@ async function init(args) {
|
|
|
35
42
|
try {
|
|
36
43
|
let gatewayObject = new Gateway({ redis, gateway: request.params.gateway, call, secret: await getSecret() });
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
const listing = await gatewayObject.listGateways(request.query.page, request.query.pageSize);
|
|
46
|
+
|
|
47
|
+
for (const entry of listing.gateways || []) {
|
|
48
|
+
maskSecrets(entry);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return listing;
|
|
39
52
|
} catch (err) {
|
|
40
53
|
handleError(request, err);
|
|
41
54
|
}
|
|
@@ -117,9 +130,13 @@ async function init(args) {
|
|
|
117
130
|
|
|
118
131
|
// remove secrets
|
|
119
132
|
if (gatewayData.pass) {
|
|
120
|
-
gatewayData.pass =
|
|
133
|
+
gatewayData.pass = MASKED;
|
|
121
134
|
}
|
|
122
135
|
|
|
136
|
+
// A failed delivery records the proxy it used under lastError.networkRouting, which
|
|
137
|
+
// is projected below - the password beside it was already masked
|
|
138
|
+
maskSecrets(gatewayData);
|
|
139
|
+
|
|
123
140
|
let result = {};
|
|
124
141
|
|
|
125
142
|
for (let key of ['gateway', 'name', 'host', 'port', 'user', 'pass', 'secure', 'deliveries', 'lastUse', 'lastError']) {
|
|
@@ -135,7 +152,7 @@ async function init(args) {
|
|
|
135
152
|
},
|
|
136
153
|
options: {
|
|
137
154
|
description: 'Get gateway info',
|
|
138
|
-
notes:
|
|
155
|
+
notes: `Returns stored information about the gateway. ${MASK_NOTE}`,
|
|
139
156
|
tags: ['api', 'SMTP Gateway'],
|
|
140
157
|
|
|
141
158
|
plugins: {
|
|
@@ -175,10 +192,18 @@ async function init(args) {
|
|
|
175
192
|
.example('2021-02-17T13:43:18.860Z')
|
|
176
193
|
.description('Last delivery time. Null for gateways that have not been used yet'),
|
|
177
194
|
|
|
178
|
-
user: Joi.string()
|
|
195
|
+
user: Joi.string()
|
|
196
|
+
.empty('')
|
|
197
|
+
.trim()
|
|
198
|
+
.allow(null)
|
|
199
|
+
.max(1024)
|
|
200
|
+
.example('smtp-user')
|
|
201
|
+
.description('SMTP authentication username')
|
|
202
|
+
.label('UserName'),
|
|
179
203
|
pass: Joi.string()
|
|
180
204
|
.empty('')
|
|
181
205
|
.max(1024)
|
|
206
|
+
.example('******')
|
|
182
207
|
.description('SMTP authentication password. Always returned as the masked value "******" when a password is set')
|
|
183
208
|
.label('Password'),
|
|
184
209
|
|
|
@@ -252,8 +277,15 @@ async function init(args) {
|
|
|
252
277
|
|
|
253
278
|
name: Joi.string().empty('').max(256).example('John Smith').description('Account Name').label('Gateway Name').required(),
|
|
254
279
|
|
|
255
|
-
user: Joi.string()
|
|
256
|
-
|
|
280
|
+
user: Joi.string()
|
|
281
|
+
.empty('')
|
|
282
|
+
.trim()
|
|
283
|
+
.default(null)
|
|
284
|
+
.max(1024)
|
|
285
|
+
.example('smtp-user')
|
|
286
|
+
.description('SMTP authentication username')
|
|
287
|
+
.label('UserName'),
|
|
288
|
+
pass: Joi.string().empty('').max(1024).default(null).example('verysecret').description('SMTP authentication password').label('Password'),
|
|
257
289
|
|
|
258
290
|
host: Joi.string().hostname().example('smtp.gmail.com').description('Hostname to connect to').label('Hostname').required(),
|
|
259
291
|
port: Joi.number()
|
|
@@ -282,7 +314,8 @@ async function init(args) {
|
|
|
282
314
|
.required()
|
|
283
315
|
.valid('existing', 'new')
|
|
284
316
|
.example('new')
|
|
285
|
-
.description('
|
|
317
|
+
.description('Whether the gateway was created or updated')
|
|
318
|
+
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.entityState })
|
|
286
319
|
.label('CreateGatewayState')
|
|
287
320
|
}).label('CreateGatewayResponse'),
|
|
288
321
|
failAction: 'log'
|
|
@@ -335,8 +368,15 @@ async function init(args) {
|
|
|
335
368
|
payload: Joi.object({
|
|
336
369
|
name: Joi.string().empty('').max(256).example('John Smith').description('Account Name').label('Gateway Name'),
|
|
337
370
|
|
|
338
|
-
user: Joi.string()
|
|
339
|
-
|
|
371
|
+
user: Joi.string()
|
|
372
|
+
.empty('')
|
|
373
|
+
.trim()
|
|
374
|
+
.max(1024)
|
|
375
|
+
.allow(null)
|
|
376
|
+
.example('smtp-user')
|
|
377
|
+
.description('SMTP authentication username')
|
|
378
|
+
.label('UserName'),
|
|
379
|
+
pass: Joi.string().empty('').max(1024).allow(null).example('verysecret').description('SMTP authentication password').label('Password'),
|
|
340
380
|
|
|
341
381
|
host: Joi.string().hostname().empty('').example('smtp.gmail.com').description('Hostname to connect to').label('Hostname'),
|
|
342
382
|
port: Joi.number()
|
|
@@ -390,6 +430,7 @@ async function init(args) {
|
|
|
390
430
|
|
|
391
431
|
plugins: {
|
|
392
432
|
openapi: {
|
|
433
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
393
434
|
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
394
435
|
}
|
|
395
436
|
},
|
|
@@ -4,6 +4,7 @@ const Joi = require('joi');
|
|
|
4
4
|
const { failAction } = require('../tools');
|
|
5
5
|
const { handleError } = require('./route-helpers');
|
|
6
6
|
const { licenseSchema, apiResponses } = require('../schemas');
|
|
7
|
+
const { IMPACT } = require('./operation-impact');
|
|
7
8
|
|
|
8
9
|
async function init(args) {
|
|
9
10
|
const { server, call, CORS_CONFIG } = args;
|
|
@@ -73,6 +74,7 @@ async function init(args) {
|
|
|
73
74
|
|
|
74
75
|
plugins: {
|
|
75
76
|
openapi: {
|
|
77
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
76
78
|
responses: apiResponses('Returns an empty license object. EmailEngine drops to limited mode.', 401, 403, 429, 500)
|
|
77
79
|
}
|
|
78
80
|
},
|
|
@@ -6,8 +6,31 @@ const { redis } = require('../db');
|
|
|
6
6
|
const { Account } = require('../account');
|
|
7
7
|
const getSecret = require('../get-secret');
|
|
8
8
|
const { failAction } = require('../tools');
|
|
9
|
-
const { handleError } = require('./route-helpers');
|
|
9
|
+
const { handleError, logApiError } = require('./route-helpers');
|
|
10
10
|
const { accountIdSchema, mailboxesSchema, apiResponses } = require('../schemas');
|
|
11
|
+
const { IMPACT } = require('./operation-impact');
|
|
12
|
+
const { FIELD_USAGE } = require('../field-usage');
|
|
13
|
+
|
|
14
|
+
// The create and modify routes publish err.info as `details`, which is the field their documented
|
|
15
|
+
// error schema declares, while the shared handleError publishes it as `info`. They keep their own
|
|
16
|
+
// envelope rather than fork the logging policy, so routing them through handleError would silently
|
|
17
|
+
// rename a published response field. Always throws, like handleError.
|
|
18
|
+
function throwMailboxError(request, err) {
|
|
19
|
+
let statusCode = logApiError(request, err);
|
|
20
|
+
|
|
21
|
+
if (Boom.isBoom(err)) {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let error = Boom.boomify(err, { statusCode });
|
|
26
|
+
if (err.code) {
|
|
27
|
+
error.output.payload.code = err.code;
|
|
28
|
+
}
|
|
29
|
+
if (err.info) {
|
|
30
|
+
error.output.payload.details = err.info;
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
11
34
|
|
|
12
35
|
async function init(args) {
|
|
13
36
|
const { server, call, CORS_CONFIG, FLAG_SORT_ORDER } = args;
|
|
@@ -123,18 +146,7 @@ async function init(args) {
|
|
|
123
146
|
try {
|
|
124
147
|
return await accountObject.createMailbox(request.payload.path);
|
|
125
148
|
} catch (err) {
|
|
126
|
-
|
|
127
|
-
if (Boom.isBoom(err)) {
|
|
128
|
-
throw err;
|
|
129
|
-
}
|
|
130
|
-
let error = Boom.boomify(err, { statusCode: err.statusCode || 500 });
|
|
131
|
-
if (err.code) {
|
|
132
|
-
error.output.payload.code = err.code;
|
|
133
|
-
}
|
|
134
|
-
if (err.info) {
|
|
135
|
-
error.output.payload.details = err.info;
|
|
136
|
-
}
|
|
137
|
-
throw error;
|
|
149
|
+
throwMailboxError(request, err);
|
|
138
150
|
}
|
|
139
151
|
},
|
|
140
152
|
|
|
@@ -204,18 +216,7 @@ async function init(args) {
|
|
|
204
216
|
try {
|
|
205
217
|
return await accountObject.modifyMailbox(request.payload.path, request.payload.newPath, request.payload.subscribed);
|
|
206
218
|
} catch (err) {
|
|
207
|
-
|
|
208
|
-
if (Boom.isBoom(err)) {
|
|
209
|
-
throw err;
|
|
210
|
-
}
|
|
211
|
-
let error = Boom.boomify(err, { statusCode: err.statusCode || 500 });
|
|
212
|
-
if (err.code) {
|
|
213
|
-
error.output.payload.code = err.code;
|
|
214
|
-
}
|
|
215
|
-
if (err.info) {
|
|
216
|
-
error.output.payload.details = err.info;
|
|
217
|
-
}
|
|
218
|
-
throw error;
|
|
219
|
+
throwMailboxError(request, err);
|
|
219
220
|
}
|
|
220
221
|
},
|
|
221
222
|
|
|
@@ -258,7 +259,8 @@ async function init(args) {
|
|
|
258
259
|
.label('TargetMailboxPath'),
|
|
259
260
|
subscribed: Joi.boolean()
|
|
260
261
|
.example(true)
|
|
261
|
-
.description('Change mailbox subscription status
|
|
262
|
+
.description('Change mailbox subscription status')
|
|
263
|
+
.meta({ usage: FIELD_USAGE.mailboxSubscribed })
|
|
262
264
|
.label('SubscriptionStatus')
|
|
263
265
|
})
|
|
264
266
|
.or('newPath', 'subscribed')
|
|
@@ -308,6 +310,7 @@ async function init(args) {
|
|
|
308
310
|
|
|
309
311
|
plugins: {
|
|
310
312
|
openapi: {
|
|
313
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
311
314
|
responses: apiResponses('Returns the deleted folder path.', 400, 401, 403, 404, 429, 500, 503)
|
|
312
315
|
}
|
|
313
316
|
},
|
|
@@ -6,9 +6,10 @@ const getSecret = require('../get-secret');
|
|
|
6
6
|
const settings = require('../settings');
|
|
7
7
|
const Joi = require('joi');
|
|
8
8
|
const { failAction } = require('../tools');
|
|
9
|
-
const { COLLAPSE_CLASS } = require('../consts');
|
|
10
9
|
const { handleError } = require('./route-helpers');
|
|
11
10
|
const BEHAVIOR = require('./behavior-notes');
|
|
11
|
+
const { IMPACT } = require('./operation-impact');
|
|
12
|
+
const { FIELD_USAGE } = require('../field-usage');
|
|
12
13
|
|
|
13
14
|
const {
|
|
14
15
|
accountIdSchema,
|
|
@@ -31,11 +32,19 @@ const {
|
|
|
31
32
|
const listMessageFolderPathDescription =
|
|
32
33
|
'Mailbox folder path. Can use special use labels like "\\Sent". Special value "\\All" is available for Gmail IMAP, Gmail API, MS Graph API accounts.';
|
|
33
34
|
|
|
35
|
+
// One entry of the array branch below. The operation's own example is a boolean for flags,
|
|
36
|
+
// so the array branch has nothing to inherit from and its entries used to document
|
|
37
|
+
// themselves as "string" - see the example coverage assertion in test/api-reference-test.js.
|
|
38
|
+
const UPDATE_OP_ENTRY_EXAMPLE = {
|
|
39
|
+
flags: '\\Seen',
|
|
40
|
+
labels: 'Label_971539351003152516'
|
|
41
|
+
};
|
|
42
|
+
|
|
34
43
|
// Response field for a flag or label update operation. IMAP accounts return a boolean (whether
|
|
35
44
|
// the operation succeeded), API-based accounts echo the requested values as an array.
|
|
36
45
|
const updateOpResultSchema = (op, noun, entryLabel, example, label) =>
|
|
37
46
|
Joi.alternatives()
|
|
38
|
-
.try(Joi.boolean(), Joi.array().items(Joi.string().label(entryLabel)))
|
|
47
|
+
.try(Joi.boolean(), Joi.array().items(Joi.string().label(entryLabel).example(UPDATE_OP_ENTRY_EXAMPLE[noun])))
|
|
39
48
|
.example(example)
|
|
40
49
|
.description(`Did the ${op} operation succeed (boolean, IMAP accounts) or the requested ${noun} (array, API-based accounts)`)
|
|
41
50
|
.label(label);
|
|
@@ -179,10 +188,8 @@ async function init(args) {
|
|
|
179
188
|
.truthy('Y', 'true', '1')
|
|
180
189
|
.falsy('N', 'false', 0)
|
|
181
190
|
.default(false)
|
|
182
|
-
.description(
|
|
183
|
-
|
|
184
|
-
`Quoted thread history is folded into a single collapsed <details class="${COLLAPSE_CLASS}"> element.`
|
|
185
|
-
)
|
|
191
|
+
.description('Shorthand option to fetch and preprocess HTML and inline images')
|
|
192
|
+
.meta({ usage: FIELD_USAGE.webSafeHtml })
|
|
186
193
|
.label('WebSafeHtml'),
|
|
187
194
|
|
|
188
195
|
embedAttachedImages: Joi.boolean()
|
|
@@ -289,9 +296,8 @@ async function init(args) {
|
|
|
289
296
|
.base64()
|
|
290
297
|
.max(MAX_ATTACHMENT_SIZE)
|
|
291
298
|
.example('TUlNRS1WZXJzaW9uOiAxLjANClN1YmplY3Q6IGhlbGxvIHdvcmxkDQoNCkhlbGxvIQ0K')
|
|
292
|
-
.description(
|
|
293
|
-
|
|
294
|
-
)
|
|
299
|
+
.description('A Base64-encoded email message in RFC 822 format')
|
|
300
|
+
.meta({ usage: FIELD_USAGE.messageRaw })
|
|
295
301
|
.label('RFC822Raw'),
|
|
296
302
|
|
|
297
303
|
from: fromAddressSchema,
|
|
@@ -347,9 +353,8 @@ async function init(args) {
|
|
|
347
353
|
.max(256)
|
|
348
354
|
.allow(false, null)
|
|
349
355
|
.example('AAAAAQAACnAcde')
|
|
350
|
-
.description(
|
|
351
|
-
|
|
352
|
-
)
|
|
356
|
+
.description('References an existing attachment by its ID instead of providing new attachment content')
|
|
357
|
+
.meta({ usage: FIELD_USAGE.attachmentReference })
|
|
353
358
|
.label('MsgUploadReference')
|
|
354
359
|
}).label('UploadAttachment')
|
|
355
360
|
)
|
|
@@ -747,6 +752,7 @@ async function init(args) {
|
|
|
747
752
|
|
|
748
753
|
plugins: {
|
|
749
754
|
openapi: {
|
|
755
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
750
756
|
'x-ee-behavior': [BEHAVIOR.GMAIL_DELETE_IS_TRASH],
|
|
751
757
|
responses: apiResponses('Returns whether the message was moved to Trash or permanently deleted.', 400, 401, 403, 404, 429, 500, 503)
|
|
752
758
|
}
|
|
@@ -832,6 +838,7 @@ async function init(args) {
|
|
|
832
838
|
|
|
833
839
|
plugins: {
|
|
834
840
|
openapi: {
|
|
841
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
835
842
|
'x-ee-behavior': [BEHAVIOR.GMAIL_DELETE_IS_TRASH],
|
|
836
843
|
responses: apiResponses('Returns the number of messages deleted.', 400, 401, 403, 404, 429, 500, 503)
|
|
837
844
|
}
|
|
@@ -971,9 +978,8 @@ async function init(args) {
|
|
|
971
978
|
.max(1024 * 1024)
|
|
972
979
|
.default(0)
|
|
973
980
|
.example(0)
|
|
974
|
-
.description(
|
|
975
|
-
|
|
976
|
-
)
|
|
981
|
+
.description('Page number (zero-indexed, so use 0 for the first page). Only supported for IMAP accounts')
|
|
982
|
+
.meta({ usage: FIELD_USAGE.messagePage })
|
|
977
983
|
.label('PageNumber'),
|
|
978
984
|
|
|
979
985
|
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize'),
|
|
@@ -1038,6 +1044,7 @@ async function init(args) {
|
|
|
1038
1044
|
|
|
1039
1045
|
plugins: {
|
|
1040
1046
|
openapi: {
|
|
1047
|
+
'x-ee-impact': IMPACT.READONLY,
|
|
1041
1048
|
responses: apiResponses('Returns a page of matching messages, newest first.', 400, 401, 403, 404, 422, 429, 500, 503)
|
|
1042
1049
|
}
|
|
1043
1050
|
},
|
|
@@ -1084,9 +1091,8 @@ async function init(args) {
|
|
|
1084
1091
|
.max(1024 * 1024)
|
|
1085
1092
|
.default(0)
|
|
1086
1093
|
.example(0)
|
|
1087
|
-
.description(
|
|
1088
|
-
|
|
1089
|
-
)
|
|
1094
|
+
.description('Page number (zero-indexed, so use 0 for the first page). Only supported for IMAP accounts')
|
|
1095
|
+
.meta({ usage: FIELD_USAGE.messagePage })
|
|
1090
1096
|
.label('PageNumber'),
|
|
1091
1097
|
|
|
1092
1098
|
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page'),
|
|
@@ -1094,9 +1100,8 @@ async function init(args) {
|
|
|
1094
1100
|
useOutlookSearch: Joi.boolean()
|
|
1095
1101
|
.truthy('Y', 'true', '1')
|
|
1096
1102
|
.falsy('N', 'false', 0)
|
|
1097
|
-
.description(
|
|
1098
|
-
|
|
1099
|
-
)
|
|
1103
|
+
.description('MS Graph only. Use the $search parameter for search queries instead of $filter')
|
|
1104
|
+
.meta({ usage: FIELD_USAGE.useOutlookSearch })
|
|
1100
1105
|
.label('useOutlookSearch')
|
|
1101
1106
|
.optional(),
|
|
1102
1107
|
|
|
@@ -1205,6 +1210,7 @@ async function init(args) {
|
|
|
1205
1210
|
|
|
1206
1211
|
plugins: {
|
|
1207
1212
|
openapi: {
|
|
1213
|
+
'x-ee-impact': IMPACT.READONLY,
|
|
1208
1214
|
responses: apiResponses('Returns matching messages across all indexed accounts.', 400, 401, 403, 429, 500)
|
|
1209
1215
|
}
|
|
1210
1216
|
},
|
|
@@ -15,8 +15,9 @@ const {
|
|
|
15
15
|
apiResponses,
|
|
16
16
|
ENUM_DESCRIPTIONS
|
|
17
17
|
} = require('../schemas');
|
|
18
|
-
const { handleError, throwNotFound, flattenOAuthAppMeta } = require('./route-helpers');
|
|
18
|
+
const { handleError, throwNotFound, flattenOAuthAppMeta, MASKED } = require('./route-helpers');
|
|
19
19
|
const { ENCRYPTED_APP_KEYS } = require('../consts');
|
|
20
|
+
const { IMPACT } = require('./operation-impact');
|
|
20
21
|
|
|
21
22
|
// Stored fields that are returned on OAuth2 application objects in addition to the basic fields
|
|
22
23
|
const oauth2AppExtraFields = {
|
|
@@ -73,7 +74,7 @@ async function init(args) {
|
|
|
73
74
|
for (let app of response.apps) {
|
|
74
75
|
for (let secretKey of ENCRYPTED_APP_KEYS) {
|
|
75
76
|
if (app[secretKey]) {
|
|
76
|
-
app[secretKey] =
|
|
77
|
+
app[secretKey] = MASKED;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -152,15 +153,7 @@ async function init(args) {
|
|
|
152
153
|
.example(true)
|
|
153
154
|
.description('Is the application enabled')
|
|
154
155
|
.label('AppEnabled'),
|
|
155
|
-
|
|
156
|
-
.truthy('Y', 'true', '1', 'on')
|
|
157
|
-
.falsy('N', 'false', 0, '')
|
|
158
|
-
.example(true)
|
|
159
|
-
.description('`true` for older OAuth2 apps set via the settings endpoint'),
|
|
160
|
-
created: Joi.date()
|
|
161
|
-
.iso()
|
|
162
|
-
.example('2021-02-17T13:43:18.860Z')
|
|
163
|
-
.description('The time this entry was added. Not present for legacy apps'),
|
|
156
|
+
created: Joi.date().iso().example('2021-02-17T13:43:18.860Z').description('The time this entry was added'),
|
|
164
157
|
updated: Joi.date().iso().example('2021-02-17T13:43:18.860Z').description('The time this entry was updated'),
|
|
165
158
|
includeInListing: Joi.boolean()
|
|
166
159
|
.truthy('Y', 'true', '1', 'on')
|
|
@@ -231,7 +224,7 @@ async function init(args) {
|
|
|
231
224
|
// remove secrets
|
|
232
225
|
for (let secretKey of ENCRYPTED_APP_KEYS) {
|
|
233
226
|
if (app[secretKey]) {
|
|
234
|
-
app[secretKey] =
|
|
227
|
+
app[secretKey] = MASKED;
|
|
235
228
|
}
|
|
236
229
|
}
|
|
237
230
|
|
|
@@ -293,12 +286,7 @@ async function init(args) {
|
|
|
293
286
|
.example(true)
|
|
294
287
|
.description('Is the application enabled')
|
|
295
288
|
.label('AppEnabled'),
|
|
296
|
-
|
|
297
|
-
.truthy('Y', 'true', '1', 'on')
|
|
298
|
-
.falsy('N', 'false', 0, '')
|
|
299
|
-
.example(true)
|
|
300
|
-
.description('`true` for older OAuth2 apps set via the settings endpoint'),
|
|
301
|
-
created: Joi.date().iso().example('2021-02-17T13:43:18.860Z').description('The time this entry was added. Not present for legacy apps'),
|
|
289
|
+
created: Joi.date().iso().example('2021-02-17T13:43:18.860Z').description('The time this entry was added'),
|
|
302
290
|
updated: Joi.date().iso().example('2021-02-17T13:43:18.860Z').description('The time this entry was updated'),
|
|
303
291
|
includeInListing: Joi.boolean()
|
|
304
292
|
.truthy('Y', 'true', '1', 'on')
|
|
@@ -340,10 +328,7 @@ async function init(args) {
|
|
|
340
328
|
.example('******')
|
|
341
329
|
.description('PEM formatted service secret for 2-legged OAuth2 applications. Actual value is not revealed.'),
|
|
342
330
|
|
|
343
|
-
accounts: Joi.number()
|
|
344
|
-
.integer()
|
|
345
|
-
.example(12)
|
|
346
|
-
.description('The number of accounts registered with this application. Not available for legacy apps.'),
|
|
331
|
+
accounts: Joi.number().integer().example(12).description('The number of accounts registered with this application'),
|
|
347
332
|
|
|
348
333
|
...oauth2AppExtraFields,
|
|
349
334
|
|
|
@@ -543,8 +528,7 @@ async function init(args) {
|
|
|
543
528
|
response: {
|
|
544
529
|
schema: Joi.object({
|
|
545
530
|
id: Joi.string().max(256).required().example('example').description('OAuth2 app ID'),
|
|
546
|
-
updated: Joi.boolean().example(true).description('Was the application updated')
|
|
547
|
-
legacy: Joi.boolean().example(false).description('`true` for older OAuth2 apps set via the settings endpoint')
|
|
531
|
+
updated: Joi.boolean().example(true).description('Was the application updated')
|
|
548
532
|
}).label('UpdateOAuthAppResponse'),
|
|
549
533
|
failAction: 'log'
|
|
550
534
|
}
|
|
@@ -577,6 +561,7 @@ async function init(args) {
|
|
|
577
561
|
|
|
578
562
|
plugins: {
|
|
579
563
|
openapi: {
|
|
564
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
580
565
|
responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
|
|
581
566
|
}
|
|
582
567
|
},
|
|
@@ -604,11 +589,7 @@ async function init(args) {
|
|
|
604
589
|
schema: Joi.object({
|
|
605
590
|
id: Joi.string().max(256).required().example('AAABhaBPHscAAAAH').description('OAuth2 application ID'),
|
|
606
591
|
deleted: Joi.boolean().truthy('Y', 'true', '1').falsy('N', 'false', 0).default(true).description('Was the OAuth2 application deleted'),
|
|
607
|
-
|
|
608
|
-
accounts: Joi.number()
|
|
609
|
-
.integer()
|
|
610
|
-
.example(12)
|
|
611
|
-
.description('The number of accounts registered with this application. Not available for legacy apps.')
|
|
592
|
+
accounts: Joi.number().integer().example(12).description('The number of accounts registered with this application')
|
|
612
593
|
}).label('DeleteAppRequestResponse'),
|
|
613
594
|
failAction: 'log'
|
|
614
595
|
}
|
|
@@ -636,6 +617,7 @@ async function init(args) {
|
|
|
636
617
|
|
|
637
618
|
plugins: {
|
|
638
619
|
openapi: {
|
|
620
|
+
'x-ee-impact': IMPACT.READONLY,
|
|
639
621
|
responses: apiResponses('Returns the outcome of the credential check against the provider.', 400, 401, 403, 404, 429, 500)
|
|
640
622
|
}
|
|
641
623
|
},
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// What running an operation actually does to the instance. Declared per route under
|
|
4
|
+
// `plugins.openapi['x-ee-impact']`, which the generator publishes verbatim (see
|
|
5
|
+
// assignVendorExtensions in lib/openapi/build-document.js), so the classification reaches every
|
|
6
|
+
// consumer of /swagger.json and not just the admin UI.
|
|
7
|
+
//
|
|
8
|
+
// It exists because the Try it panel used to carry the same warning on all 82 operations -
|
|
9
|
+
// including 42 that only read - which is how a warning teaches readers to skim past it. The
|
|
10
|
+
// weight of the warning now tracks the consequence: nothing on a read, a muted line on an
|
|
11
|
+
// ordinary write, and a real warning on the operations that destroy data or send mail.
|
|
12
|
+
//
|
|
13
|
+
// Only the exceptions are declared. resolveImpact() derives the default from the HTTP method, so
|
|
14
|
+
// a plain GET needs nothing and a POST that writes needs nothing. Declare an impact when the
|
|
15
|
+
// method is a bad proxy for the effect, which is both directions here:
|
|
16
|
+
// `POST /v1/unified/search` only reads, and `PUT /v1/account/{account}/messages/delete`
|
|
17
|
+
// deletes in bulk.
|
|
18
|
+
//
|
|
19
|
+
// The derivation lives here rather than in the one place that reads it today because it is about
|
|
20
|
+
// to have a second reader. lib/api-reference/model.js weights the Try it warning by it; the token
|
|
21
|
+
// permission model narrows on the same value. A route classified one way for the warning banner
|
|
22
|
+
// and another way for access control is a divergence nothing would catch, so both call this.
|
|
23
|
+
const IMPACT = {
|
|
24
|
+
// Removes data, or discards state that cannot be recovered from EmailEngine
|
|
25
|
+
DESTRUCTIVE: 'destructive',
|
|
26
|
+
|
|
27
|
+
// Hands a message to a mail server. Whatever else happens, mail leaves the instance and
|
|
28
|
+
// reaches real recipients - the one Try it consequence that is not undoable from here.
|
|
29
|
+
SENDS: 'sends',
|
|
30
|
+
|
|
31
|
+
// Reads only, despite not being a GET
|
|
32
|
+
READONLY: 'readonly',
|
|
33
|
+
|
|
34
|
+
// What an undeclared non-GET resolves to. Derived rather than declared, so it is absent from
|
|
35
|
+
// DECLARABLE below, but the consumers that switch on an impact still need a name for it.
|
|
36
|
+
WRITE: 'write'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// What a route may put in `x-ee-impact`. WRITE is deliberately excluded: it is the default, so
|
|
40
|
+
// declaring it says nothing, and treating it as valid input would mean two spellings of the same
|
|
41
|
+
// classification. Exported because test/api-reference-test.js asserts what the routes declare and
|
|
42
|
+
// has no business keeping its own copy of the vocabulary.
|
|
43
|
+
const DECLARABLE_IMPACTS = new Set([IMPACT.DESTRUCTIVE, IMPACT.SENDS, IMPACT.READONLY]);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resolves an operation's impact from what it declares plus its HTTP method.
|
|
47
|
+
*
|
|
48
|
+
* Returns null when `declared` is not a declarable impact. That is a typo in a route definition
|
|
49
|
+
* rather than a fourth kind of impact, and guessing would hide it: a route meaning `destructive`
|
|
50
|
+
* but spelling it `deletes` would silently resolve to the method default and lose its warning.
|
|
51
|
+
* Callers decide what null means for them - the reference page renders no warning, which is what
|
|
52
|
+
* it did before this function existed.
|
|
53
|
+
*
|
|
54
|
+
* @param {String} [declared] - the route's `x-ee-impact`, if it sets one
|
|
55
|
+
* @param {String} method - HTTP method, in any case
|
|
56
|
+
* @returns {String|null} one of IMPACT, or null when `declared` is not declarable
|
|
57
|
+
*/
|
|
58
|
+
function resolveImpact(declared, method) {
|
|
59
|
+
if (declared) {
|
|
60
|
+
return DECLARABLE_IMPACTS.has(declared) ? declared : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
switch (String(method).toLowerCase()) {
|
|
64
|
+
case 'get':
|
|
65
|
+
return IMPACT.READONLY;
|
|
66
|
+
|
|
67
|
+
// A DELETE removes something. Defaulting it to WRITE made `destructive` opt-in, which is
|
|
68
|
+
// fail-open now that a token can be narrowed to "write but not destructive": a new DELETE
|
|
69
|
+
// that forgot its declaration would resolve to WRITE and be callable by a token explicitly
|
|
70
|
+
// issued without destructive rights. Every DELETE today declares IMPACT.DESTRUCTIVE, so
|
|
71
|
+
// this changes no current classification - it removes the way the next one could go wrong.
|
|
72
|
+
case 'delete':
|
|
73
|
+
return IMPACT.DESTRUCTIVE;
|
|
74
|
+
|
|
75
|
+
default:
|
|
76
|
+
return IMPACT.WRITE;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = { IMPACT, DECLARABLE_IMPACTS, resolveImpact };
|
|
@@ -5,8 +5,9 @@ const Joi = require('joi');
|
|
|
5
5
|
const logger = require('../logger');
|
|
6
6
|
const outbox = require('../outbox');
|
|
7
7
|
const { failAction } = require('../tools');
|
|
8
|
-
const { handleError } = require('./route-helpers');
|
|
8
|
+
const { handleError, maskSecrets, MASK_NOTE } = require('./route-helpers');
|
|
9
9
|
const { outboxEntrySchema, apiResponses } = require('../schemas');
|
|
10
|
+
const { IMPACT } = require('./operation-impact');
|
|
10
11
|
|
|
11
12
|
async function init(args) {
|
|
12
13
|
const { server, CORS_CONFIG } = args;
|
|
@@ -17,7 +18,15 @@ async function init(args) {
|
|
|
17
18
|
|
|
18
19
|
async handler(request) {
|
|
19
20
|
try {
|
|
20
|
-
|
|
21
|
+
const listing = await outbox.list(Object.assign({ logger }, request.query));
|
|
22
|
+
|
|
23
|
+
// A queue entry carries the proxy the submission was told to use, and a failed one
|
|
24
|
+
// also records the route it took under progress.error.networkRouting
|
|
25
|
+
for (const entry of listing.messages || []) {
|
|
26
|
+
maskSecrets(entry);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return listing;
|
|
21
30
|
} catch (err) {
|
|
22
31
|
handleError(request, err);
|
|
23
32
|
}
|
|
@@ -25,7 +34,7 @@ async function init(args) {
|
|
|
25
34
|
|
|
26
35
|
options: {
|
|
27
36
|
description: 'List queued messages',
|
|
28
|
-
notes:
|
|
37
|
+
notes: `Lists messages in the Outbox. ${MASK_NOTE}`,
|
|
29
38
|
tags: ['api', 'Outbox'],
|
|
30
39
|
|
|
31
40
|
plugins: {
|
|
@@ -86,7 +95,7 @@ async function init(args) {
|
|
|
86
95
|
let error = Boom.boomify(new Error(message), { statusCode: 404 });
|
|
87
96
|
throw error;
|
|
88
97
|
}
|
|
89
|
-
return outboxEntry;
|
|
98
|
+
return maskSecrets(outboxEntry);
|
|
90
99
|
} catch (err) {
|
|
91
100
|
handleError(request, err);
|
|
92
101
|
}
|
|
@@ -94,7 +103,7 @@ async function init(args) {
|
|
|
94
103
|
|
|
95
104
|
options: {
|
|
96
105
|
description: 'Get queued message',
|
|
97
|
-
notes:
|
|
106
|
+
notes: `Gets a queued message in the Outbox. ${MASK_NOTE}`,
|
|
98
107
|
tags: ['api', 'Outbox'],
|
|
99
108
|
|
|
100
109
|
plugins: {
|
|
@@ -149,6 +158,7 @@ async function init(args) {
|
|
|
149
158
|
|
|
150
159
|
plugins: {
|
|
151
160
|
openapi: {
|
|
161
|
+
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
152
162
|
responses: apiResponses('Returns a deletion marker. A message already being delivered cannot be removed.', 400, 401, 403, 429, 500)
|
|
153
163
|
}
|
|
154
164
|
},
|