emailengine-app 2.80.1 → 2.81.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +39 -0
- package/Dockerfile +17 -9
- package/data/google-crawlers.json +1 -1
- package/docker-compose.yml +7 -1
- package/lib/api-routes/account-routes.js +158 -72
- package/lib/api-routes/permission-map.js +6 -1
- package/lib/autodetect-imap-settings.js +4 -4
- package/lib/sentry.js +13 -2
- package/lib/tls/provision.js +1 -1
- package/lib/token-permission-view.js +8 -7
- package/lib/tools.js +1 -0
- package/lib/ui-routes/account-routes.js +195 -61
- package/lib/ui-routes/admin-entities-routes.js +9 -9
- package/package.json +19 -19
- package/sbom.json +1 -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/licenses.html +54 -30
- 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 +142 -96
- 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 +6 -6
- package/views/account/security.hbs +2 -2
- package/views/accounts/account.hbs +17 -19
- package/views/accounts/edit.hbs +14 -14
- package/views/accounts/index.hbs +3 -3
- package/views/accounts/register/imap-server.hbs +26 -172
- package/views/accounts/register/validating.hbs +139 -0
- package/views/config/ai.hbs +14 -16
- package/views/config/branding.hbs +5 -5
- package/views/config/document-store/chat.hbs +8 -7
- package/views/config/document-store/index.hbs +13 -14
- 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 +6 -7
- package/views/config/license.hbs +8 -8
- package/views/config/logging.hbs +5 -7
- package/views/config/mcp.hbs +14 -18
- package/views/config/network.hbs +3 -3
- package/views/config/oauth/app.hbs +10 -10
- 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 +10 -9
- package/views/config/smtp.hbs +8 -11
- package/views/config/tls-upload.hbs +3 -3
- package/views/config/tls.hbs +33 -35
- package/views/config/webhooks.hbs +10 -13
- 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 +14 -12
- package/views/layout/login.hbs +27 -14
- package/views/layout/prompt.hbs +12 -15
- package/views/mcp/authorize.hbs +1 -1
- package/views/partials/accounts_table.hbs +5 -5
- package/views/partials/add_account_modal.hbs +3 -3
- package/views/partials/address_list.hbs +4 -4
- package/views/partials/gateway_form.hbs +5 -5
- package/views/partials/mcp_account_limit.hbs +2 -2
- package/views/partials/oauth_config_header.hbs +2 -2
- package/views/partials/oauth_form.hbs +36 -41
- package/views/partials/public_alerts.hbs +1 -1
- package/views/partials/public_test_labels.hbs +15 -0
- package/views/partials/security_header.hbs +2 -2
- package/views/partials/template_form.hbs +3 -3
- 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/reference/index.hbs +2 -2
- package/views/reference/token.hbs +3 -3
- 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 +4 -4
- package/views/tokens/index.hbs +17 -17
- package/views/tokens/new.hbs +18 -22
- 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 +4 -5
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
|
+
});
|