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
package/eslint.config.js
CHANGED
|
@@ -1,112 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Shared lint baseline for the Postal Systems / Nodemailer packages: eslint:recommended
|
|
4
|
+
// plus the rules of the retired eslint-config-nodemailer, with formatting left to Prettier.
|
|
5
|
+
// Keep this file identical across repos except for the "Repo-specific" block at the end.
|
|
6
|
+
|
|
1
7
|
const js = require('@eslint/js');
|
|
8
|
+
const prettier = require('eslint-config-prettier');
|
|
9
|
+
const globals = require('globals');
|
|
2
10
|
|
|
3
11
|
module.exports = [
|
|
4
12
|
{
|
|
5
|
-
ignores: ['node_modules/**', 'ee-dist/**', 'static/**']
|
|
13
|
+
ignores: ['node_modules/**', 'coverage/**', 'dist/**', 'ee-dist/**', 'static/**']
|
|
6
14
|
},
|
|
7
15
|
js.configs.recommended,
|
|
8
16
|
{
|
|
17
|
+
files: ['**/*.js', '**/*.cjs'],
|
|
9
18
|
languageOptions: {
|
|
10
|
-
ecmaVersion:
|
|
19
|
+
ecmaVersion: 2022,
|
|
11
20
|
sourceType: 'commonjs',
|
|
12
|
-
globals: {
|
|
13
|
-
// Node.js globals
|
|
14
|
-
Buffer: 'readonly',
|
|
15
|
-
__dirname: 'readonly',
|
|
16
|
-
__filename: 'readonly',
|
|
17
|
-
console: 'readonly',
|
|
18
|
-
exports: 'writable',
|
|
19
|
-
global: 'readonly',
|
|
20
|
-
module: 'writable',
|
|
21
|
-
process: 'readonly',
|
|
22
|
-
require: 'readonly',
|
|
23
|
-
BigInt: 'readonly',
|
|
24
|
-
setImmediate: 'readonly',
|
|
25
|
-
clearImmediate: 'readonly',
|
|
26
|
-
setTimeout: 'readonly',
|
|
27
|
-
clearTimeout: 'readonly',
|
|
28
|
-
setInterval: 'readonly',
|
|
29
|
-
clearInterval: 'readonly',
|
|
30
|
-
AbortController: 'readonly',
|
|
31
|
-
AbortSignal: 'readonly',
|
|
32
|
-
URL: 'readonly',
|
|
33
|
-
URLSearchParams: 'readonly',
|
|
34
|
-
structuredClone: 'readonly',
|
|
35
|
-
// Test globals
|
|
36
|
-
it: 'readonly',
|
|
37
|
-
describe: 'readonly',
|
|
38
|
-
before: 'readonly',
|
|
39
|
-
after: 'readonly',
|
|
40
|
-
beforeEach: 'readonly',
|
|
41
|
-
afterEach: 'readonly'
|
|
42
|
-
}
|
|
21
|
+
globals: { ...globals.node }
|
|
43
22
|
},
|
|
44
|
-
files: ['**/*.js'],
|
|
45
23
|
rules: {
|
|
46
|
-
|
|
47
|
-
'no-
|
|
48
|
-
'
|
|
49
|
-
|
|
50
|
-
'
|
|
51
|
-
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'no-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'nonblock-statement-body-position': 'off',
|
|
85
|
-
'object-curly-newline': 'off',
|
|
86
|
-
'object-curly-spacing': 'off',
|
|
87
|
-
'object-property-newline': 'off',
|
|
88
|
-
'one-var-declaration-per-line': 'off',
|
|
89
|
-
'operator-linebreak': 'off',
|
|
90
|
-
'padded-blocks': 'off',
|
|
91
|
-
'padding-line-between-statements': 'off',
|
|
92
|
-
'quote-props': 'off',
|
|
93
|
-
quotes: 'off',
|
|
94
|
-
'rest-spread-spacing': 'off',
|
|
95
|
-
semi: 'off',
|
|
96
|
-
'semi-spacing': 'off',
|
|
97
|
-
'semi-style': 'off',
|
|
98
|
-
'space-before-blocks': 'off',
|
|
99
|
-
'space-before-function-paren': 'off',
|
|
100
|
-
'space-in-parens': 'off',
|
|
101
|
-
'space-infix-ops': 'off',
|
|
102
|
-
'space-unary-ops': 'off',
|
|
103
|
-
'switch-colon-spacing': 'off',
|
|
104
|
-
'template-curly-spacing': 'off',
|
|
105
|
-
'template-tag-spacing': 'off',
|
|
106
|
-
'unicode-bom': 'off',
|
|
107
|
-
'wrap-iife': 'off',
|
|
108
|
-
'wrap-regex': 'off',
|
|
109
|
-
'yield-star-spacing': 'off'
|
|
24
|
+
'no-await-in-loop': 'error',
|
|
25
|
+
'no-div-regex': 'error',
|
|
26
|
+
strict: ['error', 'global'],
|
|
27
|
+
eqeqeq: 'error',
|
|
28
|
+
'dot-notation': 'error',
|
|
29
|
+
curly: 'error',
|
|
30
|
+
'no-unused-expressions': ['error', { allowShortCircuit: true }],
|
|
31
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
|
|
32
|
+
'handle-callback-err': 'error',
|
|
33
|
+
'no-new': 'error',
|
|
34
|
+
'new-cap': 'error',
|
|
35
|
+
'no-eval': 'error',
|
|
36
|
+
'no-invalid-this': 'error',
|
|
37
|
+
radix: ['error', 'always'],
|
|
38
|
+
'no-use-before-define': ['error', 'nofunc'],
|
|
39
|
+
'callback-return': ['error', ['callback', 'cb', 'done']],
|
|
40
|
+
'no-redeclare': 'error',
|
|
41
|
+
'block-scoped-var': 'error',
|
|
42
|
+
'no-sequences': 'error',
|
|
43
|
+
'no-throw-literal': 'error',
|
|
44
|
+
'no-useless-call': 'error',
|
|
45
|
+
'no-useless-concat': 'error',
|
|
46
|
+
'no-void': 'error',
|
|
47
|
+
yoda: 'error',
|
|
48
|
+
'no-var': 'error',
|
|
49
|
+
'no-bitwise': 'error',
|
|
50
|
+
'no-lonely-if': 'error',
|
|
51
|
+
'arrow-body-style': ['error', 'as-needed'],
|
|
52
|
+
'prefer-arrow-callback': 'error',
|
|
53
|
+
'object-shorthand': 'error',
|
|
54
|
+
'prefer-spread': 'error',
|
|
55
|
+
'no-prototype-builtins': 'off'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
files: ['test/**'],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
globals: { ...globals.node, ...globals.mocha }
|
|
110
62
|
}
|
|
111
|
-
}
|
|
63
|
+
},
|
|
64
|
+
// Repo-specific: overrides go here, each with a one-line reason
|
|
65
|
+
{
|
|
66
|
+
// The vendored imap-core suite (lib/imapproxy/imap-core/test) is mocha-shaped and lives outside test/
|
|
67
|
+
files: ['lib/imapproxy/imap-core/test/**'],
|
|
68
|
+
languageOptions: {
|
|
69
|
+
globals: { ...globals.node, ...globals.mocha }
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
rules: {
|
|
74
|
+
// 524 violations: workers and sync loops await sequentially on purpose (ordering, backpressure, rate limits)
|
|
75
|
+
'no-await-in-loop': 'off',
|
|
76
|
+
// 264 violations: 256 unused catch bindings (optional catch binding would churn 100+ files) and 8 named
|
|
77
|
+
// parameters kept for documented interfaces (base-class stubs, provider overrides, test doubles)
|
|
78
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^_', args: 'none', caughtErrors: 'none' }],
|
|
79
|
+
// 48 violations: IMAP/MIME parsers, crypto, flag masks and hashing need bitwise operators
|
|
80
|
+
'no-bitwise': 'off',
|
|
81
|
+
// 20 violations: closures and hoisted helpers referencing later module-level bindings, fixing means reordering modules
|
|
82
|
+
'no-use-before-define': 'off',
|
|
83
|
+
// 13 violations: SCREAMING_CASE factory constants, the TLS SNICallback option and node:test's lowercase spec reporter class
|
|
84
|
+
'new-cap': 'off',
|
|
85
|
+
// 11 violations: Handlebars helpers and test stubs use the call-site this by design
|
|
86
|
+
'no-invalid-this': 'off',
|
|
87
|
+
// 10 violations: stream transform callbacks followed by other statements, rewriting them risks changing flow
|
|
88
|
+
'callback-return': 'off',
|
|
89
|
+
// 9 violations, all deliberate x == null / x != null checks that cover both null and undefined
|
|
90
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
prettier
|
|
112
94
|
];
|
|
@@ -164,7 +164,26 @@ function planRebalance({ workerAssigned, availableWorkers }, targetWorker) {
|
|
|
164
164
|
return moves;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
// Quick retries after an assignment pass that left accounts unassigned, then a slow one for as long
|
|
168
|
+
// as it takes: the quick ones used to be all there was, so a Redis or worker problem that outlasted
|
|
169
|
+
// them (about 30 seconds) left those accounts unassigned until something unrelated assigned again
|
|
170
|
+
const QUICK_ASSIGN_RETRIES = 3;
|
|
171
|
+
const QUICK_ASSIGN_RETRY_STEP = 5000;
|
|
172
|
+
const SLOW_ASSIGN_RETRY_DELAY = 60 * 1000;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Delay before the next assignment retry
|
|
176
|
+
* @param {number} retry - Consecutive retries so far, including this one (1 based)
|
|
177
|
+
* @returns {number} Milliseconds
|
|
178
|
+
*/
|
|
179
|
+
function assignRetryDelay(retry) {
|
|
180
|
+
return retry <= QUICK_ASSIGN_RETRIES ? QUICK_ASSIGN_RETRY_STEP * retry : SLOW_ASSIGN_RETRY_DELAY;
|
|
181
|
+
}
|
|
182
|
+
|
|
167
183
|
module.exports = {
|
|
184
|
+
assignRetryDelay,
|
|
185
|
+
QUICK_ASSIGN_RETRIES,
|
|
186
|
+
SLOW_ASSIGN_RETRY_DELAY,
|
|
168
187
|
pickLeastLoadedWorker,
|
|
169
188
|
rollbackAssignment,
|
|
170
189
|
releaseWorkerAccounts,
|