@m4l/core 2.0.28 → 2.0.29
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/contexts/AuthContext/AuthContext.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAG,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAMtE,QAAA,MAAM,WAAW,oDAAiD,CAAC;AAEnE;;GAEG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AuthContext.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/contexts/AuthContext/AuthContext.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAG,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAMtE,QAAA,MAAM,WAAW,oDAAiD,CAAC;AAEnE;;GAEG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,oDAoI7C;AACD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { jsx as U } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { createContext as _, useReducer as w, useEffect as p, useCallback as
|
|
3
|
-
import { useEnvironment as
|
|
4
|
-
import { useHostTools as
|
|
5
|
-
import { useLocalStorageWithListener as
|
|
6
|
-
import { useNetwork as
|
|
2
|
+
import { createContext as _, useReducer as w, useEffect as p, useCallback as l } from "react";
|
|
3
|
+
import { useEnvironment as z } from "../../hooks/useEnvironment/index.js";
|
|
4
|
+
import { useHostTools as A } from "../../hooks/useHostTools/index.js";
|
|
5
|
+
import { useLocalStorageWithListener as I } from "../../hooks/useLocalStorageWithListener/index.js";
|
|
6
|
+
import { useNetwork as L } from "../../hooks/useNetwork/index.js";
|
|
7
7
|
import { initialState as f, EnumTypes as s } from "./constants.js";
|
|
8
|
-
import { getLocalStorage as
|
|
9
|
-
import { setLocalStorage as
|
|
8
|
+
import { getLocalStorage as P } from "../../utils/getLocalStorage/index.js";
|
|
9
|
+
import { setLocalStorage as c } from "../../utils/setLocalStorage/index.js";
|
|
10
10
|
import "axios";
|
|
11
11
|
import "qs";
|
|
12
12
|
import "camelcase-keys";
|
|
13
13
|
import "snakecase-keys";
|
|
14
|
-
import { EmmitEvents as
|
|
15
|
-
import { JWTReducer as
|
|
16
|
-
const
|
|
17
|
-
function Q(
|
|
18
|
-
const { children:
|
|
14
|
+
import { EmmitEvents as x } from "../../types/index.js";
|
|
15
|
+
import { JWTReducer as N } from "./helpers.js";
|
|
16
|
+
const k = _(null);
|
|
17
|
+
function Q(g) {
|
|
18
|
+
const { children: h, isMicroFrontEnd: i = !1, loggedUser: m } = g, [T, r] = w(N, i ? { ...f, user: m, isAuthenticated: !0, isInitialized: !0 } : f), { events_add_listener: E } = A(), { networkOperation: t } = L(), { domain_token: d } = z(), [y, a] = I(
|
|
19
19
|
// Variable para saber si ha cambiado la session en otro navegador
|
|
20
20
|
"vSession",
|
|
21
21
|
(/* @__PURE__ */ new Date()).getTime() + ""
|
|
22
22
|
);
|
|
23
23
|
p(() => {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const e = async () => {
|
|
25
|
+
console.log("*******+initialize"), t({
|
|
26
26
|
method: "GET",
|
|
27
27
|
endPoint: "auth/login",
|
|
28
28
|
parms: { user_data: !0 },
|
|
29
29
|
checkUnAuthorized: !1,
|
|
30
30
|
responseToCamelCase: !0
|
|
31
31
|
}).then((o) => {
|
|
32
|
-
|
|
32
|
+
console.log("*******+initialize success"), r({
|
|
33
33
|
type: s.Initial,
|
|
34
34
|
payload: {
|
|
35
35
|
isAuthenticated: !0,
|
|
36
36
|
user: o.user
|
|
37
37
|
}
|
|
38
|
-
}),
|
|
38
|
+
}), P("userData", {
|
|
39
39
|
email: o.user.email,
|
|
40
40
|
remember: !0
|
|
41
|
-
})?.email !== o.user.email &&
|
|
41
|
+
})?.email !== o.user.email && c("userData", { email: o.user.email }, !0);
|
|
42
42
|
}).catch(() => {
|
|
43
|
-
|
|
43
|
+
console.log("initialize error"), r({
|
|
44
44
|
type: s.Initial,
|
|
45
45
|
payload: {
|
|
46
46
|
isAuthenticated: !1,
|
|
@@ -49,50 +49,50 @@ function Q(h) {
|
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
const D =
|
|
55
|
-
await
|
|
52
|
+
i || e();
|
|
53
|
+
}, [t, y, i, m]);
|
|
54
|
+
const D = l(async (e, o, n) => {
|
|
55
|
+
await t({
|
|
56
56
|
endPoint: "auth/login",
|
|
57
57
|
method: "POST",
|
|
58
58
|
data: {
|
|
59
|
-
email:
|
|
59
|
+
email: e,
|
|
60
60
|
password: o,
|
|
61
61
|
domain_token: d
|
|
62
62
|
},
|
|
63
63
|
responseToCamelCase: !0
|
|
64
64
|
}).then((v) => {
|
|
65
65
|
const C = v.data;
|
|
66
|
-
n ?
|
|
66
|
+
n ? c("userData", { email: e, remember: n }) : c("userData", { email: "", remember: n }), r({
|
|
67
67
|
type: s.Login,
|
|
68
68
|
payload: {
|
|
69
69
|
user: C
|
|
70
70
|
}
|
|
71
71
|
}), a((/* @__PURE__ */ new Date()).getTime() + "");
|
|
72
72
|
});
|
|
73
|
-
}, [
|
|
74
|
-
|
|
73
|
+
}, [t, a, d]), u = l(async (e) => {
|
|
74
|
+
e && await t({
|
|
75
75
|
endPoint: "auth/logout",
|
|
76
76
|
method: "POST"
|
|
77
|
-
}),
|
|
78
|
-
}, [
|
|
77
|
+
}), r({ type: s.Logout }), a((/* @__PURE__ */ new Date()).getTime() + "");
|
|
78
|
+
}, [t, a]), S = l(() => {
|
|
79
79
|
u(!1);
|
|
80
80
|
}, [u]);
|
|
81
81
|
return p(function() {
|
|
82
|
-
|
|
83
|
-
}, [
|
|
84
|
-
|
|
82
|
+
i || E(x.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, S);
|
|
83
|
+
}, [i]), /* @__PURE__ */ U(
|
|
84
|
+
k.Provider,
|
|
85
85
|
{
|
|
86
86
|
value: {
|
|
87
87
|
...T,
|
|
88
88
|
login: D,
|
|
89
89
|
logout: u
|
|
90
90
|
},
|
|
91
|
-
children:
|
|
91
|
+
children: h
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
export {
|
|
96
|
-
|
|
96
|
+
k as AuthContext,
|
|
97
97
|
Q as AuthProvider
|
|
98
98
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
function
|
|
1
|
+
function u(e, t) {
|
|
2
2
|
try {
|
|
3
3
|
const n = new Function(...Object.keys(e), `return \`${t}\``)(...Object.values(e));
|
|
4
4
|
return String(n).replace(/`/g, "");
|
|
5
|
-
} catch
|
|
6
|
-
return
|
|
5
|
+
} catch {
|
|
6
|
+
return "";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
u as evaluateWithContext
|
|
11
11
|
};
|