emailengine-app 2.79.8 → 2.79.9

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 (133) 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 +20 -0
  5. package/DOCKER_DEPLOYMENT.md +6 -7
  6. package/Dockerfile +35 -11
  7. package/config/default.toml +2 -1
  8. package/copy-static-files.sh +23 -5
  9. package/data/google-crawlers.json +1 -1
  10. package/lib/account.js +26 -1
  11. package/lib/api-routes/bull-board-routes.js +3 -2
  12. package/lib/api-routes/route-helpers.js +8 -0
  13. package/lib/auth-token.js +73 -2
  14. package/lib/autodetect-imap-settings.js +33 -25
  15. package/lib/consts.js +8 -1
  16. package/lib/egress-fetch.js +133 -0
  17. package/lib/export.js +35 -2
  18. package/lib/handlebars-helpers.js +129 -0
  19. package/lib/imap-proxy-auth.js +41 -21
  20. package/lib/imapproxy/imap-core/README.md +1 -0
  21. package/lib/imapproxy/imap-core/lib/tls-options.js +5 -46
  22. package/lib/imapproxy/imap-server.js +9 -10
  23. package/lib/openapi/index.js +3 -0
  24. package/lib/outbox.js +28 -3
  25. package/lib/rate-limit.js +23 -4
  26. package/lib/schemas.js +10 -3
  27. package/lib/security-headers.js +396 -0
  28. package/lib/sentry.js +36 -4
  29. package/lib/smtp-auth.js +86 -7
  30. package/lib/tools.js +265 -120
  31. package/lib/ui-routes/account-routes.js +4 -3
  32. package/lib/ui-routes/export-routes.js +4 -0
  33. package/lib/ui-routes/mcp-consent-routes.js +7 -0
  34. package/lib/ui-routes/network-config-routes.js +4 -3
  35. package/lib/ui-routes/route-helpers.js +24 -8
  36. package/lib/ui-routes/smtp-test-routes.js +7 -0
  37. package/lib/webhook-egress.js +5 -0
  38. package/package.json +21 -24
  39. package/sbom.json +1 -1
  40. package/server.js +37 -36
  41. package/static/js/ace/css/ace.css +1462 -0
  42. package/static/js/ace/css/kuroir-1.png +0 -0
  43. package/static/js/ace/css/kuroir-2.png +0 -0
  44. package/static/js/ace/css/main-1.png +0 -0
  45. package/static/js/ace/css/main-10.svg +4 -0
  46. package/static/js/ace/css/main-11.svg +5 -0
  47. package/static/js/ace/css/main-12.svg +4 -0
  48. package/static/js/ace/css/main-13.png +0 -0
  49. package/static/js/ace/css/main-14.png +0 -0
  50. package/static/js/ace/css/main-15.png +0 -0
  51. package/static/js/ace/css/main-16.png +0 -0
  52. package/static/js/ace/css/main-17.png +0 -0
  53. package/static/js/ace/css/main-18.png +0 -0
  54. package/static/js/ace/css/main-19.png +0 -0
  55. package/static/js/ace/css/main-2.png +0 -0
  56. package/static/js/ace/css/main-20.png +0 -0
  57. package/static/js/ace/css/main-21.png +0 -0
  58. package/static/js/ace/css/main-22.png +0 -0
  59. package/static/js/ace/css/main-23.png +0 -0
  60. package/static/js/ace/css/main-24.png +0 -0
  61. package/static/js/ace/css/main-25.svg +1 -0
  62. package/static/js/ace/css/main-26.png +0 -0
  63. package/static/js/ace/css/main-3.png +0 -0
  64. package/static/js/ace/css/main-4.png +0 -0
  65. package/static/js/ace/css/main-5.svg +7 -0
  66. package/static/js/ace/css/main-6.svg +9 -0
  67. package/static/js/ace/css/main-7.svg +7 -0
  68. package/static/js/ace/css/main-8.svg +9 -0
  69. package/static/js/ace/css/main-9.svg +6 -0
  70. package/static/js/ace/css/theme/kuroir.css +78 -0
  71. package/static/js/ace/css/theme/tomorrow_night.css +128 -0
  72. package/static/js/ace/css/theme/tomorrow_night_eighties.css +128 -0
  73. package/static/js/ace/css/theme/xcode.css +106 -0
  74. package/static/js/ace/css/tomorrow_night-1.png +0 -0
  75. package/static/js/ace/css/tomorrow_night-2.png +0 -0
  76. package/static/js/ace/css/tomorrow_night_eighties-1.png +0 -0
  77. package/static/js/ace/css/tomorrow_night_eighties-2.png +0 -0
  78. package/static/js/ace/css/xcode-1.png +0 -0
  79. package/static/js/ace/css/xcode-2.png +0 -0
  80. package/static/js/ee-client.js +256 -102
  81. package/static/js/public.js +7 -0
  82. package/static/js/ui.js +32 -0
  83. package/static/licenses.html +331 -291
  84. package/static/vendor/simplewebauthn/browser.min.js +2 -2
  85. package/translations/messages.pot +203 -157
  86. package/views/accounts/account.hbs +15 -37
  87. package/views/accounts/browse.hbs +3 -1
  88. package/views/accounts/edit.hbs +1 -1
  89. package/views/accounts/register/imap-server.hbs +1 -1
  90. package/views/config/ai.hbs +1 -1
  91. package/views/config/branding.hbs +2 -2
  92. package/views/config/document-store/chat.hbs +1 -1
  93. package/views/config/document-store/index.hbs +1 -1
  94. package/views/config/imap-proxy.hbs +1 -1
  95. package/views/config/license.hbs +1 -1
  96. package/views/config/mcp.hbs +1 -1
  97. package/views/config/network.hbs +14 -16
  98. package/views/config/oauth/app.hbs +2 -2
  99. package/views/config/service.hbs +1 -1
  100. package/views/config/smtp.hbs +1 -1
  101. package/views/config/webhooks.hbs +2 -2
  102. package/views/error.hbs +4 -2
  103. package/views/internals/index.hbs +1 -1
  104. package/views/layout/app.hbs +3 -11
  105. package/views/mcp/authorize.hbs +1 -1
  106. package/views/partials/ace_assets.hbs +13 -0
  107. package/views/partials/add_account_modal.hbs +1 -1
  108. package/views/partials/address_list.hbs +4 -4
  109. package/views/partials/filter_editor_js.hbs +2 -2
  110. package/views/partials/gateway_js.hbs +1 -1
  111. package/views/partials/oauth_form.hbs +1 -1
  112. package/views/partials/public_theme_init.hbs +1 -1
  113. package/views/partials/template_form.hbs +2 -2
  114. package/views/partials/test_send.hbs +7 -4
  115. package/views/partials/theme_init.hbs +1 -1
  116. package/views/partials/ui/details.hbs +2 -2
  117. package/views/partials/webhooks_editor_functions.hbs +1 -1
  118. package/views/reference/redirect.hbs +1 -1
  119. package/views/templates/template.hbs +2 -2
  120. package/views/tokens/new.hbs +1 -1
  121. package/views/unsubscribe.hbs +1 -1
  122. package/views/webhooks/webhook.hbs +2 -2
  123. package/workers/api.js +42 -112
  124. package/workers/export.js +1 -5
  125. package/workers/imap.js +1 -3
  126. package/workers/smtp.js +12 -43
  127. package/workers/submit.js +6 -12
  128. package/workers/webhooks.js +6 -17
  129. package/static/front/EmailEngine_logo_horiz.png +0 -0
  130. package/static/front/EmailEngine_logo_vert.png +0 -0
  131. package/static/front/index.html +0 -57
  132. package/static/front/logo.png +0 -0
  133. package/static/vendor/handlebars/handlebars.min-v4.7.9.js +0 -29
