emailengine-app 2.79.6 → 2.79.8

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 (109) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +32 -0
  3. package/DOCKER_DEPLOYMENT.md +2 -0
  4. package/bin/emailengine.js +29 -13
  5. package/config/default.toml +13 -3
  6. package/data/google-crawlers.json +7 -1
  7. package/docker-compose.yml +12 -3
  8. package/install.sh +2 -0
  9. package/lib/api-routes/account-routes.js +14 -3
  10. package/lib/api-routes/mailbox-routes.js +4 -1
  11. package/lib/api-routes/message-routes.js +6 -5
  12. package/lib/api-routes/outbox-routes.js +7 -4
  13. package/lib/api-routes/settings-routes.js +34 -25
  14. package/lib/api-routes/stats-routes.js +8 -1
  15. package/lib/api-routes/submit-routes.js +2 -1
  16. package/lib/api-routes/template-routes.js +3 -2
  17. package/lib/bounce-detect.js +45 -0
  18. package/lib/consts.js +9 -3
  19. package/lib/egress-filter.js +39 -4
  20. package/lib/email-client/base-client.js +274 -24
  21. package/lib/email-client/gmail/gmail-api.js +15 -7
  22. package/lib/email-client/gmail-client.js +121 -64
  23. package/lib/email-client/imap/mailbox.js +18 -59
  24. package/lib/email-client/imap-client.js +53 -29
  25. package/lib/email-client/notification-handler.js +11 -2
  26. package/lib/email-client/outlook/graph-api.js +106 -90
  27. package/lib/email-client/outlook-client.js +222 -106
  28. package/lib/generate-text-preview.js +10 -5
  29. package/lib/headers-rewriter.js +1 -1
  30. package/lib/llm-pre-process.js +4 -1
  31. package/lib/mcp/json-schema.js +50 -2
  32. package/lib/outbox.js +22 -5
  33. package/lib/passkeys.js +39 -7
  34. package/lib/pre-process.js +4 -1
  35. package/lib/rewrite-text-nodes.js +12 -1
  36. package/lib/schemas.js +27 -5
  37. package/lib/settings.js +19 -1
  38. package/lib/sso.js +60 -7
  39. package/lib/submit-progress.js +29 -0
  40. package/lib/templates.js +11 -0
  41. package/lib/tools.js +115 -53
  42. package/lib/ui-routes/account-routes.js +79 -12
  43. package/lib/ui-routes/admin-config-routes.js +7 -21
  44. package/lib/ui-routes/admin-entities-routes.js +42 -12
  45. package/lib/ui-routes/auth-routes.js +242 -87
  46. package/lib/ui-routes/dashboard-routes.js +1 -1
  47. package/lib/ui-routes/internals-routes.js +2 -0
  48. package/lib/ui-routes/mcp-consent-routes.js +5 -2
  49. package/lib/ui-routes/network-config-routes.js +12 -3
  50. package/lib/ui-routes/oauth-config-routes.js +12 -1
  51. package/lib/ui-routes/route-helpers.js +41 -6
  52. package/lib/ui-routes/settings-page.js +10 -0
  53. package/lib/ui-routes/suppression-list-routes.js +16 -5
  54. package/lib/ui-routes/unsubscribe-routes.js +22 -3
  55. package/lib/webhooks.js +14 -2
  56. package/package.json +17 -17
  57. package/sbom.json +1 -1
  58. package/server.js +63 -35
  59. package/static/css/flyonui.css +1 -1
  60. package/static/css/src/app.tailwind.css +55 -0
  61. package/static/js/app.js +4 -35
  62. package/static/js/passkey-register.js +50 -1
  63. package/static/js/public.js +128 -0
  64. package/static/js/ui.js +183 -6
  65. package/static/licenses.html +371 -770
  66. package/translations/messages.pot +66 -66
  67. package/views/account/passkeys.hbs +141 -0
  68. package/views/account/password.hbs +11 -0
  69. package/views/account/security.hbs +318 -326
  70. package/views/accounts/account.hbs +90 -115
  71. package/views/accounts/register/imap-server.hbs +18 -12
  72. package/views/config/ai.hbs +2 -0
  73. package/views/config/branding.hbs +2 -0
  74. package/views/config/document-store/index.hbs +6 -6
  75. package/views/config/email-processing.hbs +2 -0
  76. package/views/config/imap-proxy.hbs +2 -0
  77. package/views/config/license.hbs +4 -1
  78. package/views/config/logging.hbs +3 -1
  79. package/views/config/mcp.hbs +2 -0
  80. package/views/config/network.hbs +2 -0
  81. package/views/config/oauth/app.hbs +3 -3
  82. package/views/config/oauth/edit.hbs +1 -1
  83. package/views/config/oauth/new.hbs +1 -1
  84. package/views/config/security.hbs +2 -0
  85. package/views/config/service.hbs +2 -0
  86. package/views/config/smtp.hbs +2 -0
  87. package/views/config/webhooks.hbs +9 -6
  88. package/views/error.hbs +6 -0
  89. package/views/layout/app.hbs +6 -3
  90. package/views/layout/login.hbs +1 -1
  91. package/views/layout/prompt.hbs +1 -1
  92. package/views/layout/public.hbs +1 -1
  93. package/views/legal.hbs +1 -1
  94. package/views/partials/filter_editor_js.hbs +1 -1
  95. package/views/partials/gateway_js.hbs +7 -6
  96. package/views/partials/oauth_form.hbs +5 -5
  97. package/views/partials/ui/btn.hbs +8 -2
  98. package/views/partials/ui/confirm-modal.hbs +2 -3
  99. package/views/partials/ui/empty-state.hbs +25 -0
  100. package/views/partials/ui/env-managed-alert.hbs +19 -0
  101. package/views/partials/webhook_form.hbs +1 -1
  102. package/views/partials/webhooks_editor_functions.hbs +5 -5
  103. package/views/unsubscribe.hbs +6 -0
  104. package/workers/api.js +193 -81
  105. package/workers/imap.js +32 -3
  106. package/workers/smtp.js +7 -0
  107. package/workers/submit.js +25 -1
  108. package/workers/webhooks.js +13 -17
  109. package/lib/reconnection-manager.js +0 -106
