emailengine-app 2.84.2 → 2.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ncurc.js +5 -3
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +33 -0
- package/Dockerfile +6 -0
- package/README.md +1 -1
- package/bin/emailengine.js +434 -408
- package/copy-static-files.sh +39 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16562 -0
- package/eslint.config.js +81 -99
- package/lib/account.js +36 -5
- package/lib/api-reference/format.js +4 -3
- package/lib/api-routes/account-routes.js +177 -12
- package/lib/api-routes/blocklist-routes.js +23 -2
- package/lib/api-routes/delivery-test-routes.js +26 -3
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +28 -2
- package/lib/api-routes/mailbox-routes.js +41 -2
- package/lib/api-routes/message-routes.js +97 -3
- package/lib/api-routes/oauth2-app-routes.js +48 -15
- package/lib/api-routes/outbox-routes.js +45 -11
- package/lib/api-routes/permission-map.js +12 -1
- package/lib/api-routes/settings-routes.js +23 -2
- package/lib/api-routes/submit-routes.js +336 -309
- package/lib/api-routes/template-routes.js +38 -2
- package/lib/api-routes/token-routes.js +142 -96
- package/lib/api-routes/webhook-route-routes.js +13 -2
- package/lib/bounce-detect.js +397 -205
- package/lib/consts.js +5 -4
- package/lib/email-client/base-client.js +10 -31
- package/lib/email-client/gmail-client.js +9 -11
- package/lib/email-client/imap/mailbox.js +3 -19
- package/lib/email-client/imap/subconnection.js +1 -1
- package/lib/email-client/imap-client.js +1 -1
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/gateway.js +2 -3
- package/lib/hapi-request-logger.js +107 -0
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/mcp/tools.js +37 -8
- package/lib/notify-attachments.js +17 -0
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +1 -1
- package/lib/pbkdf2-phc.js +1 -1
- package/lib/schemas.js +1 -1
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +46 -0
- package/lib/timezones.js +109 -0
- package/lib/token-permission-view.js +3 -3
- package/lib/tools.js +40 -10
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +475 -454
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +88 -10
- package/lib/ui-routes/admin-entities-routes.js +91 -7
- package/lib/ui-routes/auth-routes.js +90 -38
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/oauth-config-routes.js +124 -82
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/murmurhash3.js +66 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/version.js +74 -0
- package/lib/webhook-routing.js +27 -0
- package/lib/webhooks.js +41 -6
- package/package.json +27 -29
- package/sbom.json +7980 -1
- package/server.js +634 -441
- package/static/licenses.html +181 -1006
- package/translations/messages.pot +62 -63
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +2 -2
- package/views/config/service.hbs +3 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +738 -583
- package/workers/export.js +1 -1
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +16 -32
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The last step of the hosted account setup, shared by both arms of the form: the IMAP arm
|
|
4
|
+
// (POST /accounts/new/imap/server in ./account-routes.js) and the OAuth2 callback (GET /oauth in
|
|
5
|
+
// workers/api.js). Both claim the signed link's single-use nonce, create the account, give the
|
|
6
|
+
// nonce back when the create fails, and send the visitor on to the calling application or to the
|
|
7
|
+
// account page. The two copies this replaced had drifted apart: the OAuth2 one answered in
|
|
8
|
+
// untranslated English and built the account page link from the raw account ID.
|
|
9
|
+
|
|
10
|
+
const Boom = require('@hapi/boom');
|
|
11
|
+
|
|
12
|
+
const { redis } = require('../db');
|
|
13
|
+
const settings = require('../settings');
|
|
14
|
+
const { claimFormNonce, releaseFormNonce } = require('../tools');
|
|
15
|
+
const { adminUrl } = require('./route-helpers');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Where the visitor goes once the account exists: the calling application's redirect URL with the
|
|
19
|
+
* account ID and its state appended, or the account's admin page when the link named none.
|
|
20
|
+
*
|
|
21
|
+
* @param {string|undefined} redirectUrl - The redirect URL the signed link carried, resolved against `serviceUrl`
|
|
22
|
+
* @param {string|undefined} serviceUrl - The instance's Service URL
|
|
23
|
+
* @param {Object} result - What Account.create() returned (`account`, `state`)
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
function setupRedirectUrl(redirectUrl, serviceUrl, result) {
|
|
27
|
+
if (!redirectUrl) {
|
|
28
|
+
return adminUrl`/admin/accounts/${result.account}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const url = new URL(redirectUrl, serviceUrl);
|
|
32
|
+
url.searchParams.set('account', result.account);
|
|
33
|
+
url.searchParams.set('state', result.state);
|
|
34
|
+
return url.href;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Claims the link's nonce, creates the account and returns the URL to send the visitor to.
|
|
39
|
+
*
|
|
40
|
+
* The nonce is claimed BEFORE create (SET NX), so a concurrent double-submit, a replayed callback
|
|
41
|
+
* or one signed link spent on both arms (start OAuth2, then submit the same blob to the IMAP arm)
|
|
42
|
+
* cannot create a second account. A link with no nonce skips the claim: setup and re-auth links
|
|
43
|
+
* issued before nonces existed carry none, and the OAuth2 arm accepts them for that reason. When
|
|
44
|
+
* create() fails the nonce is released so the visitor can retry. Accepted residual: if Redis fails
|
|
45
|
+
* there too, the nonce stays consumed for its TTL and a fresh link is needed, the price of the
|
|
46
|
+
* claim-before-create ordering that makes the dedupe atomic.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} request - The Hapi request; its `app.gt` translates the refusals
|
|
49
|
+
* @param {Object} options
|
|
50
|
+
* @param {Object} options.accountObject - An Account instance to create the account with
|
|
51
|
+
* @param {Object} options.accountData - The account to create
|
|
52
|
+
* @param {Object} [options.nonce] - The signed link's nonce (`n`) and its timestamp (`t`)
|
|
53
|
+
* @param {string} [options.redirectUrl] - Where the calling application wants the visitor back
|
|
54
|
+
* @returns {Promise<string>} The URL to redirect the visitor to
|
|
55
|
+
*/
|
|
56
|
+
async function completeAccountSetup(request, { accountObject, accountData, nonce, redirectUrl }) {
|
|
57
|
+
const gt = request.app.gt;
|
|
58
|
+
|
|
59
|
+
let nonceClaimed = false;
|
|
60
|
+
if (nonce && nonce.n) {
|
|
61
|
+
let claimed;
|
|
62
|
+
try {
|
|
63
|
+
claimed = await claimFormNonce(redis, nonce.n, nonce.t);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
// A Redis failure is not a consumed nonce. Report it as a retryable server error
|
|
66
|
+
// instead of misdiagnosing a valid setup URL as invalid or expired.
|
|
67
|
+
request.logger.error({ msg: 'Failed to claim nonce for an account form request', err });
|
|
68
|
+
throw Boom.boomify(new Error(gt.gettext('Temporary error, please try again')), { statusCode: 500 });
|
|
69
|
+
}
|
|
70
|
+
if (!claimed) {
|
|
71
|
+
// SET NX returned null: the nonce key already exists, so this URL was already used.
|
|
72
|
+
//
|
|
73
|
+
// Reviewed, accepted (do not "fix" server-side): the LOSING side of a legitimate
|
|
74
|
+
// concurrent double-submit lands here and sees this 403 even though the winning request
|
|
75
|
+
// created the account. The client-side formSubmitting latch
|
|
76
|
+
// (views/accounts/register/imap-server.hbs) is the primary guard; the residual is a
|
|
77
|
+
// no-JS double-click, and even then this is strictly better than two duplicate
|
|
78
|
+
// accounts. Storing the created account ID under the nonce key and redirecting the
|
|
79
|
+
// loser to success is a possible future enhancement, not a bug.
|
|
80
|
+
throw Boom.boomify(new Error(gt.gettext('Invalid or expired account setup URL')), { statusCode: 403 });
|
|
81
|
+
}
|
|
82
|
+
nonceClaimed = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let result;
|
|
86
|
+
try {
|
|
87
|
+
result = await accountObject.create(accountData);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
if (nonceClaimed) {
|
|
90
|
+
await releaseFormNonce(redis, nonce.n, request.logger);
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const serviceUrl = redirectUrl ? await settings.get('serviceUrl') : undefined;
|
|
96
|
+
return setupRedirectUrl(redirectUrl, serviceUrl, result);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { completeAccountSetup, setupRedirectUrl };
|
|
@@ -16,7 +16,7 @@ const { fetch: fetchCmd } = require('undici');
|
|
|
16
16
|
const settings = require('../settings');
|
|
17
17
|
const consts = require('../consts');
|
|
18
18
|
const getSecret = require('../get-secret');
|
|
19
|
-
const
|
|
19
|
+
const { timezoneOptions } = require('../timezones');
|
|
20
20
|
const { Queue } = require('bullmq');
|
|
21
21
|
const { redis, submitQueue, notifyQueue, queueConf, logBullErrors } = require('../db');
|
|
22
22
|
const {
|
|
@@ -203,9 +203,7 @@ async function getOpenAiError(gt) {
|
|
|
203
203
|
return openAiError;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
function
|
|
207
|
-
const { server, call } = args;
|
|
208
|
-
|
|
206
|
+
function registerConfigWebhooksPage(server) {
|
|
209
207
|
registerSettingsPage(server, {
|
|
210
208
|
path: '/admin/config/webhooks',
|
|
211
209
|
view: 'config/webhooks',
|
|
@@ -319,6 +317,10 @@ function init(args) {
|
|
|
319
317
|
}
|
|
320
318
|
}
|
|
321
319
|
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function registerConfigServicePage(server, args) {
|
|
323
|
+
const { call } = args;
|
|
322
324
|
|
|
323
325
|
registerSettingsPage(server, {
|
|
324
326
|
path: '/admin/config/service',
|
|
@@ -355,11 +357,7 @@ function init(args) {
|
|
|
355
357
|
return {
|
|
356
358
|
locales: locales.map(locale => Object.assign({ selected: locale.locale === values.locale }, locale)),
|
|
357
359
|
|
|
358
|
-
timezones:
|
|
359
|
-
name: entry.label,
|
|
360
|
-
timezone: entry.tzCode,
|
|
361
|
-
selected: entry.tzCode === values.timezone
|
|
362
|
-
}))
|
|
360
|
+
timezones: timezoneOptions(values.timezone)
|
|
363
361
|
};
|
|
364
362
|
},
|
|
365
363
|
|
|
@@ -375,6 +373,14 @@ function init(args) {
|
|
|
375
373
|
// write would leave the old URL in place after a save meant to clear it
|
|
376
374
|
data.serviceUrl = request.payload.serviceUrl ? new URL(request.payload.serviceUrl).origin : null;
|
|
377
375
|
|
|
376
|
+
// While no timezone is stored the select starts on a blank "Not set" choice, and saving it
|
|
377
|
+
// leaves the setting alone: the next admin page load fills it in from the browser
|
|
378
|
+
// (/admin/config/browser). Without that choice the select started on the first zone in
|
|
379
|
+
// the list, and saving the page before the browser had reported stored Pacific/Midway
|
|
380
|
+
if (!data.timezone) {
|
|
381
|
+
delete data.timezone;
|
|
382
|
+
}
|
|
383
|
+
|
|
378
384
|
// Compared before the write, and only for the reload: this form submits the service URL
|
|
379
385
|
// on every save, so reloading on the write alone would hand three listeners a new
|
|
380
386
|
// certificate every time somebody changed the timezone.
|
|
@@ -389,7 +395,9 @@ function init(args) {
|
|
|
389
395
|
await maybeReloadTlsCertificates(call, request.logger, serviceUrlChanged ? ['serviceUrl'] : [], { action: 'settings' });
|
|
390
396
|
}
|
|
391
397
|
});
|
|
398
|
+
}
|
|
392
399
|
|
|
400
|
+
function registerConfigSecurityPage(server) {
|
|
393
401
|
registerSettingsPage(server, {
|
|
394
402
|
path: '/admin/config/security',
|
|
395
403
|
view: 'config/security',
|
|
@@ -446,7 +454,9 @@ function init(args) {
|
|
|
446
454
|
await settings.setMulti(data);
|
|
447
455
|
}
|
|
448
456
|
});
|
|
457
|
+
}
|
|
449
458
|
|
|
459
|
+
function registerConfigEmailProcessingPage(server) {
|
|
450
460
|
registerSettingsPage(server, {
|
|
451
461
|
path: '/admin/config/email-processing',
|
|
452
462
|
view: 'config/email-processing',
|
|
@@ -537,7 +547,9 @@ function init(args) {
|
|
|
537
547
|
});
|
|
538
548
|
}
|
|
539
549
|
});
|
|
550
|
+
}
|
|
540
551
|
|
|
552
|
+
function registerConfigBrandingPage(server) {
|
|
541
553
|
registerSettingsPage(server, {
|
|
542
554
|
path: '/admin/config/branding',
|
|
543
555
|
view: 'config/branding',
|
|
@@ -567,7 +579,9 @@ function init(args) {
|
|
|
567
579
|
});
|
|
568
580
|
}
|
|
569
581
|
});
|
|
582
|
+
}
|
|
570
583
|
|
|
584
|
+
function registerConfigMcpPage(server) {
|
|
571
585
|
registerSettingsPage(server, {
|
|
572
586
|
path: '/admin/config/mcp',
|
|
573
587
|
view: 'config/mcp',
|
|
@@ -684,7 +698,9 @@ function init(args) {
|
|
|
684
698
|
});
|
|
685
699
|
}
|
|
686
700
|
});
|
|
701
|
+
}
|
|
687
702
|
|
|
703
|
+
function registerConfigAiPage(server) {
|
|
688
704
|
registerSettingsPage(server, {
|
|
689
705
|
path: '/admin/config/ai',
|
|
690
706
|
view: 'config/ai',
|
|
@@ -773,6 +789,10 @@ function init(args) {
|
|
|
773
789
|
}
|
|
774
790
|
}
|
|
775
791
|
});
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
function registerPostConfigAiTestPrompt(server, args) {
|
|
795
|
+
const { call } = args;
|
|
776
796
|
|
|
777
797
|
server.route({
|
|
778
798
|
method: 'POST',
|
|
@@ -839,6 +859,10 @@ function init(args) {
|
|
|
839
859
|
}
|
|
840
860
|
}
|
|
841
861
|
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function registerPostConfigAiReloadModels(server, args) {
|
|
865
|
+
const { call } = args;
|
|
842
866
|
|
|
843
867
|
server.route({
|
|
844
868
|
method: 'POST',
|
|
@@ -892,7 +916,9 @@ function init(args) {
|
|
|
892
916
|
}
|
|
893
917
|
}
|
|
894
918
|
});
|
|
919
|
+
}
|
|
895
920
|
|
|
921
|
+
function registerPostConfigBrandingPreview(server) {
|
|
896
922
|
server.route({
|
|
897
923
|
method: 'POST',
|
|
898
924
|
path: '/admin/config/branding/preview',
|
|
@@ -930,7 +956,9 @@ function init(args) {
|
|
|
930
956
|
}
|
|
931
957
|
}
|
|
932
958
|
});
|
|
959
|
+
}
|
|
933
960
|
|
|
961
|
+
function registerPostConfigClearError(server) {
|
|
934
962
|
server.route({
|
|
935
963
|
method: 'POST',
|
|
936
964
|
path: '/admin/config/clear-error',
|
|
@@ -989,7 +1017,9 @@ function init(args) {
|
|
|
989
1017
|
}
|
|
990
1018
|
}
|
|
991
1019
|
});
|
|
1020
|
+
}
|
|
992
1021
|
|
|
1022
|
+
function registerPostConfigServiceClean(server) {
|
|
993
1023
|
server.route({
|
|
994
1024
|
method: 'POST',
|
|
995
1025
|
path: '/admin/config/service/clean',
|
|
@@ -1024,7 +1054,9 @@ function init(args) {
|
|
|
1024
1054
|
}
|
|
1025
1055
|
}
|
|
1026
1056
|
});
|
|
1057
|
+
}
|
|
1027
1058
|
|
|
1059
|
+
function registerConfigLoggingPage(server) {
|
|
1028
1060
|
registerSettingsPage(server, {
|
|
1029
1061
|
path: '/admin/config/logging',
|
|
1030
1062
|
view: 'config/logging',
|
|
@@ -1077,6 +1109,10 @@ function init(args) {
|
|
|
1077
1109
|
await settings.setMulti(data);
|
|
1078
1110
|
}
|
|
1079
1111
|
});
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
function registerPostConfigLoggingReconnect(server, args) {
|
|
1115
|
+
const { call } = args;
|
|
1080
1116
|
|
|
1081
1117
|
server.route({
|
|
1082
1118
|
method: 'POST',
|
|
@@ -1124,7 +1160,9 @@ function init(args) {
|
|
|
1124
1160
|
}
|
|
1125
1161
|
}
|
|
1126
1162
|
});
|
|
1163
|
+
}
|
|
1127
1164
|
|
|
1165
|
+
function registerPostConfigWebhooksTest(server) {
|
|
1128
1166
|
server.route({
|
|
1129
1167
|
method: 'POST',
|
|
1130
1168
|
path: '/admin/config/webhooks/test',
|
|
@@ -1245,8 +1283,12 @@ function init(args) {
|
|
|
1245
1283
|
}
|
|
1246
1284
|
}
|
|
1247
1285
|
});
|
|
1286
|
+
}
|
|
1248
1287
|
|
|
1249
|
-
|
|
1288
|
+
// Webhook, template, gateway, and token routes are in admin-entities-routes.js
|
|
1289
|
+
|
|
1290
|
+
function registerGetConfigLicense(server, args) {
|
|
1291
|
+
const { call } = args;
|
|
1250
1292
|
|
|
1251
1293
|
server.route({
|
|
1252
1294
|
method: 'GET',
|
|
@@ -1282,6 +1324,10 @@ function init(args) {
|
|
|
1282
1324
|
);
|
|
1283
1325
|
}
|
|
1284
1326
|
});
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function registerPostConfigLicense(server, args) {
|
|
1330
|
+
const { call } = args;
|
|
1285
1331
|
|
|
1286
1332
|
server.route({
|
|
1287
1333
|
method: 'POST',
|
|
@@ -1381,6 +1427,10 @@ function init(args) {
|
|
|
1381
1427
|
}
|
|
1382
1428
|
}
|
|
1383
1429
|
});
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
function registerPostConfigLicenseDelete(server, args) {
|
|
1433
|
+
const { call } = args;
|
|
1384
1434
|
|
|
1385
1435
|
server.route({
|
|
1386
1436
|
method: 'POST',
|
|
@@ -1422,6 +1472,10 @@ function init(args) {
|
|
|
1422
1472
|
}
|
|
1423
1473
|
}
|
|
1424
1474
|
});
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
function registerPostConfigLicenseTrial(server, args) {
|
|
1478
|
+
const { call } = args;
|
|
1425
1479
|
|
|
1426
1480
|
server.route({
|
|
1427
1481
|
method: 'POST',
|
|
@@ -1499,4 +1553,28 @@ ${Buffer.from(data.content, 'base64url').toString('base64')}
|
|
|
1499
1553
|
});
|
|
1500
1554
|
}
|
|
1501
1555
|
|
|
1556
|
+
function init(args) {
|
|
1557
|
+
const { server } = args;
|
|
1558
|
+
|
|
1559
|
+
registerConfigWebhooksPage(server);
|
|
1560
|
+
registerConfigServicePage(server, args);
|
|
1561
|
+
registerConfigSecurityPage(server);
|
|
1562
|
+
registerConfigEmailProcessingPage(server);
|
|
1563
|
+
registerConfigBrandingPage(server);
|
|
1564
|
+
registerConfigMcpPage(server);
|
|
1565
|
+
registerConfigAiPage(server);
|
|
1566
|
+
registerPostConfigAiTestPrompt(server, args);
|
|
1567
|
+
registerPostConfigAiReloadModels(server, args);
|
|
1568
|
+
registerPostConfigBrandingPreview(server);
|
|
1569
|
+
registerPostConfigClearError(server);
|
|
1570
|
+
registerPostConfigServiceClean(server);
|
|
1571
|
+
registerConfigLoggingPage(server);
|
|
1572
|
+
registerPostConfigLoggingReconnect(server, args);
|
|
1573
|
+
registerPostConfigWebhooksTest(server);
|
|
1574
|
+
registerGetConfigLicense(server, args);
|
|
1575
|
+
registerPostConfigLicense(server, args);
|
|
1576
|
+
registerPostConfigLicenseDelete(server, args);
|
|
1577
|
+
registerPostConfigLicenseTrial(server, args);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1502
1580
|
module.exports = init;
|
|
@@ -92,11 +92,9 @@ async function getExampleWebhookPayloads() {
|
|
|
92
92
|
return examplePayloads;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
const { server, call } = args;
|
|
97
|
-
|
|
98
|
-
// Webhook routes
|
|
95
|
+
// Webhook routes
|
|
99
96
|
|
|
97
|
+
function registerGetWebhooks(server) {
|
|
100
98
|
server.route({
|
|
101
99
|
method: 'GET',
|
|
102
100
|
path: '/admin/webhooks',
|
|
@@ -183,7 +181,9 @@ function init(args) {
|
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
183
|
});
|
|
184
|
+
}
|
|
186
185
|
|
|
186
|
+
function registerGetWebhooksNew(server) {
|
|
187
187
|
server.route({
|
|
188
188
|
method: 'GET',
|
|
189
189
|
path: '/admin/webhooks/new',
|
|
@@ -241,7 +241,9 @@ return payload;`)
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
|
+
}
|
|
244
245
|
|
|
246
|
+
function registerPostWebhooksNew(server) {
|
|
245
247
|
server.route({
|
|
246
248
|
method: 'POST',
|
|
247
249
|
path: '/admin/webhooks/new',
|
|
@@ -372,7 +374,9 @@ return payload;`)
|
|
|
372
374
|
}
|
|
373
375
|
}
|
|
374
376
|
});
|
|
377
|
+
}
|
|
375
378
|
|
|
379
|
+
function registerGetWebhooksWebhook(server) {
|
|
376
380
|
server.route({
|
|
377
381
|
method: 'GET',
|
|
378
382
|
path: '/admin/webhooks/webhook/{webhook}',
|
|
@@ -435,7 +439,9 @@ return payload;`)
|
|
|
435
439
|
}
|
|
436
440
|
}
|
|
437
441
|
});
|
|
442
|
+
}
|
|
438
443
|
|
|
444
|
+
function registerGetWebhooksWebhookEdit(server) {
|
|
439
445
|
server.route({
|
|
440
446
|
method: 'GET',
|
|
441
447
|
path: '/admin/webhooks/webhook/{webhook}/edit',
|
|
@@ -504,7 +510,9 @@ return payload;`)
|
|
|
504
510
|
}
|
|
505
511
|
}
|
|
506
512
|
});
|
|
513
|
+
}
|
|
507
514
|
|
|
515
|
+
function registerPostWebhooksEdit(server) {
|
|
508
516
|
server.route({
|
|
509
517
|
method: 'POST',
|
|
510
518
|
path: '/admin/webhooks/edit',
|
|
@@ -661,7 +669,9 @@ return payload;`)
|
|
|
661
669
|
}
|
|
662
670
|
}
|
|
663
671
|
});
|
|
672
|
+
}
|
|
664
673
|
|
|
674
|
+
function registerPostWebhooksDelete(server) {
|
|
665
675
|
server.route({
|
|
666
676
|
method: 'POST',
|
|
667
677
|
path: '/admin/webhooks/delete',
|
|
@@ -706,9 +716,11 @@ return payload;`)
|
|
|
706
716
|
}
|
|
707
717
|
}
|
|
708
718
|
});
|
|
719
|
+
}
|
|
709
720
|
|
|
710
|
-
|
|
721
|
+
// Template routes
|
|
711
722
|
|
|
723
|
+
function registerGetTemplates(server) {
|
|
712
724
|
server.route({
|
|
713
725
|
method: 'GET',
|
|
714
726
|
path: '/admin/templates',
|
|
@@ -805,7 +817,9 @@ return payload;`)
|
|
|
805
817
|
}
|
|
806
818
|
}
|
|
807
819
|
});
|
|
820
|
+
}
|
|
808
821
|
|
|
822
|
+
function registerGetTemplatesTemplate(server) {
|
|
809
823
|
server.route({
|
|
810
824
|
method: 'GET',
|
|
811
825
|
path: '/admin/templates/template/{template}',
|
|
@@ -866,7 +880,9 @@ return payload;`)
|
|
|
866
880
|
}
|
|
867
881
|
}
|
|
868
882
|
});
|
|
883
|
+
}
|
|
869
884
|
|
|
885
|
+
function registerGetTemplatesTemplateEdit(server) {
|
|
870
886
|
server.route({
|
|
871
887
|
method: 'GET',
|
|
872
888
|
path: '/admin/templates/template/{template}/edit',
|
|
@@ -941,7 +957,9 @@ return payload;`)
|
|
|
941
957
|
}
|
|
942
958
|
}
|
|
943
959
|
});
|
|
960
|
+
}
|
|
944
961
|
|
|
962
|
+
function registerPostTemplatesEdit(server) {
|
|
945
963
|
server.route({
|
|
946
964
|
method: 'POST',
|
|
947
965
|
path: '/admin/templates/edit',
|
|
@@ -1094,7 +1112,9 @@ return payload;`)
|
|
|
1094
1112
|
}
|
|
1095
1113
|
}
|
|
1096
1114
|
});
|
|
1115
|
+
}
|
|
1097
1116
|
|
|
1117
|
+
function registerGetTemplatesNew(server) {
|
|
1098
1118
|
server.route({
|
|
1099
1119
|
method: 'GET',
|
|
1100
1120
|
path: '/admin/templates/new',
|
|
@@ -1158,7 +1178,9 @@ return payload;`)
|
|
|
1158
1178
|
}
|
|
1159
1179
|
}
|
|
1160
1180
|
});
|
|
1181
|
+
}
|
|
1161
1182
|
|
|
1183
|
+
function registerPostTemplatesNew(server) {
|
|
1162
1184
|
server.route({
|
|
1163
1185
|
method: 'POST',
|
|
1164
1186
|
path: '/admin/templates/new',
|
|
@@ -1298,7 +1320,9 @@ return payload;`)
|
|
|
1298
1320
|
}
|
|
1299
1321
|
}
|
|
1300
1322
|
});
|
|
1323
|
+
}
|
|
1301
1324
|
|
|
1325
|
+
function registerPostTemplatesDelete(server) {
|
|
1302
1326
|
server.route({
|
|
1303
1327
|
method: 'POST',
|
|
1304
1328
|
path: '/admin/templates/delete',
|
|
@@ -1346,6 +1370,10 @@ return payload;`)
|
|
|
1346
1370
|
}
|
|
1347
1371
|
}
|
|
1348
1372
|
});
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
function registerPostTemplatesTest(server, args) {
|
|
1376
|
+
const { call } = args;
|
|
1349
1377
|
|
|
1350
1378
|
server.route({
|
|
1351
1379
|
method: 'POST',
|
|
@@ -1438,9 +1466,11 @@ return payload;`)
|
|
|
1438
1466
|
}
|
|
1439
1467
|
}
|
|
1440
1468
|
});
|
|
1469
|
+
}
|
|
1441
1470
|
|
|
1442
|
-
|
|
1471
|
+
// Gateway routes
|
|
1443
1472
|
|
|
1473
|
+
function registerGetGateways(server) {
|
|
1444
1474
|
server.route({
|
|
1445
1475
|
method: 'GET',
|
|
1446
1476
|
path: '/admin/gateways',
|
|
@@ -1542,7 +1572,9 @@ return payload;`)
|
|
|
1542
1572
|
}
|
|
1543
1573
|
}
|
|
1544
1574
|
});
|
|
1575
|
+
}
|
|
1545
1576
|
|
|
1577
|
+
function registerGetGatewaysNew(server) {
|
|
1546
1578
|
server.route({
|
|
1547
1579
|
method: 'GET',
|
|
1548
1580
|
path: '/admin/gateways/new',
|
|
@@ -1562,7 +1594,9 @@ return payload;`)
|
|
|
1562
1594
|
);
|
|
1563
1595
|
}
|
|
1564
1596
|
});
|
|
1597
|
+
}
|
|
1565
1598
|
|
|
1599
|
+
function registerGetGatewaysGateway(server) {
|
|
1566
1600
|
server.route({
|
|
1567
1601
|
method: 'GET',
|
|
1568
1602
|
path: '/admin/gateways/gateway/{gateway}',
|
|
@@ -1618,7 +1652,9 @@ return payload;`)
|
|
|
1618
1652
|
}
|
|
1619
1653
|
}
|
|
1620
1654
|
});
|
|
1655
|
+
}
|
|
1621
1656
|
|
|
1657
|
+
function registerGetGatewaysEdit(server) {
|
|
1622
1658
|
server.route({
|
|
1623
1659
|
method: 'GET',
|
|
1624
1660
|
path: '/admin/gateways/edit/{gateway}',
|
|
@@ -1665,7 +1701,9 @@ return payload;`)
|
|
|
1665
1701
|
}
|
|
1666
1702
|
}
|
|
1667
1703
|
});
|
|
1704
|
+
}
|
|
1668
1705
|
|
|
1706
|
+
function registerPostGatewaysNew(server) {
|
|
1669
1707
|
server.route({
|
|
1670
1708
|
method: 'POST',
|
|
1671
1709
|
path: '/admin/gateways/new',
|
|
@@ -1778,7 +1816,9 @@ return payload;`)
|
|
|
1778
1816
|
}
|
|
1779
1817
|
}
|
|
1780
1818
|
});
|
|
1819
|
+
}
|
|
1781
1820
|
|
|
1821
|
+
function registerPostGatewaysEdit(server) {
|
|
1782
1822
|
server.route({
|
|
1783
1823
|
method: 'POST',
|
|
1784
1824
|
path: '/admin/gateways/edit',
|
|
@@ -1906,7 +1946,9 @@ return payload;`)
|
|
|
1906
1946
|
}
|
|
1907
1947
|
}
|
|
1908
1948
|
});
|
|
1949
|
+
}
|
|
1909
1950
|
|
|
1951
|
+
function registerPostGatewaysTest(server) {
|
|
1910
1952
|
server.route({
|
|
1911
1953
|
method: 'POST',
|
|
1912
1954
|
path: '/admin/gateways/test',
|
|
@@ -2021,7 +2063,9 @@ return payload;`)
|
|
|
2021
2063
|
}
|
|
2022
2064
|
}
|
|
2023
2065
|
});
|
|
2066
|
+
}
|
|
2024
2067
|
|
|
2068
|
+
function registerPostGatewaysDelete(server) {
|
|
2025
2069
|
server.route({
|
|
2026
2070
|
method: 'POST',
|
|
2027
2071
|
path: '/admin/gateways/delete/{gateway}',
|
|
@@ -2071,9 +2115,11 @@ return payload;`)
|
|
|
2071
2115
|
}
|
|
2072
2116
|
}
|
|
2073
2117
|
});
|
|
2118
|
+
}
|
|
2074
2119
|
|
|
2075
|
-
|
|
2120
|
+
// Token routes
|
|
2076
2121
|
|
|
2122
|
+
function registerGetTokens(server) {
|
|
2077
2123
|
server.route({
|
|
2078
2124
|
method: 'GET',
|
|
2079
2125
|
path: '/admin/tokens',
|
|
@@ -2246,7 +2292,9 @@ return payload;`)
|
|
|
2246
2292
|
}
|
|
2247
2293
|
}
|
|
2248
2294
|
});
|
|
2295
|
+
}
|
|
2249
2296
|
|
|
2297
|
+
function registerGetTokensNew(server) {
|
|
2250
2298
|
server.route({
|
|
2251
2299
|
method: 'GET',
|
|
2252
2300
|
path: '/admin/tokens/new',
|
|
@@ -2332,7 +2380,9 @@ return payload;`)
|
|
|
2332
2380
|
}
|
|
2333
2381
|
}
|
|
2334
2382
|
});
|
|
2383
|
+
}
|
|
2335
2384
|
|
|
2385
|
+
function registerPostTokensNew(server) {
|
|
2336
2386
|
server.route({
|
|
2337
2387
|
method: 'POST',
|
|
2338
2388
|
path: '/admin/tokens/new',
|
|
@@ -2419,7 +2469,9 @@ return payload;`)
|
|
|
2419
2469
|
}
|
|
2420
2470
|
}
|
|
2421
2471
|
});
|
|
2472
|
+
}
|
|
2422
2473
|
|
|
2474
|
+
function registerPostTokensDelete(server) {
|
|
2423
2475
|
server.route({
|
|
2424
2476
|
method: 'POST',
|
|
2425
2477
|
path: '/admin/tokens/delete',
|
|
@@ -2474,6 +2526,38 @@ return payload;`)
|
|
|
2474
2526
|
});
|
|
2475
2527
|
}
|
|
2476
2528
|
|
|
2529
|
+
function init(args) {
|
|
2530
|
+
const { server } = args;
|
|
2531
|
+
|
|
2532
|
+
registerGetWebhooks(server);
|
|
2533
|
+
registerGetWebhooksNew(server);
|
|
2534
|
+
registerPostWebhooksNew(server);
|
|
2535
|
+
registerGetWebhooksWebhook(server);
|
|
2536
|
+
registerGetWebhooksWebhookEdit(server);
|
|
2537
|
+
registerPostWebhooksEdit(server);
|
|
2538
|
+
registerPostWebhooksDelete(server);
|
|
2539
|
+
registerGetTemplates(server);
|
|
2540
|
+
registerGetTemplatesTemplate(server);
|
|
2541
|
+
registerGetTemplatesTemplateEdit(server);
|
|
2542
|
+
registerPostTemplatesEdit(server);
|
|
2543
|
+
registerGetTemplatesNew(server);
|
|
2544
|
+
registerPostTemplatesNew(server);
|
|
2545
|
+
registerPostTemplatesDelete(server);
|
|
2546
|
+
registerPostTemplatesTest(server, args);
|
|
2547
|
+
registerGetGateways(server);
|
|
2548
|
+
registerGetGatewaysNew(server);
|
|
2549
|
+
registerGetGatewaysGateway(server);
|
|
2550
|
+
registerGetGatewaysEdit(server);
|
|
2551
|
+
registerPostGatewaysNew(server);
|
|
2552
|
+
registerPostGatewaysEdit(server);
|
|
2553
|
+
registerPostGatewaysTest(server);
|
|
2554
|
+
registerPostGatewaysDelete(server);
|
|
2555
|
+
registerGetTokens(server);
|
|
2556
|
+
registerGetTokensNew(server);
|
|
2557
|
+
registerPostTokensNew(server);
|
|
2558
|
+
registerPostTokensDelete(server);
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2477
2561
|
// The account a template belongs to, for the template pages. A template can outlive its account
|
|
2478
2562
|
// (deleted since, or stored before the create form checked the ID), and a missing account is
|
|
2479
2563
|
// then rendered as no account rather than turning the template itself into a 404 nobody can
|