@stytch/vanilla-js 4.3.1 → 4.4.0

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/index.esm.js CHANGED
@@ -1881,35 +1881,54 @@ var tt = fe(function e(t, n) {
1881
1881
  }));
1882
1882
  }, this.authenticate = function (e) {
1883
1883
  return xe(r, void 0, void 0, pe().mark(function t() {
1884
- var n, r;
1884
+ var n,
1885
+ r,
1886
+ i,
1887
+ o,
1888
+ a = this;
1885
1889
  return pe().wrap(function (t) {
1886
1890
  for (;;) switch (t.prev = t.next) {
1887
1891
  case 0:
1888
- return t.prev = 0, n = {
1892
+ return n = this._subscriptionService.getSession(), r = function r() {
1893
+ var e;
1894
+ return (null == n ? void 0 : n.session_id) !== (null === (e = a._subscriptionService.getSession()) || void 0 === e ? void 0 : e.session_id);
1895
+ }, t.prev = 2, i = {
1889
1896
  session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
1890
- }, t.next = 4, this._networkClient.fetchSDK({
1897
+ }, t.next = 6, this._networkClient.fetchSDK({
1891
1898
  url: "/sessions/authenticate",
1892
- body: n,
1899
+ body: i,
1893
1900
  errorMessage: "Error authenticating session",
1894
1901
  method: "POST"
1895
1902
  });
1896
- case 4:
1897
- return r = t.sent, this._subscriptionService.updateStateAndTokens({
1903
+ case 6:
1904
+ if (o = t.sent, !r()) {
1905
+ t.next = 9;
1906
+ break;
1907
+ }
1908
+ return t.abrupt("return", this.authenticate(e));
1909
+ case 9:
1910
+ return this._subscriptionService.updateStateAndTokens({
1898
1911
  state: {
1899
- session: r.session,
1900
- user: r.user
1912
+ session: o.session,
1913
+ user: o.user
1901
1914
  },
1902
- session_token: r.session_token,
1903
- session_jwt: r.session_jwt,
1915
+ session_token: o.session_token,
1916
+ session_jwt: o.session_jwt,
1904
1917
  intermediate_session_token: null
1905
- }), t.abrupt("return", Ye(r));
1906
- case 9:
1907
- throw t.prev = 9, t.t0 = t["catch"](0), k.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1918
+ }), t.abrupt("return", Ye(o));
1908
1919
  case 13:
1920
+ if (t.prev = 13, t.t0 = t["catch"](2), !r()) {
1921
+ t.next = 17;
1922
+ break;
1923
+ }
1924
+ return t.abrupt("return", this.authenticate(e));
1925
+ case 17:
1926
+ throw k.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1927
+ case 19:
1909
1928
  case "end":
1910
1929
  return t.stop();
1911
1930
  }
1912
- }, t, this, [[0, 9]]);
1931
+ }, t, this, [[2, 13]]);
1913
1932
  }));
1914
1933
  };
1915
1934
  }
@@ -3814,7 +3833,7 @@ var Qt = /*#__PURE__*/function () {
3814
3833
  },
3815
3834
  sdk: {
3816
3835
  identifier: "Stytch.js Javascript SDK",
3817
- version: "4.3.1"
3836
+ version: "4.4.0"
3818
3837
  }
3819
3838
  });
3820
3839
  }
@@ -7522,14 +7541,12 @@ var zs = Fs("outlook", function () {
7522
7541
  }), Ii.createElement("path", {
7523
7542
  d: "m 64.566509,22.116383 v 20.404273 l 7.130526,4.489881 c 0.188058,0.05485 0.595516,0.05877 0.783574,0 L 103.16929,26.320259 c 0,-2.44867 -2.28412,-4.203876 -3.573094,-4.203876 H 64.566509 z",
7524
7543
  id: "path3",
7525
- "inkscape:connector-curvature": "0",
7526
7544
  style: {
7527
7545
  fill: "#0072c6"
7528
7546
  }
7529
7547
  }), Ii.createElement("path", {
7530
7548
  d: "m 64.566509,50.13308 6.507584,4.470291 c 0.916782,0.673874 2.021622,0 2.021622,0 -1.100922,0.673874 30.077495,-20.035993 30.077495,-20.035993 v 37.501863 c 0,4.082422 -2.61322,5.794531 -5.551621,5.794531 H 64.562591 V 50.13308 z",
7531
7549
  id: "path5",
7532
- "inkscape:connector-curvature": "0",
7533
7550
  style: {
7534
7551
  fill: "#0072c6"
7535
7552
  }
@@ -7539,14 +7556,12 @@ var zs = Fs("outlook", function () {
7539
7556
  }, Ii.createElement("path", {
7540
7557
  d: "m 11.321,20.958 c -0.566,0 -1.017,0.266 -1.35,0.797 -0.333,0.531 -0.5,1.234 -0.5,2.109 0,0.888 0.167,1.59 0.5,2.106 0.333,0.517 0.77,0.774 1.31,0.774 0.557,0 0.999,-0.251 1.325,-0.753 0.326,-0.502 0.49,-1.199 0.49,-2.09 0,-0.929 -0.158,-1.652 -0.475,-2.169 -0.317,-0.516 -0.75,-0.774 -1.3,-0.774 z",
7541
7558
  id: "path25",
7542
- "inkscape:connector-curvature": "0",
7543
7559
  style: {
7544
7560
  fill: "#0072c6"
7545
7561
  }
7546
7562
  }), Ii.createElement("path", {
7547
7563
  d: "m 3.441,13.563 v 20.375 l 15.5,3.25 V 10.563 l -15.5,3 z m 10.372,13.632 c -0.655,0.862 -1.509,1.294 -2.563,1.294 -1.027,0 -1.863,-0.418 -2.51,-1.253 C 8.094,26.4 7.77,25.312 7.77,23.97 c 0,-1.417 0.328,-2.563 0.985,-3.438 0.657,-0.875 1.527,-1.313 2.61,-1.313 1.023,0 1.851,0.418 2.482,1.256 0.632,0.838 0.948,1.942 0.948,3.313 10e-4,1.409 -0.327,2.545 -0.982,3.407 z",
7548
7564
  id: "path27",
7549
- "inkscape:connector-curvature": "0",
7550
7565
  style: {
7551
7566
  fill: "#0072c6"
7552
7567
  }
@@ -157,8 +157,8 @@ var h, p, f, _, m, v;
157
157
  e.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", e.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", e.OTPsAuthenticate = "OTP_AUTHENTICATE", e.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", e.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", e.PasswordCreate = "PASSWORD_CREATE", e.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", e.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", e.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL", e.PasskeyRegister = "PASSKEY_REGISTER", e.PasskeyAuthenticate = "PASSKEY_AUTHENTICATE", e.PasskeySkip = "PASSKEY_SKIP", e.PasskeyDone = "PASSKEY_DONE", e.B2BMagicLinkEmailLoginOrSignup = "B2B_MAGIC_LINK_EMAIL_LOGIN_OR_SIGNUP", e.B2BMagicLinkAuthenticate = "B2B_MAGIC_LINK_AUTHENTICATE", e.B2BMagicLinkEmailDiscoverySend = "B2B_MAGIC_LINK_EMAIL_DISCOVERY_SEND", e.B2BMagicLinkDiscoveryAuthenticate = "B2B_MAGIC_LINK_DISCOVERY_AUTHENTICATE", e.B2BSSOStart = "B2B_SSO_START", e.B2BSSOAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthAuthenticate = "B2B_OAUTH_AUTHENTICATE", e.B2BOAuthDiscoveryAuthenticate = "B2B_OAUTH_DISCOVERY_AUTHENTICATE", e.B2BDiscoveryOrganizationsCreate = "B2B_DISCOVERY_ORGANIZATIONS_CREATE", e.B2BDiscoveryIntermediateSessionExchange = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE", e.B2BPasswordAuthenticate = "B2B_PASSWORD_AUTHENTICATE", e.B2BPasswordResetByEmailStart = "B2B_PASSWORD_RESET_BY_EMAIL_START", e.B2BPasswordResetByEmail = "B2B_PASSWORD_RESET_BY_EMAIL", e.B2BPasswordResetBySession = "B2B_PASSWORD_RESET_BY_SESSION";
158
158
  }(v || (v = {}));
159
159
  var y,
160
- g,
161
160
  b,
161
+ g,
162
162
  k = function (e) {
163
163
  i(c, a(Error));
164
164
  var t = s(c);
@@ -721,15 +721,15 @@ function he() {
721
721
  m = {};
722
722
  function v() {}
723
723
  function y() {}
724
- function g() {}
725
- var b = {};
726
- u(b, o, function () {
724
+ function b() {}
725
+ var g = {};
726
+ u(g, o, function () {
727
727
  return this;
728
728
  });
729
729
  var k = Object.getPrototypeOf,
730
730
  w = k && k(k(D([])));
731
- w && w !== r && n.call(w, o) && (b = w);
732
- var S = g.prototype = v.prototype = Object.create(b);
731
+ w && w !== r && n.call(w, o) && (g = w);
732
+ var S = b.prototype = v.prototype = Object.create(g);
733
733
  function C(e) {
734
734
  ["next", "throw", "return"].forEach(function (t) {
735
735
  u(e, t, function (e) {
@@ -844,17 +844,17 @@ function he() {
844
844
  }
845
845
  throw new TypeError(de(t) + " is not iterable");
846
846
  }
847
- return y.prototype = g, i(S, "constructor", {
848
- value: g,
847
+ return y.prototype = b, i(S, "constructor", {
848
+ value: b,
849
849
  configurable: !0
850
- }), i(g, "constructor", {
850
+ }), i(b, "constructor", {
851
851
  value: y,
852
852
  configurable: !0
853
- }), y.displayName = u(g, c, "GeneratorFunction"), t.isGeneratorFunction = function (e) {
853
+ }), y.displayName = u(b, c, "GeneratorFunction"), t.isGeneratorFunction = function (e) {
854
854
  var t = "function" == typeof e && e.constructor;
855
855
  return !!t && (t === y || "GeneratorFunction" === (t.displayName || t.name));
856
856
  }, t.mark = function (e) {
857
- return Object.setPrototypeOf ? Object.setPrototypeOf(e, g) : (e.__proto__ = g, u(e, c, "GeneratorFunction")), e.prototype = Object.create(S), e;
857
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, b) : (e.__proto__ = b, u(e, c, "GeneratorFunction")), e.prototype = Object.create(S), e;
858
858
  }, t.awrap = function (e) {
859
859
  return {
860
860
  __await: e
@@ -988,7 +988,7 @@ function _e(e, t) {
988
988
  if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
989
989
  }
990
990
  function me(e) {
991
- var t = ge();
991
+ var t = be();
992
992
  return function () {
993
993
  var r,
994
994
  n = ke(e);
@@ -1031,18 +1031,18 @@ function ve(e) {
1031
1031
  writable: !0,
1032
1032
  configurable: !0
1033
1033
  }
1034
- }), be(r, e);
1034
+ }), ge(r, e);
1035
1035
  }, ve(e);
1036
1036
  }
1037
1037
  function ye(e, t, r) {
1038
- return ye = ge() ? Reflect.construct.bind() : function (e, t, r) {
1038
+ return ye = be() ? Reflect.construct.bind() : function (e, t, r) {
1039
1039
  var n = [null];
1040
1040
  n.push.apply(n, t);
1041
1041
  var i = new (Function.bind.apply(e, n))();
1042
- return r && be(i, r.prototype), i;
1042
+ return r && ge(i, r.prototype), i;
1043
1043
  }, ye.apply(null, arguments);
1044
1044
  }
1045
- function ge() {
1045
+ function be() {
1046
1046
  if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
1047
1047
  if (Reflect.construct.sham) return !1;
1048
1048
  if ("function" == typeof Proxy) return !0;
@@ -1052,10 +1052,10 @@ function ge() {
1052
1052
  return !1;
1053
1053
  }
1054
1054
  }
1055
- function be(e, t) {
1056
- return be = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
1055
+ function ge(e, t) {
1056
+ return ge = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (e, t) {
1057
1057
  return e.__proto__ = t, e;
1058
- }, be(e, t);
1058
+ }, ge(e, t);
1059
1059
  }
1060
1060
  function ke(e) {
1061
1061
  return ke = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (e) {
@@ -1066,9 +1066,9 @@ function ke(e) {
1066
1066
  e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
1067
1067
  }(y || (y = {})), function (e) {
1068
1068
  e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
1069
- }(g || (g = {})), function (e) {
1069
+ }(b || (b = {})), function (e) {
1070
1070
  e.Google = "google", e.Microsoft = "microsoft";
1071
- }(b || (b = {}));
1071
+ }(g || (g = {}));
1072
1072
  var we,
1073
1073
  Se = "https://accounts.google.com/gsi",
1074
1074
  Ce = "".concat(Se, "/client");
@@ -1121,7 +1121,7 @@ var Pe,
1121
1121
  }
1122
1122
  }), Object.defineProperty(e, "prototype", {
1123
1123
  writable: !1
1124
- }), t && be(e, t);
1124
+ }), t && ge(e, t);
1125
1125
  }(r, ve(Error));
1126
1126
  var t = me(r);
1127
1127
  function r(e) {
@@ -1872,35 +1872,54 @@ var Qe = fe(function e(t, r) {
1872
1872
  }));
1873
1873
  }, this.authenticate = function (e) {
1874
1874
  return Oe(n, void 0, void 0, he().mark(function t() {
1875
- var r, n;
1875
+ var r,
1876
+ n,
1877
+ i,
1878
+ s,
1879
+ o = this;
1876
1880
  return he().wrap(function (t) {
1877
1881
  for (;;) switch (t.prev = t.next) {
1878
1882
  case 0:
1879
- return t.prev = 0, r = {
1883
+ return r = this._subscriptionService.getSession(), n = function n() {
1884
+ var e;
1885
+ return (null == r ? void 0 : r.session_id) !== (null === (e = o._subscriptionService.getSession()) || void 0 === e ? void 0 : e.session_id);
1886
+ }, t.prev = 2, i = {
1880
1887
  session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
1881
- }, t.next = 4, this._networkClient.fetchSDK({
1888
+ }, t.next = 6, this._networkClient.fetchSDK({
1882
1889
  url: "/sessions/authenticate",
1883
- body: r,
1890
+ body: i,
1884
1891
  errorMessage: "Error authenticating session",
1885
1892
  method: "POST"
1886
1893
  });
1887
- case 4:
1888
- return n = t.sent, this._subscriptionService.updateStateAndTokens({
1894
+ case 6:
1895
+ if (s = t.sent, !n()) {
1896
+ t.next = 9;
1897
+ break;
1898
+ }
1899
+ return t.abrupt("return", this.authenticate(e));
1900
+ case 9:
1901
+ return this._subscriptionService.updateStateAndTokens({
1889
1902
  state: {
1890
- session: n.session,
1891
- user: n.user
1903
+ session: s.session,
1904
+ user: s.user
1892
1905
  },
1893
- session_token: n.session_token,
1894
- session_jwt: n.session_jwt,
1906
+ session_token: s.session_token,
1907
+ session_jwt: s.session_jwt,
1895
1908
  intermediate_session_token: null
1896
- }), t.abrupt("return", Ve(n));
1897
- case 9:
1898
- throw t.prev = 9, t.t0 = t["catch"](0), T.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1909
+ }), t.abrupt("return", Ve(s));
1899
1910
  case 13:
1911
+ if (t.prev = 13, t.t0 = t["catch"](2), !n()) {
1912
+ t.next = 17;
1913
+ break;
1914
+ }
1915
+ return t.abrupt("return", this.authenticate(e));
1916
+ case 17:
1917
+ throw T.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1918
+ case 19:
1900
1919
  case "end":
1901
1920
  return t.stop();
1902
1921
  }
1903
- }, t, this, [[0, 9]]);
1922
+ }, t, this, [[2, 13]]);
1904
1923
  }));
1905
1924
  };
1906
1925
  }
@@ -2769,7 +2788,7 @@ var _t = {
2769
2788
  }),
2770
2789
  signal: ft(ut)
2771
2790
  },
2772
- gt = {
2791
+ bt = {
2773
2792
  type: pt(ut),
2774
2793
  id: pt(ut),
2775
2794
  rawId: pt(lt),
@@ -2786,7 +2805,7 @@ var _t = {
2786
2805
  return e.getClientExtensionResults();
2787
2806
  })
2788
2807
  },
2789
- bt = {
2808
+ gt = {
2790
2809
  mediation: ft(ut),
2791
2810
  publicKey: pt({
2792
2811
  challenge: pt(lt),
@@ -2817,7 +2836,7 @@ function wt(e) {
2817
2836
  return dt(at, yt, e);
2818
2837
  }
2819
2838
  function St(e) {
2820
- return dt(ct, gt, e);
2839
+ return dt(ct, bt, e);
2821
2840
  }
2822
2841
  function Ct(e) {
2823
2842
  return Oe(this, void 0, void 0, he().mark(function t() {
@@ -2836,7 +2855,7 @@ function Ct(e) {
2836
2855
  }));
2837
2856
  }
2838
2857
  function Tt(e) {
2839
- return dt(at, bt, e);
2858
+ return dt(at, gt, e);
2840
2859
  }
2841
2860
  function Ot(e) {
2842
2861
  return dt(ct, kt, e);
@@ -3796,7 +3815,7 @@ var Nt = /*#__PURE__*/function () {
3796
3815
  },
3797
3816
  sdk: {
3798
3817
  identifier: "Stytch.js Javascript SDK",
3799
- version: "4.3.1"
3818
+ version: "4.4.0"
3800
3819
  }
3801
3820
  });
3802
3821
  }
@@ -4676,16 +4695,16 @@ var ir = /*#__PURE__*/_createClass(function ir(e, t) {
4676
4695
  });
4677
4696
  var v = new Ft(e, this._networkClient, this._dataLayer),
4678
4697
  y = new Lt(v.getAsync()),
4679
- g = new Je(e, i.endpoints.dfpBackendURL, v.getAsync(), y.executeRecaptcha),
4680
- b = new Bt(i.endpoints.clientsideServicesIframeURL),
4681
- k = new Kt(e, b),
4698
+ b = new Je(e, i.endpoints.dfpBackendURL, v.getAsync(), y.executeRecaptcha),
4699
+ g = new Bt(i.endpoints.clientsideServicesIframeURL),
4700
+ k = new Kt(e, g),
4682
4701
  w = new Gt(this._networkClient);
4683
4702
  var S, C;
4684
- this.user = new Qe(this._networkClient, this._subscriptionService), this.session = new et(this._networkClient, this._subscriptionService), this.magicLinks = new rt(this._networkClient, this._subscriptionService, new Wt(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.otps = new nt(this._networkClient, this._subscriptionService, y.executeRecaptcha, g), this.oauth = new Mt(this._networkClient, this._subscriptionService, new Wt(this._dataLayer, "oauth"), v.getAsync(), {
4703
+ this.user = new Qe(this._networkClient, this._subscriptionService), this.session = new et(this._networkClient, this._subscriptionService), this.magicLinks = new rt(this._networkClient, this._subscriptionService, new Wt(this._dataLayer, "magic_links"), m, v.getAsync(), b), this.otps = new nt(this._networkClient, this._subscriptionService, y.executeRecaptcha, b), this.oauth = new Mt(this._networkClient, this._subscriptionService, new Wt(this._dataLayer, "oauth"), v.getAsync(), {
4685
4704
  publicToken: e,
4686
4705
  testAPIURL: i.endpoints.testAPIURL,
4687
4706
  liveAPIURL: i.endpoints.liveAPIURL
4688
- }, k), this.cryptoWallets = new st(this._networkClient, this._subscriptionService, y.executeRecaptcha, g), this.totps = new ot(this._networkClient, this._subscriptionService, g), this.webauthn = new At(this._networkClient, this._subscriptionService, g), this.passwords = new Et(this._networkClient, this._subscriptionService, m, v.getAsync(), g), this._sessionManager = new Rt(this._subscriptionService, this.session), this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
4707
+ }, k), this.cryptoWallets = new st(this._networkClient, this._subscriptionService, y.executeRecaptcha, b), this.totps = new ot(this._networkClient, this._subscriptionService, b), this.webauthn = new At(this._networkClient, this._subscriptionService, b), this.passwords = new Et(this._networkClient, this._subscriptionService, m, v.getAsync(), b), this._sessionManager = new Rt(this._subscriptionService, this.session), this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
4689
4708
  name: "sdk_instance_instantiated",
4690
4709
  details: {
4691
4710
  event_callback_registered: !1,
@@ -4694,7 +4713,7 @@ var ir = /*#__PURE__*/_createClass(function ir(e, t) {
4694
4713
  }
4695
4714
  }), S = this, C = {
4696
4715
  bootstrap: v,
4697
- clientsideServices: b,
4716
+ clientsideServices: g,
4698
4717
  captcha: y,
4699
4718
  oneTap: k,
4700
4719
  searchManager: w,
@@ -4703,4 +4722,4 @@ var ir = /*#__PURE__*/_createClass(function ir(e, t) {
4703
4722
  networkClient: this._networkClient
4704
4723
  }, Object.assign(S, _defineProperty({}, nr, C));
4705
4724
  });
4706
- export { g as AuthFlowType, b as B2BOAuthProviders, y as B2BProducts, X as BiometricsFailedError, F as BiometricsUnavailableError, z as ChallengeSigningFailedError, U as DeviceCredentialsNotAllowedError, V as FailedCodeChallengeError, $ as FailedToDecryptDataError, R as InternalError, G as InvalidAuthorizationCredentialError, te as InvalidCredentialTypeError, Q as InvalidRedirectSchemeError, Z as InvalidStartUrlError, ne as JSONDataNotConvertibleToStringError, j as KeyInvalidatedError, L as KeystoreUnavailableError, re as MissingAttestationObjectError, W as MissingAuthorizationCredentialIDTokenError, K as MissingGoogleClientIDError, q as MissingPKCEError, H as MissingPublicKeyError, ee as MissingUrlError, B as NoBiometricsEnrolledError, I as NoBiometricsRegistrationError, D as NoCurrentSessionError, p as OAuthProviders, m as OTPMethods, _ as OneTapPositions, se as PasskeysInvalidEncoding, J as PasskeysUnsupportedError, h as Products, ie as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, x as StytchAPIError, A as StytchAPISchemaError, P as StytchAPIUnreachableError, O as StytchError, v as StytchEventType, ir as StytchHeadlessClient, C as StytchSDKAPIError, E as StytchSDKError, S as StytchSDKSchemaError, w as StytchSDKUsageError, T as UNRECOVERABLE_ERROR_TYPES, M as UserCancellationError, N as UserLockedOutError, f as Wallets, oe as errorToStytchError };
4725
+ export { b as AuthFlowType, g as B2BOAuthProviders, y as B2BProducts, X as BiometricsFailedError, F as BiometricsUnavailableError, z as ChallengeSigningFailedError, U as DeviceCredentialsNotAllowedError, V as FailedCodeChallengeError, $ as FailedToDecryptDataError, R as InternalError, G as InvalidAuthorizationCredentialError, te as InvalidCredentialTypeError, Q as InvalidRedirectSchemeError, Z as InvalidStartUrlError, ne as JSONDataNotConvertibleToStringError, j as KeyInvalidatedError, L as KeystoreUnavailableError, re as MissingAttestationObjectError, W as MissingAuthorizationCredentialIDTokenError, K as MissingGoogleClientIDError, q as MissingPKCEError, H as MissingPublicKeyError, ee as MissingUrlError, B as NoBiometricsEnrolledError, I as NoBiometricsRegistrationError, D as NoCurrentSessionError, p as OAuthProviders, m as OTPMethods, _ as OneTapPositions, se as PasskeysInvalidEncoding, J as PasskeysUnsupportedError, h as Products, ie as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, x as StytchAPIError, A as StytchAPISchemaError, P as StytchAPIUnreachableError, O as StytchError, v as StytchEventType, ir as StytchHeadlessClient, C as StytchSDKAPIError, E as StytchSDKError, S as StytchSDKSchemaError, w as StytchSDKUsageError, T as UNRECOVERABLE_ERROR_TYPES, M as UserCancellationError, N as UserLockedOutError, f as Wallets, oe as errorToStytchError };
@@ -1790,35 +1790,54 @@ var Ze = pe(function e(t, r) {
1790
1790
  }));
1791
1791
  }, this.authenticate = function (e) {
1792
1792
  return Pe(n, void 0, void 0, de().mark(function t() {
1793
- var r, n;
1793
+ var r,
1794
+ n,
1795
+ i,
1796
+ s,
1797
+ o = this;
1794
1798
  return de().wrap(function (t) {
1795
1799
  for (;;) switch (t.prev = t.next) {
1796
1800
  case 0:
1797
- return t.prev = 0, r = {
1801
+ return r = this._subscriptionService.getSession(), n = function n() {
1802
+ var e;
1803
+ return (null == r ? void 0 : r.session_id) !== (null === (e = o._subscriptionService.getSession()) || void 0 === e ? void 0 : e.session_id);
1804
+ }, t.prev = 2, i = {
1798
1805
  session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
1799
- }, t.next = 4, this._networkClient.fetchSDK({
1806
+ }, t.next = 6, this._networkClient.fetchSDK({
1800
1807
  url: "/sessions/authenticate",
1801
- body: r,
1808
+ body: i,
1802
1809
  errorMessage: "Error authenticating session",
1803
1810
  method: "POST"
1804
1811
  });
1805
- case 4:
1806
- return n = t.sent, this._subscriptionService.updateStateAndTokens({
1812
+ case 6:
1813
+ if (s = t.sent, !n()) {
1814
+ t.next = 9;
1815
+ break;
1816
+ }
1817
+ return t.abrupt("return", this.authenticate(e));
1818
+ case 9:
1819
+ return this._subscriptionService.updateStateAndTokens({
1807
1820
  state: {
1808
- session: n.session,
1809
- user: n.user
1821
+ session: s.session,
1822
+ user: s.user
1810
1823
  },
1811
- session_token: n.session_token,
1812
- session_jwt: n.session_jwt,
1824
+ session_token: s.session_token,
1825
+ session_jwt: s.session_jwt,
1813
1826
  intermediate_session_token: null
1814
- }), t.abrupt("return", Ye(n));
1815
- case 9:
1816
- throw t.prev = 9, t.t0 = t["catch"](0), P.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1827
+ }), t.abrupt("return", Ye(s));
1817
1828
  case 13:
1829
+ if (t.prev = 13, t.t0 = t["catch"](2), !n()) {
1830
+ t.next = 17;
1831
+ break;
1832
+ }
1833
+ return t.abrupt("return", this.authenticate(e));
1834
+ case 17:
1835
+ throw P.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1836
+ case 19:
1818
1837
  case "end":
1819
1838
  return t.stop();
1820
1839
  }
1821
- }, t, this, [[0, 9]]);
1840
+ }, t, this, [[2, 13]]);
1822
1841
  }));
1823
1842
  };
1824
1843
  }
@@ -3714,7 +3733,7 @@ var Mt = /*#__PURE__*/function () {
3714
3733
  },
3715
3734
  sdk: {
3716
3735
  identifier: "Stytch.js Javascript SDK",
3717
- version: "4.3.1"
3736
+ version: "4.4.0"
3718
3737
  }
3719
3738
  });
3720
3739
  }
package/dist/index.js CHANGED
@@ -1813,35 +1813,54 @@ var Ze = oe(function e(t, n) {
1813
1813
  }));
1814
1814
  }, this.authenticate = function (e) {
1815
1815
  return ge(r, void 0, void 0, ne().mark(function t() {
1816
- var n, r;
1816
+ var n,
1817
+ r,
1818
+ o,
1819
+ i,
1820
+ a = this;
1817
1821
  return ne().wrap(function (t) {
1818
1822
  for (;;) switch (t.prev = t.next) {
1819
1823
  case 0:
1820
- return t.prev = 0, n = {
1824
+ return n = this._subscriptionService.getSession(), r = function r() {
1825
+ var e;
1826
+ return (null == n ? void 0 : n.session_id) !== (null === (e = a._subscriptionService.getSession()) || void 0 === e ? void 0 : e.session_id);
1827
+ }, t.prev = 2, o = {
1821
1828
  session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
1822
- }, t.next = 4, this._networkClient.fetchSDK({
1829
+ }, t.next = 6, this._networkClient.fetchSDK({
1823
1830
  url: "/sessions/authenticate",
1824
- body: n,
1831
+ body: o,
1825
1832
  errorMessage: "Error authenticating session",
1826
1833
  method: "POST"
1827
1834
  });
1828
- case 4:
1829
- return r = t.sent, this._subscriptionService.updateStateAndTokens({
1835
+ case 6:
1836
+ if (i = t.sent, !r()) {
1837
+ t.next = 9;
1838
+ break;
1839
+ }
1840
+ return t.abrupt("return", this.authenticate(e));
1841
+ case 9:
1842
+ return this._subscriptionService.updateStateAndTokens({
1830
1843
  state: {
1831
- session: r.session,
1832
- user: r.user
1844
+ session: i.session,
1845
+ user: i.user
1833
1846
  },
1834
- session_token: r.session_token,
1835
- session_jwt: r.session_jwt,
1847
+ session_token: i.session_token,
1848
+ session_jwt: i.session_jwt,
1836
1849
  intermediate_session_token: null
1837
- }), t.abrupt("return", Ue(r));
1838
- case 9:
1839
- throw t.prev = 9, t.t0 = t["catch"](0), A.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1850
+ }), t.abrupt("return", Ue(i));
1840
1851
  case 13:
1852
+ if (t.prev = 13, t.t0 = t["catch"](2), !r()) {
1853
+ t.next = 17;
1854
+ break;
1855
+ }
1856
+ return t.abrupt("return", this.authenticate(e));
1857
+ case 17:
1858
+ throw A.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
1859
+ case 19:
1841
1860
  case "end":
1842
1861
  return t.stop();
1843
1862
  }
1844
- }, t, this, [[0, 9]]);
1863
+ }, t, this, [[2, 13]]);
1845
1864
  }));
1846
1865
  };
