emailengine-app 2.79.9 → 2.80.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 (75) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +49 -0
  3. package/config/default.toml +5 -1
  4. package/data/google-crawlers.json +1 -1
  5. package/encrypt.js +43 -0
  6. package/lib/account/account-state.js +62 -0
  7. package/lib/account.js +34 -2
  8. package/lib/api-routes/account-routes.js +20 -0
  9. package/lib/api-routes/index.js +1 -1
  10. package/lib/api-routes/settings-routes.js +17 -2
  11. package/lib/autodetect-imap-settings.js +349 -47
  12. package/lib/cert-handler.js +62 -0
  13. package/lib/consts.js +50 -6
  14. package/lib/db.js +12 -0
  15. package/lib/egress-fetch.js +21 -9
  16. package/lib/email-client/base-client.js +234 -66
  17. package/lib/email-client/credential-errors.js +118 -0
  18. package/lib/email-client/gmail/gmail-api.js +2 -1
  19. package/lib/email-client/gmail-client.js +70 -64
  20. package/lib/email-client/imap/connection-errors.js +52 -0
  21. package/lib/email-client/imap/listing-diff.js +47 -6
  22. package/lib/email-client/imap/mailbox.js +457 -379
  23. package/lib/email-client/imap/subconnection.js +15 -11
  24. package/lib/email-client/imap/sync-operations.js +46 -59
  25. package/lib/email-client/imap-client.js +136 -95
  26. package/lib/email-client/message-builder.js +11 -11
  27. package/lib/email-client/outlook/graph-api.js +2 -1
  28. package/lib/email-client/outlook-client.js +219 -106
  29. package/lib/imap-proxy-auth.js +58 -3
  30. package/lib/imapproxy/imap-server.js +53 -62
  31. package/lib/lua/h-del-if-equals.lua +39 -0
  32. package/lib/lua/h-set-if-equals.lua +39 -0
  33. package/lib/routes-ui.js +4 -34
  34. package/lib/schemas.js +32 -0
  35. package/lib/security-headers.js +15 -0
  36. package/lib/tls/context.js +376 -0
  37. package/lib/tls/der.js +223 -0
  38. package/lib/tls/provision.js +555 -0
  39. package/lib/tls/self-signed.js +282 -0
  40. package/lib/tls/status.js +431 -0
  41. package/lib/tls/store.js +666 -0
  42. package/lib/tools.js +72 -27
  43. package/lib/ui-routes/account-routes.js +43 -30
  44. package/lib/ui-routes/admin-config-routes.js +22 -1
  45. package/lib/ui-routes/auth-routes.js +16 -1
  46. package/lib/ui-routes/internals-routes.js +3 -5
  47. package/lib/ui-routes/network-config-routes.js +54 -45
  48. package/lib/ui-routes/tls-config-routes.js +581 -0
  49. package/lib/utils/mailbox-path.js +51 -0
  50. package/lib/utils/severity.js +31 -0
  51. package/package.json +4 -4
  52. package/sbom.json +1 -1
  53. package/server.js +16 -0
  54. package/static/css/flyonui.css +1 -1
  55. package/static/css/src/app.tailwind.css +11 -0
  56. package/static/js/app.js +34 -0
  57. package/static/js/public.js +6 -2
  58. package/static/js/ui.js +8 -25
  59. package/static/licenses.html +328 -1257
  60. package/translations/messages.pot +87 -87
  61. package/views/account/login-redirect.hbs +22 -0
  62. package/views/config/imap-proxy.hbs +0 -3
  63. package/views/config/smtp.hbs +0 -3
  64. package/views/config/tls-upload.hbs +81 -0
  65. package/views/config/tls.hbs +492 -0
  66. package/views/partials/side_menu.hbs +1 -0
  67. package/views/partials/tls_security_card.hbs +25 -53
  68. package/views/partials/ui/alert-banner.hbs +3 -2
  69. package/views/partials/ui/badge.hbs +6 -2
  70. package/views/partials/ui/btn.hbs +5 -2
  71. package/workers/api.js +93 -134
  72. package/workers/imap-proxy.js +4 -1
  73. package/workers/smtp.js +51 -44
  74. package/views/partials/tls_security_js.hbs +0 -64
  75. package/views/partials/tls_security_modal.hbs +0 -22
@@ -764,3 +764,14 @@
764
764
  background-color: var(--color-base-200);
765
765
  }
766
766
  }
767
+
768
+ /* A table whose cells hold sentences. FlyonUI's .table sets every cell nowrap from the
769
+ * utilities layer, which is right for ids and badges and wrong for a status line under a
770
+ * hostname. A utility of our own is the only thing that can outrank it: same layer, and
771
+ * :is() carries the element's specificity where the library's :where() carries none. A cell
772
+ * that must stay on one line puts whitespace-nowrap on a wrapper inside the cell. */
773
+ @utility ee-table-wrap {
774
+ & :is(th, td) {
775
+ white-space: normal;
776
+ }
777
+ }
package/static/js/app.js CHANGED
@@ -379,6 +379,14 @@ document.addEventListener('DOMContentLoaded', () => {
379
379
  updateServerStateIndicators('imapProxy', data);
380
380
  break;
381
381
  }
382
+
383
+ // Page-scoped listeners (the TLS page follows certificate provisioning this way) get
384
+ // every event, including the ones this switch does not paint a badge for. One stream
385
+ // per page: a second EventSource would be a second authenticated connection for the
386
+ // same feed.
387
+ if (data) {
388
+ document.dispatchEvent(new CustomEvent('ee:change', { detail: data }));
389
+ }
382
390
  };
