@stytch/vanilla-js 4.11.0 → 4.11.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 4.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [07b310a]
8
+ - @stytch/core@2.15.2
9
+
10
+ ## 4.11.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 2e33560: Loosen typings for various options to accept both string literals and TypeScript enums
15
+ - db67d12: Show error when slug is missing or no slug pattern matches during B2B Organization auth flow
16
+ - Updated dependencies [2e33560]
17
+ - @stytch/core@2.15.1
18
+
3
19
  ## 4.11.0
4
20
 
5
21
  ### Minor Changes
@@ -4354,7 +4354,7 @@ var Nt = /*#__PURE__*/function () {
4354
4354
  },
4355
4355
  sdk: {
4356
4356
  identifier: "Stytch.js Javascript SDK",
4357
- version: "4.11.0"
4357
+ version: "4.11.2"
4358
4358
  }
4359
4359
  });
4360
4360
  }
@@ -13784,6 +13784,17 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
13784
13784
  }),
13785
13785
  th = cs.img(_templateObject51 || (_templateObject51 = _taggedTemplateLiteral(["\n width: 150px;\n"]))),
13786
13786
  nh = function nh() {
13787
+ var e = new URL(window.location.href);
13788
+ return {
13789
+ tokenType: e.searchParams.get("stytch_token_type"),
13790
+ token: e.searchParams.get("token")
13791
+ };
13792
+ },
13793
+ rh = new Set(["discovery", "discovery_oauth", "oauth", "sso", "multi_tenant_magic_links"]),
13794
+ oh = function oh(e) {
13795
+ return !(!e || !rh.has(e));
13796
+ },
13797
+ ih = function ih() {
13787
13798
  var _s5;
13788
13799
  var _Es55 = Es(),
13789
13800
  _Es56 = _slicedToArray(_Es55, 2),
@@ -13878,17 +13889,18 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
13878
13889
  }),
13879
13890
  v = _u18.trigger,
13880
13891
  b = _u18.isMutating,
13892
+ w = p || A || b || g || m,
13881
13893
  _ref124 = function () {
13882
13894
  var _Es57 = Es(),
13883
13895
  _Es58 = _slicedToArray(_Es57, 2),
13884
13896
  e = _Es58[0],
13885
13897
  t = _Es58[1],
13886
- _mr57 = mr(null),
13898
+ _mr57 = mr(),
13887
13899
  _mr58 = _slicedToArray(_mr57, 2),
13888
13900
  n = _mr58[0],
13889
13901
  r = _mr58[1],
13890
13902
  o = ks(),
13891
- i = bu(n),
13903
+ i = bu(n || null),
13892
13904
  _u19 = _u("stytchClient.organization.getBySlug", function (e, _ref130) {
13893
13905
  var t = _ref130.arg.slug;
13894
13906
  return o.organization.getBySlug({
@@ -13918,27 +13930,64 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
13918
13930
  slug: i
13919
13931
  });
13920
13932
  }, [i, e.flowState, e.screen]), {
13921
- isSearching: s
13933
+ isSearching: s,
13934
+ slug: i,
13935
+ pattern: n
13922
13936
  };
13923
13937
  }(),
13924
- w = _ref124.isSearching;
13938
+ k = _ref124.isSearching,
13939
+ E = _ref124.slug,
13940
+ S = _ref124.pattern;
13941
+ gr(function () {
13942
+ if (i) return;
13943
+ if (e.flowState.type == y.PasswordReset) return;
13944
+ var _nh = nh(),
13945
+ t = _nh.tokenType,
13946
+ n = _nh.token;
13947
+ if (n && oh(t) && !w) switch (t) {
13948
+ case "discovery":
13949
+ v({
13950
+ token: n
13951
+ });
13952
+ break;
13953
+ case "discovery_oauth":
13954
+ f({
13955
+ token: n
13956
+ });
13957
+ break;
13958
+ case "oauth":
13959
+ h({
13960
+ token: n
13961
+ });
13962
+ break;
13963
+ case "sso":
13964
+ _({
13965
+ token: n
13966
+ });
13967
+ break;
13968
+ case "multi_tenant_magic_links":
13969
+ d({
13970
+ token: n
13971
+ });
13972
+ break;
13973
+ default:
13974
+ return function () {
13975
+ throw new Error("Assertion failure");
13976
+ }();
13977
+ }
13978
+ }, []);
13979
+ var C = Cs();
13925
13980
  return gr(function () {
13926
13981
  if (i) return;
13927
- var t = new URL(window.location.href),
13928
- n = t.searchParams.get("stytch_token_type"),
13929
- r = t.searchParams.get("token");
13930
- e.flowState.type != y.PasswordReset && r && n && ("discovery" === n ? v({
13931
- token: r
13932
- }) : "discovery_oauth" === n ? f({
13933
- token: r
13934
- }) : "oauth" === n ? h({
13935
- token: r
13936
- }) : "sso" === n ? _({
13937
- token: r
13938
- }) : "multi_tenant_magic_links" === n && d({
13939
- token: r
13940
- }));
13941
- }, []), i ? Mo.createElement(hd, null) : p || A || b || g || m ? Mo.createElement(eh, null, Mo.createElement(Id, null)) : w ? Mo.createElement(eh, null, Mo.createElement(Bd, null)) : Mo.createElement(eh, null, s[a], Mo.createElement(rl, null), o && Mo.createElement(al, {
13982
+ if (w) return;
13983
+ var _nh2 = nh(),
13984
+ n = _nh2.tokenType,
13985
+ r = _nh2.token;
13986
+ r && oh(n) || E || void 0 === S || k || null !== e.flowState.organization || e.screen !== _s.Main || e.flowState.type != y.Organization || t({
13987
+ type: "transition",
13988
+ screen: _s.ErrorOrganization
13989
+ });
13990
+ }, [t, i, k, w, S, E, e.flowState.organization, e.flowState.type, e.screen, C]), i ? Mo.createElement(hd, null) : w ? Mo.createElement(eh, null, Mo.createElement(Id, null)) : k ? Mo.createElement(eh, null, Mo.createElement(Bd, null)) : Mo.createElement(eh, null, s[a], Mo.createElement(rl, null), o && Mo.createElement(al, {
13942
13991
  justifyContent: "center",
13943
13992
  marginTop: 24
13944
13993
  }, Mo.createElement("a", {
@@ -13950,8 +13999,8 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
13950
13999
  src: "https://public-assets.stytch.com/et_powered_by_stytch_logo.png"
13951
14000
  }))));
