emailengine-app 2.79.1 → 2.79.3

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 (87) hide show
  1. package/.github/workflows/deploy.yml +92 -39
  2. package/.github/workflows/release.yaml +94 -34
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +85 -0
  5. package/bin/emailengine.js +8 -1
  6. package/config/default.toml +6 -0
  7. package/copy-static-files.sh +23 -2
  8. package/data/google-crawlers.json +1 -1
  9. package/lib/account.js +138 -18
  10. package/lib/api-routes/account-routes.js +13 -1
  11. package/lib/api-routes/index.js +12 -0
  12. package/lib/api-routes/mailbox-routes.js +6 -0
  13. package/lib/api-routes/mcp-oauth-routes.js +259 -0
  14. package/lib/api-routes/mcp-routes.js +172 -0
  15. package/lib/api-routes/message-routes.js +125 -4
  16. package/lib/api-routes/outbox-routes.js +7 -0
  17. package/lib/api-routes/permission-map.js +97 -1
  18. package/lib/api-routes/route-helpers.js +16 -4
  19. package/lib/api-routes/route-metadata.js +24 -4
  20. package/lib/api-routes/submit-routes.js +41 -0
  21. package/lib/api-routes/template-routes.js +7 -0
  22. package/lib/api-routes/token-routes.js +4 -2
  23. package/lib/consts.js +30 -1
  24. package/lib/email-client/base-client.js +235 -163
  25. package/lib/email-client/gmail-client.js +99 -22
  26. package/lib/email-client/imap/mailbox.js +140 -66
  27. package/lib/email-client/imap-client.js +74 -68
  28. package/lib/email-client/outlook-client.js +29 -14
  29. package/lib/enum-descriptions.js +2 -1
  30. package/lib/field-usage.js +17 -1
  31. package/lib/logger.js +43 -3
  32. package/lib/lua/s-list-accounts.lua +5 -2
  33. package/lib/mcp/index.js +29 -0
  34. package/lib/mcp/inject.js +70 -0
  35. package/lib/mcp/json-schema.js +120 -0
  36. package/lib/mcp/listen.js +171 -0
  37. package/lib/mcp/oauth.js +324 -0
  38. package/lib/mcp/protocol.js +489 -0
  39. package/lib/mcp/resources.js +139 -0
  40. package/lib/mcp/tools.js +655 -0
  41. package/lib/openapi/index.js +3 -1
  42. package/lib/response-stream.js +52 -21
  43. package/lib/routes-ui.js +4 -0
  44. package/lib/schemas.js +24 -3
  45. package/lib/token-permission-view.js +104 -8
  46. package/lib/tokens.js +34 -5
  47. package/lib/tools.js +96 -0
  48. package/lib/ui-routes/account-routes.js +43 -1
  49. package/lib/ui-routes/admin-config-routes.js +114 -1
  50. package/lib/ui-routes/admin-entities-routes.js +54 -5
  51. package/lib/ui-routes/auth-routes.js +13 -0
  52. package/lib/ui-routes/mcp-consent-routes.js +330 -0
  53. package/lib/ui-routes/route-helpers.js +116 -1
  54. package/lib/utils/network.js +9 -1
  55. package/lib/web-safe-html.js +61 -0
  56. package/lib/webhooks.js +3 -8
  57. package/package.json +15 -14
  58. package/sbom.json +1 -1
  59. package/scripts/README.md +25 -0
  60. package/scripts/build-icon.js +77 -0
  61. package/server.js +21 -9
  62. package/static/css/flyonui.css +1 -1
  63. package/static/css/src/app.tailwind.css +98 -0
  64. package/static/emailengine.ico +0 -0
  65. package/static/js/ui.js +465 -1
  66. package/static/licenses.html +85 -135
  67. package/translations/messages.pot +103 -103
  68. package/views/config/mcp.hbs +361 -0
  69. package/views/config/oauth/index.hbs +7 -0
  70. package/views/layout/prompt.hbs +62 -0
  71. package/views/mcp/authorize.hbs +136 -0
  72. package/views/partials/head_assets.hbs +3 -3
  73. package/views/partials/mcp_access_levels.hbs +13 -0
  74. package/views/partials/mcp_account_limit.hbs +14 -0
  75. package/views/partials/mcp_tool_count.hbs +19 -0
  76. package/views/partials/side_menu.hbs +1 -0
  77. package/views/partials/ui/account-picker.hbs +59 -0
  78. package/views/partials/ui/code-block.hbs +26 -0
  79. package/views/partials/ui/menu-item.hbs +5 -0
  80. package/views/partials/ui/radio.hbs +41 -0
  81. package/views/partials/ui/tab.hbs +15 -10
  82. package/views/partials/ui/tabs.hbs +8 -5
  83. package/views/templates/template.hbs +4 -3
  84. package/views/tokens/index.hbs +8 -2
  85. package/views/tokens/new.hbs +514 -243
  86. package/winconf.js +148 -48
  87. package/workers/api.js +198 -48
