emailengine-app 2.84.2 → 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 +29 -9
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +107 -0
- package/Dockerfile +20 -1
- package/ENVIRONMENT.md +139 -0
- package/README.md +2 -2
- package/bin/emailengine.js +434 -408
- package/config/default.toml +2 -0
- package/copy-static-files.sh +41 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16563 -0
- package/eslint.config.js +81 -99
- package/lib/account-assignment.js +19 -0
- package/lib/account.js +230 -170
- package/lib/api-error-codes.js +49 -0
- package/lib/api-reference/format.js +4 -3
- package/lib/api-reference/model.js +6 -1
- package/lib/api-routes/account-routes.js +255 -38
- package/lib/api-routes/blocklist-routes.js +91 -4
- package/lib/api-routes/delivery-test-routes.js +27 -4
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +110 -12
- package/lib/api-routes/index.js +4 -0
- package/lib/api-routes/license-routes.js +2 -2
- package/lib/api-routes/mailbox-routes.js +44 -5
- package/lib/api-routes/message-routes.js +112 -10
- package/lib/api-routes/oauth2-app-routes.js +63 -23
- package/lib/api-routes/outbox-routes.js +97 -52
- package/lib/api-routes/permission-map.js +67 -7
- package/lib/api-routes/scoped-routes.js +74 -0
- package/lib/api-routes/settings-routes.js +34 -6
- package/lib/api-routes/stats-routes.js +5 -1
- package/lib/api-routes/submit-routes.js +337 -309
- package/lib/api-routes/template-routes.js +45 -8
- package/lib/api-routes/token-routes.js +152 -100
- package/lib/api-routes/webhook-delivery-routes.js +262 -0
- package/lib/api-routes/webhook-route-routes.js +132 -6
- package/lib/bounce-detect.js +397 -205
- package/lib/calendar-event.js +81 -1
- package/lib/consts.js +38 -45
- 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 +137 -184
- package/lib/email-client/fallback-poll.js +62 -0
- package/lib/email-client/gmail-client.js +60 -22
- 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 -242
- package/lib/email-client/imap/subconnection.js +8 -30
- package/lib/email-client/imap/sync-operations.js +220 -127
- package/lib/email-client/imap-client.js +228 -164
- package/lib/email-client/message-builder.js +14 -79
- package/lib/email-client/notification-handler.js +1 -2
- 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 +19 -4
- package/lib/get-raw-email.js +25 -107
- package/lib/hapi-request-logger.js +107 -0
- package/lib/health.js +75 -0
- package/lib/imapproxy/imap-core/README.md +6 -5
- 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/mcp/tools.js +37 -8
- package/lib/network-errors.js +1 -1
- package/lib/node-version.js +24 -0
- package/lib/notify-attachments.js +36 -0
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +631 -656
- package/lib/outbox.js +184 -54
- package/lib/parse-message.js +3 -3
- package/lib/pbkdf2-phc.js +1 -1
- 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 +164 -40
- package/lib/settings.js +6 -2
- package/lib/smtp-auth.js +19 -1
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +63 -0
- package/lib/timezones.js +109 -0
- package/lib/tls/provision.js +6 -3
- package/lib/token-audit-log.js +19 -20
- package/lib/token-permission-view.js +7 -6
- package/lib/tools.js +48 -51
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +475 -454
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +152 -100
- package/lib/ui-routes/admin-entities-routes.js +93 -21
- package/lib/ui-routes/auth-routes.js +90 -38
- package/lib/ui-routes/imap-idle-field.js +1 -1
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/oauth-config-routes.js +124 -82
- 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/route-helpers.js +19 -3
- package/lib/ui-routes/settings-page.js +6 -0
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/utils/back-off.js +82 -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/murmurhash3.js +66 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/tracking-settings.js +35 -0
- package/lib/utils/version.js +74 -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 +56 -0
- package/lib/webhook-test.js +88 -0
- package/lib/webhooks.js +93 -45
- package/lib/worker-rpc-error.js +2 -1
- package/package.json +37 -38
- package/sbom.json +7902 -1
- package/server.js +784 -518
- package/static/js/ace/ace.js +1 -1
- package/static/licenses.html +225 -1060
- package/translations/messages.pot +62 -63
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +24 -2
- package/views/config/service.hbs +47 -0
- package/views/config/webhooks.hbs +36 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/queue_retention_note.hbs +12 -8
- package/views/partials/ui/env-managed-alert.hbs +16 -7
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +840 -611
- package/workers/export.js +17 -632
- package/workers/imap.js +13 -0
- package/workers/smtp.js +9 -11
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +18 -448
- package/lib/email-client/outlook-fallback-poll.js +0 -30
|
@@ -96,8 +96,8 @@ const idMapSchema = Joi.array()
|
|
|
96
96
|
.description('An optional map of source and target ID values, if the server provided this info (IMAP accounts only)')
|
|
97
97
|
.label('IdMapArray');
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
const {
|
|
99
|
+
function registerGetMessageSource(server, args) {
|
|
100
|
+
const { call, CORS_CONFIG } = args;
|
|
101
101
|
|
|
102
102
|
// GET /v1/account/{account}/message/{message}/source - Download raw message
|
|
103
103
|
server.route({
|
|
@@ -122,7 +122,7 @@ async function init(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 @@ async function init(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)
|
|
@@ -153,6 +161,10 @@ async function init(args) {
|
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
163
|
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function registerGetMessage(server, args) {
|
|
167
|
+
const { call, CORS_CONFIG } = args;
|
|
156
168
|
|
|
157
169
|
// GET /v1/account/{account}/message/{message} - Get message information
|
|
158
170
|
server.route({
|
|
@@ -284,6 +296,10 @@ async function init(args) {
|
|
|
284
296
|
}
|
|
285
297
|
}
|
|
286
298
|
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function registerUploadMessage(server, args) {
|
|
302
|
+
const { call, CORS_CONFIG, MAX_ATTACHMENT_SIZE, MAX_BODY_SIZE, MAX_PAYLOAD_TIMEOUT } = args;
|
|
287
303
|
|
|
288
304
|
// POST /v1/account/{account}/message - Upload message
|
|
289
305
|
server.route({
|
|
@@ -326,7 +342,7 @@ async function init(args) {
|
|
|
326
342
|
description:
|
|
327
343
|
'Store a new message in a folder, typically a draft in the Drafts folder. Takes structured fields (from, to, subject, text, html). ' +
|
|
328
344
|
'It takes the same `reference` block as send_message, so a reply or a forward can be drafted for the user to look over first. ' +
|
|
329
|
-
'Nothing is sent
|
|
345
|
+
'Nothing is sent: once the user has reviewed the draft, send_draft sends it by the id this returns. send_message sends a new message directly.',
|
|
330
346
|
// An allowlist for the same reason send_message uses one: the composed message
|
|
331
347
|
// is a small stable set, the route's payload is not, and a field added later
|
|
332
348
|
// should not join an agent-facing schema by default. Left out are `raw` (which
|
|
@@ -382,11 +398,11 @@ async function init(args) {
|
|
|
382
398
|
.single()
|
|
383
399
|
.description('List of addresses')
|
|
384
400
|
.example([{ address: 'recipient@example.com' }])
|
|
385
|
-
.label('
|
|
401
|
+
.label('UploadToAddressList'),
|
|
386
402
|
|
|
387
|
-
cc: Joi.array().items(addressSchema).single().description('List of addresses').label('
|
|
403
|
+
cc: Joi.array().items(addressSchema).single().description('List of addresses').label('UploadAddressList'),
|
|
388
404
|
|
|
389
|
-
bcc: Joi.array().items(addressSchema).single().description('List of addresses').label('
|
|
405
|
+
bcc: Joi.array().items(addressSchema).single().description('List of addresses').label('UploadAddressList'),
|
|
390
406
|
|
|
391
407
|
subject: Joi.string()
|
|
392
408
|
.allow('')
|
|
@@ -481,6 +497,10 @@ async function init(args) {
|
|
|
481
497
|
}
|
|
482
498
|
}
|
|
483
499
|
});
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function registerUpdateMessage(server, args) {
|
|
503
|
+
const { call, CORS_CONFIG } = args;
|
|
484
504
|
|
|
485
505
|
// PUT /v1/account/{account}/message/{message} - Update message
|
|
486
506
|
server.route({
|
|
@@ -567,6 +587,10 @@ async function init(args) {
|
|
|
567
587
|
}
|
|
568
588
|
}
|
|
569
589
|
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function registerUpdateMessages(server, args) {
|
|
593
|
+
const { call, CORS_CONFIG } = args;
|
|
570
594
|
|
|
571
595
|
// PUT /v1/account/{account}/messages - Update multiple messages
|
|
572
596
|
server.route({
|
|
@@ -594,6 +618,14 @@ async function init(args) {
|
|
|
594
618
|
tags: ['api', 'Multi Message Actions'],
|
|
595
619
|
|
|
596
620
|
plugins: {
|
|
621
|
+
mcp: {
|
|
622
|
+
name: 'update_messages',
|
|
623
|
+
title: 'Update matching messages',
|
|
624
|
+
description:
|
|
625
|
+
'Change the flags or labels of every message in one folder that matches a search, in one call - for example mark all unread mail from one sender as read. ' +
|
|
626
|
+
'Run search_messages with the same folder and criteria first to see which messages match, then pass those criteria here. ' +
|
|
627
|
+
'For one message, or a few whose ids are known, use update_message instead.'
|
|
628
|
+
},
|
|
597
629
|
openapi: {
|
|
598
630
|
'x-ee-behavior': [BEHAVIOR.NO_LABEL_SET_ON_GMAIL],
|
|
599
631
|
responses: apiResponses('Returns which flag and label changes were applied to the matching messages.', 400, 401, 403, 404, 429, 500, 503)
|
|
@@ -649,6 +681,10 @@ async function init(args) {
|
|
|
649
681
|
}
|
|
650
682
|
}
|
|
651
683
|
});
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function registerMoveMessage(server, args) {
|
|
687
|
+
const { call, CORS_CONFIG } = args;
|
|
652
688
|
|
|
653
689
|
// PUT /v1/account/{account}/message/{message}/move - Move a message
|
|
654
690
|
server.route({
|
|
@@ -676,7 +712,7 @@ async function init(args) {
|
|
|
676
712
|
},
|
|
677
713
|
options: {
|
|
678
714
|
description: 'Move a message to a specified folder',
|
|
679
|
-
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.',
|
|
680
716
|
tags: ['api', 'Message'],
|
|
681
717
|
|
|
682
718
|
plugins: {
|
|
@@ -732,6 +768,10 @@ async function init(args) {
|
|
|
732
768
|
}
|
|
733
769
|
}
|
|
734
770
|
});
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function registerMoveMessages(server, args) {
|
|
774
|
+
const { call, CORS_CONFIG } = args;
|
|
735
775
|
|
|
736
776
|
// PUT /v1/account/{account}/messages/move - Move multiple messages
|
|
737
777
|
server.route({
|
|
@@ -759,6 +799,18 @@ async function init(args) {
|
|
|
759
799
|
tags: ['api', 'Multi Message Actions'],
|
|
760
800
|
|
|
761
801
|
plugins: {
|
|
802
|
+
mcp: {
|
|
803
|
+
name: 'move_messages',
|
|
804
|
+
title: 'Move matching messages',
|
|
805
|
+
description:
|
|
806
|
+
'Move every message in one folder that matches a search to another folder, in one call. `source` is the folder searched and `path` the folder the messages go to, both paths from list_mailboxes. ' +
|
|
807
|
+
'Run search_messages on the source folder with the same criteria first to see which messages match, then pass those criteria here. ' +
|
|
808
|
+
'For one message, or a few whose ids are known, use move_message instead.',
|
|
809
|
+
// The route reads the folder to search from the query and the target from the
|
|
810
|
+
// payload, both as `path`. The target keeps the name move_message gives it, and
|
|
811
|
+
// the folder searched takes the name move_message gives its own source folder.
|
|
812
|
+
rename: { query: { path: 'source' } }
|
|
813
|
+
},
|
|
762
814
|
openapi: {
|
|
763
815
|
responses: apiResponses('Returns the number of messages moved.', 400, 401, 403, 404, 429, 500, 503)
|
|
764
816
|
}
|
|
@@ -811,6 +863,10 @@ async function init(args) {
|
|
|
811
863
|
}
|
|
812
864
|
}
|
|
813
865
|
});
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
function registerDeleteMessage(server, args) {
|
|
869
|
+
const { call, CORS_CONFIG } = args;
|
|
814
870
|
|
|
815
871
|
// DELETE /v1/account/{account}/message/{message} - Delete message
|
|
816
872
|
server.route({
|
|
@@ -900,6 +956,10 @@ async function init(args) {
|
|
|
900
956
|
}
|
|
901
957
|
}
|
|
902
958
|
});
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function registerDeleteMessages(server, args) {
|
|
962
|
+
const { call, CORS_CONFIG } = args;
|
|
903
963
|
|
|
904
964
|
// PUT /v1/account/{account}/messages/delete - Delete multiple messages
|
|
905
965
|
server.route({
|
|
@@ -927,6 +987,14 @@ async function init(args) {
|
|
|
927
987
|
tags: ['api', 'Multi Message Actions'],
|
|
928
988
|
|
|
929
989
|
plugins: {
|
|
990
|
+
mcp: {
|
|
991
|
+
name: 'delete_messages',
|
|
992
|
+
title: 'Delete matching messages',
|
|
993
|
+
description:
|
|
994
|
+
'Delete every message in one folder that matches a search, in one call - confirm with the user before calling this. Messages are moved to Trash, and deleted permanently when the folder already is Trash. ' +
|
|
995
|
+
'Run search_messages with the same folder and criteria first to see which messages match, and pass exactly those criteria here. ' +
|
|
996
|
+
'For one message, or a few whose ids are known, use delete_message instead.'
|
|
997
|
+
},
|
|
930
998
|
openapi: {
|
|
931
999
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
932
1000
|
'x-ee-behavior': [BEHAVIOR.GMAIL_DELETE_IS_TRASH],
|
|
@@ -1000,6 +1068,10 @@ async function init(args) {
|
|
|
1000
1068
|
}
|
|
1001
1069
|
}
|
|
1002
1070
|
});
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function registerListMessages(server, args) {
|
|
1074
|
+
const { call, CORS_CONFIG } = args;
|
|
1003
1075
|
|
|
1004
1076
|
// GET /v1/account/{account}/messages - List messages in a folder
|
|
1005
1077
|
server.route({
|
|
@@ -1023,7 +1095,7 @@ async function init(args) {
|
|
|
1023
1095
|
},
|
|
1024
1096
|
options: {
|
|
1025
1097
|
description: 'List messages in a folder',
|
|
1026
|
-
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.',
|
|
1027
1099
|
tags: ['api', 'Message'],
|
|
1028
1100
|
|
|
1029
1101
|
plugins: {
|
|
@@ -1087,6 +1159,10 @@ async function init(args) {
|
|
|
1087
1159
|
}
|
|
1088
1160
|
}
|
|
1089
1161
|
});
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
function registerSearchMessages(server, args) {
|
|
1165
|
+
const { call, CORS_CONFIG } = args;
|
|
1090
1166
|
|
|
1091
1167
|
// POST /v1/account/{account}/search - Search for messages
|
|
1092
1168
|
server.route({
|
|
@@ -1209,6 +1285,10 @@ async function init(args) {
|
|
|
1209
1285
|
}
|
|
1210
1286
|
}
|
|
1211
1287
|
});
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
function registerGetMessageText(server, args) {
|
|
1291
|
+
const { call, CORS_CONFIG, MAX_ATTACHMENT_SIZE } = args;
|
|
1212
1292
|
|
|
1213
1293
|
// GET /v1/account/{account}/text/{text} - Retrieve message text
|
|
1214
1294
|
server.route({
|
|
@@ -1232,7 +1312,7 @@ async function init(args) {
|
|
|
1232
1312
|
},
|
|
1233
1313
|
options: {
|
|
1234
1314
|
description: 'Retrieve message text',
|
|
1235
|
-
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.',
|
|
1236
1316
|
tags: ['api', 'Message'],
|
|
1237
1317
|
|
|
1238
1318
|
plugins: {
|
|
@@ -1319,6 +1399,10 @@ async function init(args) {
|
|
|
1319
1399
|
}
|
|
1320
1400
|
}
|
|
1321
1401
|
});
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
function registerGetAttachment(server, args) {
|
|
1405
|
+
const { call, CORS_CONFIG } = args;
|
|
1322
1406
|
|
|
1323
1407
|
// GET /v1/account/{account}/attachment/{attachment} - Download attachment
|
|
1324
1408
|
server.route({
|
|
@@ -1388,4 +1472,22 @@ async function init(args) {
|
|
|
1388
1472
|
});
|
|
1389
1473
|
}
|
|
1390
1474
|
|
|
1475
|
+
async function init(args) {
|
|
1476
|
+
const { server } = args;
|
|
1477
|
+
|
|
1478
|
+
registerGetMessageSource(server, args);
|
|
1479
|
+
registerGetMessage(server, args);
|
|
1480
|
+
registerUploadMessage(server, args);
|
|
1481
|
+
registerUpdateMessage(server, args);
|
|
1482
|
+
registerUpdateMessages(server, args);
|
|
1483
|
+
registerMoveMessage(server, args);
|
|
1484
|
+
registerMoveMessages(server, args);
|
|
1485
|
+
registerDeleteMessage(server, args);
|
|
1486
|
+
registerDeleteMessages(server, args);
|
|
1487
|
+
registerListMessages(server, args);
|
|
1488
|
+
registerSearchMessages(server, args);
|
|
1489
|
+
registerGetMessageText(server, args);
|
|
1490
|
+
registerGetAttachment(server, args);
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1391
1493
|
module.exports = init;
|
|
@@ -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 = {
|
|
@@ -53,20 +55,8 @@ const oauth2AppExtraFields = {
|
|
|
53
55
|
pubSubIamPolicy: Joi.boolean().example(true).description('Whether the IAM policy for the Cloud Pub/Sub topic has been set up')
|
|
54
56
|
};
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
// Notify the worker when an app create/update changed Pub/Sub resources, and strip the
|
|
60
|
-
// internal marker from the API response
|
|
61
|
-
let applyPubSubUpdates = async result => {
|
|
62
|
-
if (result && result.pubsubUpdates) {
|
|
63
|
-
if (Object.keys(result.pubsubUpdates).length > 0) {
|
|
64
|
-
await call({ cmd: 'googlePubSub', app: result.id });
|
|
65
|
-
}
|
|
66
|
-
delete result.pubsubUpdates;
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
};
|
|
58
|
+
function registerListOAuth2Apps(server, ctx) {
|
|
59
|
+
const { CORS_CONFIG, OAuth2ProviderSchema } = ctx;
|
|
70
60
|
|
|
71
61
|
server.route({
|
|
72
62
|
method: 'GET',
|
|
@@ -74,7 +64,7 @@ async function init(args) {
|
|
|
74
64
|
|
|
75
65
|
async handler(request) {
|
|
76
66
|
try {
|
|
77
|
-
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 });
|
|
78
68
|
|
|
79
69
|
for (let app of response.apps) {
|
|
80
70
|
for (let secretKey of ENCRYPTED_APP_KEYS) {
|
|
@@ -102,7 +92,7 @@ async function init(args) {
|
|
|
102
92
|
|
|
103
93
|
options: {
|
|
104
94
|
description: 'List OAuth2 applications',
|
|
105
|
-
notes: 'Lists
|
|
95
|
+
notes: 'Lists the stored OAuth2 applications, one page at a time. Client secrets and keys are not included.',
|
|
106
96
|
tags: ['api', 'OAuth2 Applications'],
|
|
107
97
|
|
|
108
98
|
plugins: {
|
|
@@ -141,8 +131,9 @@ async function init(args) {
|
|
|
141
131
|
.example(0)
|
|
142
132
|
.description('Page number (zero indexed, so use 0 for first page)')
|
|
143
133
|
.label('PageNumber'),
|
|
144
|
-
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize')
|
|
145
|
-
|
|
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')
|
|
146
137
|
},
|
|
147
138
|
|
|
148
139
|
response: {
|
|
@@ -212,6 +203,10 @@ async function init(args) {
|
|
|
212
203
|
}
|
|
213
204
|
}
|
|
214
205
|
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function registerGetOAuth2App(server, ctx) {
|
|
209
|
+
const { CORS_CONFIG, OAuth2ProviderSchema } = ctx;
|
|
215
210
|
|
|
216
211
|
server.route({
|
|
217
212
|
method: 'GET',
|
|
@@ -338,6 +333,10 @@ async function init(args) {
|
|
|
338
333
|
}
|
|
339
334
|
}
|
|
340
335
|
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function registerCreateOAuth2App(server, ctx) {
|
|
339
|
+
const { CORS_CONFIG, applyPubSubUpdates } = ctx;
|
|
341
340
|
|
|
342
341
|
server.route({
|
|
343
342
|
method: 'POST',
|
|
@@ -396,6 +395,10 @@ async function init(args) {
|
|
|
396
395
|
}
|
|
397
396
|
}
|
|
398
397
|
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function registerUpdateOAuth2App(server, ctx) {
|
|
401
|
+
const { CORS_CONFIG, applyPubSubUpdates } = ctx;
|
|
399
402
|
|
|
400
403
|
server.route({
|
|
401
404
|
method: 'PUT',
|
|
@@ -476,7 +479,7 @@ async function init(args) {
|
|
|
476
479
|
.trim()
|
|
477
480
|
.empty('')
|
|
478
481
|
.max(256)
|
|
479
|
-
.example('
|
|
482
|
+
.example('example-client-secret')
|
|
480
483
|
.description('Client secret for 3-legged OAuth2 applications'),
|
|
481
484
|
|
|
482
485
|
pubSubApp: Joi.string()
|
|
@@ -539,7 +542,11 @@ async function init(args) {
|
|
|
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)
|
|
@@ -559,6 +566,10 @@ async function init(args) {
|
|
|
559
566
|
}
|
|
560
567
|
}
|
|
561
568
|
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function registerDeleteOAuth2App(server, ctx) {
|
|
572
|
+
const { call, CORS_CONFIG } = ctx;
|
|
562
573
|
|
|
563
574
|
server.route({
|
|
564
575
|
method: 'DELETE',
|
|
@@ -581,7 +592,7 @@ async function init(args) {
|
|
|
581
592
|
},
|
|
582
593
|
options: {
|
|
583
594
|
description: 'Remove OAuth2 application',
|
|
584
|
-
notes: '
|
|
595
|
+
notes: 'Deletes a stored OAuth2 application. Accounts that authenticate through it can no longer connect.',
|
|
585
596
|
tags: ['api', 'OAuth2 Applications'],
|
|
586
597
|
|
|
587
598
|
plugins: {
|
|
@@ -626,6 +637,10 @@ async function init(args) {
|
|
|
626
637
|
}
|
|
627
638
|
}
|
|
628
639
|
});
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function registerVerifyOAuth2App(server, ctx) {
|
|
643
|
+
const { CORS_CONFIG } = ctx;
|
|
629
644
|
|
|
630
645
|
server.route({
|
|
631
646
|
method: 'POST',
|
|
@@ -701,7 +716,7 @@ async function init(args) {
|
|
|
701
716
|
Joi.object({
|
|
702
717
|
id: Joi.string().example('signJwt').description('Step identifier'),
|
|
703
718
|
label: Joi.string().example('Sign assertion (signJwt)').description('Human readable step name'),
|
|
704
|
-
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'),
|
|
705
720
|
message: Joi.string().allow(null).example('Assertion signed via IAM signJwt').description('Outcome detail'),
|
|
706
721
|
hint: Joi.string()
|
|
707
722
|
.example('Grant roles/iam.serviceAccountTokenCreator to the workload principal')
|
|
@@ -716,4 +731,29 @@ async function init(args) {
|
|
|
716
731
|
});
|
|
717
732
|
}
|
|
718
733
|
|
|
734
|
+
async function init(args) {
|
|
735
|
+
const { server, call, CORS_CONFIG, OAuth2ProviderSchema } = args;
|
|
736
|
+
|
|
737
|
+
// Notify the worker when an app create/update changed Pub/Sub resources, and strip the
|
|
738
|
+
// internal marker from the API response
|
|
739
|
+
let applyPubSubUpdates = async result => {
|
|
740
|
+
if (result && result.pubsubUpdates) {
|
|
741
|
+
if (Object.keys(result.pubsubUpdates).length > 0) {
|
|
742
|
+
await call({ cmd: 'googlePubSub', app: result.id });
|
|
743
|
+
}
|
|
744
|
+
delete result.pubsubUpdates;
|
|
745
|
+
}
|
|
746
|
+
return result;
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
const ctx = { call, CORS_CONFIG, OAuth2ProviderSchema, applyPubSubUpdates };
|
|
750
|
+
|
|
751
|
+
registerListOAuth2Apps(server, ctx);
|
|
752
|
+
registerGetOAuth2App(server, ctx);
|
|
753
|
+
registerCreateOAuth2App(server, ctx);
|
|
754
|
+
registerUpdateOAuth2App(server, ctx);
|
|
755
|
+
registerDeleteOAuth2App(server, ctx);
|
|
756
|
+
registerVerifyOAuth2App(server, ctx);
|
|
757
|
+
}
|
|
758
|
+
|
|
719
759
|
module.exports = init;
|