react-ecosistema-unp 1.8.0-pre.3 → 1.8.0-pre.4

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,9 +1,9 @@
1
- import { jsx as v } from "react/jsx-runtime";
2
- import { useState as S, useEffect as g } from "react";
3
- import { useLocation as _, Outlet as I } from "react-router-dom";
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { useState as g, useEffect as S } from "react";
3
+ import { useLocation as I, Outlet as _ } from "react-router-dom";
4
4
  import { j as u } from "../../index-CuHybtft.js";
5
- const y = () => {
6
- const [p, o] = S(!1), m = _(), s = `${window.location.protocol}//${window.location.host}/`, n = `${window.location.host}`, w = async () => {
5
+ const W = () => {
6
+ const [k, o] = g(!1), m = I(), 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,19 +14,13 @@ const y = () => {
14
14
  return !0;
15
15
  throw new Error("Error al refrescar token de Microsoft");
16
16
  };
17
- return g(() => {
17
+ return S(() => {
18
18
  const h = async () => {
19
19
  try {
20
- if ((await fetch(`${s}api-auth/auth/validate_jwt/`, {
21
- method: "POST",
22
- headers: {
23
- "Content-Type": "application/json"
24
- },
25
- credentials: "include"
26
- })).ok) {
20
+ if (localStorage.getItem("auth_state")) {
27
21
  const c = localStorage.getItem("access_token");
28
22
  if (c) {
29
- const d = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = d.map(
23
+ const f = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = f.map(
30
24
  (e) => e.startsWith("/") ? e : `/${e}`
31
25
  ), i = r.startsWith("/") ? r : `/${r}`;
32
26
  a.some(
@@ -43,9 +37,9 @@ const y = () => {
43
37
  if (l) {
44
38
  const r = u(l).user.servicios.map((t) => t.url).filter((t) => !!t), a = m.pathname, i = r.map(
45
39
  (t) => t.startsWith("/") ? t : `/${t}`
46
- ), f = a.startsWith("/") ? a : `/${a}`;
40
+ ), d = a.startsWith("/") ? a : `/${a}`;
47
41
  i.some(
48
- (t) => f.startsWith(t)
42
+ (t) => d.startsWith(t)
49
43
  ) ? o(!0) : (o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
50
44
  } else
51
45
  o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s;
@@ -57,8 +51,8 @@ const y = () => {
57
51
  }
58
52
  };
59
53
  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;
54
+ }, []), k ? /* @__PURE__ */ p(_, {}) : null;
61
55
  };
62
56
  export {
63
- y as ProtectedRoute
57
+ W as ProtectedRoute
64
58
  };
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.3",
5
+ "version": "1.8.0-pre.4",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {