@odynn/awayz-core 0.2.3 → 0.2.4

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,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, b as JO } from "../../AccountService-BfXbgViU.js";
4
+ import { g as ZO, b as JO } from "../../AccountService-CbMoOJMJ.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,4 +1,4 @@
1
- var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", 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.EXCHANGE_TOKEN = "user/exchange-token", e.REFRESH_TOKEN = "user/refresh-token", e.OAUTH_INITIATE = "user/oauth2/initiate", e.OAUTH_CALLBACK = "user/oauth2/callback", e))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {});
1
+ var r = /* @__PURE__ */ ((e) => (e.SIGN_IN = "auth/user-login", e.SIGN_UP = "auth/sign-up", 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))(r || {}), a = /* @__PURE__ */ ((e) => (e.CURRENCY_CONVERSION = "currency/convert", e))(a || {});
2
2
  export {
3
3
  r as EAuthEndpoints,
4
4
  a as ECurrencyEndpoints
@@ -1,4 +1,4 @@
1
- import { A as N, E as r, a as u, b as F } from "../../AccountService-BfXbgViU.js";
1
+ import { A as N, E as r, a as u, b as F } from "../../AccountService-CbMoOJMJ.js";
2
2
  import { useState as m, useCallback as x, useEffect as w } from "react";
3
3
  import { EAuthFlow as k } from "../../types/EAuthFlow.js";
4
4
  import { awayzClient as U } from "../../configs/awayzClient.js";
@@ -16,8 +16,9 @@ export declare enum EAuthEndpoints {
16
16
  REGIONS = "user/region",
17
17
  UPDATE_USER_REGION = "/account/update/userRegion",
18
18
  UPDATE_PASSENGER_DETAILS = "/account/awayz",
19
+ REFRESH_TOKEN = "auth/refresh-token",
19
20
  EXCHANGE_TOKEN = "user/exchange-token",
20
- REFRESH_TOKEN = "user/refresh-token",
21
+ REFRESH_EMBED_TOKEN = "user/refresh-token",
21
22
  OAUTH_INITIATE = "user/oauth2/initiate",
22
23
  OAUTH_CALLBACK = "user/oauth2/callback"
23
24
  }
@@ -58,15 +58,24 @@ declare class _AccountService {
58
58
  */
59
59
  checkUser: () => Promise<TServiceResponse<IUser>>;
60
60
  /**
61
- * @description In the case of a 401 error, the refresh token is used to get a new access token and user details
61
+ * @description In the case of a 401 error, the refresh token is used to get a new access token and user details, by exchanging the
62
+ * refresh token for a new id_token and in turn exchanging that for a new awayz token
62
63
  *
63
64
  * @param refreshToken - The refresh token
64
65
  */
65
- refreshToken: (refreshToken: string) => Promise<TServiceResponse<{
66
+ refreshEmbedToken: (refreshToken: string) => Promise<TServiceResponse<{
66
67
  user: IUser;
67
68
  token: string;
68
69
  id_token: string;
69
70
  }>>;
71
+ /**
72
+ * @description In the case of a 401 error, the refresh token is used to get a new access token and user details
73
+ *
74
+ * @param refreshToken - The refresh token
75
+ */
76
+ refreshToken: (refreshToken: string) => Promise<TServiceResponse<{
77
+ token: string;
78
+ }>>;
70
79
  /**
71
80
  * Retrieves the request limit for the authenticated user.
72
81
  *
@@ -1,4 +1,5 @@
1
1
  export declare enum EAuthFlow {
2
+ STANDARD = "standard",
2
3
  /** Pass the token in using window.postmessage */
3
4
  POST_MESSAGE = "postMessage",
4
5
  /** Not yet supported */
@@ -5,6 +5,7 @@ export interface ISignUpParams {
5
5
  region: string;
6
6
  successUrl?: string;
7
7
  cancelUrl?: string;
8
+ priceId: string;
8
9
  }
9
10
  export interface ISignInParams {
10
11
  email: string;
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-BfXbgViU.js";
4
+ import { c as s, i as x } from "./AccountService-CbMoOJMJ.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,37 +1,37 @@
1
- import { jsx as t } from "react/jsx-runtime";
1
+ import { jsx as r } 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 a } from "../AccountService-BfXbgViU.js";
5
- import { useAwayzAuth as s } from "../hooks/useAwayzAuth/useAwayzAuth.js";
6
- import { setBaseUrl as l } from "../configs/baseUrl.js";
4
+ import { E as e } from "../AccountService-CbMoOJMJ.js";
5
+ import { useAwayzAuth as l } from "../hooks/useAwayzAuth/useAwayzAuth.js";
6
+ import { setBaseUrl as s } from "../configs/baseUrl.js";
7
7
  import { QueryClientProvider as u } from "@tanstack/react-query";
8
8
  import { awayzClient as d } from "../configs/awayzClient.js";
9
9
  import '../assets/_styles.css';/* empty css */
10
10
  import { defaultAwayzConfig as n } from "../configs/defaultAwayzConfig.js";
11
- const C = ({ children: e, config: r }) => {
12
- const o = s({
13
- authFlow: r.authFlow,
11
+ const C = ({ children: o, config: t }) => {
12
+ const a = l({
13
+ authFlow: t.authFlow,
14
14
  onSuccess: () => {
15
15
  },
16
- trustedOrigins: r.trustedOrigins
16
+ trustedOrigins: t.trustedOrigins
17
17
  });
18
18
  return i(() => {
19
- if (!r.clientId) {
19
+ if (!t.clientId) {
20
20
  console.error("You need to provide a client ID to the AwayzProvider");
21
21
  return;
22
22
  }
23
- localStorage.setItem(a.CLIENT_ID, r.clientId), l(r.testMode ?? !1);
24
- }, [r]), /* @__PURE__ */ t(u, { client: d, children: /* @__PURE__ */ t(
23
+ localStorage.setItem(e.CLIENT_ID, t.clientId), localStorage.setItem(e.AUTH_FLOW, t.authFlow), s(t.testMode ?? !1);
24
+ }, [t]), /* @__PURE__ */ r(u, { client: d, children: /* @__PURE__ */ r(
25
25
  m.Provider,
26
26
  {
27
27
  value: {
28
- ...o,
28
+ ...a,
29
29
  config: {
30
30
  ...n,
31
- ...r
31
+ ...t
32
32
  }
33
33
  },
34
- children: e
34
+ children: o
35
35
  }
36
36
  ) });
37
37
  };
@@ -1,4 +1,4 @@
1
- import { a as p } from "../../AccountService-BfXbgViU.js";
1
+ import { a as p } from "../../AccountService-CbMoOJMJ.js";
2
2
  import "react";
3
3
  import "../../configs/endpoints.js";
4
4
  import "../../configs/awayzClient.js";
@@ -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 { a as u, b as y, c as p } from "../../AccountService-BfXbgViU.js";
4
+ import { a as u, b as y, c as p } from "../../AccountService-CbMoOJMJ.js";
5
5
  import "react";
6
6
  import { ECurrencyEndpoints as m } from "../../configs/endpoints.js";
7
7
  import "react/jsx-runtime";
@@ -1,8 +1,9 @@
1
- import { c as a, i as c } from "../AccountService-BfXbgViU.js";
1
+ import { c as p, i as a } from "../AccountService-CbMoOJMJ.js";
2
2
  import "react";
3
3
  import "../configs/endpoints.js";
4
4
  import "../configs/baseUrl.js";
5
+ import "../types/EAuthFlow.js";
5
6
  export {
6
- a as clientInstance,
7
- c as instance
7
+ p as clientInstance,
8
+ a as instance
8
9
  };
@@ -1,4 +1,4 @@
1
- var r = /* @__PURE__ */ ((e) => (e.POST_MESSAGE = "postMessage", e.OAUTH = "oauth", e.QUERY = "query", e))(r || {});
1
+ var a = /* @__PURE__ */ ((r) => (r.STANDARD = "standard", r.POST_MESSAGE = "postMessage", r.OAUTH = "oauth", r.QUERY = "query", r))(a || {});
2
2
  export {
3
- r as EAuthFlow
3
+ a as EAuthFlow
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"