@odynn/awayz-core 0.10.12 → 0.10.14

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.
Files changed (38) hide show
  1. package/dist/{TripsService-fNtCUyxa.js → TripsService-PQeXLB1p.js} +8 -7
  2. package/dist/components/CashValue/CashValue.js +1 -1
  3. package/dist/components/CashValue/CashValue.stories.js +1 -1
  4. package/dist/components/ClientPointsValue/ClientPointsValue.js +1 -1
  5. package/dist/components/Wallet/Card/Card.stories.js +1 -1
  6. package/dist/configs/endpoints.js +1 -1
  7. package/dist/context/AwayzContext.js +1 -0
  8. package/dist/hooks/useAwayzAuth/useAwayzAuth.js +110 -99
  9. package/dist/hooks/useBookingManagement/useBookingManagement.js +1 -1
  10. package/dist/hooks/useBookingManagement/useBookingManagement.test.js +1 -1
  11. package/dist/hooks/useFeatureFlags.js +1 -1
  12. package/dist/hooks/useSearchLimit.js +1 -1
  13. package/dist/hooks/useTripManagement/useTripManagement.js +2 -2
  14. package/dist/hooks/useTripManagement/useTripManagement.test.js +2 -2
  15. package/dist/hooks/useWallet/useWallet.js +1 -1
  16. package/dist/hooks/useWallet/useWallet.test.js +1 -1
  17. package/dist/lib/configs/endpoints.d.ts +1 -0
  18. package/dist/lib/context/AwayzContext.d.ts +1 -0
  19. package/dist/lib/hooks/useAwayzAuth/useAwayzAuth.d.ts +9 -5
  20. package/dist/lib/services/account/AccountService.d.ts +9 -0
  21. package/dist/lib/services/trips/TripService.types.d.ts +1 -0
  22. package/dist/main.js +1 -1
  23. package/dist/{noRetryInstance-C4bqpBc7.js → noRetryInstance-CbNDzU_c.js} +111 -96
  24. package/dist/providers/AwayzProvider.js +1 -1
  25. package/dist/services/account/AccountService.js +1 -1
  26. package/dist/services/bookings/BookingService.js +1 -1
  27. package/dist/services/currency/CurrencyService.js +1 -1
  28. package/dist/services/features/featureService.js +1 -1
  29. package/dist/services/index.js +1 -1
  30. package/dist/services/instance.js +1 -1
  31. package/dist/services/instanceConfig.js +1 -1
  32. package/dist/services/noRetryInstance.js +1 -1
  33. package/dist/services/preferences/PreferencesService.js +1 -1
  34. package/dist/services/rewards/RewardsService.js +1 -1
  35. package/dist/services/trips/TripsService.js +2 -2
  36. package/dist/services/wallet/WalletService.js +1 -1
  37. package/dist/utils/clientPoints.js +1 -1
  38. package/package.json +1 -1
@@ -2,7 +2,7 @@ var v = Object.defineProperty;
2
2
  var f = (r, e, a) => e in r ? v(r, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[e] = a;
3
3
  var n = (r, e, a) => f(r, typeof e != "symbol" ? e + "" : e, a);
4
4
  import "./arrayExtensions-DlcBOj5a.js";
5
- import { c as i, f as u, b as d, r as D } from "./noRetryInstance-C4bqpBc7.js";
5
+ import { c as i, f as u, b as d, r as D } from "./noRetryInstance-CbNDzU_c.js";
6
6
  import "react";
7
7
  import { DEFAULT_LOGO as S } from "./configs/defaultAwayzConfig.js";
8
8
  import { EMyTripsEndpoints as o } from "./configs/endpoints.js";
@@ -91,7 +91,7 @@ class O {
91
91
  }
92
92
  }
93
93
  const T = (r) => r.map((e) => {
94
- var c, l, _, g;
94
+ var c, m, _, l;
95
95
  const a = e.slices.length > 1, t = e.slices[0], s = a ? e.slices.getLast() : void 0;
96
96
  return d({
97
97
  id: e._id,
@@ -100,9 +100,9 @@ const T = (r) => r.map((e) => {
100
100
  endDate: e.arrival_date,
101
101
  bookingType: y.FLIGHT,
102
102
  airlines: e.slices.map((p) => {
103
- var m;
103
+ var g;
104
104
  return {
105
- logo: (m = p.carriers.operating_iata_codes) != null && m.length ? `${I}${p.carriers.operating_iata_codes[0]}.svg` : S,
105
+ logo: (g = p.carriers.operating_iata_codes) != null && g.length ? `${I}${p.carriers.operating_iata_codes[0]}.svg` : S,
106
106
  name: p.carriers.operating[0]
107
107
  };
108
108
  }),
@@ -121,8 +121,8 @@ const T = (r) => r.map((e) => {
121
121
  type: e.type,
122
122
  cancelledAt: e.cancelled_at,
123
123
  isRoundTrip: a,
124
- outboundArrivalDate: t.arriving_at ?? ((l = (c = t.segments) == null ? void 0 : c.getLast()) == null ? void 0 : l.arriving_at),
125
- inboundDepartureDate: s ? s.departing_at ?? ((g = (_ = s.segments) == null ? void 0 : _[0]) == null ? void 0 : g.departing_at) : void 0,
124
+ outboundArrivalDate: t.arriving_at ?? ((m = (c = t.segments) == null ? void 0 : c.getLast()) == null ? void 0 : m.arriving_at),
125
+ inboundDepartureDate: s ? s.departing_at ?? ((l = (_ = s.segments) == null ? void 0 : _[0]) == null ? void 0 : l.departing_at) : void 0,
126
126
  inboundDeparture: s ? { airportCode: s.origin, location: "" } : void 0,
127
127
  inboundArrival: s ? { airportCode: s.destination, location: "" } : void 0
128
128
  });
@@ -133,7 +133,8 @@ const T = (r) => r.map((e) => {
133
133
  startDate: e.check_in_date,
134
134
  endDate: e.check_out_date,
135
135
  bookingType: y.HOTEL,
136
- name: e.rooms[0].name,
136
+ name: e.accommodation_name || e.rooms[0].name,
137
+ accommodationName: e.accommodation_name,
137
138
  image: e.images[0],
138
139
  guests: e.guests.length,
139
140
  address: Object.values(e.address).filter((a) => a).map((a) => a.trim()).join(", "),
@@ -2,7 +2,7 @@ import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
2
  import { useQuery as R } from "@tanstack/react-query";
3
3
  import "../../arrayExtensions-DlcBOj5a.js";
4
4
  import { g as m, a as _, b as N } from "../../cashUtils-DnCt66eB.js";
5
- import { E as S } from "../../noRetryInstance-C4bqpBc7.js";
5
+ import { E as S } from "../../noRetryInstance-CbNDzU_c.js";
6
6
  import { useMemo as T } from "react";
7
7
  import { a as f } from "../../index-C8p5kinH.js";
8
8
  import "react-i18next";
@@ -9,7 +9,7 @@ import { CashValue as n } from "./CashValue.js";
9
9
  import { EToolTipPosition as t, EInvalidAmountDisplayOption as o } from "./CashValueTypes.js";
10
10
  import "@tanstack/react-query";
11
11
  import "../../context/AwayzContext.js";
12
- import "../../noRetryInstance-C4bqpBc7.js";
12
+ import "../../noRetryInstance-CbNDzU_c.js";
13
13
  import "../../configs/awayzClient.js";
14
14
  /* empty css */
15
15
  import { AwayzProvider as a } from "../../providers/AwayzProvider.js";
@@ -1,7 +1,7 @@
1
1
  import { jsxs as c } from "react/jsx-runtime";
2
2
  import { useQuery as p } from "@tanstack/react-query";
3
3
  import "../../arrayExtensions-DlcBOj5a.js";
4
- import { E as u } from "../../noRetryInstance-C4bqpBc7.js";
4
+ import { E as u } from "../../noRetryInstance-CbNDzU_c.js";
5
5
  import { useMemo as f } from "react";
6
6
  import { useAwayzContext as l } from "../../hooks/useAwayzContext.js";
7
7
  import "react-i18next";
@@ -7,7 +7,7 @@ import '../../../assets/_styles6.css';import '../../../assets/_styles5.css';impo
7
7
  /* empty css */
8
8
  import "@tanstack/react-query";
9
9
  import "../../../configs/awayzClient.js";
10
- import "../../../noRetryInstance-C4bqpBc7.js";
10
+ import "../../../noRetryInstance-CbNDzU_c.js";
11
11
  /* empty css */
12
12
  /* empty css */
13
13
  import "../../../index-Cv-wvFlM.js";
@@ -1,4 +1,4 @@
1
- var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.GOOGLE_AUTH = "/auth/google-user", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e.FEATURES = "/user/features", e.CLIENT = "/clients/embed-data", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.LINKED_USER_AWARDS = "user/rewards/user-linked", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e.POINTS_AS_CASH = "/points-as-cash/available-points", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}), O = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e.ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes", e.REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking", e.BOOKING_POINTS_AS_CASH = "/points-as-cash", e))(O || {}), I = /* @__PURE__ */ ((e) => (e.POINTS_PER_CENT = "/user/rewards/points-per-cent", e))(I || {}), N = /* @__PURE__ */ ((e) => (e.USER_PREFERENCES = "/user/user-preferences", e))(N || {});
1
+ var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", e.GOOGLE_AUTH = "/auth/google-user", e.ME = "user", e.RESEND_VERIFICATION_EMAIL = "auth/resend-verification-email", e.UPDATE_USER_DETAILS = "account/update/user", e.CONFIRM_EMAIL = "account/verifyAccount", e.FORGOT_PASSWORD = "email/sendVeri", e.RESEND_OTP = "email/sendForgotPasswordVerification", e.RESET_PASSWORD = "account/updateUserPassword", e.REQUEST_LIMIT = "user/request-limit", e.APPLE_SOCIAL_SIGN_UP = "tp/apple/get/user", e.GOOGLE_SOCIAL_SIGN_UP = "tp/google/get/user", e.UPDATE_USER = "account/details/addUserDetails", e.ACKNOWLEDGEMENT = "account/update/userAcknowledgement", e.REGIONS = "user/region", e.UPDATE_USER_REGION = "/account/update/userRegion", e.UPDATE_PASSENGER_DETAILS = "/account/awayz", e.OTP = "auth/login/otp/verify", e.REFRESH_TOKEN = "auth/refresh-token", e.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_EMBED_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e.FEATURES = "/user/features", e.CLIENT = "/clients/embed-data", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {}), _ = /* @__PURE__ */ ((e) => (e.USER_AWARDS = "user/rewards", e.LINKED_USER_AWARDS = "user/rewards/user-linked", e.USER_CARDS = "user/cards", e.ADD_USER_CARDS = "user/cards/add", e.REMOVE_USER_CARDS = "user/cards/remove", e.BANKS = "banks", e.CARDS = "cards", e.POINTS_AS_CASH = "/points-as-cash/available-points", e))(_ || {}), S = /* @__PURE__ */ ((e) => (e.TRIPS = "user/trips", e.ADD_BOOKING = "user/trips/add-booking-to-trip", e.REMOVE_BOOKING = "user/trips/remove-booking-from-trip", e.UNCATEGORISED_BOOKINGS = "/user/trips/get-uncategorized-bookings", e))(S || {}), O = /* @__PURE__ */ ((e) => (e.USER_HOTEL_BOOKINGS = "/user/bookings/hotels", e.USER_FLIGHT_BOOKINGS = "/user/bookings/flights", e.INITIATE_FLIGHT_CANCEL = "/duffel/flights/initiate-order-cancellation", e.CONFIRM_FLIGHT_CANCEL = "/duffel/flights/confirm-order-cancellation", e.CANCEL_HOTEL_BOOKING = "/duffel/hotels/cancel", e.ACTION_AIRLINE_CHANGES = "/user/bookings/flights/action-airline-initiated-changes", e.REFUND_POINTS_BOOKING = "/points-as-cash/refund-booking", e.BOOKING_POINTS_AS_CASH = "/points-as-cash", e))(O || {}), I = /* @__PURE__ */ ((e) => (e.POINTS_PER_CENT = "/user/rewards/points-per-cent", e))(I || {}), N = /* @__PURE__ */ ((e) => (e.USER_PREFERENCES = "/user/user-preferences", e))(N || {});
2
2
  export {
3
3
  r as EAuthEndpoints,
4
4
  O as EBookingEndpoints,
@@ -8,6 +8,7 @@ const a = e({
8
8
  featureFlagsLoaded: !1,
9
9
  signIn: async () => ({ success: !1, message: "No Awayz Context" }),
10
10
  signUp: async () => ({ success: !1, message: "No Awayz Context" }),
11
+ verify2FA: async () => ({ success: !1, message: "No Awayz Context" }),
11
12
  signOut: () => {
12
13
  },
13
14
  continueWithGoogle: async () => ({
@@ -1,9 +1,9 @@
1
1
  import "../../arrayExtensions-DlcBOj5a.js";
2
- import { c as M } from "../../cashUtils-DnCt66eB.js";
3
- import { e as P, A as l, E as N } from "../../noRetryInstance-C4bqpBc7.js";
4
- import { a as o } from "../../keys-BcBfU51M.js";
5
- import { useState as f, useCallback as I, useEffect as h } from "react";
6
- import { awayzClient as O } from "../../configs/awayzClient.js";
2
+ import { c as P } from "../../cashUtils-DnCt66eB.js";
3
+ import { e as M, A as m, E as N } from "../../noRetryInstance-CbNDzU_c.js";
4
+ import { a as i } from "../../keys-BcBfU51M.js";
5
+ import { useState as f, useCallback as F, useEffect as T } from "react";
6
+ import { awayzClient as R } from "../../configs/awayzClient.js";
7
7
  import { PreferencesService as q } from "../../services/preferences/PreferencesService.js";
8
8
  import "@tanstack/react-query";
9
9
  import "react/jsx-runtime";
@@ -16,57 +16,57 @@ import '../../assets/_styles4.css';import '../../assets/_styles6.css';import '..
16
16
  import "../../index-Cv-wvFlM.js";
17
17
  import "../../context/AwayzContext.js";
18
18
  /* empty css */
19
- import { EAuthFlow as T } from "../../types/EAuthFlow.js";
20
- const x = (s, c) => {
21
- var m, S;
22
- let i = "", y = c;
23
- typeof c == "string" ? i = c : c instanceof P ? (i = c.message, y = {
19
+ import { EAuthFlow as k } from "../../types/EAuthFlow.js";
20
+ const x = (t, c) => {
21
+ var d, w;
22
+ let u = "", y = c;
23
+ typeof c == "string" ? u = c : c instanceof M ? (u = c.message, y = {
24
24
  message: c.message,
25
25
  cause: c.cause,
26
26
  status: c.status,
27
- data: (m = c == null ? void 0 : c.response) == null ? void 0 : m.data
28
- }) : i = c.message, (S = window.parent) == null || S.postMessage(
27
+ data: (d = c == null ? void 0 : c.response) == null ? void 0 : d.data
28
+ }) : u = c.message, (w = window.parent) == null || w.postMessage(
29
29
  {
30
30
  type: "auth_error",
31
- details: { message: i, action: s, info: y }
31
+ details: { message: u, action: t, info: y }
32
32
  },
33
33
  "*"
34
34
  );
35
- }, fe = (s) => {
36
- const [c, i] = f(!0), [y, m] = f(!1), [S, A] = f(), [g, k] = f(), [p, C] = f([]), [_, F] = f([]), E = I(
37
- async (t) => {
38
- s != null && s.onSuccess && (s == null || s.onSuccess(t)), s != null && s.onSuccessAsync && await (s == null ? void 0 : s.onSuccessAsync(t)), i(!1), m(!0), A(t.token), k(t.user), O.invalidateQueries();
35
+ }, fe = (t) => {
36
+ const [c, u] = f(!0), [y, d] = f(!1), [w, O] = f(), [o, S] = f(), [p, I] = f([]), [C, _] = f([]), g = F(
37
+ async (s) => {
38
+ t != null && t.onSuccess && (t == null || t.onSuccess(s)), t != null && t.onSuccessAsync && await (t == null ? void 0 : t.onSuccessAsync(s)), u(!1), d(!0), O(s.token), S(s.user), R.invalidateQueries();
39
39
  },
40
- [s]
41
- ), u = I(
42
- async (t, e) => {
43
- if (s.authFlow !== T.POST_MESSAGE)
44
- return x(e ?? "exchange_token", t);
45
- s != null && s.onError && (s == null || s.onError(t)), s != null && s.onErrorAsync && await (s == null ? void 0 : s.onErrorAsync(t)), i(!1);
40
+ [t]
41
+ ), l = F(
42
+ async (s, e) => {
43
+ if (t.authFlow !== k.POST_MESSAGE)
44
+ return x(e ?? "exchange_token", s);
45
+ t != null && t.onError && (t == null || t.onError(s)), t != null && t.onErrorAsync && await (t == null ? void 0 : t.onErrorAsync(s)), u(!1);
46
46
  },
47
- [s]
48
- ), R = async (t, e, r) => {
47
+ [t]
48
+ ), A = async (s, e, r) => {
49
49
  try {
50
- const { success: a, data: n, message: w } = await l.authenticateWithToken(
51
- t,
50
+ const { success: a, data: n, message: h } = await m.authenticateWithToken(
51
+ s,
52
52
  e,
53
53
  r
54
54
  );
55
55
  if (!a) {
56
- u(w);
56
+ l(h);
57
57
  return;
58
58
  }
59
59
  if (!(n != null && n.token)) {
60
- u("no awayz token returned after exchanging id token");
60
+ l("no awayz token returned after exchanging id token");
61
61
  return;
62
62
  }
63
- localStorage.setItem(o.TOKEN, n.token), await E(n);
64
- const { data: d, ...K } = await l.getRequestLimit();
63
+ localStorage.setItem(i.TOKEN, n.token), await g(n);
64
+ const { data: E, ...K } = await m.getRequestLimit();
65
65
  if (!K.success) {
66
66
  console.error({ reqLimitError: K });
67
67
  return;
68
68
  }
69
- d == null || d.forEach(
69
+ E == null || E.forEach(
70
70
  (H) => window.parent.postMessage(
71
71
  {
72
72
  type: "request_limit",
@@ -78,140 +78,151 @@ const x = (s, c) => {
78
78
  } catch (a) {
79
79
  console.error("error handling message", a);
80
80
  } finally {
81
- i(!1);
81
+ u(!1);
82
82
  }
83
83
  }, v = async () => {
84
84
  try {
85
- const { success: t, data: e } = await O.ensureQueryData({
85
+ const { success: s, data: e } = await R.ensureQueryData({
86
86
  queryKey: [N.CHECK_USER],
87
- queryFn: l.checkUser
87
+ queryFn: m.checkUser
88
88
  });
89
- if (!t) {
90
- u(e);
89
+ if (!s) {
90
+ l(e);
91
91
  return;
92
92
  }
93
- await E({
93
+ await g({
94
94
  user: e,
95
- token: localStorage.getItem(o.TOKEN)
95
+ token: localStorage.getItem(i.TOKEN)
96
96
  });
97
- } catch (t) {
98
- u(t);
97
+ } catch (s) {
98
+ l(s);
99
99
  } finally {
100
- i(!1);
100
+ u(!1);
101
101
  }
102
102
  };
103
- h(() => {
104
- if (s.authFlow !== T.STANDARD) return;
105
- localStorage.getItem(o.TOKEN) ? v() : i(!1);
103
+ T(() => {
104
+ if (t.authFlow !== k.STANDARD) return;
105
+ localStorage.getItem(i.TOKEN) ? v() : u(!1);
106
106
  }, []);
107
107
  const U = async () => {
108
- const t = await l.getRegions();
109
- C(t);
110
- const e = t.map((n) => n.currency), a = Array.from(new Set(e)).map((n) => ({
108
+ const s = await m.getRegions();
109
+ I(s);
110
+ const e = s.map((n) => n.currency), a = Array.from(new Set(e)).map((n) => ({
111
111
  code: n,
112
- symbol: M(n) || n
112
+ symbol: P(n) || n
113
113
  }));
114
- F(a);
114
+ _(a);
115
115
  };
116
- return h(() => {
116
+ return T(() => {
117
117
  U();
118
- }, []), h(() => {
119
- if (s.authFlow !== T.QUERY) return;
120
- const t = new URLSearchParams(window.location.search), e = t.get(o.TOKEN), r = t.get(o.REFRESH_TOKEN);
121
- let a = (s.isTestMode ? t.get(o.OVERRIDE_TOKEN_EXCHANGE_ENDPOINT) : void 0) || void 0;
122
- e && R(e, r ?? "", a);
123
- }, []), h(() => {
124
- if (s.authFlow !== T.POST_MESSAGE) return;
125
- const t = async (e) => {
126
- var w;
118
+ }, []), T(() => {
119
+ if (t.authFlow !== k.QUERY) return;
120
+ const s = new URLSearchParams(window.location.search), e = s.get(i.TOKEN), r = s.get(i.REFRESH_TOKEN);
121
+ let a = (t.isTestMode ? s.get(i.OVERRIDE_TOKEN_EXCHANGE_ENDPOINT) : void 0) || void 0;
122
+ e && A(e, r ?? "", a);
123
+ }, []), T(() => {
124
+ if (t.authFlow !== k.POST_MESSAGE) return;
125
+ const s = async (e) => {
126
+ var h;
127
127
  if (e.data.type !== "auth") return;
128
- const r = (w = e.data) == null ? void 0 : w.idToken, a = e.data.refreshToken, n = s.isTestMode ? e.data.overrideTokenExchangeEndpoint : void 0;
128
+ const r = (h = e.data) == null ? void 0 : h.idToken, a = e.data.refreshToken, n = t.isTestMode ? e.data.overrideTokenExchangeEndpoint : void 0;
129
129
  if (!r) {
130
- const d = `received message ${JSON.stringify(
130
+ const E = `received message ${JSON.stringify(
131
131
  e.data
132
132
  )}
133
133
  no idToken in body`;
134
- u(d);
134
+ l(E);
135
135
  return;
136
136
  }
137
- localStorage.setItem(o.REFRESH_TOKEN, a), await R(r, a, n);
137
+ localStorage.setItem(i.REFRESH_TOKEN, a), await A(r, a, n);
138
138
  };
139
- return window.addEventListener("message", t), window.parent && window.parent.postMessage(
139
+ return window.addEventListener("message", s), window.parent && window.parent.postMessage(
140
140
  {
141
141
  type: "ready"
142
142
  /* READY */
143
143
  },
144
144
  "*"
145
145
  ), () => {
146
- window.removeEventListener("message", t);
146
+ window.removeEventListener("message", s);
147
147
  };
148
148
  }, []), {
149
149
  isAuthenticating: c,
150
150
  isAuthenticated: y,
151
- token: S,
152
- user: g,
151
+ token: w,
152
+ user: o,
153
153
  supportedRegions: p,
154
- supportedCurrencies: _,
155
- signIn: async (t) => {
156
- var r;
157
- const e = await l.login(t);
158
- if (!e.success)
159
- u(e.message);
160
- else {
161
- const a = (r = e.data) == null ? void 0 : r.refreshToken;
162
- localStorage.setItem(o.REFRESH_TOKEN, a), await E(e.data);
163
- }
164
- return e;
154
+ supportedCurrencies: C,
155
+ signIn: async (s) => {
156
+ const e = await m.login(s);
157
+ return e.success ? (S(e.data.user), { success: !0, message: "OTP sent to email" }) : (l(e.message), { success: !1, message: e.message });
165
158
  },
166
- signUp: async (t) => {
159
+ signUp: async (s) => {
167
160
  var r;
168
- const e = await l.signUp(t);
161
+ const e = await m.signUp(s);
169
162
  if (!e.success)
170
- u(e.message);
163
+ l(e.message);
171
164
  else {
172
165
  const a = (r = e.data) == null ? void 0 : r.refreshToken;
173
- localStorage.setItem(o.REFRESH_TOKEN, a), await E(e.data);
166
+ localStorage.setItem(i.REFRESH_TOKEN, a), await g(e.data);
174
167
  }
175
168
  return e;
176
169
  },
177
170
  signOut: () => {
178
- localStorage.removeItem(o.TOKEN), localStorage.removeItem(o.REFRESH_TOKEN), m(!1), A(void 0), k(void 0);
171
+ localStorage.removeItem(i.TOKEN), localStorage.removeItem(i.REFRESH_TOKEN), d(!1), O(void 0), S(void 0);
179
172
  },
180
- continueWithGoogle: async (t, e) => {
173
+ continueWithGoogle: async (s, e) => {
181
174
  var a;
182
- const r = await l.getOrCreateGoogleUser(
183
- t,
175
+ const r = await m.getOrCreateGoogleUser(
176
+ s,
184
177
  e
185
178
  );
186
179
  if (!r.success)
187
- u(r.message);
180
+ l(r.message);
188
181
  else {
189
182
  const n = (a = r.data) == null ? void 0 : a.refreshToken;
190
- localStorage.setItem(o.REFRESH_TOKEN, n), await E(r.data);
183
+ localStorage.setItem(i.REFRESH_TOKEN, n), await g(r.data);
191
184
  }
192
185
  return r;
193
186
  },
194
- resendVerificationEmail: async (t) => (await l.resendVerificationEmail(t)).success,
195
- setTokens: (t, e) => {
196
- localStorage.setItem(o.TOKEN, t), localStorage.setItem(o.REFRESH_TOKEN, e), R(t, e);
187
+ resendVerificationEmail: async (s) => (await m.resendVerificationEmail(s)).success,
188
+ setTokens: (s, e) => {
189
+ localStorage.setItem(i.TOKEN, s), localStorage.setItem(i.REFRESH_TOKEN, e), A(s, e);
197
190
  },
198
- setPreferredCurrency: async (t) => {
199
- const e = await q.setCurrency(t);
191
+ setPreferredCurrency: async (s) => {
192
+ const e = await q.setCurrency(s);
200
193
  if (!e.success || !e.data)
201
194
  return console.error("Failed to set preferred currency:", e), !1;
202
- if (g) {
195
+ if (o) {
203
196
  const r = {
204
- ...g,
197
+ ...o,
205
198
  preferences: {
206
- ...g.preferences,
207
- currency: e.data.currency || g.preferences.currency
199
+ ...o.preferences,
200
+ currency: e.data.currency || o.preferences.currency
208
201
  }
209
202
  };
210
- k(r), O.invalidateQueries({
203
+ S(r), R.invalidateQueries({
211
204
  queryKey: [N.CHECK_USER]
212
205
  });
213
206
  }
214
207
  return !0;
208
+ },
209
+ verify2FA: async (s) => {
210
+ var r;
211
+ if (!(o != null && o.emailAddress)) {
212
+ const a = "No email address associated with user for 2FA verification";
213
+ return l(a), {
214
+ success: !1,
215
+ message: a
216
+ };
217
+ }
218
+ const e = await m.validate2FA(o == null ? void 0 : o.emailAddress, s);
219
+ if (!e.success)
220
+ l(e.message);
221
+ else {
222
+ const a = (r = e.data) == null ? void 0 : r.refreshToken;
223
+ localStorage.setItem(i.REFRESH_TOKEN, a), await g(e.data);
224
+ }
225
+ return e;
215
226
  }
216
227
  };
217
228
  };
@@ -1,6 +1,6 @@
1
1
  import { useQuery as g, useMutation as u } from "@tanstack/react-query";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as s } from "../../noRetryInstance-C4bqpBc7.js";
3
+ import { E as s } from "../../noRetryInstance-CbNDzU_c.js";
4
4
  import { useState as M } from "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
@@ -10,7 +10,7 @@ import "@tanstack/react-query";
10
10
  /* empty css */
11
11
  /* empty css */
12
12
  import "../../index-Cv-wvFlM.js";
13
- import { c } from "../../noRetryInstance-C4bqpBc7.js";
13
+ import { c } from "../../noRetryInstance-CbNDzU_c.js";
14
14
  import "../../context/AwayzContext.js";
15
15
  import { useBookingManagement as t } from "./useBookingManagement.js";
16
16
  import "../../configs/awayzClient.js";
@@ -1,6 +1,6 @@
1
1
  import { useQuery as O } from "@tanstack/react-query";
2
2
  import "../arrayExtensions-DlcBOj5a.js";
3
- import { E as r, t as F } from "../noRetryInstance-C4bqpBc7.js";
3
+ import { E as r, t as F } from "../noRetryInstance-CbNDzU_c.js";
4
4
  import { useMemo as N } from "react";
5
5
  import { FeatureService as e } from "../services/features/featureService.js";
6
6
  const L = [
@@ -1,6 +1,6 @@
1
1
  import { useQuery as u } from "@tanstack/react-query";
2
2
  import "../arrayExtensions-DlcBOj5a.js";
3
- import { E as m, A as c, b as f } from "../noRetryInstance-C4bqpBc7.js";
3
+ import { E as m, A as c, b as f } from "../noRetryInstance-CbNDzU_c.js";
4
4
  import { useEffect as d } from "react";
5
5
  import { useAwayzContext as y } from "./useAwayzContext.js";
6
6
  var i = /* @__PURE__ */ ((r) => (r.HOTEL = "Hotel", r.FLIGHT = "Flight", r))(i || {});
@@ -1,6 +1,6 @@
1
1
  import { useQuery as u, useMutation as p } from "@tanstack/react-query";
2
2
  import { h as m } from "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as e } from "../../noRetryInstance-C4bqpBc7.js";
3
+ import { E as e } from "../../noRetryInstance-CbNDzU_c.js";
4
4
  import "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
@@ -13,7 +13,7 @@ import { awayzClient as o } from "../../configs/awayzClient.js";
13
13
  import "../../index-Cv-wvFlM.js";
14
14
  import "../../context/AwayzContext.js";
15
15
  /* empty css */
16
- import { T as n } from "../../TripsService-fNtCUyxa.js";
16
+ import { T as n } from "../../TripsService-PQeXLB1p.js";
17
17
  const b = ({
18
18
  tripId: t,
19
19
  tripDetails: s
@@ -1,5 +1,5 @@
1
1
  import { h as p } from "../../arrayExtensions-DlcBOj5a.js";
2
- import { D as f } from "../../TripsService-fNtCUyxa.js";
2
+ import { D as f } from "../../TripsService-PQeXLB1p.js";
3
3
  import "react";
4
4
  import { renderHook as o, waitFor as i } from "../../tests/TestWrapper.js";
5
5
  import { EMyTripsEndpoints as c } from "../../configs/endpoints.js";
@@ -10,7 +10,7 @@ import '../../assets/_styles4.css';import '../../assets/_styles6.css';import '..
10
10
  /* empty css */
11
11
  import "@tanstack/react-query";
12
12
  import "../../configs/awayzClient.js";
13
- import { c as d } from "../../noRetryInstance-C4bqpBc7.js";
13
+ import { c as d } from "../../noRetryInstance-CbNDzU_c.js";
14
14
  /* empty css */
15
15
  /* empty css */
16
16
  import "../../index-Cv-wvFlM.js";
@@ -1,6 +1,6 @@
1
1
  import { useQuery as n, useMutation as s } from "@tanstack/react-query";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
- import { E as a, d as u } from "../../noRetryInstance-C4bqpBc7.js";
3
+ import { E as a, d as u } from "../../noRetryInstance-CbNDzU_c.js";
4
4
  import "react";
5
5
  import "react/jsx-runtime";
6
6
  import "react-i18next";
@@ -8,7 +8,7 @@ import '../../assets/_styles4.css';import '../../assets/_styles6.css';import '..
8
8
  /* empty css */
9
9
  import "@tanstack/react-query";
10
10
  import "../../configs/awayzClient.js";
11
- import { c as l } from "../../noRetryInstance-C4bqpBc7.js";
11
+ import { c as l } from "../../noRetryInstance-CbNDzU_c.js";
12
12
  /* empty css */
13
13
  /* empty css */
14
14
  import "../../index-Cv-wvFlM.js";
@@ -17,6 +17,7 @@ export declare enum EAuthEndpoints {
17
17
  REGIONS = "user/region",
18
18
  UPDATE_USER_REGION = "/account/update/userRegion",
19
19
  UPDATE_PASSENGER_DETAILS = "/account/awayz",
20
+ OTP = "auth/login/otp/verify",
20
21
  REFRESH_TOKEN = "auth/refresh-token",
21
22
  EXCHANGE_TOKEN = "user/exchange-token",
22
23
  REFRESH_EMBED_TOKEN = "user/refresh-token",
@@ -15,6 +15,7 @@ export interface IAwayzContext {
15
15
  supportedCurrencies: ISupportedCurrency[];
16
16
  signIn: (params: ISignInParams) => Promise<TAuthResponse>;
17
17
  signUp: (params: ISignUpParams) => Promise<TAuthResponse>;
18
+ verify2FA: (otp: string) => Promise<TAuthResponse>;
18
19
  signOut: () => void;
19
20
  continueWithGoogle: (googleAccessToken: string, region: string) => Promise<TAuthResponse>;
20
21
  resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<boolean>;
@@ -15,13 +15,8 @@ export declare const useAwayzAuth: (options: TEmbeddedAuthOptions) => {
15
15
  supportedRegions: IRegion[];
16
16
  supportedCurrencies: ISupportedCurrency[];
17
17
  signIn: (params: ISignInParams) => Promise<{
18
- success: boolean;
19
- data: IAuthData;
20
- message?: undefined;
21
- } | {
22
18
  success: boolean;
23
19
  message: any;
24
- data?: undefined;
25
20
  }>;
26
21
  signUp: (params: ISignUpParams) => Promise<{
27
22
  success: boolean;
@@ -45,5 +40,14 @@ export declare const useAwayzAuth: (options: TEmbeddedAuthOptions) => {
45
40
  resendVerificationEmail: (params: IResendVerificationEmailParams) => Promise<any>;
46
41
  setTokens: (accessToken: string, refreshToken: string) => void;
47
42
  setPreferredCurrency: (currency: string) => Promise<boolean>;
43
+ verify2FA: (code: string) => Promise<{
44
+ success: boolean;
45
+ data: IAuthData;
46
+ message?: undefined;
47
+ } | {
48
+ success: boolean;
49
+ message: any;
50
+ data?: undefined;
51
+ }>;
48
52
  };
49
53
  export {};
@@ -99,6 +99,15 @@ declare class _AccountService {
99
99
  */
100
100
  getRegions: () => Promise<IRegion[]>;
101
101
  getClientDetails: () => Promise<IClientDetails>;
102
+ validate2FA: (email: string, code: string) => Promise<{
103
+ success: boolean;
104
+ data: IAuthData;
105
+ message?: undefined;
106
+ } | {
107
+ success: boolean;
108
+ message: any;
109
+ data?: undefined;
110
+ }>;
102
111
  }
103
112
  export declare const AccountService: _AccountService;
104
113
  export {};
@@ -27,6 +27,7 @@ export interface IBooking {
27
27
  }
28
28
  export interface IHotelBooking extends IBooking {
29
29
  name: string;
30
+ accommodationName?: string;
30
31
  image: string;
31
32
  guests: number;
32
33
  tripId?: string;
package/dist/main.js CHANGED
@@ -14,7 +14,7 @@ import { useWallet as P } from "./hooks/useWallet/useWallet.js";
14
14
  import { ECancelStatus as z } from "./hooks/useBookingManagement/useBookingManagement.types.js";
15
15
  import { AwayzProvider as D } from "./providers/AwayzProvider.js";
16
16
  import { CurrencyService as O } from "./services/currency/CurrencyService.js";
17
- import { c as V, a as H, g as L, i as N } from "./noRetryInstance-C4bqpBc7.js";
17
+ import { c as V, a as H, g as L, i as N } from "./noRetryInstance-CbNDzU_c.js";
18
18
  import { RewardsService as W } from "./services/rewards/RewardsService.js";
19
19
  import { EBookingType as j } from "./services/trips/TripService.types.js";
20
20
  import { EAuthFlow as G } from "./types/EAuthFlow.js";