@odynn/awayz-core 0.2.10 → 0.2.11
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,8 +1,8 @@
|
|
|
1
|
-
import { A as _, E as n, a as o, b as
|
|
1
|
+
import { A as _, E as n, a as o, b as q, d as L } from "../../AccountService-CKQ3VzVx.js";
|
|
2
2
|
import { useState as m, useCallback as R, useEffect as w } from "react";
|
|
3
3
|
import { EAuthFlow as S } from "../../types/EAuthFlow.js";
|
|
4
|
-
import { awayzClient as
|
|
5
|
-
const
|
|
4
|
+
import { awayzClient as U } from "../../configs/awayzClient.js";
|
|
5
|
+
const v = (t, a) => {
|
|
6
6
|
var f, d;
|
|
7
7
|
let c = "", E = a;
|
|
8
8
|
typeof a == "string" ? c = a : a instanceof _ ? (c = a.message, E = {
|
|
@@ -18,7 +18,7 @@ const L = (t, a) => {
|
|
|
18
18
|
"*"
|
|
19
19
|
);
|
|
20
20
|
}, J = (t) => {
|
|
21
|
-
const [a, c] = m(!0), [E, f] = m(!1), [d, T] = m(), [
|
|
21
|
+
const [a, c] = m(!0), [E, f] = m(!1), [d, T] = m(), [A, k] = m(), [O, K] = m([]), y = R(
|
|
22
22
|
async (s) => {
|
|
23
23
|
t != null && t.onSuccess && (t == null || t.onSuccess(s)), t != null && t.onSuccessAsync && await (t == null ? void 0 : t.onSuccessAsync(s)), c(!1), f(!0), T(s.token), k(s.user);
|
|
24
24
|
},
|
|
@@ -26,7 +26,7 @@ const L = (t, a) => {
|
|
|
26
26
|
), i = R(
|
|
27
27
|
async (s, e) => {
|
|
28
28
|
if (t.authFlow !== S.POST_MESSAGE)
|
|
29
|
-
return
|
|
29
|
+
return v(e ?? "exchange_token", s);
|
|
30
30
|
t != null && t.onError && (t == null || t.onError(s)), t != null && t.onErrorAsync && await (t == null ? void 0 : t.onErrorAsync(s)), c(!1);
|
|
31
31
|
},
|
|
32
32
|
[t]
|
|
@@ -63,8 +63,8 @@ const L = (t, a) => {
|
|
|
63
63
|
}
|
|
64
64
|
}, I = async () => {
|
|
65
65
|
try {
|
|
66
|
-
const { success: s, data: e } = await
|
|
67
|
-
queryKey: [
|
|
66
|
+
const { success: s, data: e } = await U.ensureQueryData({
|
|
67
|
+
queryKey: [q.CHECK_USER],
|
|
68
68
|
queryFn: o.checkUser
|
|
69
69
|
});
|
|
70
70
|
if (!s) {
|
|
@@ -82,7 +82,7 @@ const L = (t, a) => {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
w(() => {
|
|
85
|
-
if (t.authFlow !== S.
|
|
85
|
+
if (t.authFlow !== S.STANDARD) return;
|
|
86
86
|
const s = localStorage.getItem(n.TOKEN), e = localStorage.getItem(n.REFRESH_TOKEN);
|
|
87
87
|
s && e ? I() : c(!1);
|
|
88
88
|
}, []);
|
|
@@ -137,8 +137,8 @@ const L = (t, a) => {
|
|
|
137
137
|
isAuthenticating: a,
|
|
138
138
|
isAuthenticated: E,
|
|
139
139
|
token: d,
|
|
140
|
-
user:
|
|
141
|
-
supportedRegions:
|
|
140
|
+
user: A,
|
|
141
|
+
supportedRegions: O,
|
|
142
142
|
signIn: async (s) => {
|
|
143
143
|
var r;
|
|
144
144
|
const e = await o.login(s);
|
|
@@ -174,11 +174,11 @@ const L = (t, a) => {
|
|
|
174
174
|
console.error({ reqLimitError: e });
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
|
-
return
|
|
177
|
+
return L(s);
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
180
|
};
|
|
181
181
|
export {
|
|
182
|
-
|
|
182
|
+
v as authFailurePostMessage,
|
|
183
183
|
J as useAwayzAuth
|
|
184
184
|
};
|