emailengine-app 2.79.7 → 2.79.9
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 +37 -0
- package/DOCKER_DEPLOYMENT.md +8 -7
- package/Dockerfile +35 -11
- package/bin/emailengine.js +29 -13
- package/config/default.toml +15 -4
- package/copy-static-files.sh +23 -5
- package/data/google-crawlers.json +7 -1
- package/docker-compose.yml +12 -3
- package/install.sh +2 -0
- package/lib/account.js +26 -1
- package/lib/api-routes/account-routes.js +14 -3
- package/lib/api-routes/bull-board-routes.js +3 -2
- package/lib/api-routes/mailbox-routes.js +4 -1
- package/lib/api-routes/message-routes.js +6 -5
- package/lib/api-routes/outbox-routes.js +7 -4
- package/lib/api-routes/route-helpers.js +8 -0
- package/lib/api-routes/settings-routes.js +34 -25
- package/lib/api-routes/stats-routes.js +8 -1
- package/lib/api-routes/submit-routes.js +2 -1
- package/lib/api-routes/template-routes.js +3 -2
- package/lib/auth-token.js +73 -2
- package/lib/autodetect-imap-settings.js +33 -25
- package/lib/bounce-detect.js +45 -0
- package/lib/consts.js +13 -2
- package/lib/egress-fetch.js +133 -0
- package/lib/egress-filter.js +39 -4
- package/lib/email-client/base-client.js +274 -24
- package/lib/email-client/gmail/gmail-api.js +15 -7
- package/lib/email-client/gmail-client.js +121 -64
- package/lib/email-client/imap/mailbox.js +18 -59
- package/lib/email-client/imap-client.js +53 -29
- package/lib/email-client/notification-handler.js +11 -2
- package/lib/email-client/outlook/graph-api.js +106 -90
- package/lib/email-client/outlook-client.js +222 -106
- package/lib/export.js +35 -2
- package/lib/generate-text-preview.js +10 -5
- package/lib/handlebars-helpers.js +129 -0
- package/lib/headers-rewriter.js +1 -1
- package/lib/imap-proxy-auth.js +41 -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 +9 -10
- package/lib/llm-pre-process.js +4 -1
- package/lib/mcp/json-schema.js +50 -2
- package/lib/openapi/index.js +3 -0
- package/lib/outbox.js +50 -8
- package/lib/pre-process.js +4 -1
- package/lib/rate-limit.js +23 -4
- package/lib/rewrite-text-nodes.js +12 -1
- package/lib/schemas.js +37 -8
- package/lib/security-headers.js +396 -0
- package/lib/sentry.js +36 -4
- package/lib/settings.js +19 -1
- package/lib/smtp-auth.js +86 -7
- package/lib/sso.js +13 -3
- package/lib/submit-progress.js +29 -0
- package/lib/templates.js +11 -0
- package/lib/tools.js +361 -173
- package/lib/ui-routes/account-routes.js +73 -13
- package/lib/ui-routes/admin-config-routes.js +7 -21
- package/lib/ui-routes/admin-entities-routes.js +42 -12
- package/lib/ui-routes/auth-routes.js +87 -28
- package/lib/ui-routes/dashboard-routes.js +1 -1
- package/lib/ui-routes/export-routes.js +4 -0
- package/lib/ui-routes/internals-routes.js +2 -0
- package/lib/ui-routes/mcp-consent-routes.js +12 -2
- package/lib/ui-routes/network-config-routes.js +6 -5
- package/lib/ui-routes/oauth-config-routes.js +12 -1
- package/lib/ui-routes/route-helpers.js +65 -14
- package/lib/ui-routes/settings-page.js +10 -0
- package/lib/ui-routes/smtp-test-routes.js +7 -0
- package/lib/ui-routes/suppression-list-routes.js +16 -5
- package/lib/ui-routes/unsubscribe-routes.js +22 -3
- package/lib/webhook-egress.js +5 -0
- package/lib/webhooks.js +14 -2
- package/package.json +23 -26
- package/sbom.json +1 -1
- package/server.js +100 -71
- package/static/css/flyonui.css +1 -1
- 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/ee-client.js +256 -102
- package/static/js/public.js +7 -0
- package/static/js/ui.js +32 -0
- package/static/licenses.html +338 -298
- package/static/vendor/simplewebauthn/browser.min.js +2 -2
- package/translations/messages.pot +158 -112
- package/views/account/passkeys.hbs +8 -0
- package/views/account/password.hbs +11 -0
- package/views/account/security.hbs +18 -7
- package/views/accounts/account.hbs +21 -38
- package/views/accounts/browse.hbs +3 -1
- package/views/accounts/edit.hbs +1 -1
- package/views/accounts/register/imap-server.hbs +11 -3
- package/views/config/ai.hbs +3 -1
- package/views/config/branding.hbs +4 -2
- package/views/config/document-store/chat.hbs +1 -1
- package/views/config/document-store/index.hbs +1 -1
- package/views/config/email-processing.hbs +2 -0
- package/views/config/imap-proxy.hbs +3 -1
- package/views/config/license.hbs +1 -1
- package/views/config/logging.hbs +3 -1
- package/views/config/mcp.hbs +3 -1
- package/views/config/network.hbs +16 -16
- package/views/config/oauth/app.hbs +4 -4
- package/views/config/security.hbs +2 -0
- package/views/config/service.hbs +3 -1
- package/views/config/smtp.hbs +3 -1
- package/views/config/webhooks.hbs +4 -2
- package/views/error.hbs +10 -2
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +9 -14
- package/views/layout/login.hbs +1 -1
- package/views/layout/prompt.hbs +1 -1
- package/views/layout/public.hbs +1 -1
- package/views/legal.hbs +1 -1
- 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 +3 -3
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/oauth_form.hbs +6 -6
- package/views/partials/public_theme_init.hbs +1 -1
- 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/ui/details.hbs +2 -2
- package/views/partials/ui/env-managed-alert.hbs +19 -0
- package/views/partials/webhook_form.hbs +1 -1
- 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 +7 -1
- package/views/webhooks/webhook.hbs +2 -2
- package/workers/api.js +179 -175
- package/workers/export.js +1 -5
- package/workers/imap.js +33 -6
- package/workers/smtp.js +19 -43
- package/workers/submit.js +31 -13
- package/workers/webhooks.js +9 -24
- package/lib/reconnection-manager.js +0 -106
- 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
|
@@ -240,6 +240,8 @@ function init(args) {
|
|
|
240
240
|
let killed = await call({ cmd: 'kill-thread', thread: request.payload.thread });
|
|
241
241
|
if (killed) {
|
|
242
242
|
await request.flash({ type: 'info', message: `Worker stopped` });
|
|
243
|
+
} else {
|
|
244
|
+
await request.flash({ type: 'danger', message: `Requested worker thread was not found` });
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
return h.redirect('/admin/internals');
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Nothing reachable before the human clicks ever redirects off this origin. RFC 6749 4.1.2.1
|
|
8
8
|
// only forbids redirecting when the client or the redirect_uri cannot be validated, and an
|
|
9
9
|
// earlier revision of this file followed that literally: a validated-but-malformed request
|
|
10
|
-
// (wrong response_type, a code_challenge_method other than S256, a resource naming another
|
|
10
|
+
// (wrong response_type, a code_challenge_method missing or other than S256, a resource naming another
|
|
11
11
|
// server) bounced straight back to the client's address with ?error=. Client registration is
|
|
12
12
|
// open and unauthenticated, so anyone could register their own https redirect_uri and turn that
|
|
13
13
|
// into a no-interaction redirect off the admin origin - an open redirector aimed by whoever
|
|
@@ -36,6 +36,11 @@ const { MCP_ACCESS_LEVELS, MCP_ACCESS_LEVEL_OPTIONS, MCP_GRANT_WORDING } = requi
|
|
|
36
36
|
const { mcpFeatureEnabled } = require('../mcp');
|
|
37
37
|
const { oauthOrigin, getClient, touchClient, createAuthorizationCode, isAcceptableResource } = require('../mcp/oauth');
|
|
38
38
|
|
|
39
|
+
// Both consent routes answer with a redirect to the OAuth client's registered redirect_uri,
|
|
40
|
+
// often http://localhost for a native client, and Chrome checks the redirect target of a form
|
|
41
|
+
// submission against form-action - so neither carries that directive
|
|
42
|
+
const CONSENT_SECURITY_HEADERS = { securityHeaders: { directives: { 'form-action': null } } };
|
|
43
|
+
|
|
39
44
|
// The OAuth request parameters, carried through the GET render and posted back with the
|
|
40
45
|
// decision. state is a client-side value with no format promises; the size bounds are only
|
|
41
46
|
// there so the consent form cannot be used to store arbitrary blobs in a hidden field.
|
|
@@ -173,7 +178,10 @@ async function init(args) {
|
|
|
173
178
|
return renderError(h, `This client asked for an unsupported response type ("${request.query.response_type}"). Only "code" is supported.`);
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
// An absent method is not S256: RFC 7636 defaults it to "plain", which the token
|
|
182
|
+
// endpoint refuses - so a client that omits it would clear consent and only fail at
|
|
183
|
+
// the exchange, where nobody is looking. Required explicitly, the reason renders here.
|
|
184
|
+
if (request.query.code_challenge_method !== 'S256') {
|
|
177
185
|
return renderError(h, 'This client asked for an unsupported PKCE method. Only "S256" is supported.');
|
|
178
186
|
}
|
|
179
187
|
|
|
@@ -198,6 +206,7 @@ async function init(args) {
|
|
|
198
206
|
},
|
|
199
207
|
|
|
200
208
|
options: {
|
|
209
|
+
plugins: CONSENT_SECURITY_HEADERS,
|
|
201
210
|
validate: {
|
|
202
211
|
options: {
|
|
203
212
|
stripUnknown: true,
|
|
@@ -301,6 +310,7 @@ async function init(args) {
|
|
|
301
310
|
},
|
|
302
311
|
|
|
303
312
|
options: {
|
|
313
|
+
plugins: CONSENT_SECURITY_HEADERS,
|
|
304
314
|
validate: {
|
|
305
315
|
options: {
|
|
306
316
|
stripUnknown: true,
|
|
@@ -16,7 +16,7 @@ const { REDIS_PREFIX } = require('../consts');
|
|
|
16
16
|
const { failAction, getServiceHostname, reloadTlsServers } = require('../tools');
|
|
17
17
|
const { ADDRESS_STRATEGIES, settingsSchema } = require('../schemas');
|
|
18
18
|
const { updatePublicInterfaces } = require('../utils/network');
|
|
19
|
-
const { getServerStatus,
|
|
19
|
+
const { getServerStatus, compiledFragments } = require('./route-helpers');
|
|
20
20
|
const { registerSettingsPage } = require('./settings-page');
|
|
21
21
|
|
|
22
22
|
const configSmtpSchema = {
|
|
@@ -146,7 +146,6 @@ function init(args) {
|
|
|
146
146
|
imapStrategies: ADDRESS_STRATEGIES.map(entry => Object.assign({ selected: values.imapStrategy === entry.key }, entry)),
|
|
147
147
|
|
|
148
148
|
addresses: await listPublicInterfaces([].concat(values.localAddresses || [])),
|
|
149
|
-
addressListTemplate: cachedTemplates.addressList,
|
|
150
149
|
defaultSmtpEhloName: await getServiceHostname()
|
|
151
150
|
};
|
|
152
151
|
},
|
|
@@ -186,7 +185,9 @@ function init(args) {
|
|
|
186
185
|
|
|
187
186
|
return {
|
|
188
187
|
success: true,
|
|
189
|
-
|
|
188
|
+
// The page swaps its table body for this: the same partial the page was
|
|
189
|
+
// rendered with, so a rescan cannot drift from first paint
|
|
190
|
+
html: compiledFragments.addressList({ addresses: await listPublicInterfaces(localAddresses) })
|
|
190
191
|
};
|
|
191
192
|
} catch (err) {
|
|
192
193
|
request.logger.error({ msg: 'Failed loading public IP addresses', err });
|
|
@@ -369,7 +370,7 @@ function init(args) {
|
|
|
369
370
|
|
|
370
371
|
let certificateData = await h.getCertificate(true);
|
|
371
372
|
if (!certificateData) {
|
|
372
|
-
throw new Error(`Failed to provision a
|
|
373
|
+
throw new Error(`Failed to provision a certificate`);
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
if (certificateData.fingerprint && certificateData.fingerprint !== (existingCertificateData && existingCertificateData.fingerprint)) {
|
|
@@ -385,7 +386,7 @@ function init(args) {
|
|
|
385
386
|
label: certificateData.label
|
|
386
387
|
};
|
|
387
388
|
} catch (err) {
|
|
388
|
-
request.logger.error({ msg: 'Failed to
|
|
389
|
+
request.logger.error({ msg: 'Failed to provision a certificate', err });
|
|
389
390
|
return {
|
|
390
391
|
success: false,
|
|
391
392
|
error: err.message
|
|
@@ -18,7 +18,7 @@ const { Account } = require('../account');
|
|
|
18
18
|
const { oauth2Apps, OAUTH_PROVIDERS, oauth2ProviderData, SERVICE_ACCOUNT_PROVIDERS } = require('../oauth2-apps');
|
|
19
19
|
const { verifyOAuth2App } = require('../oauth/verify-app');
|
|
20
20
|
const { oauthCreateSchema, oauthUpdateSchema, accountIdSchema } = require('../schemas');
|
|
21
|
-
const { throwAsBoom, adminUrl } = require('./route-helpers');
|
|
21
|
+
const { throwAsBoom, adminUrl, submittedValues } = require('./route-helpers');
|
|
22
22
|
|
|
23
23
|
const { DEFAULT_PAGE_SIZE } = consts;
|
|
24
24
|
|
|
@@ -758,6 +758,11 @@ function init(args) {
|
|
|
758
758
|
return entry;
|
|
759
759
|
}),
|
|
760
760
|
|
|
761
|
+
// The submitted fields, not the stored app: without them the new-app form
|
|
762
|
+
// loses its provider on a validation error and the next submit is bounced
|
|
763
|
+
// to /admin
|
|
764
|
+
values: submittedValues(request, 'clientSecret', 'serviceKey'),
|
|
765
|
+
|
|
761
766
|
authorityCommon: request.payload.authority === 'common',
|
|
762
767
|
authorityOrganizations: request.payload.authority === 'organizations',
|
|
763
768
|
authorityConsumers: request.payload.authority === 'consumers',
|
|
@@ -830,6 +835,8 @@ function init(args) {
|
|
|
830
835
|
return entry;
|
|
831
836
|
}),
|
|
832
837
|
|
|
838
|
+
values: submittedValues(request, 'clientSecret', 'serviceKey'),
|
|
839
|
+
|
|
833
840
|
authorityCommon: request.payload.authority === 'common',
|
|
834
841
|
authorityOrganizations: request.payload.authority === 'organizations',
|
|
835
842
|
authorityConsumers: request.payload.authority === 'consumers',
|
|
@@ -1015,6 +1022,8 @@ function init(args) {
|
|
|
1015
1022
|
return entry;
|
|
1016
1023
|
}),
|
|
1017
1024
|
|
|
1025
|
+
values: submittedValues(request, 'clientSecret', 'serviceKey'),
|
|
1026
|
+
|
|
1018
1027
|
authorityCommon: request.payload.authority === 'common',
|
|
1019
1028
|
authorityOrganizations: request.payload.authority === 'organizations',
|
|
1020
1029
|
authorityConsumers: request.payload.authority === 'consumers',
|
|
@@ -1098,6 +1107,8 @@ function init(args) {
|
|
|
1098
1107
|
return entry;
|
|
1099
1108
|
}),
|
|
1100
1109
|
|
|
1110
|
+
values: submittedValues(request, 'clientSecret', 'serviceKey'),
|
|
1111
|
+
|
|
1101
1112
|
authorityCommon: request.payload.authority === 'common',
|
|
1102
1113
|
authorityOrganizations: request.payload.authority === 'organizations',
|
|
1103
1114
|
authorityConsumers: request.payload.authority === 'consumers',
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
// be extracted without stranding a helper its sibling groups still need. Pure functions
|
|
7
7
|
// and cached data only - this module registers no routes.
|
|
8
8
|
//
|
|
9
|
-
// Every symbol below was moved verbatim from lib/routes-ui.js
|
|
10
|
-
//
|
|
11
|
-
// lives one directory deeper (lib/ui-routes/) than the original (lib/).
|
|
9
|
+
// Every symbol below was moved verbatim from lib/routes-ui.js, apart from compiledFragments,
|
|
10
|
+
// which replaced the raw template sources the monolith handed to the browser.
|
|
12
11
|
|
|
13
12
|
const Boom = require('@hapi/boom');
|
|
14
13
|
const util = require('util');
|
|
15
14
|
const fs = require('fs');
|
|
16
15
|
const pathlib = require('path');
|
|
17
16
|
const psl = require('psl');
|
|
17
|
+
const handlebars = require('handlebars');
|
|
18
18
|
|
|
19
19
|
const settings = require('../settings');
|
|
20
20
|
const { redis } = require('../db');
|
|
21
21
|
const { toolGrants } = require('../mcp/tools');
|
|
22
|
-
const { Account, accountsExist, accountSummary, isAuthFailureDisabled } = require('../account');
|
|
22
|
+
const { Account, accountsExist, accountSummary, isAuthFailureDisabled, isAccessTokenInvalidated } = require('../account');
|
|
23
23
|
const { REDIS_PREFIX, DEFAULT_PAGE_SIZE } = require('../consts');
|
|
24
24
|
const { oauth2ProviderData } = require('../oauth2-apps');
|
|
25
25
|
const exampleDocumentsPayloads = require('../payload-examples-documents.json');
|
|
@@ -44,9 +44,22 @@ const OPEN_AI_MODELS = [
|
|
|
44
44
|
}
|
|
45
45
|
];
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
// Partials a page renders again after it has loaded: the delivery-test results and the address
|
|
48
|
+
// list after an IP rescan. They used to be shipped to the browser as source and compiled there,
|
|
49
|
+
// which runs `new Function` and would need 'unsafe-eval' in the Content-Security-Policy the
|
|
50
|
+
// admin surface sends. Compiled once here instead, outside vision but on the same handlebars
|
|
51
|
+
// instance it renders with, so the helpers and partials registered on it resolve at render
|
|
52
|
+
// time; the JSON endpoints return the rendered HTML. Not going through vision is deliberate: its
|
|
53
|
+
// per-request view context consumes the pending flash messages. What a fragment therefore lacks
|
|
54
|
+
// is that context - no `cspNonce`, so a fragment can never carry an inline <script>.
|
|
55
|
+
const FRAGMENT_COMPILE_OPTIONS = { preventIndent: true }; // matches the vision compileOptions in workers/api.js
|
|
56
|
+
|
|
57
|
+
const compiledFragments = {
|
|
58
|
+
addressList: handlebars.compile(
|
|
59
|
+
fs.readFileSync(pathlib.join(__dirname, '..', '..', 'views', 'partials', 'address_list.hbs'), 'utf-8'),
|
|
60
|
+
FRAGMENT_COMPILE_OPTIONS
|
|
61
|
+
),
|
|
62
|
+
testSend: handlebars.compile(fs.readFileSync(pathlib.join(__dirname, '..', '..', 'views', 'partials', 'test_send.hbs'), 'utf-8'), FRAGMENT_COMPILE_OPTIONS)
|
|
50
63
|
};
|
|
51
64
|
|
|
52
65
|
const getOpenAiModels = async (models, selectedModel) => {
|
|
@@ -82,6 +95,23 @@ const ACCOUNT_STATE_DISPLAY = [
|
|
|
82
95
|
{ state: 'unset', label: 'Not syncing', variant: 'neutral' }
|
|
83
96
|
];
|
|
84
97
|
|
|
98
|
+
// The wording for the two ImapFlow closed-after-connect codes, shared by the account state
|
|
99
|
+
// badge (accountStateLabel below) and the connection check on the account form
|
|
100
|
+
// (lib/ui-routes/account-routes.js), so the two cannot drift. The Text variant keeps the TLS
|
|
101
|
+
// hint because a wrong port/TLS pairing is the usual cause. Null for any other code.
|
|
102
|
+
function closedAfterConnectMessage(code, gt) {
|
|
103
|
+
switch (code) {
|
|
104
|
+
case 'ClosedAfterConnectTLS':
|
|
105
|
+
return gt.gettext('The server unexpectedly closed the connection.');
|
|
106
|
+
case 'ClosedAfterConnectText':
|
|
107
|
+
return gt.gettext(
|
|
108
|
+
'The server unexpectedly closed the connection. This usually happens when attempting to connect to a TLS port without TLS enabled.'
|
|
109
|
+
);
|
|
110
|
+
default:
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
85
115
|
// State badge descriptor for an account, shared by the server-rendered views
|
|
86
116
|
// (formatAccountData below) and the live SSE change feed (publishChangeEvent in
|
|
87
117
|
// workers/api.js), so the badge cannot drift between page load and repaint.
|
|
@@ -132,12 +162,8 @@ function accountStateLabel(state, opts, gt) {
|
|
|
132
162
|
errorMessage = gt.gettext('Connection timed out. This usually occurs if you are behind a firewall or connecting to the wrong port.');
|
|
133
163
|
break;
|
|
134
164
|
case 'ClosedAfterConnectTLS':
|
|
135
|
-
errorMessage = gt.gettext('The server unexpectedly closed the connection.');
|
|
136
|
-
break;
|
|
137
165
|
case 'ClosedAfterConnectText':
|
|
138
|
-
errorMessage = gt
|
|
139
|
-
'The server unexpectedly closed the connection. This usually happens when attempting to connect to a TLS port without TLS enabled.'
|
|
140
|
-
);
|
|
166
|
+
errorMessage = closedAfterConnectMessage(lastErrorState.serverResponseCode, gt);
|
|
141
167
|
break;
|
|
142
168
|
case 'ECONNREFUSED':
|
|
143
169
|
errorMessage = gt.gettext(
|
|
@@ -231,6 +257,9 @@ function formatAccountData(account, gt) {
|
|
|
231
257
|
account.oauth2.expiresStr = account.oauth2.expires ? account.oauth2.expires.toISOString() : false;
|
|
232
258
|
account.oauth2.generatedStr = account.oauth2.generated ? account.oauth2.generated.toISOString() : false;
|
|
233
259
|
|
|
260
|
+
// the view names the state instead of printing the inverted range the invalidation leaves
|
|
261
|
+
account.oauth2.accessTokenInvalidated = isAccessTokenInvalidated(account.oauth2);
|
|
262
|
+
|
|
234
263
|
if (account.outlookSubscription) {
|
|
235
264
|
account.outlookSubscription.subscriptionExpiresStr = account.outlookSubscription.expirationDateTime
|
|
236
265
|
? account.outlookSubscription.expirationDateTime.toISOString()
|
|
@@ -397,6 +426,26 @@ function adminUrl(strings, ...values) {
|
|
|
397
426
|
return strings.reduce((url, part, i) => url + part + (i < values.length ? encodeURIComponent(values[i]) : ''), '');
|
|
398
427
|
}
|
|
399
428
|
|
|
429
|
+
/**
|
|
430
|
+
* The submitted form fields for an error re-render, minus the secrets.
|
|
431
|
+
*
|
|
432
|
+
* A form re-rendered after a failed save shows what was typed rather than the stored record, so
|
|
433
|
+
* a validation error does not clear the form. The named secret fields are blanked, not echoed
|
|
434
|
+
* into the page: a password or a client secret is typed again, the way the account form treats
|
|
435
|
+
* its passwords.
|
|
436
|
+
*
|
|
437
|
+
* @param {Object} request - the Hapi request, whose payload is the submitted form
|
|
438
|
+
* @param {...String} secretFields - payload keys to blank
|
|
439
|
+
* @returns {Object}
|
|
440
|
+
*/
|
|
441
|
+
function submittedValues(request, ...secretFields) {
|
|
442
|
+
const values = Object.assign({}, request.payload);
|
|
443
|
+
for (const field of secretFields) {
|
|
444
|
+
values[field] = '';
|
|
445
|
+
}
|
|
446
|
+
return values;
|
|
447
|
+
}
|
|
448
|
+
|
|
400
449
|
function buildPagingView(basePath, data, query) {
|
|
401
450
|
const getPagingUrl = page => {
|
|
402
451
|
let url = new URL(basePath, 'http://localhost');
|
|
@@ -560,8 +609,9 @@ module.exports = {
|
|
|
560
609
|
accountPickerSelection,
|
|
561
610
|
identityErrorView,
|
|
562
611
|
OPEN_AI_MODELS,
|
|
563
|
-
|
|
612
|
+
compiledFragments,
|
|
564
613
|
getOpenAiModels,
|
|
614
|
+
closedAfterConnectMessage,
|
|
565
615
|
accountStateLabel,
|
|
566
616
|
ACCOUNT_STATE_DISPLAY,
|
|
567
617
|
formatServerState,
|
|
@@ -572,5 +622,6 @@ module.exports = {
|
|
|
572
622
|
isClientError,
|
|
573
623
|
authAwareLevel,
|
|
574
624
|
buildPagingView,
|
|
575
|
-
adminUrl
|
|
625
|
+
adminUrl,
|
|
626
|
+
submittedValues
|
|
576
627
|
};
|
|
@@ -22,8 +22,16 @@
|
|
|
22
22
|
// defaults to the submitted payload as-is
|
|
23
23
|
// viewContext - optional async (request, values, h) => extra view context,
|
|
24
24
|
// shared verbatim by all three render paths
|
|
25
|
+
//
|
|
26
|
+
// Every render also carries `envManagedKeys`, the form fields whose settings EENGINE_SETTINGS
|
|
27
|
+
// re-applies on every boot (server.js records the key list as the preparedSettingsKeys
|
|
28
|
+
// setting). A value saved for one of them reverts at the next restart, and the view has to say
|
|
29
|
+
// so - the way the logging page flags the SENTRY_DSN pinned fields. Field names are matched to
|
|
30
|
+
// settings keys as-is, which holds for every page except the logging form, whose
|
|
31
|
+
// `all`/`maxLogLines` fields fold into the `logs` setting.
|
|
25
32
|
|
|
26
33
|
const Joi = require('joi');
|
|
34
|
+
const settings = require('../settings');
|
|
27
35
|
|
|
28
36
|
function registerSettingsPage(server, page) {
|
|
29
37
|
const { path, view, pageTitle, menuKey, schema, loadValues, applySettings, errorValues, viewContext } = page;
|
|
@@ -35,6 +43,8 @@ function registerSettingsPage(server, page) {
|
|
|
35
43
|
if (errors) {
|
|
36
44
|
context.errors = errors;
|
|
37
45
|
}
|
|
46
|
+
const preparedKeys = (await settings.get('preparedSettingsKeys')) || [];
|
|
47
|
+
context.envManagedKeys = preparedKeys.filter(key => Object.hasOwn(schema, key));
|
|
38
48
|
return context;
|
|
39
49
|
};
|
|
40
50
|
|
|
@@ -13,6 +13,7 @@ const getSecret = require('../get-secret');
|
|
|
13
13
|
const { failAction, httpAgent } = require('../tools');
|
|
14
14
|
const { accountIdSchema } = require('../schemas');
|
|
15
15
|
const { REDIS_PREFIX } = require('../consts');
|
|
16
|
+
const { compiledFragments } = require('./route-helpers');
|
|
16
17
|
const packageData = require('../../package.json');
|
|
17
18
|
|
|
18
19
|
const SMTP_TEST_HOST = 'https://api.nodemailer.com';
|
|
@@ -207,6 +208,12 @@ ${now}`,
|
|
|
207
208
|
if (testResponse.spf && testResponse.spf.status && testResponse.spf.status.comment) {
|
|
208
209
|
testResponse.spf.status.comment = testResponse.spf.status.comment.replace(/^[^:\s]+:s*/, '');
|
|
209
210
|
}
|
|
211
|
+
|
|
212
|
+
if (testResponse.status === 'success') {
|
|
213
|
+
// The page shows the results through this fragment rather than
|
|
214
|
+
// compiling the template in the browser, which the admin CSP forbids
|
|
215
|
+
testResponse.html = compiledFragments.testSend(testResponse);
|
|
216
|
+
}
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
return testResponse;
|
|
@@ -21,6 +21,12 @@ const pagingQuerySchema = Joi.object({
|
|
|
21
21
|
pageSize: Joi.number().integer().min(1).max(250).default(DEFAULT_PAGE_SIZE)
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
// Where a request that named a list goes back to: the list's own page when the ID is one
|
|
25
|
+
// the routes would accept, the index otherwise (the ID might be the invalid part)
|
|
26
|
+
function listPagePath(listId) {
|
|
27
|
+
return blocklistListIdSchema.validate(listId).error ? '/admin/suppression-lists' : adminUrl`/admin/suppression-lists/list/${listId}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
function init(args) {
|
|
25
31
|
const { server } = args;
|
|
26
32
|
|
|
@@ -134,7 +140,8 @@ function init(args) {
|
|
|
134
140
|
},
|
|
135
141
|
|
|
136
142
|
async failAction(request, h /*, err*/) {
|
|
137
|
-
|
|
143
|
+
// A bad page argument on a real list goes back to that list, not to the index
|
|
144
|
+
return h.redirect(listPagePath(request.params.listId)).takeover();
|
|
138
145
|
},
|
|
139
146
|
|
|
140
147
|
params: Joi.object({
|
|
@@ -182,10 +189,14 @@ function init(args) {
|
|
|
182
189
|
},
|
|
183
190
|
|
|
184
191
|
async failAction(request, h, err) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
// The add form is a modal that closes on submit, so the field error cannot be
|
|
193
|
+
// shown inline: flash what joi objected to and land back where the modal was
|
|
194
|
+
// opened, which is the list page whenever the list ID itself is valid
|
|
195
|
+
let reasons = (err.details || []).map(detail => detail.message).join('; ');
|
|
196
|
+
await request.flash({ type: 'danger', message: `Couldn't add the address${reasons ? `: ${reasons}` : ''}` });
|
|
197
|
+
request.logger.debug({ msg: 'Failed to add suppression list entry', err });
|
|
198
|
+
|
|
199
|
+
return h.redirect(listPagePath(request.payload && request.payload.listId)).takeover();
|
|
189
200
|
},
|
|
190
201
|
|
|
191
202
|
payload: Joi.object({
|
|
@@ -26,7 +26,9 @@ function init(args) {
|
|
|
26
26
|
let data = await parseSignedFormData(redis, { data: request.query.data, sig: request.query.sig }, request.app.gt);
|
|
27
27
|
|
|
28
28
|
if (!data || typeof data !== 'object' || data.act !== 'unsub') {
|
|
29
|
-
|
|
29
|
+
// A validly signed blob of another type is the client's problem, not a server
|
|
30
|
+
// failure - the same 400 the submit handler answers with
|
|
31
|
+
throw Boom.boomify(new Error(request.app.gt.gettext('Invalid input')), { statusCode: 400 });
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
// throws if account does not exist
|
|
@@ -84,12 +86,16 @@ function init(args) {
|
|
|
84
86
|
method: 'POST',
|
|
85
87
|
path: '/unsubscribe/address',
|
|
86
88
|
async handler(request, h) {
|
|
89
|
+
// Declared outside the try so the error branch can re-render the form for a request
|
|
90
|
+
// whose signature did verify and only failed later
|
|
91
|
+
let signed;
|
|
87
92
|
try {
|
|
88
93
|
// Verify the signature and read account/list/recipient from the SIGNED payload -
|
|
89
94
|
// never from client-supplied fields - so subscribe/unsubscribe cannot be forged (M7).
|
|
90
|
-
|
|
95
|
+
signed = await parseSignedFormData(redis, { data: request.payload.data, sig: request.payload.sig }, request.app.gt);
|
|
91
96
|
|
|
92
97
|
if (!signed || typeof signed !== 'object' || signed.act !== 'unsub') {
|
|
98
|
+
signed = null;
|
|
93
99
|
throw Boom.boomify(new Error(request.app.gt.gettext('Invalid input')), { statusCode: 400 });
|
|
94
100
|
}
|
|
95
101
|
|
|
@@ -182,10 +188,23 @@ function init(args) {
|
|
|
182
188
|
// endpoint, not a server failure
|
|
183
189
|
request.logger[isClientError(err) ? 'debug' : 'error']({ msg: 'Failed to process subscription request', err });
|
|
184
190
|
|
|
191
|
+
// With a verified signature the form comes back filled in so the person can retry;
|
|
192
|
+
// without one there is nothing trustworthy to show, and the view renders its
|
|
193
|
+
// invalid-link state instead of an empty form
|
|
185
194
|
return h.view(
|
|
186
195
|
'unsubscribe',
|
|
187
196
|
{
|
|
188
|
-
pageTitleFull: request.app.gt.gettext('Subscription Management')
|
|
197
|
+
pageTitleFull: request.app.gt.gettext('Subscription Management'),
|
|
198
|
+
values: signed
|
|
199
|
+
? {
|
|
200
|
+
listId: signed.list,
|
|
201
|
+
account: signed.acc,
|
|
202
|
+
messageId: signed.msg,
|
|
203
|
+
email: signed.rcpt,
|
|
204
|
+
data: request.payload.data,
|
|
205
|
+
sig: request.payload.sig
|
|
206
|
+
}
|
|
207
|
+
: {}
|
|
189
208
|
},
|
|
190
209
|
{
|
|
191
210
|
layout: 'public'
|
package/lib/webhook-egress.js
CHANGED
|
@@ -13,6 +13,11 @@ const { assertAllowedUrl, createEgressLookup, normalizePolicy, POLICY_OFF } = re
|
|
|
13
13
|
// system can aim EmailEngine at anything its host can route to. Defaults to blocking the
|
|
14
14
|
// link-local range (cloud instance metadata); `private` also blocks RFC1918 and friends, `off`
|
|
15
15
|
// disables the check and restores redirect following. See lib/egress-filter.js
|
|
16
|
+
//
|
|
17
|
+
// The autodiscovery lookups (lib/autodetect-imap-settings.js) apply the same policy: their
|
|
18
|
+
// destinations are derived from the domain of a caller-supplied email address, which a DNS record
|
|
19
|
+
// can point anywhere. One policy rather than two because they guard the same thing, the host's
|
|
20
|
+
// network position, and an operator who tuned it for webhooks meant the tuning for all egress.
|
|
16
21
|
const WEBHOOK_EGRESS_POLICY = normalizePolicy(readEnvValue('EENGINE_WEBHOOK_EGRESS_POLICY'));
|
|
17
22
|
|
|
18
23
|
const policyEnabled = WEBHOOK_EGRESS_POLICY !== POLICY_OFF;
|
package/lib/webhooks.js
CHANGED
|
@@ -379,6 +379,12 @@ class WebhooksHandler {
|
|
|
379
379
|
|
|
380
380
|
async getHandler(id) {
|
|
381
381
|
let webhookData = await this.get(id);
|
|
382
|
+
if (!webhookData) {
|
|
383
|
+
// The route was deleted between the index read and the content read. Callers skip a
|
|
384
|
+
// null handler; anything else would leave the cache refresh half done, with its
|
|
385
|
+
// version marker stale and the main webhook never queued
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
382
388
|
|
|
383
389
|
try {
|
|
384
390
|
if (webhookData.content.fn) {
|
|
@@ -460,7 +466,9 @@ class WebhooksHandler {
|
|
|
460
466
|
if (!existing) {
|
|
461
467
|
// add as new
|
|
462
468
|
let handler = await this.getHandler(webhookId);
|
|
463
|
-
|
|
469
|
+
if (handler) {
|
|
470
|
+
this.handlerCache.push(handler);
|
|
471
|
+
}
|
|
464
472
|
} else {
|
|
465
473
|
// compare existing
|
|
466
474
|
// the per-route counter is stored as a string, existing.v is a number (see get())
|
|
@@ -470,7 +478,11 @@ class WebhooksHandler {
|
|
|
470
478
|
for (let i = this.handlerCache.length - 1; i >= 0; i--) {
|
|
471
479
|
if (webhookId === this.handlerCache[i].id) {
|
|
472
480
|
let handler = await this.getHandler(webhookId);
|
|
473
|
-
|
|
481
|
+
if (handler) {
|
|
482
|
+
this.handlerCache[i] = handler;
|
|
483
|
+
} else {
|
|
484
|
+
this.handlerCache.splice(i, 1);
|
|
485
|
+
}
|
|
474
486
|
}
|
|
475
487
|
}
|
|
476
488
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailengine-app",
|
|
3
|
-
"version": "2.79.
|
|
3
|
+
"version": "2.79.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"productTitle": "EmailEngine",
|
|
6
6
|
"description": "Email Sync Engine",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://emailengine.app/",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@bull-board/api": "9.
|
|
55
|
-
"@bull-board/hapi": "9.
|
|
54
|
+
"@bull-board/api": "9.8.0",
|
|
55
|
+
"@bull-board/hapi": "9.8.0",
|
|
56
56
|
"@elastic/elasticsearch": "8.15.3",
|
|
57
57
|
"@hapi/accept": "6.0.3",
|
|
58
58
|
"@hapi/bell": "13.1.0",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"@msgpack/msgpack": "3.1.3",
|
|
66
66
|
"@phc/pbkdf2": "1.1.14",
|
|
67
67
|
"@postalsys/bounce-classifier": "3.0.0",
|
|
68
|
-
"@postalsys/certs": "1.
|
|
69
|
-
"@postalsys/ee-client": "1.
|
|
70
|
-
"@postalsys/email-ai-tools": "1.
|
|
71
|
-
"@postalsys/email-content": "0.1.
|
|
72
|
-
"@postalsys/email-text-tools": "2.4.
|
|
68
|
+
"@postalsys/certs": "1.1.1",
|
|
69
|
+
"@postalsys/ee-client": "1.8.0",
|
|
70
|
+
"@postalsys/email-ai-tools": "1.14.3",
|
|
71
|
+
"@postalsys/email-content": "0.1.5",
|
|
72
|
+
"@postalsys/email-text-tools": "2.4.16",
|
|
73
73
|
"@postalsys/gettext": "4.1.1",
|
|
74
74
|
"@postalsys/joi-messages": "1.0.5",
|
|
75
75
|
"@postalsys/templates": "2.0.2",
|
|
76
|
-
"@sentry/node": "10.
|
|
77
|
-
"@simplewebauthn/browser": "
|
|
78
|
-
"@simplewebauthn/server": "
|
|
76
|
+
"@sentry/node": "10.73.0",
|
|
77
|
+
"@simplewebauthn/browser": "14.0.0",
|
|
78
|
+
"@simplewebauthn/server": "14.0.1",
|
|
79
79
|
"@zone-eu/mailsplit": "5.4.16",
|
|
80
80
|
"@zone-eu/wild-config": "1.7.6",
|
|
81
81
|
"ace-builds": "1.44.0",
|
|
82
|
-
"bullmq": "6.3.
|
|
82
|
+
"bullmq": "6.3.4",
|
|
83
83
|
"compare-versions": "6.1.1",
|
|
84
84
|
"dotenv": "17.4.2",
|
|
85
85
|
"encoding-japanese": "2.3.0",
|
|
@@ -93,42 +93,42 @@
|
|
|
93
93
|
"html-to-text": "10.0.1",
|
|
94
94
|
"ical.js": "1.5.0",
|
|
95
95
|
"iconv-lite": "0.7.3",
|
|
96
|
-
"imapflow": "
|
|
96
|
+
"imapflow": "2.0.0",
|
|
97
97
|
"ioredfour": "1.4.3",
|
|
98
98
|
"ioredis": "6.0.0",
|
|
99
99
|
"ipaddr.js": "2.5.0",
|
|
100
|
-
"joi": "18.2.
|
|
100
|
+
"joi": "18.2.8",
|
|
101
101
|
"libbase64": "1.3.0",
|
|
102
102
|
"libmime": "5.4.3",
|
|
103
103
|
"libqp": "2.1.1",
|
|
104
|
-
"mailparser": "3.9.
|
|
104
|
+
"mailparser": "3.9.23",
|
|
105
105
|
"marked": "15.0.12",
|
|
106
106
|
"minimist": "1.2.8",
|
|
107
107
|
"murmurhash": "2.0.1",
|
|
108
108
|
"nanoid": "3.3.18",
|
|
109
|
-
"nodemailer": "
|
|
109
|
+
"nodemailer": "10.0.1",
|
|
110
110
|
"pino": "10.3.1",
|
|
111
111
|
"prom-client": "15.1.3",
|
|
112
112
|
"psl": "1.15.0",
|
|
113
|
-
"pubface": "1.1.
|
|
113
|
+
"pubface": "1.1.12",
|
|
114
114
|
"punycode.js": "2.3.1",
|
|
115
115
|
"qrcode": "1.5.4",
|
|
116
|
-
"smtp-server": "3.19.
|
|
117
|
-
"socks": "2.8.
|
|
116
|
+
"smtp-server": "3.19.9",
|
|
117
|
+
"socks": "2.8.10",
|
|
118
118
|
"timezones-list": "3.1.0",
|
|
119
|
-
"undici": "7.29.
|
|
119
|
+
"undici": "7.29.1"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@eslint/js": "10.0.1",
|
|
123
123
|
"@iconify-json/tabler": "1.2.38",
|
|
124
124
|
"@iconify/tailwind4": "1.2.3",
|
|
125
|
-
"@playwright/test": "1.
|
|
125
|
+
"@playwright/test": "1.63.0",
|
|
126
126
|
"@tailwindcss/cli": "4.3.3",
|
|
127
127
|
"acorn": "8.18.0",
|
|
128
128
|
"acorn-walk": "8.3.5",
|
|
129
129
|
"chai": "4.5.0",
|
|
130
130
|
"eerawlog": "1.5.5",
|
|
131
|
-
"eslint": "10.
|
|
131
|
+
"eslint": "10.10.0",
|
|
132
132
|
"flyonui": "2.4.1",
|
|
133
133
|
"pino-pretty": "13.1.3",
|
|
134
134
|
"prettier": "3.9.6",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"deepmerge-ts": "^8.0.1"
|
|
144
144
|
},
|
|
145
145
|
"engines": {
|
|
146
|
-
"node": ">=20.
|
|
146
|
+
"node": ">=20.0.0"
|
|
147
147
|
},
|
|
148
148
|
"pkg": {
|
|
149
149
|
"scripts": [
|
|
@@ -157,14 +157,11 @@
|
|
|
157
157
|
"static/**/*",
|
|
158
158
|
"views/**/*",
|
|
159
159
|
"lib/lua/**/*",
|
|
160
|
-
"node_modules/bull/lib/commands/**/*",
|
|
161
160
|
"translations/**/*",
|
|
162
161
|
"node_modules/@postalsys/joi-messages/translations/*",
|
|
163
162
|
"node_modules/@postalsys/bounce-classifier/model/**/*",
|
|
164
163
|
"node_modules/@postalsys/email-content/dist/detect/patterns/*.json",
|
|
165
164
|
"node_modules/jsdom/lib/jsdom/browser/default-stylesheet.css",
|
|
166
|
-
"node_modules/nodemailer/lib/well-known/*.json",
|
|
167
|
-
"node_modules/nodemailer/package.json",
|
|
168
165
|
"LICENSE_EMAILENGINE.txt",
|
|
169
166
|
"version-info.json",
|
|
170
167
|
"sbom.json"
|