@@ -82,6 +82,23 @@ const ACCOUNT_STATE_DISPLAY = [
82
82
  { state: 'unset', label: 'Not syncing', variant: 'neutral' }
83
83
  ];
84
84
 
85
+ // The wording for the two ImapFlow closed-after-connect codes, shared by the account state
86
+ // badge (accountStateLabel below) and the connection check on the account form
87
+ // (lib/ui-routes/account-routes.js), so the two cannot drift. The Text variant keeps the TLS
88
+ // hint because a wrong port/TLS pairing is the usual cause. Null for any other code.
89
+ function closedAfterConnectMessage(code, gt) {
90
+ switch (code) {
91
+ case 'ClosedAfterConnectTLS':
92
+ return gt.gettext('The server unexpectedly closed the connection.');
93
+ case 'ClosedAfterConnectText':
94
+ return gt.gettext(
95
+ 'The server unexpectedly closed the connection. This usually happens when attempting to connect to a TLS port without TLS enabled.'
96
+ );
97
+ default:
98
+ return null;
99
+ }
100
+ }
101
+
85
102
  // State badge descriptor for an account, shared by the server-rendered views
86
103
  // (formatAccountData below) and the live SSE change feed (publishChangeEvent in
87
104
  // workers/api.js), so the badge cannot drift between page load and repaint.
