authscape 1.0.773 → 1.0.776
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/index.js +728 -560
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +20 -9
package/package.json
CHANGED
|
@@ -507,16 +507,27 @@ export function AuthScapeApp({
|
|
|
507
507
|
// back to /signin-oidc (a URL with no Next.js page in the consumer project),
|
|
508
508
|
// useSearchParams() returns null and the PKCE code is never picked up.
|
|
509
509
|
// The Pages Router router parses query from `asPath` and works on 404 too.
|
|
510
|
+
//
|
|
511
|
+
// SSR safety: accessing `router.isReady`, `router.query`, `router.asPath`
|
|
512
|
+
// throws "NextRouter was not mounted" on server-side renders where the
|
|
513
|
+
// router singleton hasn't been initialized (Static Generation, _error
|
|
514
|
+
// pages, some edge-runtime paths). We only do the work on the client.
|
|
510
515
|
const router = useRouter();
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
516
|
+
let queryCode = null;
|
|
517
|
+
let pathname = "";
|
|
518
|
+
if (typeof window !== "undefined") {
|
|
519
|
+
try {
|
|
520
|
+
if (router && router.isReady) {
|
|
521
|
+
const raw = router.query && router.query.code;
|
|
522
|
+
queryCode = typeof raw === "string"
|
|
523
|
+
? raw
|
|
524
|
+
: (Array.isArray(raw) ? raw[0] : null);
|
|
525
|
+
}
|
|
526
|
+
pathname = ((router && router.asPath) || "").split("?")[0].split("#")[0];
|
|
527
|
+
} catch (_) {
|
|
528
|
+
// router not mounted (SSR / static render) — leave defaults
|
|
529
|
+
}
|
|
530
|
+
}
|
|
520
531
|
|
|
521
532
|
const signInValidator = async (codeFromQuery) => {
|
|
522
533
|
if (queryCodeUsed.current === codeFromQuery) return;
|