antaeus.keycloak.react 2.1.2 → 2.1.3

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/dist/index.mjs CHANGED
@@ -1482,6 +1482,7 @@ var DeviceLogin = ({
1482
1482
  function useProtectedFetch(options = {}) {
1483
1483
  const auth = useAuth();
1484
1484
  const refreshInProgressRef = useRef(false);
1485
+ const { user, isLoading, signinSilent } = auth;
1485
1486
  const {
1486
1487
  baseUrl = "",
1487
1488
  onUnauthorized,
@@ -1500,11 +1501,11 @@ function useProtectedFetch(options = {}) {
1500
1501
  [baseUrl]
1501
1502
  );
1502
1503
  const getAuthHeader = () => {
1503
- if (!auth.user?.access_token) {
1504
+ if (!user?.access_token) {
1504
1505
  return {};
1505
1506
  }
1506
1507
  return {
1507
- Authorization: `Bearer ${auth.user.access_token}`
1508
+ Authorization: `Bearer ${user.access_token}`
1508
1509
  };
1509
1510
  };
1510
1511
  const buildHeaders = useCallback(
@@ -1531,10 +1532,10 @@ function useProtectedFetch(options = {}) {
1531
1532
  });
1532
1533
  if (response.status === 401) {
1533
1534
  onUnauthorized?.();
1534
- if (retryOn401 && auth.user && !refreshInProgressRef.current) {
1535
+ if (retryOn401 && user && !refreshInProgressRef.current) {
1535
1536
  refreshInProgressRef.current = true;
1536
1537
  try {
1537
- await auth.signinSilent();
1538
+ await signinSilent();
1538
1539
  const newHeaders = buildHeaders(init?.headers);
1539
1540
  const retryResponse = await fetch(fullUrl, {
1540
1541
  ...init,
@@ -1552,7 +1553,7 @@ function useProtectedFetch(options = {}) {
1552
1553
  }
1553
1554
  return response;
1554
1555
  },
1555
- [buildUrl, buildHeaders, onUnauthorized, retryOn401, auth]
1556
+ [buildUrl, buildHeaders, onUnauthorized, retryOn401, user, signinSilent]
1556
1557
  );
1557
1558
  const fetchJson = useCallback(
1558
1559
  async (url, init) => {
@@ -1571,7 +1572,7 @@ function useProtectedFetch(options = {}) {
1571
1572
  return {
1572
1573
  fetchJson,
1573
1574
  fetch: protectedFetch,
1574
- isLoading: auth.isLoading
1575
+ isLoading
1575
1576
  };
1576
1577
  }
1577
1578