react-ecosistema-unp 1.6.0-pre.3 → 1.6.0-pre.5

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.
@@ -1,10 +1,9 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { useState as h, useEffect as p } from "react";
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import { useState as m, useEffect as p } from "react";
3
3
  import { useNavigate as w, useLocation as u, Outlet as k } from "react-router-dom";
4
4
  import { j as v } from "../../index-CuHybtft.js";
5
- import "./fetchInterceptor.js";
6
- const W = () => {
7
- const [i, e] = h(!1), r = w(), c = u(), o = `${window.location.protocol}//${window.location.host}/`;
5
+ const V = () => {
6
+ const [i, e] = m(!1), r = w(), c = u(), o = `${window.location.protocol}//${window.location.host}/`;
8
7
  return p(() => {
9
8
  (async () => {
10
9
  try {
@@ -35,8 +34,8 @@ const W = () => {
35
34
  } finally {
36
35
  }
37
36
  })();
38
- }, [r]), i ? /* @__PURE__ */ m(k, {}) : null;
37
+ }, [r]), i ? /* @__PURE__ */ h(k, {}) : null;
39
38
  };
40
39
  export {
41
- W as ProtectedRoute
40
+ V as ProtectedRoute
42
41
  };
@@ -1,5 +1,5 @@
1
1
  window.originalFetch = window.fetch.bind(window);
2
- let i = !1, h = null;
2
+ let c = !1, h = null;
3
3
  const s = [];
4
4
  async function k() {
5
5
  const e = `${`${window.location.protocol}//${window.location.host}/`}api-auth/auth/refresh_token/`, o = await window.originalFetch(e, {
@@ -26,19 +26,19 @@ window.fetch = async function(r, e) {
26
26
  };
27
27
  try {
28
28
  const t = await window.originalFetch(r, e);
29
- return t.status !== 401 ? t : new Promise((u, w) => {
30
- s.push({ input: r, init: e, resolve: u, reject: w }), i || (i = !0, h = k(), h.then((a) => {
31
- s.forEach(({ input: c, init: l, resolve: d, reject: f }) => {
29
+ return t.status !== 401 && !(await t.text()).includes("Signature has expired") ? t : new Promise((u, w) => {
30
+ s.push({ input: r, init: e, resolve: u, reject: w }), c || (c = !0, h = k(), h.then((a) => {
31
+ s.forEach(({ input: i, init: l, resolve: d, reject: f }) => {
32
32
  const g = {
33
33
  ...l,
34
34
  headers: { ...l.headers, Authorization: a }
35
35
  };
36
- window.originalFetch(c, g).then(d).catch(f);
36
+ window.originalFetch(i, g).then(d).catch(f);
37
37
  });
38
38
  }).catch((a) => {
39
- s.forEach(({ reject: c }) => c(a));
39
+ s.forEach(({ reject: i }) => i(a));
40
40
  }).finally(() => {
41
- s.length = 0, i = !1, h = null;
41
+ s.length = 0, c = !1, h = null;
42
42
  }));
43
43
  });
44
44
  } catch (t) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-ecosistema-unp",
3
3
  "author": "Ecosistema de Información - Unidad Nacional de Protección",
4
4
  "private": false,
5
- "version": "1.6.0-pre.3",
5
+ "version": "1.6.0-pre.5",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {