@frontegg/js 7.127.0 → 7.129.0-alpha.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.
@@ -1934,7 +1934,7 @@ __webpack_require__.r(__webpack_exports__);
1934
1934
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1935
1935
  /* harmony export */ });
1936
1936
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1937
- cdnVersion: '7.127.0'
1937
+ cdnVersion: '7.129.0-alpha.0'
1938
1938
  });
1939
1939
 
1940
1940
  /***/ }),
@@ -5520,13 +5520,15 @@ __webpack_require__.r(__webpack_exports__);
5520
5520
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5521
5521
  /* harmony export */ });
5522
5522
  /* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "../../node_modules/@babel/runtime/helpers/esm/extends.js");
5523
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../helpers */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers.js");
5524
- /* harmony import */ var _helpers_tenantSelect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../helpers/tenantSelect */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers/tenantSelect.js");
5525
- /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../constants */ "../../dist/@frontegg/redux-store/constants.js");
5526
- /* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../interfaces */ "../../dist/@frontegg/redux-store/auth/LoginState/interfaces.js");
5527
- /* harmony import */ var _StepUpState_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
5528
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/common.js");
5529
- /* harmony import */ var _StepUpState_helpers__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../StepUpState/helpers */ "../../dist/@frontegg/redux-store/auth/StepUpState/helpers.js");
5523
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/feature-flags/index.js");
5524
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/interfaces.js");
5525
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../helpers */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers.js");
5526
+ /* harmony import */ var _helpers_tenantSelect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../helpers/tenantSelect */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers/tenantSelect.js");
5527
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../constants */ "../../dist/@frontegg/redux-store/constants.js");
5528
+ /* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../interfaces */ "../../dist/@frontegg/redux-store/auth/LoginState/interfaces.js");
5529
+ /* harmony import */ var _StepUpState_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
5530
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/common.js");
5531
+ /* harmony import */ var _StepUpState_helpers__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../StepUpState/helpers */ "../../dist/@frontegg/redux-store/auth/StepUpState/helpers.js");
5530
5532
  /* harmony import */ var _oauthStorage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../oauthStorage */ "../../dist/@frontegg/redux-store/auth/LoginState/oauthStorage.js");
5531
5533
 
5532
5534
 
@@ -5537,6 +5539,7 @@ __webpack_require__.r(__webpack_exports__);
5537
5539
 
5538
5540
 
5539
5541
 
5542
+
5540
5543
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((store, api, sharedActions) => {
5541
5544
  const actions = sharedActions;
5542
5545
 
@@ -5586,6 +5589,33 @@ __webpack_require__.r(__webpack_exports__);
5586
5589
  }, additionalUpdate));
5587
5590
  }
5588
5591
 
5592
+ /**
5593
+ * A switch that needed SSO saved its target tenant (in this tab) before sending the user to SSO.
5594
+ * Once logged in again, switch to it once if the login landed in another tenant.
5595
+ * @returns true when the switch left the user without a session (MFA step for the target tenant, or logout)
5596
+ */
5597
+ async function switchToPendingSsoTenant() {
5598
+ var _store$auth$user, _store$auth$user2;
5599
+ const [isEnforceSsoOnTenantAccessEnabled] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__.FeatureFlags.getFeatureFlags([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.ENFORCE_SSO_ON_TENANT_ACCESS_FF], store.root.appName);
5600
+ const pendingTenantId = window.sessionStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_PENDING_SWITCH_TENANT);
5601
+ if (!isEnforceSsoOnTenantAccessEnabled || !pendingTenantId || !((_store$auth$user = store.auth.user) != null && _store$auth$user.accessToken)) {
5602
+ return false;
5603
+ }
5604
+ if (store.auth.user.tenantId === pendingTenantId) {
5605
+ window.sessionStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_PENDING_SWITCH_TENANT);
5606
+ return false;
5607
+ }
5608
+ // silentReload keeps switchingTenant set, so the switch's own refresh doesn't re-run this navigation
5609
+ await actions.switchTenant({
5610
+ tenantId: pendingTenantId,
5611
+ silentReload: true,
5612
+ keepLoginState: true
5613
+ });
5614
+ // removed only after the switch: a refused re-run must not send the user to SSO again
5615
+ window.sessionStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_PENDING_SWITCH_TENANT);
5616
+ return !((_store$auth$user2 = store.auth.user) != null && _store$auth$user2.accessToken);
5617
+ }
5618
+
5589
5619
  /**
5590
5620
  * @param customLoginAuthenticatedUrl custom login authenticated url if exists
5591
5621
  * @returns the authenticated url to redirect to after auth navigation
@@ -5600,9 +5630,9 @@ __webpack_require__.r(__webpack_exports__);
5600
5630
  enforceRedirectToSameSite = false,
5601
5631
  allowedRedirectOrigins = []
5602
5632
  } = store.auth;
5603
- const urlFromLocalStorage = window.localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_2__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
5633
+ const urlFromLocalStorage = window.localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
5604
5634
  if (customLoginAuthenticatedUrl && !urlFromLocalStorage) {
5605
- return (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getPathAndSearchParamsFromUrl)(customLoginAuthenticatedUrl, preventRedirectUrlOriginCleaning);
5635
+ return (0,_helpers__WEBPACK_IMPORTED_MODULE_5__.getPathAndSearchParamsFromUrl)(customLoginAuthenticatedUrl, preventRedirectUrlOriginCleaning);
5606
5636
  }
5607
5637
  const {
5608
5638
  authenticatedUrl,
@@ -5616,7 +5646,7 @@ __webpack_require__.r(__webpack_exports__);
5616
5646
  if (!finalUrl || [loginUrl, logoutUrl, socialLoginCallbackUrl, activateUrl, activateWithOTCUrl].includes(finalUrl)) {
5617
5647
  finalUrl = authenticatedUrl;
5618
5648
  }
5619
- const redirectUrl = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getRedirectUrl)({
5649
+ const redirectUrl = (0,_helpers__WEBPACK_IMPORTED_MODULE_5__.getRedirectUrl)({
5620
5650
  authenticatedUrl: finalUrl,
5621
5651
  includeQueryParam,
5622
5652
  enforceRedirectToSameSite,
@@ -5655,8 +5685,8 @@ __webpack_require__.r(__webpack_exports__);
5655
5685
  if (shouldStepUpDuringLogin) {
5656
5686
  // getUrlForAfterAuthNavigation give priority to the redirectUrl
5657
5687
  // avoiding use of getUrlForAfterAuthNavigation because we don't want to use the redirectUrl for magic link for example
5658
- const localStorageRedirectUrl = window.localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_2__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
5659
- if (localStorageRedirectUrl && !(0,_helpers__WEBPACK_IMPORTED_MODULE_3__.isAbsoluteUrl)(localStorageRedirectUrl)) {
5688
+ const localStorageRedirectUrl = window.localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
5689
+ if (localStorageRedirectUrl && !(0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isAbsoluteUrl)(localStorageRedirectUrl)) {
5660
5690
  redirectUrl = localStorageRedirectUrl;
5661
5691
  }
5662
5692
  }
@@ -5666,9 +5696,9 @@ __webpack_require__.r(__webpack_exports__);
5666
5696
  preventRedirectUrlOriginCleaning
5667
5697
  });
5668
5698
  }
5669
- (_window3 = window) == null ? void 0 : _window3.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_2__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
5699
+ (_window3 = window) == null ? void 0 : _window3.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
5670
5700
  }
5671
- await (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.delay)(200);
5701
+ await (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.delay)(200);
5672
5702
  await resetStateAction();
5673
5703
  if (redirectUrl.startsWith('http')) {
5674
5704
  (0,_oauthStorage__WEBPACK_IMPORTED_MODULE_1__.clearHostedOAuthState)();
@@ -5689,7 +5719,7 @@ __webpack_require__.r(__webpack_exports__);
5689
5719
  * until the resolved-guard, the LD flag, and the option all pass.
5690
5720
  */
5691
5721
  const shouldRouteToChooseTenant = async () => {
5692
- var _store$auth$tenantSel, _store$auth$user, _store$auth$user$act, _store$auth$tenantsSt;
5722
+ var _store$auth$tenantSel, _store$auth$user3, _store$auth$user3$act, _store$auth$tenantsSt;
5693
5723
  const loginState = store.auth.loginState;
5694
5724
  // Guard first so re-entry after the choice is resolved finalizes without re-reading the flag.
5695
5725
  if (loginState.tenantChoiceResolved) {
@@ -5705,7 +5735,7 @@ __webpack_require__.r(__webpack_exports__);
5705
5735
  return false; // feature off — never read tenant data
5706
5736
  }
5707
5737
 
5708
- const isImpersonation = !!((_store$auth$user = store.auth.user) != null && (_store$auth$user$act = _store$auth$user.act) != null && _store$auth$user$act.sub);
5738
+ const isImpersonation = !!((_store$auth$user3 = store.auth.user) != null && (_store$auth$user3$act = _store$auth$user3.act) != null && _store$auth$user3$act.sub);
5709
5739
  if (isImpersonation) {
5710
5740
  return false;
5711
5741
  }
@@ -5727,7 +5757,7 @@ __webpack_require__.r(__webpack_exports__);
5727
5757
  const {
5728
5758
  tenants
5729
5759
  } = store.auth.tenantsState;
5730
- return (0,_helpers_tenantSelect__WEBPACK_IMPORTED_MODULE_5__.shouldPromptChooseTenant)({
5760
+ return (0,_helpers_tenantSelect__WEBPACK_IMPORTED_MODULE_7__.shouldPromptChooseTenant)({
5731
5761
  ldEnabled,
5732
5762
  enabledByOption,
5733
5763
  tenants,
@@ -5783,6 +5813,14 @@ __webpack_require__.r(__webpack_exports__);
5783
5813
  }
5784
5814
  try {
5785
5815
  var _window4, _payload$preventRedir;
5816
+ const isSessionLostInPendingSwitch = await switchToPendingSsoTenant();
5817
+ if (isSessionLostInPendingSwitch) {
5818
+ // MFA for the target tenant or a failed refresh: continue on the login page
5819
+ store.auth.onRedirectTo(store.auth.routes.loginUrl, {
5820
+ preserveQueryParams: true
5821
+ });
5822
+ return;
5823
+ }
5786
5824
  const {
5787
5825
  customLoginAuthenticatedUrl,
5788
5826
  stepUpUrl
@@ -5793,20 +5831,20 @@ __webpack_require__.r(__webpack_exports__);
5793
5831
  // org requires on its own, and the isSteppedUp guard below means an already-stepped-up user is
5794
5832
  // never re-prompted.
5795
5833
  // login with magic code, try to step up, no other mfa, invalid max age, force_enroll -> logout, login with first factor, not-stepped up jwt -> navigate to step up
5796
- const shouldStepUp = (_window4 = window) == null ? void 0 : _window4.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_6__.SHOULD_STEP_UP_KEY);
5834
+ const shouldStepUp = (_window4 = window) == null ? void 0 : _window4.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_8__.SHOULD_STEP_UP_KEY);
5797
5835
  const user = store.auth.user;
5798
5836
  if (shouldStepUp) {
5799
5837
  var _window5;
5800
- (_window5 = window) == null ? void 0 : _window5.localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_6__.SHOULD_STEP_UP_KEY);
5838
+ (_window5 = window) == null ? void 0 : _window5.localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_8__.SHOULD_STEP_UP_KEY);
5801
5839
  }
5802
- if (stepUpUrl && shouldStepUp && !(0,_StepUpState_helpers__WEBPACK_IMPORTED_MODULE_7__.isSteppedUp)(user)) {
5840
+ if (stepUpUrl && shouldStepUp && !(0,_StepUpState_helpers__WEBPACK_IMPORTED_MODULE_9__.isSteppedUp)(user)) {
5803
5841
  return await afterAuthNavigationUtil(actions.resetLoginState, {
5804
5842
  forceStepUpUrl: stepUpUrl
5805
5843
  });
5806
5844
  }
5807
5845
  if (await shouldRouteToChooseTenant()) {
5808
5846
  actions.setLoginState({
5809
- step: _interfaces__WEBPACK_IMPORTED_MODULE_8__.LoginStep.chooseTenant,
5847
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_10__.LoginStep.chooseTenant,
5810
5848
  loading: false
5811
5849
  });
5812
5850
  // Mirror the other post-auth interstitials (e.g. promptPasskeys): navigate to the login URL
@@ -6009,12 +6047,14 @@ __webpack_require__.r(__webpack_exports__);
6009
6047
  /* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "../../node_modules/@babel/runtime/helpers/esm/extends.js");
6010
6048
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/refreshTokenRetry.js");
6011
6049
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/random.js");
6012
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/gtm.js");
6050
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/gtm.js");
6013
6051
  /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../constants */ "../../dist/@frontegg/redux-store/constants.js");
6052
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/feature-flags/index.js");
6053
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/interfaces.js");
6014
6054
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../helpers */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers.js");
6015
6055
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/auth/helpers.js");
6016
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/auth/StepUpState/helpers.js");
6017
- /* harmony import */ var _StepUpState_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
6056
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/auth/StepUpState/helpers.js");
6057
+ /* harmony import */ var _StepUpState_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
6018
6058
  /* harmony import */ var _toolkit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../toolkit */ "../../dist/@frontegg/redux-store/toolkit/FronteggNativeModule.js");
6019
6059
 
6020
6060
 
@@ -6023,6 +6063,7 @@ __webpack_require__.r(__webpack_exports__);
6023
6063
 
6024
6064
 
6025
6065
 
6066
+
6026
6067
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((store, api, sharedActions) => {
6027
6068
  const actions = sharedActions;
6028
6069
 
@@ -6097,7 +6138,10 @@ __webpack_require__.r(__webpack_exports__);
6097
6138
  code_challenge_method: 'S256',
6098
6139
  nonce
6099
6140
  }, additionalParams);
6100
- if (context.tenantResolver) {
6141
+ const [isEnforceSsoOnTenantAccessEnabled] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_7__.FeatureFlags.getFeatureFlags([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__.ENFORCE_SSO_ON_TENANT_ACCESS_FF], store.root.appName);
6142
+ // the tenant asked for (SSO for a refused switch or refresh) wins over the resolved and the page's tenant
6143
+ const isTenantRequested = isEnforceSsoOnTenantAccessEnabled && !!(additionalParams != null && additionalParams.tenantId);
6144
+ if (context.tenantResolver && !isTenantRequested) {
6101
6145
  var _context$tenantResolv;
6102
6146
  const resolvedTenantResult = await ((_context$tenantResolv = context.tenantResolver) == null ? void 0 : _context$tenantResolv.call(context));
6103
6147
  if (resolvedTenantResult != null && resolvedTenantResult.tenant) {
@@ -6105,7 +6149,7 @@ __webpack_require__.r(__webpack_exports__);
6105
6149
  }
6106
6150
  }
6107
6151
  const tenantId = (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.getSearchParam)(_helpers__WEBPACK_IMPORTED_MODULE_6__.TENANT_ID_PARAM_KEY);
6108
- if (tenantId) {
6152
+ if (tenantId && !isTenantRequested) {
6109
6153
  params['tenantId'] = tenantId;
6110
6154
  }
6111
6155
  if (_toolkit__WEBPACK_IMPORTED_MODULE_1__["default"].isAvailable('closeWindow')) {
@@ -6120,7 +6164,7 @@ __webpack_require__.r(__webpack_exports__);
6120
6164
  const refreshOrRequestHostedLoginAuthorize = async additionalParams => {
6121
6165
  var _localStorage;
6122
6166
  // when the user pause the step up flow we may still have the key in the local storage in hosted - Remove it
6123
- (_localStorage = localStorage) == null ? void 0 : _localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_7__.SHOULD_STEP_UP_KEY);
6167
+ (_localStorage = localStorage) == null ? void 0 : _localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_9__.SHOULD_STEP_UP_KEY);
6124
6168
  const disableSilentRefresh = store.auth.disableSilentRefresh;
6125
6169
  if ((additionalParams == null ? void 0 : additionalParams['prompt']) === 'login') {
6126
6170
  return await requestHostedLoginAuthorize(additionalParams);
@@ -6144,11 +6188,11 @@ __webpack_require__.r(__webpack_exports__);
6144
6188
  let {
6145
6189
  additionalParams
6146
6190
  } = payload != null ? payload : {};
6147
- const urlDerivedStepUp = (0,_helpers__WEBPACK_IMPORTED_MODULE_8__.getUrlDerivedStepUp)();
6191
+ const urlDerivedStepUp = (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.getUrlDerivedStepUp)();
6148
6192
  const isNativeStepUp = _toolkit__WEBPACK_IMPORTED_MODULE_1__["default"].isGetTokensAvailable() && urlDerivedStepUp.isStepUpRequested;
6149
6193
  if (!isNativeStepUp) {
6150
6194
  var _localStorage2;
6151
- (_localStorage2 = localStorage) == null ? void 0 : _localStorage2.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_7__.SHOULD_STEP_UP_KEY);
6195
+ (_localStorage2 = localStorage) == null ? void 0 : _localStorage2.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_9__.SHOULD_STEP_UP_KEY);
6152
6196
  }
6153
6197
  if (firstTime) {
6154
6198
  const urlStrategy = store.root.urlStrategy;
@@ -6171,7 +6215,7 @@ __webpack_require__.r(__webpack_exports__);
6171
6215
  if (((_additionalParams = additionalParams) == null ? void 0 : _additionalParams['prompt']) === 'login') {
6172
6216
  return await requestHostedLoginAuthorize(additionalParams);
6173
6217
  }
6174
- if (isNativeStepUp && !(0,_helpers__WEBPACK_IMPORTED_MODULE_8__.isSteppedUp)(store.auth.user, {
6218
+ if (isNativeStepUp && !(0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isSteppedUp)(store.auth.user, {
6175
6219
  maxAge: urlDerivedStepUp.maxAge
6176
6220
  })) {
6177
6221
  const {
@@ -6179,11 +6223,11 @@ __webpack_require__.r(__webpack_exports__);
6179
6223
  onRedirectTo
6180
6224
  } = store.auth;
6181
6225
  if (routes.stepUpUrl && !window.location.href.includes(routes.stepUpUrl)) {
6182
- window.localStorage.setItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_7__.SHOULD_STEP_UP_KEY, 'true');
6226
+ window.localStorage.setItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_9__.SHOULD_STEP_UP_KEY, 'true');
6183
6227
  actions.setAuthState({
6184
6228
  isLoading: true
6185
6229
  });
6186
- (0,_helpers__WEBPACK_IMPORTED_MODULE_8__.redirectByStepUpUrl)(routes.stepUpUrl, onRedirectTo, urlDerivedStepUp.maxAge);
6230
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.redirectByStepUpUrl)(routes.stepUpUrl, onRedirectTo, urlDerivedStepUp.maxAge);
6187
6231
  return;
6188
6232
  }
6189
6233
  }
@@ -6224,7 +6268,7 @@ __webpack_require__.r(__webpack_exports__);
6224
6268
  code_verifier,
6225
6269
  grant_type: 'authorization_code'
6226
6270
  };
6227
- const isStepUpFlow = window.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_7__.SHOULD_STEP_UP_KEY);
6271
+ const isStepUpFlow = window.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_9__.SHOULD_STEP_UP_KEY);
6228
6272
  try {
6229
6273
  const response = await api.auth.exchangeOAuthTokensV2(body);
6230
6274
  const user = response.user;
@@ -6241,7 +6285,7 @@ __webpack_require__.r(__webpack_exports__);
6241
6285
  email: user == null ? void 0 : user.email,
6242
6286
  name: user == null ? void 0 : user.name
6243
6287
  };
6244
- (0,_helpers__WEBPACK_IMPORTED_MODULE_9__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_9__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
6288
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_11__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_11__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
6245
6289
  }
6246
6290
  } catch (e) {
6247
6291
  actions.setAuthState({
@@ -6250,10 +6294,10 @@ __webpack_require__.r(__webpack_exports__);
6250
6294
  console.error('Failed to exchangeOAuthTokens', e);
6251
6295
  } finally {
6252
6296
  const user = store.auth.user;
6253
- window.localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_7__.SHOULD_STEP_UP_KEY);
6297
+ window.localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_9__.SHOULD_STEP_UP_KEY);
6254
6298
 
6255
6299
  // when the user pause the step up flow we may still have the key in the local storage in hosted. Ignore it.
6256
- if (isStepUpFlow && (0,_helpers__WEBPACK_IMPORTED_MODULE_8__.isSteppedUp)(user)) {
6300
+ if (isStepUpFlow && (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isSteppedUp)(user)) {
6257
6301
  await actions.afterStepUpAuthNavigation();
6258
6302
  } else {
6259
6303
  await actions.afterAuthNavigation();
@@ -6284,38 +6328,39 @@ __webpack_require__.r(__webpack_exports__);
6284
6328
  /* harmony export */ });
6285
6329
  /* harmony import */ var _babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/objectWithoutPropertiesLoose */ "../../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js");
