@odynn/awayz-core 0.2.16 → 0.2.17
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,32 +1,32 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as U, E as r, a as o, b as v } from "../../AccountService--d4c37gO.js";
|
|
2
2
|
import { useState as E, useCallback as R, useEffect as y } from "react";
|
|
3
3
|
import { EAuthFlow as S } from "../../types/EAuthFlow.js";
|
|
4
|
-
import { awayzClient as
|
|
5
|
-
const
|
|
6
|
-
var f,
|
|
7
|
-
let c = "",
|
|
8
|
-
typeof t == "string" ? c = t : t instanceof
|
|
4
|
+
import { awayzClient as A } from "../../configs/awayzClient.js";
|
|
5
|
+
const H = (s, t) => {
|
|
6
|
+
var f, m;
|
|
7
|
+
let c = "", d = t;
|
|
8
|
+
typeof t == "string" ? c = t : t instanceof U ? (c = t.message, d = {
|
|
9
9
|
message: t.message,
|
|
10
10
|
cause: t.cause,
|
|
11
11
|
status: t.status,
|
|
12
12
|
data: (f = t == null ? void 0 : t.response) == null ? void 0 : f.data
|
|
13
|
-
}) : c = t.message, (
|
|
13
|
+
}) : c = t.message, (m = window.parent) == null || m.postMessage(
|
|
14
14
|
{
|
|
15
15
|
type: "auth_error",
|
|
16
|
-
details: { message: c, action: s, info:
|
|
16
|
+
details: { message: c, action: s, info: d }
|
|
17
17
|
},
|
|
18
18
|
"*"
|
|
19
19
|
);
|
|
20
20
|
}, V = (s) => {
|
|
21
|
-
const [t, c] = E(!0), [
|
|
21
|
+
const [t, c] = E(!0), [d, f] = E(!1), [m, T] = E(), [O, k] = E(), [I, K] = E([]), w = R(
|
|
22
22
|
async (a) => {
|
|
23
|
-
s != null && s.onSuccess && (s == null || s.onSuccess(a)), s != null && s.onSuccessAsync && await (s == null ? void 0 : s.onSuccessAsync(a)), c(!1), f(!0), T(a.token), k(a.user);
|
|
23
|
+
s != null && s.onSuccess && (s == null || s.onSuccess(a)), s != null && s.onSuccessAsync && await (s == null ? void 0 : s.onSuccessAsync(a)), c(!1), f(!0), T(a.token), k(a.user), A.invalidateQueries();
|
|
24
24
|
},
|
|
25
25
|
[s]
|
|
26
26
|
), i = R(
|
|
27
27
|
async (a, e) => {
|
|
28
28
|
if (s.authFlow !== S.POST_MESSAGE)
|
|
29
|
-
return
|
|
29
|
+
return H(e ?? "exchange_token", a);
|
|
30
30
|
s != null && s.onError && (s == null || s.onError(a)), s != null && s.onErrorAsync && await (s == null ? void 0 : s.onErrorAsync(a)), c(!1);
|
|
31
31
|
},
|
|
32
32
|
[s]
|
|
@@ -48,10 +48,10 @@ const M = (s, t) => {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
l == null || l.forEach(
|
|
51
|
-
(
|
|
51
|
+
(_) => window.parent.postMessage(
|
|
52
52
|
{
|
|
53
53
|
type: "request_limit",
|
|
54
|
-
limit:
|
|
54
|
+
limit: _
|
|
55
55
|
},
|
|
56
56
|
"*"
|
|
57
57
|
)
|
|
@@ -61,10 +61,10 @@ const M = (s, t) => {
|
|
|
61
61
|
} finally {
|
|
62
62
|
c(!1);
|
|
63
63
|
}
|
|
64
|
-
},
|
|
64
|
+
}, N = async () => {
|
|
65
65
|
try {
|
|
66
|
-
const { success: a, data: e } = await
|
|
67
|
-
queryKey: [
|
|
66
|
+
const { success: a, data: e } = await A.ensureQueryData({
|
|
67
|
+
queryKey: [v.CHECK_USER],
|
|
68
68
|
queryFn: o.checkUser
|
|
69
69
|
});
|
|
70
70
|
if (!a) {
|
|
@@ -84,14 +84,14 @@ const M = (s, t) => {
|
|
|
84
84
|
y(() => {
|
|
85
85
|
if (s.authFlow !== S.STANDARD) return;
|
|
86
86
|
const a = localStorage.getItem(r.TOKEN), e = localStorage.getItem(r.REFRESH_TOKEN);
|
|
87
|
-
a && e ?
|
|
87
|
+
a && e ? N() : c(!1);
|
|
88
88
|
}, []);
|
|
89
|
-
const
|
|
89
|
+
const F = async () => {
|
|
90
90
|
const a = await o.getRegions();
|
|
91
|
-
|
|
91
|
+
K(a);
|
|
92
92
|
};
|
|
93
93
|
return y(() => {
|
|
94
|
-
|
|
94
|
+
F();
|
|
95
95
|
}, []), y(() => {
|
|
96
96
|
if (s.authFlow !== S.QUERY) return;
|
|
97
97
|
const e = new URLSearchParams(window.location.search).get(r.TOKEN);
|
|
@@ -135,10 +135,10 @@ const M = (s, t) => {
|
|
|
135
135
|
};
|
|
136
136
|
}, []), {
|
|
137
137
|
isAuthenticating: t,
|
|
138
|
-
isAuthenticated:
|
|
139
|
-
token:
|
|
140
|
-
user:
|
|
141
|
-
supportedRegions:
|
|
138
|
+
isAuthenticated: d,
|
|
139
|
+
token: m,
|
|
140
|
+
user: O,
|
|
141
|
+
supportedRegions: I,
|
|
142
142
|
signIn: async (a) => {
|
|
143
143
|
var n;
|
|
144
144
|
const e = await o.login(a);
|
|
@@ -171,6 +171,6 @@ const M = (s, t) => {
|
|
|
171
171
|
};
|
|
172
172
|
};
|
|
173
173
|
export {
|
|
174
|
-
|
|
174
|
+
H as authFailurePostMessage,
|
|
175
175
|
V as useAwayzAuth
|
|
176
176
|
};
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import { ISearchLimit } from '../services/account/AccountServices.types';
|
|
2
|
-
export declare const useSearchLimit: () => [ISearchLimit, ISearchLimit] | [undefined, undefined];
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"number_of_calls": 1,
|
|
11
|
-
"remaining_calls": 4
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"search_type": "Hotel",
|
|
15
|
-
"subscription": "free",
|
|
16
|
-
"is_admin": false,
|
|
17
|
-
"search_limit": 5,
|
|
18
|
-
"number_of_calls": 1,
|
|
19
|
-
"remaining_calls": 4
|
|
20
|
-
}
|
|
21
|
-
],
|
|
3
|
+
* @description
|
|
4
|
+
* useSearchLimit is a custom hook that fetches the search limits for Flight and Hotel searches.
|
|
5
|
+
* The hook returns an array of two ISearchLimit objects, one for Flights and one for Hotels.
|
|
6
|
+
*
|
|
7
|
+
* @returns [FlightSearchLimit, HotelSearchLimit]
|
|
8
|
+
* @returns [undefined, undefined] if the data is not available
|
|
22
9
|
*/
|
|
10
|
+
export declare const useSearchLimit: () => [ISearchLimit, ISearchLimit] | [undefined, undefined];
|