emailengine-app 2.84.1 → 2.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +6 -0
- package/.ncurc.js +5 -3
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +61 -0
- package/Dockerfile +8 -2
- package/README.md +1 -1
- package/bin/emailengine.js +444 -403
- package/copy-static-files.sh +39 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16562 -0
- package/docker-compose.yml +1 -1
- package/eslint.config.js +81 -99
- package/lib/account/own-account-key.js +42 -0
- package/lib/account-assignment.js +1 -33
- package/lib/account.js +68 -24
- package/lib/add-trackers.js +11 -4
- package/lib/api-reference/format.js +4 -3
- package/lib/api-routes/account-routes.js +244 -26
- package/lib/api-routes/blocklist-routes.js +23 -2
- package/lib/api-routes/delivery-test-routes.js +26 -3
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +37 -5
- package/lib/api-routes/mailbox-routes.js +41 -2
- package/lib/api-routes/message-routes.js +104 -4
- package/lib/api-routes/mint-bounds.js +11 -0
- package/lib/api-routes/oauth2-app-routes.js +48 -15
- package/lib/api-routes/outbox-routes.js +45 -11
- package/lib/api-routes/permission-map.js +12 -1
- package/lib/api-routes/route-helpers.js +125 -3
- package/lib/api-routes/settings-routes.js +23 -2
- package/lib/api-routes/submit-routes.js +338 -309
- package/lib/api-routes/template-routes.js +38 -2
- package/lib/api-routes/token-routes.js +142 -96
- package/lib/api-routes/webhook-route-routes.js +13 -2
- package/lib/auth-token.js +23 -10
- package/lib/bounce-detect.js +414 -210
- package/lib/consts.js +39 -4
- package/lib/create-imap-client.js +41 -2
- package/lib/email-client/base-client.js +30 -41
- package/lib/email-client/gmail-client.js +30 -18
- package/lib/email-client/imap/mailbox.js +13 -23
- package/lib/email-client/imap/response-metrics.js +75 -0
- package/lib/email-client/imap/subconnection.js +1 -1
- package/lib/email-client/imap-client.js +6 -3
- package/lib/email-client/message-builder.js +7 -2
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/email-client/outlook/graph-api.js +17 -2
- package/lib/email-client/outlook-client.js +6 -3
- package/lib/email-client/smtp-pool-manager.js +6 -0
- package/lib/encrypt.js +9 -0
- package/lib/export.js +3 -1
- package/lib/gateway.js +2 -3
- package/lib/get-raw-email.js +4 -2
- package/lib/hapi-request-logger.js +107 -0
- package/lib/imap-proxy-auth.js +14 -1
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +1 -0
- package/lib/imapproxy/imap-core/lib/commands/login.js +1 -0
- package/lib/imapproxy/imap-core/lib/imap-command.js +86 -43
- package/lib/imapproxy/imap-core/lib/imap-stream.js +58 -13
- package/lib/imapproxy/imap-core/lib/indexer/indexer.js +3 -1
- package/lib/mcp/listen.js +10 -1
- package/lib/mcp/tools.js +37 -8
- package/lib/notify-attachments.js +17 -0
- package/lib/oauth/external-account-config.js +3 -1
- package/lib/oauth/gmail.js +21 -48
- package/lib/oauth/mail-ru.js +5 -38
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/outlook.js +26 -44
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +1 -1
- package/lib/pbkdf2-phc.js +19 -2
- package/lib/privileged-settings.js +6 -3
- package/lib/redis-scan-delete.js +15 -1
- package/lib/schemas.js +79 -33
- package/lib/settings.js +13 -1
- package/lib/smtp-auth.js +23 -0
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +46 -0
- package/lib/timezones.js +109 -0
- package/lib/token-permission-view.js +3 -3
- package/lib/tools.js +285 -66
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +491 -491
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +98 -48
- package/lib/ui-routes/admin-entities-routes.js +113 -31
- package/lib/ui-routes/auth-routes.js +137 -62
- package/lib/ui-routes/connection-security-form.js +74 -0
- package/lib/ui-routes/form-lists.js +46 -0
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/mcp-consent-routes.js +5 -1
- package/lib/ui-routes/oauth-config-routes.js +133 -100
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/sign-in-helpers.js +59 -0
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/ui-routes/unsubscribe-routes.js +6 -3
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/map-concurrent.js +36 -0
- package/lib/utils/murmurhash3.js +66 -0
- package/lib/utils/network.js +28 -0
- package/lib/utils/provider-id.js +27 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/require-tls.js +33 -0
- package/lib/utils/version.js +74 -0
- package/lib/web-safe-html.js +5 -6
- package/lib/webhook-penalty.js +75 -0
- package/lib/webhook-routing.js +49 -2
- package/lib/webhooks.js +41 -6
- package/package.json +37 -39
- package/sbom.json +7980 -1
- package/server.js +659 -455
- package/static/js/ace/ace.js +1 -1
- package/static/js/ace/mode-handlebars.js +1 -1
- package/static/js/ace/mode-html.js +1 -1
- package/static/js/ace/mode-javascript.js +1 -1
- package/static/js/ace/mode-markdown.js +1 -1
- package/static/js/ace/worker-html.js +1 -1
- package/static/js/ace/worker-javascript.js +1 -1
- package/static/js/ace/worker-json.js +1 -1
- package/static/js/ee-client.js +5 -0
- package/static/licenses.html +191 -1016
- package/translations/messages.pot +70 -71
- package/views/account/security.hbs +10 -0
- package/views/accounts/account.hbs +11 -11
- package/views/accounts/edit.hbs +6 -2
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +2 -2
- package/views/config/service.hbs +3 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/gateway_form.hbs +3 -1
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +780 -585
- package/workers/export.js +1 -1
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +54 -34
- package/config/test.toml +0 -46
- package/install.sh +0 -428
- package/setup-production.sh +0 -215
- package/systemd/emailengine.service +0 -97
- package/systemd/nginx-proxy.conf +0 -77
|
@@ -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 {
|
|
@@ -53,6 +53,7 @@ const TOOL_BADGES = {
|
|
|
53
53
|
const { locales } = require('../translations');
|
|
54
54
|
const { settingsSchema, formBoolean } = require('../schemas');
|
|
55
55
|
const { getExampleDocumentsPayloads, mcpToolGrants } = require('./route-helpers');
|
|
56
|
+
const { parseCustomHeaders } = require('./form-lists');
|
|
56
57
|
const { getOpenAiModels, reasoningEffortOptions, aiPageSchema, aiFieldSchema, aiFieldValues, aiFieldStrings } = require('./ai-options');
|
|
57
58
|
const { DEFAULT_INSTRUCTIONS, DEFAULT_MODEL, DEFAULT_MAX_TOKENS } = require('@postalsys/email-ai-tools');
|
|
58
59
|
|
|
@@ -202,9 +203,7 @@ async function getOpenAiError(gt) {
|
|
|
202
203
|
return openAiError;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
function
|
|
206
|
-
const { server, call } = args;
|
|
207
|
-
|
|
206
|
+
function registerConfigWebhooksPage(server) {
|
|
208
207
|
registerSettingsPage(server, {
|
|
209
208
|
path: '/admin/config/webhooks',
|
|
210
209
|
view: 'config/webhooks',
|
|
@@ -275,24 +274,6 @@ function init(args) {
|
|
|
275
274
|
},
|
|
276
275
|
|
|
277
276
|
async applySettings(request) {
|
|
278
|
-
let customHeaders = request.payload.customHeaders
|
|
279
|
-
.split(/[\r\n]+/)
|
|
280
|
-
.map(header => header.trim())
|
|
281
|
-
.filter(header => header)
|
|
282
|
-
.map(line => {
|
|
283
|
-
let sep = line.indexOf(':');
|
|
284
|
-
if (sep >= 0) {
|
|
285
|
-
return {
|
|
286
|
-
key: line.substring(0, sep).trim(),
|
|
287
|
-
value: line.substring(sep + 1).trim()
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
return {
|
|
291
|
-
key: line,
|
|
292
|
-
value: ''
|
|
293
|
-
};
|
|
294
|
-
});
|
|
295
|
-
|
|
296
277
|
const data = {
|
|
297
278
|
webhooksEnabled: request.payload.webhooksEnabled,
|
|
298
279
|
webhooks: request.payload.webhooks,
|
|
@@ -312,11 +293,14 @@ function init(args) {
|
|
|
312
293
|
notifyHeaders: (request.payload.notifyHeaders || '')
|
|
313
294
|
.split(/\r?\n/)
|
|
314
295
|
.map(line => line.toLowerCase().trim())
|
|
315
|
-
.filter(line => line)
|
|
316
|
-
|
|
317
|
-
webhooksCustomHeaders: customHeaders
|
|
296
|
+
.filter(line => line)
|
|
318
297
|
};
|
|
319
298
|
|
|
299
|
+
// Absent only from a request that did not render the field, keep the stored headers then
|
|
300
|
+
if (typeof request.payload.customHeaders === 'string') {
|
|
301
|
+
data.webhooksCustomHeaders = parseCustomHeaders(request.payload.customHeaders);
|
|
302
|
+
}
|
|
303
|
+
|
|
320
304
|
if (request.payload.notifyAll) {
|
|
321
305
|
data.webhookEvents.push('*');
|
|
322
306
|
}
|
|
@@ -333,6 +317,10 @@ function init(args) {
|
|
|
333
317
|
}
|
|
334
318
|
}
|
|
335
319
|
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function registerConfigServicePage(server, args) {
|
|
323
|
+
const { call } = args;
|
|
336
324
|
|
|
337
325
|
registerSettingsPage(server, {
|
|
338
326
|
path: '/admin/config/service',
|
|
@@ -369,11 +357,7 @@ function init(args) {
|
|
|
369
357
|
return {
|
|
370
358
|
locales: locales.map(locale => Object.assign({ selected: locale.locale === values.locale }, locale)),
|
|
371
359
|
|
|
372
|
-
timezones:
|
|
373
|
-
name: entry.label,
|
|
374
|
-
timezone: entry.tzCode,
|
|
375
|
-
selected: entry.tzCode === values.timezone
|
|
376
|
-
}))
|
|
360
|
+
timezones: timezoneOptions(values.timezone)
|
|
377
361
|
};
|
|
378
362
|
},
|
|
379
363
|
|
|
@@ -389,6 +373,14 @@ function init(args) {
|
|
|
389
373
|
// write would leave the old URL in place after a save meant to clear it
|
|
390
374
|
data.serviceUrl = request.payload.serviceUrl ? new URL(request.payload.serviceUrl).origin : null;
|
|
391
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
|
+
|
|
392
384
|
// Compared before the write, and only for the reload: this form submits the service URL
|
|
393
385
|
// on every save, so reloading on the write alone would hand three listeners a new
|
|
394
386
|
// certificate every time somebody changed the timezone.
|
|
@@ -403,7 +395,9 @@ function init(args) {
|
|
|
403
395
|
await maybeReloadTlsCertificates(call, request.logger, serviceUrlChanged ? ['serviceUrl'] : [], { action: 'settings' });
|
|
404
396
|
}
|
|
405
397
|
});
|
|
398
|
+
}
|
|
406
399
|
|
|
400
|
+
function registerConfigSecurityPage(server) {
|
|
407
401
|
registerSettingsPage(server, {
|
|
408
402
|
path: '/admin/config/security',
|
|
409
403
|
view: 'config/security',
|
|
@@ -460,7 +454,9 @@ function init(args) {
|
|
|
460
454
|
await settings.setMulti(data);
|
|
461
455
|
}
|
|
462
456
|
});
|
|
457
|
+
}
|
|
463
458
|
|
|
459
|
+
function registerConfigEmailProcessingPage(server) {
|
|
464
460
|
registerSettingsPage(server, {
|
|
465
461
|
path: '/admin/config/email-processing',
|
|
466
462
|
view: 'config/email-processing',
|
|
@@ -551,7 +547,9 @@ function init(args) {
|
|
|
551
547
|
});
|
|
552
548
|
}
|
|
553
549
|
});
|
|
550
|
+
}
|
|
554
551
|
|
|
552
|
+
function registerConfigBrandingPage(server) {
|
|
555
553
|
registerSettingsPage(server, {
|
|
556
554
|
path: '/admin/config/branding',
|
|
557
555
|
view: 'config/branding',
|
|
@@ -581,7 +579,9 @@ function init(args) {
|
|
|
581
579
|
});
|
|
582
580
|
}
|
|
583
581
|
});
|
|
582
|
+
}
|
|
584
583
|
|
|
584
|
+
function registerConfigMcpPage(server) {
|
|
585
585
|
registerSettingsPage(server, {
|
|
586
586
|
path: '/admin/config/mcp',
|
|
587
587
|
view: 'config/mcp',
|
|
@@ -698,7 +698,9 @@ function init(args) {
|
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
700
|
});
|
|
701
|
+
}
|
|
701
702
|
|
|
703
|
+
function registerConfigAiPage(server) {
|
|
702
704
|
registerSettingsPage(server, {
|
|
703
705
|
path: '/admin/config/ai',
|
|
704
706
|
view: 'config/ai',
|
|
@@ -787,6 +789,10 @@ function init(args) {
|
|
|
787
789
|
}
|
|
788
790
|
}
|
|
789
791
|
});
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
function registerPostConfigAiTestPrompt(server, args) {
|
|
795
|
+
const { call } = args;
|
|
790
796
|
|
|
791
797
|
server.route({
|
|
792
798
|
method: 'POST',
|
|
@@ -853,6 +859,10 @@ function init(args) {
|
|
|
853
859
|
}
|
|
854
860
|
}
|
|
855
861
|
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function registerPostConfigAiReloadModels(server, args) {
|
|
865
|
+
const { call } = args;
|
|
856
866
|
|
|
857
867
|
server.route({
|
|
858
868
|
method: 'POST',
|
|
@@ -861,6 +871,8 @@ function init(args) {
|
|
|
861
871
|
try {
|
|
862
872
|
request.logger.info({ msg: 'Reload models' });
|
|
863
873
|
|
|
874
|
+
// without a key in the form the stored key is used, and then the URL has to be the
|
|
875
|
+
// stored one as well; aiRequestOptions() in server.js refuses the other case
|
|
864
876
|
const { models } = await call({
|
|
865
877
|
cmd: 'openAiListModels',
|
|
866
878
|
data: {
|
|
@@ -904,7 +916,9 @@ function init(args) {
|
|
|
904
916
|
}
|
|
905
917
|
}
|
|
906
918
|
});
|
|
919
|
+
}
|
|
907
920
|
|
|
921
|
+
function registerPostConfigBrandingPreview(server) {
|
|
908
922
|
server.route({
|
|
909
923
|
method: 'POST',
|
|
910
924
|
path: '/admin/config/branding/preview',
|
|
@@ -942,7 +956,9 @@ function init(args) {
|
|
|
942
956
|
}
|
|
943
957
|
}
|
|
944
958
|
});
|
|
959
|
+
}
|
|
945
960
|
|
|
961
|
+
function registerPostConfigClearError(server) {
|
|
946
962
|
server.route({
|
|
947
963
|
method: 'POST',
|
|
948
964
|
path: '/admin/config/clear-error',
|
|
@@ -1001,7 +1017,9 @@ function init(args) {
|
|
|
1001
1017
|
}
|
|
1002
1018
|
}
|
|
1003
1019
|
});
|
|
1020
|
+
}
|
|
1004
1021
|
|
|
1022
|
+
function registerPostConfigServiceClean(server) {
|
|
1005
1023
|
server.route({
|
|
1006
1024
|
method: 'POST',
|
|
1007
1025
|
path: '/admin/config/service/clean',
|
|
@@ -1036,7 +1054,9 @@ function init(args) {
|
|
|
1036
1054
|
}
|
|
1037
1055
|
}
|
|
1038
1056
|
});
|
|
1057
|
+
}
|
|
1039
1058
|
|
|
1059
|
+
function registerConfigLoggingPage(server) {
|
|
1040
1060
|
registerSettingsPage(server, {
|
|
1041
1061
|
path: '/admin/config/logging',
|
|
1042
1062
|
view: 'config/logging',
|
|
@@ -1089,6 +1109,10 @@ function init(args) {
|
|
|
1089
1109
|
await settings.setMulti(data);
|
|
1090
1110
|
}
|
|
1091
1111
|
});
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
function registerPostConfigLoggingReconnect(server, args) {
|
|
1115
|
+
const { call } = args;
|
|
1092
1116
|
|
|
1093
1117
|
server.route({
|
|
1094
1118
|
method: 'POST',
|
|
@@ -1136,7 +1160,9 @@ function init(args) {
|
|
|
1136
1160
|
}
|
|
1137
1161
|
}
|
|
1138
1162
|
});
|
|
1163
|
+
}
|
|
1139
1164
|
|
|
1165
|
+
function registerPostConfigWebhooksTest(server) {
|
|
1140
1166
|
server.route({
|
|
1141
1167
|
method: 'POST',
|
|
1142
1168
|
path: '/admin/config/webhooks/test',
|
|
@@ -1160,23 +1186,7 @@ function init(args) {
|
|
|
1160
1186
|
headers.Authorization = authorization;
|
|
1161
1187
|
}
|
|
1162
1188
|
|
|
1163
|
-
let customHeaders = request.payload.customHeaders
|
|
1164
|
-
.split(/[\r\n]+/)
|
|
1165
|
-
.map(header => header.trim())
|
|
1166
|
-
.filter(header => header)
|
|
1167
|
-
.map(line => {
|
|
1168
|
-
let sep = line.indexOf(':');
|
|
1169
|
-
if (sep >= 0) {
|
|
1170
|
-
return {
|
|
1171
|
-
key: line.substring(0, sep).trim(),
|
|
1172
|
-
value: line.substring(sep + 1).trim()
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
|
-
return {
|
|
1176
|
-
key: line,
|
|
1177
|
-
value: ''
|
|
1178
|
-
};
|
|
1179
|
-
});
|
|
1189
|
+
let customHeaders = parseCustomHeaders(request.payload.customHeaders);
|
|
1180
1190
|
|
|
1181
1191
|
customHeaders.forEach(header => {
|
|
1182
1192
|
headers[header.key] = header.value;
|
|
@@ -1273,8 +1283,12 @@ function init(args) {
|
|
|
1273
1283
|
}
|
|
1274
1284
|
}
|
|
1275
1285
|
});
|
|
1286
|
+
}
|
|
1276
1287
|
|
|
1277
|
-
|
|
1288
|
+
// Webhook, template, gateway, and token routes are in admin-entities-routes.js
|
|
1289
|
+
|
|
1290
|
+
function registerGetConfigLicense(server, args) {
|
|
1291
|
+
const { call } = args;
|
|
1278
1292
|
|
|
1279
1293
|
server.route({
|
|
1280
1294
|
method: 'GET',
|
|
@@ -1310,6 +1324,10 @@ function init(args) {
|
|
|
1310
1324
|
);
|
|
1311
1325
|
}
|
|
1312
1326
|
});
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
function registerPostConfigLicense(server, args) {
|
|
1330
|
+
const { call } = args;
|
|
1313
1331
|
|
|
1314
1332
|
server.route({
|
|
1315
1333
|
method: 'POST',
|
|
@@ -1409,6 +1427,10 @@ function init(args) {
|
|
|
1409
1427
|
}
|
|
1410
1428
|
}
|
|
1411
1429
|
});
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
function registerPostConfigLicenseDelete(server, args) {
|
|
1433
|
+
const { call } = args;
|
|
1412
1434
|
|
|
1413
1435
|
server.route({
|
|
1414
1436
|
method: 'POST',
|
|
@@ -1450,6 +1472,10 @@ function init(args) {
|
|
|
1450
1472
|
}
|
|
1451
1473
|
}
|
|
1452
1474
|
});
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
function registerPostConfigLicenseTrial(server, args) {
|
|
1478
|
+
const { call } = args;
|
|
1453
1479
|
|
|
1454
1480
|
server.route({
|
|
1455
1481
|
method: 'POST',
|
|
@@ -1527,4 +1553,28 @@ ${Buffer.from(data.content, 'base64url').toString('base64')}
|
|
|
1527
1553
|
});
|
|
1528
1554
|
}
|
|
1529
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
|
+
|
|
1530
1580
|
module.exports = init;
|