6286
6330
  /* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "../../node_modules/@babel/runtime/helpers/esm/extends.js");
6287
- /* harmony import */ var _afterAuthNavigation_actions__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./afterAuthNavigation.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/afterAuthNavigation.actions.js");
6288
- /* harmony import */ var _handleVerifyMFAResponse_actions__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./handleVerifyMFAResponse.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/handleVerifyMFAResponse.actions.js");
6289
- /* harmony import */ var _mfaRequiredState_actions__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./mfaRequiredState.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaRequiredState.actions.js");
6290
- /* harmony import */ var _mfaWithAuthenticator_actions__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./mfaWithAuthenticator.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithAuthenticator.actions.js");
6291
- /* harmony import */ var _mfaWithEmailCode_actions__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./mfaWithEmailCode.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithEmailCode.actions.js");
6292
- /* harmony import */ var _mfaWithSMS_actions__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./mfaWithSMS.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithSMS.actions.js");
6293
- /* harmony import */ var _mfaWithWebAuthn_actions__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./mfaWithWebAuthn.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithWebAuthn.actions.js");
6294
- /* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../interfaces */ "../../dist/@frontegg/redux-store/auth/LoginState/interfaces.js");
6295
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/refreshTokenRetry.js");
6296
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/common.js");
6297
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/handlers.js");
6298
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/gtm.js");
6299
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/encoders.js");
6300
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/converters.js");
6301
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../state */ "../../dist/@frontegg/redux-store/auth/LoginState/state.js");
6302
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../helpers */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers.js");
6331
+ /* harmony import */ var _afterAuthNavigation_actions__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./afterAuthNavigation.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/afterAuthNavigation.actions.js");
6332
+ /* harmony import */ var _handleVerifyMFAResponse_actions__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./handleVerifyMFAResponse.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/handleVerifyMFAResponse.actions.js");
6333
+ /* harmony import */ var _mfaRequiredState_actions__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./mfaRequiredState.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaRequiredState.actions.js");
6334
+ /* harmony import */ var _mfaWithAuthenticator_actions__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./mfaWithAuthenticator.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithAuthenticator.actions.js");
6335
+ /* harmony import */ var _mfaWithEmailCode_actions__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./mfaWithEmailCode.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithEmailCode.actions.js");
6336
+ /* harmony import */ var _mfaWithSMS_actions__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./mfaWithSMS.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithSMS.actions.js");
6337
+ /* harmony import */ var _mfaWithWebAuthn_actions__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./mfaWithWebAuthn.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/mfaWithWebAuthn.actions.js");
6338
+ /* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../interfaces */ "../../dist/@frontegg/redux-store/auth/LoginState/interfaces.js");
6339
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/handlers.js");
6340
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/refreshTokenRetry.js");
6341
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/common.js");
6342
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/gtm.js");
6343
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/encoders.js");
6344
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../../helpers */ "../../dist/@frontegg/redux-store/helpers/converters.js");
6345
+ /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../state */ "../../dist/@frontegg/redux-store/auth/LoginState/state.js");
6346
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../helpers */ "../../dist/@frontegg/redux-store/auth/LoginState/helpers.js");
6303
6347
  /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/ContextHolder/index.js");
6304
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/utils.js");
6305
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/feature-flags/index.js");
6306
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/enums.js");
6307
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/interfaces.js");
6308
- /* harmony import */ var _hostedLoginAuthorize_actions__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./hostedLoginAuthorize.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/hostedLoginAuthorize.actions.js");
6309
- /* harmony import */ var _oauthStorage__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../oauthStorage */ "../../dist/@frontegg/redux-store/auth/LoginState/oauthStorage.js");
6310
- /* harmony import */ var _StepUpState_consts__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
6311
- /* harmony import */ var _toolkit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../toolkit */ "../../dist/@frontegg/redux-store/toolkit/FronteggNativeModule.js");
6312
- /* harmony import */ var _toolkit__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../toolkit */ "../../dist/@frontegg/redux-store/auth/Entitlements/helpers.js");
6313
- /* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../interfaces */ "../../dist/@frontegg/redux-store/auth/interfaces.js");
6314
- /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../consts */ "../../dist/@frontegg/redux-store/auth/LoginState/consts.js");
6315
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/auth/helpers.js");
6316
- /* harmony import */ var _MfaState_interfaces__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../MfaState/interfaces */ "../../dist/@frontegg/redux-store/auth/MfaState/interfaces.js");
6317
- /* harmony import */ var _SSOState_interfaces__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../SSOState/interfaces */ "../../dist/@frontegg/redux-store/auth/SSOState/interfaces.js");
6318
- /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../constants */ "../../dist/@frontegg/redux-store/constants.js");
6348
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/feature-flags/index.js");
6349
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/interfaces.js");
6350
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/utils.js");
6351
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/enums.js");
6352
+ /* harmony import */ var _hostedLoginAuthorize_actions__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./hostedLoginAuthorize.actions */ "../../dist/@frontegg/redux-store/auth/LoginState/actions/hostedLoginAuthorize.actions.js");
6353
+ /* harmony import */ var _oauthStorage__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../oauthStorage */ "../../dist/@frontegg/redux-store/auth/LoginState/oauthStorage.js");
6354
+ /* harmony import */ var _StepUpState_consts__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
6355
+ /* harmony import */ var _toolkit__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../toolkit */ "../../dist/@frontegg/redux-store/toolkit/FronteggNativeModule.js");
6356
+ /* harmony import */ var _toolkit__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../toolkit */ "../../dist/@frontegg/redux-store/auth/Entitlements/helpers.js");
6357
+ /* harmony import */ var _interfaces__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../interfaces */ "../../dist/@frontegg/redux-store/auth/interfaces.js");
6358
+ /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../consts */ "../../dist/@frontegg/redux-store/auth/LoginState/consts.js");
6359
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/auth/StepUpState/helpers.js");
6360
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/auth/helpers.js");
6361
+ /* harmony import */ var _MfaState_interfaces__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../MfaState/interfaces */ "../../dist/@frontegg/redux-store/auth/MfaState/interfaces.js");
6362
+ /* harmony import */ var _SSOState_interfaces__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../SSOState/interfaces */ "../../dist/@frontegg/redux-store/auth/SSOState/interfaces.js");
6363
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../constants */ "../../dist/@frontegg/redux-store/constants.js");
6319
6364
 
6320
6365
 
6321
6366
  const _excluded = ["callback", "error"],
@@ -6359,8 +6404,67 @@ const _excluded = ["callback", "error"],
6359
6404
  const actions = sharedActions;
6360
6405
  const contextHolder = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__.ContextHolder.for(store.root.appName);
6361
6406
 
6407
+ /**
6408
+ * Sends the user to log in through the tenant's SSO and back to the current page afterwards.
6409
+ * @protected
6410
+ */
6411
+ const __redirectToSsoForTenant = async ({
6412
+ tenantId,
6413
+ address
6414
+ }) => {
6415
+ // on the login page (tenant chooser) keep the destination the login already saved
6416
+ if (!window.location.pathname.endsWith(store.auth.routes.loginUrl)) {
6417
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.setAfterAuthRedirectUrlForStepUp)();
6418
+ }
6419
+ if (store.auth.hostedLoginBox) {
6420
+ await actions.requestHostedLoginAuthorize({
6421
+ prompt: 'login',
6422
+ tenantId
6423
+ });
6424
+ return;
6425
+ }
6426
+ store.auth.onRedirectTo(address, {
6427
+ refresh: true
6428
+ });
6429
+ };
6430
+ /**
6431
+ * Handles a token refresh refused because the tenant requires SSO.
6432
+ * ssoRequired: true sends the user to SSO. ssoRequired: false renews once more for the tenant of the
6433
+ * current token, which keeps the session.
6434
+ * @returns true when handled, false when the caller should log out
6435
+ * @private
6436
+ */
6437
+ const __handleSsoEnforcementRefreshError = async (e, isSsoEnforcementRetry, refreshForTenant) => {
6438
+ var _store$auth$user;
6439
+ const [isEnforceSsoOnTenantAccessEnabled] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__.FeatureFlags.getFeatureFlags([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ENFORCE_SSO_ON_TENANT_ACCESS_FF], store.root.appName);
6440
+ if (!isEnforceSsoOnTenantAccessEnabled || !(0,_helpers__WEBPACK_IMPORTED_MODULE_6__.isSsoEnforcementError)(e)) {
6441
+ return false;
6442
+ }
6443
+ const {
6444
+ errorContext
6445
+ } = e;
6446
+ // the switch re-run after coming back from SSO keeps the session instead of sending the user to SSO again
6447
+ const isPendingSwitchRerun = !!window.sessionStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_7__.FRONTEGG_PENDING_SWITCH_TENANT);
6448
+ if (errorContext.ssoRequired && !isPendingSwitchRerun) {
6449
+ await __redirectToSsoForTenant(errorContext);
6450
+ return true;
6451
+ }
6452
+ if (isSsoEnforcementRetry) {
6453
+ return false;
6454
+ }
6455
+ const currentTenantId = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.tenantId;
6456
+ if (currentTenantId && contextHolder.isSessionPerTenantEnabled()) {
6457
+ (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__.setTabTenantInSessionStorage)(currentTenantId);
6458
+ }
6459
+ await refreshForTenant(currentTenantId);
6460
+ return true;
6461
+ };
6462
+
6362
6463
  /** @private */
