react-ecosistema-unp 1.6.4 → 1.6.10-pre.0

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,8 +1,7 @@
1
- import { useNavigate as m } from "react-router-dom";
2
1
  window.originalFetch = window.fetch.bind(window);
3
2
  let l = !1, h = null;
4
3
  const i = [];
5
- async function k() {
4
+ async function p() {
6
5
  const e = `${`${window.location.protocol}//${window.location.host}/`}api-auth/auth/refresh_token/`, t = await window.originalFetch(e, {
7
6
  method: "POST",
8
7
  credentials: "include"
@@ -22,36 +21,36 @@ window.fetch = async function(o, e) {
22
21
  ...u ? { Authorization: u } : {}
23
22
  };
24
23
  try {
25
- const a = m(), d = `${window.location.protocol}//${window.location.host}/`, r = await window.originalFetch(o, e);
24
+ const c = `${window.location.protocol}//${window.location.host}/`, r = await window.originalFetch(o, e);
26
25
  if (r.status !== 401) {
27
26
  const n = await r.clone().text();
28
27
  if (!n.includes("Signature has expired"))
29
28
  return r;
30
29
  if (n.includes("Invalid or expired token"))
31
30
  return sessionStorage.removeItem("user_token"), setTimeout(() => {
32
- a("/"), window.location.href = d;
31
+ window.location.href = c;
33
32
  }, 1e3), r;
34
33
  }
35
34
  return new Promise((w, n) => {
36
- i.push({ input: o, init: e, resolve: w, reject: n }), l || (l = !0, h = k(), h.then(() => {
37
- i.forEach(({ input: c, init: s, resolve: f, reject: g }) => {
38
- const p = {
35
+ i.push({ input: o, init: e, resolve: w, reject: n }), l || (l = !0, h = p(), h.then(() => {
36
+ i.forEach(({ input: a, init: s, resolve: d, reject: f }) => {
37
+ const g = {
39
38
  ...s,
40
39
  headers: { ...s.headers, Authorization: sessionStorage.getItem("user_token") }
41
40
  };
42
- window.originalFetch(c, p).then(f).catch(g);
41
+ window.originalFetch(a, g).then(d).catch(f);
43
42
  });
44
- }).catch((c) => {
45
- i.forEach(({ reject: s }) => s(c));
43
+ }).catch((a) => {
44
+ i.forEach(({ reject: s }) => s(a));
46
45
  }).finally(() => {
47
46
  i.length = 0, l = !1, h = null;
48
47
  }));
49
48
  });
50
- } catch (a) {
51
- return Promise.reject(a);
49
+ } catch (c) {
50
+ return Promise.reject(c);
52
51
  }
53
52
  };
54
- const I = {};
53
+ const k = {};
55
54
  export {
56
- I as default
55
+ k as default
57
56
  };
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.4",
5
+ "version": "1.6.10-pre.0",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {