emailengine-app 2.87.2 → 2.89.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.
Files changed (71) hide show
  1. package/.ncurc.js +24 -44
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +37 -0
  4. package/ENVIRONMENT.md +26 -23
  5. package/LICENSE_EMAILENGINE.txt +20 -12
  6. package/app.json +3 -3
  7. package/bin/emailengine.js +7 -11
  8. package/data/google-crawlers.json +1 -1
  9. package/data/public_suffix_list.dat +155 -16
  10. package/lib/account.js +69 -49
  11. package/lib/admin-password.js +85 -0
  12. package/lib/api-routes/license-routes.js +9 -0
  13. package/lib/api-token-auth.js +21 -5
  14. package/lib/calendar-event.js +15 -3
  15. package/lib/consts.js +5 -0
  16. package/lib/db.js +1 -0
  17. package/lib/email-client/base-client.js +36 -15
  18. package/lib/email-client/gmail-client.js +20 -6
  19. package/lib/email-client/imap/connection-errors.js +30 -1
  20. package/lib/email-client/imap/session-expiry.js +83 -0
  21. package/lib/email-client/imap-client.js +12 -2
  22. package/lib/email-client/smtp-pool-manager.js +66 -8
  23. package/lib/export.js +147 -22
  24. package/lib/graph-notifications.js +60 -0
  25. package/lib/imap-proxy-auth.js +52 -18
  26. package/lib/imapproxy/imap-core/lib/commands/id.js +4 -2
  27. package/lib/imapproxy/imap-core/lib/imap-command.js +44 -4
  28. package/lib/imapproxy/imap-server.js +10 -1
  29. package/lib/imapproxy/proxy-handoff.js +100 -5
  30. package/lib/license-subscription.js +244 -0
  31. package/lib/node-version.js +99 -12
  32. package/lib/oauth/gmail.js +18 -0
  33. package/lib/oauth/outlook-identity.js +54 -12
  34. package/lib/prepared-password.js +38 -0
  35. package/lib/queue-browser/index.js +6 -6
  36. package/lib/queue-job-actions.js +59 -4
  37. package/lib/read-env-value.js +46 -21
  38. package/lib/redis-url.js +23 -0
  39. package/lib/response-stream.js +69 -1
  40. package/lib/revocation-events.js +79 -0
  41. package/lib/schemas.js +18 -2
  42. package/lib/settings.js +50 -24
  43. package/lib/sso.js +23 -0
  44. package/lib/submit-penalty.js +24 -0
  45. package/lib/submit-processor.js +10 -2
  46. package/lib/tokens.js +6 -0
  47. package/lib/tools.js +90 -18
  48. package/lib/ui-routes/admin-config-routes.js +3 -276
  49. package/lib/ui-routes/auth-routes.js +13 -64
  50. package/lib/ui-routes/dashboard-routes.js +4 -0
  51. package/lib/ui-routes/license-routes.js +326 -0
  52. package/lib/web-safe-html.js +74 -1
  53. package/lib/webhook-delivery.js +21 -20
  54. package/lib/webhook-penalty.js +18 -17
  55. package/lib/webhooks.js +18 -0
  56. package/list-generate.js +56 -19
  57. package/package.json +28 -31
  58. package/sbom.json +373 -964
  59. package/scan.js +2 -0
  60. package/server.js +273 -100
  61. package/static/css/flyonui.css +2 -2
  62. package/static/js/ui.js +11 -4
  63. package/static/licenses.html +1108 -504
  64. package/translations/messages.pot +18 -18
  65. package/views/config/license.hbs +43 -16
  66. package/views/dashboard.hbs +9 -0
  67. package/views/partials/side_menu.hbs +1 -1
  68. package/views/upgrade.hbs +25 -0
  69. package/workers/api.js +108 -107
  70. package/workers/imap.js +4 -6
  71. package/lib/net-tos-guard.js +0 -42