6363
- const __refreshTokenHosted = async () => {
6464
+ const __refreshTokenHosted = async ({
6465
+ tenantId,
6466
+ isSsoEnforcementRetry = false
6467
+ } = {}) => {
6364
6468
  const user = store.auth.user;
6365
6469
  if (!(user != null && user.refreshToken)) {
6366
6470
  contextHolder.setAccessToken(null);
@@ -6372,7 +6476,7 @@ const _excluded = ["callback", "error"],
6372
6476
  return;
6373
6477
  }
6374
6478
  try {
6375
- const tabTenantId = (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.getTabTenantFromSessionStorage)(store.root.appName);
6479
+ const tabTenantId = tenantId != null ? tenantId : (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__.getTabTenantFromSessionStorage)(store.root.appName);
6376
6480
  const body = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({
6377
6481
  grant_type: 'refresh_token',
6378
6482
  refresh_token: user == null ? void 0 : user.refreshToken
@@ -6387,6 +6491,13 @@ const _excluded = ["callback", "error"],
6387
6491
  isAuthenticated: true
6388
6492
  });
6389
6493
  } catch (e) {
6494
+ const retry = tenantId => __refreshTokenHosted({
6495
+ tenantId,
6496
+ isSsoEnforcementRetry: true
6497
+ });
6498
+ if (await __handleSsoEnforcementRefreshError(e, isSsoEnforcementRetry, retry)) {
6499
+ return;
6500
+ }
6390
6501
  contextHolder.setAccessToken(null);
6391
6502
  contextHolder.setUser(null);
6392
6503
  actions.setAuthState({
@@ -6406,7 +6517,10 @@ const _excluded = ["callback", "error"],
6406
6517
  };
6407
6518
 
6408
6519
  /** @private */
6409
- const __refreshTokenEmbedded = async () => {
6520
+ const __refreshTokenEmbedded = async ({
6521
+ tenantId,
6522
+ isSsoEnforcementRetry = false
6523
+ } = {}) => {
6410
6524
  try {
6411
6525
  const {
6412
6526
  routes,
@@ -6417,8 +6531,8 @@ const _excluded = ["callback", "error"],
6417
6531
  user,
6418
6532
  tenants = [],
6419
6533
  activeTenant
6420
- } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.refreshTokenWithRetry)(() => api.auth.refreshTokenV3());
6421
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isMfaRequired)(user, store.root.appName)) {
6534
+ } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_9__.refreshTokenWithRetry)(() => api.auth.refreshTokenV3(tenantId));
6535
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isMfaRequired)(user, store.root.appName)) {
6422
6536
  const mfaRequiredState = await actions.getMfaRequiredState(user);
6423
6537
  actions.setAuthState(mfaRequiredState);
6424
6538
  onRedirectTo(routes.loginUrl, {
@@ -6439,7 +6553,7 @@ const _excluded = ["callback", "error"],
6439
6553
  }, {
6440
6554
  loginState: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, loginState, {
6441
6555
  quickLoginToRegister,
6442
- flow: shouldNavigateToRegisterQuickLogin ? _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.RegisterQuickLogin : _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.Login
6556
+ flow: shouldNavigateToRegisterQuickLogin ? _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.RegisterQuickLogin : _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.Login
6443
6557
  }),
6444
6558
  isAuthenticated: true
6445
6559
  });
@@ -6448,6 +6562,13 @@ const _excluded = ["callback", "error"],
6448
6562
  });
6449
6563
  }
6450
6564
  } catch (e) {
6565
+ const retry = tenantId => __refreshTokenEmbedded({
6566
+ tenantId,
6567
+ isSsoEnforcementRetry: true
6568
+ });
6569
+ if (await __handleSsoEnforcementRefreshError(e, isSsoEnforcementRetry, retry)) {
6570
+ return;
6571
+ }
6451
6572
  contextHolder.setAccessToken(null);
6452
6573
  contextHolder.setUser(null);
6453
6574
  actions.setAuthState({
@@ -6458,11 +6579,13 @@ const _excluded = ["callback", "error"],
6458
6579
  };
6459
6580
 
6460
6581
  /** @private */
6461
- const __refreshTokenWithNativeTokens = async () => {
6582
+ const __refreshTokenWithNativeTokens = async ({
6583
+ isSsoEnforcementRetry = false
6584
+ } = {}) => {
6462
6585
  try {
6463
6586
  const authApi = api.auth;
6464
- const response = await (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.refreshTokenWithRetry)(async () => {
6465
- const tokens = await _toolkit__WEBPACK_IMPORTED_MODULE_7__["default"].getTokens();
6587
+ const response = await (0,_helpers__WEBPACK_IMPORTED_MODULE_9__.refreshTokenWithRetry)(async () => {
6588
+ const tokens = await _toolkit__WEBPACK_IMPORTED_MODULE_12__["default"].getTokens();
6466
6589
  return await authApi.silentOAuthRefreshTokenV3(tokens);
6467
6590
  });
6468
6591
  const updatedUser = await __handleUnnecessaryEntitlementsUpdate(response.user);
@@ -6472,6 +6595,13 @@ const _excluded = ["callback", "error"],
6472
6595
  isAuthenticated: true
6473
6596
  });
6474
6597
  } catch (e) {
6598
+ // native tokens can't name a tenant: the retry relies on the tab tenant only
6599
+ const retry = () => __refreshTokenWithNativeTokens({
6600
+ isSsoEnforcementRetry: true
6601
+ });
6602
+ if (await __handleSsoEnforcementRefreshError(e, isSsoEnforcementRetry, retry)) {
6603
+ return;
6604
+ }
6475
6605
  contextHolder.setAccessToken(null);
6476
6606
  contextHolder.setUser(null);
6477
6607
  actions.setAuthState({
@@ -6483,7 +6613,7 @@ const _excluded = ["callback", "error"],
6483
6613
 
6484
6614
  /** @protected */
6485
6615
  const __refreshToken = async () => {
6486
- if (_toolkit__WEBPACK_IMPORTED_MODULE_7__["default"].isGetTokensAvailable()) {
6616
+ if (_toolkit__WEBPACK_IMPORTED_MODULE_12__["default"].isGetTokensAvailable()) {
6487
6617
  await __refreshTokenWithNativeTokens();
6488
6618
  return;
6489
6619
  }
@@ -6505,10 +6635,10 @@ const _excluded = ["callback", "error"],
6505
6635
  * @private
6506
6636
  */
6507
6637
  const __handleUnnecessaryEntitlementsUpdate = async updatedUser => {
6508
- var _store$auth$user;
6638
+ var _store$auth$user2;
6509
6639
  // @ts-ignore TODO: fix entitlements state type
6510
- const oldEntitlements = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.entitlements;
6511
- if ((0,_toolkit__WEBPACK_IMPORTED_MODULE_8__.isEntitlementsDeeplyEqual)(oldEntitlements, updatedUser == null ? void 0 : updatedUser.entitlements)) {
6640
+ const oldEntitlements = (_store$auth$user2 = store.auth.user) == null ? void 0 : _store$auth$user2.entitlements;
6641
+ if ((0,_toolkit__WEBPACK_IMPORTED_MODULE_13__.isEntitlementsDeeplyEqual)(oldEntitlements, updatedUser == null ? void 0 : updatedUser.entitlements)) {
6512
6642
  // set the previous entitlements object
6513
6643
  return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, updatedUser, {
6514
6644
  entitlements: oldEntitlements
@@ -6528,7 +6658,7 @@ const _excluded = ["callback", "error"],
6528
6658
  loginState,
6529
6659
  onRedirectTo
6530
6660
  } = store.auth;
6531
- const [preventAuthRedirectOnSocialLogin] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_9__.FeatureFlags.getFeatureFlags(['prevent-auth-redirect-on-social-login'], store.root.appName);
6661
+ const [preventAuthRedirectOnSocialLogin] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__.FeatureFlags.getFeatureFlags(['prevent-auth-redirect-on-social-login'], store.root.appName);
6532
6662
  const invitationToken = url.searchParams.get('invitationToken');
6533
6663
  const redirectRoutes = [routes.socialLoginCallbackUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl, routes.magicLinkCallbackUrl];
6534
6664
  if (!invitationToken) {
@@ -6557,7 +6687,7 @@ const _excluded = ["callback", "error"],
6557
6687
  var _payload$callback;
6558
6688
  const {
6559
6689
  isActive
6560
- } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.retryIfNeeded)(api.auth.getSSOPublicConfiguration, payload == null ? void 0 : payload.retryConfig);
6690
+ } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_14__.retryIfNeeded)(api.auth.getSSOPublicConfiguration, payload == null ? void 0 : payload.retryConfig);
6561
6691
  actions.setAuthState({
6562
6692
  isSSOAuth: isActive
6563
6693
  });
@@ -6576,7 +6706,7 @@ const _excluded = ["callback", "error"],
6576
6706
  let ssoACS;
6577
6707
  try {
6578
6708
  var _metadata$configurati;
6579
- const metadata = await (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.retryIfNeeded)(api.metadata.getSamlMetadata, payload == null ? void 0 : payload.retryConfig);
6709
+ const metadata = await (0,_helpers__WEBPACK_IMPORTED_MODULE_14__.retryIfNeeded)(api.metadata.getSamlMetadata, payload == null ? void 0 : payload.retryConfig);
6580
6710
  ssoACS = metadata == null ? void 0 : (_metadata$configurati = metadata.configuration) == null ? void 0 : _metadata$configurati.acsUrl;
6581
6711
  } catch (e) {
6582
6712
  console.error(e);
@@ -6602,8 +6732,8 @@ const _excluded = ["callback", "error"],
6602
6732
  onRedirectTo,
6603
6733
  routes
6604
6734
  } = store.auth;
6605
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isMfaRequired)(user, store.root.appName)) {
6606
- const mfaRequiredState = await actions.getMfaRequiredState(user, _constants__WEBPACK_IMPORTED_MODULE_11__.DEFAULT_RETRY_CONFIG, true);
6735
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isMfaRequired)(user, store.root.appName)) {
6736
+ const mfaRequiredState = await actions.getMfaRequiredState(user, _constants__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_RETRY_CONFIG, true);
6607
6737
  actions.setAuthState(mfaRequiredState);
6608
6738
  onRedirectTo(routes.loginUrl, {
6609
6739
  preserveQueryParams: true
@@ -6614,17 +6744,17 @@ const _excluded = ["callback", "error"],
6614
6744
  Object.assign(store.auth.loginState, state);
6615
6745
  };
6616
6746
  const resetLoginState = () => {
6617
- (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.deepResetState)(store, ['auth', 'loginState'], _state__WEBPACK_IMPORTED_MODULE_12__.initialState);
6747
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_14__.deepResetState)(store, ['auth', 'loginState'], _state__WEBPACK_IMPORTED_MODULE_15__.initialState);
6618
6748
  };
6619
6749
  const getRetryWithBlockingCallbackPayload = requestName => {
6620
6750
  const callback = (_, error) => {
6621
6751
  if (!error || error.statusCode < 500) return;
6622
6752
  actions.setErrorByRequestName({
6623
6753
  requestName,
6624
- traceId: (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.errorTraceId)(error)
6754
+ traceId: (0,_helpers__WEBPACK_IMPORTED_MODULE_14__.errorTraceId)(error)
6625
6755
  });
6626
6756
  };
6627
- return (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.withRetryConfig)({
6757
+ return (0,_helpers__WEBPACK_IMPORTED_MODULE_14__.withRetryConfig)({
6628
6758
  callback
6629
6759
  });
6630
6760
  };
@@ -6636,19 +6766,19 @@ const _excluded = ["callback", "error"],
6636
6766
  actions.setAuthState({
6637
6767
  isLoading: true
6638
6768
  });
6639
- calls.push(actions.loadSocialLoginsConfigurationV2((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.withRetryConfig)()));
6640
- calls.push(actions.loadAllowSignUps(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_ALLOW_SIGNUPS)));
6641
- calls.push(actions.loadPublicAuthStrategiesPolicy(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY)));
6769
+ calls.push(actions.loadSocialLoginsConfigurationV2((0,_helpers__WEBPACK_IMPORTED_MODULE_14__.withRetryConfig)()));
6770
+ calls.push(actions.loadAllowSignUps(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_ALLOW_SIGNUPS)));
6771
+ calls.push(actions.loadPublicAuthStrategiesPolicy(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY)));
6642
6772
  calls.push(actions.loadSignUpStrategies());
6643
- calls.push(__loadSSOPublicConfigurationFunction(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_SSO_PUBLIC_CONFIGURATION)));
6644
- calls.push(actions.loadVendorPublicInfo((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.withRetryConfig)()));
6645
- calls.push(__refreshMetadata((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.withRetryConfig)()));
6773
+ calls.push(__loadSSOPublicConfigurationFunction(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_SSO_PUBLIC_CONFIGURATION)));
6774
+ calls.push(actions.loadVendorPublicInfo((0,_helpers__WEBPACK_IMPORTED_MODULE_14__.withRetryConfig)()));
6775
+ calls.push(__refreshMetadata((0,_helpers__WEBPACK_IMPORTED_MODULE_14__.withRetryConfig)()));
6646
6776
  /*
6647
6777
  We will load custom login routes only if custom login is enabled
6648
6778
  to check if custom login is enabled without the tenant alias (search-param/subdomain)
6649
6779
  we have to wait for the user state (refreshToken request)
6650
6780
  */
6651
- callsAfterRefresh.push(actions.loadCustomLoginRoutes(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_CUSTOM_LOGIN_ROUTES)));
6781
+ callsAfterRefresh.push(actions.loadCustomLoginRoutes(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_CUSTOM_LOGIN_ROUTES)));
6652
6782
  }
6653
6783
  await Promise.all(calls);
6654
6784
  if (callsAfterRefresh.length > 0) {
@@ -6660,14 +6790,14 @@ const _excluded = ["callback", "error"],
6660
6790
  };
6661
6791
  const requestAuthorizeSSR = async payload => {
6662
6792
  const calls = [];
6663
- calls.push(actions.loadSocialLoginsConfigurationV2((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.withRetryConfig)()));
6664
- calls.push(actions.loadAllowSignUps(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_ALLOW_SIGNUPS)));
6665
- calls.push(__loadSSOPublicConfigurationFunction(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_SSO_PUBLIC_CONFIGURATION)));
6793
+ calls.push(actions.loadSocialLoginsConfigurationV2((0,_helpers__WEBPACK_IMPORTED_MODULE_14__.withRetryConfig)()));
6794
+ calls.push(actions.loadAllowSignUps(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_ALLOW_SIGNUPS)));
6795
+ calls.push(__loadSSOPublicConfigurationFunction(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_SSO_PUBLIC_CONFIGURATION)));
6666
6796
  calls.push(actions.loadSignUpStrategies());