13952
14001
  },
13953
- rh = "stytch-b2b-ui",
13954
- oh = (ih = function ih(_ref133) {
14002
+ ah = "stytch-b2b-ui",
14003
+ sh = (ch = function ch(_ref133) {
13955
14004
  var e = _ref133.client,
13956
14005
  t = _ref133.styles,
13957
14006
  n = _ref133.callbacks,
@@ -13992,8 +14041,8 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
13992
14041
  initialState: a
13993
14042
  }, Mo.createElement(ns, {
13994
14043
  theme: s
13995
- }, Mo.createElement(nh, null)));
13996
- }, ah = rh, "undefined" == typeof window ? function () {
14044
+ }, Mo.createElement(ih, null)));
14045
+ }, lh = ah, "undefined" == typeof window ? function () {
13997
14046
  return null;
13998
14047
  } : function (e) {
13999
14048
  if (e.config.enableShadowDOM) {
@@ -14043,7 +14092,7 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
14043
14092
  return r;
14044
14093
  }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
14045
14094
  return customElements.define(t, r), r;
14046
- }(ih, ah);
14095
+ }(ch, lh);
14047
14096
  return new _t11(e);
14048
14097
  }
14049
14098
  {
@@ -14081,26 +14130,26 @@ var Kp = cs.button(_templateObject45 || (_templateObject45 = _taggedTemplateLite
14081
14130
  return r;
14082
14131
  }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
14083
14132
  return customElements.define(t, r), r;
14084
- }(ih, ah);
14133
+ }(ch, lh);
14085
14134
  return new _t12(e);
14086
14135
  }
14087
14136
  });
14088
- var ih, ah;
14089
- var sh = /*#__PURE__*/function (_mn) {
14090
- _inherits(sh, _mn);
14091
- function sh() {
14137
+ var ch, lh;
14138
+ var uh = /*#__PURE__*/function (_mn) {
14139
+ _inherits(uh, _mn);
14140
+ function uh() {
14092
14141
  var _this15;
14093
- _classCallCheck(this, sh);
14142
+ _classCallCheck(this, uh);
14094
14143
  for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
14095
14144
  e[_key6] = arguments[_key6];
14096
14145
  }
14097
14146
  !function (e) {
14098
14147
  var t = "StytchUIClient" === e ? "import { createStytchUIClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchUIClient('public-token-...');\n" : "import { createStytchHeadlessClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchHeadlessClient('public-token-...');\n";
14099
14148
  if ("undefined" == typeof window) throw new Error("The ".concat(e, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e, " method instead.\n```\n").concat(t, "\n```\n"));
14100
- }("StytchUIClient"), _this15 = _callSuper(this, sh, [].concat(e));
14149
+ }("StytchUIClient"), _this15 = _callSuper(this, uh, [].concat(e));
14101
14150
  return _this15;
14102
14151
  }
14103
- _createClass(sh, [{
14152
+ _createClass(uh, [{
14104
14153
  key: "mount",
14105
14154
  value: function mount(_ref135) {
14106
14155
  var e = _ref135.elementId,
@@ -14112,7 +14161,7 @@ var sh = /*#__PURE__*/function (_mn) {
14112
14161
  if (!i) {
14113
14162
  throw new Error("The selector you specified (".concat(e, ") applies to no DOM elements that are currently on the page. Make sure the element exists on the page before calling mountLogin()."));
14114
14163
  }
14115
- if ((null === (o = i.firstChild) || void 0 === o ? void 0 : o.nodeName.toLowerCase()) === rh.toLowerCase()) {
14164
+ if ((null === (o = i.firstChild) || void 0 === o ? void 0 : o.nodeName.toLowerCase()) === ah.toLowerCase()) {
14116
14165
  return void i.firstChild.render({
14117
14166
  client: this,
14118
14167
  config: r,
@@ -14120,7 +14169,7 @@ var sh = /*#__PURE__*/function (_mn) {
14120
14169
  styles: t
14121
14170
  });
14122
14171
  }
14123
- var a = oh({
14172
+ var a = sh({
14124
14173
  client: this,
14125
14174
  config: r,
14126
14175
  callbacks: n,
@@ -14129,6 +14178,6 @@ var sh = /*#__PURE__*/function (_mn) {
14129
14178
  i.appendChild(a);
14130
14179
  }
14131
14180
  }]);
14132
- return sh;
14181
+ return uh;
14133
14182
  }(mn);
14134
- export { y as AuthFlowType, b as B2BMFAProducts, w as B2BOAuthProviders, v as B2BProducts, ee as BiometricsFailedError, L as BiometricsUnavailableError, W as ChallengeSigningFailedError, Q as DeviceCredentialsNotAllowedError, J as FailedCodeChallengeError, X as FailedToDecryptDataError, M as InternalError, V as InvalidAuthorizationCredentialError, oe as InvalidCredentialTypeError, ne as InvalidRedirectSchemeError, te as InvalidStartUrlError, ae as JSONDataNotConvertibleToStringError, j as KeyInvalidatedError, z as KeystoreUnavailableError, ie as MissingAttestationObjectError, K as MissingAuthorizationCredentialIDTokenError, $ as MissingGoogleClientIDError, H as MissingPKCEError, G as MissingPublicKeyError, re as MissingUrlError, F as NoBiometricsEnrolledError, D as NoBiometricsRegistrationError, q as NoCredentialsPresentError, R as NoCurrentSessionError, h as OAuthProviders, g as OTPMethods, f as OneTapPositions, ce as PasskeysInvalidEncoding, le as PasskeysMisconfigured, Z as PasskeysUnsupportedError, p as Products, A as RNUIProducts, se as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, ue as SignInWithAppleMisconfigured, I as StytchAPIError, P as StytchAPISchemaError, T as StytchAPIUnreachableError, sh as StytchB2BUIClient, x as StytchError, _ as StytchEventType, C as StytchSDKAPIError, B as StytchSDKError, S as StytchSDKSchemaError, E as StytchSDKUsageError, O as UNRECOVERABLE_ERROR_TYPES, N as UserCancellationError, U as UserLockedOutError, m as Wallets, de as errorToStytchError };
14183
+ export { y as AuthFlowType, b as B2BMFAProducts, w as B2BOAuthProviders, v as B2BProducts, ee as BiometricsFailedError, L as BiometricsUnavailableError, W as ChallengeSigningFailedError, Q as DeviceCredentialsNotAllowedError, J as FailedCodeChallengeError, X as FailedToDecryptDataError, M as InternalError, V as InvalidAuthorizationCredentialError, oe as InvalidCredentialTypeError, ne as InvalidRedirectSchemeError, te as InvalidStartUrlError, ae as JSONDataNotConvertibleToStringError, j as KeyInvalidatedError, z as KeystoreUnavailableError, ie as MissingAttestationObjectError, K as MissingAuthorizationCredentialIDTokenError, $ as MissingGoogleClientIDError, H as MissingPKCEError, G as MissingPublicKeyError, re as MissingUrlError, F as NoBiometricsEnrolledError, D as NoBiometricsRegistrationError, q as NoCredentialsPresentError, R as NoCurrentSessionError, h as OAuthProviders, g as OTPMethods, f as OneTapPositions, ce as PasskeysInvalidEncoding, le as PasskeysMisconfigured, Z as PasskeysUnsupportedError, p as Products, A as RNUIProducts, se as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, ue as SignInWithAppleMisconfigured, I as StytchAPIError, P as StytchAPISchemaError, T as StytchAPIUnreachableError, uh as StytchB2BUIClient, x as StytchError, _ as StytchEventType, C as StytchSDKAPIError, B as StytchSDKError, S as StytchSDKSchemaError, E as StytchSDKUsageError, O as UNRECOVERABLE_ERROR_TYPES, N as UserCancellationError, U as UserLockedOutError, m as Wallets, de as errorToStytchError };
@@ -4230,7 +4230,7 @@ var Nt = /*#__PURE__*/function () {
4230
4230
  },
4231
4231
  sdk: {
4232
4232
  identifier: "Stytch.js Javascript SDK",
4233
- version: "4.11.0"
4233
+ version: "4.11.2"
4234
4234
  }
4235
4235
  });
4236
4236
  }
@@ -4156,7 +4156,7 @@ var Et = /*#__PURE__*/function () {
4156
4156
  },
4157
4157
  sdk: {
4158
4158
  identifier: "Stytch.js Javascript SDK",
4159
- version: "4.11.0"
4159
+ version: "4.11.2"
4160
4160
  }
4161
4161
  });
4162
4162
  }