@@ -132,12 +149,8 @@ function accountStateLabel(state, opts, gt) {
132
149
  errorMessage = gt.gettext('Connection timed out. This usually occurs if you are behind a firewall or connecting to the wrong port.');
133
150
  break;
134
151
  case 'ClosedAfterConnectTLS':
135
- errorMessage = gt.gettext('The server unexpectedly closed the connection.');
136
- break;
137
152
  case 'ClosedAfterConnectText':
138
- errorMessage = gt.gettext(
139
- 'The server unexpectedly closed the connection. This usually happens when attempting to connect to a TLS port without TLS enabled.'
140
- );
153
+ errorMessage = closedAfterConnectMessage(lastErrorState.serverResponseCode, gt);
141
154
  break;
142
155
  case 'ECONNREFUSED':
143
156
  errorMessage = gt.gettext(
@@ -397,6 +410,26 @@ function adminUrl(strings, ...values) {
397
410
  return strings.reduce((url, part, i) => url + part + (i < values.length ? encodeURIComponent(values[i]) : ''), '');
398
411
  }
399
412
 
413
+ /**
414
+ * The submitted form fields for an error re-render, minus the secrets.
415
+ *
416
+ * A form re-rendered after a failed save shows what was typed rather than the stored record, so
417
+ * a validation error does not clear the form. The named secret fields are blanked, not echoed
418
+ * into the page: a password or a client secret is typed again, the way the account form treats
419
+ * its passwords.
420
+ *
421
+ * @param {Object} request - the Hapi request, whose payload is the submitted form
422
+ * @param {...String} secretFields - payload keys to blank
423
+ * @returns {Object}
424
+ */
425
+ function submittedValues(request, ...secretFields) {
426
+ const values = Object.assign({}, request.payload);
427
+ for (const field of secretFields) {
428
+ values[field] = '';
429
+ }
430
+ return values;
431
+ }
432
+
400
433
  function buildPagingView(basePath, data, query) {
401
434
  const getPagingUrl = page => {
402
435
  let url = new URL(basePath, 'http://localhost');
@@ -562,6 +595,7 @@ module.exports = {
562
595
  OPEN_AI_MODELS,
563
596
  cachedTemplates,
564
597
  getOpenAiModels,
598
+ closedAfterConnectMessage,
565
599
  accountStateLabel,
566
600
  ACCOUNT_STATE_DISPLAY,
567
601
  formatServerState,
@@ -572,5 +606,6 @@ module.exports = {
572
606
  isClientError,
573
607
  authAwareLevel,
574
608
  buildPagingView,
575
- adminUrl
609
+ adminUrl,
610
+ submittedValues
576
611
  };
@@ -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
 
@@ -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
- return h.redirect('/admin/suppression-lists').takeover();
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
- await request.flash({ type: 'danger', message: `Couldn't add the address. Check the list ID and email address and try again.` });
186
- request.logger.error({ msg: 'Failed to add suppression list entry', err });
187
-
188
- return h.redirect('/admin/suppression-lists').takeover();
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
- throw new Error(request.app.gt.gettext('Invalid input'));
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
- let signed = await parseSignedFormData(redis, { data: request.payload.data, sig: request.payload.sig }, request.app.gt);
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/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
- this.handlerCache.push(handler);
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
- this.handlerCache[i] = handler;
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.6",
3
+ "version": "2.79.8",
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.5.0",
55
- "@bull-board/hapi": "9.5.0",
54
+ "@bull-board/api": "9.6.1",
55
+ "@bull-board/hapi": "9.6.1",
56
56
  "@elastic/elasticsearch": "8.15.3",
57
57
  "@hapi/accept": "6.0.3",
58
58
  "@hapi/bell": "13.1.0",
@@ -65,24 +65,24 @@
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.0.18",
68
+ "@postalsys/certs": "1.0.19",
69
69
  "@postalsys/ee-client": "1.7.0",
70
- "@postalsys/email-ai-tools": "1.13.20",
71
- "@postalsys/email-content": "0.1.3",
72
- "@postalsys/email-text-tools": "2.4.14",
70
+ "@postalsys/email-ai-tools": "1.13.24",
71
+ "@postalsys/email-content": "0.1.4",
72
+ "@postalsys/email-text-tools": "2.4.15",
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.71.0",
76
+ "@sentry/node": "10.73.0",
77
77
  "@simplewebauthn/browser": "13.3.0",
78
78
  "@simplewebauthn/server": "13.3.3",
79
- "@zone-eu/mailsplit": "5.4.15",
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.1",
82
+ "bullmq": "6.3.4",
83
83
  "compare-versions": "6.1.1",
84
84
  "dotenv": "17.4.2",
85
- "encoding-japanese": "2.2.0",
85
+ "encoding-japanese": "2.3.0",
86
86
  "exponential-backoff": "3.1.3",
87
87
  "fast-xml-parser": "5.11.1",
88
88
  "gettext-parser": "7.0.1",
@@ -93,27 +93,27 @@
93
93
  "html-to-text": "10.0.1",
94
94
  "ical.js": "1.5.0",
95
95
  "iconv-lite": "0.7.3",
96
- "imapflow": "1.7.6",
96
+ "imapflow": "1.7.8",
97
97
  "ioredfour": "1.4.3",
98
98
  "ioredis": "6.0.0",
99
99
  "ipaddr.js": "2.5.0",
100
100
  "joi": "18.2.5",
101
101
  "libbase64": "1.3.0",
102
- "libmime": "5.4.2",
102
+ "libmime": "5.4.3",
103
103
  "libqp": "2.1.1",
104
- "mailparser": "3.9.17",
104
+ "mailparser": "3.9.20",
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": "9.0.6",
109
+ "nodemailer": "9.1.1",
110
110
  "pino": "10.3.1",
111
111
  "prom-client": "15.1.3",
112
112
  "psl": "1.15.0",
113
- "pubface": "1.1.7",
113
+ "pubface": "1.1.9",
114
114
  "punycode.js": "2.3.1",
115
115
  "qrcode": "1.5.4",
116
- "smtp-server": "3.19.4",
116
+ "smtp-server": "3.19.6",
117
117
  "socks": "2.8.9",
118
118
  "timezones-list": "3.1.0",
119
119
  "undici": "7.29.0"