6667
- calls.push(actions.loadVendorPublicInfo((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.withRetryConfig)()));
6797
+ calls.push(actions.loadVendorPublicInfo((0,_helpers__WEBPACK_IMPORTED_MODULE_14__.withRetryConfig)()));
6668
6798
  calls.push(__refreshMetadata());
6669
6799
  calls.push(__isMFARequiredSSR(payload));
6670
- calls.push(actions.loadCustomLoginRoutes(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_13__.REQUEST_NAME.LOAD_CUSTOM_LOGIN_ROUTES)));
6800
+ calls.push(actions.loadCustomLoginRoutes(getRetryWithBlockingCallbackPayload(_interfaces__WEBPACK_IMPORTED_MODULE_16__.REQUEST_NAME.LOAD_CUSTOM_LOGIN_ROUTES)));
6671
6801
  await Promise.all(calls);
6672
6802
  };
6673
6803
  const ssoPreloginFailed = async _ref3 => {
@@ -6679,28 +6809,28 @@ const _excluded = ["callback", "error"],
6679
6809
  const publicPolicy = store.auth.securityPolicyState.publicPolicy.policy;
6680
6810
  if (!(publicPolicy != null && publicPolicy.authStrategy)) {
6681
6811
  actions.setLoginState({
6682
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.loginWithPassword,
6812
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.loginWithPassword,
6683
6813
  loading: false
6684
6814
  });
6685
6815
  callback == null ? void 0 : callback();
6686
6816
  return;
6687
6817
  }
6688
- if ((publicPolicy == null ? void 0 : publicPolicy.authStrategy) === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__.AuthStrategyEnum.EmailAndPassword) {
6818
+ if ((publicPolicy == null ? void 0 : publicPolicy.authStrategy) === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.AuthStrategyEnum.EmailAndPassword) {
6689
6819
  actions.setLoginState({
6690
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.loginWithPassword,
6820
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.loginWithPassword,
6691
6821
  loading: false
6692
6822
  });
6693
6823
  callback == null ? void 0 : callback();
6694
- } else if ([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__.AuthStrategyEnum.MagicLink, _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__.AuthStrategyEnum.Code, _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__.AuthStrategyEnum.SmsCode].includes(publicPolicy == null ? void 0 : publicPolicy.authStrategy)) {
6824
+ } else if ([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.AuthStrategyEnum.MagicLink, _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.AuthStrategyEnum.Code, _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.AuthStrategyEnum.SmsCode].includes(publicPolicy == null ? void 0 : publicPolicy.authStrategy)) {
6695
6825
  await actions.passwordlessPreLogin((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, body, {
6696
6826
  type: publicPolicy == null ? void 0 : publicPolicy.authStrategy,
6697
6827
  callback
6698
6828
  }));
6699
6829
  } else {
6700
6830
  actions.setLoginState({
6701
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.loginWithPassword,
6831
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.loginWithPassword,
6702
6832
  loading: false,
6703
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(error)
6833
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(error)
6704
6834
  });
6705
6835
  callback == null ? void 0 : callback();
6706
6836
  }
@@ -6718,7 +6848,7 @@ const _excluded = ["callback", "error"],
6718
6848
  });
6719
6849
  try {
6720
6850
  const onRedirectTo = store.auth.onRedirectTo;
6721
- const tenantId = (0,_helpers__WEBPACK_IMPORTED_MODULE_16__.getSearchParam)(_helpers__WEBPACK_IMPORTED_MODULE_16__.TENANT_ID_PARAM_KEY);
6851
+ const tenantId = (0,_helpers__WEBPACK_IMPORTED_MODULE_18__.getSearchParam)(_helpers__WEBPACK_IMPORTED_MODULE_18__.TENANT_ID_PARAM_KEY);
6722
6852
  const preLoginResult = await api.auth.preLoginV2((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, email ? {
6723
6853
  email
6724
6854
  } : {}, username ? {
@@ -6732,7 +6862,7 @@ const _excluded = ["callback", "error"],
6732
6862
  addressType
6733
6863
  } = preLoginResult != null ? preLoginResult : {};
6734
6864
  if (address) {
6735
- if (addressType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.PreLoginAddressType.External) {
6865
+ if (addressType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.PreLoginAddressType.External) {
6736
6866
  // Domain-based routing: navigate to the vendor legacy login URL immediately,
6737
6867
  // skipping the SSO interstitial and the SSO/OIDC-specific handling.
6738
6868
  setLoginState({
@@ -6744,22 +6874,22 @@ const _excluded = ["callback", "error"],
6744
6874
  return;
6745
6875
  }
6746
6876
  let ssoRedirectUrl = address;
6747
- if (idpType === _SSOState_interfaces__WEBPACK_IMPORTED_MODULE_18__.SamlVendors.Oidc && !ssoRedirectUrl.includes('redirect_uri')) {
6877
+ if (idpType === _SSOState_interfaces__WEBPACK_IMPORTED_MODULE_19__.SamlVendors.Oidc && !ssoRedirectUrl.includes('redirect_uri')) {
6748
6878
  const {
6749
6879
  oidcRedirectUrl
6750
6880
  } = store.auth.routes;
6751
6881
  ssoRedirectUrl += `&redirect_uri=${window.location.origin}${oidcRedirectUrl}`;
6752
6882
  }
6753
- if (_toolkit__WEBPACK_IMPORTED_MODULE_7__["default"].isLoginWithSSOAvailable()) {
6883
+ if (_toolkit__WEBPACK_IMPORTED_MODULE_12__["default"].isLoginWithSSOAvailable()) {
6754
6884
  var _ref4;
6755
- _toolkit__WEBPACK_IMPORTED_MODULE_7__["default"].loginWithSSO((_ref4 = email != null ? email : username) != null ? _ref4 : '');
6885
+ _toolkit__WEBPACK_IMPORTED_MODULE_12__["default"].loginWithSSO((_ref4 = email != null ? email : username) != null ? _ref4 : '');
6756
6886
  setLoginState({
6757
6887
  loading: false
6758
6888
  });
6759
6889
  callback == null ? void 0 : callback();
6760
6890
  } else {
6761
6891
  setLoginState({
6762
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.redirectToSSO,
6892
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.redirectToSSO,
6763
6893
  loading: false,
6764
6894
  ssoRedirectUrl
6765
6895
  });
@@ -6818,7 +6948,7 @@ const _excluded = ["callback", "error"],
6818
6948
  email: user.email,
6819
6949
  name: user.name
6820
6950
  };
6821
- (0,_helpers__WEBPACK_IMPORTED_MODULE_19__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_19__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
6951
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_20__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_20__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
6822
6952
  }
6823
6953
  await actions.afterAuthNavigation();
6824
6954
  } catch (e) {
@@ -6826,7 +6956,7 @@ const _excluded = ["callback", "error"],
6826
6956
  onRedirectTo(routes.authenticatedUrl);
6827
6957
  }, 1000);
6828
6958
  setLoginState({
6829
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.loginWithSSOFailed,
6959
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.loginWithSSOFailed,
6830
6960
  loading: false
6831
6961
  });
6832
6962
  }
@@ -6861,17 +6991,17 @@ const _excluded = ["callback", "error"],
6861
6991
  onRedirectTo,
6862
6992
  routes
6863
6993
  } = store.auth;
6864
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isMfaRequired)(user, store.root.appName)) {
6865
- const mfaRequiredState = await actions.getMfaRequiredState(user, _constants__WEBPACK_IMPORTED_MODULE_11__.DEFAULT_RETRY_CONFIG, true, email);
6994
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isMfaRequired)(user, store.root.appName)) {
6995
+ const mfaRequiredState = await actions.getMfaRequiredState(user, _constants__WEBPACK_IMPORTED_MODULE_7__.DEFAULT_RETRY_CONFIG, true, email);
6866
6996
  actions.setAuthState(mfaRequiredState);
6867
6997
  onRedirectTo(routes.loginUrl, {
6868
6998
  preserveQueryParams: true
6869
6999
  });
6870
7000
  } else {
6871
7001
  const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
6872
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isResetPasswordRequired)(user, store.root.appName)) {
7002
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isResetPasswordRequired)(user, store.root.appName)) {
6873
7003
  setLoginState({
6874
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.passwordRotationExpired,
7004
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.passwordRotationExpired,
6875
7005
  loading: false,
6876
7006
  resetPasswordToken: user.resetPasswordToken,
6877
7007
  userId: user.userId
@@ -6894,7 +7024,7 @@ const _excluded = ["callback", "error"],
6894
7024
  loading: false,
6895
7025
  error: undefined,
6896
7026
  mfaToken: user.mfaToken,
6897
- step: loginState.flow === _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.Login ? _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.success : loginState.step,
7027
+ step: loginState.flow === _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.Login ? _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.success : loginState.step,
6898
7028
  tenants,
6899
7029
  tenantsLoading: true,
6900
7030
  isBreachedPassword: user.isBreachedPassword,
@@ -6914,27 +7044,27 @@ const _excluded = ["callback", "error"],
6914
7044
  email,
6915
7045
  name: user.name
6916
7046
  };
6917
- (0,_helpers__WEBPACK_IMPORTED_MODULE_19__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_19__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
7047
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_20__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_20__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
6918
7048
  }
6919
- if (loginState.flow === _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.Login) {
7049
+ if (loginState.flow === _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.Login) {
6920
7050
  if (securityCenterLoginFlows && user.isBreachedPassword && !isAuthenticated) {
6921
7051
  setLoginState({
6922
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.breachedPassword,
7052
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.breachedPassword,
6923
7053
  loading: false
6924
7054
  });
6925
7055
  } else {
6926
7056
  if (isAuthenticated) {
6927
- const shouldShowPasswordRotationPrompt = (0,_helpers__WEBPACK_IMPORTED_MODULE_16__.shouldShowPasswordRotationPromptFunc)(user);
7057
+ const shouldShowPasswordRotationPrompt = (0,_helpers__WEBPACK_IMPORTED_MODULE_18__.shouldShowPasswordRotationPromptFunc)(user);
6928
7058
  if (shouldShowPasswordRotationPrompt) {
6929
7059
  setLoginState({
6930
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.passwordRotationNotification,
7060
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.passwordRotationNotification,
6931
7061
  loading: false
6932
7062
  });
6933
7063
  } else {
6934
7064
  const shouldShowPromptPasskeys = await actions.__shouldShowPromptPasskeys();
6935
7065
  if (shouldShowPromptPasskeys) {
6936
7066
  setLoginState({
6937
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.promptPasskeys,
7067
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.promptPasskeys,
6938
7068
  loading: false
6939
7069
  });
6940
7070
  onRedirectTo(routes.loginUrl, {
@@ -6949,8 +7079,8 @@ const _excluded = ["callback", "error"],
6949
7079
  }
6950
7080
  }
6951
7081
  }
6952
- if (_toolkit__WEBPACK_IMPORTED_MODULE_7__["default"].isSuggestSavePasswordAvailable()) {
6953
- _toolkit__WEBPACK_IMPORTED_MODULE_7__["default"].suggestSavePassword(email, password);
7082
+ if (_toolkit__WEBPACK_IMPORTED_MODULE_12__["default"].isSuggestSavePasswordAvailable()) {
7083
+ _toolkit__WEBPACK_IMPORTED_MODULE_12__["default"].suggestSavePassword(email, password);
6954
7084
  }
6955
7085
 
6956
7086
  // TODO: extract item name to constants
@@ -6962,7 +7092,7 @@ const _excluded = ["callback", "error"],
6962
7092
  callback == null ? void 0 : callback(false, e);
6963
7093
  setLoginState({
6964
7094
  email,
6965
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e),
7095
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e),
6966
7096
  loading: false
6967
7097
  });
6968
7098
  }
@@ -6971,12 +7101,13 @@ const _excluded = ["callback", "error"],
6971
7101
  keepHostedOAuthState = false
6972
7102
  } = {}) => {
6973
7103
  if (contextHolder.isSessionPerTenantEnabled()) {
6974
- (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.removeTabTenantFromSessionStorage)();
7104
+ (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__.removeTabTenantFromSessionStorage)();
6975
7105
  }
6976
7106
  // Step-up re-login goes through silentLogout but still needs the hosted OAuth state to finish the client flow.
6977
7107
  if (!keepHostedOAuthState) {
6978
- (0,_oauthStorage__WEBPACK_IMPORTED_MODULE_20__.clearHostedOAuthState)();
7108
+ (0,_oauthStorage__WEBPACK_IMPORTED_MODULE_21__.clearHostedOAuthState)();
6979
7109
  }
7110
+ window.sessionStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_7__.FRONTEGG_PENDING_SWITCH_TENANT);
6980
7111
  };
6981
7112
  const logout = async payload => {
6982
7113
  const hostedLoginBox = store.auth.hostedLoginBox;
@@ -7004,7 +7135,7 @@ const _excluded = ["callback", "error"],
7004
7135
  } catch {
7005
7136
  /* empty */
7006
7137
  }
7007
- const isStepUpInProgress = !!((_window2 = window) != null && _window2.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_21__.SHOULD_STEP_UP_KEY));
7138
+ const isStepUpInProgress = !!((_window2 = window) != null && _window2.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_22__.SHOULD_STEP_UP_KEY));
7008
7139
  clearLogoutLocalState({
7009
7140
  keepHostedOAuthState: isStepUpInProgress
7010
7141
  });
