emailengine-app 2.79.8 → 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 (182) hide show
  1. package/.github/dependabot.yml +22 -0
  2. package/.github/workflows/test.yml +39 -0
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +69 -0
  5. package/DOCKER_DEPLOYMENT.md +6 -7
  6. package/Dockerfile +35 -11
  7. package/config/default.toml +7 -2
  8. package/copy-static-files.sh +23 -5
  9. package/data/google-crawlers.json +1 -1
  10. package/encrypt.js +43 -0
  11. package/lib/account/account-state.js +62 -0
  12. package/lib/account.js +60 -3
  13. package/lib/api-routes/account-routes.js +20 -0
  14. package/lib/api-routes/bull-board-routes.js +3 -2
  15. package/lib/api-routes/index.js +1 -1
  16. package/lib/api-routes/route-helpers.js +8 -0
  17. package/lib/api-routes/settings-routes.js +17 -2
  18. package/lib/auth-token.js +73 -2
  19. package/lib/autodetect-imap-settings.js +379 -69
  20. package/lib/cert-handler.js +62 -0
  21. package/lib/consts.js +58 -7
  22. package/lib/db.js +12 -0
  23. package/lib/egress-fetch.js +145 -0
  24. package/lib/email-client/base-client.js +234 -66
  25. package/lib/email-client/credential-errors.js +118 -0
  26. package/lib/email-client/gmail/gmail-api.js +2 -1
  27. package/lib/email-client/gmail-client.js +70 -64
  28. package/lib/email-client/imap/connection-errors.js +52 -0
  29. package/lib/email-client/imap/listing-diff.js +47 -6
  30. package/lib/email-client/imap/mailbox.js +457 -379
  31. package/lib/email-client/imap/subconnection.js +15 -11
  32. package/lib/email-client/imap/sync-operations.js +46 -59
  33. package/lib/email-client/imap-client.js +136 -95
  34. package/lib/email-client/message-builder.js +11 -11
  35. package/lib/email-client/outlook/graph-api.js +2 -1
  36. package/lib/email-client/outlook-client.js +219 -106
  37. package/lib/export.js +35 -2
  38. package/lib/handlebars-helpers.js +129 -0
  39. package/lib/imap-proxy-auth.js +96 -21
  40. package/lib/imapproxy/imap-core/README.md +1 -0
  41. package/lib/imapproxy/imap-core/lib/tls-options.js +5 -46
  42. package/lib/imapproxy/imap-server.js +56 -66
  43. package/lib/lua/h-del-if-equals.lua +39 -0
  44. package/lib/lua/h-set-if-equals.lua +39 -0
  45. package/lib/openapi/index.js +3 -0
  46. package/lib/outbox.js +28 -3
  47. package/lib/rate-limit.js +23 -4
  48. package/lib/routes-ui.js +4 -34
  49. package/lib/schemas.js +42 -3
  50. package/lib/security-headers.js +411 -0
  51. package/lib/sentry.js +36 -4
  52. package/lib/smtp-auth.js +86 -7
  53. package/lib/tls/context.js +376 -0
  54. package/lib/tls/der.js +223 -0
  55. package/lib/tls/provision.js +555 -0
  56. package/lib/tls/self-signed.js +282 -0
  57. package/lib/tls/status.js +431 -0
  58. package/lib/tls/store.js +666 -0
  59. package/lib/tools.js +337 -147
  60. package/lib/ui-routes/account-routes.js +47 -33
  61. package/lib/ui-routes/admin-config-routes.js +22 -1
  62. package/lib/ui-routes/auth-routes.js +16 -1
  63. package/lib/ui-routes/export-routes.js +4 -0
  64. package/lib/ui-routes/internals-routes.js +3 -5
  65. package/lib/ui-routes/mcp-consent-routes.js +7 -0
  66. package/lib/ui-routes/network-config-routes.js +58 -48
  67. package/lib/ui-routes/route-helpers.js +24 -8
  68. package/lib/ui-routes/smtp-test-routes.js +7 -0
  69. package/lib/ui-routes/tls-config-routes.js +581 -0
  70. package/lib/utils/mailbox-path.js +51 -0
  71. package/lib/utils/severity.js +31 -0
  72. package/lib/webhook-egress.js +5 -0
  73. package/package.json +21 -24
  74. package/sbom.json +1 -1
  75. package/server.js +53 -36
  76. package/static/css/flyonui.css +1 -1
  77. package/static/css/src/app.tailwind.css +11 -0
  78. package/static/js/ace/css/ace.css +1462 -0
  79. package/static/js/ace/css/kuroir-1.png +0 -0
  80. package/static/js/ace/css/kuroir-2.png +0 -0
  81. package/static/js/ace/css/main-1.png +0 -0
  82. package/static/js/ace/css/main-10.svg +4 -0
  83. package/static/js/ace/css/main-11.svg +5 -0
  84. package/static/js/ace/css/main-12.svg +4 -0
  85. package/static/js/ace/css/main-13.png +0 -0
  86. package/static/js/ace/css/main-14.png +0 -0
  87. package/static/js/ace/css/main-15.png +0 -0
  88. package/static/js/ace/css/main-16.png +0 -0
  89. package/static/js/ace/css/main-17.png +0 -0
  90. package/static/js/ace/css/main-18.png +0 -0
  91. package/static/js/ace/css/main-19.png +0 -0
  92. package/static/js/ace/css/main-2.png +0 -0
  93. package/static/js/ace/css/main-20.png +0 -0
  94. package/static/js/ace/css/main-21.png +0 -0
  95. package/static/js/ace/css/main-22.png +0 -0
  96. package/static/js/ace/css/main-23.png +0 -0
  97. package/static/js/ace/css/main-24.png +0 -0
  98. package/static/js/ace/css/main-25.svg +1 -0
  99. package/static/js/ace/css/main-26.png +0 -0
  100. package/static/js/ace/css/main-3.png +0 -0
  101. package/static/js/ace/css/main-4.png +0 -0
  102. package/static/js/ace/css/main-5.svg +7 -0
  103. package/static/js/ace/css/main-6.svg +9 -0
  104. package/static/js/ace/css/main-7.svg +7 -0
  105. package/static/js/ace/css/main-8.svg +9 -0
  106. package/static/js/ace/css/main-9.svg +6 -0
  107. package/static/js/ace/css/theme/kuroir.css +78 -0
  108. package/static/js/ace/css/theme/tomorrow_night.css +128 -0
  109. package/static/js/ace/css/theme/tomorrow_night_eighties.css +128 -0
  110. package/static/js/ace/css/theme/xcode.css +106 -0
  111. package/static/js/ace/css/tomorrow_night-1.png +0 -0
  112. package/static/js/ace/css/tomorrow_night-2.png +0 -0
  113. package/static/js/ace/css/tomorrow_night_eighties-1.png +0 -0
  114. package/static/js/ace/css/tomorrow_night_eighties-2.png +0 -0
  115. package/static/js/ace/css/xcode-1.png +0 -0
  116. package/static/js/ace/css/xcode-2.png +0 -0
  117. package/static/js/app.js +34 -0
  118. package/static/js/ee-client.js +256 -102
  119. package/static/js/public.js +13 -2
  120. package/static/js/ui.js +40 -25
  121. package/static/licenses.html +393 -1282
  122. package/static/vendor/simplewebauthn/browser.min.js +2 -2
  123. package/translations/messages.pot +203 -157
  124. package/views/account/login-redirect.hbs +22 -0
  125. package/views/accounts/account.hbs +15 -37
  126. package/views/accounts/browse.hbs +3 -1
  127. package/views/accounts/edit.hbs +1 -1
  128. package/views/accounts/register/imap-server.hbs +1 -1
  129. package/views/config/ai.hbs +1 -1
  130. package/views/config/branding.hbs +2 -2
  131. package/views/config/document-store/chat.hbs +1 -1
  132. package/views/config/document-store/index.hbs +1 -1
  133. package/views/config/imap-proxy.hbs +1 -4
  134. package/views/config/license.hbs +1 -1
  135. package/views/config/mcp.hbs +1 -1
  136. package/views/config/network.hbs +14 -16
  137. package/views/config/oauth/app.hbs +2 -2
  138. package/views/config/service.hbs +1 -1
  139. package/views/config/smtp.hbs +1 -4
  140. package/views/config/tls-upload.hbs +81 -0
  141. package/views/config/tls.hbs +492 -0
  142. package/views/config/webhooks.hbs +2 -2
  143. package/views/error.hbs +4 -2
  144. package/views/internals/index.hbs +1 -1
  145. package/views/layout/app.hbs +3 -11
  146. package/views/mcp/authorize.hbs +1 -1
  147. package/views/partials/ace_assets.hbs +13 -0
  148. package/views/partials/add_account_modal.hbs +1 -1
  149. package/views/partials/address_list.hbs +4 -4
  150. package/views/partials/filter_editor_js.hbs +2 -2
  151. package/views/partials/gateway_js.hbs +1 -1
  152. package/views/partials/oauth_form.hbs +1 -1
  153. package/views/partials/public_theme_init.hbs +1 -1
  154. package/views/partials/side_menu.hbs +1 -0
  155. package/views/partials/template_form.hbs +2 -2
  156. package/views/partials/test_send.hbs +7 -4
  157. package/views/partials/theme_init.hbs +1 -1
  158. package/views/partials/tls_security_card.hbs +25 -53
  159. package/views/partials/ui/alert-banner.hbs +3 -2
  160. package/views/partials/ui/badge.hbs +6 -2
  161. package/views/partials/ui/btn.hbs +5 -2
  162. package/views/partials/ui/details.hbs +2 -2
  163. package/views/partials/webhooks_editor_functions.hbs +1 -1
  164. package/views/reference/redirect.hbs +1 -1
  165. package/views/templates/template.hbs +2 -2
  166. package/views/tokens/new.hbs +1 -1
  167. package/views/unsubscribe.hbs +1 -1
  168. package/views/webhooks/webhook.hbs +2 -2
  169. package/workers/api.js +131 -242
  170. package/workers/export.js +1 -5
  171. package/workers/imap-proxy.js +4 -1
  172. package/workers/imap.js +1 -3
  173. package/workers/smtp.js +59 -83
  174. package/workers/submit.js +6 -12
  175. package/workers/webhooks.js +6 -17
  176. package/static/front/EmailEngine_logo_horiz.png +0 -0
  177. package/static/front/EmailEngine_logo_vert.png +0 -0
  178. package/static/front/index.html +0 -57
  179. package/static/front/logo.png +0 -0
  180. package/static/vendor/handlebars/handlebars.min-v4.7.9.js +0 -29
  181. package/views/partials/tls_security_js.hbs +0 -64
  182. package/views/partials/tls_security_modal.hbs +0 -22
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
  }
