@ranty/ranty-sdk 3.17.0-beta.2 → 3.17.0-beta.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.
@@ -925,7 +925,7 @@ function ie(t) {
925
925
  */
926
926
  var ky;
927
927
  ((ky = window.HTMLSlotElement) === null || ky === void 0 ? void 0 : ky.prototype.assignedElements) != null;
928
- const CI = "@ranty/ranty-sdk", BI = "3.17.0-beta.2", EI = "Ranty sdk", kI = "dist/index.js", SI = {
928
+ const CI = "@ranty/ranty-sdk", BI = "3.17.0-beta.4", EI = "Ranty sdk", kI = "dist/index.js", SI = {
929
929
  ".": "./dist/index.js"
930
930
  }, II = "types/index.d.ts", TI = [
931
931
  "dist",
@@ -12603,10 +12603,16 @@ const pD = () => jt.getConfig().VITE_DATADOG_ENV !== "production", K = {
12603
12603
  };
12604
12604
  class hD {
12605
12605
  constructor() {
12606
- this._token = "", this._region = "", this.expirationTime = 0, this.key = "", this.pendingRefresh = null;
12606
+ this._token = "", this._region = "", this.expirationTime = 0, this.key = "", this.lastTokenContext = {}, this.pendingRefresh = null, this.originalCreateTokenParams = null;
12607
12607
  const e = sessionStorage.getItem("key");
12608
12608
  e && (this.key = e);
12609
12609
  }
12610
+ get token() {
12611
+ return this._token;
12612
+ }
12613
+ get region() {
12614
+ return this._region;
12615
+ }
12610
12616
  createTokenCaptcha(e) {
12611
12617
  return de(this, null, function* () {
12612
12618
  if (jt.getConfig().VITE_ENV === "sandbox")
@@ -12669,6 +12675,7 @@ class hD {
12669
12675
  createTokenWithAmplify(e, n, s, r) {
12670
12676
  return de(this, null, function* () {
12671
12677
  const i = jt.getConfig();
12678
+ sessionStorage.setItem("key", e);
12672
12679
  let o = this._region;
12673
12680
  o || (o = i.VITE_COGNITO_REGION_1);
12674
12681
  const a = o === i.VITE_COGNITO_REGION_1 ? i.VITE_COGNITO_REGION_1 : i.VITE_COGNITO_REGION_2, d = a === i.VITE_COGNITO_REGION_1 ? i.VITE_IDENTITY_POOL_ID_1 : i.VITE_IDENTITY_POOL_ID_2;
@@ -12685,13 +12692,13 @@ class hD {
12685
12692
  region: a,
12686
12693
  service: "execute-api"
12687
12694
  }, p = {
12695
+ clientid: a === i.VITE_COGNITO_REGION_1 ? i.VITE_COGNITO_CLIENT_ID_REGION_1 : i.VITE_COGNITO_CLIENT_ID_REGION_2,
12696
+ publickey: e
12697
+ }, m = {
12688
12698
  method: "POST",
12689
12699
  url: u,
12690
- headers: {
12691
- clientid: a === i.VITE_COGNITO_REGION_1 ? i.VITE_COGNITO_CLIENT_ID_REGION_1 : i.VITE_COGNITO_CLIENT_ID_REGION_2,
12692
- publickey: e
12693
- }
12694
- }, { headers: m, url: y } = A6.sign(p, c, h), _ = fy(m, []);
12700
+ headers: p
12701
+ }, { headers: y, url: _ } = A6.sign(m, c, h), N = y, { host: v } = N, x = fy(N, ["host"]);
12695
12702
  K.info("createTokenWithAmplify", {
12696
12703
  context: n,
12697
12704
  tag: "AMPLIFY_TOKEN_CREATED",
@@ -12701,14 +12708,14 @@ class hD {
12701
12708
  region: a
12702
12709
  }
12703
12710
  });
12704
- const { data: v } = yield wm.post(y, null, { headers: _ });
12705
- return v;
12711
+ const { data: j } = yield wm.post(_, null, { headers: x });
12712
+ return console.log(j), this._token = `${j.token_type} ${j.access_token}`, j;
12706
12713
  });
12707
12714
  }
12708
12715
  createToken(e, n, s, r) {
12709
12716
  return de(this, null, function* () {
12710
12717
  try {
12711
- this.key = e;
12718
+ this.key = e, this.lastTokenContext = { mode: n, isEmbedded: s, paymentRequestId: r }, this.originalCreateTokenParams = { key: e, mode: n, isEmbedded: s, paymentRequestId: r };
12712
12719
  let i, o;
12713
12720
  try {
12714
12721
  i = yield this.createTokenWithAmplify(e, n, s, r), o = this._region || jt.getConfig().VITE_COGNITO_REGION_1, K.info("createToken with Amplify success", {
@@ -12733,7 +12740,7 @@ class hD {
12733
12740
  const d = yield this.signer(e, n, s, r), { headers: l, url: c } = d;
12734
12741
  o = d.region, delete l.host, i = (yield wm.post(c, null, { headers: l })).data;
12735
12742
  }
12736
- return this._token = `${i.token_type} ${i.access_token}`, this._region = o, this.expirationTime = Date.now() + i.expires_in * 1e3, i;
12743
+ return this._token = `${i.token_type} ${i.access_token}`, this._region = o, this.expirationTime = Date.now() + i.expires_in * 1e3, sessionStorage.setItem("region", o), i;
12737
12744
  } catch (i) {
12738
12745
  throw K.error(
12739
12746
  "createTokenError",
@@ -12752,19 +12759,61 @@ class hD {
12752
12759
  }
12753
12760
  ensureValidToken() {
12754
12761
  return de(this, null, function* () {
12755
- Date.now() < this.expirationTime || (this.pendingRefresh || (this.pendingRefresh = this.createToken(this.key).catch((e) => {
12756
- throw this.pendingRefresh = null, e;
12762
+ if (K.info("ensureValidToken called", {
12763
+ tag: "TOKEN_VALIDATION",
12764
+ contextObject: {
12765
+ hasToken: !!this._token,
12766
+ isExpired: Date.now() >= this.expirationTime,
12767
+ expirationTime: this.expirationTime,
12768
+ currentTime: Date.now(),
12769
+ hasKey: !!this.key,
12770
+ lastContext: this.lastTokenContext,
12771
+ hasOriginalParams: !!this.originalCreateTokenParams
12772
+ }
12773
+ }), Date.now() < this.expirationTime)
12774
+ return;
12775
+ const e = this.originalCreateTokenParams || {
12776
+ key: this.key,
12777
+ mode: this.lastTokenContext.mode,
12778
+ isEmbedded: this.lastTokenContext.isEmbedded,
12779
+ paymentRequestId: this.lastTokenContext.paymentRequestId
12780
+ };
12781
+ this.pendingRefresh || (K.info("Starting token refresh", {
12782
+ tag: "TOKEN_REFRESH_START",
12783
+ contextObject: {
12784
+ refreshParams: {
12785
+ hasKey: !!e.key,
12786
+ mode: e.mode,
12787
+ isEmbedded: e.isEmbedded,
12788
+ paymentRequestId: e.paymentRequestId
12789
+ }
12790
+ }
12791
+ }), this.pendingRefresh = this.createToken(
12792
+ e.key,
12793
+ e.mode,
12794
+ e.isEmbedded,
12795
+ e.paymentRequestId
12796
+ ).catch((n) => {
12797
+ throw K.error(
12798
+ "Token refresh failed in ensureValidToken",
12799
+ {
12800
+ tag: "TOKEN_REFRESH_FAILED",
12801
+ contextObject: {
12802
+ error: n.message,
12803
+ refreshParams: e,
12804
+ lastContext: this.lastTokenContext
12805
+ }
12806
+ },
12807
+ n
12808
+ ), this.pendingRefresh = null, n;
12757
12809
  }).then(() => {
12758
- this.pendingRefresh = null;
12759
- })), yield this.pendingRefresh);
12810
+ K.info("Token refreshed successfully", {
12811
+ tag: "TOKEN_REFRESH_SUCCESS",
12812
+ contextObject: { newExpirationTime: this.expirationTime }
12813
+ }), this.pendingRefresh = null;
12814
+ })), yield this.pendingRefresh;
12760
12815
  });
12761
12816
  }
12762
- get token() {
12763
- return this._token;
12764
- }
12765
- get region() {
12766
- return this._region;
12767
- }
12768
12817
  }
12769
12818
  const IA = new hD(), qy = (t = !1, e, n) => {
12770
12819
  const s = wm.create();
@@ -19521,10 +19570,10 @@ function GQ(t, e, n, s) {
19521
19570
  }
19522
19571
  const zp = mQ(GQ);
19523
19572
  mL(Po(), "DD_LOGS", zp);
19524
- const WQ = "@nx-ranty/ranty-sdk", YQ = "3.17.0-beta.2", JQ = 3, XQ = !0, ZQ = {
19573
+ const WQ = "@nx-ranty/ranty-sdk", YQ = "3.17.0-beta.4", JQ = 3, XQ = !0, ZQ = {
19525
19574
  "": {
19526
19575
  name: "@nx-ranty/ranty-sdk",
19527
- version: "3.17.0-beta.2",
19576
+ version: "3.17.0-beta.4",
19528
19577
  license: "ISC",
19529
19578
  dependencies: {
19530
19579
  "@datadog/browser-logs": "^6.17.0",
@@ -65450,7 +65499,7 @@ function(t) {
65450
65499
  */
65451
65500
  function(t) {
65452
65501
  function e() {
65453
- return (yt.canvg ? Promise.resolve(yt.canvg) : import("./index.es-3cdd0721.js")).catch(function(n) {
65502
+ return (yt.canvg ? Promise.resolve(yt.canvg) : import("./index.es-cad1df1b.js")).catch(function(n) {
65454
65503
  return Promise.reject(new Error("Could not load canvg: " + n));
65455
65504
  }).then(function(n) {
65456
65505
  return n.default ? n.default : n;
@@ -1,4 +1,4 @@
1
- import { c as Ke, _ as za, g as _o } from "./index-d759ce66.js";
1
+ import { c as Ke, _ as za, g as _o } from "./index-889c7d9a.js";
2
2
  var vt = function(a) {
3
3
  return a && a.Math === Math && a;
4
4
  }, V = (
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ar as o, an as t, aq as e, ag as n, au as r, as as C, at as i, ah as p, ae as A, am as m, al as l, af as u, ap as c, ao as d, ai as F, aj as S, ak as P, A as f, M as I, X as y, R as D, B as L, ad as O, a1 as k, Z as H, a6 as g, Y as M, a7 as v, a8 as b, a9 as x, h as E, f as h, ac as Q, ab as B, $ as j, a0 as q, a2 as w, a3 as N, a4 as z, C as G, j as J, w as K, a as R, d as T, aa as U, x as V, L as W, y as X, W as Y, K as Z, z as $, G as _, J as aa, D as sa, a5 as oa, E as ta, e as ea, l as na, b as ra, F as Ca, H as ia, I as pa, V as Aa, N as ma, k as la, T as ua, P as ca, m as da, O as Fa, U as Sa, Q as Pa, n as fa, i as Ia, o as ya, p as Da, q as La, S as Oa, u as ka, r as Ha, s as ga, t as Ma, v as va } from "./index-d759ce66.js";
1
+ import { ar as o, an as t, aq as e, ag as n, au as r, as as C, at as i, ah as p, ae as A, am as m, al as l, af as u, ap as c, ao as d, ai as F, aj as S, ak as P, A as f, M as I, X as y, R as D, B as L, ad as O, a1 as k, Z as H, a6 as g, Y as M, a7 as v, a8 as b, a9 as x, h as E, f as h, ac as Q, ab as B, $ as j, a0 as q, a2 as w, a3 as N, a4 as z, C as G, j as J, w as K, a as R, d as T, aa as U, x as V, L as W, y as X, W as Y, K as Z, z as $, G as _, J as aa, D as sa, a5 as oa, E as ta, e as ea, l as na, b as ra, F as Ca, H as ia, I as pa, V as Aa, N as ma, k as la, T as ua, P as ca, m as da, O as Fa, U as Sa, Q as Pa, n as fa, i as Ia, o as ya, p as Da, q as La, S as Oa, u as ka, r as Ha, s as ga, t as Ma, v as va } from "./index-889c7d9a.js";
2
2
  export {
3
3
  o as A2AAccountDetails,
4
4
  t as A2AAccountList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ranty/ranty-sdk",
3
- "version": "3.17.0-beta.2",
3
+ "version": "3.17.0-beta.4",
4
4
  "description": "Ranty sdk",
5
5
  "main": "dist/index.js",
6
6
  "exports": {