@@ -7023,7 +7154,7 @@ const _excluded = ["callback", "error"],
7023
7154
  setLoginState({
7024
7155
  loading: false,
7025
7156
  error: undefined,
7026
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.preLogin
7157
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.preLogin
7027
7158
  });
7028
7159
  actions.setAuthState({
7029
7160
  user: undefined,
@@ -7033,7 +7164,7 @@ const _excluded = ["callback", "error"],
7033
7164
  } catch (e) {
7034
7165
  var _payload$callback5;
7035
7166
  setLoginState({
7036
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e),
7167
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e),
7037
7168
  loading: false
7038
7169
  });
7039
7170
  (_payload$callback5 = payload.callback) == null ? void 0 : _payload$callback5.call(payload, false, e);
@@ -7052,10 +7183,10 @@ const _excluded = ["callback", "error"],
7052
7183
  // TODO: fix @frontegg/rest-api return value
7053
7184
  // @ts-ignore
7054
7185
  const preloginRes = await api.auth.passwordlessPreLogin((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, payload, {
7055
- type: _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__.AuthStrategyEnum.SmsCode
7186
+ type: _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.AuthStrategyEnum.SmsCode
7056
7187
  }));
7057
7188
  setLoginState({
7058
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.loginWithQuickSmsOtc,
7189
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.loginWithQuickSmsOtc,
7059
7190
  loading: false,
7060
7191
  phoneNumber: preloginRes == null ? void 0 : preloginRes.phoneNumber,
7061
7192
  error: undefined
@@ -7063,7 +7194,7 @@ const _excluded = ["callback", "error"],
7063
7194
  callback == null ? void 0 : callback(true);
7064
7195
  } catch (e) {
7065
7196
  setLoginState({
7066
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e),
7197
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e),
7067
7198
  loading: false
7068
7199
  });
7069
7200
  callback == null ? void 0 : callback(false, e);
@@ -7083,13 +7214,13 @@ const _excluded = ["callback", "error"],
7083
7214
  phoneNumber: payload.phoneNumber,
7084
7215
  loading: false,
7085
7216
  changePhoneId: changePhoneRes.changePhoneId,
7086
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.loginWithQuickSmsOtc,
7217
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.loginWithQuickSmsOtc,
7087
7218
  error: undefined
7088
7219
  });
7089
7220
  callback == null ? void 0 : callback(true);
7090
7221
  } catch (e) {
7091
7222
  setLoginState({
7092
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e),
7223
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e),
7093
7224
  loading: false
7094
7225
  });
7095
7226
  }
@@ -7110,7 +7241,7 @@ const _excluded = ["callback", "error"],
7110
7241
  callback == null ? void 0 : callback(true);
7111
7242
  } catch (e) {
7112
7243
  setLoginState({
7113
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e),
7244
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e),
7114
7245
  loading: false
7115
7246
  });
7116
7247
  }
@@ -7126,11 +7257,11 @@ const _excluded = ["callback", "error"],
7126
7257
  loading: true
7127
7258
  });
7128
7259
  let email;
7129
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_16__.isEmailPayload)(payload)) {
7260
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_18__.isEmailPayload)(payload)) {
7130
7261
  email = payload.email;
7131
7262
  }
7132
7263
  let username;
7133
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_16__.isUsernamePayload)(payload)) {
7264
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_18__.isUsernamePayload)(payload)) {
7134
7265
  username = payload.username;
7135
7266
  }
7136
7267
  // TODO: [Typescript 4.8] fix @frontegg/rest-api return value
@@ -7140,7 +7271,7 @@ const _excluded = ["callback", "error"],
7140
7271
  username: (_username = username) != null ? _username : ''
7141
7272
  }));
7142
7273
  // @ts-ignore
7143
- const step = _consts__WEBPACK_IMPORTED_MODULE_22__.authStrategyLoginStepMap[payload.type];
7274
+ const step = _consts__WEBPACK_IMPORTED_MODULE_23__.authStrategyLoginStepMap[payload.type];
7144
7275
  setLoginState({
7145
7276
  step,
7146
7277
  loading: false,
@@ -7152,7 +7283,7 @@ const _excluded = ["callback", "error"],
7152
7283
  callback == null ? void 0 : callback();
7153
7284
  } catch (e) {
7154
7285
  setLoginState({
7155
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e),
7286
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e),
7156
7287
  loading: false
7157
7288
  });
7158
7289
  callback == null ? void 0 : callback(null, e);
@@ -7177,7 +7308,7 @@ const _excluded = ["callback", "error"],
7177
7308
  routes,
7178
7309
  onRedirectTo
7179
7310
  } = store.auth;
7180
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isMfaRequired)(user, store.root.appName)) {
7311
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isMfaRequired)(user, store.root.appName)) {
7181
7312
  const mfaRequiredState = await actions.getMfaRequiredState(user);
7182
7313
  actions.setAuthState(mfaRequiredState);
7183
7314
  onRedirectTo(routes.loginUrl, {
@@ -7190,14 +7321,14 @@ const _excluded = ["callback", "error"],
7190
7321
  var _events$userVerified;
7191
7322
  const userVerifiedPayload = {
7192
7323
  email: user.email,
7193
- origin: _interfaces__WEBPACK_IMPORTED_MODULE_13__.UserVerifiedOriginTypes.PASSWORDLESS,
7324
+ origin: _interfaces__WEBPACK_IMPORTED_MODULE_16__.UserVerifiedOriginTypes.PASSWORDLESS,
7194
7325
  id: user.id,
7195
7326
  tenantId: user.tenantId,
7196
7327
  createdAt: new Date(),
7197
7328
  name: user.name
7198
7329
  };
7199
7330
  events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
7200
- (0,_helpers__WEBPACK_IMPORTED_MODULE_19__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_19__.GTMEventAction.USER_VERIFIED, userVerifiedPayload);
7331
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_20__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_20__.GTMEventAction.USER_VERIFIED, userVerifiedPayload);
7201
7332
  }
7202
7333
  const loginCompletedPayload = {
7203
7334
  tenantId: user.tenantId,
@@ -7207,7 +7338,7 @@ const _excluded = ["callback", "error"],
7207
7338
  email: user.email,
7208
7339
  name: user.name
7209
7340
  };
7210
- (0,_helpers__WEBPACK_IMPORTED_MODULE_19__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_19__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
7341
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_20__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_20__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
7211
7342
  if (user.id) {
7212
7343
  localStorage.setItem('userId', user.id);
7213
7344
  }
@@ -7222,11 +7353,11 @@ const _excluded = ["callback", "error"],
7222
7353
  actions.setAuthState({
7223
7354
  isLoading: false
7224
7355
  });
7225
- if (loginState.flow === _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.Login) {
7356
+ if (loginState.flow === _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.Login) {
7226
7357
  const shouldShowPrompt = await actions.__shouldShowPromptPasskeys();
7227
7358
  if (shouldShowPrompt) {
7228
7359
  actions.setLoginState({
7229
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.promptPasskeys,
7360
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.promptPasskeys,
7230
7361
  loading: false
7231
7362
  });
7232
7363
  onRedirectTo(routes.loginUrl, {
@@ -7236,12 +7367,12 @@ const _excluded = ["callback", "error"],
7236
7367
  actions.setAuthState({
7237
7368
  isAuthenticated: true
7238
7369
  });
7239
- if (_payload.type === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_14__.AuthStrategyEnum.MagicLink) {
7370
+ if (_payload.type === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.AuthStrategyEnum.MagicLink) {
7240
7371
  actions.setLoginState({
7241
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.magicLinkPostLoginSuccess,
7372
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.magicLinkPostLoginSuccess,
7242
7373
  loading: false
7243
7374
  });
7244
- await (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.delay)(5000);
7375
+ await (0,_helpers__WEBPACK_IMPORTED_MODULE_14__.delay)(5000);
7245
7376
  }
7246
7377
  await actions.afterAuthNavigation();
7247
7378
  }
@@ -7255,7 +7386,7 @@ const _excluded = ["callback", "error"],
7255
7386
  }
7256
7387
  } catch (e) {
7257
7388
  setLoginState({
7258
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e, 'Failed to authenticate')
7389
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e, 'Failed to authenticate')
7259
7390
  });
7260
7391
  callback == null ? void 0 : callback(null, e);
7261
7392
  } finally {
@@ -7279,7 +7410,7 @@ const _excluded = ["callback", "error"],
7279
7410
  });
7280
7411
  } catch (e) {
7281
7412
  setLoginState({
7282
- inviteTokenError: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e, `We couldn't verify your invitation`)
7413
+ inviteTokenError: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e, `We couldn't verify your invitation`)
7283
7414
  });
7284
7415
  } finally {
7285
7416
  setLoginState({
@@ -7305,9 +7436,9 @@ const _excluded = ["callback", "error"],
7305
7436
  const {
7306
7437
  options
7307
7438
  } = await api.auth.webAuthnPreLogin(body);
7308
- options.challenge = (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(options.challenge);
7439
+ options.challenge = (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(options.challenge);
7309
7440
  options.allowCredentials = (_options$allowCredent = options.allowCredentials) == null ? void 0 : _options$allowCredent.map(credentials => (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, credentials, {
7310
- id: (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(credentials.id)
7441
+ id: (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(credentials.id)
7311
7442
  }));
7312
7443
  setLoginState({
7313
7444
  error: undefined
@@ -7315,7 +7446,7 @@ const _excluded = ["callback", "error"],
7315
7446
  callback == null ? void 0 : callback(options);
7316
7447
  } catch (e) {
7317
7448
  setLoginState({
7318
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7449
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7319
7450
  });
7320
7451
  callback == null ? void 0 : callback(null);
7321
7452
  } finally {
@@ -7340,7 +7471,7 @@ const _excluded = ["callback", "error"],
7340
7471
  setLoginState({
7341
7472
  loading: true
7342
7473
  });
7343
- const publicKey = (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.publicKeyCredentialToJSON)(body.publicKey);
7474
+ const publicKey = (0,_helpers__WEBPACK_IMPORTED_MODULE_25__.publicKeyCredentialToJSON)(body.publicKey);
7344
7475
  const _await$api$auth$webAu = await api.auth.webAuthnPostLoginV2((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, publicKey, {
7345
7476
  response: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, publicKey.response, {
7346
7477
  userHandle: (_publicKey$response$u = publicKey.response.userHandle) != null ? _publicKey$response$u : undefined
@@ -7352,7 +7483,7 @@ const _excluded = ["callback", "error"],
7352
7483
  user
7353
7484
  } = _await$api$auth$webAu,
7354
7485
  rest = (0,_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(_await$api$auth$webAu, _excluded9);
7355
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isMfaRequired)(user, store.root.appName)) {
7486
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isMfaRequired)(user, store.root.appName)) {
7356
7487
  const {
7357
7488
  routes,
7358
7489
  onRedirectTo
@@ -7383,7 +7514,7 @@ const _excluded = ["callback", "error"],
7383
7514
  email: user.email,
7384
7515
  name: user.name
7385
7516
  };
7386
- (0,_helpers__WEBPACK_IMPORTED_MODULE_19__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_19__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
7517
+ (0,_helpers__WEBPACK_IMPORTED_MODULE_20__.reportGTMEvent)(_helpers__WEBPACK_IMPORTED_MODULE_20__.GTMEventAction.LOGIN_COMPLETED, loginCompletedPayload);
7387
7518
  await actions.afterAuthNavigation();
7388
7519
  // TODO: Itamar why moving callback to inside the else block
7389
7520
  callback == null ? void 0 : callback(true);
@@ -7391,7 +7522,7 @@ const _excluded = ["callback", "error"],
7391
7522
  // callback?.(true);
7392
7523
  } catch (e) {
7393
7524
  setLoginState({
7394
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7525
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7395
7526
  });
7396
7527
  callback == null ? void 0 : callback(null);
7397
7528
  } finally {
@@ -7416,13 +7547,13 @@ const _excluded = ["callback", "error"],
7416
7547
  const {
7417
7548
  options
7418
7549
  } = await api.auth.webAuthnCreateNewDeviceSession();
7419
- options.user.id = (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(options.user.id);
7420
- options.challenge = (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(options.challenge);
7550
+ options.user.id = (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(options.user.id);
7551
+ options.challenge = (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(options.challenge);
7421
7552
  options.excludeCredentials = [];
7422
7553
  callback == null ? void 0 : callback(options);
7423
7554
  } catch (e) {
7424
7555
  setLoginState({
7425
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7556
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7426
7557
  });
7427
7558
  callback == null ? void 0 : callback(null);
7428
7559
  } finally {
@@ -7440,8 +7571,8 @@ const _excluded = ["callback", "error"],
7440
7571
  setLoginState({
7441
7572
  loading: true
7442
7573
  });
7443
- const publicKey = (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.publicKeyCredentialToJSON)(body.publicKey);
7444
- const deviceType = (publicKey == null ? void 0 : publicKey.authenticatorAttachment) === 'platform' ? _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.WebAuthnDeviceType.Platform : _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_17__.WebAuthnDeviceType.CrossPlatform;
7574
+ const publicKey = (0,_helpers__WEBPACK_IMPORTED_MODULE_25__.publicKeyCredentialToJSON)(body.publicKey);
7575
+ const deviceType = (publicKey == null ? void 0 : publicKey.authenticatorAttachment) === 'platform' ? _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.WebAuthnDeviceType.Platform : _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.WebAuthnDeviceType.CrossPlatform;
7445
7576
  await api.auth.verifyNewDeviceSession({
7446
7577
  id: publicKey.id,
7447
7578
  response: publicKey.response,
@@ -7450,7 +7581,7 @@ const _excluded = ["callback", "error"],
7450
7581
  callback == null ? void 0 : callback(true);
7451
7582
  } catch (e) {
7452
7583
  setLoginState({
7453
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7584
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7454
7585
  });
7455
7586
  callback == null ? void 0 : callback(null);
7456
7587
  } finally {
@@ -7508,12 +7639,12 @@ const _excluded = ["callback", "error"],
7508
7639
  var _data$options$exclude;
7509
7640
  const data = await api.auth.preEnrollMFAWebAuthnForLogin(payload);
7510
7641
  const options = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, data.options, {
7511
- challenge: (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(data.options.challenge),
7642
+ challenge: (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(data.options.challenge),
7512
7643
  user: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, data.options.user, {
7513
- id: (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(data.options.user.id)
7644
+ id: (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(data.options.user.id)
7514
7645
  }),
7515
7646
  excludeCredentials: (_data$options$exclude = data.options.excludeCredentials) == null ? void 0 : _data$options$exclude.map(credentials => (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, credentials, {
7516
- id: (0,_helpers__WEBPACK_IMPORTED_MODULE_23__.base64urlDecode)(credentials.id)
7647
+ id: (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.base64urlDecode)(credentials.id)
7517
7648
  }))
7518
7649
  });
7519
7650
  setLoginState({
@@ -7526,7 +7657,7 @@ const _excluded = ["callback", "error"],
7526
7657
  } catch (e) {
7527
7658
  setLoginState({
7528
7659
  loading: false,
7529
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7660
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7530
7661
  });
7531
7662
  callback == null ? void 0 : callback(null);
7532
7663
  }
@@ -7540,7 +7671,7 @@ const _excluded = ["callback", "error"],
7540
7671
  loading: true
7541
7672
  });
7542
7673
  try {
7543
- const publicKey = (0,_helpers__WEBPACK_IMPORTED_MODULE_24__.publicKeyCredentialToJSON)(payload.publicKey);
7674
+ const publicKey = (0,_helpers__WEBPACK_IMPORTED_MODULE_25__.publicKeyCredentialToJSON)(payload.publicKey);
7544
7675
  const data = await api.auth.enrollMFAWebAuthnForLoginV2((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, payload, {
7545
7676
  options: publicKey
7546
7677
  }));
@@ -7552,7 +7683,7 @@ const _excluded = ["callback", "error"],
7552
7683
  } catch (e) {
7553
7684
  setLoginState({
7554
7685
  loading: false,
7555
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7686
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7556
7687
  });
7557
7688
  callback == null ? void 0 : callback(null);
7558
7689
  }
@@ -7575,7 +7706,7 @@ const _excluded = ["callback", "error"],
7575
7706
  } catch (e) {
7576
7707
  setLoginState({
7577
7708
  loading: false,
7578
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7709
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7579
7710
  });
7580
7711
  callback == null ? void 0 : callback(null);
7581
7712
  }
@@ -7592,7 +7723,7 @@ const _excluded = ["callback", "error"],
7592
7723
  const data = await api.auth.preEnrollMFASMSForLogin(payload);
7593
7724
  actions.setMfaState({
7594
7725
  otcToken: data.otcToken,
7595
- step: _MfaState_interfaces__WEBPACK_IMPORTED_MODULE_25__.MFAStep.smsVerifyCode,
7726
+ step: _MfaState_interfaces__WEBPACK_IMPORTED_MODULE_26__.MFAStep.smsVerifyCode,
7596
7727
  phoneNumber: data.phoneNumber
7597
7728
  });
7598
7729
  setLoginState({
@@ -7602,7 +7733,7 @@ const _excluded = ["callback", "error"],
7602
7733
  } catch (e) {
7603
7734
  setLoginState({
7604
7735
  loading: false,
7605
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7736
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7606
7737
  });
7607
7738
  callback == null ? void 0 : callback(null);
7608
7739
  }
@@ -7625,7 +7756,7 @@ const _excluded = ["callback", "error"],
7625
7756
  } catch (e) {
7626
7757
  setLoginState({
7627
7758
  loading: false,
7628
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7759
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7629
7760
  });
7630
7761
  callback == null ? void 0 : callback(null);
7631
7762
  }
@@ -7637,7 +7768,7 @@ const _excluded = ["callback", "error"],
7637
7768
  activeTenant
7638
7769
  } = payload;
7639
7770
  const mfaState = {
7640
- step: _MfaState_interfaces__WEBPACK_IMPORTED_MODULE_25__.MFAStep.recoveryCode,
7771
+ step: _MfaState_interfaces__WEBPACK_IMPORTED_MODULE_26__.MFAStep.recoveryCode,
7641
7772
  loading: false,
7642
7773
  error: undefined,
7643
7774
  saving: false
@@ -7665,7 +7796,7 @@ const _excluded = ["callback", "error"],
7665
7796
  setLoginState({
7666
7797
  loading: false,
7667
7798
  error: undefined,
7668
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.breachedPasswordSuccess
7799
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.breachedPasswordSuccess
7669
7800
  });
7670
7801
  actions.setAuthState({
7671
7802
  isAuthenticated: false
@@ -7673,13 +7804,16 @@ const _excluded = ["callback", "error"],
7673
7804
  } catch (e) {
7674
7805
  setLoginState({
7675
7806
  loading: false,
7676
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_15__.errorHandler)(e)
7807
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_6__.errorHandler)(e)
7677
7808
  });
7678
7809
  }
7679
7810
  };
7680
7811
 
7681
7812
  /** @private */
7682
- const __refreshTokenHostedSocialLogins = async () => {
7813
+ const __refreshTokenHostedSocialLogins = async ({
7814
+ tenantId,
7815
+ isSsoEnforcementRetry = false
7816
+ } = {}) => {
7683
7817
  const {
7684
7818
  user: currentUser
7685
7819
  } = store.auth;
@@ -7693,7 +7827,7 @@ const _excluded = ["callback", "error"],
7693
7827
  return;
7694
7828
  }
7695
7829
  try {
7696
- const tabTenantId = (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.getTabTenantFromSessionStorage)(store.root.appName);
7830
+ const tabTenantId = tenantId != null ? tenantId : (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_8__.getTabTenantFromSessionStorage)(store.root.appName);
7697
7831
  const body = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({
7698
7832
  grant_type: 'refresh_token',
7699
7833
  refresh_token: currentUser == null ? void 0 : currentUser.refreshToken
@@ -7708,6 +7842,13 @@ const _excluded = ["callback", "error"],
7708
7842
  isAuthenticated: true
7709
7843
  });
7710
7844
  } catch (e) {
7845
+ const retry = tenantId => __refreshTokenHostedSocialLogins({
7846
+ tenantId,
7847
+ isSsoEnforcementRetry: true
7848
+ });
7849
+ if (await __handleSsoEnforcementRefreshError(e, isSsoEnforcementRetry, retry)) {
7850
+ return;
7851
+ }
7711
7852
  contextHolder.setAccessToken(null);
7712
7853
  contextHolder.setUser(null);
7713
7854
  actions.setAuthState({
@@ -7717,7 +7858,10 @@ const _excluded = ["callback", "error"],
7717
7858
  }
7718
7859
  };
7719
7860
  /** @private */
7720
- const __refreshTokenEmbeddedSocialLogins = async () => {
7861
+ const __refreshTokenEmbeddedSocialLogins = async ({
7862
+ tenantId,
7863
+ isSsoEnforcementRetry = false
7864
+ } = {}) => {
7721
7865
  try {
7722
7866
  const {
7723
7867
  routes,
@@ -7728,8 +7872,8 @@ const _excluded = ["callback", "error"],
7728
7872
  user,
7729
7873
  tenants = [],
7730
7874
  activeTenant
7731
- } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.refreshTokenWithRetry)(() => api.auth.refreshTokenV3());
7732
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isMfaRequired)(user, store.root.appName)) {
7875
+ } = await (0,_helpers__WEBPACK_IMPORTED_MODULE_9__.refreshTokenWithRetry)(() => api.auth.refreshTokenV3(tenantId));
7876
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.isMfaRequired)(user, store.root.appName)) {
7733
7877
  const mfaRequiredState = await actions.getMfaRequiredState(user);
7734
7878
  actions.setAuthState(mfaRequiredState);
7735
7879
  onRedirectTo(routes.loginUrl, {
@@ -7740,7 +7884,7 @@ const _excluded = ["callback", "error"],
7740
7884
  const shouldShowPrompt = await actions.__shouldShowPromptPasskeys();
7741
7885
  if (shouldShowPrompt) {
7742
7886
  actions.setLoginState({
7743
- step: _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginStep.promptPasskeys,
7887
+ step: _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginStep.promptPasskeys,
7744
7888
  loading: false
7745
7889
  });
7746
7890
  actions.afterAuthenticationStateUpdate({
@@ -7767,7 +7911,7 @@ const _excluded = ["callback", "error"],
7767
7911
  }, {
7768
7912
  loginState: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, loginState, {
7769
7913
  quickLoginToRegister,
7770
- flow: shouldNavigateToRegisterQuickLogin ? _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.RegisterQuickLogin : _interfaces__WEBPACK_IMPORTED_MODULE_6__.LoginFlow.Login
7914
+ flow: shouldNavigateToRegisterQuickLogin ? _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.RegisterQuickLogin : _interfaces__WEBPACK_IMPORTED_MODULE_11__.LoginFlow.Login
7771
7915
  }),
7772
7916
  isAuthenticated: true
7773
7917
  });
@@ -7778,6 +7922,13 @@ const _excluded = ["callback", "error"],
7778
7922
  }
7779
7923
  }
7780
7924
  } catch (e) {
7925
+ const retry = tenantId => __refreshTokenEmbeddedSocialLogins({
7926
+ tenantId,
7927
+ isSsoEnforcementRetry: true
7928
+ });
7929
+ if (await __handleSsoEnforcementRefreshError(e, isSsoEnforcementRetry, retry)) {
7930
+ return;
7931
+ }
7781
7932
  contextHolder.setAccessToken(null);
7782
7933
  contextHolder.setUser(null);
7783
7934
  actions.setAuthState({
@@ -7824,8 +7975,9 @@ const _excluded = ["callback", "error"],
7824
7975
  resetBreachedPassword,
7825
7976
  refreshTokenForSocialLogins,
7826
7977
  // protected
7827
- __refreshToken
7828
- }, (0,_hostedLoginAuthorize_actions__WEBPACK_IMPORTED_MODULE_26__["default"])(store, api, sharedActions), (0,_afterAuthNavigation_actions__WEBPACK_IMPORTED_MODULE_27__["default"])(store, api, sharedActions), (0,_handleVerifyMFAResponse_actions__WEBPACK_IMPORTED_MODULE_28__["default"])(store, api, sharedActions), (0,_mfaRequiredState_actions__WEBPACK_IMPORTED_MODULE_29__["default"])(store, api, sharedActions), (0,_mfaWithAuthenticator_actions__WEBPACK_IMPORTED_MODULE_30__["default"])(store, api, sharedActions), (0,_mfaWithEmailCode_actions__WEBPACK_IMPORTED_MODULE_31__["default"])(store, api, sharedActions), (0,_mfaWithSMS_actions__WEBPACK_IMPORTED_MODULE_32__["default"])(store, api, sharedActions), (0,_mfaWithWebAuthn_actions__WEBPACK_IMPORTED_MODULE_33__["default"])(store, api, sharedActions));
7978
+ __refreshToken,
7979
+ __redirectToSsoForTenant
7980
+ }, (0,_hostedLoginAuthorize_actions__WEBPACK_IMPORTED_MODULE_27__["default"])(store, api, sharedActions), (0,_afterAuthNavigation_actions__WEBPACK_IMPORTED_MODULE_28__["default"])(store, api, sharedActions), (0,_handleVerifyMFAResponse_actions__WEBPACK_IMPORTED_MODULE_29__["default"])(store, api, sharedActions), (0,_mfaRequiredState_actions__WEBPACK_IMPORTED_MODULE_30__["default"])(store, api, sharedActions), (0,_mfaWithAuthenticator_actions__WEBPACK_IMPORTED_MODULE_31__["default"])(store, api, sharedActions), (0,_mfaWithEmailCode_actions__WEBPACK_IMPORTED_MODULE_32__["default"])(store, api, sharedActions), (0,_mfaWithSMS_actions__WEBPACK_IMPORTED_MODULE_33__["default"])(store, api, sharedActions), (0,_mfaWithWebAuthn_actions__WEBPACK_IMPORTED_MODULE_34__["default"])(store, api, sharedActions));
7829
7981
  });
7830
7982
 
7831
7983
  /***/ }),
@@ -16791,6 +16943,7 @@ __webpack_require__.r(__webpack_exports__);
16791
16943
 
16792
16944
 
16793
16945
 
16946
+ const DEFAULT_INVITE_EXPIRES_IN_MINUTES = 43200;
16794
16947
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((store, api, sharedActions) => {
16795
16948
  const actions = sharedActions;
16796
16949
 
@@ -16818,6 +16971,7 @@ __webpack_require__.r(__webpack_exports__);
16818
16971
  value: false
16819
16972
  });
16820
16973
  try {
16974
+ var _data$roleIds;
16821
16975
  const retryConfig = payload == null ? void 0 : payload.retryConfig;
16822
16976
  await __getInvitationLinkConfig(retryConfig);
16823
16977
  const data = await (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.retryIfNeeded)(() => api.teams.getInviteUserLink(), retryConfig);
@@ -16825,7 +16979,9 @@ __webpack_require__.r(__webpack_exports__);
16825
16979
  inviteTokenState
16826
16980
  } = store.auth.teamState;
16827
16981
  actions.setTeamState({
16828
- inviteTokenState: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, inviteTokenState, data)
16982
+ inviteTokenState: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, inviteTokenState, data, {
16983
+ roleIds: (_data$roleIds = data.roleIds) != null ? _data$roleIds : []
16984
+ })
16829
16985
  });
16830
16986
  } catch (e) {
16831
16987
  actions.setTeamError({
@@ -16849,13 +17005,18 @@ __webpack_require__.r(__webpack_exports__);
16849
17005
  inviteTokenState
16850
17006
  } = store.auth.teamState;
16851
17007
  try {
16852
- const data = await api.teams.createInviteUserLinkV2({
16853
- expiresInMinutes: expiresInMinutes != null ? expiresInMinutes : 43200,
16854
- shouldSendEmail: shouldSendEmail != null ? shouldSendEmail : true,
16855
- roleIds: roleIds != null ? roleIds : []
16856
- });
17008
+ var _data$roleIds2;
17009
+ const invitationBody = {
17010
+ expiresInMinutes: expiresInMinutes != null ? expiresInMinutes : DEFAULT_INVITE_EXPIRES_IN_MINUTES,
17011
+ shouldSendEmail: shouldSendEmail != null ? shouldSendEmail : true
17012
+ };
17013
+ const data = roleIds != null && roleIds.length ? await api.teams.createInviteUserLinkV2((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, invitationBody, {
17014
+ roleIds
17015
+ })) : await api.teams.createInviteUserLink(invitationBody);
16857
17016
  actions.setTeamState({
16858
- inviteTokenState: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, inviteTokenState, data)
17017
+ inviteTokenState: (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, inviteTokenState, data, {
17018
+ roleIds: (_data$roleIds2 = data.roleIds) != null ? _data$roleIds2 : []
17019
+ })
16859
17020
  });
16860
17021
  callback == null ? void 0 : callback(data.token);
16861
17022
  } catch (e) {
@@ -18224,7 +18385,12 @@ __webpack_require__.r(__webpack_exports__);
18224
18385
  /* harmony export */ });
18225
18386
  /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./state */ "../../dist/@frontegg/redux-store/auth/TenantsState/state.js");
18226
18387
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/helpers/common.js");
18227
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/utils.js");
18388
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/helpers/handlers.js");
18389
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/feature-flags/index.js");
18390
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/interfaces.js");
18391
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/auth/utils.js");
18392
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../constants */ "../../dist/@frontegg/redux-store/constants.js");
18393
+
18228
18394
 
18229
18395
 
18230
18396
 
@@ -18278,6 +18444,15 @@ __webpack_require__.r(__webpack_exports__);
18278
18444
  }) : actions.setAuthState({
18279
18445
  isLoading: false
18280
18446
  });
18447
+ const [isEnforceSsoOnTenantAccessEnabled] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__.FeatureFlags.getFeatureFlags([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.ENFORCE_SSO_ON_TENANT_ACCESS_FF], store.root.appName);
18448
+ // a switch re-run after coming back from SSO doesn't send the user to SSO again
18449
+ const isPendingSwitchRerun = window.sessionStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_PENDING_SWITCH_TENANT) === tenantId;
18450
+ if (isEnforceSsoOnTenantAccessEnabled && (0,_helpers__WEBPACK_IMPORTED_MODULE_5__.isSsoEnforcementError)(e) && e.errorContext.ssoRequired && !isPendingSwitchRerun) {
18451
+ // saved to finish the switch after the SSO login, which may land in another tenant
18452
+ window.sessionStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_PENDING_SWITCH_TENANT, tenantId);
18453
+ await actions.__redirectToSsoForTenant(e.errorContext);
18454
+ return;
18455
+ }
18281
18456
  callback == null ? void 0 : callback(false, e);
18282
18457
  }
18283
18458
  };
@@ -18287,7 +18462,7 @@ __webpack_require__.r(__webpack_exports__);
18287
18462
  });
18288
18463
  try {
18289
18464
  var _payload$callback;
18290
- const userTenantsResponseFunc = (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__.getCurrentUserTenantsFunction)(store.root.appName);
18465
+ const userTenantsResponseFunc = (0,_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_6__.getCurrentUserTenantsFunction)(store.root.appName);
18291
18466
  const userTenantsResponse = await userTenantsResponseFunc();
18292
18467
  setTenantsState({
18293
18468
  tenants: userTenantsResponse.tenants,
@@ -20019,6 +20194,7 @@ __webpack_require__.r(__webpack_exports__);
20019
20194
  /* harmony export */ AMR_MFA_VALUE: () => (/* reexport safe */ _auth_StepUpState_consts__WEBPACK_IMPORTED_MODULE_0__.AMR_MFA_VALUE),
20020
20195
  /* harmony export */ DEFAULT_RETRY_CONFIG: () => (/* binding */ DEFAULT_RETRY_CONFIG),
20021
20196
  /* harmony export */ FRONTEGG_AFTER_AUTH_REDIRECT_URL: () => (/* binding */ FRONTEGG_AFTER_AUTH_REDIRECT_URL),
20197
+ /* harmony export */ FRONTEGG_PENDING_SWITCH_TENANT: () => (/* binding */ FRONTEGG_PENDING_SWITCH_TENANT),
20022
20198
  /* harmony export */ HOSTED_LOGIN_VERIFIER_KEY: () => (/* binding */ HOSTED_LOGIN_VERIFIER_KEY),
20023
20199
  /* harmony export */ SHOULD_STEP_UP_KEY: () => (/* reexport safe */ _auth_StepUpState_consts__WEBPACK_IMPORTED_MODULE_0__.SHOULD_STEP_UP_KEY),
20024
20200
  /* harmony export */ STEP_UP_MAX_AGE_PARAM_NAME: () => (/* reexport safe */ _auth_StepUpState_consts__WEBPACK_IMPORTED_MODULE_0__.STEP_UP_MAX_AGE_PARAM_NAME),
@@ -20028,6 +20204,7 @@ __webpack_require__.r(__webpack_exports__);
20028
20204
  /* harmony import */ var _auth_StepUpState_consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./auth/StepUpState/consts */ "../../dist/@frontegg/redux-store/auth/StepUpState/consts.js");
20029
20205
  /* harmony import */ var _auth_LoginState_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./auth/LoginState/consts */ "../../dist/@frontegg/redux-store/auth/LoginState/consts.js");
20030
20206
  const FRONTEGG_AFTER_AUTH_REDIRECT_URL = 'FRONTEGG_AFTER_AUTH_REDIRECT_URL';
20207
+ const FRONTEGG_PENDING_SWITCH_TENANT = 'FRONTEGG_PENDING_SWITCH_TENANT';
20031
20208
  const HOSTED_LOGIN_VERIFIER_KEY = 'HOSTED_LOGIN_VERIFIER_KEY';
20032
20209
  const DEFAULT_RETRY_CONFIG = {
20033
20210
  retryCount: 3
@@ -20349,12 +20526,16 @@ __webpack_require__.r(__webpack_exports__);
20349
20526
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
20350
20527
  /* harmony export */ errorHandler: () => (/* binding */ errorHandler),
20351
20528
  /* harmony export */ isError: () => (/* binding */ isError),
20352
- /* harmony export */ isFronteggApiError: () => (/* binding */ isFronteggApiError)
20529
+ /* harmony export */ isFronteggApiError: () => (/* binding */ isFronteggApiError),
20530
+ /* harmony export */ isSsoEnforcementError: () => (/* binding */ isSsoEnforcementError)
20353
20531
  /* harmony export */ });
20354
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/error.js");
20355
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/constants.js");
20532
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/constants.js");
20533
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/error.js");
20356
20534
 
20357
20535
  const isFronteggApiError = error => Boolean(error == null ? void 0 : error.statusCode);
20536
+
20537
+ // ER-01079 (disabled user / expired tenant) is not this: it still logs out
20538
+ const isSsoEnforcementError = error => isFronteggApiError(error) && error.errorCode === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__.SSO_REQUIRED_FOR_TENANT_ERROR_CODE;
20358
20539
  const isError = error => {
20359
20540
  if (error instanceof Error) {
20360
20541
  return true;
@@ -20376,7 +20557,7 @@ const errorHandler = (error, fallback) => {
20376
20557
  } else if (typeof error === 'string') {
20377
20558
  console.error(error);
20378
20559
  }
20379
- return fallback != null ? fallback : new _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__.FronteggApiError(_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_1__.GENERIC_ERROR_MESSAGE, 500, null, _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_1__.GENERIC_ERROR_CODE);
20560
+ return fallback != null ? fallback : new _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_1__.FronteggApiError(_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__.GENERIC_ERROR_MESSAGE, 500, null, _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__.GENERIC_ERROR_CODE);
20380
20561
  };
20381
20562
 
20382
20563
  /***/ }),
@@ -20407,6 +20588,7 @@ __webpack_require__.r(__webpack_exports__);
20407
20588
  /* harmony export */ isError: () => (/* reexport safe */ _handlers__WEBPACK_IMPORTED_MODULE_1__.isError),
20408
20589
  /* harmony export */ isFronteggApiError: () => (/* reexport safe */ _handlers__WEBPACK_IMPORTED_MODULE_1__.isFronteggApiError),
20409
20590
  /* harmony export */ isProxy: () => (/* reexport safe */ _common__WEBPACK_IMPORTED_MODULE_0__.isProxy),
20591
+ /* harmony export */ isSsoEnforcementError: () => (/* reexport safe */ _handlers__WEBPACK_IMPORTED_MODULE_1__.isSsoEnforcementError),
20410
20592
  /* harmony export */ omitProps: () => (/* reexport safe */ _common__WEBPACK_IMPORTED_MODULE_0__.omitProps),
20411
20593
  /* harmony export */ publicKeyCredentialToJSON: () => (/* reexport safe */ _converters__WEBPACK_IMPORTED_MODULE_2__.publicKeyCredentialToJSON),
20412
20594
  /* harmony export */ readFileAsText: () => (/* reexport safe */ _converters__WEBPACK_IMPORTED_MODULE_2__.readFileAsText),
@@ -21012,6 +21194,7 @@ __webpack_require__.r(__webpack_exports__);
21012
21194
  /* harmony export */ FRONTEGG_OAUTH_STEP_UP_ACR_VALUES: () => (/* reexport safe */ _toolkit__WEBPACK_IMPORTED_MODULE_0__.FRONTEGG_OAUTH_STEP_UP_ACR_VALUES),
21013
21195
  /* harmony export */ FRONTEGG_OAUTH_STEP_UP_MAX_AGE: () => (/* reexport safe */ _toolkit__WEBPACK_IMPORTED_MODULE_0__.FRONTEGG_OAUTH_STEP_UP_MAX_AGE),
21014
21196
  /* harmony export */ FRONTEGG_OAUTH_TENANT_ID: () => (/* reexport safe */ _toolkit__WEBPACK_IMPORTED_MODULE_0__.FRONTEGG_OAUTH_TENANT_ID),
21197
+ /* harmony export */ FRONTEGG_PENDING_SWITCH_TENANT: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_1__.FRONTEGG_PENDING_SWITCH_TENANT),
21015
21198
  /* harmony export */ ForgotPasswordStep: () => (/* reexport safe */ _toolkit__WEBPACK_IMPORTED_MODULE_0__.ForgotPasswordStep),
21016
21199
  /* harmony export */ FronteggNativeModule: () => (/* reexport safe */ _toolkit__WEBPACK_IMPORTED_MODULE_0__.FronteggNativeModule),
21017
21200
  /* harmony export */ GTMEventAction: () => (/* reexport safe */ _helpers__WEBPACK_IMPORTED_MODULE_2__.GTMEventAction),
@@ -21105,6 +21288,7 @@ __webpack_require__.r(__webpack_exports__);
21105
21288
  /* harmony export */ isPreferredMfaMethod: () => (/* reexport safe */ _toolkit__WEBPACK_IMPORTED_MODULE_0__.isPreferredMfaMethod),
21106
21289
  /* harmony export */ isProxy: () => (/* reexport safe */ _helpers__WEBPACK_IMPORTED_MODULE_2__.isProxy),
21107
21290
  /* harmony export */ isResetPasswordRequired: () => (/* reexport safe */ _auth_helpers__WEBPACK_IMPORTED_MODULE_3__.isResetPasswordRequired),
21291
+ /* harmony export */ isSsoEnforcementError: () => (/* reexport safe */ _helpers__WEBPACK_IMPORTED_MODULE_2__.isSsoEnforcementError),
21108
21292
  /* harmony export */ isSteppedUp: () => (/* reexport safe */ _auth_helpers__WEBPACK_IMPORTED_MODULE_3__.isSteppedUp),
21109
21293
  /* harmony export */ isUsernamePayload: () => (/* reexport safe */ _auth_helpers__WEBPACK_IMPORTED_MODULE_3__.isUsernamePayload),
21110
21294
  /* harmony export */ mapMetaDataObjectToActions: () => (/* reexport safe */ _auth_helpers__WEBPACK_IMPORTED_MODULE_3__.mapMetaDataObjectToActions),
@@ -21139,7 +21323,7 @@ __webpack_require__.r(__webpack_exports__);
21139
21323
  /* harmony import */ var _subscriptions_interfaces__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./subscriptions/interfaces */ "../../dist/@frontegg/redux-store/subscriptions/interfaces.js");
21140
21324
  /* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./vendor */ "../../dist/@frontegg/redux-store/vendor/index.js");
21141
21325
  /* harmony import */ var _audits__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./audits */ "../../dist/@frontegg/redux-store/audits/index.js");
21142
- /** @license Frontegg v7.127.0
21326
+ /** @license Frontegg v7.129.0-alpha.0
21143
21327
  *
21144
21328
  * This source code is licensed under the MIT license found in the
21145
21329
  * LICENSE file in the root directory of this source tree.
@@ -29899,10 +30083,10 @@ class AuthenticationApi extends _BaseApiClient__WEBPACK_IMPORTED_MODULE_6__.Base
29899
30083
  });
29900
30084
  return this.generateLoginResponseV2(data);
29901
30085
  };
29902
- this.refreshTokenV3 = async () => {
30086
+ this.refreshTokenV3 = async tenantId => {
29903
30087
  const tabTenantId = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getTabTenantFromSessionStorage)(this.appName);
29904
30088
  const data = await this.post(`${_constants__WEBPACK_IMPORTED_MODULE_11__.urls.identity.auth.v1}/user/token/refresh`, {
29905
- tenantId: tabTenantId
30089
+ tenantId: tenantId != null ? tenantId : tabTenantId
29906
30090
  });
29907
30091
  return this.generateLoginResponseV3(data);
29908
30092
  };
@@ -30578,6 +30762,7 @@ class AuthenticationApi extends _BaseApiClient__WEBPACK_IMPORTED_MODULE_6__.Base
30578
30762
  "use strict";
30579
30763
  __webpack_require__.r(__webpack_exports__);
30580
30764
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
30765
+ /* harmony export */ ENFORCE_SSO_ON_TENANT_ACCESS_FF: () => (/* binding */ ENFORCE_SSO_ON_TENANT_ACCESS_FF),
30581
30766
  /* harmony export */ LOAD_AUTHORIZATION_FF: () => (/* binding */ LOAD_AUTHORIZATION_FF),
30582
30767
  /* harmony export */ MFAStrategyEnum: () => (/* binding */ MFAStrategyEnum),
30583
30768
  /* harmony export */ PreLoginAddressType: () => (/* binding */ PreLoginAddressType),
@@ -30619,6 +30804,13 @@ let MFAStrategyEnum;
30619
30804
  MFAStrategyEnum["EmailCode"] = "EmailCode";
30620
30805
  })(MFAStrategyEnum || (MFAStrategyEnum = {}));
30621
30806
  const LOAD_AUTHORIZATION_FF = 'admin_portal_should_load_authorization';
30807
+ const ENFORCE_SSO_ON_TENANT_ACCESS_FF = 'enforce-sso-on-tenant-access';
30808
+
30809
+ /**
30810
+ * errorContext of a refused tenant switch or token refresh when the tenant requires SSO.
30811
+ * ssoRequired: true - the user must log in through the tenant's SSO at `address`.
30812
+ * ssoRequired: false - the user may stay in the current tenant, still logged in.
30813
+ */
30622
30814
 
