emailengine-app 2.79.8 → 2.80.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/dependabot.yml +22 -0
- package/.github/workflows/test.yml +39 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +69 -0
- package/DOCKER_DEPLOYMENT.md +6 -7
- package/Dockerfile +35 -11
- package/config/default.toml +7 -2
- package/copy-static-files.sh +23 -5
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +43 -0
- package/lib/account/account-state.js +62 -0
- package/lib/account.js +60 -3
- package/lib/api-routes/account-routes.js +20 -0
- package/lib/api-routes/bull-board-routes.js +3 -2
- package/lib/api-routes/index.js +1 -1
- package/lib/api-routes/route-helpers.js +8 -0
- package/lib/api-routes/settings-routes.js +17 -2
- package/lib/auth-token.js +73 -2
- package/lib/autodetect-imap-settings.js +379 -69
- package/lib/cert-handler.js +62 -0
- package/lib/consts.js +58 -7
- package/lib/db.js +12 -0
- package/lib/egress-fetch.js +145 -0
- package/lib/email-client/base-client.js +234 -66
- package/lib/email-client/credential-errors.js +118 -0
- package/lib/email-client/gmail/gmail-api.js +2 -1
- package/lib/email-client/gmail-client.js +70 -64
- package/lib/email-client/imap/connection-errors.js +52 -0
- package/lib/email-client/imap/listing-diff.js +47 -6
- package/lib/email-client/imap/mailbox.js +457 -379
- package/lib/email-client/imap/subconnection.js +15 -11
- package/lib/email-client/imap/sync-operations.js +46 -59
- package/lib/email-client/imap-client.js +136 -95
- package/lib/email-client/message-builder.js +11 -11
- package/lib/email-client/outlook/graph-api.js +2 -1
- package/lib/email-client/outlook-client.js +219 -106
- package/lib/export.js +35 -2
- package/lib/handlebars-helpers.js +129 -0
- package/lib/imap-proxy-auth.js +96 -21
- package/lib/imapproxy/imap-core/README.md +1 -0
- package/lib/imapproxy/imap-core/lib/tls-options.js +5 -46
- package/lib/imapproxy/imap-server.js +56 -66
- package/lib/lua/h-del-if-equals.lua +39 -0
- package/lib/lua/h-set-if-equals.lua +39 -0
- package/lib/openapi/index.js +3 -0
- package/lib/outbox.js +28 -3
- package/lib/rate-limit.js +23 -4
- package/lib/routes-ui.js +4 -34
- package/lib/schemas.js +42 -3
- package/lib/security-headers.js +411 -0
- package/lib/sentry.js +36 -4
- package/lib/smtp-auth.js +86 -7
- package/lib/tls/context.js +376 -0
- package/lib/tls/der.js +223 -0
- package/lib/tls/provision.js +555 -0
- package/lib/tls/self-signed.js +282 -0
- package/lib/tls/status.js +431 -0
- package/lib/tls/store.js +666 -0
- package/lib/tools.js +337 -147
- package/lib/ui-routes/account-routes.js +47 -33
- package/lib/ui-routes/admin-config-routes.js +22 -1
- package/lib/ui-routes/auth-routes.js +16 -1
- package/lib/ui-routes/export-routes.js +4 -0
- package/lib/ui-routes/internals-routes.js +3 -5
- package/lib/ui-routes/mcp-consent-routes.js +7 -0
- package/lib/ui-routes/network-config-routes.js +58 -48
- package/lib/ui-routes/route-helpers.js +24 -8
- package/lib/ui-routes/smtp-test-routes.js +7 -0
- package/lib/ui-routes/tls-config-routes.js +581 -0
- package/lib/utils/mailbox-path.js +51 -0
- package/lib/utils/severity.js +31 -0
- package/lib/webhook-egress.js +5 -0
- package/package.json +21 -24
- package/sbom.json +1 -1
- package/server.js +53 -36
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +11 -0
- package/static/js/ace/css/ace.css +1462 -0
- package/static/js/ace/css/kuroir-1.png +0 -0
- package/static/js/ace/css/kuroir-2.png +0 -0
- package/static/js/ace/css/main-1.png +0 -0
- package/static/js/ace/css/main-10.svg +4 -0
- package/static/js/ace/css/main-11.svg +5 -0
- package/static/js/ace/css/main-12.svg +4 -0
- package/static/js/ace/css/main-13.png +0 -0
- package/static/js/ace/css/main-14.png +0 -0
- package/static/js/ace/css/main-15.png +0 -0
- package/static/js/ace/css/main-16.png +0 -0
- package/static/js/ace/css/main-17.png +0 -0
- package/static/js/ace/css/main-18.png +0 -0
- package/static/js/ace/css/main-19.png +0 -0
- package/static/js/ace/css/main-2.png +0 -0
- package/static/js/ace/css/main-20.png +0 -0
- package/static/js/ace/css/main-21.png +0 -0
- package/static/js/ace/css/main-22.png +0 -0
- package/static/js/ace/css/main-23.png +0 -0
- package/static/js/ace/css/main-24.png +0 -0
- package/static/js/ace/css/main-25.svg +1 -0
- package/static/js/ace/css/main-26.png +0 -0
- package/static/js/ace/css/main-3.png +0 -0
- package/static/js/ace/css/main-4.png +0 -0
- package/static/js/ace/css/main-5.svg +7 -0
- package/static/js/ace/css/main-6.svg +9 -0
- package/static/js/ace/css/main-7.svg +7 -0
- package/static/js/ace/css/main-8.svg +9 -0
- package/static/js/ace/css/main-9.svg +6 -0
- package/static/js/ace/css/theme/kuroir.css +78 -0
- package/static/js/ace/css/theme/tomorrow_night.css +128 -0
- package/static/js/ace/css/theme/tomorrow_night_eighties.css +128 -0
- package/static/js/ace/css/theme/xcode.css +106 -0
- package/static/js/ace/css/tomorrow_night-1.png +0 -0
- package/static/js/ace/css/tomorrow_night-2.png +0 -0
- package/static/js/ace/css/tomorrow_night_eighties-1.png +0 -0
- package/static/js/ace/css/tomorrow_night_eighties-2.png +0 -0
- package/static/js/ace/css/xcode-1.png +0 -0
- package/static/js/ace/css/xcode-2.png +0 -0
- package/static/js/app.js +34 -0
- package/static/js/ee-client.js +256 -102
- package/static/js/public.js +13 -2
- package/static/js/ui.js +40 -25
- package/static/licenses.html +393 -1282
- package/static/vendor/simplewebauthn/browser.min.js +2 -2
- package/translations/messages.pot +203 -157
- package/views/account/login-redirect.hbs +22 -0
- package/views/accounts/account.hbs +15 -37
- package/views/accounts/browse.hbs +3 -1
- package/views/accounts/edit.hbs +1 -1
- package/views/accounts/register/imap-server.hbs +1 -1
- package/views/config/ai.hbs +1 -1
- package/views/config/branding.hbs +2 -2
- package/views/config/document-store/chat.hbs +1 -1
- package/views/config/document-store/index.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -4
- package/views/config/license.hbs +1 -1
- package/views/config/mcp.hbs +1 -1
- package/views/config/network.hbs +14 -16
- package/views/config/oauth/app.hbs +2 -2
- package/views/config/service.hbs +1 -1
- package/views/config/smtp.hbs +1 -4
- package/views/config/tls-upload.hbs +81 -0
- package/views/config/tls.hbs +492 -0
- package/views/config/webhooks.hbs +2 -2
- package/views/error.hbs +4 -2
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +3 -11
- package/views/mcp/authorize.hbs +1 -1
- package/views/partials/ace_assets.hbs +13 -0
- package/views/partials/add_account_modal.hbs +1 -1
- package/views/partials/address_list.hbs +4 -4
- package/views/partials/filter_editor_js.hbs +2 -2
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/oauth_form.hbs +1 -1
- package/views/partials/public_theme_init.hbs +1 -1
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/template_form.hbs +2 -2
- package/views/partials/test_send.hbs +7 -4
- package/views/partials/theme_init.hbs +1 -1
- package/views/partials/tls_security_card.hbs +25 -53
- package/views/partials/ui/alert-banner.hbs +3 -2
- package/views/partials/ui/badge.hbs +6 -2
- package/views/partials/ui/btn.hbs +5 -2
- package/views/partials/ui/details.hbs +2 -2
- package/views/partials/webhooks_editor_functions.hbs +1 -1
- package/views/reference/redirect.hbs +1 -1
- package/views/templates/template.hbs +2 -2
- package/views/tokens/new.hbs +1 -1
- package/views/unsubscribe.hbs +1 -1
- package/views/webhooks/webhook.hbs +2 -2
- package/workers/api.js +131 -242
- package/workers/export.js +1 -5
- package/workers/imap-proxy.js +4 -1
- package/workers/imap.js +1 -3
- package/workers/smtp.js +59 -83
- package/workers/submit.js +6 -12
- package/workers/webhooks.js +6 -17
- package/static/front/EmailEngine_logo_horiz.png +0 -0
- package/static/front/EmailEngine_logo_vert.png +0 -0
- package/static/front/index.html +0 -57
- package/static/front/logo.png +0 -0
- package/static/vendor/handlebars/handlebars.min-v4.7.9.js +0 -29
- package/views/partials/tls_security_js.hbs +0 -64
- package/views/partials/tls_security_modal.hbs +0 -22
package/server.js
CHANGED
|
@@ -30,11 +30,12 @@ try {
|
|
|
30
30
|
// Set process title for easier identification in process lists
|
|
31
31
|
process.title = 'emailengine';
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
// EmailEngine and its dependencies need Node 20 or newer, the same floor the engines field in
|
|
34
|
+
// package.json declares. Checked before anything is required, so an older runtime gets this line
|
|
35
|
+
// instead of a syntax error from a dependency. The check used to be a structuredClone probe, which
|
|
36
|
+
// only caught Node 16 and older.
|
|
37
|
+
if (Number(process.versions.node.split('.')[0]) < 20) {
|
|
38
|
+
console.error(`Node.js version ${process.version} is not supported. Please upgrade to Node.js 20 or later.`);
|
|
38
39
|
process.exit(1);
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -1075,7 +1076,8 @@ async function sendWebhook(account, event, data) {
|
|
|
1075
1076
|
* Spawn a new worker thread of the specified type
|
|
1076
1077
|
* @param {string} type - Worker type (imap, api, webhooks, submit, documents, smtp, imapProxy)
|
|
1077
1078
|
* @param {Object} [opts] - Optional spawn options
|
|
1078
|
-
* @param {Object} [opts.workerData] - Data passed to the worker thread (e.g. API worker index)
|
|
1079
|
+
* @param {Object} [opts.workerData] - Data passed to the worker thread (e.g. API worker index). The
|
|
1080
|
+
* proxy in effect is added for every type, see lib/tools.js
|
|
1079
1081
|
* @returns {Promise<number|void>} Thread ID if successful
|
|
1080
1082
|
*/
|
|
1081
1083
|
let spawnWorker = async (type, opts) => {
|
|
@@ -1113,7 +1115,9 @@ let spawnWorker = async (type, opts) => {
|
|
|
1113
1115
|
let worker = new WorkerThread(pathlib.join(__dirname, 'workers', `${type.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`)}.js`), {
|
|
1114
1116
|
argv,
|
|
1115
1117
|
env: SHARE_ENV,
|
|
1116
|
-
|
|
1118
|
+
// every worker builds its HTTP dispatchers from the proxy in effect before its first line of
|
|
1119
|
+
// code runs (lib/tools.js); this thread resolved it from settings before spawning anything
|
|
1120
|
+
workerData: Object.assign({ httpProxyUrl: httpAgent.proxyUrl }, opts && opts.workerData),
|
|
1117
1121
|
trackUnmanagedFds: true
|
|
1118
1122
|
});
|
|
1119
1123
|
metrics.threadStarts.inc();
|
|
@@ -1502,18 +1506,19 @@ let spawnWorker = async (type, opts) => {
|
|
|
1502
1506
|
}
|
|
1503
1507
|
});
|
|
1504
1508
|
|
|
1505
|
-
// Forward settings changes to
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
if (
|
|
1509
|
-
|
|
1510
|
-
try {
|
|
1511
|
-
postMessage(worker, message);
|
|
1512
|
-
} catch (err) {
|
|
1513
|
-
logger.error({ msg: 'Unable to forward settings to worker', type, worker: worker.threadId, err });
|
|
1514
|
-
}
|
|
1515
|
-
});
|
|
1509
|
+
// Forward settings changes to every other worker type (the IMAP workers were
|
|
1510
|
+
// handled above); each reloads its HTTP proxy agent from the 'settings' message
|
|
1511
|
+
for (let [type, typeWorkers] of workers) {
|
|
1512
|
+
if (type === 'imap') {
|
|
1513
|
+
continue;
|
|
1516
1514
|
}
|
|
1515
|
+
typeWorkers.forEach(worker => {
|
|
1516
|
+
try {
|
|
1517
|
+
postMessage(worker, message);
|
|
1518
|
+
} catch (err) {
|
|
1519
|
+
logger.error({ msg: 'Unable to forward settings to worker', type, worker: worker.threadId, err });
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1517
1522
|
}
|
|
1518
1523
|
return;
|
|
1519
1524
|
|
|
@@ -2368,6 +2373,14 @@ async function updateQueueCounters() {
|
|
|
2368
2373
|
* @param {Object} message - Command message
|
|
2369
2374
|
* @returns {Promise<*>} Command result
|
|
2370
2375
|
*/
|
|
2376
|
+
// Options shared by every OpenAI call. A function rather than a constant because httpAgent.fetch is
|
|
2377
|
+
// swapped when the proxy settings change. The plain agent rather than the retrying one: the library
|
|
2378
|
+
// keeps its own 429 retry.
|
|
2379
|
+
const openAiRequestOpts = () => ({
|
|
2380
|
+
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE),
|
|
2381
|
+
dispatcher: httpAgent.fetch
|
|
2382
|
+
});
|
|
2383
|
+
|
|
2371
2384
|
async function onCommand(worker, message) {
|
|
2372
2385
|
switch (message.cmd) {
|
|
2373
2386
|
case 'metrics':
|
|
@@ -2528,9 +2541,7 @@ async function onCommand(worker, message) {
|
|
|
2528
2541
|
|
|
2529
2542
|
// OpenAI integration commands - run in main process to avoid memory overhead
|
|
2530
2543
|
case 'generateSummary': {
|
|
2531
|
-
let requestOpts =
|
|
2532
|
-
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
|
|
2533
|
-
};
|
|
2544
|
+
let requestOpts = openAiRequestOpts();
|
|
2534
2545
|
|
|
2535
2546
|
let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
|
|
2536
2547
|
|
|
@@ -2588,9 +2599,7 @@ async function onCommand(worker, message) {
|
|
|
2588
2599
|
}
|
|
2589
2600
|
|
|
2590
2601
|
case 'generateEmbeddings': {
|
|
2591
|
-
let requestOpts =
|
|
2592
|
-
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
|
|
2593
|
-
};
|
|
2602
|
+
let requestOpts = openAiRequestOpts();
|
|
2594
2603
|
|
|
2595
2604
|
let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
|
|
2596
2605
|
|
|
@@ -2623,9 +2632,7 @@ async function onCommand(worker, message) {
|
|
|
2623
2632
|
}
|
|
2624
2633
|
|
|
2625
2634
|
case 'embeddingsQuery': {
|
|
2626
|
-
let requestOpts =
|
|
2627
|
-
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
|
|
2628
|
-
};
|
|
2635
|
+
let requestOpts = openAiRequestOpts();
|
|
2629
2636
|
|
|
2630
2637
|
let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
|
|
2631
2638
|
|
|
@@ -2694,9 +2701,7 @@ async function onCommand(worker, message) {
|
|
|
2694
2701
|
}
|
|
2695
2702
|
|
|
2696
2703
|
case 'questionQuery': {
|
|
2697
|
-
let requestOpts =
|
|
2698
|
-
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
|
|
2699
|
-
};
|
|
2704
|
+
let requestOpts = openAiRequestOpts();
|
|
2700
2705
|
|
|
2701
2706
|
let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
|
|
2702
2707
|
|
|
@@ -2729,9 +2734,7 @@ async function onCommand(worker, message) {
|
|
|
2729
2734
|
}
|
|
2730
2735
|
|
|
2731
2736
|
case 'generateChunkEmbeddings': {
|
|
2732
|
-
let requestOpts =
|
|
2733
|
-
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
|
|
2734
|
-
};
|
|
2737
|
+
let requestOpts = openAiRequestOpts();
|
|
2735
2738
|
|
|
2736
2739
|
let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
|
|
2737
2740
|
|
|
@@ -2752,9 +2755,7 @@ async function onCommand(worker, message) {
|
|
|
2752
2755
|
}
|
|
2753
2756
|
|
|
2754
2757
|
case 'openAiListModels': {
|
|
2755
|
-
let requestOpts =
|
|
2756
|
-
verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
|
|
2757
|
-
};
|
|
2758
|
+
let requestOpts = openAiRequestOpts();
|
|
2758
2759
|
|
|
2759
2760
|
let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
|
|
2760
2761
|
|
|
@@ -2919,6 +2920,22 @@ async function onCommand(worker, message) {
|
|
|
2919
2920
|
}
|
|
2920
2921
|
break;
|
|
2921
2922
|
|
|
2923
|
+
case 'apiReloadCertificates':
|
|
2924
|
+
case 'smtpReloadCertificates':
|
|
2925
|
+
case 'imapProxyReloadCertificates':
|
|
2926
|
+
{
|
|
2927
|
+
// A renewed certificate, handed to a running listener. Forwarded to the worker
|
|
2928
|
+
// rather than terminating it: a restart would cut every session in flight, and
|
|
2929
|
+
// every listener can swap its secure context between handshakes. Sent to every
|
|
2930
|
+
// worker of the type, not just the one that ordered the certificate: the
|
|
2931
|
+
// reconciler is a singleton but the listeners are not.
|
|
2932
|
+
let type = message.cmd.replace(/ReloadCertificates$/, '');
|
|
2933
|
+
for (let worker of (workers.get(type) || new Set()).values()) {
|
|
2934
|
+
call(worker, message).catch(err => logger.error({ msg: 'Failed to reload certificates', type, worker: worker.threadId, err }));
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
break;
|
|
2938
|
+
|
|
2922
2939
|
// IMAP operations - forward to assigned worker
|
|
2923
2940
|
case 'submitMessage':
|
|
2924
2941
|
case 'queueMessage':
|