@@ -719,11 +702,41 @@ window.uiBusyAction = (btn, run) => {
719
702
  // creation and re-applied whenever the admin theme changes. The theme files
720
703
  // must exist under static/js/ace/ - they are copied from ace-builds by
721
704
  // copy-static-files.sh and ship in the pkg binary via the static/**/* asset glob.
705
+ // Their stylesheets are linked by views/partials/ace_assets.hbs, which also puts
706
+ // ACE in strict-CSP mode so it injects none of its own.
722
707
  const uiAceThemes = {
723
708
  editor: { light: 'ace/theme/xcode', dark: 'ace/theme/tomorrow_night' },
724
709
  preview: { light: 'ace/theme/kuroir', dark: 'ace/theme/tomorrow_night_eighties' }
725
710
  };
726
711
 
712
+ // ACE keeps its stylesheets inside its JavaScript and injects them as elements the admin
713
+ // Content-Security-Policy refuses (it accepts a stylesheet only with the request nonce, which
714
+ // ACE cannot set). Strict mode stops the injection and the sheets are linked instead:
715
+ // views/partials/ace_assets.hbs carries them in the markup for the pages that always have an
716
+ // editor, and this adds whatever is missing for the one that loads ACE lazily from script (the
717
+ // try-it panels in static/js/reference.js). Both paths reach ACE through the two helpers below,
718
+ // so this is the one place that has to know. The hrefs come from uiAceThemes, so a theme added
719
+ // there needs no second edit.
720
+ const uiAceEnsureAssets = () => {
721
+ ace.config.set('useStrictCSP', true);
722
+
723
+ let sheets = ['/static/js/ace/css/ace.css'];
724
+ for (let kind of Object.values(uiAceThemes)) {
725
+ for (let theme of Object.values(kind)) {
726
+ sheets.push(`/static/js/ace/css/theme/${theme.split('/').pop()}.css`);
727
+ }
728
+ }
729
+
730
+ for (let href of sheets) {
731
+ if (!document.querySelector(`link[href="${href}"]`)) {
732
+ let link = document.createElement('link');
733
+ link.rel = 'stylesheet';
734
+ link.href = href;
735
+ document.head.appendChild(link);
736
+ }
737
+ }
738
+ };
739
+
727
740
  // container element -> { editor, kind }; also the lookup the .copy-btn
728
741
  // handler uses to read the full session value of a targeted editor
729
742
  const uiAceInstances = new Map();
@@ -744,6 +757,7 @@ const uiAceRegister = (editor, kind) => {
744
757
  // the initial value loaded into the session. Extra ace options pass through
745
758
  // via opts.
746
759
  window.uiAceEditor = (id, mode, value, opts) => {
760
+ uiAceEnsureAssets();
747
761
  const editor = opts ? ace.edit(id, opts) : ace.edit(id);
748
762
  uiAceRegister(editor, 'editor');
749
763
  editor.session.setMode(`ace/mode/${mode}`);
@@ -756,6 +770,7 @@ window.uiAceEditor = (id, mode, value, opts) => {
756
770
  // Read-only preview pane variant: gutter, no print margin or active-line
757
771
  // highlight, with its own theme pair to keep previews visually distinct
758
772
  window.uiAcePreview = (id, mode, opts) => {
773
+ uiAceEnsureAssets();
759
774
  const editor = ace.edit(id, Object.assign({ showGutter: true }, opts));
760
775
  editor.setReadOnly(true);
761
776
  editor.setShowPrintMargin(false);