1847
1866
  }
@@ -3746,7 +3765,7 @@ var It = /*#__PURE__*/function () {
3746
3765
  },
3747
3766
  sdk: {
3748
3767
  identifier: "Stytch.js Javascript SDK",
3749
- version: "4.3.1"
3768
+ version: "4.4.0"
3750
3769
  }
3751
3770
  });
3752
3771
  }
@@ -7454,14 +7473,12 @@ var Ls = Ms("outlook", function () {
7454
7473
  }), bo.createElement("path", {
7455
7474
  d: "m 64.566509,22.116383 v 20.404273 l 7.130526,4.489881 c 0.188058,0.05485 0.595516,0.05877 0.783574,0 L 103.16929,26.320259 c 0,-2.44867 -2.28412,-4.203876 -3.573094,-4.203876 H 64.566509 z",
7456
7475
  id: "path3",
7457
- "inkscape:connector-curvature": "0",
7458
7476
  style: {
7459
7477
  fill: "#0072c6"
7460
7478
  }
7461
7479
  }), bo.createElement("path", {
7462
7480
  d: "m 64.566509,50.13308 6.507584,4.470291 c 0.916782,0.673874 2.021622,0 2.021622,0 -1.100922,0.673874 30.077495,-20.035993 30.077495,-20.035993 v 37.501863 c 0,4.082422 -2.61322,5.794531 -5.551621,5.794531 H 64.562591 V 50.13308 z",
7463
7481
  id: "path5",
7464
- "inkscape:connector-curvature": "0",
7465
7482
  style: {
7466
7483
  fill: "#0072c6"
7467
7484
  }
@@ -7471,14 +7488,12 @@ var Ls = Ms("outlook", function () {
7471
7488
  }, bo.createElement("path", {
7472
7489
  d: "m 11.321,20.958 c -0.566,0 -1.017,0.266 -1.35,0.797 -0.333,0.531 -0.5,1.234 -0.5,2.109 0,0.888 0.167,1.59 0.5,2.106 0.333,0.517 0.77,0.774 1.31,0.774 0.557,0 0.999,-0.251 1.325,-0.753 0.326,-0.502 0.49,-1.199 0.49,-2.09 0,-0.929 -0.158,-1.652 -0.475,-2.169 -0.317,-0.516 -0.75,-0.774 -1.3,-0.774 z",
7473
7490
  id: "path25",
7474
- "inkscape:connector-curvature": "0",
7475
7491
  style: {
7476
7492
  fill: "#0072c6"
7477
7493
  }
7478
7494
  }), bo.createElement("path", {
7479
7495
  d: "m 3.441,13.563 v 20.375 l 15.5,3.25 V 10.563 l -15.5,3 z m 10.372,13.632 c -0.655,0.862 -1.509,1.294 -2.563,1.294 -1.027,0 -1.863,-0.418 -2.51,-1.253 C 8.094,26.4 7.77,25.312 7.77,23.97 c 0,-1.417 0.328,-2.563 0.985,-3.438 0.657,-0.875 1.527,-1.313 2.61,-1.313 1.023,0 1.851,0.418 2.482,1.256 0.632,0.838 0.948,1.942 0.948,3.313 10e-4,1.409 -0.327,2.545 -0.982,3.407 z",
7480
7496
  id: "path27",
7481
- "inkscape:connector-curvature": "0",
7482
7497
  style: {
7483
7498
  fill: "#0072c6"
7484
7499
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stytch/vanilla-js",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "Stytch's official Javascript Client Library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -30,7 +30,7 @@
30
30
  "user"
31
31
  ],
32
32
  "dependencies": {
33
- "@stytch/core": "2.4.1",
33
+ "@stytch/core": "2.5.0",
34
34
  "@types/google-one-tap": "^1.2.0"
35
35
  },
36
36
  "devDependencies": {