package/server.js CHANGED
@@ -30,11 +30,12 @@ try {
30
30
  // Set process title for easier identification in process lists
31
31
  process.title = 'emailengine';
32
32
 
33
- // Ensure Node.js version supports structuredClone (Node 17+)
34
- try {
35
- structuredClone(true);
36
- } catch (err) {
37
- console.error(`Node.js version ${process.version} is not supported. Please upgrade to Node.js 17 or later.`);
33
+ // EmailEngine and its dependencies need Node 20 or newer, the same floor the engines field in
34
+ // package.json declares. Checked before anything is required, so an older runtime gets this line
35
+ // instead of a syntax error from a dependency. The check used to be a structuredClone probe, which
36
+ // only caught Node 16 and older.
37
+ if (Number(process.versions.node.split('.')[0]) < 20) {
38
+ console.error(`Node.js version ${process.version} is not supported. Please upgrade to Node.js 20 or later.`);
38
39
  process.exit(1);
39
40
  }
40
41
 
@@ -1075,7 +1076,8 @@ async function sendWebhook(account, event, data) {
1075
1076
  * Spawn a new worker thread of the specified type
1076
1077
  * @param {string} type - Worker type (imap, api, webhooks, submit, documents, smtp, imapProxy)
1077
1078
  * @param {Object} [opts] - Optional spawn options
1078
- * @param {Object} [opts.workerData] - Data passed to the worker thread (e.g. API worker index)
1079
+ * @param {Object} [opts.workerData] - Data passed to the worker thread (e.g. API worker index). The
1080
+ * proxy in effect is added for every type, see lib/tools.js
1079
1081
  * @returns {Promise<number|void>} Thread ID if successful
1080
1082
  */
1081
1083
  let spawnWorker = async (type, opts) => {
@@ -1113,7 +1115,9 @@ let spawnWorker = async (type, opts) => {
1113
1115
  let worker = new WorkerThread(pathlib.join(__dirname, 'workers', `${type.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`)}.js`), {
1114
1116
  argv,
1115
1117
  env: SHARE_ENV,
1116
- workerData: opts && opts.workerData,
1118
+ // every worker builds its HTTP dispatchers from the proxy in effect before its first line of
1119
+ // code runs (lib/tools.js); this thread resolved it from settings before spawning anything
1120
+ workerData: Object.assign({ httpProxyUrl: httpAgent.proxyUrl }, opts && opts.workerData),
1117
1121
  trackUnmanagedFds: true
1118
1122
  });
1119
1123
  metrics.threadStarts.inc();
@@ -1502,18 +1506,19 @@ let spawnWorker = async (type, opts) => {
1502
1506
  }
1503
1507
  });
1504
1508
 
1505
- // Forward settings changes to API, webhooks, submit, and export workers
1506
- for (let type of ['api', 'webhooks', 'submit', 'export']) {
1507
- let typeWorkers = workers.get(type);
1508
- if (typeWorkers) {
1509
- typeWorkers.forEach(worker => {
1510
- try {
1511
- postMessage(worker, message);
1512
- } catch (err) {
1513
- logger.error({ msg: 'Unable to forward settings to worker', type, worker: worker.threadId, err });
1514
- }
1515
- });
1509
+ // Forward settings changes to every other worker type (the IMAP workers were
1510
+ // handled above); each reloads its HTTP proxy agent from the 'settings' message
1511
+ for (let [type, typeWorkers] of workers) {
1512
+ if (type === 'imap') {
1513
+ continue;
1516
1514
  }
1515
+ typeWorkers.forEach(worker => {
1516
+ try {
1517
+ postMessage(worker, message);
1518
+ } catch (err) {
1519
+ logger.error({ msg: 'Unable to forward settings to worker', type, worker: worker.threadId, err });
1520
+ }
1521
+ });
1517
1522
  }
1518
1523
  return;
1519
1524
 
@@ -2368,6 +2373,14 @@ async function updateQueueCounters() {
2368
2373
  * @param {Object} message - Command message
2369
2374
  * @returns {Promise<*>} Command result
2370
2375
  */
2376
+ // Options shared by every OpenAI call. A function rather than a constant because httpAgent.fetch is
2377
+ // swapped when the proxy settings change. The plain agent rather than the retrying one: the library
2378
+ // keeps its own 429 retry.
2379
+ const openAiRequestOpts = () => ({
2380
+ verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE),
2381
+ dispatcher: httpAgent.fetch
2382
+ });
2383
+
2371
2384
  async function onCommand(worker, message) {
2372
2385
  switch (message.cmd) {
2373
2386
  case 'metrics':
@@ -2528,9 +2541,7 @@ async function onCommand(worker, message) {
2528
2541
 
2529
2542
  // OpenAI integration commands - run in main process to avoid memory overhead
2530
2543
  case 'generateSummary': {
2531
- let requestOpts = {
2532
- verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
2533
- };
2544
+ let requestOpts = openAiRequestOpts();
2534
2545
 
2535
2546
  let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
2536
2547
 
@@ -2588,9 +2599,7 @@ async function onCommand(worker, message) {
2588
2599
  }
2589
2600
 
2590
2601
  case 'generateEmbeddings': {
2591
- let requestOpts = {
2592
- verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
2593
- };
2602
+ let requestOpts = openAiRequestOpts();
2594
2603
 
2595
2604
  let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
2596
2605
 
@@ -2623,9 +2632,7 @@ async function onCommand(worker, message) {
2623
2632
  }
2624
2633
 
2625
2634
  case 'embeddingsQuery': {
2626
- let requestOpts = {
2627
- verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
2628
- };
2635
+ let requestOpts = openAiRequestOpts();
2629
2636
 
2630
2637
  let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
2631
2638
 
@@ -2694,9 +2701,7 @@ async function onCommand(worker, message) {
2694
2701
  }
2695
2702
 
2696
2703
  case 'questionQuery': {
2697
- let requestOpts = {
2698
- verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
2699
- };
2704
+ let requestOpts = openAiRequestOpts();
2700
2705
 
2701
2706
  let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
2702
2707
 
@@ -2729,9 +2734,7 @@ async function onCommand(worker, message) {
2729
2734
  }
2730
2735
 
2731
2736
  case 'generateChunkEmbeddings': {
2732
- let requestOpts = {
2733
- verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
2734
- };
2737
+ let requestOpts = openAiRequestOpts();
2735
2738
 
2736
2739
  let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
2737
2740
 
@@ -2752,9 +2755,7 @@ async function onCommand(worker, message) {
2752
2755
  }
2753
2756
 
2754
2757
  case 'openAiListModels': {
2755
- let requestOpts = {
2756
- verbose: getBoolean(process.env.EE_OPENAPI_VERBOSE)
2757
- };
2758
+ let requestOpts = openAiRequestOpts();
2758
2759
 
2759
2760
  let openAiAPIKey = message.data.openAiAPIKey || (await settings.get('openAiAPIKey'));
2760
2761