react-ecosistema-unp 1.7.0-pre.4 → 1.7.0-pre.5
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.
|
@@ -2,8 +2,17 @@ import { default as React, ReactNode } from 'react';
|
|
|
2
2
|
export type ConnectionStatus = 'connected' | 'connecting' | 'disconnected';
|
|
3
3
|
interface WebSocketContextType {
|
|
4
4
|
connectionStatus: ConnectionStatus;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated función experimental, no se recomienda su uso.
|
|
7
|
+
*/
|
|
5
8
|
connectWebSocket: (url: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated función experimental, no se recomienda su uso.
|
|
11
|
+
*/
|
|
6
12
|
disconnectWebSocket: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated función experimental, no se recomienda su uso.
|
|
15
|
+
*/
|
|
7
16
|
sendWebSocketMessage: (data: any) => void;
|
|
8
17
|
}
|
|
9
18
|
export declare const WebSocketProvider: React.FC<{
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useNavigate as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as u } from "react";
|
|
3
|
+
import { useNavigate as p, useLocation as w, Outlet as k } from "react-router-dom";
|
|
4
4
|
import { j as v } from "../../index-CuHybtft.js";
|
|
5
|
-
const
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
5
|
+
const $ = () => {
|
|
6
|
+
const [r, t] = h(!1), i = p(), c = w(), e = `${window.location.protocol}//${window.location.host}/`;
|
|
7
|
+
return u(() => {
|
|
8
8
|
(async () => {
|
|
9
9
|
try {
|
|
10
10
|
if ((await fetch(
|
|
11
|
-
`${
|
|
11
|
+
`${e}api-auth/auth/validate_jwt/`,
|
|
12
12
|
{
|
|
13
13
|
method: "POST",
|
|
14
14
|
headers: {
|
|
@@ -17,25 +17,24 @@ const V = () => {
|
|
|
17
17
|
credentials: "include"
|
|
18
18
|
}
|
|
19
19
|
)).ok) {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const l = v(
|
|
23
|
-
(
|
|
24
|
-
),
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
) ?
|
|
20
|
+
const a = sessionStorage.getItem("user_token");
|
|
21
|
+
if (a) {
|
|
22
|
+
const l = v(a).datos_basicos.servicios.map((o) => o.url).filter((o) => !!o), s = c.pathname, m = l.map(
|
|
23
|
+
(o) => o.startsWith("/") ? o : `/${o}`
|
|
24
|
+
), d = s.startsWith("/") ? s : `/${s}`;
|
|
25
|
+
m.some(
|
|
26
|
+
(o) => d.startsWith(o)
|
|
27
|
+
) ? t(!0) : (t(!1), sessionStorage.removeItem("user_token"), window.location.href = e);
|
|
28
28
|
} else
|
|
29
|
-
|
|
29
|
+
t(!1), sessionStorage.removeItem("user_token"), window.location.href = e;
|
|
30
30
|
} else
|
|
31
|
-
window.location.href =
|
|
32
|
-
} catch (
|
|
33
|
-
console.error("Validation error:",
|
|
34
|
-
} finally {
|
|
31
|
+
sessionStorage.removeItem("user_token"), window.location.href = e;
|
|
32
|
+
} catch (n) {
|
|
33
|
+
console.error("Validation error:", n), sessionStorage.removeItem("user_token"), window.location.href = e;
|
|
35
34
|
}
|
|
36
35
|
})();
|
|
37
|
-
}, [
|
|
36
|
+
}, [i]), r ? /* @__PURE__ */ f(k, {}) : null;
|
|
38
37
|
};
|
|
39
38
|
export {
|
|
40
|
-
|
|
39
|
+
$ as ProtectedRoute
|
|
41
40
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as a, useEffect as i } from "react";
|
|
3
3
|
import { useNavigate as l, Outlet as c } from "react-router-dom";
|
|
4
|
-
const
|
|
5
|
-
const [
|
|
6
|
-
return
|
|
4
|
+
const p = () => {
|
|
5
|
+
const [t, r] = a(!1), n = l(), e = `${window.location.protocol}//${window.location.host}/`;
|
|
6
|
+
return i(() => {
|
|
7
7
|
(async () => {
|
|
8
8
|
try {
|
|
9
9
|
if ((await fetch(
|
|
10
|
-
`${
|
|
10
|
+
`${e}/auth/validate/`,
|
|
11
11
|
{
|
|
12
12
|
method: "POST",
|
|
13
13
|
headers: {
|
|
@@ -16,16 +16,15 @@ const h = () => {
|
|
|
16
16
|
credentials: "include"
|
|
17
17
|
}
|
|
18
18
|
)).ok)
|
|
19
|
-
|
|
19
|
+
r(!0);
|
|
20
20
|
else
|
|
21
|
-
return window.location.href =
|
|
22
|
-
} catch (
|
|
23
|
-
return console.error("Validation error:",
|
|
24
|
-
} finally {
|
|
21
|
+
return sessionStorage.removeItem("user_token"), window.location.href = e;
|
|
22
|
+
} catch (o) {
|
|
23
|
+
return console.error("Validation error:", o), sessionStorage.removeItem("user_token"), window.location.href = e;
|
|
25
24
|
}
|
|
26
25
|
})();
|
|
27
|
-
}, [
|
|
26
|
+
}, [n]), t ? /* @__PURE__ */ s(c, {}) : null;
|
|
28
27
|
};
|
|
29
28
|
export {
|
|
30
|
-
|
|
29
|
+
p as UserRoute
|
|
31
30
|
};
|