@ofidj/generator-fidj 1.4.0 → 1.4.2
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.
|
@@ -274,6 +274,24 @@ function startModule() {
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
function render() {
|
|
277
|
+
// Leaving the provider's screen is a hash change, and a hash change does not
|
|
278
|
+
// reload the document: without this the shell kept its interaction state and
|
|
279
|
+
// drew that screen again over an address that no longer named one — the
|
|
280
|
+
// person asked to leave and stayed put.
|
|
281
|
+
if (interactionId && !addressedInteraction()) {
|
|
282
|
+
interactionId = "";
|
|
283
|
+
interactionError = "";
|
|
284
|
+
interaction = null;
|
|
285
|
+
interactionFailed = false;
|
|
286
|
+
}
|
|
287
|
+
// Once the mounted app owns the document the shell cannot draw over it, and
|
|
288
|
+
// its own router will try to match addresses that were never its business.
|
|
289
|
+
// So any address it does not own means starting the document again — checked
|
|
290
|
+
// first, because every later branch writes into an element that is gone.
|
|
291
|
+
if (moduleStarted && !moduleRoute()) {
|
|
292
|
+
window.location.reload();
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
277
295
|
// The provider handed this person here to answer a question. Nothing else
|
|
278
296
|
// this app might want to show belongs on the screen until they have.
|
|
279
297
|
if (interactionId) {
|
|
@@ -299,11 +317,6 @@ function render() {
|
|
|
299
317
|
startModule();
|
|
300
318
|
return;
|
|
301
319
|
}
|
|
302
|
-
// The mounted app has taken the document; the shell cannot draw over it.
|
|
303
|
-
if (moduleStarted) {
|
|
304
|
-
window.location.reload();
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
320
|
let route = currentRoute();
|
|
308
321
|
if (
|
|
309
322
|
!signedIn &&
|
|
@@ -575,6 +588,11 @@ const refusals: Record<string, string> = {
|
|
|
575
588
|
refused: "That could not be completed. Please try again.",
|
|
576
589
|
};
|
|
577
590
|
|
|
591
|
+
function addressedInteraction() {
|
|
592
|
+
const query = window.location.hash.slice(2).split("?")[1] || "";
|
|
593
|
+
return new URLSearchParams(query).get("interaction") || "";
|
|
594
|
+
}
|
|
595
|
+
|
|
578
596
|
function readInteraction() {
|
|
579
597
|
const query = window.location.hash.slice(2).split("?")[1] || "";
|
|
580
598
|
const parameters = new URLSearchParams(query);
|
|
@@ -582,9 +600,11 @@ function readInteraction() {
|
|
|
582
600
|
if (!uid) return false;
|
|
583
601
|
interactionId = uid;
|
|
584
602
|
interactionError = parameters.get("error") || "";
|
|
585
|
-
// The
|
|
586
|
-
//
|
|
587
|
-
|
|
603
|
+
// The id stays in the address while the screen is up. Taking it out looked
|
|
604
|
+
// tidier and made the screen a trap: the address became "#/signin", so going
|
|
605
|
+
// back to "#/signin" changed nothing, the document never reloaded, and the
|
|
606
|
+
// person stayed on a screen they had asked to leave. It is single-use, it is
|
|
607
|
+
// where the provider put it, and the form navigates away from it.
|
|
588
608
|
return true;
|
|
589
609
|
}
|
|
590
610
|
|
|
@@ -609,6 +629,13 @@ function interactionScreen() {
|
|
|
609
629
|
? `<p role="alert" class="error">${escape(refusals[interactionError] || refusals.refused)}</p>`
|
|
610
630
|
: "";
|
|
611
631
|
const action = new URL(details.action, config.apiEndpoint).href;
|
|
632
|
+
// A refusal comes back as a redirect, so the typed address would be lost —
|
|
633
|
+
// and retyping an address is the part a person gets wrong twice. It is kept
|
|
634
|
+
// in this browser, never in the address: nothing about them travels in a URL.
|
|
635
|
+
let typed = "";
|
|
636
|
+
try {
|
|
637
|
+
typed = sessionStorage.getItem("fidj.interaction.email") || "";
|
|
638
|
+
} catch {}
|
|
612
639
|
const body =
|
|
613
640
|
details.prompt === "login"
|
|
614
641
|
? `<h2>Sign in to continue to ${asking}</h2>
|
|
@@ -616,7 +643,7 @@ function interactionScreen() {
|
|
|
616
643
|
${notice}
|
|
617
644
|
<form method="post" action="${escape(action)}" id="interaction">
|
|
618
645
|
<input type="hidden" name="csrf" value="${escape(details.csrf)}">
|
|
619
|
-
<label for="email">Email</label><input id="email" name="email" type="email" autocomplete="username" required>
|
|
646
|
+
<label for="email">Email</label><input id="email" name="email" type="email" value="${escape(typed)}" autocomplete="username" required>
|
|
620
647
|
<div class="field-head"><label for="password">Password</label><a href="${escape(config.dashboardUrl)}/#/forgot">Forgot?</a></div>
|
|
621
648
|
<div class="password-field"><input id="password" name="password" type="password" autocomplete="current-password" required><button type="button" id="reveal" aria-controls="password">Show</button></div>
|
|
622
649
|
<button class="primary" type="submit" name="action" value="continue">Sign in</button>
|
|
@@ -653,6 +680,13 @@ function interactionScreen() {
|
|
|
653
680
|
field.type = hidden ? "text" : "password";
|
|
654
681
|
button.textContent = hidden ? "Hide" : "Show";
|
|
655
682
|
});
|
|
683
|
+
element("interaction")?.addEventListener("submit", () => {
|
|
684
|
+
const address = element<HTMLInputElement>("email")?.value || "";
|
|
685
|
+
try {
|
|
686
|
+
if (address) sessionStorage.setItem("fidj.interaction.email", address);
|
|
687
|
+
else sessionStorage.removeItem("fidj.interaction.email");
|
|
688
|
+
} catch {}
|
|
689
|
+
});
|
|
656
690
|
}
|
|
657
691
|
|
|
658
692
|
function renderAccount(route: string) {
|
|
@@ -741,6 +775,9 @@ void action(async () => {
|
|
|
741
775
|
const callback = new URL(window.location.href);
|
|
742
776
|
window.history.replaceState(null, "", window.location.pathname + "#/content");
|
|
743
777
|
await oidc.completeLogin(callback);
|
|
778
|
+
try {
|
|
779
|
+
sessionStorage.removeItem("fidj.interaction.email");
|
|
780
|
+
} catch {}
|
|
744
781
|
}
|
|
745
782
|
await sdk.init(config.appId, {
|
|
746
783
|
apiEndpoint: config.apiEndpoint,
|