react-ecosistema-unp 1.6.4 → 1.6.9
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/lib/utils.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ export { useFormValidation } from './utils/validations/useFormValidation.js';
|
|
|
6
6
|
export { IsInvalidStyles } from './utils/validations/useFormValidation.js';
|
|
7
7
|
export { CaptchaEcosistema } from './utils/captcha/CaptchaEcosistema.js';
|
|
8
8
|
export { useFetchData } from './utils/fetch-data/useFetchData.js';
|
|
9
|
-
export { default as fetchInterceptor } from './utils/components/fetchInterceptor.js';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m, useEffect as p } from "react";
|
|
3
3
|
import { useNavigate as w, useLocation as u, Outlet as k } from "react-router-dom";
|
|
4
4
|
import { j as v } from "../../index-CuHybtft.js";
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const [i, e] = h(!1), r = w(), c = u(), o = `${window.location.protocol}//${window.location.host}/`;
|
|
5
|
+
const V = () => {
|
|
6
|
+
const [i, e] = m(!1), r = w(), c = u(), o = `${window.location.protocol}//${window.location.host}/`;
|
|
8
7
|
return p(() => {
|
|
9
8
|
(async () => {
|
|
10
9
|
try {
|
|
@@ -35,8 +34,8 @@ const W = () => {
|
|
|
35
34
|
} finally {
|
|
36
35
|
}
|
|
37
36
|
})();
|
|
38
|
-
}, [r]), i ? /* @__PURE__ */
|
|
37
|
+
}, [r]), i ? /* @__PURE__ */ h(k, {}) : null;
|
|
39
38
|
};
|
|
40
39
|
export {
|
|
41
|
-
|
|
40
|
+
V as ProtectedRoute
|
|
42
41
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { useState as i, useEffect as s } from "react";
|
|
3
3
|
import { useNavigate as l, Outlet as c } from "react-router-dom";
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const [e, r] = i(!1), n = l(), o = `${window.location.protocol}//${window.location.host}/`;
|
|
4
|
+
const h = () => {
|
|
5
|
+
const [e, n] = i(!1), r = l(), o = `${window.location.protocol}//${window.location.host}/`;
|
|
7
6
|
return s(() => {
|
|
8
7
|
(async () => {
|
|
9
8
|
try {
|
|
@@ -17,7 +16,7 @@ const w = () => {
|
|
|
17
16
|
credentials: "include"
|
|
18
17
|
}
|
|
19
18
|
)).ok)
|
|
20
|
-
|
|
19
|
+
n(!0);
|
|
21
20
|
else
|
|
22
21
|
return window.location.href = o;
|
|
23
22
|
} catch (t) {
|
|
@@ -25,8 +24,8 @@ const w = () => {
|
|
|
25
24
|
} finally {
|
|
26
25
|
}
|
|
27
26
|
})();
|
|
28
|
-
}, [
|
|
27
|
+
}, [r]), e ? /* @__PURE__ */ a(c, {}) : null;
|
|
29
28
|
};
|
|
30
29
|
export {
|
|
31
|
-
|
|
30
|
+
h as UserRoute
|
|
32
31
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { useNavigate as m } from "react-router-dom";
|
|
2
1
|
window.originalFetch = window.fetch.bind(window);
|
|
3
2
|
let l = !1, h = null;
|
|
4
3
|
const i = [];
|
|
5
|
-
async function
|
|
4
|
+
async function p() {
|
|
6
5
|
const e = `${`${window.location.protocol}//${window.location.host}/`}api-auth/auth/refresh_token/`, t = await window.originalFetch(e, {
|
|
7
6
|
method: "POST",
|
|
8
7
|
credentials: "include"
|
|
@@ -22,36 +21,36 @@ window.fetch = async function(o, e) {
|
|
|
22
21
|
...u ? { Authorization: u } : {}
|
|
23
22
|
};
|
|
24
23
|
try {
|
|
25
|
-
const
|
|
24
|
+
const c = `${window.location.protocol}//${window.location.host}/`, r = await window.originalFetch(o, e);
|
|
26
25
|
if (r.status !== 401) {
|
|
27
26
|
const n = await r.clone().text();
|
|
28
27
|
if (!n.includes("Signature has expired"))
|
|
29
28
|
return r;
|
|
30
29
|
if (n.includes("Invalid or expired token"))
|
|
31
30
|
return sessionStorage.removeItem("user_token"), setTimeout(() => {
|
|
32
|
-
|
|
31
|
+
window.location.href = c;
|
|
33
32
|
}, 1e3), r;
|
|
34
33
|
}
|
|
35
34
|
return new Promise((w, n) => {
|
|
36
|
-
i.push({ input: o, init: e, resolve: w, reject: n }), l || (l = !0, h =
|
|
37
|
-
i.forEach(({ input:
|
|
38
|
-
const
|
|
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 = {
|
|
39
38
|
...s,
|
|
40
39
|
headers: { ...s.headers, Authorization: sessionStorage.getItem("user_token") }
|
|
41
40
|
};
|
|
42
|
-
window.originalFetch(
|
|
41
|
+
window.originalFetch(a, g).then(d).catch(f);
|
|
43
42
|
});
|
|
44
|
-
}).catch((
|
|
45
|
-
i.forEach(({ reject: s }) => s(
|
|
43
|
+
}).catch((a) => {
|
|
44
|
+
i.forEach(({ reject: s }) => s(a));
|
|
46
45
|
}).finally(() => {
|
|
47
46
|
i.length = 0, l = !1, h = null;
|
|
48
47
|
}));
|
|
49
48
|
});
|
|
50
|
-
} catch (
|
|
51
|
-
return Promise.reject(
|
|
49
|
+
} catch (c) {
|
|
50
|
+
return Promise.reject(c);
|
|
52
51
|
}
|
|
53
52
|
};
|
|
54
|
-
const
|
|
53
|
+
const k = {};
|
|
55
54
|
export {
|
|
56
|
-
|
|
55
|
+
k as default
|
|
57
56
|
};
|
package/dist/utils.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { AuthProvider as t } from "./auth/contexts/AuthContex.js";
|
|
2
|
-
import { ProtectedRoute as
|
|
3
|
-
import { UserRoute as
|
|
4
|
-
import { UnpHistorico as
|
|
5
|
-
import { IsInvalidStyles as
|
|
2
|
+
import { ProtectedRoute as m } from "./utils/components/ProtectedRoute.js";
|
|
3
|
+
import { UserRoute as a } from "./utils/components/UserRoute.js";
|
|
4
|
+
import { UnpHistorico as f } from "./utils/unp-historico/UnpHistorico.js";
|
|
5
|
+
import { IsInvalidStyles as x, useFormValidation as c } from "./utils/validations/useFormValidation.js";
|
|
6
6
|
import { CaptchaEcosistema as d } from "./utils/captcha/CaptchaEcosistema.js";
|
|
7
7
|
import { useFetchData as l } from "./utils/fetch-data/useFetchData.js";
|
|
8
|
-
import { default as I } from "./utils/components/fetchInterceptor.js";
|
|
9
8
|
export {
|
|
10
9
|
t as AuthProvider,
|
|
11
10
|
d as CaptchaEcosistema,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
I as fetchInterceptor,
|
|
11
|
+
x as IsInvalidStyles,
|
|
12
|
+
m as ProtectedRoute,
|
|
13
|
+
f as UnpHistorico,
|
|
14
|
+
a as UserRoute,
|
|
17
15
|
l as useFetchData,
|
|
18
|
-
|
|
16
|
+
c as useFormValidation
|
|
19
17
|
};
|