react-ecosistema-unp 1.8.0-pre.9 → 1.9.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.
- package/dist/auth/hooks/useFinalizarSesion.js +33 -5
- package/dist/lib/utils/fingerprint/fingerprintService.d.ts +27 -0
- package/dist/shared/iconos-sistema/logout-button/LogoutButton.js +3 -3
- package/dist/shared/menu-lateral/MenuLateral.js +46 -46
- package/dist/utils/components/ProtectedRoute.js +38 -33
- package/dist/utils/components/UserRoute.js +27 -25
- package/dist/utils/fingerprint/fingerprintService.js +1749 -0
- package/package.json +2 -1
- package/dist/useFinalizarSesion-DXrrb8G5.js +0 -84
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.
|
|
5
|
+
"version": "1.9.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"react-router-dom": ">=6.0.0 <=8.0.0"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
+
"@fingerprintjs/fingerprintjs": "^5.0.1",
|
|
70
71
|
"@marsidev/react-turnstile": "^1.1.0",
|
|
71
72
|
"bootstrap": "^5.3.3",
|
|
72
73
|
"jwt-decode": "^4.0.0",
|
|
@@ -1,84 +0,0 @@
|
|
|
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
|
-
};
|