@ofidj/generator-fidj 3.22.0 → 3.24.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.
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"privacy:rehearse": "npm run build && node --test test/server.test.mjs"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ofidj/entry": "^3.
|
|
19
|
-
"@ofidj/node": "^3.
|
|
18
|
+
"@ofidj/entry": "^3.24.0",
|
|
19
|
+
"@ofidj/node": "^3.24.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^22.0.0",
|
|
@@ -589,15 +589,16 @@ function render() {
|
|
|
589
589
|
interactionScreen();
|
|
590
590
|
return;
|
|
591
591
|
}
|
|
592
|
-
//
|
|
593
|
-
// shell
|
|
594
|
-
//
|
|
595
|
-
// handed over as it stands — before the shell asks the API who this is, not
|
|
596
|
-
// after. Waiting cost several seconds of "Loading your session…" on an address
|
|
597
|
-
// the shell was never going to draw: a token refresh and three round trips ran
|
|
598
|
-
// to completion before a quarter of a megabyte of application even began
|
|
599
|
-
// downloading. Nothing in that answer decides anything here.
|
|
592
|
+
// Public app routes can mount immediately. Private routes wait only while
|
|
593
|
+
// the shell checks whether Fidj already recognises this browser; after that
|
|
594
|
+
// the mounted app revalidates its own session and owns its routing.
|
|
600
595
|
if (moduleRoute()) {
|
|
596
|
+
// A private app must wait while Fidj recognises an existing browser session.
|
|
597
|
+
// Otherwise its router can redirect to sign-in and abort the OAuth navigation.
|
|
598
|
+
if (recognising) {
|
|
599
|
+
root.innerHTML = '<p role="status">Loading your session…</p>';
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
601
602
|
startModule();
|
|
602
603
|
return;
|
|
603
604
|
}
|
|
@@ -1325,7 +1326,11 @@ if (relayProviderAnswer()) {
|
|
|
1325
1326
|
function boot() {
|
|
1326
1327
|
window.addEventListener("hashchange", render);
|
|
1327
1328
|
recognising = mightBeRecognised();
|
|
1328
|
-
|
|
1329
|
+
// OAuth redirects inherit the old fragment when the provider omits one.
|
|
1330
|
+
// Settle the callback before mounting the app that owns that fragment.
|
|
1331
|
+
if (oidc && new URL(window.location.href).searchParams.has("state"))
|
|
1332
|
+
root.innerHTML = '<p role="status">Completing your sign-in…</p>';
|
|
1333
|
+
else render();
|
|
1329
1334
|
if (readInteraction()) {
|
|
1330
1335
|
render();
|
|
1331
1336
|
void loadInteraction()
|
|
@@ -1340,49 +1345,59 @@ function boot() {
|
|
|
1340
1345
|
.finally(render);
|
|
1341
1346
|
}
|
|
1342
1347
|
void action(async () => {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1348
|
+
try {
|
|
1349
|
+
if (interactionId) return;
|
|
1350
|
+
if (oidc && new URL(window.location.href).searchParams.has("state")) {
|
|
1351
|
+
const callback = new URL(window.location.href);
|
|
1352
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
1353
|
+
try {
|
|
1354
|
+
await oidc.completeLogin(callback);
|
|
1355
|
+
} catch (refusal) {
|
|
1356
|
+
const why = (refusal as {code?: string; silentRefusal?: boolean}) || {};
|
|
1357
|
+
// A silent question answered "no" is an answer, not a failure. But the
|
|
1358
|
+
// two ways of saying no mean opposite things here.
|
|
1359
|
+
//
|
|
1360
|
+
// `login_required` — the provider does not know this browser, and the
|
|
1361
|
+
// entry is the right next screen.
|
|
1362
|
+
//
|
|
1363
|
+
// `consent_required` — it knows exactly who this is; what it has not got
|
|
1364
|
+
// is this client's permission, because the account was made through
|
|
1365
|
+
// another app and Fidj's console is a client of its own. Asking again
|
|
1366
|
+
// without `prompt=none` gets the screen that collects it, and no
|
|
1367
|
+
// password: the person already typed theirs once.
|
|
1368
|
+
if (why.code === "consent_required") {
|
|
1369
|
+
window.location.assign(await oidc.beginLogin());
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
if (!why.silentRefusal) throw refusal;
|
|
1365
1373
|
}
|
|
1366
|
-
|
|
1374
|
+
// Restore the app route only after the callback settles. Restoring it
|
|
1375
|
+
// before a consent redirect lets the app mount and replace that redirect
|
|
1376
|
+
// with its own entry while the provider navigation is still pending.
|
|
1377
|
+
window.history.replaceState(null, "", window.location.pathname + "#/" + takeReturnRoute());
|
|
1378
|
+
try {
|
|
1379
|
+
sessionStorage.removeItem("fidj.interaction.email");
|
|
1380
|
+
} catch {}
|
|
1367
1381
|
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
return;
|
|
1382
|
+
await sdk.init(config.appId, {
|
|
1383
|
+
apiEndpoint: config.apiEndpoint,
|
|
1384
|
+
prod: !config.localDemo,
|
|
1385
|
+
});
|
|
1386
|
+
recognising = recognising && !sdk.isLoggedIn();
|
|
1387
|
+
if (!recognising && moduleRoute()) render();
|
|
1388
|
+
if (sdk.isLoggedIn()) {
|
|
1389
|
+
await refresh();
|
|
1390
|
+
if (!moduleRoute() && !accountRoutes.includes(currentRoute()))
|
|
1391
|
+
navigate("content");
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
// Nothing held here. Fidj may still know this browser from an app.
|
|
1395
|
+
if (await askWhetherFidjKnowsThisBrowser()) return;
|
|
1396
|
+
recognising = false;
|
|
1397
|
+
render();
|
|
1398
|
+
} catch (error) {
|
|
1399
|
+
recognising = false;
|
|
1400
|
+
throw error;
|
|
1382
1401
|
}
|
|
1383
|
-
// Nothing held here. Fidj may still know this browser from an app.
|
|
1384
|
-
if (await askWhetherFidjKnowsThisBrowser()) return;
|
|
1385
|
-
recognising = false;
|
|
1386
|
-
render();
|
|
1387
1402
|
});
|
|
1388
1403
|
}
|