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/static/css/public.css
CHANGED
|
@@ -928,6 +928,47 @@ dialog.ee-modal.ee-modal-wide {
|
|
|
928
928
|
cursor: pointer;
|
|
929
929
|
}
|
|
930
930
|
|
|
931
|
+
/* ---------------------------------------------------------------------------
|
|
932
|
+
* Status panel (hosted auth form, the step that checks the discovered mail
|
|
933
|
+
* server settings before skipping the settings form)
|
|
934
|
+
* ------------------------------------------------------------------------- */
|
|
935
|
+
|
|
936
|
+
.ee-status {
|
|
937
|
+
text-align: center;
|
|
938
|
+
padding: 1.5rem 0 0.5rem;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/* the panel's own icon is a standalone graphic, not an icon beside text, so it
|
|
942
|
+
is sized in rem rather than inheriting the 1em of .ee-icon. Both classes are
|
|
943
|
+
named because .ee-icon sets that 1em further down the file and would otherwise
|
|
944
|
+
win on source order alone */
|
|
945
|
+
.ee-icon.ee-status-icon {
|
|
946
|
+
display: block;
|
|
947
|
+
width: 2.5rem;
|
|
948
|
+
height: 2.5rem;
|
|
949
|
+
margin: 0 auto 1rem;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.ee-status h1 {
|
|
953
|
+
margin-bottom: 0.5rem;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
.ee-status-servers {
|
|
957
|
+
/* two hostnames, which have no natural break opportunity on a narrow screen */
|
|
958
|
+
overflow-wrap: anywhere;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/* the error rows read as a list, so they keep the normal reading direction
|
|
962
|
+
inside the otherwise centered panel */
|
|
963
|
+
.ee-status-errors {
|
|
964
|
+
margin-top: 1.5rem;
|
|
965
|
+
text-align: start;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.ee-status .ee-form-actions {
|
|
969
|
+
justify-content: center;
|
|
970
|
+
}
|
|
971
|
+
|
|
931
972
|
/* ---------------------------------------------------------------------------
|
|
932
973
|
* Error page panel
|
|
933
974
|
* ------------------------------------------------------------------------- */
|
|
@@ -137,9 +137,17 @@
|
|
|
137
137
|
opacity: 0.75;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
/* Tooltip overrides. Un-layered on purpose: FlyonUI emits .tooltip-content
|
|
140
|
+
/* Tooltip overrides. Un-layered on purpose: FlyonUI emits .tooltip and .tooltip-content
|
|
141
141
|
* in @layer utilities, which beats any components-layer rule regardless of
|
|
142
142
|
* specificity. */
|
|
143
|
+
/* FlyonUI centers .tooltip, which is the bubble AND the trigger inside it. A one-line
|
|
144
|
+
* trigger never shows it; a multi-line bubble and a dashboard tile label that wraps
|
|
145
|
+
* ("Webhooks delivered" in a two-up phone grid) both read better left-aligned, the
|
|
146
|
+
* latter because it sits in a left-aligned card. ui/tooltip renders nothing but the
|
|
147
|
+
* toggle and the content, so one rule on the wrapper covers both. */
|
|
148
|
+
.tooltip {
|
|
149
|
+
text-align: start;
|
|
150
|
+
}
|
|
143
151
|
/* tooltips float above the sidebar (lg:z-40) and topbar; FlyonUI's default
|
|
144
152
|
* z-20 leaves bubbles clipped under the drawer. The width cap makes long
|
|
145
153
|
* tooltip texts wrap (FlyonUI's width:max-content otherwise renders them as
|
|
@@ -153,10 +161,8 @@
|
|
|
153
161
|
* box per wrapped line */
|
|
154
162
|
display: block;
|
|
155
163
|
text-wrap: balance;
|
|
156
|
-
/* FlyonUI centers via .tooltip; multi-line bubbles read better
|
|
157
|
-
* left-aligned (matches the public-page ee-tooltip) */
|
|
158
|
-
text-align: start;
|
|
159
164
|
}
|
|
165
|
+
|
|
160
166
|
/* empty-state gate for SSE state badges (ui/state-badge): while there is no
|
|
161
167
|
* error, the bubble must not render at all. Gated on the wrapper because
|
|
162
168
|
* HSTooltip's show() removes the hidden class from the content. */
|
|
@@ -164,6 +170,18 @@
|
|
|
164
170
|
display: none;
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
/* FlyonUI's .badge pins height to --size, so a badge whose label wraps keeps the
|
|
174
|
+
* one-line box and spills its second line over whatever follows - on the TLS page the
|
|
175
|
+
* three "used by" badges printed on top of each other. Grow instead: min-height keeps
|
|
176
|
+
* every single-line badge pixel-identical (one 20px line inside a 24px box), and a
|
|
177
|
+
* wrapped one gets the room it needs. Un-layered on purpose, like the rules around it:
|
|
178
|
+
* FlyonUI emits .badge from @layer utilities, which a layered rule of ours could not
|
|
179
|
+
* outrank whatever its specificity. */
|
|
180
|
+
.badge {
|
|
181
|
+
height: auto;
|
|
182
|
+
min-height: var(--size);
|
|
183
|
+
}
|
|
184
|
+
|
|
167
185
|
/* FlyonUI's .link keeps the surrounding text color (the only resting cue is
|
|
168
186
|
* a font-weight bump) and .link-animated hides the underline until hover, so
|
|
169
187
|
* links read as plain text. Color them with the brand primary so they are
|
|
@@ -175,6 +193,19 @@
|
|
|
175
193
|
--link-color: var(--color-primary);
|
|
176
194
|
}
|
|
177
195
|
|
|
196
|
+
/* FlyonUI lays a tab strip out as a nowrap flex row with no overflow handling, so one
|
|
197
|
+
* wider than its column pushes the whole page sideways instead of adapting: the Document
|
|
198
|
+
* Store's four section tabs are 437px against a 390px phone, and an API reference operation
|
|
199
|
+
* documents up to eight status codes. Wrapping rather than scrolling because these are
|
|
200
|
+
* navigation - a second row keeps every tab reachable, where a scroller hides some behind an
|
|
201
|
+
* interaction with no affordance for it. No strip in the app wraps at desktop width. Here
|
|
202
|
+
* rather than on each strip: ui/tabs and the three hand-rolled link navs (oauth_tabs,
|
|
203
|
+
* document_store_header, the auth-method strip in oauth_form) all need it. Un-layered on
|
|
204
|
+
* purpose, like the rules around it: FlyonUI emits .tabs from @layer utilities. */
|
|
205
|
+
.tabs {
|
|
206
|
+
flex-wrap: wrap;
|
|
207
|
+
}
|
|
208
|
+
|
|
178
209
|
/* Segmented (pill) tab strip, used through ui/tabs variant="segment" for a
|
|
179
210
|
* choice nested inside a page whose top already carries a bordered tab row -
|
|
180
211
|
* a second identical bordered row would read as the same navigation level.
|
|
@@ -775,3 +806,103 @@
|
|
|
775
806
|
white-space: normal;
|
|
776
807
|
}
|
|
777
808
|
}
|
|
809
|
+
|
|
810
|
+
/* Setting row: the control on the left, its setting reference (and usually a state badge)
|
|
811
|
+
* on the right. On a phone the two do not fit beside each other - ui/checkbox's root is
|
|
812
|
+
* w-full and a setting key does not wrap, so the label was squeezed into a column of single
|
|
813
|
+
* words - and the reference column has to span the line it wraps onto, or it lands
|
|
814
|
+
* shrink-to-fit at the start and its text-end does nothing. One utility rather than the same
|
|
815
|
+
* two variants written at every call site, the same reasoning as .ee-setting-row above. */
|
|
816
|
+
@utility ee-toggle-row {
|
|
817
|
+
@media (width < 40rem) {
|
|
818
|
+
flex-wrap: wrap;
|
|
819
|
+
|
|
820
|
+
& > *:last-child {
|
|
821
|
+
width: 100%;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/* A resource list that stops being a table on a phone. FlyonUI's .table only offers a
|
|
827
|
+
* horizontally scrolling container, so at 390px an accounts list shows the Name column and
|
|
828
|
+
* hides the connection status, and a half-cut second column reads as broken rather than as
|
|
829
|
+
* something to scroll. Below the md breakpoint each row becomes a stacked block: the column
|
|
830
|
+
* names move out of the head and into each cell through data-label, the first cell (no
|
|
831
|
+
* data-label) stays the row's heading, and a cell marked .ee-stack-actions floats its kebab
|
|
832
|
+
* over that heading. Same layer + :is() reasoning as ee-table-wrap above - the library's cell
|
|
833
|
+
* rules are utilities-layer :where(), so only a utility of our own can outrank them.
|
|
834
|
+
* A min-w-[...] that keeps the desktop columns readable has to carry an md: prefix: the
|
|
835
|
+
* stacked table is a block, so an unprefixed one applies to it and forces a scroller anyway,
|
|
836
|
+
* and nothing here can override it (same layer, and the utility is emitted later). */
|
|
837
|
+
@utility ee-table-stack {
|
|
838
|
+
@media (width < 48rem) {
|
|
839
|
+
display: block;
|
|
840
|
+
|
|
841
|
+
& thead {
|
|
842
|
+
display: none;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
& tbody {
|
|
846
|
+
display: block;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/* the row separator is .table's own and keeps applying to a display:block row */
|
|
850
|
+
& tbody tr {
|
|
851
|
+
display: block;
|
|
852
|
+
position: relative;
|
|
853
|
+
padding: 0.75rem 1rem;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/* room for the floated kebab, only in the rows that carry one */
|
|
857
|
+
& tbody tr:has(.ee-stack-actions) {
|
|
858
|
+
padding-inline-end: 3rem;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
& :is(td, tbody th) {
|
|
862
|
+
/* flow-root, not block: the label below is a float, and a plain block box would
|
|
863
|
+
* let it escape an empty cell and sit beside the next cell's content */
|
|
864
|
+
display: flow-root;
|
|
865
|
+
width: auto;
|
|
866
|
+
padding: 0.125rem 0;
|
|
867
|
+
white-space: normal;
|
|
868
|
+
overflow-wrap: anywhere;
|
|
869
|
+
/* a right-aligned numeric column reads as stray text once the head is gone */
|
|
870
|
+
text-align: start;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/* The label floats rather than taking a flex or grid slot: a cell is free to hold
|
|
874
|
+
* several blocks (the tokens list puts a scope list, a badge and a sentence in one),
|
|
875
|
+
* and as flex items those share the row's width and each collapse into a column of
|
|
876
|
+
* single letters. Floated, the first line runs on after the label and anything
|
|
877
|
+
* taller simply continues underneath it. */
|
|
878
|
+
& :is(td, tbody th)[data-label]::before {
|
|
879
|
+
content: attr(data-label);
|
|
880
|
+
float: inline-start;
|
|
881
|
+
margin-inline-end: 0.75rem;
|
|
882
|
+
color: color-mix(in oklab, var(--color-base-content) 60%, transparent);
|
|
883
|
+
font-size: 0.6875rem;
|
|
884
|
+
font-weight: 600;
|
|
885
|
+
letter-spacing: 0.04em;
|
|
886
|
+
text-transform: uppercase;
|
|
887
|
+
line-height: 1.25rem;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/* :not(.hidden) so the re-assertion below still wins for a hidden actions cell -
|
|
891
|
+
* this selector is one class heavier than it is */
|
|
892
|
+
& td.ee-stack-actions:not(.hidden) {
|
|
893
|
+
position: absolute;
|
|
894
|
+
top: 0.5rem;
|
|
895
|
+
inset-inline-end: 0.5rem;
|
|
896
|
+
padding: 0;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/* Re-assert display:none. The rules above name an element as well as this class,
|
|
900
|
+
* so they outrank a bare .hidden and would reveal a row the page keeps collapsed -
|
|
901
|
+
* the TLS hostname list carries one hidden row per name for the "why the last order
|
|
902
|
+
* failed" line, and it appeared as an empty info alert. */
|
|
903
|
+
& .hidden,
|
|
904
|
+
& [hidden] {
|
|
905
|
+
display: none;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
package/static/js/public.js
CHANGED
|
@@ -223,3 +223,221 @@ window.addEventListener('pageshow', e => {
|
|
|
223
223
|
}
|
|
224
224
|
eeSubmittedForms.clear();
|
|
225
225
|
});
|
|
226
|
+
|
|
227
|
+
/*
|
|
228
|
+
* The connection test the two hosted-form steps share: the server settings page
|
|
229
|
+
* (which runs it from a button and reports into a dialog) and the checking page
|
|
230
|
+
* (which runs it on load and reports inline). Everything from building the
|
|
231
|
+
* request to laying out the failure rows is the same on both; only what happens
|
|
232
|
+
* next differs, so that is all each page keeps.
|
|
233
|
+
*
|
|
234
|
+
* The text these render comes back from a mail server, so the rows are built out
|
|
235
|
+
* of DOM nodes rather than markup.
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
// Append text to an element, turning bare URLs into links. Text nodes and
|
|
239
|
+
// anchors are created through DOM APIs, so server-provided text is never parsed
|
|
240
|
+
// as HTML - this is what keeps a mail server's response text out of innerHTML.
|
|
241
|
+
window.eeAppendLinkified = (parentElm, text) => {
|
|
242
|
+
let parts = String(text === null || text === undefined ? '' : text).split(/(https?:\/\/[^\s]+)/g);
|
|
243
|
+
for (let part of parts) {
|
|
244
|
+
if (/^https?:\/\//.test(part)) {
|
|
245
|
+
let a = document.createElement('a');
|
|
246
|
+
a.href = part;
|
|
247
|
+
a.target = '_blank';
|
|
248
|
+
a.rel = 'noopener noreferrer';
|
|
249
|
+
a.textContent = part;
|
|
250
|
+
parentElm.appendChild(a);
|
|
251
|
+
} else if (part) {
|
|
252
|
+
parentElm.appendChild(document.createTextNode(part));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// Append one labelled error row (<dt> term, <dd> message) to a <dl class="ee-dl">,
|
|
258
|
+
// optionally followed by a smaller secondary line such as the raw server response.
|
|
259
|
+
window.eeAppendErrorRow = (listElm, type, text, extraLabel, extraText) => {
|
|
260
|
+
let keyElm = document.createElement('dt');
|
|
261
|
+
let valueContainerElm = document.createElement('dd');
|
|
262
|
+
let valueElm = document.createElement('div');
|
|
263
|
+
|
|
264
|
+
valueElm.classList.add('ee-error-text');
|
|
265
|
+
|
|
266
|
+
keyElm.textContent = type;
|
|
267
|
+
valueElm.textContent = text;
|
|
268
|
+
|
|
269
|
+
valueContainerElm.append(valueElm);
|
|
270
|
+
|
|
271
|
+
listElm.appendChild(keyElm);
|
|
272
|
+
listElm.appendChild(valueContainerElm);
|
|
273
|
+
|
|
274
|
+
if (extraLabel && extraText) {
|
|
275
|
+
let extraLabelElm = document.createElement('div');
|
|
276
|
+
extraLabelElm.textContent = extraLabel;
|
|
277
|
+
|
|
278
|
+
let extraTextElm = document.createElement('small');
|
|
279
|
+
window.eeAppendLinkified(extraTextElm, extraText);
|
|
280
|
+
|
|
281
|
+
valueContainerElm.appendChild(extraLabelElm);
|
|
282
|
+
valueContainerElm.appendChild(extraTextElm);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// Run the hosted form's connection test for the values currently in `form`.
|
|
287
|
+
// Resolves with the parsed body for both a passing and a failing test - the
|
|
288
|
+
// endpoint reports a refused login as a 200 carrying { imap, smtp } - and with
|
|
289
|
+
// the error body for a 4xx/5xx, so a caller has one shape to render either way.
|
|
290
|
+
// `opts.timeoutMs` gives up when the request itself never comes back, which the
|
|
291
|
+
// server-side connection budget cannot cover.
|
|
292
|
+
window.eePostConnectionTest = async (form, opts) => {
|
|
293
|
+
opts = opts || {};
|
|
294
|
+
|
|
295
|
+
let body = {};
|
|
296
|
+
for (let [key, value] of new FormData(form).entries()) {
|
|
297
|
+
body[key] = value;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let signal;
|
|
301
|
+
if (opts.timeoutMs && typeof AbortSignal !== 'undefined' && AbortSignal.timeout) {
|
|
302
|
+
signal = AbortSignal.timeout(opts.timeoutMs);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const res = await fetch('/accounts/new/imap/test', {
|
|
306
|
+
method: 'post',
|
|
307
|
+
headers: { 'content-type': 'application/json' },
|
|
308
|
+
body: JSON.stringify(body),
|
|
309
|
+
signal
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
if (!res.ok) {
|
|
313
|
+
try {
|
|
314
|
+
return await res.json();
|
|
315
|
+
} catch (err) {
|
|
316
|
+
console.error(err);
|
|
317
|
+
}
|
|
318
|
+
throw new Error(`${opts.requestFailedText || 'Request failed.'} status: ${res.status}`);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return await res.json();
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// Lay out what a connection test reported into a <dl class="ee-dl">. Three shapes
|
|
325
|
+
// come back from the endpoint: a Hapi/Boom error body (403, 429), a payload
|
|
326
|
+
// validation failure carrying `fields`, and the per-protocol result of a test that
|
|
327
|
+
// actually ran. `labels` carries the translated strings, which is the only reason
|
|
328
|
+
// the caller has to supply anything.
|
|
329
|
+
window.eeRenderTestErrors = (listElm, data, labels) => {
|
|
330
|
+
data = data || {};
|
|
331
|
+
labels = labels || {};
|
|
332
|
+
|
|
333
|
+
listElm.innerHTML = '';
|
|
334
|
+
|
|
335
|
+
if (data.error && !data.fields) {
|
|
336
|
+
// A Boom body carries the human-readable text in data.message and only the status name in
|
|
337
|
+
// data.error ('Forbidden', 'Too Many Requests'); a caller's own catch path passes
|
|
338
|
+
// { error: Error } instead, hence the fallbacks.
|
|
339
|
+
window.eeAppendErrorRow(listElm, labels.error, data.message || data.error.message || data.error);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (data.fields) {
|
|
344
|
+
window.eeAppendErrorRow(listElm, labels.invalidSettings, data.message);
|
|
345
|
+
for (let field of data.fields) {
|
|
346
|
+
window.eeAppendErrorRow(listElm, '-', field.message);
|
|
347
|
+
}
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
for (let [key, protocol, fallback] of [
|
|
352
|
+
['imap', 'IMAP', labels.imapFailed],
|
|
353
|
+
['smtp', 'SMTP', labels.smtpFailed]
|
|
354
|
+
]) {
|
|
355
|
+
let result = data[key];
|
|
356
|
+
if (result && result.success) {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
let error = (result && result.error) || fallback;
|
|
360
|
+
if (result && result.responseText) {
|
|
361
|
+
window.eeAppendErrorRow(listElm, protocol, error, labels.serverResponse, result.responseText);
|
|
362
|
+
} else {
|
|
363
|
+
window.eeAppendErrorRow(listElm, protocol, error);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// A one-shot submit for a form the page submits itself. form.submit() fires no
|
|
369
|
+
// submit event, so the document-level latch above never sees it - and both hosted
|
|
370
|
+
// form steps that use it POST to an endpoint claiming a single-use nonce, where a
|
|
371
|
+
// second submission is answered with an error for a step that succeeded.
|
|
372
|
+
//
|
|
373
|
+
// Returns the submit function. `opts.button` gets the busy treatment for the
|
|
374
|
+
// duration, `opts.validate` runs the constraint validation that submit() skips,
|
|
375
|
+
// and `opts.recoveryMs` re-arms the latch when the navigation never happened at
|
|
376
|
+
// all - the visitor cancelled it (Esc / Stop) while the page stayed alive, which
|
|
377
|
+
// fires no DOM event, so without it the form would be left unsubmittable. Re-arming
|
|
378
|
+
// is safe: the single-use nonce is the real double-submit guard, so at worst a
|
|
379
|
+
// later duplicate POST is refused by the server.
|
|
380
|
+
window.eeSubmitOnce = (form, opts) => {
|
|
381
|
+
opts = opts || {};
|
|
382
|
+
|
|
383
|
+
let submitting = false;
|
|
384
|
+
let recoveryTimer = null;
|
|
385
|
+
|
|
386
|
+
let reset = () => {
|
|
387
|
+
submitting = false;
|
|
388
|
+
if (recoveryTimer) {
|
|
389
|
+
clearTimeout(recoveryTimer);
|
|
390
|
+
recoveryTimer = null;
|
|
391
|
+
}
|
|
392
|
+
if (opts.button) {
|
|
393
|
+
window.eeButtonBusy(opts.button, false);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// Back to a submitted form through the bfcache: JS state survives, so without this
|
|
398
|
+
// the latch stays set and the buttons stay disabled, deadening the form for good.
|
|
399
|
+
window.addEventListener('pageshow', e => {
|
|
400
|
+
if (e.persisted) {
|
|
401
|
+
reset();
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
return () => {
|
|
406
|
+
if (submitting) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
// Bail without latching so the visitor can still fix the field
|
|
410
|
+
if (opts.validate && !form.reportValidity()) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
submitting = true;
|
|
414
|
+
if (opts.button) {
|
|
415
|
+
window.eeButtonBusy(opts.button, true);
|
|
416
|
+
}
|
|
417
|
+
if (opts.recoveryMs) {
|
|
418
|
+
recoveryTimer = setTimeout(reset, opts.recoveryMs);
|
|
419
|
+
}
|
|
420
|
+
form.submit();
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// Fill any input carrying data-ee-tz with the visitor's IANA time zone, so a page
|
|
425
|
+
// that wants one only has to mark the field.
|
|
426
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
427
|
+
let fields = document.querySelectorAll('input[data-ee-tz]');
|
|
428
|
+
if (!fields.length) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
if (typeof Intl !== 'undefined' && Intl && typeof Intl.DateTimeFormat === 'function') {
|
|
433
|
+
let tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
434
|
+
if (tz) {
|
|
435
|
+
for (let field of fields) {
|
|
436
|
+
field.value = tz;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
} catch (err) {
|
|
441
|
+
// Intl probably not supported
|
|
442
|
+
}
|
|
443
|
+
});
|
package/static/js/ui.js
CHANGED
|
@@ -840,22 +840,43 @@ window.uiCodeExamples = config => {
|
|
|
840
840
|
|
|
841
841
|
// The MCP tool count: how many of the endpoint's tools a credential would actually be offered.
|
|
842
842
|
//
|
|
843
|
-
// Shared by the three places an
|
|
844
|
-
//
|
|
845
|
-
//
|
|
846
|
-
//
|
|
843
|
+
// Shared by the three places an MCP token is minted - the access-token form, the MCP config page's
|
|
844
|
+
// generator and the OAuth consent prompt - because all three ask the same question, and the count
|
|
845
|
+
// is the one thing a permission record does not tell a reader: a record that looks generous can
|
|
846
|
+
// still leave an agent holding one tool.
|
|
847
847
|
//
|
|
848
|
-
//
|
|
849
|
-
//
|
|
850
|
-
//
|
|
851
|
-
//
|
|
848
|
+
// Three filters, the same three lib/mcp/tools.js toolVisibleTo() applies to tools/list: the scopes
|
|
849
|
+
// (a tool is offered only through a surface scope whose table covers it), the permission record,
|
|
850
|
+
// and the account binding - a credential bound to one account is never offered the tools that take
|
|
851
|
+
// no account argument, because there is nothing to bind them to. This is the browser's copy of
|
|
852
|
+
// that rule, and test/mcp-tools-test.js asserts the two agree over the whole catalog.
|
|
852
853
|
//
|
|
853
|
-
// `record` is {
|
|
854
|
-
//
|
|
855
|
-
//
|
|
856
|
-
// is
|
|
854
|
+
// `record` is { surfaces, grants | actions + groups, unrestricted, account }. `surfaces` lists the
|
|
855
|
+
// MCP scopes the token holds (absent: no scope bound). `grants` is a list of {action, group} pairs,
|
|
856
|
+
// the pair-list form; `actions` and `groups` are the two-axis form. `unrestricted` is the absence
|
|
857
|
+
// of a permissions record, which is a different answer from an empty one: the scopes are the only
|
|
858
|
+
// bound. A null record clears the element - the question does not apply to this credential at
|
|
859
|
+
// all, which is not the same as it having no tools.
|
|
860
|
+
|
|
861
|
+
// Whether a record allows one (action, group) pair, in whichever form it is written. The one
|
|
862
|
+
// reading of the record shape in the browser: the count and the token form's scope warning both
|
|
863
|
+
// ask this.
|
|
864
|
+
window.uiMcpRecordAllows = (record, action, group) => {
|
|
865
|
+
if (record.unrestricted) {
|
|
866
|
+
return true;
|
|
867
|
+
}
|
|
868
|
+
if (record.grants) {
|
|
869
|
+
return record.grants.some(grant => grant.action === action && grant.group === group);
|
|
870
|
+
}
|
|
871
|
+
return record.actions.includes(action) && record.groups.includes(group);
|
|
872
|
+
};
|
|
873
|
+
|
|
857
874
|
window.uiMcpToolCount = (elm, record) => {
|
|
858
|
-
|
|
875
|
+
// Parsed once per element: the account field repaints this per keystroke
|
|
876
|
+
if (!elm.mcpTools) {
|
|
877
|
+
elm.mcpTools = JSON.parse(elm.dataset.mcpTools || '[]');
|
|
878
|
+
}
|
|
879
|
+
let tools = elm.mcpTools;
|
|
859
880
|
|
|
860
881
|
elm.replaceChildren();
|
|
861
882
|
if (!tools.length || !record) {
|
|
@@ -863,8 +884,9 @@ window.uiMcpToolCount = (elm, record) => {
|
|
|
863
884
|
}
|
|
864
885
|
|
|
865
886
|
let bound = !!(record.account || '').trim();
|
|
866
|
-
let
|
|
867
|
-
let
|
|
887
|
+
let reachable = record.surfaces ? tools.filter(tool => (tool.surfaces || []).some(scope => record.surfaces.includes(scope))) : tools;
|
|
888
|
+
let offered = bound ? reachable.filter(tool => tool.accountScoped) : reachable;
|
|
889
|
+
let available = offered.filter(tool => window.uiMcpRecordAllows(record, tool.action, tool.group));
|
|
868
890
|
|
|
869
891
|
let count = document.createElement('div');
|
|
870
892
|
let countLabel = document.createElement('strong');
|
|
@@ -879,7 +901,7 @@ window.uiMcpToolCount = (elm, record) => {
|
|
|
879
901
|
|
|
880
902
|
// Said out loud rather than left as a smaller total: the tools a binding takes away are the
|
|
881
903
|
// ones an agent would otherwise use to discover what it is connected to.
|
|
882
|
-
let instanceWide =
|
|
904
|
+
let instanceWide = reachable.filter(tool => !tool.accountScoped);
|
|
883
905
|
if (bound && instanceWide.length) {
|
|
884
906
|
let note = document.createElement('div');
|
|
885
907
|
note.className = 'text-base-content/60';
|
|
@@ -888,32 +910,63 @@ window.uiMcpToolCount = (elm, record) => {
|
|
|
888
910
|
}
|
|
889
911
|
};
|
|
890
912
|
|
|
891
|
-
//
|
|
892
|
-
//
|
|
893
|
-
//
|
|
913
|
+
// The level a page has selected per section, read off the radio groups. Every page renders one
|
|
914
|
+
// radio group per section, named `<prefix><section key>` by the mcp_access_levels partial; a
|
|
915
|
+
// section with no radio checked (the token form leaves a section out entirely while its scope is
|
|
916
|
+
// unticked) is declined.
|
|
917
|
+
window.uiMcpLevelChoice = (sections, prefix) => {
|
|
918
|
+
let choice = {};
|
|
919
|
+
for (let key of Object.keys(sections)) {
|
|
920
|
+
let radio = document.querySelector('input[name="' + (prefix || '') + key + '"]:checked');
|
|
921
|
+
choice[key] = radio ? radio.value : 'none';
|
|
922
|
+
}
|
|
923
|
+
return choice;
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
// The record a choice of section levels mints, as the count reads it and as the mint posts it:
|
|
927
|
+
// the scopes of the sections that were not declined and the union of their pairs. The browser's
|
|
928
|
+
// copy of mcpGrantsFor() in lib/token-permission-view.js, over the same table.
|
|
929
|
+
window.uiMcpLevelRecord = (sections, choice) => {
|
|
930
|
+
let surfaces = [];
|
|
931
|
+
let grants = [];
|
|
932
|
+
for (let key of Object.keys(sections)) {
|
|
933
|
+
let level = sections[key].levels.find(entry => entry.value === choice[key]);
|
|
934
|
+
if (!level) {
|
|
935
|
+
// Declined, or a level the table does not know - which counts as nothing rather than
|
|
936
|
+
// as everything, the same direction every other reader of this table fails in
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
surfaces.push(sections[key].scope);
|
|
940
|
+
for (let pair of level.pairs) {
|
|
941
|
+
if (!grants.some(grant => grant.action === pair.action && grant.group === pair.group)) {
|
|
942
|
+
grants.push({ action: pair.action, group: pair.group });
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
return { surfaces, grants, unrestricted: false };
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// Auto-wiring for the pages whose whole answer is a level per section (the MCP config generator
|
|
950
|
+
// and the consent prompt): the count element carries the section table and the radio name prefix,
|
|
951
|
+
// and repaints whenever a level or the account binding changes. The access-token form drives its
|
|
952
|
+
// own count instead, because its custom option is a hand-built record rather than a level.
|
|
894
953
|
document.addEventListener('DOMContentLoaded', () => {
|
|
895
|
-
for (let elm of document.querySelectorAll('[data-mcp-
|
|
896
|
-
let
|
|
954
|
+
for (let elm of document.querySelectorAll('[data-mcp-auto-wire]')) {
|
|
955
|
+
let sections = JSON.parse(elm.dataset.mcpSections || '{}');
|
|
956
|
+
let prefix = elm.dataset.mcpLevelPrefix || '';
|
|
897
957
|
let accountElm = elm.dataset.mcpAccountId ? document.getElementById(elm.dataset.mcpAccountId) : null;
|
|
898
|
-
let radios = Array.from(document.querySelectorAll('input[name="' + elm.dataset.mcpLevelName + '"]'));
|
|
899
958
|
|
|
900
959
|
let paint = () => {
|
|
901
|
-
let
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
window.uiMcpToolCount(elm, {
|
|
906
|
-
actions: preset ? preset.actions : [],
|
|
907
|
-
groups: preset ? preset.groups : [],
|
|
908
|
-
// A level the table stores as null is the unrestricted one. A level missing from
|
|
909
|
-
// the table entirely is not, and counts as nothing rather than as everything -
|
|
910
|
-
// the same direction every other reader of this table fails in.
|
|
911
|
-
unrestricted: !preset && Object.prototype.hasOwnProperty.call(presets, level),
|
|
912
|
-
account: accountElm ? accountElm.value : ''
|
|
913
|
-
});
|
|
960
|
+
let record = window.uiMcpLevelRecord(sections, window.uiMcpLevelChoice(sections, prefix));
|
|
961
|
+
record.account = accountElm ? accountElm.value : '';
|
|
962
|
+
window.uiMcpToolCount(elm, record);
|
|
914
963
|
};
|
|
915
964
|
|
|
916
|
-
|
|
965
|
+
for (let key of Object.keys(sections)) {
|
|
966
|
+
for (let radio of document.querySelectorAll('input[name="' + prefix + key + '"]')) {
|
|
967
|
+
radio.addEventListener('change', paint);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
917
970
|
if (accountElm) {
|
|
918
971
|
// Per keystroke, so what the binding costs is visible while the field is being filled
|
|
919
972
|
// in rather than only after it loses focus
|