react-ecosistema-unp 1.8.0-pre.6 → 1.8.0-pre.8

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,36 +1,7 @@
1
- import { FinSesionService as i } from "../services/FinSesionService.js";
2
- import { y as a } from "../../index-BUe3EJDH.js";
3
- import { useState as c, useEffect as l } from "react";
4
- import { j as m } from "../../index-CuHybtft.js";
5
- const d = () => {
6
- const [o, r] = c(null), n = `${window.location.protocol}//${window.location.host}/`;
7
- return l(() => {
8
- const e = localStorage.getItem("access_token");
9
- if (e) {
10
- const t = m(e);
11
- r(t);
12
- }
13
- }, []), { FinSesion: () => {
14
- a.promise(
15
- new Promise(async (e, t) => {
16
- try {
17
- await i((o == null ? void 0 : o.user.username) || "", n), e(!0);
18
- } catch (s) {
19
- t(s);
20
- } finally {
21
- sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), setTimeout(() => {
22
- window.location.href = n;
23
- }, 1e3);
24
- }
25
- }),
26
- {
27
- pending: "Finalizando sesión...",
28
- success: "Sesión finalizada con éxito",
29
- error: "Error al finalizar la sesión"
30
- }
31
- );
32
- } };
33
- };
1
+ import "../services/FinSesionService.js";
2
+ import "../../index-BUe3EJDH.js";
3
+ import "react";
4
+ import { u as t } from "../../useFinalizarSesion-DXrrb8G5.js";
34
5
  export {
35
- d as useFinalizarSesion
6
+ t as useFinalizarSesion
36
7
  };