@@ -0,0 +1,59 @@
1
+ {{!--
2
+ ui/account-picker - the "which account" field.
3
+
4
+ A free-text account id is a field only the person who already knows the id can fill in, and the
5
+ id is the one thing about an account nobody remembers. This is a search box instead: type any
6
+ part of an id, a name or an address, pick from the suggestions, and the box is replaced by a
7
+ card naming the account that was picked, with a button to clear it again.
8
+
9
+ The posted value stays a plain account id in a hidden input carrying the given id, so a page
10
+ that already reads or watches that field keeps working - static/js/ui.js fires `input` and
11
+ `change` on it whenever the choice changes, exactly as typing into a text field would.
12
+
13
+ Suggestions come from GET /admin/accounts/suggestions; the card is painted by ui.js from the
14
+ same JSON shape, so a server-rendered selection and a just-picked one cannot look different.
15
+
16
+ Hand-rolled rather than FlyonUI's HSComboBox, which the vendored bundle does carry: that
17
+ component renders items from template strings, and every field on a row here (a display name,
18
+ an address) arrives from a mail provider, so the rows are built as text nodes instead. The
19
+ hidden-id-plus-card shape is not one of its modes either.
20
+ {{> ui/account-picker id="account" label="Account" value=values.account selected=selectedAccount}}
21
+ Params:
22
+ id - hidden input id, also the default posted name and what page scripts read (required)
23
+ name - posted field name (defaults to id)
24
+ label - field label (optional)
25
+ hint - muted helper text under the control (optional)
26
+ error - validation error message (optional)
27
+ value - current account id (optional)
28
+ selected - picker entry for `value`: {account, name, email, state} (optional; without it a
29
+ value renders as an id the picker could not resolve, which is what a deleted
30
+ account looks like)
31
+ placeholder - search box placeholder (optional)
32
+ --}}
33
+ <div class="w-full">
34
+ {{#if label}}
35
+ <label class="label-text" for="{{id}}-search">{{label}}</label>
36
+ {{/if}}
37
+ <div data-account-picker data-input="{{id}}" {{#if selected}}data-selected="{{json selected}}" {{/if}}>
38
+ <input type="hidden" id="{{id}}" name="{{#if name}}{{name}}{{else}}{{id}}{{/if}}" {{#if value}}value="{{value}}" {{/if}}>
39
+
40
+ {{!-- The picked account. Empty until ui.js paints it, and hidden whenever nothing is picked. --}}
41
+ <div class="ee-account-picker-card hidden" data-picker-card></div>
42
+
43
+ <div class="ee-account-picker-search" data-picker-search>
44
+ <div class="input{{#if error}} is-invalid{{/if}}">
45
+ <span class="icon-[tabler--search] text-base-content/60 my-auto me-2 size-4 shrink-0"></span>
46
+ <input type="text" class="grow" id="{{id}}-search" role="combobox" aria-expanded="false" aria-autocomplete="list"
47
+ aria-controls="{{id}}-results" autocomplete="off" data-lpignore="true"
48
+ placeholder="{{#if placeholder}}{{placeholder}}{{else}}Search by name, address or account id{{/if}}">
49
+ </div>
50
+ <div class="ee-account-picker-results hidden" id="{{id}}-results" role="listbox" data-picker-results></div>
51
+ </div>
52
+ </div>
53
+ {{#if error}}
54
+ <span class="helper-text text-error">{{error}}</span>
55
+ {{/if}}
56
+ {{#if hint}}
57
+ <span class="helper-text">{{hint}}</span>
58
+ {{/if}}
59
+ </div>
@@ -0,0 +1,26 @@
1
+ {{!--
2
+ ui/code-block - labeled preformatted code block with an optional copy button (handled
3
+ centrally by the .copy-btn listener in static/js/ui.js). The <code> element renders empty -
4
+ pages fill it by id from their script. Optional block content renders as muted helper text
5
+ under the block; it is block content rather than a hash param so it can carry inline markup.
6
+ {{> ui/code-block id="x" label="..." copy=true}}
7
+ {{#> ui/code-block id="x" label="..."}}helper text{{/ui/code-block}}
8
+ Params:
9
+ id - id of the inner <code> element (required; also the copy target)
10
+ label - label text above the block (required)
11
+ copy - true to render a copy-to-clipboard button
12
+ --}}
13
+ <div>
14
+ {{#if copy}}
15
+ <div class="flex items-center justify-between gap-2 mb-1">
16
+ <span class="label-text">{{label}}</span>
17
+ {{> ui/copy-btn target=id small=true}}
18
+ </div>
19
+ {{else}}
20
+ <span class="label-text">{{label}}</span>
21
+ {{/if}}
22
+ <pre class="ee-code-block"><code id="{{id}}"></code></pre>
23
+ {{#if @partial-block}}
24
+ <span class="helper-text">{{> @partial-block id="" label="" copy=""}}</span>
25
+ {{/if}}
26
+ </div>
@@ -5,6 +5,7 @@
5
5
  label - link text (required)
6
6
  icon - full iconify class incl. size, e.g. "icon-[tabler--users] size-4.5" (optional)
7
7
  active - true to highlight as the current page
8
+ badge - small soft badge text after the label, e.g. "Beta" (optional)
8
9
  warnText - when non-empty, renders a trailing warning icon whose tooltip
9
10
  shows this text (optional)
10
11
  --}}
@@ -13,9 +14,13 @@
13
14
  {{#if icon}}<span class="{{icon}}"></span>{{/if}}
14
15
  {{#if warnText}}
15
16
  <span class="grow">{{label}}</span>
17
+ {{#if badge}}{{> ui/badge label=badge variant="info" soft=true class="badge-sm shrink-0" icon="" elId=""}}{{/if}}
16
18
  {{#> ui/tooltip text=warnText class="shrink-0"}}
17
19
  <span class="icon-[tabler--alert-triangle] text-warning size-4 shrink-0"></span>
18
20
  {{/ui/tooltip}}
21
+ {{else if badge}}
22
+ <span class="grow">{{label}}</span>
23
+ {{> ui/badge label=badge variant="info" soft=true class="badge-sm shrink-0" icon="" elId=""}}
19
24
  {{else}}
20
25
  <span>{{label}}</span>
21
26
  {{/if}}</a>
@@ -0,0 +1,41 @@
1
+ {{!--
2
+ ui/radio - one radio option with label, optional help tooltip, hint and error.
3
+ Emits no outer margin (caller owns spacing, same as ui/checkbox). Options
4
+ group by sharing a name; render one partial per option.
5
+ Usage:
6
+ {{> ui/radio id="accessRead" name="access" value="read" label="Read-only" checked=true hint="Recommended."}}
7
+ Params:
8
+ id - control id (required)
9
+ name - input name shared by the group (required; radios group by name)
10
+ value - the value this option posts (required)
11
+ label - label text (required)
12
+ labelTitle - title attribute on the label, shown on hover (optional)
13
+ selected - the group's selected value; this option renders checked when
14
+ it equals value (the natural API for a radio group)
15
+ checked - true to render checked (alternative to selected, for a
16
+ static default)
17
+ tooltip - help text shown on hover behind a question icon (optional)
18
+ hint - muted helper text under the control (optional)
19
+ error - validation error message (optional)
20
+ disabled - true to render the input disabled (optional)
21
+ class - extra classes on the input (optional)
22
+ --}}
23
+ <div class="w-full">
24
+ <div class="flex items-center gap-2">
25
+ <input type="radio" class="radio radio-sm{{#if error}} is-invalid{{/if}}{{#if class}} {{class}}{{/if}}" id="{{id}}" name="{{name}}" value="{{value}}"
26
+ {{#if checked}}checked {{else}}{{#equals selected value}}checked {{/equals}}{{/if}}{{#if disabled}}disabled {{/if}}>
27
+ <label class="label-text p-0" for="{{id}}" {{#if labelTitle}}title="{{labelTitle}}" {{/if}}>{{label}}</label>
28
+ {{#if tooltip}}
29
+ {{!-- class="" blocks this partial's own class param (meant for the
30
+ input) from falling through onto the tooltip wrapper --}}
31
+ {{#> ui/tooltip text=tooltip class=""}}<span
32
+ class="icon-[tabler--help-circle] size-4 text-base-content/50"></span>{{/ui/tooltip}}
33
+ {{/if}}
34
+ </div>
35
+ {{#if error}}
36
+ <span class="helper-text text-error">{{error}}</span>
37
+ {{/if}}
38
+ {{#if hint}}
39
+ <span class="helper-text">{{hint}}</span>
40
+ {{/if}}
41
+ </div>
@@ -1,14 +1,19 @@
1
1
  {{!--
2
2
  ui/tab - one tab button inside a ui/tabs strip.
3
3
  Params:
4
- target - id of the tabpanel this button controls; the button id becomes
5
- "<target>-tab" (required)
6
- label - button text (required)
7
- active - true for the initially selected tab
8
- key - stable identity for this tab within its strip, emitted as
9
- data-tab-key (optional). For scripts that reselect a tab across
10
- pages: `target` carries the operation id so it cannot match
11
- anywhere else, and the label is display text that changes when
12
- the wording does.
4
+ target - id of the tabpanel this button controls; the button id
5
+ becomes "<target>-tab" (required)
6
+ label - button text (required)
7
+ active - true for the initially selected tab
8
+ badgeLabel - short state badge rendered after the label, e.g.
9
+ "not enabled" on a method that needs setup first; the tab
10
+ stays clickable so its panel can explain how to enable it
11
+ (optional)
12
+ badgeVariant - color of that badge (ui/badge variant, default neutral)
13
+ key - stable identity for this tab within its strip, emitted as
14
+ data-tab-key (optional). For scripts that reselect a tab
15
+ across pages: `target` carries the operation id so it
16
+ cannot match anywhere else, and the label is display text
17
+ that changes when the wording does.
13
18
  --}}
14
- <button type="button" class="tab active-tab:tab-active{{#if active}} active{{/if}}" id="{{target}}-tab" data-tab="#{{target}}" role="tab" aria-controls="{{target}}" aria-selected="{{#if active}}true{{else}}false{{/if}}"{{#if key}} data-tab-key="{{key}}"{{/if}}>{{label}}</button>
19
+ <button type="button" class="tab active-tab:tab-active{{#if active}} active{{/if}}" id="{{target}}-tab" data-tab="#{{target}}" role="tab" aria-controls="{{target}}" aria-selected="{{#if active}}true{{else}}false{{/if}}"{{#if key}} data-tab-key="{{key}}"{{/if}}>{{label}}{{#if badgeLabel}} {{> ui/badge label=badgeLabel variant=badgeVariant soft=true class="" icon="" elId=""}}{{/if}}</button>
@@ -5,9 +5,12 @@
5
5
  {{> ui/tab target="text" label="Plain text"}}
6
6
  {{/ui/tabs}}
7
7
  Params:
8
- label - aria-label describing the strip (required)
9
- elId - element id (optional; see ui/badge for why it is not called `id`)
10
- class - extra classes on the nav, e.g. "mb-4" (optional)
8
+ label - aria-label describing the strip (required)
9
+ elId - element id (optional; see ui/badge for why it is not called `id`)
10
+ class - extra classes on the nav, e.g. "mb-4" (optional)
11
+ variant - "segment" for the pill/segmented style (.tabs-segment in
12
+ app.tailwind.css), for a choice nested inside a page that
13
+ already has a bordered strip at the top; default bordered
11
14
  flex-wrap because FlyonUI lays the strip out as a nowrap flex row with no overflow
12
15
  handling, so one wider than its column pushes the whole page sideways instead of
13
16
  adapting: an API reference operation documents up to eight status codes, which is 464px
@@ -19,7 +22,7 @@
19
22
  The auth-method tabs in oauth_form.hbs intentionally do NOT use this partial -
20
23
  they run a custom script instead of the FlyonUI data-tabs plugin.
21
24
  --}}
22
- <nav class="tabs tabs-bordered flex-wrap{{#if class}} {{class}}{{/if}}" aria-label="{{label}}" role="tablist"{{#if elId}} id="{{elId}}"{{/if}} data-tabs>
25
+ <nav class="tabs {{#equals variant 'segment'}}tabs-segment{{else}}tabs-bordered{{/equals}} flex-wrap{{#if class}} {{class}}{{/if}}" aria-label="{{label}}" role="tablist"{{#if elId}} id="{{elId}}"{{/if}} data-tabs>
23
26
  {{!-- own hash params neutralized against fallthrough into the block --}}
24
- {{> @partial-block label="" id="" class=""}}
27
+ {{> @partial-block label="" elId="" class="" variant=""}}
25
28
  </nav>
@@ -97,7 +97,7 @@ fieldName="template" fieldValue=template.id submitLabel="Delete template"}}
97
97
  <div class="modal-body space-y-4">
98
98
 
99
99
  {{#unless account}}
100
- {{> ui/form-field id="inputAccount" name="account" label="Account ID" required=true hint="The account ID to send email as."}}
100
+ {{> ui/account-picker id="inputAccount" name="account" label="Account" hint="The account to send the test email as."}}
101
101
  {{/unless}}
102
102
 
103
103
  {{> ui/form-field id="inputTo" name="inputTo" type="email" label="Recipient's email address" required=true hint="Where to send the test email to."}}
@@ -153,7 +153,7 @@ fieldName="template" fieldValue=template.id submitLabel="Delete template"}}
153
153
  editorJson.session.setValue('{\n "keyName": "value"\n}');
154
154
 
155
155
  if (inputAccount) {
156
- inputAccount.value = '';
156
+ uiAccountPickerClear(inputAccount);
157
157
  }
158
158
  inputTo.value = '';
159
159
 
@@ -194,9 +194,10 @@ fieldName="template" fieldValue=template.id submitLabel="Delete template"}}
194
194
  });
195
195
 
196
196
  if (inputAccount) {
197
+ // The picker fires both on the hidden input whenever the choice changes. No keyup:
198
+ // the field cannot be typed into.
197
199
  inputAccount.addEventListener('input', setStateUpdate);
198
200
  inputAccount.addEventListener('change', setStateUpdate);
199
- inputAccount.addEventListener('keyup', setStateUpdate);
200
201
  }
201
202
 
202
203
  inputTo.addEventListener('input', setStateUpdate);
@@ -13,6 +13,12 @@
13
13
 
14
14
  {{> ui/search-crumb parentHref="/admin/tokens" parentLabel="Access Tokens" query=query}}
15
15
 
16
+ {{!-- The scope deep-link filter (the MCP pages link here with ?scope=mcp): named the same way an
17
+ active search is, with the parent crumb as the way out of it --}}
18
+ {{#if scopeFilter}}
19
+ {{> ui/breadcrumb parentHref="/admin/tokens" parentLabel="Access Tokens" current=(concat 'Tokens with the "' scopeFilter '" scope') class="mb-6"}}
20
+ {{/if}}
21
+
16
22
  {{#if data.tokens}}
17
23
  <div class="card bg-base-100 shadow-md mb-6">
18
24
  {{#if account}}
@@ -116,7 +122,7 @@
116
122
  program-association bug (the account note never rendered). Keep the block's first
117
123
  content token a static element. --}}
118
124
  {{#if account}}
119
- {{#> ui/list-empty noun="access tokens" query=query firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
125
+ {{#> ui/list-empty noun="access tokens" query=query filterActive=scopeFilter firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
120
126
  <div class="mb-2">
121
127
  Currently showing tokens for <strong><a href="/admin/accounts/{{urlpart account.account}}"
122
128
  class="link link-animated">{{#if account.name}}{{account.name}}{{else}}{{account.email}}{{/if}}</a></strong>.
@@ -124,7 +130,7 @@
124
130
  </div>
125
131
  {{/ui/list-empty}}
126
132
  {{else}}
127
- {{> ui/list-empty noun="access tokens" query=query firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
133
+ {{> ui/list-empty noun="access tokens" query=query filterActive=scopeFilter firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
128
134
  {{/if}}
129
135
  {{/if}}
130
136