383
391
 
384
392
  evtSource.onerror = function (e) {
@@ -412,3 +420,29 @@ document.addEventListener('DOMContentLoaded', () => {
412
420
  }
413
421
 
414
422
  });
423
+
424
+ // "Choose file" buttons: a .file-picker-btn with data-file-target="#selector" reads the picked
425
+ // file as text into that control (a PEM certificate into its textarea). Delegated, so a page
426
+ // needs no script of its own for it; the .droptxt class on the same control adds drag and drop.
427
+ document.addEventListener('click', e => {
428
+ let btn = e.target.closest('.file-picker-btn');
429
+ if (!btn) {
430
+ return;
431
+ }
432
+ e.preventDefault();
433
+
434
+ let target = btn.dataset.fileTarget ? document.querySelector(btn.dataset.fileTarget) : null;
435
+ if (!target) {
436
+ return;
437
+ }
438
+
439
+ window
440
+ .browseFileContents('text')
441
+ .then(contents => {
442
+ if (contents) {
443
+ target.value = contents.toString().trim();
444
+ target.focus();
445
+ }
446
+ })
447
+ .catch(err => window.showToast('Could not read the file\n' + err.message, 'alert-triangle'));
448
+ });
@@ -153,11 +153,15 @@ window.eeButtonBusy = (btn, busy) => {
153
153
  // the event by the time this sees it.
154
154
  document.addEventListener('submit', e => {
155
155
  let form = e.target;
156
- if (e.defaultPrevented || !form || form.method !== 'post') {
156
+ // Attributes rather than properties: a control named `method` or `target` shadows the
157
+ // same-named property on HTMLFormElement
158
+ if (e.defaultPrevented || !form || (form.getAttribute('method') || 'get').toLowerCase() !== 'post') {
157
159
  return;
158
160
  }
159
161
 
160
- let target = form.target.trim().toLowerCase();
162
+ // The attribute, not the property: a form control named `target` shadows
163
+ // HTMLFormElement.target, and reading the property would throw on such a form
164
+ let target = (form.getAttribute('target') || '').trim().toLowerCase();
161
165
  if (target && target !== '_self') {
162
166
  return;
163
167
  }
package/static/js/ui.js CHANGED
@@ -293,29 +293,6 @@ window.uiEditorFullscreen = editors => {
293
293
  }
294
294
  };
295
295
 
296
- // Repaint the #tls-label certificate badge (config/smtp and config/imap-proxy
297
- // pages) from a certificate-check response: badge color, label text and the
298
- // FlyonUI tooltip body that carries the status details
299
- window.paintCertData = certData => {
300
- let tlsLabelElm = document.getElementById('tls-label');
301
-
302
- if (!certData || !certData.label || !tlsLabelElm) {
303
- return;
304
- }
305
-
306
- tlsLabelElm.classList.remove(`badge-${tlsLabelElm.dataset.labeltype}`);
307
- tlsLabelElm.classList.add(`badge-${certData.label.type}`);
308
- tlsLabelElm.dataset.labeltype = certData.label.type;
309
-
310
- tlsLabelElm.textContent = certData.label.text;
311
-
312
- let tooltipBodyElm = tlsLabelElm.closest('.tooltip');
313
- tooltipBodyElm = tooltipBodyElm && tooltipBodyElm.querySelector('.tooltip-body');
314
- if (tooltipBodyElm) {
315
- tooltipBodyElm.textContent = certData.label.title;
316
- }
317
- };
318
-
319
296
  // Keyboard hints that spell a modifier differently on macOS (ui/search-input
320
297
  // renders `shortcut` with an optional `shortcutMac`). The server cannot know
321
298
  // the platform, so it emits the Ctrl form and the Mac spelling rides along in
@@ -620,13 +597,19 @@ const uiFormBusy = new Map();
620
597
  // this guard by not being POST forms.)
621
598
  document.addEventListener('submit', event => {
622
599
  const form = event.target;
623
- if (event.defaultPrevented || !form || form.method !== 'post') {
600
+ // Attributes rather than properties throughout: a form control named `method` or `target`
601
+ // shadows the same-named property on HTMLFormElement, and this handler runs on every form.
602
+ if (event.defaultPrevented || !form || (form.getAttribute('method') || 'get').toLowerCase() !== 'post') {
624
603
  return;
625
604
  }
626
605
 
627
606
  // A form aimed at another browsing context leaves this page in place, so
628
607
  // there is no navigation to end the busy state and nothing to latch.
629
- const target = form.target.trim().toLowerCase();
608
+ //
609
+ // Read the attribute, not the property: a form control named `target` shadows
610
+ // HTMLFormElement.target, so form.target can be an <input> element. That threw here and took
611
+ // every busy button on the page down with it.
612
+ const target = (form.getAttribute('target') || '').trim().toLowerCase();
630
613
  if (target && target !== '_self') {
631
614
  return;
632
615
  }