emailengine-app 2.80.0 → 2.81.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.
- package/.dockerignore +44 -0
- package/.github/docker-smoke-test.sh +16 -0
- package/.github/workflows/deploy.yml +4 -0
- package/.github/workflows/release.yaml +4 -0
- package/.github/workflows/test.yml +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +56 -0
- package/Dockerfile +17 -9
- package/README.md +6 -0
- package/data/google-crawlers.json +1 -1
- package/docker-compose.yml +7 -1
- package/lib/api-routes/account-routes.js +239 -73
- package/lib/api-routes/blocklist-routes.js +24 -0
- package/lib/api-routes/delivery-test-routes.js +6 -0
- package/lib/api-routes/gateway-routes.js +30 -0
- package/lib/api-routes/license-routes.js +10 -0
- package/lib/api-routes/mcp-oauth-routes.js +3 -3
- package/lib/api-routes/mcp-routes.js +39 -21
- package/lib/api-routes/oauth2-app-routes.js +38 -1
- package/lib/api-routes/outbox-routes.js +6 -0
- package/lib/api-routes/permission-map.js +212 -42
- package/lib/api-routes/pubsub-routes.js +8 -0
- package/lib/api-routes/route-helpers.js +58 -11
- package/lib/api-routes/settings-routes.js +50 -4
- package/lib/api-routes/stats-routes.js +6 -0
- package/lib/api-routes/template-routes.js +21 -0
- package/lib/api-routes/token-routes.js +34 -2
- package/lib/api-routes/webhook-route-routes.js +13 -0
- package/lib/autodetect-imap-settings.js +4 -4
- package/lib/email-client/base-client.js +6 -3
- package/lib/email-client/credential-errors.js +4 -0
- package/lib/email-client/imap/login-failure.js +52 -0
- package/lib/email-client/imap/subconnection.js +2 -1
- package/lib/email-client/imap-client.js +3 -6
- package/lib/enum-descriptions.js +12 -2
- package/lib/imapproxy/imap-server.js +1 -1
- package/lib/mcp/oauth.js +46 -8
- package/lib/mcp/protocol.js +78 -35
- package/lib/mcp/tools.js +53 -17
- package/lib/privileged-settings.js +147 -0
- package/lib/schemas.js +60 -16
- package/lib/sentry.js +13 -2
- package/lib/settings.js +13 -0
- package/lib/tls/catalog.js +428 -0
- package/lib/tls/context.js +87 -161
- package/lib/tls/listeners.js +62 -0
- package/lib/tls/provision.js +1 -1
- package/lib/tls/status.js +128 -79
- package/lib/tls/store.js +3 -2
- package/lib/token-permission-view.js +253 -102
- package/lib/token-permissions.js +176 -26
- package/lib/tokens.js +7 -6
- package/lib/tools.js +5 -3
- package/lib/ui-routes/account-routes.js +195 -61
- package/lib/ui-routes/admin-config-routes.js +41 -21
- package/lib/ui-routes/admin-entities-routes.js +32 -22
- package/lib/ui-routes/mcp-consent-routes.js +72 -31
- package/lib/ui-routes/tls-config-routes.js +121 -74
- package/package.json +16 -16
- package/sbom.json +1 -1
- package/server.js +7 -1
- package/static/css/flyonui.css +1 -1
- package/static/css/public.css +41 -0
- package/static/css/src/app.tailwind.css +135 -4
- package/static/js/public.js +218 -0
- package/static/js/ui.js +89 -36
- package/static/licenses.html +55 -37
- package/translations/README.md +4 -3
- package/translations/de.mo +0 -0
- package/translations/de.po +296 -185
- package/translations/en.po +220 -128
- package/translations/es.mo +0 -0
- package/translations/es.po +558 -0
- package/translations/et.mo +0 -0
- package/translations/et.po +288 -181
- package/translations/fr.mo +0 -0
- package/translations/fr.po +295 -183
- package/translations/it.mo +0 -0
- package/translations/it.po +558 -0
- package/translations/ja.mo +0 -0
- package/translations/ja.po +268 -192
- package/translations/locales.json +24 -0
- package/translations/messages.pot +179 -127
- package/translations/nl.mo +0 -0
- package/translations/nl.po +288 -175
- package/translations/pl.mo +0 -0
- package/translations/pl.po +294 -181
- package/translations/sv.mo +0 -0
- package/translations/sv.po +555 -0
- package/translations/tr.mo +0 -0
- package/translations/tr.po +555 -0
- package/update-info.sh +12 -6
- package/views/account/login-redirect.hbs +6 -5
- package/views/account/passkeys.hbs +8 -8
- package/views/account/security.hbs +2 -2
- package/views/accounts/account.hbs +19 -21
- package/views/accounts/browse.hbs +1 -1
- package/views/accounts/edit.hbs +15 -15
- package/views/accounts/index.hbs +3 -3
- package/views/accounts/register/imap-server.hbs +27 -173
- package/views/accounts/register/validating.hbs +139 -0
- package/views/config/ai.hbs +15 -17
- package/views/config/branding.hbs +7 -7
- package/views/config/document-store/chat.hbs +9 -8
- package/views/config/document-store/index.hbs +14 -15
- package/views/config/document-store/mappings/index.hbs +5 -6
- package/views/config/document-store/mappings/new.hbs +1 -2
- package/views/config/document-store/pre-processing/index.hbs +4 -4
- package/views/config/email-processing.hbs +6 -6
- package/views/config/imap-proxy.hbs +7 -8
- package/views/config/license.hbs +9 -9
- package/views/config/logging.hbs +5 -7
- package/views/config/mcp.hbs +90 -58
- package/views/config/network.hbs +4 -4
- package/views/config/oauth/app.hbs +12 -12
- package/views/config/oauth/index.hbs +6 -6
- package/views/config/oauth/subscriptions.hbs +9 -9
- package/views/config/security.hbs +5 -7
- package/views/config/service.hbs +11 -10
- package/views/config/smtp.hbs +9 -12
- package/views/config/tls-upload.hbs +3 -3
- package/views/config/tls.hbs +281 -182
- package/views/config/webhooks.hbs +12 -15
- package/views/dashboard.hbs +9 -8
- package/views/gateways/edit.hbs +3 -3
- package/views/gateways/gateway.hbs +3 -3
- package/views/gateways/index.hbs +6 -6
- package/views/gateways/new.hbs +3 -3
- package/views/internals/index.hbs +15 -13
- package/views/layout/app.hbs +6 -6
- package/views/layout/login.hbs +32 -19
- package/views/layout/main.hbs +2 -2
- package/views/layout/prompt.hbs +15 -18
- package/views/layout/public.hbs +1 -1
- package/views/mcp/authorize.hbs +47 -45
- package/views/partials/accounts_table.hbs +5 -5
- package/views/partials/ace_assets.hbs +1 -1
- package/views/partials/add_account_modal.hbs +4 -4
- package/views/partials/address_list.hbs +4 -4
- package/views/partials/filter_editor_js.hbs +2 -2
- package/views/partials/gateway_form.hbs +5 -5
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/mcp_access_levels.hbs +16 -9
- package/views/partials/mcp_account_limit.hbs +2 -2
- package/views/partials/mcp_tool_count.hbs +15 -14
- package/views/partials/oauth_config_header.hbs +2 -2
- package/views/partials/oauth_form.hbs +37 -42
- package/views/partials/public_alerts.hbs +1 -1
- package/views/partials/public_test_labels.hbs +15 -0
- package/views/partials/public_theme_init.hbs +1 -1
- package/views/partials/security_header.hbs +2 -2
- package/views/partials/template_form.hbs +4 -4
- package/views/partials/theme_init.hbs +1 -1
- package/views/partials/tls_security_card.hbs +4 -1
- package/views/partials/ui/form-field.hbs +6 -1
- package/views/partials/ui/setting-ref.hbs +12 -7
- package/views/partials/ui/stat-card.hbs +4 -1
- package/views/partials/ui/tabs.hbs +3 -7
- package/views/partials/webhook_form.hbs +9 -12
- package/views/partials/webhooks_editor_functions.hbs +1 -1
- package/views/reference/index.hbs +3 -3
- package/views/reference/redirect.hbs +1 -1
- package/views/reference/tag.hbs +1 -1
- package/views/reference/token.hbs +4 -4
- package/views/suppression-lists/index.hbs +8 -6
- package/views/suppression-lists/list.hbs +13 -8
- package/views/templates/edit.hbs +1 -1
- package/views/templates/index.hbs +10 -11
- package/views/templates/template.hbs +5 -5
- package/views/tokens/index.hbs +17 -17
- package/views/tokens/new.hbs +190 -93
- package/views/unsubscribe.hbs +1 -1
- package/views/webhooks/edit.hbs +1 -1
- package/views/webhooks/index.hbs +10 -11
- package/views/webhooks/new.hbs +1 -1
- package/views/webhooks/webhook.hbs +5 -6
- package/workers/api.js +9 -8
- package/workers/smtp.js +1 -1
package/views/tokens/new.hbs
CHANGED
|
@@ -10,11 +10,9 @@
|
|
|
10
10
|
{{#unless canProvision}}
|
|
11
11
|
{{#> ui/stat-card variant="error" title="Set an admin password first" icon="icon-[tabler--shield-lock]" class="mb-6"}}
|
|
12
12
|
|
|
13
|
-
<p class="mb-4">
|
|
14
|
-
that carries an admin session. This instance has no admin password set, so there is no session to
|
|
15
|
-
carry - set one and the form appears here.</p>
|
|
13
|
+
<p class="mb-4">Set an admin password and sign in to create access tokens. Tokens created here remain valid until you delete them.</p>
|
|
16
14
|
<div>
|
|
17
|
-
{{> ui/btn href="/admin/account/password" variant="primary" icon="icon-[tabler--arrow-right]" label="
|
|
15
|
+
{{> ui/btn href="/admin/account/password" variant="primary" icon="icon-[tabler--arrow-right]" label="Set admin password"}}
|
|
18
16
|
</div>
|
|
19
17
|
|
|
20
18
|
{{/ui/stat-card}}
|
|
@@ -26,7 +24,7 @@
|
|
|
26
24
|
|
|
27
25
|
<div class="card-body space-y-4">
|
|
28
26
|
|
|
29
|
-
{{> ui/form-field id="description" label="Description" value=values.description error=errors.description required=true hint="
|
|
27
|
+
{{> ui/form-field id="description" label="Description" value=values.description error=errors.description required=true hint="Describe the app or task that will use this token."}}
|
|
30
28
|
|
|
31
29
|
{{!-- A search box rather than a select or free text: an instance can hold far more
|
|
32
30
|
accounts than a list could usefully carry, and an account id is the one thing
|
|
@@ -35,13 +33,12 @@
|
|
|
35
33
|
nothing. --}}
|
|
36
34
|
{{> ui/account-picker id="account" label="Account (optional)" value=values.account selected=selectedAccount error=errors.account
|
|
37
35
|
placeholder="Leave empty to allow all accounts"
|
|
38
|
-
hint="
|
|
36
|
+
hint="Limit this token to one account. Leave blank to allow access to all accounts within the selected scopes and permissions."}}
|
|
39
37
|
|
|
40
38
|
<div>
|
|
41
39
|
<h6 class="mb-1 font-bold">Allowed scopes</h6>
|
|
42
40
|
<p class="text-base-content/60 text-sm mb-3">
|
|
43
|
-
|
|
44
|
-
a surface left out here cannot be added later.
|
|
41
|
+
Choose which EmailEngine interfaces this token can access. Scopes cannot be changed after creation.
|
|
45
42
|
</p>
|
|
46
43
|
|
|
47
44
|
{{!-- One line of plain words per row. The bracketed slug beside each was the only
|
|
@@ -57,7 +54,7 @@
|
|
|
57
54
|
<label class="label-text grow p-0" for="scopesAll">All scopes</label>
|
|
58
55
|
<div class="text-base-content/60 code-link">["*"]</div>
|
|
59
56
|
</div>
|
|
60
|
-
<p class="helper-text ms-7">
|
|
57
|
+
<p class="helper-text ms-7">All interfaces below, including any added in future releases.</p>
|
|
61
58
|
</li>
|
|
62
59
|
|
|
63
60
|
<li class="p-4">
|
|
@@ -100,16 +97,32 @@
|
|
|
100
97
|
<p class="helper-text ms-7">Read the Prometheus metrics endpoint and nothing else.</p>
|
|
101
98
|
</li>
|
|
102
99
|
|
|
100
|
+
{{!-- Two MCP scopes, management first: the endpoint is one door with two tool
|
|
101
|
+
sets behind it, and each scope opens one of them. Both rows carry the Beta
|
|
102
|
+
badge the MCP config page carries. --}}
|
|
103
|
+
<li class="p-4">
|
|
104
|
+
<div class="flex items-center gap-2">
|
|
105
|
+
<input type="checkbox" class="checkbox checkbox-sm scope-entry scope-list" id="scopesMcpManage"
|
|
106
|
+
name="scopesMcpManage" data-scope="mcp-manage" {{#if values.scopesMcpManage}}checked{{/if}} />
|
|
107
|
+
<label class="label-text grow p-0" for="scopesMcpManage">MCP management
|
|
108
|
+
{{> ui/badge label="Beta" variant="info" soft=true class="badge-sm align-middle" icon="" elId=""}}</label>
|
|
109
|
+
<div class="text-base-content/60 code-link">["mcp-manage"]</div>
|
|
110
|
+
</div>
|
|
111
|
+
<p class="helper-text ms-7">Let an AI agent manage this instance through the MCP tools at
|
|
112
|
+
<code>/mcp</code>: accounts, settings, OAuth2 applications, gateways, tokens and the license.
|
|
113
|
+
This scope does not grant REST API access.</p>
|
|
114
|
+
</li>
|
|
115
|
+
|
|
103
116
|
<li class="p-4">
|
|
104
117
|
<div class="flex items-center gap-2">
|
|
105
118
|
<input type="checkbox" class="checkbox checkbox-sm scope-entry scope-list" id="scopesMcp"
|
|
106
119
|
name="scopesMcp" data-scope="mcp" {{#if values.scopesMcp}}checked{{/if}} />
|
|
107
|
-
<label class="label-text grow p-0" for="scopesMcp">MCP
|
|
120
|
+
<label class="label-text grow p-0" for="scopesMcp">MCP mail
|
|
108
121
|
{{> ui/badge label="Beta" variant="info" soft=true class="badge-sm align-middle" icon="" elId=""}}</label>
|
|
109
122
|
<div class="text-base-content/60 code-link">["mcp"]</div>
|
|
110
123
|
</div>
|
|
111
|
-
<p class="helper-text ms-7">Let an AI agent
|
|
112
|
-
|
|
124
|
+
<p class="helper-text ms-7">Let an AI agent work with mailbox contents through the MCP tools at
|
|
125
|
+
<code>/mcp</code>: list, read, organize and send mail. This scope does not grant REST API access.</p>
|
|
113
126
|
{{!-- The endpoint is off by default, so an operator can otherwise mint a
|
|
114
127
|
credential for something that is not serving and only find out in the
|
|
115
128
|
client. Both halves of the gate are folded into mcpReady. Revealed by
|
|
@@ -118,8 +131,8 @@
|
|
|
118
131
|
selection ("All scopes") technically carries the mcp scope too. --}}
|
|
119
132
|
{{#unless mcpReady}}
|
|
120
133
|
<p id="mcpDisabledHint" class="helper-text ms-7 text-warning hidden">The MCP endpoint is not
|
|
121
|
-
enabled on this instance
|
|
122
|
-
|
|
134
|
+
enabled on this instance. <a href="/admin/config/mcp" class="link">Enable MCP</a>
|
|
135
|
+
before using this token with an MCP client.</p>
|
|
123
136
|
{{/unless}}
|
|
124
137
|
</li>
|
|
125
138
|
</ul>
|
|
@@ -138,7 +151,7 @@
|
|
|
138
151
|
The record itself stays single: one `permissions` object narrows whatever surface the
|
|
139
152
|
request arrives on. That is why this is one editor with two modes rather than a tab per
|
|
140
153
|
scope - separate panes would promise two records that cannot exist. --}}
|
|
141
|
-
<div id="accessCard" class="hidden" data-surfaces="{{permissionSurfacesJson}}" data-mcp-
|
|
154
|
+
<div id="accessCard" class="hidden" data-surfaces="{{permissionSurfacesJson}}" data-mcp-sections="{{json mcpSections}}">
|
|
142
155
|
{{#> ui/card bodyClass="space-y-4"}}
|
|
143
156
|
|
|
144
157
|
<div>
|
|
@@ -146,32 +159,42 @@
|
|
|
146
159
|
<p id="accessAppliesTo" class="text-base-content/60 text-sm"></p>
|
|
147
160
|
</div>
|
|
148
161
|
|
|
149
|
-
{{!-- MCP-only mode.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
{{!-- MCP-only mode. One level per MCP scope, shown while that scope is ticked above: the
|
|
163
|
+
same sections and levels the OAuth consent prompt and the MCP config page offer, from
|
|
164
|
+
the same table through the same partial, because the same credential minted from
|
|
165
|
+
three places must not mean three different things. A 72-cell matrix is not how
|
|
166
|
+
anyone provisions an agent, so it is the opt-in behind the levels rather than the way
|
|
167
|
+
in - and unlike the API editor there is no "restrict?" toggle: the narrowest level is
|
|
154
168
|
the default, because an agent credential that starts unrestricted is the wrong way
|
|
155
169
|
round. --}}
|
|
156
170
|
{{!-- Labelled by the card heading rather than carrying a legend of its own, which would
|
|
157
171
|
repeat "Access level" directly under itself --}}
|
|
158
|
-
<fieldset id="mcpLevelBlock" class="hidden space-y-
|
|
159
|
-
{{
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
<fieldset id="mcpLevelBlock" class="hidden space-y-4" aria-labelledby="accessCardTitle">
|
|
173
|
+
{{!-- One block per section, shown while that section's scope is ticked above; the radio
|
|
174
|
+
group is named mcpLevel_<key>, which is what the script and ui.js read back --}}
|
|
175
|
+
{{#each mcpSections}}
|
|
176
|
+
<div class="space-y-2 mcp-section-block" data-mcp-scope="{{scope}}">
|
|
177
|
+
<div class="label-text font-medium">{{label}}
|
|
178
|
+
<span class="text-base-content/60 code-link font-normal">["{{scope}}"]</span></div>
|
|
179
|
+
{{> mcp_access_levels section=this name=(concat "mcpLevel_" @key) idPrefix=(concat "mcpLevel_" @key) selected=levels.[0].value}}
|
|
180
|
+
</div>
|
|
181
|
+
{{/each}}
|
|
182
|
+
|
|
183
|
+
{{> ui/checkbox id="mcpCustom" label="Custom permissions" noName=true
|
|
184
|
+
hint="Choose the exact actions and sections yourself, starting from the levels selected above."}}
|
|
162
185
|
|
|
163
186
|
{{!-- At the decision point, as on the MCP config page: the level chosen here is what
|
|
164
187
|
decides whether instructions hidden inside received mail can act --}}
|
|
165
|
-
<p class="text-base-content/60 text-sm">
|
|
166
|
-
|
|
188
|
+
<p class="text-base-content/60 text-sm">The connected client may send email content to its AI model. Instructions in received emails can influence
|
|
189
|
+
the agent. Grant permission to send or delete email only when the agent needs it.</p>
|
|
167
190
|
</fieldset>
|
|
168
191
|
|
|
169
192
|
{{!-- API mode. Unrestricted by default, because an API token is the general-purpose
|
|
170
193
|
credential and narrowing it is the exception. --}}
|
|
171
194
|
<div id="apiLimitBlock" class="hidden">
|
|
172
195
|
<p class="text-base-content/60 text-sm mb-3">
|
|
173
|
-
|
|
174
|
-
|
|
196
|
+
Limit this token to the actions its app or service needs, such as reading email or sending messages.
|
|
197
|
+
Without restrictions, it can use all operations allowed by its scopes and account selection.
|
|
175
198
|
</p>
|
|
176
199
|
{{> ui/checkbox id="permissionsEnabled" label="Restrict what this token can do" checked=values.permissionsEnabled error=errors.permissions noName=true}}
|
|
177
200
|
</div>
|
|
@@ -201,7 +224,7 @@
|
|
|
201
224
|
<div id="permissionPresetRow">
|
|
202
225
|
<h6 class="mb-1 font-bold">Pick a preset</h6>
|
|
203
226
|
<p class="text-base-content/60 text-sm mb-2">
|
|
204
|
-
|
|
227
|
+
Start with a common set of permissions, then adjust the actions and sections below.
|
|
205
228
|
</p>
|
|
206
229
|
<div class="flex flex-wrap gap-2">
|
|
207
230
|
{{#each permissionPresets}}
|
|
@@ -255,8 +278,9 @@
|
|
|
255
278
|
<span class="icon-[tabler--lock] size-5 shrink-0"></span>
|
|
256
279
|
<span>
|
|
257
280
|
Some endpoints are never available to a restricted token, whatever you select here:
|
|
258
|
-
|
|
259
|
-
|
|
281
|
+
creating access tokens, reading an account's live OAuth2 credential, and the settings
|
|
282
|
+
that would let a token widen itself ({{privilegedSettingsSummary}}). A token that
|
|
283
|
+
could reach those could grant itself more.
|
|
260
284
|
</span>
|
|
261
285
|
</div>
|
|
262
286
|
</div>
|
|
@@ -266,20 +290,20 @@
|
|
|
266
290
|
</div>
|
|
267
291
|
|
|
268
292
|
<div class="mb-6">
|
|
269
|
-
{{> ui/btn label="
|
|
293
|
+
{{> ui/btn label="Create access token" type="submit" icon="icon-[tabler--key]"}}
|
|
270
294
|
</div>
|
|
271
295
|
</form>
|
|
272
296
|
|
|
273
297
|
{{!-- Wider than the default: the token is 64 characters and this is the only time it is shown, so
|
|
274
298
|
it has to be readable in full rather than scrolled through a 32-character window. --}}
|
|
275
|
-
{{#> ui/modal id="showToken" title="
|
|
299
|
+
{{#> ui/modal id="showToken" title="Your access token" static=true dialogClass="max-w-2xl"}}
|
|
276
300
|
<div class="modal-body">
|
|
277
301
|
<div id="showTokenLoader" class="py-2 text-center">
|
|
278
302
|
<span class="loading loading-spinner loading-sm align-middle"></span> Generating token…
|
|
279
303
|
</div>
|
|
280
304
|
<div id="showTokenContent" class="hidden">
|
|
281
305
|
|
|
282
|
-
<div class="mb-2">
|
|
306
|
+
<div class="mb-2">Copy and store this token securely. It will only be shown once.</div>
|
|
283
307
|
{{!-- w-full because ui/copy-field's join wrapper is inline-flex, so the `grow` on the input
|
|
284
308
|
has nothing to grow inside and the field kept its intrinsic width. text-sm so all 64
|
|
285
309
|
characters fit: this is the only time the value is ever shown, and a token truncated at
|
|
@@ -294,7 +318,7 @@
|
|
|
294
318
|
</div>
|
|
295
319
|
{{/ui/modal}}
|
|
296
320
|
|
|
297
|
-
<script nonce="{{cspNonce}}">
|
|
321
|
+
<script data-cfasync="false" nonce="{{cspNonce}}">
|
|
298
322
|
document.addEventListener('DOMContentLoaded', () => {
|
|
299
323
|
|
|
300
324
|
let showTokenValueElm = document.getElementById('showTokenValue');
|
|
@@ -334,13 +358,32 @@
|
|
|
334
358
|
};
|
|
335
359
|
}
|
|
336
360
|
|
|
337
|
-
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
let
|
|
361
|
+
// The two MCP access sections and what each level mints, from the same table the consent
|
|
362
|
+
// prompt and the MCP config page mint from
|
|
363
|
+
let mcpSections = JSON.parse(accessCardElm.dataset.mcpSections || '{}');
|
|
364
|
+
let mcpCustomElm = document.getElementById('mcpCustom');
|
|
365
|
+
|
|
366
|
+
let mcpScopes = Object.values(mcpSections).map(section => section.scope);
|
|
341
367
|
|
|
342
368
|
let scopeElms = Array.from(document.querySelectorAll('.scope-entry'));
|
|
343
369
|
let selectedScopes = () => scopeElms.filter(elm => elm.checked && !elm.disabled).map(elm => elm.dataset.scope);
|
|
370
|
+
let selectedMcpScopes = () => selectedScopes().filter(scope => mcpScopes.includes(scope));
|
|
371
|
+
|
|
372
|
+
// What the ticked MCP scopes can reach at all: the union of their surface tables. Read per
|
|
373
|
+
// call because it follows the scopes - a token holding only the management scope has no
|
|
374
|
+
// business ticking Messages in the custom editor.
|
|
375
|
+
let mcpCeilingFor = scopes => {
|
|
376
|
+
let ceiling = { actions: [], groups: [] };
|
|
377
|
+
for (let scope of scopes) {
|
|
378
|
+
let need = surfaceRequirements[scope];
|
|
379
|
+
if (!need) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
ceiling.actions = ceiling.actions.concat(need.actions.filter(value => !ceiling.actions.includes(value)));
|
|
383
|
+
ceiling.groups = ceiling.groups.concat(need.groups.filter(value => !ceiling.groups.includes(value)));
|
|
384
|
+
}
|
|
385
|
+
return ceiling;
|
|
386
|
+
};
|
|
344
387
|
|
|
345
388
|
// Permissions are resolved per endpoint on the REST API and per tool call on the MCP
|
|
346
389
|
// endpoint, so both of those scopes can carry a narrowing. The login-time scopes (SMTP,
|
|
@@ -353,7 +396,7 @@
|
|
|
353
396
|
// be greyed while this is open. That reads correctly: API access is granted by "All", and
|
|
354
397
|
// this is how to narrow it.
|
|
355
398
|
let hasApiScope = () => selectedScopes().some(scope => ['*', 'api'].includes(scope));
|
|
356
|
-
let hasMcpScope = () => selectedScopes().some(scope =>
|
|
399
|
+
let hasMcpScope = () => selectedScopes().some(scope => scope === '*' || mcpScopes.includes(scope));
|
|
357
400
|
let narrowableScope = () => hasApiScope() || hasMcpScope();
|
|
358
401
|
|
|
359
402
|
// The two editor modes. A token that reaches the MCP endpoint and not the REST API is a
|
|
@@ -363,9 +406,18 @@
|
|
|
363
406
|
// permissions record covers both surfaces and the API side needs all thirteen sections.
|
|
364
407
|
let mcpLevelMode = () => hasMcpScope() && !hasApiScope();
|
|
365
408
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
409
|
+
// The level per section, read through the shared helper: a section whose scope is not
|
|
410
|
+
// ticked has no radio group on screen and so comes back declined - the scope checkbox is
|
|
411
|
+
// this form's way of switching a section off
|
|
412
|
+
let selectedMcpLevels = () => {
|
|
413
|
+
let ticked = selectedMcpScopes();
|
|
414
|
+
let choice = uiMcpLevelChoice(mcpSections, 'mcpLevel_');
|
|
415
|
+
for (let key of Object.keys(mcpSections)) {
|
|
416
|
+
if (!ticked.includes(mcpSections[key].scope)) {
|
|
417
|
+
choice[key] = 'none';
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return choice;
|
|
369
421
|
};
|
|
370
422
|
|
|
371
423
|
// Sections the MCP surface can never reach are disabled while the level editor is showing,
|
|
@@ -396,29 +448,23 @@
|
|
|
396
448
|
// an empty one: it means the scopes are the only bound.
|
|
397
449
|
let effectiveRecord = () => {
|
|
398
450
|
if (mcpLevelMode()) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return { actions: record.actions, groups: record.groups, unrestricted: false };
|
|
404
|
-
}
|
|
405
|
-
// The full level is the one that legitimately stores no record. Any other level
|
|
406
|
-
// missing from the table means the table did not load, and a missing preset must
|
|
407
|
-
// not quietly mint a wider credential than the level on screen promises - the
|
|
408
|
-
// MCP config page's generator refuses the same way, and the consent route
|
|
409
|
-
// defaults the same direction.
|
|
410
|
-
return {
|
|
411
|
-
actions: mcpCeiling.actions,
|
|
412
|
-
groups: mcpCeiling.groups,
|
|
413
|
-
unrestricted: true,
|
|
414
|
-
unknownLevel: !Object.prototype.hasOwnProperty.call(mcpAccessPresets, level)
|
|
415
|
-
};
|
|
451
|
+
if (!mcpCustomElm.checked) {
|
|
452
|
+
// The pair list the selected levels mint, through the shared helper, so a level
|
|
453
|
+
// mints here exactly what it mints on the consent prompt
|
|
454
|
+
return uiMcpLevelRecord(mcpSections, selectedMcpLevels());
|
|
416
455
|
}
|
|
417
456
|
} else if (!permissionsEnabledElm.checked) {
|
|
418
457
|
return { actions: allActions, groups: Object.keys(axisLabels.group), unrestricted: true };
|
|
419
458
|
}
|
|
420
459
|
|
|
421
|
-
return {
|
|
460
|
+
return {
|
|
461
|
+
actions: tickedValues('.permission-action'),
|
|
462
|
+
groups: tickedValues('.permission-group'),
|
|
463
|
+
// The scope bound applies to a custom record too: the count must not promise a
|
|
464
|
+
// management tool to a token that only holds the mail scope
|
|
465
|
+
surfaces: mcpLevelMode() ? selectedMcpScopes() : undefined,
|
|
466
|
+
unrestricted: false
|
|
467
|
+
};
|
|
422
468
|
};
|
|
423
469
|
|
|
424
470
|
// Applies a permission record to the axes. Shared by the API presets and by the switch into
|
|
@@ -434,10 +480,11 @@
|
|
|
434
480
|
|
|
435
481
|
let syncAxisAvailability = () => {
|
|
436
482
|
let restrictToMcp = mcpLevelMode();
|
|
483
|
+
let ceiling = mcpCeilingFor(selectedMcpScopes());
|
|
437
484
|
|
|
438
485
|
for (let elm of document.querySelectorAll('.permission-axis')) {
|
|
439
486
|
let axis = elm.classList.contains('permission-action') ? 'actions' : 'groups';
|
|
440
|
-
let reachable = !restrictToMcp ||
|
|
487
|
+
let reachable = !restrictToMcp || ceiling[axis].includes(elm.dataset.value);
|
|
441
488
|
|
|
442
489
|
// Disabled rather than unticked: flipping the scopes back has to restore the
|
|
443
490
|
// selection rather than quietly lose it, and a disabled box is skipped by every
|
|
@@ -479,6 +526,35 @@
|
|
|
479
526
|
// stale count cannot survive a scope change.
|
|
480
527
|
window.uiMcpToolCount(mcpToolCountElm, hasMcpScope() ? Object.assign({ account: accountElm.value }, record) : null);
|
|
481
528
|
|
|
529
|
+
let rest = document.createElement('div');
|
|
530
|
+
rest.className = 'text-base-content/60';
|
|
531
|
+
rest.textContent = 'It cannot reach anything else, create tokens or read stored credentials.';
|
|
532
|
+
|
|
533
|
+
if (record.grants) {
|
|
534
|
+
// A level per section, each read out in the words of the table it came from
|
|
535
|
+
if (!record.grants.length) {
|
|
536
|
+
let line = document.createElement('div');
|
|
537
|
+
line.className = 'text-warning';
|
|
538
|
+
line.textContent = 'No access level is selected, so this token would not be able to do anything.';
|
|
539
|
+
permissionOutcomeTextElm.append(line);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
let levels = selectedMcpLevels();
|
|
543
|
+
for (let key of Object.keys(mcpSections)) {
|
|
544
|
+
let level = mcpSections[key].levels.find(entry => entry.value === levels[key]);
|
|
545
|
+
if (!level) {
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
let line = document.createElement('div');
|
|
549
|
+
let label = document.createElement('strong');
|
|
550
|
+
label.textContent = mcpSections[key].label + ' (' + level.label + '): ';
|
|
551
|
+
line.append(label, document.createTextNode('can ' + level.actions + ' across ' + level.groups + '.'));
|
|
552
|
+
permissionOutcomeTextElm.append(line);
|
|
553
|
+
}
|
|
554
|
+
permissionOutcomeTextElm.append(rest);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
482
558
|
if (!record.unrestricted && (!record.actions.length || !record.groups.length)) {
|
|
483
559
|
let line = document.createElement('div');
|
|
484
560
|
line.className = 'text-warning';
|
|
@@ -504,9 +580,6 @@
|
|
|
504
580
|
permissionOutcomeTextElm.append(cannot);
|
|
505
581
|
}
|
|
506
582
|
|
|
507
|
-
let rest = document.createElement('div');
|
|
508
|
-
rest.className = 'text-base-content/60';
|
|
509
|
-
rest.textContent = 'It cannot reach anything else, or read credentials and settings.';
|
|
510
583
|
permissionOutcomeTextElm.append(rest);
|
|
511
584
|
};
|
|
512
585
|
|
|
@@ -525,15 +598,18 @@
|
|
|
525
598
|
scopes = Object.keys(surfaceRequirements);
|
|
526
599
|
}
|
|
527
600
|
|
|
601
|
+
let covers = ([action, group]) => uiMcpRecordAllows(record, action, group);
|
|
602
|
+
|
|
528
603
|
let blocked = scopes
|
|
529
604
|
.filter(scope => surfaceRequirements[scope])
|
|
530
605
|
.filter(scope => {
|
|
531
606
|
let need = surfaceRequirements[scope];
|
|
532
607
|
if (need.mode === 'any') {
|
|
533
608
|
// Per-request surface: usable while any one (action, group) pair survives
|
|
534
|
-
return !need.grants.some(
|
|
609
|
+
return !need.grants.some(covers);
|
|
535
610
|
}
|
|
536
|
-
|
|
611
|
+
// Login-time surface: every pair it exercises has to survive
|
|
612
|
+
return !need.grants.every(covers);
|
|
537
613
|
})
|
|
538
614
|
.map(scope => surfaceRequirements[scope].label);
|
|
539
615
|
|
|
@@ -582,11 +658,18 @@
|
|
|
582
658
|
apiLimitBlockElm.classList.toggle('hidden', levelMode);
|
|
583
659
|
syncAxisAvailability();
|
|
584
660
|
|
|
585
|
-
//
|
|
661
|
+
// A section is shown while its scope is ticked: the scope checkbox is how this form
|
|
662
|
+
// declines a section, so an unticked scope must not leave a level on screen
|
|
663
|
+
let ticked = selectedMcpScopes();
|
|
664
|
+
for (let block of document.querySelectorAll('.mcp-section-block')) {
|
|
665
|
+
block.classList.toggle('hidden', !ticked.includes(block.dataset.mcpScope));
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// The matrix is the detail view behind either mode: the "Custom permissions" opt-in on
|
|
586
669
|
// one side, the restriction toggle on the other. The API presets are shapes for the
|
|
587
670
|
// REST API, so they stay out of the way in level mode, where the named levels above
|
|
588
671
|
// are the presets.
|
|
589
|
-
permissionSectionElm.classList.toggle('hidden', levelMode ?
|
|
672
|
+
permissionSectionElm.classList.toggle('hidden', levelMode ? !mcpCustomElm.checked : !permissionsEnabledElm.checked);
|
|
590
673
|
permissionPresetRowElm.classList.toggle('hidden', levelMode);
|
|
591
674
|
};
|
|
592
675
|
|
|
@@ -594,7 +677,7 @@
|
|
|
594
677
|
// ticked - the default selection carries the mcp scope with everything else, and warning
|
|
595
678
|
// about a disabled endpoint on a page nobody opened for MCP is noise.
|
|
596
679
|
let mcpDisabledHintElm = document.getElementById('mcpDisabledHint');
|
|
597
|
-
let
|
|
680
|
+
let scopesMcpElms = [document.getElementById('scopesMcpManage'), document.getElementById('scopesMcp')];
|
|
598
681
|
|
|
599
682
|
let syncAll = () => {
|
|
600
683
|
syncAccessCard();
|
|
@@ -602,7 +685,7 @@
|
|
|
602
685
|
syncPermissionOutcome();
|
|
603
686
|
|
|
604
687
|
if (mcpDisabledHintElm) {
|
|
605
|
-
mcpDisabledHintElm.classList.toggle('hidden', !
|
|
688
|
+
mcpDisabledHintElm.classList.toggle('hidden', !scopesMcpElms.some(elm => elm.checked && !elm.disabled));
|
|
606
689
|
}
|
|
607
690
|
};
|
|
608
691
|
|
|
@@ -618,19 +701,28 @@
|
|
|
618
701
|
syncAll();
|
|
619
702
|
});
|
|
620
703
|
|
|
621
|
-
//
|
|
622
|
-
//
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
704
|
+
// Custom starts from the levels selected above, which is what its hint promises: the axes
|
|
705
|
+
// are seeded from the pairs those levels mint, which is the two-axis record closest to them
|
|
706
|
+
mcpCustomElm.addEventListener('change', () => {
|
|
707
|
+
if (mcpCustomElm.checked) {
|
|
708
|
+
let record = uiMcpLevelRecord(mcpSections, selectedMcpLevels());
|
|
709
|
+
let actions = [];
|
|
710
|
+
let groups = [];
|
|
711
|
+
for (let grant of record.grants) {
|
|
712
|
+
if (!actions.includes(grant.action)) {
|
|
713
|
+
actions.push(grant.action);
|
|
714
|
+
}
|
|
715
|
+
if (!groups.includes(grant.group)) {
|
|
716
|
+
groups.push(grant.group);
|
|
717
|
+
}
|
|
631
718
|
}
|
|
632
|
-
|
|
633
|
-
}
|
|
719
|
+
applyRecord(actions, groups);
|
|
720
|
+
}
|
|
721
|
+
syncAll();
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
for (let elm of document.querySelectorAll('input[name^="mcpLevel_"]')) {
|
|
725
|
+
elm.addEventListener('change', syncAll);
|
|
634
726
|
}
|
|
635
727
|
|
|
636
728
|
for (let elm of document.querySelectorAll('.permission-axis, .scope-entry')) {
|
|
@@ -689,12 +781,12 @@
|
|
|
689
781
|
document.getElementById('showTokenError').classList.add('hidden');
|
|
690
782
|
uiModal.open('#showToken');
|
|
691
783
|
|
|
692
|
-
// Omitting the field is what "not narrowed" means on the record, so an unchecked toggle
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
784
|
+
// Omitting the field is what "not narrowed" means on the record, so an unchecked toggle
|
|
785
|
+
// must not post an empty object. That is a different answer, and the API refuses it. An
|
|
786
|
+
// MCP token minted by level always carries its pair list explicitly, so what the operator
|
|
787
|
+
// saw is exactly what the credential holds.
|
|
696
788
|
let record = effectiveRecord();
|
|
697
|
-
let permissions = record.unrestricted ? null : { actions: record.actions, groups: record.groups };
|
|
789
|
+
let permissions = record.unrestricted ? null : record.grants ? { grants: record.grants } : { actions: record.actions, groups: record.groups };
|
|
698
790
|
|
|
699
791
|
let refuse = message => {
|
|
700
792
|
document.getElementById('showTokenLoader').classList.add('hidden');
|
|
@@ -704,10 +796,11 @@
|
|
|
704
796
|
uiModal.open('#showToken');
|
|
705
797
|
};
|
|
706
798
|
|
|
707
|
-
// The
|
|
708
|
-
// record
|
|
709
|
-
//
|
|
710
|
-
|
|
799
|
+
// The section table failed to load, so the levels on screen cannot be resolved to the
|
|
800
|
+
// record they promise. Refused rather than posted, as the MCP config page's generator
|
|
801
|
+
// refuses: what would go out is a record that grants nothing, which the API refuses
|
|
802
|
+
// too, but with an answer that names the wrong cause.
|
|
803
|
+
if (mcpLevelMode() && !mcpCustomElm.checked && !Object.keys(mcpSections).length) {
|
|
711
804
|
refuse('The access levels failed to load, so the selected level cannot be applied. Reload the page and try again.');
|
|
712
805
|
return;
|
|
713
806
|
}
|
|
@@ -715,7 +808,11 @@
|
|
|
715
808
|
// Said here rather than left to the schema. tokenPermissionsSchema refuses an empty axis
|
|
716
809
|
// too, but a joi rejection reaches this page as a bare "HTTP error! status: 400", which
|
|
717
810
|
// tells the reader nothing about the box they left unticked.
|
|
718
|
-
if (permissions &&
|
|
811
|
+
if (permissions && permissions.grants && !permissions.grants.length) {
|
|
812
|
+
refuse('Select an access level for at least one MCP scope. A token that grants nothing cannot make any request.');
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (permissions && permissions.actions && (!permissions.actions.length || !permissions.groups.length)) {
|
|
719
816
|
let missing = !permissions.actions.length ? 'action' : 'section';
|
|
720
817
|
refuse(`Select at least one ${missing}. A restriction that allows nothing would create a token that cannot make any request.`);
|
|
721
818
|
return;
|
package/views/unsubscribe.hbs
CHANGED
|
@@ -37,7 +37,7 @@ focus ring on) the corner close button --}}
|
|
|
37
37
|
</div>
|
|
38
38
|
</dialog>
|
|
39
39
|
|
|
40
|
-
<script nonce="{{cspNonce}}">
|
|
40
|
+
<script data-cfasync="false" nonce="{{cspNonce}}">
|
|
41
41
|
document.addEventListener('DOMContentLoaded', () => {
|
|
42
42
|
|
|
43
43
|
document.getElementById('resubscribe-link').addEventListener('click', e => {
|
package/views/webhooks/edit.hbs
CHANGED
package/views/webhooks/index.hbs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{{#> ui/page-header title="Webhook Routes" icon="icon-[tabler--webhook]" subtitle="
|
|
1
|
+
{{#> ui/page-header title="Webhook Routes" icon="icon-[tabler--webhook]" subtitle="Filter email events, customize their payloads, and send them to your chosen URLs." badgeLabel=total badgeVariant="neutral" class="mb-6"}}
|
|
2
2
|
{{> ui/btn href=newLink label="Create webhook route" icon="icon-[tabler--plus]"}}
|
|
3
3
|
{{/ui/page-header}}
|
|
4
4
|
|
|
5
5
|
{{> ui/search-crumb parentHref="/admin/webhooks" parentLabel="Webhook Routes" query=query}}
|
|
6
6
|
|
|
7
7
|
{{#unless webhooksEnabled}}
|
|
8
|
-
<div class="alert alert-soft alert-warning mb-6"><span><strong>Note:</strong>
|
|
8
|
+
<div class="alert alert-soft alert-warning mb-6"><span><strong>Note:</strong> Webhooks are disabled
|
|
9
9
|
for EmailEngine.
|
|
10
10
|
<a href="/admin/config/webhooks" class="link link-animated">Enable webhooks in configuration
|
|
11
11
|
settings</a>.</span></div>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{{#if webhooks}}
|
|
15
15
|
<div class="card bg-base-100 shadow-md mb-6">
|
|
16
16
|
<div class="overflow-x-auto">
|
|
17
|
-
<table class="table">
|
|
17
|
+
<table class="table ee-table-stack">
|
|
18
18
|
<thead>
|
|
19
19
|
<tr>
|
|
20
20
|
<th>Name</th>
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
{{> ui/entity-id id=id label="Webhook Route ID"}}
|
|
35
35
|
</td>
|
|
36
36
|
|
|
37
|
-
<td class="relative">
|
|
37
|
+
<td class="relative" data-label="Description">
|
|
38
38
|
{{> ui/row-link href=(concat "/admin/webhooks/webhook/" id)}}{{description}}
|
|
39
39
|
</td>
|
|
40
40
|
|
|
41
|
-
<td class="relative">
|
|
41
|
+
<td class="relative" data-label="Triggered">
|
|
42
42
|
{{> ui/row-link href=(concat "/admin/webhooks/webhook/" id)}}{{tcount}}
|
|
43
43
|
</td>
|
|
44
44
|
|
|
45
|
-
<td class="relative">
|
|
45
|
+
<td class="relative" data-label="Status">
|
|
46
46
|
{{> ui/row-link href=(concat "/admin/webhooks/webhook/" id)}}
|
|
47
47
|
{{#if enabled}}
|
|
48
48
|
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
{{/if}}
|
|
57
57
|
</td>
|
|
58
58
|
|
|
59
|
-
<td class="relative text-end">
|
|
59
|
+
<td class="ee-stack-actions relative text-end">
|
|
60
60
|
{{> ui/row-actions openHref=(concat "/admin/webhooks/webhook/" id) label="Webhook route actions"
|
|
61
61
|
deleteModal="#deleteWebhook" deleteId=id deleteName=name}}
|
|
62
62
|
</td>
|
|
@@ -75,10 +75,9 @@
|
|
|
75
75
|
{{#> ui/details summary="How webhook routes work" class="card bg-base-100 shadow-md mb-6"}}
|
|
76
76
|
<div>
|
|
77
77
|
<p class="mb-2">
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
function</em> to modify the payload before sending.
|
|
78
|
+
Each enabled route evaluates events with its filter function. When the filter returns <code>true</code>,
|
|
79
|
+
EmailEngine sends the event to the route's target URL. Add a map function to change the payload format.
|
|
80
|
+
Routes run independently of the default webhook target and its event selection.
|
|
82
81
|
</p>
|
|
83
82
|
<p class="mb-0"><a href="https://learn.emailengine.app/docs/integrations/low-code" target="_blank"
|
|
84
83
|
rel="noopener noreferrer" referrerpolicy="no-referrer" class="link link-animated">Learn more about webhook
|