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
@@ -17,7 +17,7 @@ const { templates } = require('../templates');
17
17
  const { webhooks } = require('../webhooks');
18
18
  const consts = require('../consts');
19
19
  const wellKnownServices = require('nodemailer/lib/well-known/services.json');
20
- const { authAwareLevel, resolveKnownAccounts, adminUrl, mcpToolGrants, accountPickerEntry } = require('./route-helpers');
20
+ const { authAwareLevel, isClientError, resolveKnownAccounts, adminUrl, mcpToolGrants, accountPickerEntry, submittedValues } = require('./route-helpers');
21
21
  const exampleWebhookPayloads = require('../payload-examples-webhooks.json');
22
22
 
23
23
  const { DEFAULT_PAGE_SIZE } = consts;
@@ -316,6 +316,7 @@ return payload;`)
316
316
  {
317
317
  pageTitle: 'Webhook Routes',
318
318
  menuWebhooks: true,
319
+ values: request.payload,
319
320
  errors: err.details,
320
321
 
321
322
  examplePayloadsJson: JSON.stringify(await getExampleWebhookPayloads()),
@@ -352,14 +353,16 @@ return payload;`)
352
353
 
353
354
  return h
354
355
  .view(
355
- 'templates/new',
356
+ 'webhooks/new',
356
357
  {
357
- pageTitle: 'Templates',
358
- menuTemplates: true,
358
+ pageTitle: 'Webhook Routes',
359
+ menuWebhooks: true,
360
+ values: request.payload,
359
361
  errors,
360
362
 
361
363
  examplePayloadsJson: JSON.stringify(await getExampleWebhookPayloads()),
362
- notificationTypesJson: JSON.stringify(notificationTypes)
364
+ notificationTypesJson: JSON.stringify(notificationTypes),
365
+ scriptEnvJson: JSON.stringify((await settings.get('scriptEnv')) || '{}')
363
366
  },
364
367
  {
365
368
  layout: 'app'
@@ -637,6 +640,7 @@ return payload;`)
637
640
 
638
641
  webhook,
639
642
 
643
+ values: request.payload,
640
644
  errors: err.details,
641
645
 
642
646
  examplePayloadsJson: JSON.stringify(await getExampleWebhookPayloads()),
@@ -686,6 +690,7 @@ return payload;`)
686
690
 
687
691
  webhook,
688
692
 
693
+ values: request.payload,
689
694
  errors,
690
695
 
691
696
  examplePayloadsJson: JSON.stringify(await getExampleWebhookPayloads()),
@@ -1100,6 +1105,7 @@ return payload;`)
1100
1105
 
1101
1106
  formats: CODE_FORMATS.map(format => Object.assign({ selected: format.format === request.payload.format }, format)),
1102
1107
 
1108
+ values: request.payload,
1103
1109
  errors: err.details,
1104
1110
 
1105
1111
  contentHtmlJson: JSON.stringify(request.payload.contentHtml || ''),
@@ -1165,6 +1171,7 @@ return payload;`)
1165
1171
 
1166
1172
  formats: CODE_FORMATS.map(format => Object.assign({ selected: format.format === request.payload.format }, format)),
1167
1173
 
1174
+ values: request.payload,
1168
1175
  errors,
1169
1176
 
1170
1177
  contentHtmlJson: JSON.stringify(request.payload.contentHtml || ''),
@@ -1319,6 +1326,7 @@ return payload;`)
1319
1326
 
1320
1327
  formats: CODE_FORMATS.map(format => Object.assign({ selected: format.format === request.payload.format }, format)),
1321
1328
 
1329
+ values: request.payload,
1322
1330
  errors: err.details,
1323
1331
 
1324
1332
  contentHtmlJson: JSON.stringify(request.payload.contentHtml || ''),
@@ -1376,6 +1384,7 @@ return payload;`)
1376
1384
 
1377
1385
  formats: CODE_FORMATS.map(format => Object.assign({ selected: format.format === request.payload.format }, format)),
1378
1386
 
1387
+ values: request.payload,
1379
1388
  errors,
1380
1389
 
1381
1390
  contentHtmlJson: JSON.stringify(request.payload.contentHtml || ''),
@@ -1558,10 +1567,6 @@ return payload;`)
1558
1567
 
1559
1568
  let gateways = await gatewayObject.listGateways(request.query.page - 1, request.query.pageSize, request.query.query);
1560
1569
 
1561
- if (gateways.pages < request.query.page) {
1562
- request.query.page = gateways.pages;
1563
- }
1564
-
1565
1570
  let nextPage = false;
1566
1571
  let prevPage = false;
1567
1572
 
@@ -1577,6 +1582,13 @@ return payload;`)
1577
1582
  return url.pathname + url.search;
1578
1583
  };
1579
1584
 
1585
+ // A page past the end lists nothing, and the view renders its page links only
1586
+ // around a non-empty listing, so it would show "No gateways found" with no way
1587
+ // back - send it to the last page instead
1588
+ if (gateways.pages && request.query.page > gateways.pages) {
1589
+ return h.redirect(getPagingUrl(gateways.pages));
1590
+ }
1591
+
1580
1592
  if (gateways.pages > gateways.page + 1) {
1581
1593
  nextPage = getPagingUrl(gateways.page + 2);
1582
1594
  }
@@ -1808,7 +1820,10 @@ return payload;`)
1808
1820
  {
1809
1821
  pageTitle: 'Gateways',
1810
1822
  menuGateways: true,
1811
- wellKnownServices: JSON.stringify(Object.keys(wellKnownServices).map(key => Object.assign({ key }, wellKnownServices[key])))
1823
+ wellKnownServices: JSON.stringify(Object.keys(wellKnownServices).map(key => Object.assign({ key }, wellKnownServices[key]))),
1824
+ // the submitted password is not echoed back into the page
1825
+ values: submittedValues(request, 'pass'),
1826
+ errors: err.details
1812
1827
  },
1813
1828
  {
1814
1829
  layout: 'app'
@@ -1846,6 +1861,7 @@ return payload;`)
1846
1861
  pageTitle: 'Gateways',
1847
1862
  menuGateways: true,
1848
1863
  wellKnownServices: JSON.stringify(Object.keys(wellKnownServices).map(key => Object.assign({ key }, wellKnownServices[key]))),
1864
+ values: submittedValues(request, 'pass'),
1849
1865
 
1850
1866
  errors
1851
1867
  },
@@ -1930,7 +1946,9 @@ return payload;`)
1930
1946
  menuGateways: true,
1931
1947
  wellKnownServices: JSON.stringify(Object.keys(wellKnownServices).map(key => Object.assign({ key }, wellKnownServices[key]))),
1932
1948
  hasSMTPPass,
1933
- gatewayData
1949
+ gatewayData,
1950
+ values: submittedValues(request, 'pass'),
1951
+ errors: err.details
1934
1952
  },
1935
1953
  {
1936
1954
  layout: 'app'
@@ -1975,6 +1993,7 @@ return payload;`)
1975
1993
  wellKnownServices: JSON.stringify(Object.keys(wellKnownServices).map(key => Object.assign({ key }, wellKnownServices[key]))),
1976
1994
  hasSMTPPass,
1977
1995
  gatewayData,
1996
+ values: submittedValues(request, 'pass'),
1978
1997
 
1979
1998
  errors
1980
1999
  },
@@ -2138,13 +2157,22 @@ return payload;`)
2138
2157
  try {
2139
2158
  let gatewayObject = new Gateway({ redis, gateway: request.params.gateway, secret: await getSecret() });
2140
2159
 
2141
- let deleted = await gatewayObject.delete();
2160
+ let { deleted } = await gatewayObject.delete();
2142
2161
  if (deleted) {
2143
2162
  await request.flash({ type: 'info', message: `Gateway deleted` });
2163
+ } else {
2164
+ await request.flash({ type: 'danger', message: `Requested gateway was not found` });
2144
2165
  }
2145
2166
 
2146
2167
  return h.redirect('/admin/gateways');
2147
2168
  } catch (err) {
2169
+ if (isClientError(err) && err.output.statusCode === 404) {
2170
+ // Already gone (a stale tab, a double submit): say so and land on the
2171
+ // listing rather than on the deleted gateway's page
2172
+ await request.flash({ type: 'danger', message: `Requested gateway was not found` });
2173
+ return h.redirect('/admin/gateways');
2174
+ }
2175
+
2148
2176
  await request.flash({ type: 'danger', message: `Couldn't delete gateway. Try again.` });
2149
2177
  request.logger.error({ msg: 'Failed to delete the gateway', err, gateway: request.params.gateway, remoteAddress: request.app.ip });
2150
2178
  return h.redirect(adminUrl`/admin/gateways/gateway/${request.params.gateway}`);
@@ -2523,6 +2551,8 @@ return payload;`)
2523
2551
  let deleted = await tokens.delete(request.payload.token, { remoteAddress: request.app.ip });
2524
2552
  if (deleted) {
2525
2553
  await request.flash({ type: 'info', message: `Token deleted` });
2554
+ } else {
2555
+ await request.flash({ type: 'danger', message: `Requested token was not found` });
2526
2556
  }
2527
2557
 
2528
2558
  return h.redirect('/admin/tokens');