emailengine-app 2.84.2 → 2.86.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 +29 -9
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +107 -0
- package/Dockerfile +20 -1
- package/ENVIRONMENT.md +139 -0
- package/README.md +2 -2
- package/bin/emailengine.js +434 -408
- package/config/default.toml +2 -0
- package/copy-static-files.sh +41 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16563 -0
- package/eslint.config.js +81 -99
- package/lib/account-assignment.js +19 -0
- package/lib/account.js +230 -170
- package/lib/api-error-codes.js +49 -0
- package/lib/api-reference/format.js +4 -3
- package/lib/api-reference/model.js +6 -1
- package/lib/api-routes/account-routes.js +255 -38
- package/lib/api-routes/blocklist-routes.js +91 -4
- package/lib/api-routes/delivery-test-routes.js +27 -4
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +110 -12
- package/lib/api-routes/index.js +4 -0
- package/lib/api-routes/license-routes.js +2 -2
- package/lib/api-routes/mailbox-routes.js +44 -5
- package/lib/api-routes/message-routes.js +112 -10
- package/lib/api-routes/oauth2-app-routes.js +63 -23
- package/lib/api-routes/outbox-routes.js +97 -52
- package/lib/api-routes/permission-map.js +67 -7
- package/lib/api-routes/scoped-routes.js +74 -0
- package/lib/api-routes/settings-routes.js +34 -6
- package/lib/api-routes/stats-routes.js +5 -1
- package/lib/api-routes/submit-routes.js +337 -309
- package/lib/api-routes/template-routes.js +45 -8
- package/lib/api-routes/token-routes.js +152 -100
- package/lib/api-routes/webhook-delivery-routes.js +262 -0
- package/lib/api-routes/webhook-route-routes.js +132 -6
- package/lib/bounce-detect.js +397 -205
- package/lib/calendar-event.js +81 -1
- package/lib/consts.js +38 -45
- package/lib/db.js +14 -6
- package/lib/delivery-error.js +6 -0
- package/lib/deprecations.js +270 -0
- package/lib/email-client/base-client.js +137 -184
- package/lib/email-client/fallback-poll.js +62 -0
- package/lib/email-client/gmail-client.js +60 -22
- package/lib/email-client/imap/adaptive-idle-store.js +73 -0
- package/lib/email-client/imap/adaptive-idle.js +278 -0
- package/lib/email-client/imap/connection-errors.js +14 -1
- package/lib/email-client/imap/idle-settings.js +31 -5
- package/lib/email-client/imap/listing-diff.js +37 -0
- package/lib/email-client/imap/mailbox.js +372 -242
- package/lib/email-client/imap/subconnection.js +8 -30
- package/lib/email-client/imap/sync-operations.js +220 -127
- package/lib/email-client/imap-client.js +228 -164
- package/lib/email-client/message-builder.js +14 -79
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/email-client/outlook-client.js +372 -338
- package/lib/email-client/smtp-pool-manager.js +16 -13
- package/lib/email-client/sync-state-fields.js +19 -0
- package/lib/encrypt.js +157 -41
- package/lib/enum-descriptions.js +3 -1
- package/lib/env-setting-overrides.js +288 -0
- package/lib/export-worker.js +751 -0
- package/lib/export.js +64 -15
- package/lib/gateway.js +19 -4
- package/lib/get-raw-email.js +25 -107
- package/lib/hapi-request-logger.js +107 -0
- package/lib/health.js +75 -0
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/lock-run.js +119 -0
- package/lib/logger-consts.js +48 -0
- package/lib/logger.js +1 -1
- package/lib/lua/z-head-scores.lua +28 -0
- package/lib/mcp/tools.js +37 -8
- package/lib/network-errors.js +1 -1
- package/lib/node-version.js +24 -0
- package/lib/notify-attachments.js +36 -0
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +631 -656
- package/lib/outbox.js +184 -54
- package/lib/parse-message.js +3 -3
- package/lib/pbkdf2-phc.js +1 -1
- package/lib/privileged-settings.js +2 -2
- package/lib/queue-browser/definitions.js +11 -0
- package/lib/queue-browser/index.js +68 -19
- package/lib/queue-job-actions.js +18 -1
- package/lib/queue-retention.js +48 -12
- package/lib/queue-stats.js +11 -2
- package/lib/read-env-value.js +3 -0
- package/lib/redis-memory-warnings.js +99 -0
- package/lib/redis-reconnect.js +29 -0
- package/lib/request-timing.js +23 -0
- package/lib/respawn-backoff.js +35 -0
- package/lib/rewrite-text-nodes.js +19 -59
- package/lib/schemas.js +164 -40
- package/lib/settings.js +6 -2
- package/lib/smtp-auth.js +19 -1
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +63 -0
- package/lib/timezones.js +109 -0
- package/lib/tls/provision.js +6 -3
- package/lib/token-audit-log.js +19 -20
- package/lib/token-permission-view.js +7 -6
- package/lib/tools.js +48 -51
- 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 +152 -100
- package/lib/ui-routes/admin-entities-routes.js +93 -21
- package/lib/ui-routes/auth-routes.js +90 -38
- package/lib/ui-routes/imap-idle-field.js +1 -1
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/oauth-config-routes.js +124 -82
- package/lib/ui-routes/outlook-subscription-view.js +1 -1
- package/lib/ui-routes/overridable-fields.js +84 -0
- package/lib/ui-routes/queue-routes.js +8 -5
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/settings-page.js +6 -0
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/decode-headers.js +3 -12
- package/lib/utils/filter-empty.js +20 -0
- package/lib/utils/int-setting.js +48 -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/tracking-settings.js +35 -0
- package/lib/utils/version.js +74 -0
- package/lib/web-safe-html.js +18 -105
- package/lib/webhook-delivery.js +461 -0
- package/lib/webhook-failures.js +132 -0
- package/lib/webhook-request.js +29 -1
- package/lib/webhook-routing.js +56 -0
- package/lib/webhook-test.js +88 -0
- package/lib/webhooks.js +93 -45
- package/lib/worker-rpc-error.js +2 -1
- package/package.json +37 -38
- package/sbom.json +7902 -1
- package/server.js +784 -518
- package/static/js/ace/ace.js +1 -1
- package/static/licenses.html +225 -1060
- package/translations/messages.pot +62 -63
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +24 -2
- package/views/config/service.hbs +47 -0
- package/views/config/webhooks.hbs +36 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/queue_retention_note.hbs +12 -8
- package/views/partials/ui/env-managed-alert.hbs +16 -7
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +840 -611
- package/workers/export.js +17 -632
- package/workers/imap.js +13 -0
- package/workers/smtp.js +9 -11
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +18 -448
- package/lib/email-client/outlook-fallback-poll.js +0 -30
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { Gateway } = require('../gateway');
|
|
3
|
+
const { Gateway, gatewaySmtpConfig } = require('../gateway');
|
|
4
4
|
const { oauth2ProviderData } = require('../oauth2-apps');
|
|
5
5
|
const { useAuthServerForConnection, redactUrlCredentials } = require('../tools');
|
|
6
6
|
const { resolveAuthServerCredentials } = require('./credential-errors');
|
|
@@ -83,21 +83,8 @@ class SmtpConfigBuilder {
|
|
|
83
83
|
* @returns {Object} SMTP connection config
|
|
84
84
|
*/
|
|
85
85
|
buildGatewayConfig(gatewayData) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
port: gatewayData.port,
|
|
89
|
-
secure: gatewayData.secure,
|
|
90
|
-
requireTLS: gatewayData.requireTLS
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
if (gatewayData.user || gatewayData.pass) {
|
|
94
|
-
config.auth = {
|
|
95
|
-
user: gatewayData.user || '',
|
|
96
|
-
pass: gatewayData.pass || ''
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return config;
|
|
86
|
+
// the same config the gateway verification connects with, so a verified gateway is the one sent through
|
|
87
|
+
return gatewaySmtpConfig(gatewayData);
|
|
101
88
|
}
|
|
102
89
|
|
|
103
90
|
/**
|
|
@@ -377,75 +364,23 @@ class NotificationBuilder {
|
|
|
377
364
|
}
|
|
378
365
|
|
|
379
366
|
/**
|
|
380
|
-
*
|
|
367
|
+
* The Message-ID a provider gave the message it accepted. Outlook and Amazon SES replace the one
|
|
368
|
+
* the message was sent with and report theirs in the final 250 reply; nodemailer (10.2.0) reads it
|
|
369
|
+
* from there as info.serverMessageId, for the formats this used to parse itself
|
|
381
370
|
*/
|
|
382
371
|
class ProviderMessageIdHandler {
|
|
383
372
|
/**
|
|
384
|
-
*
|
|
385
|
-
* The server may override the message ID in its response
|
|
386
|
-
* @param {Object} info - SMTP send result info
|
|
387
|
-
* @returns {string|undefined} Original message ID if overridden
|
|
388
|
-
*/
|
|
389
|
-
static handleHotmail(info) {
|
|
390
|
-
const response = (info.response || '').toString();
|
|
391
|
-
const match = response.match(/^250 2.0.0 OK (<[^>]+\.prod\.outlook\.com>)/);
|
|
392
|
-
|
|
393
|
-
if (match && match[1] !== info.messageId) {
|
|
394
|
-
const originalMessageId = info.messageId;
|
|
395
|
-
info.messageId = match[1];
|
|
396
|
-
return originalMessageId;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return undefined;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Constructs message ID from AWS SES response
|
|
404
|
-
* SES returns a message ID in the response that should be used
|
|
405
|
-
* @param {Object} info - SMTP send result info
|
|
406
|
-
* @param {string} smtpHost - SMTP host name
|
|
407
|
-
* @returns {string|undefined} Original message ID if overridden
|
|
408
|
-
*/
|
|
409
|
-
static handleAwsSes(info, smtpHost) {
|
|
410
|
-
const hostMatch = (smtpHost || '').toString().match(/\.([^.]+)\.(amazonaws\.com|awsapps\.com)$/i);
|
|
411
|
-
const responseMatch = (info.response || '').toString().match(/^250 Ok ([0-9a-f-]+)$/);
|
|
412
|
-
|
|
413
|
-
if (hostMatch && responseMatch) {
|
|
414
|
-
let region = hostMatch[1].toLowerCase().trim();
|
|
415
|
-
const messageIdPart = responseMatch[1].toLowerCase().trim();
|
|
416
|
-
|
|
417
|
-
if (region === 'us-east-1') {
|
|
418
|
-
region = 'email';
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
const originalMessageId = info.messageId;
|
|
422
|
-
info.messageId = '<' + messageIdPart + (!/@/.test(messageIdPart) ? '@' + region + '.amazonses.com' : '') + '>';
|
|
423
|
-
return originalMessageId;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
return undefined;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Processes SMTP response to extract provider-specific message ID
|
|
373
|
+
* Switches info.messageId to the provider's own one when it reported one
|
|
431
374
|
* @param {Object} info - SMTP send result info
|
|
432
|
-
* @
|
|
433
|
-
* @returns {string|undefined} Original message ID if it was overridden
|
|
375
|
+
* @returns {string|undefined} The Message-ID the message was sent with, if it was replaced
|
|
434
376
|
*/
|
|
435
|
-
static processResponse(info
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (originalMessageId) {
|
|
439
|
-
return originalMessageId;
|
|
377
|
+
static processResponse(info) {
|
|
378
|
+
if (!info?.serverMessageId || info.serverMessageId === info.messageId) {
|
|
379
|
+
return undefined;
|
|
440
380
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
originalMessageId
|
|
444
|
-
if (originalMessageId) {
|
|
445
|
-
return originalMessageId;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return undefined;
|
|
381
|
+
const originalMessageId = info.messageId;
|
|
382
|
+
info.messageId = info.serverMessageId;
|
|
383
|
+
return originalMessageId;
|
|
449
384
|
}
|
|
450
385
|
}
|
|
451
386
|
|
|
@@ -97,8 +97,7 @@ class NotificationHandler {
|
|
|
97
97
|
// Build notification payload
|
|
98
98
|
const payload = this.buildPayload(mailbox, event, data, serviceUrl);
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
await Webhooks.pushToQueue(event, notifyPayload);
|
|
100
|
+
await Webhooks.enqueue(event, payload);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|