authscape 1.0.776 → 1.0.778

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 CHANGED
@@ -42,9 +42,10 @@ exports.useNotifications = useNotifications;
42
42
  var _react = _interopRequireWildcard(require("react"));
43
43
  var _reactToastify = require("react-toastify");
44
44
  var _head = _interopRequireDefault(require("next/head"));
45
- var _router = _interopRequireWildcard(require("next/router"));
45
+ var _navigation = require("next/navigation");
46
46
  var _axios = _interopRequireDefault(require("axios"));
47
47
  var _queryString = _interopRequireDefault(require("query-string"));
48
+ var _router = _interopRequireDefault(require("next/router"));
48
49
  var _ga4React = _interopRequireDefault(require("ga-4-react"));
49
50
  var _zustand = require("zustand");
50
51
  var _reactMicrosoftClarity = require("react-microsoft-clarity");
@@ -726,6 +727,7 @@ function ensureUserHelpers(u) {
726
727
  // AuthScapeApp Component
727
728
  // ============================================================================
728
729
  function AuthScapeApp(_ref0) {
730
+ var _searchParams$get;
729
731
  var Component = _ref0.Component,
730
732
  layout = _ref0.layout,
731
733
  loadingLayout = _ref0.loadingLayout,
@@ -769,32 +771,9 @@ function AuthScapeApp(_ref0) {
769
771
  var ga4React = (0, _react.useRef)(null);
770
772
  var errorTrackingInitializedRef = (0, _react.useRef)(false);
771
773
  var loginRedirectPending = (0, _react.useRef)(false);
772
-
773
- // Use Pages Router's `useRouter` instead of `useSearchParams`/`usePathname`
774
- // from `next/navigation`. The `next/navigation` hooks don't hydrate query
775
- // params reliably on the 404 page in Webkit/Safari — when the IDP redirects
776
- // back to /signin-oidc (a URL with no Next.js page in the consumer project),
777
- // useSearchParams() returns null and the PKCE code is never picked up.
778
- // The Pages Router router parses query from `asPath` and works on 404 too.
779
- //
780
- // SSR safety: accessing `router.isReady`, `router.query`, `router.asPath`
781
- // throws "NextRouter was not mounted" on server-side renders where the
782
- // router singleton hasn't been initialized (Static Generation, _error
783
- // pages, some edge-runtime paths). We only do the work on the client.
784
- var router = (0, _router.useRouter)();
785
- var queryCode = null;
786
- var pathname = "";
787
- if (typeof window !== "undefined") {
788
- try {
789
- if (router && router.isReady) {
790
- var raw = router.query && router.query.code;
791
- queryCode = typeof raw === "string" ? raw : Array.isArray(raw) ? raw[0] : null;
792
- }
793
- pathname = (router && router.asPath || "").split("?")[0].split("#")[0];
794
- } catch (_) {
795
- // router not mounted (SSR / static render) — leave defaults
796
- }
797
- }
774
+ var searchParams = (0, _navigation.useSearchParams)();
775
+ var queryCode = (_searchParams$get = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("code")) !== null && _searchParams$get !== void 0 ? _searchParams$get : null;
776
+ var pathname = (0, _navigation.usePathname)();
798
777
  var signInValidator = /*#__PURE__*/function () {
799
778
  var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(codeFromQuery) {
800
779
  var codeVerifier, headers, body, response, domainHost, redirectUri, usr, enrichedUser;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.776",
3
+ "version": "1.0.778",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -4,7 +4,7 @@ import Head from "next/head";
4
4
 
5
5
  // Re-export toast and transitions so pages can import from authscape
6
6
  export { toast, Bounce, Slide, Zoom, Flip };
7
- import { useRouter } from "next/router";
7
+ import { useSearchParams, usePathname } from "next/navigation";
8
8
  import axios from "axios";
9
9
  import querystring from "query-string";
10
10
  import Router from "next/router";
@@ -501,33 +501,9 @@ export function AuthScapeApp({
501
501
  const errorTrackingInitializedRef = useRef(false);
502
502
  const loginRedirectPending = useRef(false);
503
503
 
504
- // Use Pages Router's `useRouter` instead of `useSearchParams`/`usePathname`
505
- // from `next/navigation`. The `next/navigation` hooks don't hydrate query
506
- // params reliably on the 404 page in Webkit/Safari — when the IDP redirects
507
- // back to /signin-oidc (a URL with no Next.js page in the consumer project),
508
- // useSearchParams() returns null and the PKCE code is never picked up.
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.
515
- const router = useRouter();
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
- }
504
+ const searchParams = useSearchParams();
505
+ const queryCode = searchParams?.get("code") ?? null;
506
+ const pathname = usePathname();
531
507
 
532
508
  const signInValidator = async (codeFromQuery) => {
533
509
  if (queryCodeUsed.current === codeFromQuery) return;