@@ -6,18 +6,19 @@
6
6
  // that accepts the connection and never answers costs the whole attempt timeout (30 seconds by
7
7
  // default). One account pointing its own webhook URL at such a target, and generating a dozen
8
8
  // events a minute, kept the queue busy with timeouts and delayed every other account's
9
- // deliveries behind them, indefinitely. So a target whose attempt just ran into the timeout is
10
- // penalised: for a short while, deliveries to the same origin are moved back to the delayed set
9
+ // deliveries behind them, indefinitely. So a target whose attempt held the worker for most of the
10
+ // timeout is penalised: for a short while, deliveries to the same origin are moved back to the delayed set
11
11
  // instead of being attempted, and the queue spends its time on targets that answer. The
12
12
  // penalised delivery is not lost, it is tried again once the penalty is over, with its attempt
13
13
  // count unchanged.
14
14
  //
15
- // Only the slow failures count. A refused or reset connection and a name that does not resolve
16
- // fail in milliseconds, so they never hold the queue, and penalising them would defer every
17
- // delivery to a receiver for a minute because it was restarting when one attempt arrived. A
18
- // target answering with an HTTP status, any status, is not penalised either: it answered
19
- // quickly, and the retry schedule already spaces those out. Nor is an egress or redirect
20
- // refusal, which fails the job for good anyway.
15
+ // Only the slow attempts count: one that ran into a deadline, and one that held the worker for at
16
+ // least half the attempt timeout before it ended, whatever the receiver answered. The receiver
17
+ // chooses its answer, so keying on it let a target hold every attempt just short of the timeout
18
+ // and answer 500, or 200, and never be penalised. A refused or reset connection and a name that
19
+ // does not resolve fail in milliseconds, so they never hold the queue, and penalising them would
20
+ // defer every delivery to a receiver for a minute because it was restarting when one attempt
21
+ // arrived. Nor is an egress or redirect refusal penalised, which fails the job for good anyway.
21
22
 
22
23
  const { createHash } = require('crypto');
23
24
  const { REDIS_PREFIX } = require('./consts');
@@ -50,19 +51,19 @@ function penaltyKey(url) {
50
51
  }
51
52
 
52
53
  /**
53
- * How long a target is penalised after a failed attempt, in milliseconds; 0 when the failure is
54
- * not the kind that holds the queue.
54
+ * How long a target is penalised after an attempt, in milliseconds; 0 when the attempt is not the
55
+ * kind that holds the queue.
55
56
  *
56
- * @param {Error} err - the failure
57
+ * @param {Error|null} err - the failure, or null for a delivered attempt
57
58
  * @param {Number} attemptTimeout - the per-attempt wall clock cap, in milliseconds
59
+ * @param {Number} [duration] - how long the attempt took, in milliseconds
58
60
  * @returns {Number}
59
61
  */