@@ -3,30 +3,29 @@ import { useState as d, useEffect as h } from "react";
3
3
  import { F as n, 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
- import { j as w } from "../../index-CuHybtft.js";
7
- import { N as U } from "../../NavDropdown-ei8eIwIE.js";
8
- import '../../assets/AppList.css';function b(s) {
6
+ import { N as w } from "../../NavDropdown-ei8eIwIE.js";
7
+ import '../../assets/AppList.css';function U(s) {
9
8
  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
9
  }
11
- const F = {
10
+ const b = {
12
11
  Usuario: /* @__PURE__ */ o(n, { size: 24, className: "icon-app-2" }),
13
12
  "Asesor(a) poblacional": /* @__PURE__ */ o(u, { size: 24, className: "icon-app-2" }),
14
13
  Radicador: /* @__PURE__ */ o(f, { size: 24, className: "icon-app-2" }),
15
14
  "Reparto poblacional": /* @__PURE__ */ o(v, { size: 24, className: "icon-app-2" }),
16
15
  Digitador: /* @__PURE__ */ o(z, { size: 24, className: "icon-app-2" })
17
- }, R = {
16
+ }, F = {
18
17
  Usuario: "Mi perfil",
19
18
  "Asesor(a) poblacional": "Asesoría",
20
19
  Radicador: "Radicación",
21
20
  "Reparto poblacional": "Reparto",
22
21
  Digitador: "Digitación"
23
- }, j = () => {
22
+ }, M = () => {
24
23
  const [s, l] = d([]), e = location.pathname, c = e.startsWith("/") ? e : `/${e}`;
25
24
  h(() => {
26
25
  const a = localStorage.getItem("auth_state");
27
26
  if (a)
28
27
  try {
29
- const i = w(a);
28
+ const i = JSON.parse(a);
30
29
  l(i.user.servicios);
31
30
  } catch (i) {
32
31
  console.error("Error al decodificar el token:", i);
@@ -37,16 +36,16 @@ const F = {
37
36
  window.location.href = i;
38
37
  };
39
38
  return /* @__PURE__ */ o(
40
- U,
39
+ w,
41
40
  {
42
- title: /* @__PURE__ */ o(b, { className: "icono-app" }),
41
+ title: /* @__PURE__ */ o(U, { className: "icono-app" }),
43
42
  align: "end",
44
43
  children: /* @__PURE__ */ o("div", { style: {
45
44
  fontWeight: "400",
46
45
  padding: "1rem"
47
46
  }, children: /* @__PURE__ */ r("div", { className: "grid-container", children: [
48
47
  s.filter((a) => !(a.url === "unp/ecosistema/usuario" && a.rol === "Usuario")).map(({ rol: a, url: i }) => {
49
- const p = F[a] || /* @__PURE__ */ o(N, { size: 24, className: "icon-app-2" }), m = R[a] || a;
48
+ const p = b[a] || /* @__PURE__ */ o(N, { size: 24, className: "icon-app-2" }), m = F[a] || a;
50
49
  return /* @__PURE__ */ r(
51
50
  "div",
52
51
  {
@@ -77,5 +76,5 @@ const F = {
77
76
  );
78
77
  };
79
78
  export {
80
- j as AppList
79
+ M as AppList
81
80
  };
@@ -1,10 +1,10 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { useFinalizarSesion as t } from "../../../auth/hooks/useFinalizarSesion.js";
2
+ import { u as t } from "../../../useFinalizarSesion-DXrrb8G5.js";
3
3
  import { y as i } from "../../../index-DDjnZyBf.js";
4
- import '../../../assets/LogoutButton.css';const a = () => {
4
+ import '../../../assets/LogoutButton.css';const m = () => {
5
5
  const { FinSesion: o } = t();
6
6
  return /* @__PURE__ */ r(i, { className: "icono-logout", onClick: o });
7
7
  };
8
8
  export {
9
- a as LogoutButton
9
+ m as LogoutButton
10
10
  };
@@ -1,8 +1,7 @@
1
1
  import { jsx as a, Fragment as g, jsxs as e } from "react/jsx-runtime";
2
2
  import { useState as o, useEffect as d } from "react";
3
3
  import { useNavigate as H } from "react-router-dom";
4
- import { j as u } from "../../index-CuHybtft.js";
5
- import { useFinalizarSesion as C } from "../../auth/hooks/useFinalizarSesion.js";
4
+ import { u as C, j as u } from "../../useFinalizarSesion-DXrrb8G5.js";
6
5
  import { urlBase as L, urlCertificadoLaboral as S } from "../../utils/Url.js";
7
6
  import "../../auth/contexts/AuthContex.js";
8
7
  import '../../assets/EcoModalStyles.css';import '../../assets/Modal.css';import '../../assets/ContenedorVentana.css';import '../../assets/IconoTooltip.css';import '../../assets/ItemsModal.css';import '../../assets/Paginador.css';import '../../assets/ContenidoModal.css';import '../../assets/Encabezado.css';import '../../assets/SeccionTarjetaLectura.css';import '../../assets/Logo.css';import '../../assets/TarjetaLectura.css';import '../../assets/ContenedorTarjeta.css';import '../../assets/Bootstrap.css';import '../../assets/Tarjeta.css';import '../../assets/UnpHistorico.css';import '../../assets/MenuLateral.css';/* empty css */
@@ -68,7 +67,7 @@ function G(t) {
68
67
  function W(t) {
69
68
  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
69
  }
71
- const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
70
+ const b1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
72
71
  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
72
  if (d(() => {
74
73
  const r = localStorage.getItem("access_token");
@@ -305,5 +304,5 @@ const z1 = ({ onToggle: t, isOpen: c, showConnectionStatus: x }) => {
305
304
  ] }) });
306
305
  };
307
306
  export {
308
- z1 as MenuLateral
307
+ b1 as MenuLateral
309
308
  };
@@ -0,0 +1,84 @@
1
+ import { FinSesionService as c } from "./auth/services/FinSesionService.js";
2
+ import { y as l } from "./index-BUe3EJDH.js";
3
+ import { useState as d, useEffect as u } from "react";
4
+ class s extends Error {
5
+ }
6
+ s.prototype.name = "InvalidTokenError";
7
+ function p(t) {
8
+ return decodeURIComponent(atob(t).replace(/(.)/g, (e, r) => {
9
+ let o = r.charCodeAt(0).toString(16).toUpperCase();
10
+ return o.length < 2 && (o = "0" + o), "%" + o;
11
+ }));
12
+ }
13
+ function f(t) {
14
+ let e = t.replace(/-/g, "+").replace(/_/g, "/");
15
+ switch (e.length % 4) {
16
+ case 0:
17
+ break;
18
+ case 2:
19
+ e += "==";
20
+ break;
21
+ case 3:
22
+ e += "=";
23
+ break;
24
+ default:
25
+ throw new Error("base64 string is not of the correct length");
26
+ }
27
+ try {
28
+ return p(e);
29
+ } catch {
30
+ return atob(e);
31
+ }
32
+ }
33
+ function m(t, e) {
34
+ if (typeof t != "string")
35
+ throw new s("Invalid token specified: must be a string");
36
+ e || (e = {});
37
+ const r = e.header === !0 ? 0 : 1, o = t.split(".")[r];
38
+ if (typeof o != "string")
39
+ throw new s(`Invalid token specified: missing part #${r + 1}`);
40
+ let n;
41
+ try {
42
+ n = f(o);
43
+ } catch (a) {
44
+ throw new s(`Invalid token specified: invalid base64 for part #${r + 1} (${a.message})`);
45
+ }
46
+ try {
47
+ return JSON.parse(n);
48
+ } catch (a) {
49
+ throw new s(`Invalid token specified: invalid json for part #${r + 1} (${a.message})`);
50
+ }
51
+ }
52
+ const k = () => {
53
+ const [t, e] = d(null), r = `${window.location.protocol}//${window.location.host}/`;
54
+ return u(() => {
55
+ const n = localStorage.getItem("access_token");
56
+ if (n) {
57
+ const a = m(n);
58
+ e(a);
59
+ }
60
+ }, []), { FinSesion: () => {
61
+ l.promise(
62
+ new Promise(async (n, a) => {
63
+ try {
64
+ await c((t == null ? void 0 : t.user.username) || "", r), n(!0);
65
+ } catch (i) {
66
+ a(i);
67
+ } finally {
68
+ sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), setTimeout(() => {
69
+ window.location.href = r;
70
+ }, 1e3);
71
+ }
72
+ }),
73
+ {
74
+ pending: "Finalizando sesión...",
75
+ success: "Sesión finalizada con éxito",
76
+ error: "Error al finalizar la sesión"
77
+ }
78
+ );
79
+ } };
80
+ };
81
+ export {
82
+ m as j,
83
+ k as u
84
+ };
@@ -1,32 +1,34 @@
1
- import { jsx as v } from "react/jsx-runtime";
2
- import { useState as p, useEffect as S } from "react";
3
- import { useLocation as I, Outlet as _ } from "react-router-dom";
4
- import { j as u } from "../../index-CuHybtft.js";
5
- const W = () => {
6
- const [k, o] = p(!1), m = I(), s = `${window.location.protocol}//${window.location.host}/`, n = `${window.location.host}`, w = async () => {
7
- if ((await fetch(`${s}api-auth/auth/refresh_token/`, {
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { useState as S, useEffect as v } from "react";
3
+ import { useLocation as p, Outlet as I } from "react-router-dom";
4
+ const T = () => {
5
+ const [k, o] = S(!1), h = p(), s = `${window.location.protocol}//${window.location.host}/`, c = `${window.location.host}`, w = async () => {
6
+ const l = await fetch(`${s}api-auth/auth/refresh_token/`, {
8
7
  method: "POST",
9
8
  headers: {
10
9
  "Content-Type": "application/json",
11
10
  Authorization: `Bearer ${localStorage.getItem("access_token")}`
12
11
  },
13
12
  credentials: "include"
14
- })).ok)
15
- return !0;
16
- throw new Error("Error al refrescar token de Microsoft");
13
+ });
14
+ if (l.ok) {
15
+ const r = (await l.json()).token;
16
+ return localStorage.setItem("access_token", r), !0;
17
+ } else
18
+ throw new Error("Error al refrescar token de Microsoft");
17
19
  };
18
- return S(() => {
19
- const h = async () => {
20
+ return v(() => {
21
+ const l = async () => {
20
22
  try {
21
23
  if (localStorage.getItem("access_token")) {
22
- const c = localStorage.getItem("auth_state");
23
- if (c) {
24
- const f = u(c).user.servicios.map((e) => e.url).filter((e) => !!e), r = m.pathname, a = f.map(
24
+ const r = localStorage.getItem("auth_state");
25
+ if (r) {
26
+ const f = JSON.parse(r).user.servicios.map((e) => e.url).filter((e) => !!e), a = h.pathname, n = f.map(
25
27
  (e) => e.startsWith("/") ? e : `/${e}`
26
- ), i = r.startsWith("/") ? r : `/${r}`;
27
- a.some(
28
- (e) => i.startsWith(e)
29
- ) ? o(!0) : (o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
28
+ ), m = a.startsWith("/") ? a : `/${a}`;
29
+ n.some(
30
+ (e) => m.startsWith(e)
31
+ ) ? o(!0) : (console.warn("No hay match con los roles del usuario"), o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
30
32
  } else
31
33
  o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s;
32
34
  } else
@@ -34,13 +36,13 @@ const W = () => {
34
36
  } catch {
35
37
  try {
36
38
  if (await w()) {
37
- const l = localStorage.getItem("auth_state");
38
- if (l) {
39
- const r = u(l).user.servicios.map((t) => t.url).filter((t) => !!t), a = m.pathname, i = r.map(
39
+ const i = localStorage.getItem("auth_state");
40
+ if (i) {
41
+ const a = JSON.parse(i).user.servicios.map((t) => t.url).filter((t) => !!t), n = h.pathname, m = a.map(
40
42
  (t) => t.startsWith("/") ? t : `/${t}`
41
- ), d = a.startsWith("/") ? a : `/${a}`;
42
- i.some(
43
- (t) => d.startsWith(t)
43
+ ), u = n.startsWith("/") ? n : `/${n}`;
44
+ m.some(
45
+ (t) => u.startsWith(t)
44
46
  ) ? o(!0) : (o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s);
45
47
  } else
46
48
  o(!1), sessionStorage.removeItem("user_token"), localStorage.removeItem("auth_state"), localStorage.removeItem("access_token"), window.location.href = s;
@@ -51,9 +53,9 @@ const W = () => {
51
53
  }
52
54
  }
53
55
  };
54
- 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));
55
- }, []), k ? /* @__PURE__ */ v(_, {}) : null;
56
+ c.includes("ecosistemadesarrollo") || c.includes("ecosistemapruebas") || c.includes("ecosistemaprov") || c.includes("ecosistema") ? l() : (console.warn("ProtectedRoute is disabled in the local development environment."), o(!0));
57
+ }, []), k ? /* @__PURE__ */ g(I, {}) : null;
56
58
  };
57
59
  export {
58
- W as ProtectedRoute
60
+ T as ProtectedRoute
59
61
  };
@@ -2,7 +2,6 @@ import { jsx as r } from "react/jsx-runtime";
2
2
  import { AuthProvider as t } from "../../auth/contexts/AuthContex.js";
3
3
  import "react";
4
4
  import "react-router-dom";
5
- import "../../index-CuHybtft.js";
6
5
  import '../../assets/EcoModalStyles.css';import '../../assets/Modal.css';import '../../assets/ContenedorVentana.css';import '../../assets/IconoTooltip.css';import '../../assets/ItemsModal.css';import '../../assets/Paginador.css';import '../../assets/ContenidoModal.css';import '../../assets/Encabezado.css';import '../../assets/SeccionTarjetaLectura.css';import '../../assets/Logo.css';import '../../assets/TarjetaLectura.css';import '../../assets/ContenedorTarjeta.css';import '../../assets/Bootstrap.css';import '../../assets/Tarjeta.css';import '../../assets/UnpHistorico.css';/* empty css */
7
6
  /* empty css */
8
7
  /* empty css */
@@ -25,7 +24,7 @@ import "../../index-BrykDZgK.js";
25
24
  import "../../Animacion-ThNL9iiY.js";
26
25
  import "../../index-BUe3EJDH.js";
27
26
  import { WebSocketProvider as i } from "../websocket-manager/WebSocketContext.js";
28
- const B = ({ children: o }) => /* @__PURE__ */ r(t, { children: /* @__PURE__ */ r(i, { children: o }) });
27
+ const z = ({ children: o }) => /* @__PURE__ */ r(t, { children: /* @__PURE__ */ r(i, { children: o }) });
29
28
  export {
30
- B as EcoProvider
29
+ z as EcoProvider
31
30
  };
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.6",
5
+ "version": "1.8.0-pre.8",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
@@ -1,51 +0,0 @@
1
- class o extends Error {
2
- }
3
- o.prototype.name = "InvalidTokenError";
4
- function i(t) {
5
- return decodeURIComponent(atob(t).replace(/(.)/g, (e, r) => {
6
- let n = r.charCodeAt(0).toString(16).toUpperCase();
7
- return n.length < 2 && (n = "0" + n), "%" + n;
8
- }));
9
- }
10
- function s(t) {
11
- let e = t.replace(/-/g, "+").replace(/_/g, "/");
12
- switch (e.length % 4) {
13
- case 0:
14
- break;
15
- case 2:
16
- e += "==";
17
- break;
18
- case 3:
19
- e += "=";
20
- break;
21
- default:
22
- throw new Error("base64 string is not of the correct length");
23
- }
24
- try {
25
- return i(e);
26
- } catch {
27
- return atob(e);
28
- }
29
- }
30
- function d(t, e) {
31
- if (typeof t != "string")
32
- throw new o("Invalid token specified: must be a string");
33
- e || (e = {});
34
- const r = e.header === !0 ? 0 : 1, n = t.split(".")[r];
35
- if (typeof n != "string")
36
- throw new o(`Invalid token specified: missing part #${r + 1}`);
37
- let c;
38
- try {
39
- c = s(n);
40
- } catch (a) {
41
- throw new o(`Invalid token specified: invalid base64 for part #${r + 1} (${a.message})`);
42
- }
43
- try {
44
- return JSON.parse(c);
45
- } catch (a) {
46
- throw new o(`Invalid token specified: invalid json for part #${r + 1} (${a.message})`);
47
- }
48
- }
49
- export {
50
- d as j
51
- };