@odynn/awayz-core 0.2.12 → 0.2.13
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/{AccountService-CKYH_7VT.js → AccountService-Dt2-k7CN.js} +5 -5
- package/dist/components/CashValue/CashValue.js +1 -1
- package/dist/context/AwayzContext.js +0 -2
- package/dist/hooks/useAwayzAuth/useAwayzAuth.js +72 -80
- package/dist/hooks/useSearchLimit.js +22 -0
- package/dist/lib/context/AwayzContext.d.ts +1 -2
- package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.d.ts +1 -2
- package/dist/lib/hooks/useSearchLimit.d.ts +22 -0
- package/dist/main.js +1 -1
- package/dist/providers/AwayzProvider.js +1 -1
- package/dist/services/account/AccountService.js +1 -1
- package/dist/services/currency/CurrencyService.js +1 -1
- package/dist/services/instance.js +1 -1
- package/package.json +1 -1
|
@@ -5708,7 +5708,7 @@ function Rc() {
|
|
|
5708
5708
|
return k0.countries = z, k0;
|
|
5709
5709
|
}
|
|
5710
5710
|
Rc();
|
|
5711
|
-
var e1 = /* @__PURE__ */ ((M) => (M.CHECK_USER = "CHECK_USER", M.USER_REGIONS = "USER_REGIONS", M.CONVERT_CURRENCY = "CONVERT_CURRENCY", M.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", M))(e1 || {}), f0 = /* @__PURE__ */ ((M) => (M.TOKEN = "token", M.REFRESH_TOKEN = "refreshToken", M.CLIENT_ID = "clientId", M.AUTH_FLOW = "authFlow", M))(f0 || {});
|
|
5711
|
+
var e1 = /* @__PURE__ */ ((M) => (M.CHECK_USER = "CHECK_USER", M.USER_REGIONS = "USER_REGIONS", M.CONVERT_CURRENCY = "CONVERT_CURRENCY", M.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", M.SEARCH_LIMIT = "SEARCH_LIMIT", M))(e1 || {}), f0 = /* @__PURE__ */ ((M) => (M.TOKEN = "token", M.REFRESH_TOKEN = "refreshToken", M.CLIENT_ID = "clientId", M.AUTH_FLOW = "authFlow", M))(f0 || {});
|
|
5712
5712
|
Array.prototype.getLast || (Array.prototype.getLast = function() {
|
|
5713
5713
|
return this[this.length - 1];
|
|
5714
5714
|
});
|
|
@@ -7710,12 +7710,12 @@ class bA {
|
|
|
7710
7710
|
}
|
|
7711
7711
|
const gM = new bA();
|
|
7712
7712
|
export {
|
|
7713
|
-
|
|
7713
|
+
gM as A,
|
|
7714
7714
|
f0 as E,
|
|
7715
|
-
|
|
7716
|
-
|
|
7715
|
+
e1 as a,
|
|
7716
|
+
E0 as b,
|
|
7717
7717
|
Z as c,
|
|
7718
|
-
|
|
7718
|
+
Zo as d,
|
|
7719
7719
|
nA as g,
|
|
7720
7720
|
$o as i
|
|
7721
7721
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as Fe, Fragment as GO, jsxs as Jo } from "react/jsx-runtime";
|
|
2
2
|
import * as Q from "react";
|
|
3
3
|
import Jl, { useLayoutEffect as XO, useEffect as qO, useMemo as KO } from "react";
|
|
4
|
-
import { g as ZO,
|
|
4
|
+
import { g as ZO, a as JO } from "../../AccountService-Dt2-k7CN.js";
|
|
5
5
|
import { useQuery as e_ } from "@tanstack/react-query";
|
|
6
6
|
import { CurrencyService as t_ } from "../../services/currency/CurrencyService.js";
|
|
7
7
|
import '../../assets/_styles.css';/* empty css */
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as
|
|
1
|
+
import { d as _, E as r, A as o, a as U } from "../../AccountService-Dt2-k7CN.js";
|
|
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
|
|
9
|
-
message:
|
|
10
|
-
cause:
|
|
11
|
-
status:
|
|
12
|
-
data: (f =
|
|
13
|
-
}) : c =
|
|
4
|
+
import { awayzClient as H } from "../../configs/awayzClient.js";
|
|
5
|
+
const M = (s, t) => {
|
|
6
|
+
var f, m;
|
|
7
|
+
let c = "", d = t;
|
|
8
|
+
typeof t == "string" ? c = t : t instanceof _ ? (c = t.message, d = {
|
|
9
|
+
message: t.message,
|
|
10
|
+
cause: t.cause,
|
|
11
|
+
status: t.status,
|
|
12
|
+
data: (f = t == null ? void 0 : t.response) == null ? void 0 : f.data
|
|
13
|
+
}) : c = t.message, (m = window.parent) == null || m.postMessage(
|
|
14
14
|
{
|
|
15
15
|
type: "auth_error",
|
|
16
|
-
details: { message: c, action:
|
|
16
|
+
details: { message: c, action: s, info: d }
|
|
17
17
|
},
|
|
18
18
|
"*"
|
|
19
19
|
);
|
|
20
|
-
},
|
|
21
|
-
const [
|
|
22
|
-
async (
|
|
23
|
-
|
|
20
|
+
}, V = (s) => {
|
|
21
|
+
const [t, c] = E(!0), [d, f] = E(!1), [m, T] = E(), [A, k] = E(), [O, I] = E([]), w = R(
|
|
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);
|
|
24
24
|
},
|
|
25
|
-
[
|
|
25
|
+
[s]
|
|
26
26
|
), i = R(
|
|
27
|
-
async (
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
|
|
27
|
+
async (a, e) => {
|
|
28
|
+
if (s.authFlow !== S.POST_MESSAGE)
|
|
29
|
+
return M(e ?? "exchange_token", a);
|
|
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
|
-
[
|
|
33
|
-
), h = async (
|
|
32
|
+
[s]
|
|
33
|
+
), h = async (a) => {
|
|
34
34
|
try {
|
|
35
|
-
const { success: e, data:
|
|
35
|
+
const { success: e, data: n, message: u } = await o.authenticateWithToken(a);
|
|
36
36
|
if (!e) {
|
|
37
37
|
i(u);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (!(
|
|
40
|
+
if (!(n != null && n.token)) {
|
|
41
41
|
i("no awayz token returned after exchanging id token");
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
localStorage.setItem(
|
|
44
|
+
localStorage.setItem(r.TOKEN, n.token), await w(n);
|
|
45
45
|
const { data: l, ...g } = await o.getRequestLimit();
|
|
46
46
|
if (!g.success) {
|
|
47
47
|
console.error({ reqLimitError: g });
|
|
@@ -61,48 +61,48 @@ const v = (t, a) => {
|
|
|
61
61
|
} finally {
|
|
62
62
|
c(!1);
|
|
63
63
|
}
|
|
64
|
-
},
|
|
64
|
+
}, K = async () => {
|
|
65
65
|
try {
|
|
66
|
-
const { success:
|
|
67
|
-
queryKey: [
|
|
66
|
+
const { success: a, data: e } = await H.ensureQueryData({
|
|
67
|
+
queryKey: [U.CHECK_USER],
|
|
68
68
|
queryFn: o.checkUser
|
|
69
69
|
});
|
|
70
|
-
if (!
|
|
70
|
+
if (!a) {
|
|
71
71
|
i(e);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
await
|
|
74
|
+
await w({
|
|
75
75
|
user: e,
|
|
76
|
-
token: localStorage.getItem(
|
|
76
|
+
token: localStorage.getItem(r.TOKEN)
|
|
77
77
|
});
|
|
78
|
-
} catch (
|
|
79
|
-
i(
|
|
78
|
+
} catch (a) {
|
|
79
|
+
i(a);
|
|
80
80
|
} finally {
|
|
81
81
|
c(!1);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
84
|
+
y(() => {
|
|
85
|
+
if (s.authFlow !== S.STANDARD) return;
|
|
86
|
+
const a = localStorage.getItem(r.TOKEN), e = localStorage.getItem(r.REFRESH_TOKEN);
|
|
87
|
+
a && e ? K() : c(!1);
|
|
88
88
|
}, []);
|
|
89
89
|
const N = async () => {
|
|
90
|
-
const
|
|
91
|
-
|
|
90
|
+
const a = await o.getRegions();
|
|
91
|
+
I(a);
|
|
92
92
|
};
|
|
93
|
-
return
|
|
93
|
+
return y(() => {
|
|
94
94
|
N();
|
|
95
|
-
}, []),
|
|
96
|
-
if (
|
|
97
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
95
|
+
}, []), y(() => {
|
|
96
|
+
if (s.authFlow !== S.QUERY) return;
|
|
97
|
+
const e = new URLSearchParams(window.location.search).get(r.TOKEN);
|
|
98
98
|
e && h(e);
|
|
99
|
-
}, []),
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
99
|
+
}, []), y(() => {
|
|
100
|
+
if (s.authFlow !== S.POST_MESSAGE) return;
|
|
101
|
+
const a = async (e) => {
|
|
102
102
|
var l;
|
|
103
103
|
if (e.data.type !== "auth") return;
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
104
|
+
const n = (l = e.data) == null ? void 0 : l.idToken, u = e.data.refreshToken;
|
|
105
|
+
if (!n) {
|
|
106
106
|
const g = `received message ${JSON.stringify(
|
|
107
107
|
e.data
|
|
108
108
|
)}
|
|
@@ -122,63 +122,55 @@ const v = (t, a) => {
|
|
|
122
122
|
);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
localStorage.setItem(
|
|
125
|
+
localStorage.setItem(r.REFRESH_TOKEN, u), await h(n);
|
|
126
126
|
};
|
|
127
|
-
return window.addEventListener("message",
|
|
127
|
+
return window.addEventListener("message", a), window.parent && window.parent.postMessage(
|
|
128
128
|
{
|
|
129
129
|
type: "ready"
|
|
130
130
|
/* READY */
|
|
131
131
|
},
|
|
132
132
|
"*"
|
|
133
133
|
), () => {
|
|
134
|
-
window.removeEventListener("message",
|
|
134
|
+
window.removeEventListener("message", a);
|
|
135
135
|
};
|
|
136
136
|
}, []), {
|
|
137
|
-
isAuthenticating:
|
|
138
|
-
isAuthenticated:
|
|
139
|
-
token:
|
|
137
|
+
isAuthenticating: t,
|
|
138
|
+
isAuthenticated: d,
|
|
139
|
+
token: m,
|
|
140
140
|
user: A,
|
|
141
141
|
supportedRegions: O,
|
|
142
|
-
signIn: async (
|
|
143
|
-
var
|
|
144
|
-
const e = await o.login(
|
|
142
|
+
signIn: async (a) => {
|
|
143
|
+
var n;
|
|
144
|
+
const e = await o.login(a);
|
|
145
145
|
if (!e.success)
|
|
146
146
|
i(e.message);
|
|
147
147
|
else {
|
|
148
|
-
const u = (
|
|
149
|
-
localStorage.setItem(
|
|
148
|
+
const u = (n = e.data) == null ? void 0 : n.refreshToken;
|
|
149
|
+
localStorage.setItem(r.REFRESH_TOKEN, u), await w(e.data);
|
|
150
150
|
}
|
|
151
151
|
return e;
|
|
152
152
|
},
|
|
153
|
-
signUp: async (
|
|
154
|
-
var
|
|
155
|
-
const e = await o.signUp(
|
|
153
|
+
signUp: async (a) => {
|
|
154
|
+
var n;
|
|
155
|
+
const e = await o.signUp(a);
|
|
156
156
|
if (!e.success)
|
|
157
157
|
i(e.message);
|
|
158
158
|
else {
|
|
159
|
-
const u = (
|
|
160
|
-
localStorage.setItem(
|
|
159
|
+
const u = (n = e.data) == null ? void 0 : n.refreshToken;
|
|
160
|
+
localStorage.setItem(r.REFRESH_TOKEN, u), await w(e.data);
|
|
161
161
|
}
|
|
162
162
|
return e;
|
|
163
163
|
},
|
|
164
164
|
signOut: () => {
|
|
165
|
-
localStorage.removeItem(
|
|
165
|
+
localStorage.removeItem(r.TOKEN), localStorage.removeItem(r.REFRESH_TOKEN), f(!1), T(void 0), k(void 0);
|
|
166
166
|
},
|
|
167
|
-
resendVerificationEmail: async (
|
|
168
|
-
setTokens: (
|
|
169
|
-
localStorage.setItem(
|
|
170
|
-
},
|
|
171
|
-
getRequestLimits: async () => {
|
|
172
|
-
const { data: s, ...e } = await o.getRequestLimit();
|
|
173
|
-
if (!e.success) {
|
|
174
|
-
console.error({ reqLimitError: e });
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
return L(s);
|
|
167
|
+
resendVerificationEmail: async (a) => (await o.resendVerificationEmail(a)).success,
|
|
168
|
+
setTokens: (a, e) => {
|
|
169
|
+
localStorage.setItem(r.TOKEN, a), localStorage.setItem(r.REFRESH_TOKEN, e), h(a);
|
|
178
170
|
}
|
|
179
171
|
};
|
|
180
172
|
};
|
|
181
173
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
M as authFailurePostMessage,
|
|
175
|
+
V as useAwayzAuth
|
|
184
176
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { a as s, A as a, b as i } from "../AccountService-Dt2-k7CN.js";
|
|
2
|
+
import { useQuery as o } from "@tanstack/react-query";
|
|
3
|
+
import "react";
|
|
4
|
+
const n = () => {
|
|
5
|
+
const { data: r } = o({
|
|
6
|
+
queryKey: [s.SEARCH_LIMIT],
|
|
7
|
+
queryFn: async () => {
|
|
8
|
+
const { data: t, ...e } = await a.getRequestLimit();
|
|
9
|
+
if (!e.success) {
|
|
10
|
+
console.error({ reqLimitError: e });
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return i(t);
|
|
14
|
+
},
|
|
15
|
+
staleTime: 3e5
|
|
16
|
+
// 5 minutes
|
|
17
|
+
});
|
|
18
|
+
return r;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
n as useSearchLimit
|
|
22
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRegion, IResendVerificationEmailParams,
|
|
1
|
+
import { IRegion, IResendVerificationEmailParams, IUser } from '../services/account/AccountServices.types';
|
|
2
2
|
import { ISignInParams, ISignUpParams, TAuthResponse } from '../types/auth';
|
|
3
3
|
import { IAwayzConfig } from '../configs/awayzConfig';
|
|
4
4
|
export interface IAwayzContext {
|
|
@@ -13,6 +13,5 @@ export interface IAwayzContext {
|
|
|
13
13
|
signOut: () => void;
|
|
14
14
|
resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<boolean>;
|
|
15
15
|
setTokens: (accessToken: string, refreshToken: string) => void;
|
|
16
|
-
getRequestLimits: () => Promise<ISearchLimit[] | undefined>;
|
|
17
16
|
}
|
|
18
17
|
export declare const AwayzContext: import('react').Context<IAwayzContext>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TEmbeddedAuthOptions } from './useAwayzAuth.types';
|
|
2
|
-
import { IAuthData, IRegion, IResendVerificationEmailParams,
|
|
2
|
+
import { IAuthData, IRegion, IResendVerificationEmailParams, IUser } from '../../services/account/AccountServices.types';
|
|
3
3
|
import { ISignInParams, ISignUpParams } from '../../types/auth';
|
|
4
4
|
declare enum ETokenType {
|
|
5
5
|
EXCHANGE = "exchange_token",
|
|
@@ -33,6 +33,5 @@ export declare const useAwayzAuth: (options: TEmbeddedAuthOptions) => {
|
|
|
33
33
|
signOut: () => void;
|
|
34
34
|
resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<any>;
|
|
35
35
|
setTokens: (accessToken: string, refreshToken: string) => void;
|
|
36
|
-
getRequestLimits: () => Promise<ISearchLimit[] | undefined>;
|
|
37
36
|
};
|
|
38
37
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ISearchLimit } from '../services/account/AccountServices.types';
|
|
2
|
+
export declare const useSearchLimit: () => ISearchLimit[] | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* "data": [
|
|
5
|
+
{
|
|
6
|
+
"search_type": "Flight",
|
|
7
|
+
"subscription": "free",
|
|
8
|
+
"is_admin": false,
|
|
9
|
+
"search_limit": 5,
|
|
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
|
+
],
|
|
22
|
+
*/
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AwayzProvider as r } from "./providers/AwayzProvider.js";
|
|
2
2
|
import { useAwayzContext as a } from "./hooks/useAwayzContext.js";
|
|
3
3
|
import { EAuthFlow as n } from "./types/EAuthFlow.js";
|
|
4
|
-
import { c as s, i as x } from "./AccountService-
|
|
4
|
+
import { c as s, i as x } from "./AccountService-Dt2-k7CN.js";
|
|
5
5
|
import { awayzClient as m } from "./configs/awayzClient.js";
|
|
6
6
|
import { CashValue as c, EToolTipPosition as w } from "./components/CashValue/CashValue.js";
|
|
7
7
|
import { getBaseUrl as y } from "./configs/baseUrl.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect as i } from "react";
|
|
3
3
|
import { AwayzContext as m } from "../context/AwayzContext.js";
|
|
4
|
-
import { E as e } from "../AccountService-
|
|
4
|
+
import { E as e } from "../AccountService-Dt2-k7CN.js";
|
|
5
5
|
import { useAwayzAuth as s } from "../hooks/useAwayzAuth/useAwayzAuth.js";
|
|
6
6
|
import { setBaseUrl as l } from "../configs/baseUrl.js";
|
|
7
7
|
import { QueryClientProvider as u } from "@tanstack/react-query";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../../assets/_styles.css';var s = Object.defineProperty;
|
|
2
2
|
var i = (t, r, e) => r in t ? s(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
3
|
var c = (t, r, e) => i(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
-
import {
|
|
4
|
+
import { A as u, a as y, c as p } from "../../AccountService-Dt2-k7CN.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { ECurrencyEndpoints as m } from "../../configs/endpoints.js";
|
|
7
7
|
import "react/jsx-runtime";
|