emailengine-app 2.84.1 → 2.84.2
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +28 -0
- package/Dockerfile +2 -2
- package/bin/emailengine.js +15 -0
- package/data/google-crawlers.json +1 -1
- package/docker-compose.yml +1 -1
- package/lib/account/own-account-key.js +42 -0
- package/lib/account-assignment.js +1 -33
- package/lib/account.js +32 -19
- package/lib/add-trackers.js +11 -4
- package/lib/api-routes/account-routes.js +67 -14
- package/lib/api-routes/gateway-routes.js +9 -3
- package/lib/api-routes/message-routes.js +7 -1
- package/lib/api-routes/mint-bounds.js +11 -0
- package/lib/api-routes/route-helpers.js +125 -3
- package/lib/api-routes/submit-routes.js +4 -2
- package/lib/auth-token.js +23 -10
- package/lib/bounce-detect.js +17 -5
- package/lib/consts.js +34 -0
- package/lib/create-imap-client.js +41 -2
- package/lib/email-client/base-client.js +20 -10
- package/lib/email-client/gmail-client.js +21 -7
- package/lib/email-client/imap/mailbox.js +10 -4
- package/lib/email-client/imap/response-metrics.js +75 -0
- package/lib/email-client/imap-client.js +5 -2
- package/lib/email-client/message-builder.js +7 -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/get-raw-email.js +4 -2
- package/lib/imap-proxy-auth.js +14 -1
- 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/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.js +26 -44
- package/lib/pbkdf2-phc.js +18 -1
- package/lib/privileged-settings.js +6 -3
- package/lib/redis-scan-delete.js +15 -1
- package/lib/schemas.js +78 -32
- package/lib/settings.js +13 -1
- package/lib/smtp-auth.js +23 -0
- package/lib/tools.js +245 -56
- package/lib/ui-routes/account-routes.js +16 -37
- package/lib/ui-routes/admin-config-routes.js +10 -38
- package/lib/ui-routes/admin-entities-routes.js +22 -24
- package/lib/ui-routes/auth-routes.js +47 -24
- package/lib/ui-routes/connection-security-form.js +74 -0
- package/lib/ui-routes/form-lists.js +46 -0
- package/lib/ui-routes/mcp-consent-routes.js +5 -1
- package/lib/ui-routes/oauth-config-routes.js +9 -18
- package/lib/ui-routes/sign-in-helpers.js +59 -0
- package/lib/ui-routes/unsubscribe-routes.js +6 -3
- package/lib/utils/map-concurrent.js +36 -0
- package/lib/utils/network.js +28 -0
- package/lib/utils/provider-id.js +27 -0
- package/lib/utils/require-tls.js +33 -0
- package/lib/web-safe-html.js +5 -6
- package/lib/webhook-penalty.js +75 -0
- package/lib/webhook-routing.js +22 -2
- package/package.json +21 -21
- package/sbom.json +1 -1
- package/server.js +25 -14
- 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 +23 -23
- package/translations/messages.pot +66 -66
- package/views/account/security.hbs +10 -0
- package/views/accounts/account.hbs +11 -11
- package/views/accounts/edit.hbs +6 -2
- package/views/partials/gateway_form.hbs +3 -1
- package/workers/api.js +43 -3
- package/workers/webhooks.js +39 -3
- 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
package/server.js
CHANGED
|
@@ -20,19 +20,23 @@
|
|
|
20
20
|
// same way. Set before anything can require bullmq; worker threads share this environment.
|
|
21
21
|
process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED = 'true';
|
|
22
22
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Attempt to change working directory to script location
|
|
23
|
+
// Attempt to change working directory to script location. Before anything reads a file by a
|
|
24
|
+
// relative path: `.env` below and the `config/` directory wild-config loads (including executable
|
|
25
|
+
// `.js` configuration files, run with the real require) are both resolved against the working
|
|
26
|
+
// directory, and the directory the operator happened to start from is not where this instance's
|
|
27
|
+
// configuration lives
|
|
30
28
|
try {
|
|
31
29
|
process.chdir(__dirname);
|
|
32
30
|
} catch (err) {
|
|
33
31
|
// ignore - may fail in some containerized environments
|
|
34
32
|
}
|
|
35
33
|
|
|
34
|
+
// Load environment variables if not already loaded
|
|
35
|
+
if (!process.env.EE_ENV_LOADED) {
|
|
36
|
+
require('dotenv').config({ quiet: true });
|
|
37
|
+
process.env.EE_ENV_LOADED = 'true';
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
// Set process title for easier identification in process lists
|
|
37
41
|
process.title = 'emailengine';
|
|
38
42
|
|
|
@@ -146,10 +150,10 @@ const {
|
|
|
146
150
|
releaseWorkerAccounts,
|
|
147
151
|
requeueFailedAccounts,
|
|
148
152
|
forgetAccount,
|
|
149
|
-
mapConcurrent,
|
|
150
153
|
shouldRequeueFailedAssignment,
|
|
151
154
|
planRebalance
|
|
152
155
|
} = require('./lib/account-assignment');
|
|
156
|
+
const { mapConcurrent } = require('./lib/utils/map-concurrent');
|
|
153
157
|
const { RespawnTracker } = require('./lib/respawn-backoff');
|
|
154
158
|
|
|
155
159
|
const msgpack = require('./lib/msgpack');
|
|
@@ -2548,10 +2552,15 @@ const openAiRequestOpts = () => ({
|
|
|
2548
2552
|
|
|
2549
2553
|
const aiValueSet = value => value !== undefined && value !== null && value !== '';
|
|
2550
2554
|
|
|
2555
|
+
const aiUrlValue = value => (value === undefined || value === null ? '' : String(value).trim());
|
|
2556
|
+
|
|
2551
2557
|
/**
|
|
2552
2558
|
* Options for one request to the AI provider. The configuration page's test sends every field as
|
|
2553
2559
|
* its form shows it, so the test runs with what the page shows; the sync path sends none and gets
|
|
2554
|
-
* the stored settings. The key is the exception: the form leaves it blank to keep the stored one
|
|
2560
|
+
* the stored settings. The key is the exception: the form leaves it blank to keep the stored one,
|
|
2561
|
+
* and a request made with the stored key goes to the stored URL, since a write-only secret must
|
|
2562
|
+
* not be extractable by pointing a request that falls back to it at a server of one's own. The
|
|
2563
|
+
* rule is here rather than on the page's routes so every request the form can make is under it
|
|
2555
2564
|
* @param {Object} data - The command's data
|
|
2556
2565
|
* @returns {Promise<{openAiAPIKey: string, requestOpts: Object}>}
|
|
2557
2566
|
*/
|
|
@@ -2563,6 +2572,9 @@ async function aiRequestOptions(data) {
|
|
|
2563
2572
|
if (!openAiAPIKey) {
|
|
2564
2573
|
throw new Error(`OpenAI API key is not configured`);
|
|
2565
2574
|
}
|
|
2575
|
+
if (data.options && !data.options.openAiAPIKey && aiUrlValue(data.options.openAiAPIUrl) !== aiUrlValue(stored.openAiAPIUrl)) {
|
|
2576
|
+
throw new Error('Enter the API key to use a different API URL');
|
|
2577
|
+
}
|
|
2566
2578
|
|
|
2567
2579
|
const requestOpts = openAiRequestOpts();
|
|
2568
2580
|
requestOpts.gptModel = aiValueSet(values.openAiModel) ? values.openAiModel : openAiDefaultModel;
|
|
@@ -3454,11 +3466,10 @@ const startApplication = async () => {
|
|
|
3454
3466
|
await settings.set('enableApiProxy', HAS_API_PROXY_SET ? API_PROXY : true);
|
|
3455
3467
|
}
|
|
3456
3468
|
|
|
3457
|
-
// Service settings
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
}
|
|
3469
|
+
// Service settings. HSETNX rather than read-then-write: a stored secret that does not decrypt
|
|
3470
|
+
// (the wrong EENGINE_SECRET) reads as null, and overwriting it would destroy a value the
|
|
3471
|
+
// rotation CLI can still recover once the right secret is back
|
|
3472
|
+
await settings.setIfMissing('serviceSecret', crypto.randomBytes(16).toString('hex'));
|
|
3462
3473
|
|
|
3463
3474
|
let existingQueueKeep = await settings.get('queueKeep');
|
|
3464
3475
|
if (existingQueueKeep === null) {
|