react-ecosistema-unp 1.8.0-pre.1 → 1.8.0-pre.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.
@@ -1,22 +1,20 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { createContext as c, useState as e } from "react";
3
- const i = c(void 0), h = ({ children: t }) => {
4
- const [o, r] = e(
5
- // localStorage.getItem("access_token")
6
- ""
7
- ), [n, s] = e(
8
- // localStorage.getItem("user_token")
9
- ""
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { createContext as u, useState as t } from "react";
3
+ const c = u(void 0), i = ({ children: e }) => {
4
+ const [o, r] = t(
5
+ localStorage.getItem("access_token")
6
+ ), [n, s] = t(
7
+ localStorage.getItem("auth_state")
10
8
  );
11
- return /* @__PURE__ */ u(
12
- i.Provider,
9
+ return /* @__PURE__ */ a(
10
+ c.Provider,
13
11
  {
14
12
  value: { authToken: o, setAuthToken: r, userToken: n, setUserToken: s },
15
- children: t
13
+ children: e
16
14
  }
17
15
  );
18
16
  };
19
17
  export {
20
- i as AuthContext,
21
- h as AuthProvider
18
+ c as AuthContext,
19
+ i as AuthProvider
22
20
  };
@@ -1,25 +1,25 @@
1
- import { FinSesionService as r } from "../services/FinSesionService.js";
1
+ import { FinSesionService as i } from "../services/FinSesionService.js";
2
2
  import { y as a } from "../../index-BUe3EJDH.js";
3
3
  import { useState as c, useEffect as l } from "react";
4
4
  import { j as m } from "../../index-CuHybtft.js";
5
- const p = () => {
6
- const [e, i] = c(null), s = `${window.location.protocol}//${window.location.host}/`;
5
+ const d = () => {
6
+ const [o, r] = c(null), n = `${window.location.protocol}//${window.location.host}/`;
7
7
  return l(() => {
8
- const o = sessionStorage.getItem("user_token");
9
- if (o) {
10
- const n = m(o);
11
- i(n);
8
+ const e = localStorage.getItem("access_token");
9
+ if (e) {
10
+ const t = m(e);
11
+ r(t);
12
12
  }
13
13
  }, []), { FinSesion: () => {
14
14
  a.promise(
15
- new Promise(async (o, n) => {
15
+ new Promise(async (e, t) => {
16
16
  try {
17
- await r((e == null ? void 0 : e.datos_basicos.username) || "", s), o(!0);
18
- } catch (t) {
19
- n(t);
17
+ await i((o == null ? void 0 : o.user.username) || "", n), e(!0);
18
+ } catch (s) {
19
+ t(s);
20
20
  } finally {
21
- sessionStorage.removeItem("user_token"), setTimeout(() => {
22
- window.location.href = s;
21
+ sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), setTimeout(() => {
22
+ window.location.href = n;
23
23
  }, 1e3);
24
24
  }
25
25
  }),
@@ -32,5 +32,5 @@ const p = () => {
32
32
  } };
33
33
  };
34
34
  export {
35
- p as useFinalizarSesion
35
+ d as useFinalizarSesion
36
36
  };
@@ -4,8 +4,5 @@ declare const AuthContext: React.Context<AuthContextType | undefined>;
4
4
  interface AuthProviderProps {
5
5
  children: ReactNode;
6
6
  }
7
- /**
8
- * @deprecated since version 1.7.7 — use `EcoProvider` instead.
9
- */
10
7
  declare const AuthProvider: React.FC<AuthProviderProps>;
11
8
  export { AuthContext, AuthProvider };
@@ -4,8 +4,8 @@ import { F as t, f as u, g as f, h as v, i as z } from "../../index-D3WseyJh.js"
4
4
  import { z as N } from "../../index-DDjnZyBf.js";
5
5
  import { G as g } from "../../iconBase-LROS5hdG.js";
6
6
  import { j as w } from "../../index-CuHybtft.js";
7
- import { N as b } from "../../NavDropdown-ei8eIwIE.js";
8
- import '../../assets/AppList.css';function U(s) {
7
+ import { N as U } from "../../NavDropdown-ei8eIwIE.js";
8
+ import '../../assets/AppList.css';function b(s) {
9
9
  return g({ tag: "svg", attr: { fill: "currentColor", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M1 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 12a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1z" }, child: [] }] })(s);
10
10
  }
11
11
  const F = {
@@ -23,11 +23,11 @@ const F = {
23
23
  }, j = () => {
24
24
  const [s, l] = d([]), e = location.pathname, c = e.startsWith("/") ? e : `/${e}`;
25
25
  h(() => {
26
- const a = sessionStorage.getItem("user_token");
26
+ const a = localStorage.getItem("access_token");
27
27
  if (a)
28
28
  try {
29
29
  const i = w(a);
30
- l(i.datos_basicos.servicios);
30
+ l(i.user.servicios);
31
31
  } catch (i) {
32
32
  console.error("Error al decodificar el token:", i);
33
33
  }
@@ -37,9 +37,9 @@ const F = {
37
37
  window.location.href = i;
38
38
  };
39
39
  return /* @__PURE__ */ o(
40
- b,
40
+ U,
41
41
  {
42
- title: /* @__PURE__ */ o(U, { className: "icono-app" }),
42
+ title: /* @__PURE__ */ o(b, { className: "icono-app" }),
43
43
  align: "end",
44
44
  children: /* @__PURE__ */ o("div", { style: {
45
45
  fontWeight: "400",
@@ -69,9 +69,9 @@ function W(t) {
69
69
  return i({ tag: "svg", attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z" }, child: [] }] })(t);
70
70
  }
71
71
  const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
72
- const [N, f] = o(!0), [m, p] = o(null), k = c ? "sidebar-bar-panel open" : "sidebar-bar-panel", b = H(), { FinSesion: w } = C(), { connectionStatus: v } = A(), [z, l] = o(!1), [M, n] = o(""), h = `${window.location.host}`;
72
+ const [N, f] = o(!0), [m, p] = o(null), k = c ? "sidebar-bar-panel open" : "sidebar-bar-panel", w = H(), { FinSesion: b } = C(), { connectionStatus: v } = A(), [z, l] = o(!1), [M, n] = o(""), h = `${window.location.host}`;
73
73
  if (d(() => {
74
- const r = sessionStorage.getItem("user_token");
74
+ const r = localStorage.getItem("access_token");
75
75
  if (r) {
76
76
  const s = u(r);
77
77
  p(s);
@@ -79,10 +79,10 @@ const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
79
79
  f(!1);
80
80
  }, []), d(() => {
81
81
  const r = setTimeout(() => {
82
- const s = sessionStorage.getItem("user_token");
82
+ const s = localStorage.getItem("access_token");
83
83
  if (s) {
84
- const B = u(s);
85
- p(B);
84
+ const _ = u(s);
85
+ p(_);
86
86
  }
87
87
  }, 2e3);
88
88
  return () => clearTimeout(r);
@@ -90,8 +90,8 @@ const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
90
90
  h.includes("localhost") ? (l(!0), n("Entorno local")) : h.includes("ecosistemadesarrollo") ? (l(!0), n("Entorno de desarrollo")) : h.includes("ecosistemapruebas") ? (l(!0), n("Entorno de pruebas")) : (l(!1), n(""));
91
91
  }, []), N)
92
92
  return /* @__PURE__ */ a(g, {});
93
- const _ = () => {
94
- b("/unp/ecosistema/usuario");
93
+ const B = () => {
94
+ w("/unp/ecosistema/usuario");
95
95
  };
96
96
  return /* @__PURE__ */ a("div", { className: `container-fluid ${c ? "menu-open" : ""}`, children: /* @__PURE__ */ e("div", { className: k, children: [
97
97
  /* @__PURE__ */ e("div", { className: "logo_details", children: [
@@ -291,15 +291,15 @@ const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
291
291
  "div",
292
292
  {
293
293
  className: "profile-detail",
294
- onClick: _,
294
+ onClick: B,
295
295
  style: { cursor: "pointer" },
296
296
  children: m && /* @__PURE__ */ e("div", { className: "name-job", style: { marginTop: "3px" }, children: [
297
- /* @__PURE__ */ a("div", { className: "name text-truncate", style: { width: "200px" }, children: m.datos_basicos.nombre }),
297
+ /* @__PURE__ */ a("div", { className: "name text-truncate", style: { width: "200px" }, children: m.user.nombres }),
298
298
  /* @__PURE__ */ a("div", { className: "job" })
299
299
  ] })
300
300
  }
301
301
  ),
302
- /* @__PURE__ */ a(F, { className: "icon", onClick: w })
302
+ /* @__PURE__ */ a(F, { className: "icon", onClick: b })
303
303
  ] })
304
304
  ] })
305
305
  ] }) });
@@ -1,9 +1,9 @@
1
1
  import { jsx as v } from "react/jsx-runtime";
2
- import { useState as _, useEffect as S } from "react";
3
- import { useLocation as U, Outlet as g } from "react-router-dom";
2
+ import { useState as S, useEffect as g } from "react";
3
+ import { useLocation as _, Outlet as I } from "react-router-dom";
4
4
  import { j as u } from "../../index-CuHybtft.js";
5
5
  const y = () => {
6
- const [p, t] = _(!1), m = U(), s = `${window.location.protocol}//${window.location.host}/`, a = `${window.location.host}`, w = async () => {
6
+ const [p, o] = S(!1), m = _(), s = `${window.location.protocol}//${window.location.host}/`, n = `${window.location.host}`, w = async () => {
7
7
  if ((await fetch(`${s}api-auth/auth/refresh_token/`, {
8
8
  method: "POST",
9
9
  headers: {
@@ -14,8 +14,8 @@ const y = () => {
14
14
  return !0;
15
15
  throw new Error("Error al refrescar token de Microsoft");
16
16
  };
17
- return S(() => {
18
- const d = async () => {
17
+ return g(() => {
18
+ const h = async () => {
19
19
  try {
20
20
  if ((await fetch(`${s}api-auth/auth/validate_jwt/`, {
21
21
  method: "POST",
@@ -24,40 +24,40 @@ const y = () => {
24
24
  },
25
25
  credentials: "include"
26
26
  })).ok) {
27
- const i = sessionStorage.getItem("user_token");
28
- if (i) {
29
- const f = u(i).datos_basicos.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, n = f.map(
27
+ const c = localStorage.getItem("access_token");
28
+ if (c) {
29
+ const d = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = d.map(
30
30
  (e) => e.startsWith("/") ? e : `/${e}`
31
- ), l = r.startsWith("/") ? r : `/${r}`;
32
- n.some(
33
- (e) => l.startsWith(e)
34
- ) ? t(!0) : (t(!1), sessionStorage.removeItem("user_token"), window.location.href = s);
31
+ ), i = r.startsWith("/") ? r : `/${r}`;
32
+ a.some(
33
+ (e) => i.startsWith(e)
34
+ ) ? o(!0) : (o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
35
35
  } else
36
- t(!1), sessionStorage.removeItem("user_token"), window.location.href = s;
36
+ o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s;
37
37
  } else
38
38
  throw new Error("Token inválido");
39
39
  } catch {
40
40
  try {
41
41
  if (await w()) {
42
- const c = sessionStorage.getItem("user_token");
43
- if (c) {
44
- const r = u(c).datos_basicos.servicios.map((o) => o.url).filter((o) => !!o), n = m.pathname, l = r.map(
45
- (o) => o.startsWith("/") ? o : `/${o}`
46
- ), h = n.startsWith("/") ? n : `/${n}`;
47
- l.some(
48
- (o) => h.startsWith(o)
49
- ) ? t(!0) : (t(!1), sessionStorage.removeItem("user_token"), window.location.href = s);
42
+ const l = localStorage.getItem("access_token");
43
+ if (l) {
44
+ const r = u(l).user.servicios.map((t) => t.url).filter((t) => !!t), a = m.pathname, i = r.map(
45
+ (t) => t.startsWith("/") ? t : `/${t}`
46
+ ), f = a.startsWith("/") ? a : `/${a}`;
47
+ i.some(
48
+ (t) => f.startsWith(t)
49
+ ) ? o(!0) : (o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
50
50
  } else
51
- t(!1), sessionStorage.removeItem("user_token"), window.location.href = s;
51
+ o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s;
52
52
  } else
53
53
  throw new Error("No se pudo refrescar el token.");
54
54
  } catch {
55
- sessionStorage.removeItem("user_token"), window.location.href = s, t(!1);
55
+ sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s, o(!1);
56
56
  }
57
57
  }
58
58
  };
59
- a.includes("ecosistemadesarrollo") || a.includes("ecosistemapruebas") || a.includes("ecosistemaprov") || a.includes("ecosistema") ? d() : (console.warn("ProtectedRoute is disabled in the local development environment."), t(!0));
60
- }, []), p ? /* @__PURE__ */ v(g, {}) : null;
59
+ n.includes("ecosistemadesarrollo") || n.includes("ecosistemapruebas") || n.includes("ecosistemaprov") || n.includes("ecosistema") ? h() : (console.warn("ProtectedRoute is disabled in the local development environment."), o(!0));
60
+ }, []), p ? /* @__PURE__ */ v(I, {}) : null;
61
61
  };
62
62
  export {
63
63
  y as ProtectedRoute
@@ -1,12 +1,12 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import { useState as d, useEffect as h } from "react";
3
- import { useNavigate as u, Outlet as f } from "react-router-dom";
3
+ import { useNavigate as u, Outlet as m } from "react-router-dom";
4
4
  const k = () => {
5
- const [r, e] = d(!1), s = u(), o = `${window.location.protocol}//${window.location.host}/`, t = `${window.location.host}`;
6
- if (t.includes("localhost"))
5
+ const [a, e] = d(!1), s = u(), t = `${window.location.protocol}//${window.location.host}/`, o = `${window.location.host}`;
6
+ if (o.includes("localhost"))
7
7
  return console.warn("ProtectedRoute is disabled in the local development environment."), null;
8
- const a = async () => {
9
- if ((await fetch(`${o}api-auth/auth/refresh_token/`, {
8
+ const n = async () => {
9
+ if ((await fetch(`${t}api-auth/auth/refresh_token/`, {
10
10
  method: "POST",
11
11
  headers: {
12
12
  "Content-Type": "application/json"
@@ -17,9 +17,9 @@ const k = () => {
17
17
  throw new Error("Error al refrescar token de Microsoft");
18
18
  };
19
19
  return h(() => {
20
- const n = async () => {
20
+ const r = async () => {
21
21
  try {
22
- if ((await fetch(`${o}api-auth/auth/validate_jwt/`, {
22
+ if ((await fetch(`${t}api-auth/auth/validate_jwt/`, {
23
23
  method: "POST",
24
24
  headers: {
25
25
  "Content-Type": "application/json"
@@ -29,9 +29,9 @@ const k = () => {
29
29
  e(!0);
30
30
  else
31
31
  try {
32
- if (await a())
32
+ if (await n())
33
33
  (await fetch(
34
- `${o}api-auth/auth/validate_jwt/`,
34
+ `${t}api-auth/auth/validate_jwt/`,
35
35
  {
36
36
  method: "POST",
37
37
  headers: {
@@ -39,18 +39,18 @@ const k = () => {
39
39
  },
40
40
  credentials: "include"
41
41
  }
42
- )).ok ? e(!0) : (sessionStorage.removeItem("user_token"), window.location.href = o, e(!1));
42
+ )).ok ? e(!0) : (sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = t, e(!1));
43
43
  else
44
44
  throw new Error("No se pudo refrescar el token.");
45
45
  } catch {
46
- sessionStorage.removeItem("user_token"), window.location.href = o, e(!1);
46
+ sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = t, e(!1);
47
47
  }
48
48
  } catch {
49
- sessionStorage.removeItem("user_token"), window.location.href = o, e(!1);
49
+ sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = t, e(!1);
50
50
  }
51
51
  };
52
- t.includes("localhost") ? (console.warn("ProtectedRoute is disabled in the local development environment."), e(!0)) : n();
53
- }, [s]), r ? /* @__PURE__ */ c(f, {}) : null;
52
+ o.includes("localhost") ? (console.warn("ProtectedRoute is disabled in the local development environment."), e(!0)) : r();
53
+ }, [s]), a ? /* @__PURE__ */ c(m, {}) : null;
54
54
  };
55
55
  export {
56
56
  k as UserRoute
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.8.0-pre.1",
5
+ "version": "1.8.0-pre.3",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
@@ -1,7 +0,0 @@
1
- declare global {
2
- interface Window {
3
- originalFetch: typeof fetch;
4
- }
5
- }
6
- declare const _default: {};
7
- export default _default;
@@ -1,7 +0,0 @@
1
- declare global {
2
- interface Window {
3
- originalFetch: typeof fetch;
4
- }
5
- }
6
- declare const _default: {};
7
- export default _default;
@@ -1,56 +0,0 @@
1
- window.originalFetch = window.fetch.bind(window);
2
- let l = !1, h = null;
3
- const i = [];
4
- async function p() {
5
- const e = `${`${window.location.protocol}//${window.location.host}/`}api-auth/auth/refresh_token/`, t = await window.originalFetch(e, {
6
- method: "POST",
7
- credentials: "include"
8
- });
9
- if (!t.ok)
10
- throw new Error("Error al refrescar token, status " + t.status);
11
- return "Token refreshed";
12
- }
13
- window.fetch = async function(o, e) {
14
- const t = typeof o == "string" ? o : o.toString();
15
- if (console.log("URL petición:", t), t.includes("/api-auth/"))
16
- return window.originalFetch(o, e);
17
- e = e || {};
18
- const u = sessionStorage.getItem("user_token");
19
- e.headers = {
20
- ...e.headers,
21
- ...u ? { Authorization: u } : {}
22
- };
23
- try {
24
- const c = `${window.location.protocol}//${window.location.host}/`, r = await window.originalFetch(o, e);
25
- if (r.status !== 401) {
26
- const n = await r.clone().text();
27
- if (!n.includes("Signature has expired"))
28
- return r;
29
- if (n.includes("Invalid or expired token"))
30
- return sessionStorage.removeItem("user_token"), setTimeout(() => {
31
- window.location.href = c;
32
- }, 1e3), r;
33
- }
34
- return new Promise((w, n) => {
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 = {
38
- ...s,
39
- headers: { ...s.headers, Authorization: sessionStorage.getItem("user_token") }
40
- };
41
- window.originalFetch(a, g).then(d).catch(f);
42
- });
43
- }).catch((a) => {
44
- i.forEach(({ reject: s }) => s(a));
45
- }).finally(() => {
46
- i.length = 0, l = !1, h = null;
47
- }));
48
- });
49
- } catch (c) {
50
- return Promise.reject(c);
51
- }
52
- };
53
- const k = {};
54
- export {
55
- k as default
56
- };
@@ -1,56 +0,0 @@
1
- window.originalFetch = window.fetch.bind(window);
2
- let l = !1, h = null;
3
- const c = [];
4
- async function k() {
5
- const e = `${`${window.location.protocol}//${window.location.host}/`}api-auth/auth/refresh_token/`, t = await window.originalFetch(e, {
6
- method: "POST",
7
- credentials: "include"
8
- });
9
- if (!t.ok)
10
- throw new Error("Error al refrescar token, status " + t.status);
11
- return console.warn("Token refrescado"), "Token refreshed";
12
- }
13
- window.fetch = async function(o, e) {
14
- const t = typeof o == "string" ? o : o.toString();
15
- if (console.log("Petición fetchInterceptor Librería:", t), t.includes("/api-auth/"))
16
- return window.originalFetch(o, e);
17
- e = e || {};
18
- const u = sessionStorage.getItem("user_token");
19
- e.headers = {
20
- ...e.headers,
21
- ...u ? { Authorization: u } : {}
22
- };
23
- try {
24
- const i = `${window.location.protocol}//${window.location.host}/`, r = await window.originalFetch(o, e);
25
- if (r.status !== 401) {
26
- const n = await r.clone().text();
27
- if (!n.includes("Signature has expired"))
28
- return r;
29
- if (n.includes("Invalid or expired token"))
30
- return console.warn("El token expiró"), sessionStorage.removeItem("user_token"), setTimeout(() => {
31
- window.location.href = i;
32
- }, 1e3), r;
33
- }
34
- return new Promise((w, n) => {
35
- c.push({ input: o, init: e, resolve: w, reject: n }), l || (l = !0, h = k(), h.then(() => {
36
- c.forEach(({ input: a, init: s, resolve: d, reject: f }) => {
37
- const g = {
38
- ...s,
39
- headers: { ...s.headers, Authorization: sessionStorage.getItem("user_token") }
40
- };
41
- window.originalFetch(a, g).then(d).catch(f);
42
- });
43
- }).catch((a) => {
44
- c.forEach(({ reject: s }) => s(a));
45
- }).finally(() => {
46
- c.length = 0, l = !1, h = null;
47
- }));
48
- });
49
- } catch (i) {
50
- return Promise.reject(i);
51
- }
52
- };
53
- const p = {};
54
- export {
55
- p as default
56
- };