emailengine-app 2.79.9 → 2.80.1

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 (146) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +73 -0
  3. package/README.md +6 -0
  4. package/config/default.toml +5 -1
  5. package/data/google-crawlers.json +1 -1
  6. package/encrypt.js +43 -0
  7. package/lib/account/account-state.js +62 -0
  8. package/lib/account.js +34 -2
  9. package/lib/api-routes/account-routes.js +101 -1
  10. package/lib/api-routes/blocklist-routes.js +24 -0
  11. package/lib/api-routes/delivery-test-routes.js +6 -0
  12. package/lib/api-routes/gateway-routes.js +30 -0
  13. package/lib/api-routes/index.js +1 -1
  14. package/lib/api-routes/license-routes.js +10 -0
  15. package/lib/api-routes/mcp-oauth-routes.js +3 -3
  16. package/lib/api-routes/mcp-routes.js +39 -21
  17. package/lib/api-routes/oauth2-app-routes.js +38 -1
  18. package/lib/api-routes/outbox-routes.js +6 -0
  19. package/lib/api-routes/permission-map.js +208 -43
  20. package/lib/api-routes/pubsub-routes.js +8 -0
  21. package/lib/api-routes/route-helpers.js +58 -11
  22. package/lib/api-routes/settings-routes.js +67 -6
  23. package/lib/api-routes/stats-routes.js +6 -0
  24. package/lib/api-routes/template-routes.js +21 -0
  25. package/lib/api-routes/token-routes.js +34 -2
  26. package/lib/api-routes/webhook-route-routes.js +13 -0
  27. package/lib/autodetect-imap-settings.js +349 -47
  28. package/lib/cert-handler.js +62 -0
  29. package/lib/consts.js +50 -6
  30. package/lib/db.js +12 -0
  31. package/lib/egress-fetch.js +21 -9
  32. package/lib/email-client/base-client.js +238 -67
  33. package/lib/email-client/credential-errors.js +122 -0
  34. package/lib/email-client/gmail/gmail-api.js +2 -1
  35. package/lib/email-client/gmail-client.js +70 -64
  36. package/lib/email-client/imap/connection-errors.js +52 -0
  37. package/lib/email-client/imap/listing-diff.js +47 -6
  38. package/lib/email-client/imap/login-failure.js +52 -0
  39. package/lib/email-client/imap/mailbox.js +457 -379
  40. package/lib/email-client/imap/subconnection.js +17 -12
  41. package/lib/email-client/imap/sync-operations.js +46 -59
  42. package/lib/email-client/imap-client.js +139 -101
  43. package/lib/email-client/message-builder.js +11 -11
  44. package/lib/email-client/outlook/graph-api.js +2 -1
  45. package/lib/email-client/outlook-client.js +219 -106
  46. package/lib/enum-descriptions.js +12 -2
  47. package/lib/imap-proxy-auth.js +58 -3
  48. package/lib/imapproxy/imap-server.js +53 -62
  49. package/lib/lua/h-del-if-equals.lua +39 -0
  50. package/lib/lua/h-set-if-equals.lua +39 -0
  51. package/lib/mcp/oauth.js +46 -8
  52. package/lib/mcp/protocol.js +78 -35
  53. package/lib/mcp/tools.js +53 -17
  54. package/lib/privileged-settings.js +147 -0
  55. package/lib/routes-ui.js +4 -34
  56. package/lib/schemas.js +92 -16
  57. package/lib/security-headers.js +15 -0
  58. package/lib/settings.js +13 -0
  59. package/lib/tls/catalog.js +428 -0
  60. package/lib/tls/context.js +302 -0
  61. package/lib/tls/der.js +223 -0
  62. package/lib/tls/listeners.js +62 -0
  63. package/lib/tls/provision.js +555 -0
  64. package/lib/tls/self-signed.js +282 -0
  65. package/lib/tls/status.js +480 -0
  66. package/lib/tls/store.js +667 -0
  67. package/lib/token-permission-view.js +252 -102
  68. package/lib/token-permissions.js +176 -26
  69. package/lib/tokens.js +7 -6
  70. package/lib/tools.js +73 -27
  71. package/lib/ui-routes/account-routes.js +43 -30
  72. package/lib/ui-routes/admin-config-routes.js +63 -22
  73. package/lib/ui-routes/admin-entities-routes.js +23 -13
  74. package/lib/ui-routes/auth-routes.js +16 -1
  75. package/lib/ui-routes/internals-routes.js +3 -5
  76. package/lib/ui-routes/mcp-consent-routes.js +72 -31
  77. package/lib/ui-routes/network-config-routes.js +54 -45
  78. package/lib/ui-routes/tls-config-routes.js +628 -0
  79. package/lib/utils/mailbox-path.js +51 -0
  80. package/lib/utils/severity.js +31 -0
  81. package/package.json +12 -12
  82. package/sbom.json +1 -1
  83. package/server.js +23 -1
  84. package/static/css/flyonui.css +1 -1
  85. package/static/css/src/app.tailwind.css +11 -0
  86. package/static/js/app.js +34 -0
  87. package/static/js/public.js +6 -2
  88. package/static/js/ui.js +97 -61
  89. package/static/licenses.html +341 -1252
  90. package/translations/messages.pot +62 -56
  91. package/views/account/login-redirect.hbs +22 -0
  92. package/views/account/passkeys.hbs +2 -2
  93. package/views/accounts/account.hbs +2 -2
  94. package/views/accounts/browse.hbs +1 -1
  95. package/views/accounts/edit.hbs +1 -1
  96. package/views/accounts/register/imap-server.hbs +1 -1
  97. package/views/config/ai.hbs +1 -1
  98. package/views/config/branding.hbs +2 -2
  99. package/views/config/document-store/chat.hbs +1 -1
  100. package/views/config/document-store/index.hbs +1 -1
  101. package/views/config/imap-proxy.hbs +1 -4
  102. package/views/config/license.hbs +1 -1
  103. package/views/config/mcp.hbs +88 -52
  104. package/views/config/network.hbs +1 -1
  105. package/views/config/oauth/app.hbs +2 -2
  106. package/views/config/service.hbs +1 -1
  107. package/views/config/smtp.hbs +1 -4
  108. package/views/config/tls-upload.hbs +81 -0
  109. package/views/config/tls.hbs +593 -0
  110. package/views/config/webhooks.hbs +2 -2
  111. package/views/internals/index.hbs +1 -1
  112. package/views/layout/app.hbs +6 -6
  113. package/views/layout/login.hbs +5 -5
  114. package/views/layout/main.hbs +2 -2
  115. package/views/layout/prompt.hbs +3 -3
  116. package/views/layout/public.hbs +1 -1
  117. package/views/mcp/authorize.hbs +47 -45
  118. package/views/partials/ace_assets.hbs +1 -1
  119. package/views/partials/add_account_modal.hbs +1 -1
  120. package/views/partials/filter_editor_js.hbs +2 -2
  121. package/views/partials/gateway_js.hbs +1 -1
  122. package/views/partials/mcp_access_levels.hbs +16 -9
  123. package/views/partials/mcp_tool_count.hbs +15 -14
  124. package/views/partials/oauth_form.hbs +1 -1
  125. package/views/partials/public_theme_init.hbs +1 -1
  126. package/views/partials/side_menu.hbs +1 -0
  127. package/views/partials/template_form.hbs +1 -1
  128. package/views/partials/theme_init.hbs +1 -1
  129. package/views/partials/tls_security_card.hbs +25 -53
  130. package/views/partials/ui/alert-banner.hbs +3 -2
  131. package/views/partials/ui/badge.hbs +6 -2
  132. package/views/partials/ui/btn.hbs +5 -2
  133. package/views/partials/webhooks_editor_functions.hbs +1 -1
  134. package/views/reference/index.hbs +1 -1
  135. package/views/reference/redirect.hbs +1 -1
  136. package/views/reference/tag.hbs +1 -1
  137. package/views/reference/token.hbs +1 -1
  138. package/views/templates/template.hbs +1 -1
  139. package/views/tokens/new.hbs +175 -74
  140. package/views/unsubscribe.hbs +1 -1
  141. package/views/webhooks/webhook.hbs +1 -1
  142. package/workers/api.js +102 -142
  143. package/workers/imap-proxy.js +4 -1
  144. package/workers/smtp.js +51 -44
  145. package/views/partials/tls_security_js.hbs +0 -64
  146. package/views/partials/tls_security_modal.hbs +0 -22
@@ -58,6 +58,12 @@ async function init(args) {
58
58
  tags: ['api', 'Templates'],
59
59
 
60
60
  plugins: {
61
+ mcp: {
62
+ name: 'create_template',
63
+ title: 'Create template',
64
+ description:
65
+ 'Create a stored email template: a subject and body (html, text, previewText) that send_message can reference by id. account names the account the template belongs to.'
66
+ },
61
67
  openapi: {
62
68
  responses: apiResponses('Returns the created template.', 400, 401, 403, 404, 429, 500)
63
69
  }
@@ -146,6 +152,11 @@ async function init(args) {
146
152
  tags: ['api', 'Templates'],
147
153
 
148
154
  plugins: {
155
+ mcp: {
156
+ name: 'update_template',
157
+ title: 'Update template',
158
+ description: "Update a stored template's name, description, format or content. Send only the fields to change."
159
+ },
149
160
  openapi: {
150
161
  responses: apiResponses('Returns the updated template.', 400, 401, 403, 404, 429, 500)
151
162
  }
@@ -394,6 +405,11 @@ async function init(args) {
394
405
  tags: ['api', 'Templates'],
395
406
 
396
407
  plugins: {
408
+ mcp: {
409
+ name: 'delete_template',
410
+ title: 'Delete template',
411
+ description: 'Remove a stored template.'
412
+ },
397
413
  openapi: {
398
414
  'x-ee-impact': IMPACT.DESTRUCTIVE,
399
415
  responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 429, 500)
@@ -459,6 +475,11 @@ async function init(args) {
459
475
  tags: ['api', 'Templates'],
460
476
 
461
477
  plugins: {
478
+ mcp: {
479
+ name: 'delete_account_templates',
480
+ title: 'Delete all templates of an account',
481
+ description: 'Remove every stored template of one account. Requires force to be true. Confirm with the user before calling this.'
482
+ },
462
483
  openapi: {
463
484
  'x-ee-impact': IMPACT.DESTRUCTIVE,
464
485
  responses: apiResponses('Returns the number of templates removed.', 400, 401, 403, 404, 429, 500)
@@ -11,6 +11,7 @@ const { failAction } = require('../tools');
11
11
  const { handleError, throwNotFound } = require('./route-helpers');
12
12
  const { accountIdSchema, tokenRestrictionsSchema, tokenPermissionsSchema, ipSchema, tokenIdSchema, apiResponses, ENUM_DESCRIPTIONS } = require('../schemas');
13
13
  const { IMPACT } = require('./operation-impact');
14
+ const { MCP_MAX_PAGE_SIZE } = require('../consts');
14
15
 
15
16
  const tokenAccessSchema = Joi.object({
16
17
  time: Joi.date().iso().allow(null).example('2021-02-17T13:43:18.860Z').description('Last time this token was used. Null if the token has never been used'),
@@ -123,12 +124,17 @@ async function init(args) {
123
124
  description: Joi.string().empty('').trim().max(1024).required().example('Token description').description('Token description'),
124
125
 
125
126
  scopes: Joi.array()
126
- .items(Joi.string().valid('api', 'smtp', 'imap-proxy', 'mcp').meta({ enumDescriptions: ENUM_DESCRIPTIONS.tokenScope }).label('TokenScope'))
127
+ .items(
128
+ Joi.string()
129
+ .valid('api', 'smtp', 'imap-proxy', 'mcp', 'mcp-manage')
130
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.tokenScope })
131
+ .label('TokenScope')
132
+ )
127
133
  .single()
128
134
  .default(['api'])
129
135
  .required()
130
136
  .description(
131
- 'Token permission scopes: "api" for REST API access, "smtp" for SMTP submission, "imap-proxy" for IMAP proxy authentication, "mcp" for the MCP endpoint only'
137
+ 'Token permission scopes: "api" for REST API access, "smtp" for SMTP submission, "imap-proxy" for IMAP proxy authentication, "mcp-manage" for the instance management tools of the MCP endpoint, "mcp" for its mail tools'
132
138
  )
133
139
  .label('Scopes'),
134
140
 
@@ -296,6 +302,12 @@ async function init(args) {
296
302
  tags: ['api', 'Access Tokens'],
297
303
 
298
304
  plugins: {
305
+ mcp: {
306
+ name: 'revoke_token',
307
+ title: 'Revoke access token',
308
+ description:
309
+ 'Revoke an access token by its id. Every client using it is cut off immediately and there is no undo. Confirm with the user before calling this.'
310
+ },
299
311
  openapi: {
300
312
  'x-ee-impact': IMPACT.DESTRUCTIVE,
301
313
  responses: apiResponses('Returns a deletion marker. The token stops working immediately.', 400, 401, 403, 429, 500)
@@ -354,6 +366,13 @@ async function init(args) {
354
366
  tags: ['api', 'Access Tokens'],
355
367
 
356
368
  plugins: {
369
+ mcp: {
370
+ name: 'list_tokens',
371
+ title: 'List access tokens',
372
+ description:
373
+ 'List the access tokens on this instance, paged: description, scopes, restrictions, the account each is bound to and when it was last used. Token values are never shown. Filter with query, or with account for the tokens bound to one account.',
374
+ bounds: { pageSize: MCP_MAX_PAGE_SIZE }
375
+ },
357
376
  openapi: {
358
377
  responses: apiResponses('Returns the matching access tokens. Token values are never returned after creation.', 400, 401, 403, 429, 500)
359
378
  }
@@ -462,6 +481,12 @@ async function init(args) {
462
481
  tags: ['api', 'Access Tokens'],
463
482
 
464
483
  plugins: {
484
+ mcp: {
485
+ name: 'get_token',
486
+ title: 'Get access token',
487
+ description:
488
+ 'Get one access token by its id (from list_tokens): scopes, permissions, restrictions and last use. Never the token value itself.'
489
+ },
465
490
  openapi: {
466
491
  responses: apiResponses('Returns the stored token record. The token value is not included.', 400, 401, 403, 404, 429, 500)
467
492
  }
@@ -519,6 +544,13 @@ async function init(args) {
519
544
  tags: ['api', 'Access Tokens'],
520
545
 
521
546
  plugins: {
547
+ mcp: {
548
+ name: 'get_token_log',
549
+ title: 'Get access token audit log',
550
+ description:
551
+ 'Read the audit log of one access token, paged: which requests it made, against which account, from which address, and which were refused and why. Only kept while the tokenAuditLog setting is on.',
552
+ bounds: { pageSize: MCP_MAX_PAGE_SIZE }
553
+ },
522
554
  openapi: {
523
555
  'x-ee-impact': IMPACT.READONLY,
524
556
  responses: apiResponses('Returns the recorded requests for this token, newest first.', 400, 401, 403, 404, 429, 500)
@@ -5,6 +5,7 @@ const { webhooks: Webhooks } = require('../webhooks');
5
5
  const { failAction } = require('../tools');
6
6
  const { handleError, throwNotFound, maskSecrets, MASK_NOTE } = require('./route-helpers');
7
7
  const { settingsSchema, apiResponses } = require('../schemas');
8
+ const { MCP_MAX_PAGE_SIZE } = require('../consts');
8
9
 
9
10
  const webhookErrorFlagSchema = Joi.object({
10
11
  message: Joi.string().example('Request failed with status 500').description('Error message from the last failed delivery')
@@ -48,6 +49,13 @@ async function init(args) {
48
49
  tags: ['api', 'Webhooks'],
49
50
 
50
51
  plugins: {
52
+ mcp: {
53
+ name: 'list_webhook_routes',
54
+ title: 'List webhook routes',
55
+ description:
56
+ 'List the custom webhook routes, paged: per-route targets with their own event filters, beside the global webhook target in the settings. Credentials in target URLs are masked.',
57
+ bounds: { pageSize: MCP_MAX_PAGE_SIZE }
58
+ },
51
59
  openapi: {
52
60
  responses: apiResponses('Returns a page of custom webhook routes.', 400, 401, 403, 429, 500)
53
61
  }
@@ -136,6 +144,11 @@ async function init(args) {
136
144
  tags: ['api', 'Webhooks'],
137
145
 
138
146
  plugins: {
147
+ mcp: {
148
+ name: 'get_webhook_route',
149
+ title: 'Get webhook route',
150
+ description: 'Get one webhook route: its target URL, the events it forwards, whether it is enabled, and its filter and mapping functions.'
151
+ },
139
152
  openapi: {
140
153
  responses: apiResponses('Returns the webhook route, including its filter and transform functions.', 400, 401, 403, 404, 429, 500)
141
154
  }