@odynn/awayz-core 0.6.6 → 0.6.7
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-DSlN1q1q.js → AccountService-CPWv4uJS.js} +1 -1
- package/dist/{TripsService-BWc1KjO6.js → TripsService-CCdhF5uK.js} +2 -2
- package/dist/{_commonjsHelpers-MdHo5S7N.js → _commonjsHelpers-B52_cu2H.js} +2 -2
- package/dist/{arrayExtensions-DlcBOj5a.js → arrayExtensions--Llcg40q.js} +1 -1
- package/dist/components/Bookings/FlightBooking/FlightBooking.js +1 -1
- package/dist/components/Bookings/HotelBooking/HotelBooking.js +1 -1
- package/dist/components/CashValue/CashValue.js +8 -7
- package/dist/components/CashValue/CashValue.stories.js +2 -2
- package/dist/components/Menu/Menu.js +2 -2
- package/dist/components/Wallet/Card/Card.js +1 -1
- package/dist/components/Wallet/Card/Card.stories.js +2 -2
- package/dist/context/AwayzContext.js +1 -0
- package/dist/currency-symbol-map-RM3-TVyB.js +211 -0
- package/dist/hooks/useAwayzAuth/useAwayzAuth.js +102 -95
- package/dist/hooks/useBookingManagement/useBookingManagement.js +5 -4
- package/dist/hooks/useBookingManagement/useBookingManagement.test.js +3 -2
- package/dist/hooks/useSearchLimit.js +2 -2
- package/dist/hooks/useTripManagement/useTripManagement.js +14 -13
- package/dist/hooks/useTripManagement/useTripManagement.test.js +24 -22
- package/dist/hooks/useWallet/useWallet.js +9 -8
- package/dist/hooks/useWallet/useWallet.test.js +3 -2
- package/dist/{index-Cv-wvFlM.js → index-B7QVGqcx.js} +1 -1
- package/dist/{index-BC-KTkxU.js → index-C135U4OR.js} +1 -1
- package/dist/lib/context/AwayzContext.d.ts +2 -0
- package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.d.ts +2 -0
- package/dist/lib/services/currency/CurrencyService.types.d.ts +4 -0
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/main.js +33 -36
- package/dist/providers/AwayzProvider.js +2 -2
- package/dist/services/account/AccountService.js +2 -2
- package/dist/services/bookings/BookingService.js +2 -2
- package/dist/services/currency/CurrencyService.js +5 -4
- package/dist/services/index.js +1 -1
- package/dist/services/instance.js +2 -2
- package/dist/services/instanceConfig.js +2 -2
- package/dist/services/noRetryInstance.js +1 -1
- package/dist/services/preferences/PreferencesService.js +1 -1
- package/dist/services/rewards/RewardsService.js +2 -2
- package/dist/services/trips/TripsService.js +3 -3
- package/dist/services/wallet/WalletService.js +2 -2
- package/dist/tests/TestWrapper.js +2 -2
- package/dist/types/index.js +2 -5
- package/package.json +2 -1
- package/dist/lib/types/ECurrency.d.ts +0 -32
- package/dist/types/ECurrency.js +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var lt = Object.defineProperty;
|
|
2
2
|
var ft = (e, t, n) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var U = (e, t, n) => ft(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import "./arrayExtensions
|
|
4
|
+
import "./arrayExtensions--Llcg40q.js";
|
|
5
5
|
import { a as L } from "./keys-D66VvSIm.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import { getBaseUrl as qe } from "./configs/baseUrl.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
2
|
var g = (a, e, s) => e in a ? _(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
|
|
3
3
|
var r = (a, e, s) => g(a, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
-
import "./arrayExtensions
|
|
5
|
-
import { c as n, f as p, a as o, r as T } from "./AccountService-
|
|
4
|
+
import "./arrayExtensions--Llcg40q.js";
|
|
5
|
+
import { c as n, f as p, a as o, r as T } from "./AccountService-CPWv4uJS.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import { EMyTripsEndpoints as i } from "./configs/endpoints.js";
|
|
8
8
|
import { EBookingType as m } from "./services/trips/TripService.types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { h as t } from "../../../arrayExtensions
|
|
2
|
+
import { h as t } from "../../../arrayExtensions--Llcg40q.js";
|
|
3
3
|
import { E as o } from "../../../DateFormats-DZD30Nea.js";
|
|
4
4
|
import { E as r } from "../../../keys-D66VvSIm.js";
|
|
5
5
|
import "react";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as e, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { G as g } from "../../../index-CDh8vAM_.js";
|
|
3
|
-
import { h as k } from "../../../arrayExtensions
|
|
3
|
+
import { h as k } from "../../../arrayExtensions--Llcg40q.js";
|
|
4
4
|
import { E as N } from "../../../DateFormats-DZD30Nea.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import '../../../assets/_styles4.css';/* empty css */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as u, Fragment as rt, jsxs as R } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
3
|
import { useMemo as nt } from "react";
|
|
4
|
-
import { u as D, a as ot, c as A, b as q, d as ve, e as st, f as it, g as G, o as at, s as ct, h as lt, i as ut, j as dt, k as pt, l as ft, m as ht, n as vt, p as mt, P as me } from "../../index-
|
|
5
|
-
import { r as yt, R as gt } from "../../index-
|
|
4
|
+
import { u as D, a as ot, c as A, b as q, d as ve, e as st, f as it, g as G, o as at, s as ct, h as lt, i as ut, j as dt, k as pt, l as ft, m as ht, n as vt, p as mt, P as me } from "../../index-C135U4OR.js";
|
|
5
|
+
import { r as yt, R as gt } from "../../index-B7QVGqcx.js";
|
|
6
6
|
import { useQuery as Ct } from "@tanstack/react-query";
|
|
7
|
-
import "../../arrayExtensions
|
|
8
|
-
import { E as wt } from "../../AccountService-
|
|
7
|
+
import "../../arrayExtensions--Llcg40q.js";
|
|
8
|
+
import { E as wt } from "../../AccountService-CPWv4uJS.js";
|
|
9
9
|
import { b as de } from "../../index-CDh8vAM_.js";
|
|
10
10
|
import { EInvalidAmountDisplayOption as O, EToolTipPosition as Et } from "./CashValueTypes.js";
|
|
11
11
|
import '../../assets/_styles5.css';import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';/* empty css */
|
|
@@ -16,6 +16,7 @@ import "react-i18next";
|
|
|
16
16
|
import "../../configs/awayzClient.js";
|
|
17
17
|
import { useAwayzContext as Pt } from "../../hooks/useAwayzContext.js";
|
|
18
18
|
import "../../context/AwayzContext.js";
|
|
19
|
+
import "../../currency-symbol-map-RM3-TVyB.js";
|
|
19
20
|
import "../../services/noRetryInstance.js";
|
|
20
21
|
import { CurrencyService as bt } from "../../services/currency/CurrencyService.js";
|
|
21
22
|
/* empty css */
|
|
@@ -456,7 +457,7 @@ var Qt = Object.freeze({
|
|
|
456
457
|
)
|
|
457
458
|
);
|
|
458
459
|
Le.displayName = Jt;
|
|
459
|
-
var er = Le, [Y,
|
|
460
|
+
var er = Le, [Y, Gr] = ve("Tooltip", [
|
|
460
461
|
be
|
|
461
462
|
]), V = be(), Ie = "TooltipProvider", tr = 700, X = "tooltip.open", [rr, J] = Y(Ie), Me = (e) => {
|
|
462
463
|
const {
|
|
@@ -788,7 +789,7 @@ const he = (e, t) => {
|
|
|
788
789
|
currency: t ?? "USD",
|
|
789
790
|
maximumFractionDigits: r
|
|
790
791
|
}).format(isNaN(n) ? 0 : n);
|
|
791
|
-
}, br = 1e3 * 60 * 60,
|
|
792
|
+
}, br = 1e3 * 60 * 60, zr = ({
|
|
792
793
|
amount: e,
|
|
793
794
|
currency: t,
|
|
794
795
|
position: r = Et.RIGHT,
|
|
@@ -895,6 +896,6 @@ const he = (e, t) => {
|
|
|
895
896
|
) })
|
|
896
897
|
] }) });
|
|
897
898
|
export {
|
|
898
|
-
|
|
899
|
+
zr as CashValue,
|
|
899
900
|
br as CurrencyCallStaleTimeMs
|
|
900
901
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import { CashValue as n } from "./CashValue.js";
|
|
3
3
|
import { EToolTipPosition as t, EInvalidAmountDisplayOption as o } from "./CashValueTypes.js";
|
|
4
4
|
import '../../assets/_styles4.css';import '../../assets/_styles3.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';/* empty css */
|
|
5
|
-
import "../../arrayExtensions
|
|
5
|
+
import "../../arrayExtensions--Llcg40q.js";
|
|
6
6
|
import "react";
|
|
7
7
|
import "react-i18next";
|
|
8
8
|
/* empty css */
|
|
@@ -11,7 +11,7 @@ import "react-i18next";
|
|
|
11
11
|
import "../../configs/awayzClient.js";
|
|
12
12
|
import "../../context/AwayzContext.js";
|
|
13
13
|
import "@tanstack/react-query";
|
|
14
|
-
import "../../AccountService-
|
|
14
|
+
import "../../AccountService-CPWv4uJS.js";
|
|
15
15
|
import { AwayzProvider as a } from "../../providers/AwayzProvider.js";
|
|
16
16
|
import "../../services/noRetryInstance.js";
|
|
17
17
|
import { EAuthFlow as i } from "../../types/EAuthFlow.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as f, jsxs as Fe } from "react/jsx-runtime";
|
|
2
2
|
import * as a from "react";
|
|
3
3
|
import Z, { useState as or } from "react";
|
|
4
|
-
import { q as ie, d as me, u as T, a as ar, c as R, b as U, e as ir, f as cr, g as Ue, o as sr, s as ur, h as lr, i as dr, j as fr, k as pr, l as vr, m as mr, n as oe, p as Qe, P as Oe } from "../../index-
|
|
5
|
-
import { r as hr, R as gr } from "../../index-
|
|
4
|
+
import { q as ie, d as me, u as T, a as ar, c as R, b as U, e as ir, f as cr, g as Ue, o as sr, s as ur, h as lr, i as dr, j as fr, k as pr, l as vr, m as mr, n as oe, p as Qe, P as Oe } from "../../index-C135U4OR.js";
|
|
5
|
+
import { r as hr, R as gr } from "../../index-B7QVGqcx.js";
|
|
6
6
|
import '../../assets/_styles2.css';/* empty css */
|
|
7
7
|
import { c as br, d as yr } from "../../index-CDh8vAM_.js";
|
|
8
8
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as i, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import '../../../assets/_styles.css';/* empty css */
|
|
3
3
|
import { a as l } from "../../../index-CDh8vAM_.js";
|
|
4
|
-
import "../../../arrayExtensions
|
|
4
|
+
import "../../../arrayExtensions--Llcg40q.js";
|
|
5
5
|
import "react";
|
|
6
6
|
const t = (r) => {
|
|
7
7
|
if (!r)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { Card as r } from "./Card.js";
|
|
3
3
|
import "@tanstack/react-query";
|
|
4
|
-
import "../../../arrayExtensions
|
|
4
|
+
import "../../../arrayExtensions--Llcg40q.js";
|
|
5
5
|
import "react";
|
|
6
|
-
import "../../../AccountService-
|
|
6
|
+
import "../../../AccountService-CPWv4uJS.js";
|
|
7
7
|
import "../../../configs/awayzClient.js";
|
|
8
8
|
import '../../../assets/_styles4.css';import '../../../assets/_styles3.css';import '../../../assets/_styles2.css';import '../../../assets/_styles5.css';/* empty css */
|
|
9
9
|
import "react-i18next";
|
|
@@ -3,6 +3,7 @@ const t = e({
|
|
|
3
3
|
isAuthenticated: !1,
|
|
4
4
|
isAuthenticating: !1,
|
|
5
5
|
supportedRegions: [],
|
|
6
|
+
supportedCurrencies: [],
|
|
6
7
|
signIn: async () => ({ success: !1, message: "No Awayz Context" }),
|
|
7
8
|
signUp: async () => ({ success: !1, message: "No Awayz Context" }),
|
|
8
9
|
signOut: () => {
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { g as C } from "./_commonjsHelpers-B52_cu2H.js";
|
|
2
|
+
var r = { exports: {} }, S, R;
|
|
3
|
+
function B() {
|
|
4
|
+
return R || (R = 1, S = {
|
|
5
|
+
AED: "د.إ",
|
|
6
|
+
AFN: "؋",
|
|
7
|
+
ALL: "L",
|
|
8
|
+
AMD: "֏",
|
|
9
|
+
ANG: "ƒ",
|
|
10
|
+
AOA: "Kz",
|
|
11
|
+
ARS: "$",
|
|
12
|
+
AUD: "$",
|
|
13
|
+
AWG: "ƒ",
|
|
14
|
+
AZN: "₼",
|
|
15
|
+
BAM: "KM",
|
|
16
|
+
BBD: "$",
|
|
17
|
+
BDT: "৳",
|
|
18
|
+
BGN: "лв",
|
|
19
|
+
BHD: ".د.ب",
|
|
20
|
+
BIF: "FBu",
|
|
21
|
+
BMD: "$",
|
|
22
|
+
BND: "$",
|
|
23
|
+
BOB: "$b",
|
|
24
|
+
BOV: "BOV",
|
|
25
|
+
BRL: "R$",
|
|
26
|
+
BSD: "$",
|
|
27
|
+
BTC: "₿",
|
|
28
|
+
BTN: "Nu.",
|
|
29
|
+
BWP: "P",
|
|
30
|
+
BYN: "Br",
|
|
31
|
+
BYR: "Br",
|
|
32
|
+
BZD: "BZ$",
|
|
33
|
+
CAD: "$",
|
|
34
|
+
CDF: "FC",
|
|
35
|
+
CHE: "CHE",
|
|
36
|
+
CHF: "CHF",
|
|
37
|
+
CHW: "CHW",
|
|
38
|
+
CLF: "CLF",
|
|
39
|
+
CLP: "$",
|
|
40
|
+
CNH: "¥",
|
|
41
|
+
CNY: "¥",
|
|
42
|
+
COP: "$",
|
|
43
|
+
COU: "COU",
|
|
44
|
+
CRC: "₡",
|
|
45
|
+
CUC: "$",
|
|
46
|
+
CUP: "₱",
|
|
47
|
+
CVE: "$",
|
|
48
|
+
CZK: "Kč",
|
|
49
|
+
DJF: "Fdj",
|
|
50
|
+
DKK: "kr",
|
|
51
|
+
DOP: "RD$",
|
|
52
|
+
DZD: "دج",
|
|
53
|
+
EEK: "kr",
|
|
54
|
+
EGP: "£",
|
|
55
|
+
ERN: "Nfk",
|
|
56
|
+
ETB: "Br",
|
|
57
|
+
ETH: "Ξ",
|
|
58
|
+
EUR: "€",
|
|
59
|
+
FJD: "$",
|
|
60
|
+
FKP: "£",
|
|
61
|
+
GBP: "£",
|
|
62
|
+
GEL: "₾",
|
|
63
|
+
GGP: "£",
|
|
64
|
+
GHC: "₵",
|
|
65
|
+
GHS: "GH₵",
|
|
66
|
+
GIP: "£",
|
|
67
|
+
GMD: "D",
|
|
68
|
+
GNF: "FG",
|
|
69
|
+
GTQ: "Q",
|
|
70
|
+
GYD: "$",
|
|
71
|
+
HKD: "$",
|
|
72
|
+
HNL: "L",
|
|
73
|
+
HRK: "kn",
|
|
74
|
+
HTG: "G",
|
|
75
|
+
HUF: "Ft",
|
|
76
|
+
IDR: "Rp",
|
|
77
|
+
ILS: "₪",
|
|
78
|
+
IMP: "£",
|
|
79
|
+
INR: "₹",
|
|
80
|
+
IQD: "ع.د",
|
|
81
|
+
IRR: "﷼",
|
|
82
|
+
ISK: "kr",
|
|
83
|
+
JEP: "£",
|
|
84
|
+
JMD: "J$",
|
|
85
|
+
JOD: "JD",
|
|
86
|
+
JPY: "¥",
|
|
87
|
+
KES: "KSh",
|
|
88
|
+
KGS: "лв",
|
|
89
|
+
KHR: "៛",
|
|
90
|
+
KMF: "CF",
|
|
91
|
+
KPW: "₩",
|
|
92
|
+
KRW: "₩",
|
|
93
|
+
KWD: "KD",
|
|
94
|
+
KYD: "$",
|
|
95
|
+
KZT: "₸",
|
|
96
|
+
LAK: "₭",
|
|
97
|
+
LBP: "£",
|
|
98
|
+
LKR: "₨",
|
|
99
|
+
LRD: "$",
|
|
100
|
+
LSL: "M",
|
|
101
|
+
LTC: "Ł",
|
|
102
|
+
LTL: "Lt",
|
|
103
|
+
LVL: "Ls",
|
|
104
|
+
LYD: "LD",
|
|
105
|
+
MAD: "MAD",
|
|
106
|
+
MDL: "lei",
|
|
107
|
+
MGA: "Ar",
|
|
108
|
+
MKD: "ден",
|
|
109
|
+
MMK: "K",
|
|
110
|
+
MNT: "₮",
|
|
111
|
+
MOP: "MOP$",
|
|
112
|
+
MRO: "UM",
|
|
113
|
+
MRU: "UM",
|
|
114
|
+
MUR: "₨",
|
|
115
|
+
MVR: "Rf",
|
|
116
|
+
MWK: "MK",
|
|
117
|
+
MXN: "$",
|
|
118
|
+
MXV: "MXV",
|
|
119
|
+
MYR: "RM",
|
|
120
|
+
MZN: "MT",
|
|
121
|
+
NAD: "$",
|
|
122
|
+
NGN: "₦",
|
|
123
|
+
NIO: "C$",
|
|
124
|
+
NOK: "kr",
|
|
125
|
+
NPR: "₨",
|
|
126
|
+
NZD: "$",
|
|
127
|
+
OMR: "﷼",
|
|
128
|
+
PAB: "B/.",
|
|
129
|
+
PEN: "S/.",
|
|
130
|
+
PGK: "K",
|
|
131
|
+
PHP: "₱",
|
|
132
|
+
PKR: "₨",
|
|
133
|
+
PLN: "zł",
|
|
134
|
+
PYG: "Gs",
|
|
135
|
+
QAR: "﷼",
|
|
136
|
+
RMB: "¥",
|
|
137
|
+
RON: "lei",
|
|
138
|
+
RSD: "Дин.",
|
|
139
|
+
RUB: "₽",
|
|
140
|
+
RWF: "R₣",
|
|
141
|
+
SAR: "﷼",
|
|
142
|
+
SBD: "$",
|
|
143
|
+
SCR: "₨",
|
|
144
|
+
SDG: "ج.س.",
|
|
145
|
+
SEK: "kr",
|
|
146
|
+
SGD: "S$",
|
|
147
|
+
SHP: "£",
|
|
148
|
+
SLL: "Le",
|
|
149
|
+
SOS: "S",
|
|
150
|
+
SRD: "$",
|
|
151
|
+
SSP: "£",
|
|
152
|
+
STD: "Db",
|
|
153
|
+
STN: "Db",
|
|
154
|
+
SVC: "$",
|
|
155
|
+
SYP: "£",
|
|
156
|
+
SZL: "E",
|
|
157
|
+
THB: "฿",
|
|
158
|
+
TJS: "SM",
|
|
159
|
+
TMT: "T",
|
|
160
|
+
TND: "د.ت",
|
|
161
|
+
TOP: "T$",
|
|
162
|
+
TRL: "₤",
|
|
163
|
+
TRY: "₺",
|
|
164
|
+
TTD: "TT$",
|
|
165
|
+
TVD: "$",
|
|
166
|
+
TWD: "NT$",
|
|
167
|
+
TZS: "TSh",
|
|
168
|
+
UAH: "₴",
|
|
169
|
+
UGX: "USh",
|
|
170
|
+
USD: "$",
|
|
171
|
+
UYI: "UYI",
|
|
172
|
+
UYU: "$U",
|
|
173
|
+
UYW: "UYW",
|
|
174
|
+
UZS: "лв",
|
|
175
|
+
VEF: "Bs",
|
|
176
|
+
VES: "Bs.S",
|
|
177
|
+
VND: "₫",
|
|
178
|
+
VUV: "VT",
|
|
179
|
+
WST: "WS$",
|
|
180
|
+
XAF: "FCFA",
|
|
181
|
+
XBT: "Ƀ",
|
|
182
|
+
XCD: "$",
|
|
183
|
+
XOF: "CFA",
|
|
184
|
+
XPF: "₣",
|
|
185
|
+
XSU: "Sucre",
|
|
186
|
+
XUA: "XUA",
|
|
187
|
+
YER: "﷼",
|
|
188
|
+
ZAR: "R",
|
|
189
|
+
ZMW: "ZK",
|
|
190
|
+
ZWD: "Z$",
|
|
191
|
+
ZWL: "$"
|
|
192
|
+
}), S;
|
|
193
|
+
}
|
|
194
|
+
var $;
|
|
195
|
+
function T() {
|
|
196
|
+
if ($) return r.exports;
|
|
197
|
+
$ = 1;
|
|
198
|
+
const D = B();
|
|
199
|
+
return r.exports = function(M) {
|
|
200
|
+
if (typeof M != "string")
|
|
201
|
+
return;
|
|
202
|
+
const e = M.toUpperCase();
|
|
203
|
+
if (Object.prototype.hasOwnProperty.call(D, e))
|
|
204
|
+
return D[e];
|
|
205
|
+
}, r.exports.currencySymbolMap = D, r.exports;
|
|
206
|
+
}
|
|
207
|
+
var t = T();
|
|
208
|
+
const P = /* @__PURE__ */ C(t);
|
|
209
|
+
export {
|
|
210
|
+
P as g
|
|
211
|
+
};
|
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import "../../arrayExtensions
|
|
2
|
-
import { e as
|
|
3
|
-
import { a as
|
|
4
|
-
import { useState as
|
|
1
|
+
import "../../arrayExtensions--Llcg40q.js";
|
|
2
|
+
import { e as P, A as l, E as K } from "../../AccountService-CPWv4uJS.js";
|
|
3
|
+
import { a as c } from "../../keys-D66VvSIm.js";
|
|
4
|
+
import { useState as f, useCallback as O, useEffect as S } from "react";
|
|
5
|
+
import { g as q } from "../../currency-symbol-map-RM3-TVyB.js";
|
|
5
6
|
import { awayzClient as R } from "../../configs/awayzClient.js";
|
|
6
|
-
import { PreferencesService as
|
|
7
|
+
import { PreferencesService as H } from "../../services/preferences/PreferencesService.js";
|
|
7
8
|
import { EAuthFlow as h } from "../../types/EAuthFlow.js";
|
|
8
|
-
const
|
|
9
|
-
var
|
|
10
|
-
let
|
|
11
|
-
typeof
|
|
12
|
-
message:
|
|
13
|
-
cause:
|
|
14
|
-
status:
|
|
15
|
-
data: (
|
|
16
|
-
}) :
|
|
9
|
+
const M = (r, a) => {
|
|
10
|
+
var g, y;
|
|
11
|
+
let u = "", d = a;
|
|
12
|
+
typeof a == "string" ? u = a : a instanceof P ? (u = a.message, d = {
|
|
13
|
+
message: a.message,
|
|
14
|
+
cause: a.cause,
|
|
15
|
+
status: a.status,
|
|
16
|
+
data: (g = a == null ? void 0 : a.response) == null ? void 0 : g.data
|
|
17
|
+
}) : u = a.message, (y = window.parent) == null || y.postMessage(
|
|
17
18
|
{
|
|
18
19
|
type: "auth_error",
|
|
19
|
-
details: { message:
|
|
20
|
+
details: { message: u, action: r, info: d }
|
|
20
21
|
},
|
|
21
22
|
"*"
|
|
22
23
|
);
|
|
23
|
-
},
|
|
24
|
-
const [
|
|
25
|
-
async (
|
|
26
|
-
|
|
24
|
+
}, X = (r) => {
|
|
25
|
+
const [a, u] = f(!0), [d, g] = f(!1), [y, A] = f(), [m, T] = f(), [C, I] = f([]), [F, N] = f([]), E = O(
|
|
26
|
+
async (s) => {
|
|
27
|
+
r != null && r.onSuccess && (r == null || r.onSuccess(s)), r != null && r.onSuccessAsync && await (r == null ? void 0 : r.onSuccessAsync(s)), u(!1), g(!0), A(s.token), T(s.user), R.invalidateQueries();
|
|
27
28
|
},
|
|
28
|
-
[
|
|
29
|
-
),
|
|
30
|
-
async (
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
|
|
29
|
+
[r]
|
|
30
|
+
), o = O(
|
|
31
|
+
async (s, e) => {
|
|
32
|
+
if (r.authFlow !== h.POST_MESSAGE)
|
|
33
|
+
return M(e ?? "exchange_token", s);
|
|
34
|
+
r != null && r.onError && (r == null || r.onError(s)), r != null && r.onErrorAsync && await (r == null ? void 0 : r.onErrorAsync(s)), u(!1);
|
|
34
35
|
},
|
|
35
|
-
[
|
|
36
|
-
), k = async (
|
|
36
|
+
[r]
|
|
37
|
+
), k = async (s) => {
|
|
37
38
|
try {
|
|
38
|
-
const { success: e, data:
|
|
39
|
+
const { success: e, data: t, message: i } = await l.authenticateWithToken(s);
|
|
39
40
|
if (!e) {
|
|
40
|
-
i
|
|
41
|
+
o(i);
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
|
-
if (!(
|
|
44
|
-
|
|
44
|
+
if (!(t != null && t.token)) {
|
|
45
|
+
o("no awayz token returned after exchanging id token");
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
localStorage.setItem(
|
|
48
|
-
const { data:
|
|
48
|
+
localStorage.setItem(c.TOKEN, t.token), await E(t);
|
|
49
|
+
const { data: n, ...w } = await l.getRequestLimit();
|
|
49
50
|
if (!w.success) {
|
|
50
51
|
console.error({ reqLimitError: w });
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
(
|
|
54
|
+
n == null || n.forEach(
|
|
55
|
+
(v) => window.parent.postMessage(
|
|
55
56
|
{
|
|
56
57
|
type: "request_limit",
|
|
57
|
-
limit:
|
|
58
|
+
limit: v
|
|
58
59
|
},
|
|
59
60
|
"*"
|
|
60
61
|
)
|
|
@@ -62,115 +63,121 @@ const P = (s, r) => {
|
|
|
62
63
|
} catch (e) {
|
|
63
64
|
console.error("error handling message", e);
|
|
64
65
|
} finally {
|
|
65
|
-
|
|
66
|
+
u(!1);
|
|
66
67
|
}
|
|
67
|
-
},
|
|
68
|
+
}, _ = async () => {
|
|
68
69
|
try {
|
|
69
|
-
const { success:
|
|
70
|
+
const { success: s, data: e } = await R.ensureQueryData({
|
|
70
71
|
queryKey: [K.CHECK_USER],
|
|
71
|
-
queryFn:
|
|
72
|
+
queryFn: l.checkUser
|
|
72
73
|
});
|
|
73
|
-
if (!
|
|
74
|
-
|
|
74
|
+
if (!s) {
|
|
75
|
+
o(e);
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
|
-
await
|
|
78
|
+
await E({
|
|
78
79
|
user: e,
|
|
79
|
-
token: localStorage.getItem(
|
|
80
|
+
token: localStorage.getItem(c.TOKEN)
|
|
80
81
|
});
|
|
81
|
-
} catch (
|
|
82
|
-
|
|
82
|
+
} catch (s) {
|
|
83
|
+
o(s);
|
|
83
84
|
} finally {
|
|
84
|
-
|
|
85
|
+
u(!1);
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
S(() => {
|
|
88
|
-
if (
|
|
89
|
-
localStorage.getItem(
|
|
89
|
+
if (r.authFlow !== h.STANDARD) return;
|
|
90
|
+
localStorage.getItem(c.TOKEN) ? _() : u(!1);
|
|
90
91
|
}, []);
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const U = async () => {
|
|
93
|
+
const s = await l.getRegions();
|
|
94
|
+
I(s);
|
|
95
|
+
const e = s.map((n) => n.currency), i = Array.from(new Set(e)).map((n) => ({
|
|
96
|
+
code: n,
|
|
97
|
+
symbol: q(n) || n
|
|
98
|
+
}));
|
|
99
|
+
N(i);
|
|
94
100
|
};
|
|
95
101
|
return S(() => {
|
|
96
|
-
|
|
102
|
+
U();
|
|
97
103
|
}, []), S(() => {
|
|
98
|
-
if (
|
|
99
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
104
|
+
if (r.authFlow !== h.QUERY) return;
|
|
105
|
+
const e = new URLSearchParams(window.location.search).get(c.TOKEN);
|
|
100
106
|
e && k(e);
|
|
101
107
|
}, []), S(() => {
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
var
|
|
108
|
+
if (r.authFlow !== h.POST_MESSAGE) return;
|
|
109
|
+
const s = async (e) => {
|
|
110
|
+
var n;
|
|
105
111
|
if (e.data.type !== "auth") return;
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
112
|
+
const t = (n = e.data) == null ? void 0 : n.idToken, i = e.data.refreshToken;
|
|
113
|
+
if (!t) {
|
|
108
114
|
const w = `received message ${JSON.stringify(
|
|
109
115
|
e.data
|
|
110
116
|
)}
|
|
111
117
|
no idToken in body`;
|
|
112
|
-
|
|
118
|
+
o(w);
|
|
113
119
|
return;
|
|
114
120
|
}
|
|
115
|
-
localStorage.setItem(
|
|
121
|
+
localStorage.setItem(c.REFRESH_TOKEN, i), await k(t);
|
|
116
122
|
};
|
|
117
|
-
return window.addEventListener("message",
|
|
123
|
+
return window.addEventListener("message", s), window.parent && window.parent.postMessage(
|
|
118
124
|
{
|
|
119
125
|
type: "ready"
|
|
120
126
|
/* READY */
|
|
121
127
|
},
|
|
122
128
|
"*"
|
|
123
129
|
), () => {
|
|
124
|
-
window.removeEventListener("message",
|
|
130
|
+
window.removeEventListener("message", s);
|
|
125
131
|
};
|
|
126
132
|
}, []), {
|
|
127
|
-
isAuthenticating:
|
|
128
|
-
isAuthenticated:
|
|
129
|
-
token:
|
|
130
|
-
user:
|
|
131
|
-
supportedRegions:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
isAuthenticating: a,
|
|
134
|
+
isAuthenticated: d,
|
|
135
|
+
token: y,
|
|
136
|
+
user: m,
|
|
137
|
+
supportedRegions: C,
|
|
138
|
+
supportedCurrencies: F,
|
|
139
|
+
signIn: async (s) => {
|
|
140
|
+
var t;
|
|
141
|
+
const e = await l.login(s);
|
|
135
142
|
if (!e.success)
|
|
136
|
-
|
|
143
|
+
o(e.message);
|
|
137
144
|
else {
|
|
138
|
-
const
|
|
139
|
-
localStorage.setItem(
|
|
145
|
+
const i = (t = e.data) == null ? void 0 : t.refreshToken;
|
|
146
|
+
localStorage.setItem(c.REFRESH_TOKEN, i), await E(e.data);
|
|
140
147
|
}
|
|
141
148
|
return e;
|
|
142
149
|
},
|
|
143
|
-
signUp: async (
|
|
144
|
-
var
|
|
145
|
-
const e = await
|
|
150
|
+
signUp: async (s) => {
|
|
151
|
+
var t;
|
|
152
|
+
const e = await l.signUp(s);
|
|
146
153
|
if (!e.success)
|
|
147
|
-
|
|
154
|
+
o(e.message);
|
|
148
155
|
else {
|
|
149
|
-
const
|
|
150
|
-
localStorage.setItem(
|
|
156
|
+
const i = (t = e.data) == null ? void 0 : t.refreshToken;
|
|
157
|
+
localStorage.setItem(c.REFRESH_TOKEN, i), await E(e.data);
|
|
151
158
|
}
|
|
152
159
|
return e;
|
|
153
160
|
},
|
|
154
161
|
signOut: () => {
|
|
155
|
-
localStorage.removeItem(
|
|
162
|
+
localStorage.removeItem(c.TOKEN), localStorage.removeItem(c.REFRESH_TOKEN), g(!1), A(void 0), T(void 0);
|
|
156
163
|
},
|
|
157
|
-
resendVerificationEmail: async (
|
|
158
|
-
setTokens: (
|
|
159
|
-
localStorage.setItem(
|
|
164
|
+
resendVerificationEmail: async (s) => (await l.resendVerificationEmail(s)).success,
|
|
165
|
+
setTokens: (s, e) => {
|
|
166
|
+
localStorage.setItem(c.TOKEN, s), localStorage.setItem(c.REFRESH_TOKEN, e), k(s);
|
|
160
167
|
},
|
|
161
|
-
setPreferredCurrency: async (
|
|
162
|
-
const e = await
|
|
168
|
+
setPreferredCurrency: async (s) => {
|
|
169
|
+
const e = await H.setCurrency(s);
|
|
163
170
|
if (!e.success || !e.data)
|
|
164
171
|
return console.error("Failed to set preferred currency:", e), !1;
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
...
|
|
172
|
+
if (m) {
|
|
173
|
+
const t = {
|
|
174
|
+
...m,
|
|
168
175
|
preferences: {
|
|
169
|
-
...
|
|
170
|
-
currency: e.data.currency ||
|
|
176
|
+
...m.preferences,
|
|
177
|
+
currency: e.data.currency || m.preferences.currency
|
|
171
178
|
}
|
|
172
179
|
};
|
|
173
|
-
T(
|
|
180
|
+
T(t), R.invalidateQueries({
|
|
174
181
|
queryKey: [K.CHECK_USER]
|
|
175
182
|
});
|
|
176
183
|
}
|
|
@@ -179,6 +186,6 @@ const P = (s, r) => {
|
|
|
179
186
|
};
|
|
180
187
|
};
|
|
181
188
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
M as authFailurePostMessage,
|
|
190
|
+
X as useAwayzAuth
|
|
184
191
|
};
|