30623
30815
  /***/ }),
30624
30816
 
@@ -31013,6 +31205,7 @@ __webpack_require__.r(__webpack_exports__);
31013
31205
  /* harmony export */ INVITATION_LINK_CREATION_TENANT_LOCKED_ERROR_CODE: () => (/* binding */ INVITATION_LINK_CREATION_TENANT_LOCKED_ERROR_CODE),
31014
31206
  /* harmony export */ INVITATION_TENANT_LOCKED_ERROR_CODE: () => (/* binding */ INVITATION_TENANT_LOCKED_ERROR_CODE),
31015
31207
  /* harmony export */ SSO_EMAIL_MISMATCH_ERROR_CODE: () => (/* binding */ SSO_EMAIL_MISMATCH_ERROR_CODE),
31208
+ /* harmony export */ SSO_REQUIRED_FOR_TENANT_ERROR_CODE: () => (/* binding */ SSO_REQUIRED_FOR_TENANT_ERROR_CODE),
31016
31209
  /* harmony export */ urls: () => (/* binding */ urls)
31017
31210
  /* harmony export */ });
31018
31211
  const urls = {
@@ -31344,6 +31537,10 @@ const INVALID_SSO_EMAIL_DOMAIN_ERROR_CODE = 'ER-01248';
31344
31537
  // Returned on the SAML callback when the email returned by the IdP differs from the one that started the login.
31345
31538
  const SSO_EMAIL_MISMATCH_ERROR_CODE = 'ER-01249';
31346
31539
 
31540
+ // Returned by identity-service when a login, tenant switch or token refresh is refused because the target tenant
31541
+ // requires SSO (HTTP 400 Bad Request, IdentityErrorCodes.SsoRequiredForTenantException with an errorContext).
31542
+ const SSO_REQUIRED_FOR_TENANT_ERROR_CODE = 'ER-01253';
31543
+
31347
31544
  /***/ }),
31348
31545
 
31349
31546
  /***/ "../../dist/@frontegg/rest-api/directory/index.js":
@@ -31746,6 +31943,7 @@ __webpack_require__.r(__webpack_exports__);
31746
31943
  /* harmony export */ ContextHolder: () => (/* reexport safe */ _ContextHolder__WEBPACK_IMPORTED_MODULE_46__.ContextHolder),
31747
31944
  /* harmony export */ DirectoryApi: () => (/* reexport safe */ _directory_index__WEBPACK_IMPORTED_MODULE_11__.DirectoryApi),
31748
31945
  /* harmony export */ EIdentifierType: () => (/* reexport safe */ _auth_enums__WEBPACK_IMPORTED_MODULE_2__.EIdentifierType),
31946
+ /* harmony export */ ENFORCE_SSO_ON_TENANT_ACCESS_FF: () => (/* reexport safe */ _auth_interfaces__WEBPACK_IMPORTED_MODULE_1__.ENFORCE_SSO_ON_TENANT_ACCESS_FF),
31749
31947
  /* harmony export */ FRONTEGG_SEPARATE_TABS_BY_TENANT: () => (/* reexport safe */ _auth__WEBPACK_IMPORTED_MODULE_4__.FRONTEGG_SEPARATE_TABS_BY_TENANT),
31750
31948
  /* harmony export */ FeatureFlags: () => (/* reexport safe */ _feature_flags_index__WEBPACK_IMPORTED_MODULE_10__.FeatureFlags),
31751
31949
  /* harmony export */ FeatureFlagsApi: () => (/* reexport safe */ _feature_flags_index__WEBPACK_IMPORTED_MODULE_10__.FeatureFlagsApi),
@@ -31780,6 +31978,7 @@ __webpack_require__.r(__webpack_exports__);
31780
31978
  /* harmony export */ RequestSource: () => (/* reexport safe */ _interfaces__WEBPACK_IMPORTED_MODULE_0__.RequestSource),
31781
31979
  /* harmony export */ RestrictionType: () => (/* reexport safe */ _auth_interfaces__WEBPACK_IMPORTED_MODULE_1__.RestrictionType),
31782
31980
  /* harmony export */ SSO_EMAIL_MISMATCH_ERROR_CODE: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_18__.SSO_EMAIL_MISMATCH_ERROR_CODE),
31981
+ /* harmony export */ SSO_REQUIRED_FOR_TENANT_ERROR_CODE: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_18__.SSO_REQUIRED_FOR_TENANT_ERROR_CODE),
31783
31982
  /* harmony export */ ScimConnectionSource: () => (/* reexport safe */ _directory_interfaces__WEBPACK_IMPORTED_MODULE_12__.ScimConnectionSource),
31784
31983
  /* harmony export */ SecondaryAuthStrategy: () => (/* reexport safe */ _auth_interfaces__WEBPACK_IMPORTED_MODULE_1__.SecondaryAuthStrategy),
31785
31984
  /* harmony export */ SecurityCategory: () => (/* reexport safe */ _security_center_interfaces__WEBPACK_IMPORTED_MODULE_16__.SecurityCategory),
@@ -31858,7 +32057,7 @@ __webpack_require__.r(__webpack_exports__);
31858
32057
  /* harmony import */ var _security_center_interfaces__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./security-center/interfaces */ "../../dist/@frontegg/rest-api/security-center/interfaces.js");
31859
32058
  /* harmony import */ var _applications_interfaces__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./applications/interfaces */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
31860
32059
  /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./constants */ "../../dist/@frontegg/rest-api/constants.js");
31861
- /** @license Frontegg v7.127.0
32060
+ /** @license Frontegg v7.129.0-alpha.0
31862
32061
  *
31863
32062
  * This source code is licensed under the MIT license found in the
31864
32063
  * LICENSE file in the root directory of this source tree.
@@ -33437,10 +33636,14 @@ __webpack_require__.r(__webpack_exports__);
33437
33636
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
33438
33637
  /* harmony export */ });
33439
33638
  /* harmony import */ var _babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/extends */ "../../node_modules/@babel/runtime/helpers/esm/extends.js");
33440
- /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../constants */ "../../dist/@frontegg/rest-api/constants.js");
33441
- /* harmony import */ var _auth_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../auth/utils */ "../../dist/@frontegg/rest-api/auth/utils.js");
33442
- /* harmony import */ var _ContextHolder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ContextHolder */ "../../dist/@frontegg/rest-api/ContextHolder/index.js");
33639
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../constants */ "../../dist/@frontegg/rest-api/constants.js");
33640
+ /* harmony import */ var _auth_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../auth/utils */ "../../dist/@frontegg/rest-api/auth/utils.js");
33641
+ /* harmony import */ var _auth_interfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../auth/interfaces */ "../../dist/@frontegg/rest-api/auth/interfaces.js");
33642
+ /* harmony import */ var _ContextHolder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../ContextHolder */ "../../dist/@frontegg/rest-api/ContextHolder/index.js");
33443
33643
  /* harmony import */ var _BaseApiClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../BaseApiClient */ "../../dist/@frontegg/rest-api/BaseApiClient.js");
33644
+ /* harmony import */ var _feature_flags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../feature-flags */ "../../dist/@frontegg/rest-api/feature-flags/index.js");
33645
+
33646
+
33444
33647
 
33445
33648
 
33446
33649
 
@@ -33450,46 +33653,60 @@ class TenantsApi extends _BaseApiClient__WEBPACK_IMPORTED_MODULE_1__.BaseApiClie
33450
33653
  constructor(appName) {
33451
33654
  super(appName);
33452
33655
  this.switchTenant = async body => {
33453
- if (_ContextHolder__WEBPACK_IMPORTED_MODULE_2__.ContextHolder.for(this.appName).isSessionPerTenantEnabled()) {
33454
- (0,_auth_utils__WEBPACK_IMPORTED_MODULE_3__.setTabTenantInSessionStorage)(body.tenantId);
33656
+ const [isEnforceSsoOnTenantAccessEnabled] = _feature_flags__WEBPACK_IMPORTED_MODULE_2__.FeatureFlags.getFeatureFlags([_auth_interfaces__WEBPACK_IMPORTED_MODULE_3__.ENFORCE_SSO_ON_TENANT_ACCESS_FF], this.appName);
33657
+ if (isEnforceSsoOnTenantAccessEnabled && _ContextHolder__WEBPACK_IMPORTED_MODULE_4__.ContextHolder.for(this.appName).isSessionPerTenantEnabled()) {
33658
+ return this.switchTabTenantKeepingItOnRefusal(body);
33659
+ }
33660
+ if (_ContextHolder__WEBPACK_IMPORTED_MODULE_4__.ContextHolder.for(this.appName).isSessionPerTenantEnabled()) {
33661
+ (0,_auth_utils__WEBPACK_IMPORTED_MODULE_5__.setTabTenantInSessionStorage)(body.tenantId);
33662
+ }
33663
+ return this.put(`${_constants__WEBPACK_IMPORTED_MODULE_6__.urls.identity.users.v1}/tenant`, body);
33664
+ };
33665
+ this.switchTabTenantKeepingItOnRefusal = async body => {
33666
+ const previousTabTenantId = (0,_auth_utils__WEBPACK_IMPORTED_MODULE_5__.getTabTenantFromSessionStorage)(this.appName);
33667
+ (0,_auth_utils__WEBPACK_IMPORTED_MODULE_5__.setTabTenantInSessionStorage)(body.tenantId);
33668
+ try {
33669
+ return await this.put(`${_constants__WEBPACK_IMPORTED_MODULE_6__.urls.identity.users.v1}/tenant`, body);
33670
+ } catch (e) {
33671
+ previousTabTenantId ? (0,_auth_utils__WEBPACK_IMPORTED_MODULE_5__.setTabTenantInSessionStorage)(previousTabTenantId) : (0,_auth_utils__WEBPACK_IMPORTED_MODULE_5__.removeTabTenantFromSessionStorage)();
33672
+ throw e;
33455
33673
  }
33456
- return this.put(`${_constants__WEBPACK_IMPORTED_MODULE_4__.urls.identity.users.v1}/tenant`, body);
33457
33674
  };
33458
33675
  this.getTenants = async () => {
33459
- return this.get(`${_constants__WEBPACK_IMPORTED_MODULE_4__.urls.identity.users.v2}/me/tenants`);
33676
+ return this.get(`${_constants__WEBPACK_IMPORTED_MODULE_6__.urls.identity.users.v2}/me/tenants`);
33460
33677
  };
33461
33678
  this.getSubTenants = async options => {
33462
- return this.get(_constants__WEBPACK_IMPORTED_MODULE_4__.urls.tenants.hierarchy.v1, undefined, {
33679
+ return this.get(_constants__WEBPACK_IMPORTED_MODULE_6__.urls.tenants.hierarchy.v1, undefined, {
33463
33680
  headers: this.extractHeadersFromOptions(options)
33464
33681
  });
33465
33682
  };
33466
33683
  this.getSubTenantsAsTree = async options => {
33467
- return this.get(_constants__WEBPACK_IMPORTED_MODULE_4__.urls.tenants.hierarchy.tree.v1, undefined, {
33684
+ return this.get(_constants__WEBPACK_IMPORTED_MODULE_6__.urls.tenants.hierarchy.tree.v1, undefined, {
33468
33685
  headers: this.extractHeadersFromOptions(options)
33469
33686
  });
33470
33687
  };
33471
33688
  this.getParentTenants = async options => {
33472
- return this.get(_constants__WEBPACK_IMPORTED_MODULE_4__.urls.tenants.hierarchy.parents.v1, undefined, {
33689
+ return this.get(_constants__WEBPACK_IMPORTED_MODULE_6__.urls.tenants.hierarchy.parents.v1, undefined, {
33473
33690
  headers: this.extractHeadersFromOptions(options)
33474
33691
  });
33475
33692
  };
33476
33693
  this.getParentTenantsById = async (tenantId, options) => {
33477
- return this.get(`${_constants__WEBPACK_IMPORTED_MODULE_4__.urls.tenants.hierarchy.parents.v1}/${tenantId}`, undefined, {
33694
+ return this.get(`${_constants__WEBPACK_IMPORTED_MODULE_6__.urls.tenants.hierarchy.parents.v1}/${tenantId}`, undefined, {
33478
33695
  headers: this.extractHeadersFromOptions(options)
33479
33696
  });
33480
33697
  };
33481
33698
  this.getTenantsUsersCount = async (body, options) => {
33482
- return this.post(`${_constants__WEBPACK_IMPORTED_MODULE_4__.urls.identity.tenants.users.v1}/count`, body, {
33699
+ return this.post(`${_constants__WEBPACK_IMPORTED_MODULE_6__.urls.identity.tenants.users.v1}/count`, body, {
33483
33700
  headers: this.extractHeadersFromOptions(options)
33484
33701
  });
33485
33702
  };
33486
33703
  this.searchSubTenants = async (params, options) => {
33487
- return this.get(_constants__WEBPACK_IMPORTED_MODULE_4__.urls.tenants.hierarchy.v2, params, {
33704
+ return this.get(_constants__WEBPACK_IMPORTED_MODULE_6__.urls.tenants.hierarchy.v2, params, {
33488
33705
  headers: this.extractHeadersFromOptions(options)
33489
33706
  });
33490
33707
  };
33491
33708
  this.getHierarchyMetadata = async (params, options) => {
33492
- return this.get(_constants__WEBPACK_IMPORTED_MODULE_4__.urls.tenants.hierarchy.metadata.v2, (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, params, {
33709
+ return this.get(_constants__WEBPACK_IMPORTED_MODULE_6__.urls.tenants.hierarchy.metadata.v2, (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, params, {
33493
33710
  _tenantIds: params._tenantIds.join(',')
33494
33711
  }), {
33495
33712
  headers: this.extractHeadersFromOptions(options)
@@ -34700,7 +34917,7 @@ __webpack_require__.r(__webpack_exports__);
34700
34917
  /* harmony export */ });
34701
34918
  /* harmony import */ var _ThemeOptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ThemeOptions */ "../../dist/@frontegg/types/ThemeOptions/index.js");
34702
34919
  /* harmony import */ var _Metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Metadata */ "../../dist/@frontegg/types/Metadata/index.js");
34703
- /** @license Frontegg v7.127.0
34920
+ /** @license Frontegg v7.129.0-alpha.0
34704
34921
  *
34705
34922
  * This source code is licensed under the MIT license found in the
34706
34923
  * LICENSE file in the root directory of this source tree.