60
- function penaltyFor(err, attemptTimeout) {
61
- if (!err || typeof err !== 'object') {
62
- return 0;
63
- }
64
- let code = err.code || (err.cause && err.cause.code);
65
- if (!code || !SLOW_FAILURE_CODES.has(code)) {
62
+ function penaltyFor(err, attemptTimeout, duration) {
63
+ let code = err && typeof err === 'object' && (err.code || (err.cause && err.cause.code));
64
+ let timedOut = !!code && SLOW_FAILURE_CODES.has(code);
65
+ let slow = Number(attemptTimeout) > 0 && Number(duration) >= Number(attemptTimeout) / 2;
66
+ if (!timedOut && !slow) {
66
67
  return 0;
67
68
  }
68
69
  // twice the attempt cap: long enough that a dozen events a minute to a dead target no
package/lib/webhooks.js CHANGED
@@ -631,6 +631,13 @@ class WebhooksHandler {
631
631
  } else if (data.text && truncateTextContents(data.text, notifyTextSize)) {
632
632
  data.text.hasMore = true;
633
633
  }
634
+
635
+ // The web-safe copy replaces the HTML below, after this limit was applied to the HTML,
636
+ // so it is held to the same limit: with inline images embedded it can be far larger
637
+ if (data.text && notifyText && notifyTextSize && typeof data.text._generatedHtml === 'string' && data.text._generatedHtml.length > notifyTextSize) {
638
+ data.text._generatedHtml = data.text._generatedHtml.substr(0, notifyTextSize);
639
+ data.text.hasMore = true;
640
+ }
634
641
  }
635
642
 
636
643
  if (data.headers) {
@@ -655,6 +662,17 @@ class WebhooksHandler {
655
662
  delete data.otp;
656
663
  }
657
664
 
665
+ // Calendar files are attachments too, and their description is message text: both used to
666
+ // be copied in whole whatever the two limits said
667
+ for (let calendarEvent of data.calendarEvents || []) {
668
+ if (calendarEvent.content && !withinNotifyAttachmentSize(calendarEvent, notifyAttachmentSize)) {
669
+ delete calendarEvent.content;
670
+ }
671
+ if (notifyTextSize && typeof calendarEvent.description === 'string' && calendarEvent.description.length > notifyTextSize) {
672
+ calendarEvent.description = calendarEvent.description.substr(0, notifyTextSize);
673
+ }
674
+ }
675
+
658
676
  // remove attachment contents
659
677
  if (data.attachments) {
660
678
  for (let attachment of data.attachments) {
package/list-generate.js CHANGED
@@ -53,10 +53,7 @@ const ASSET_PACKAGES = [
53
53
  const LICENSE_OVERRIDES = {
54
54
  // our own package; the LICENSE file is MIT but package.json lacks the
55
55
  // license field (fix upstream in postalsys/gettext, then drop this)
56
- '@postalsys/gettext': 'MIT',
57
- // declares the free-text "MIT (http://mootools.net/license.txt)"
58
- // instead of an SPDX id
59
- slick: 'MIT'
56
+ '@postalsys/gettext': 'MIT'
60
57
  };
61
58
 
62
59
  // Hand-vendored assets that are not npm dependencies. gateExempt entries skip
@@ -162,26 +159,66 @@ function collect(dirs, section) {
162
159
  if (pkg.private || !pkg.name || pkg.name === packageData.name) {
163
160
  continue;
164
161
  }
165
- let key = `${pkg.name}@${pkg.version}`;
166
- let entry = packages.get(key);
167
- if (!entry) {
168
- entry = {
169
- name: pkg.name,
170
- version: pkg.version || '',
171
- license: LICENSE_OVERRIDES[pkg.name] || (typeof pkg.license === 'string' ? pkg.license : (pkg.license && pkg.license.type) || ''),
172
- homepage: homepageOf(pkg),
173
- sections: [],
174
- licenseText: findLicenseText(dir)
175
- };
176
- packages.set(key, entry);
162
+ addPackage(pkg, section, { homepage: homepageOf(pkg), licenseText: () => findLicenseText(dir) });
163
+ }
164
+ }
165
+
166
+ // Lists a package under a section, once per name and version. `licenseText` is read only for a
167
+ // package not seen before
168
+ function addPackage(pkg, section, { homepage, licenseText }) {
169
+ let key = `${pkg.name}@${pkg.version}`;
170
+ let entry = packages.get(key);
171
+ if (!entry) {
172
+ entry = {
173
+ name: pkg.name,
174
+ version: pkg.version || '',
175
+ license: LICENSE_OVERRIDES[pkg.name] || (typeof pkg.license === 'string' ? pkg.license : (pkg.license && pkg.license.type) || ''),
176
+ homepage,
177
+ sections: [],
178
+ licenseText: licenseText()
179
+ };
180
+ packages.set(key, entry);
181
+ }
182
+ if (!entry.sections.includes(section)) {
183
+ entry.sections.push(section);
184
+ }
185
+ }
186
+
187
+ // Packages bundled into a dependency's own files, which npm ls never sees: @postalsys/email-text-tools
188
+ // ships jsdom and juice, with everything they load, as dist/vendor/<name>.cjs. Such a package lists
189
+ // the bundled packages in dist/vendor/<name>.packages.json and their license texts, in the same
190
+ // order, in dist/vendor/<name>.LICENSES.txt (a header, then one "name@version (license)" block per
191
+ // package, separated by a line of dashes). They are runtime code like any other dependency, so the
192
+ // license gate below applies to them too.
193
+ const VENDOR_SEPARATOR = '\n\n' + '-'.repeat(72) + '\n\n';
194
+
195
+ function collectVendored(dirs) {
196
+ for (let dir of dirs) {
197
+ let vendorDir = path.join(dir, 'dist', 'vendor');
198
+ if (!fs.existsSync(vendorDir)) {
199
+ continue;
177
200
  }
178
- if (!entry.sections.includes(section)) {
179
- entry.sections.push(section);
201
+ for (let file of fs.readdirSync(vendorDir).filter(name => name.endsWith('.packages.json'))) {
202
+ let bundled = JSON.parse(fs.readFileSync(path.join(vendorDir, file), 'utf8'));
203
+ let licensesFile = path.join(vendorDir, file.replace(/\.packages\.json$/, '.LICENSES.txt'));
204
+ let texts = new Map();
205
+ if (fs.existsSync(licensesFile)) {
206
+ for (let block of fs.readFileSync(licensesFile, 'utf8').split(VENDOR_SEPARATOR).slice(1)) {
207
+ let [title, ...rest] = block.split('\n\n');
208
+ let text = rest.join('\n\n').trim();
209
+ texts.set(title.replace(/ \(.*\)$/, ''), /^Licensed under [^\n]*\.$/.test(text) ? null : text);
210
+ }
211
+ }
212
+ for (let pkg of bundled) {
213
+ addPackage(pkg, 'runtime', { homepage: null, licenseText: () => texts.get(`${pkg.name}@${pkg.version}`) || null });
214
+ }
180
215
  }
181
216
  }
182
217
  }
183
218
 
184
- collect(prodDependencyPaths(), 'runtime');
219
+ const runtimeDirs = prodDependencyPaths();
220
+ collect(runtimeDirs, 'runtime');
221
+ collectVendored(runtimeDirs);
185
222
  collect(
186
223
  ASSET_PACKAGES.map(name => path.join(__dirname, 'node_modules', name)),
187
224
  'assets'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emailengine-app",
3
- "version": "2.87.2",
3
+ "version": "2.89.0",
4
4
  "private": false,
5
5
  "productTitle": "EmailEngine",
6
6
  "description": "Email Sync Engine",
@@ -65,76 +65,73 @@
65
65
  "@hapi/vision": "7.0.3",
66
66
  "@msgpack/msgpack": "3.1.3",
67
67
  "@postalsys/bounce-classifier": "3.1.0",
68
- "@postalsys/certs": "2.0.4",
69
- "@postalsys/email-ai-tools": "2.4.2",
70
- "@postalsys/email-content": "0.1.20",
71
- "@postalsys/email-text-tools": "2.6.3",
72
- "@postalsys/gettext": "4.3.0",
68
+ "@postalsys/certs": "3.0.0",
69
+ "@postalsys/email-ai-tools": "3.0.1",
70
+ "@postalsys/email-content": "0.1.22",
71
+ "@postalsys/email-text-tools": "3.0.1",
72
+ "@postalsys/gettext": "4.3.1",
73
73
  "@postalsys/joi-messages": "1.4.1",
74
74
  "@postalsys/templates": "2.1.1",
75
75
  "@sentry/node-core": "10.78.0",
76
- "@simplewebauthn/server": "14.0.3",
77
- "@zone-eu/mailsplit": "5.4.30",
76
+ "@simplewebauthn/server": "14.1.0",
77
+ "@zone-eu/mailsplit": "5.4.31",
78
78
  "@zone-eu/wild-config": "1.7.10",
79
- "bullmq": "6.7.0",
80
- "dotenv": "18.0.9",
81
- "fast-xml-parser": "5.12.0",
79
+ "bullmq": "6.7.6",
80
+ "dotenv": "18.0.10",
81
+ "fast-xml-parser": "5.12.1",
82
82
  "handlebars": "4.7.10",
83
83
  "he": "1.2.0",
84
84
  "html-to-text": "10.0.1",
85
85
  "ical.js": "2.2.1",
86
86
  "iconv-lite": "0.7.3",
87
- "imapflow": "2.10.2",
87
+ "imapflow": "2.12.1",
88
88
  "ioredfour": "2.2.0",
89
89
  "ioredis": "6.0.0",
90
90
  "ipaddr.js": "2.5.0",
91
91
  "joi": "18.3.2",
92
92
  "libbase64": "1.4.1",
93
- "libmime": "5.6.4",
94
- "libqp": "3.0.1",
95
- "mailparser": "3.14.2",
93
+ "libmime": "5.6.5",
94
+ "libqp": "3.0.2",
95
+ "mailparser": "3.14.4",
96
96
  "marked": "15.0.12",
97
97
  "minimist": "1.2.8",
98
- "nodemailer": "10.3.1",
98
+ "nodemailer": "10.6.0",
99
99
  "pino": "10.3.1",
100
100
  "prom-client": "15.1.3",
101
101
  "pubface": "1.2.0",
102
102
  "punycode.js": "2.3.1",
103
103
  "qrcode-generator": "2.0.4",
104
- "smtp-server": "3.21.3",
104
+ "smtp-server": "3.21.5",
105
105
  "socks": "2.8.10",
106
- "undici": "7.30.1"
106
+ "undici": "8.12.4"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@eslint/js": "10.0.1",
110
- "@iconify-json/tabler": "1.2.43",
110
+ "@iconify-json/tabler": "1.2.46",
111
111
  "@iconify/tailwind4": "1.2.3",
112
112
  "@playwright/test": "1.63.0",
113
113
  "@postalsys/ee-client": "1.10.0",
114
114
  "@simplewebauthn/browser": "14.0.0",
115
- "@tailwindcss/cli": "4.3.4",
115
+ "@tailwindcss/cli": "4.3.5",
116
116
  "ace-builds": "1.45.2",
117
117
  "acorn": "8.19.0",
118
118
  "acorn-walk": "8.3.5",
119
119
  "eerawlog": "1.5.5",
120
- "eslint": "10.14.0",
120
+ "eslint": "10.15.0",
121
121
  "eslint-config-prettier": "10.1.8",
122
122
  "flyonui": "2.4.1",
123
123
  "gettext-parser": "7.0.1",
124
124
  "globals": "17.14.0",
125
125
  "pino-pretty": "13.2.0",
126
- "prettier": "3.9.10",
127
- "resedit": "3.1.0",
128
- "spdx-satisfies": "6.0.0",
129
- "supertest": "7.3.1",
130
- "tailwindcss": "4.3.4",
131
- "xgettext-template": "5.0.0"
132
- },
133
- "overrides": {
134
- "cheerio": "1.2.0"
126
+ "prettier": "3.10.1",
127
+ "resedit": "3.1.1",
128
+ "spdx-satisfies": "6.0.1",
129
+ "supertest": "7.3.2",
130
+ "tailwindcss": "4.3.5",
131
+ "xgettext-template": "7.0.0"
135
132
  },
136
133
  "engines": {
137
- "node": ">=20.19.0"
134
+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
138
135
  },
139
136
  "pkg": {
140
137
  "scripts": [