authscape 1.0.774 → 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,21 +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
- var router = (0, _router.useRouter)();
780
- var rawQueryCode = router.isReady ? router.query.code : null;
781
- // router.query values can be string | string[] — coerce to a single string.
782
- var queryCode = typeof rawQueryCode === "string" ? rawQueryCode : Array.isArray(rawQueryCode) ? rawQueryCode[0] : null;
783
- // Pages Router's `router.pathname` returns the route file path (e.g. "/_error"
784
- // for the 404 page). The auth-redirect guard below compares against
785
- // "/signin-oidc", so we derive the actual URL path from `asPath` instead.
786
- var pathname = (router.asPath || "").split("?")[0].split("#")[0];
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)();
787
777
  var signInValidator = /*#__PURE__*/function () {
788
778
  var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(codeFromQuery) {
789
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.774",
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,22 +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
- const router = useRouter();
511
- const rawQueryCode = router.isReady ? router.query.code : null;
512
- // router.query values can be string | string[] — coerce to a single string.
513
- const queryCode = typeof rawQueryCode === "string"
514
- ? rawQueryCode
515
- : (Array.isArray(rawQueryCode) ? rawQueryCode[0] : null);
516
- // Pages Router's `router.pathname` returns the route file path (e.g. "/_error"
517
- // for the 404 page). The auth-redirect guard below compares against
518
- // "/signin-oidc", so we derive the actual URL path from `asPath` instead.
519
- const pathname = (router.asPath || "").split("?")[0].split("#")[0];
504
+ const searchParams = useSearchParams();
505
+ const queryCode = searchParams?.get("code") ?? null;
506
+ const pathname = usePathname();
520
507
 
521
508
  const signInValidator = async (codeFromQuery) => {
522
509
  if (queryCodeUsed.current === codeFromQuery) return;