@frontegg/js 7.133.0-alpha.0 → 7.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.133.0-alpha.0
1
+ /** @license Frontegg v7.134.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.133.0-alpha.0
1
+ /** @license Frontegg v7.134.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/node/version.js CHANGED
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _default = {
8
- cdnVersion: '7.133.0-alpha.0'
8
+ cdnVersion: '7.134.0'
9
9
  };
10
10
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@frontegg/js",
3
- "version": "7.133.0-alpha.0",
3
+ "version": "7.134.0",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
- "@frontegg/types": "7.133.0-alpha.0"
9
+ "@frontegg/types": "7.134.0"
10
10
  },
11
11
  "browserslist": {
12
12
  "production": [
@@ -1965,7 +1965,7 @@ __webpack_require__.r(__webpack_exports__);
1965
1965
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1966
1966
  /* harmony export */ });
1967
1967
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1968
- cdnVersion: '7.133.0-alpha.0'
1968
+ cdnVersion: '7.134.0'
1969
1969
  });
1970
1970
 
1971
1971
  /***/ }),
@@ -17509,11 +17509,21 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17509
17509
 
17510
17510
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((store, api, sharedActions) => {
17511
17511
  const actions = sharedActions;
17512
- const isEnvironmentScopedRolesEnabled = () => {
17512
+ const isEnvironmentScopedRolesFlagOn = () => {
17513
17513
  const [isEnabled] = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_2__.FeatureFlags.getFeatureFlags([_frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.ENVIRONMENT_SCOPED_ROLES_FF], store.root.appName);
17514
17514
  return isEnabled;
17515
17515
  };
17516
- const getEnabledEnvironmentRoles = requested => isEnvironmentScopedRolesEnabled() ? requested : undefined;
17516
+
17517
+ // The flag loads before login, so it can't target an account; identity tells per account by sending environmentRoles.
17518
+ // The answer is kept with the tenant it came from, so a tenant switch never reuses it
17519
+ const isEnvironmentScopedRolesEnabled = () => {
17520
+ var _store$auth$user;
17521
+ const tenantId = (_store$auth$user = store.auth.user) == null ? void 0 : _store$auth$user.tenantId;
17522
+ return isEnvironmentScopedRolesFlagOn() && !!tenantId && store.auth.teamState.environmentRolesEnabledForTenantId === tenantId;
17523
+ };
17524
+
17525
+ // Saves keep the requested roles even before identity's answer loads; identity rejects them when off for the account
17526
+ const getEnabledEnvironmentRoles = requested => isEnvironmentScopedRolesFlagOn() ? requested : undefined;
17517
17527
 
17518
17528
  /**
17519
17529
  * @private
@@ -17537,6 +17547,7 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17537
17547
  * Enriches users with roles, groups, permissions, and application data
17538
17548
  */
17539
17549
  const __enrichUsersWithRolesGroupsAndPermissions = async (users, options) => {
17550
+ var _options$tenantId, _store$auth$user2, _store$auth$user3;
17540
17551
  const {
17541
17552
  shouldLoadRoles = true,
17542
17553
  shouldLoadApps,
@@ -17546,6 +17557,8 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17546
17557
 
17547
17558
  // Get user IDs for fetching roles and groups and emails
17548
17559
  const userIds = users.map(user => user.id);
17560
+ // Identity answers for the tenant the load started on, so a switch during the load discards the answer
17561
+ const requestTenantId = (_options$tenantId = options.tenantId) != null ? _options$tenantId : (_store$auth$user2 = store.auth.user) == null ? void 0 : _store$auth$user2.tenantId;
17549
17562
 
17550
17563
  // Fetch roles, permissions, user roles, user groups, user emails, and all groups in parallel
17551
17564
  const [{
@@ -17575,7 +17588,18 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17575
17588
  }, __getGroupsForUsers(retryConfig), shouldLoadRoles ? loadRoles({
17576
17589
  retryConfig
17577
17590
  }) : undefined]);
17578
- const shouldKeepEnvironmentRoles = isEnvironmentScopedRolesEnabled();
17591
+ const shouldKeepEnvironmentRoles = isEnvironmentScopedRolesFlagOn();
17592
+ if (shouldKeepEnvironmentRoles && userRoles.length > 0 && requestTenantId === ((_store$auth$user3 = store.auth.user) == null ? void 0 : _store$auth$user3.tenantId)) {
17593
+ const isEnabledForAccount = userRoles.some(({
17594
+ environmentRoles
17595
+ }) => environmentRoles !== undefined);
17596
+ const environmentRolesEnabledForTenantId = isEnabledForAccount ? requestTenantId : undefined;
17597
+ if (environmentRolesEnabledForTenantId !== store.auth.teamState.environmentRolesEnabledForTenantId) {
17598
+ actions.setTeamState({
17599
+ environmentRolesEnabledForTenantId
17600
+ });
17601
+ }
17602
+ }
17579
17603
 
17580
17604
  // Map user roles and groups to users
17581
17605
  const usersWithRolesAndGroups = users.map(user => {
@@ -17704,6 +17728,8 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17704
17728
  pageOffset
17705
17729
  });
17706
17730
  try {
17731
+ var _store$auth$user4;
17732
+ const requestTenantId = (_store$auth$user4 = store.auth.user) == null ? void 0 : _store$auth$user4.tenantId;
17707
17733
  const response = await fetchFunction(pageOffset, pageSize);
17708
17734
  if (!response.items || response.items.length === 0) {
17709
17735
  sharedActions.setTeamState({
@@ -17739,7 +17765,8 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17739
17765
  shouldLoadRoles,
17740
17766
  shouldLoadApps,
17741
17767
  shouldLoadEmails,
17742
- retryConfig
17768
+ retryConfig,
17769
+ tenantId: requestTenantId
17743
17770
  });
17744
17771
  __setUsersStateAndCallback(enrichedUsers, roles, permissions, response._metadata.totalPages, response._metadata.totalItems, callback);
17745
17772
  } catch (e) {
@@ -17782,35 +17809,59 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17782
17809
  });
17783
17810
  }
17784
17811
  };
17812
+ let latestEnvironmentsRequest = 0;
17813
+ const isSameEnvironments = (current = [], loaded) => current.length === loaded.length && current.every(({
17814
+ id,
17815
+ environmentName
17816
+ }, index) => id === loaded[index].id && environmentName === loaded[index].environmentName);
17817
+
17818
+ // Only the latest request updates the state, so an older answer arriving last can't bring back an old list.
17819
+ // The list is stored with its tenant, so a switch during the request discards it and another tenant's list is never shown
17785
17820
  const loadEnvironments = async payload => {
17821
+ var _store$auth$user5;
17786
17822
  if (!isEnvironmentScopedRolesEnabled()) {
17787
17823
  return;
17788
17824
  }
17825
+ const request = ++latestEnvironmentsRequest;
17826
+ const isLatestRequest = () => request === latestEnvironmentsRequest;
17827
+ const requestTenantId = (_store$auth$user5 = store.auth.user) == null ? void 0 : _store$auth$user5.tenantId;
17789
17828
  actions.setTeamLoader({
17790
17829
  key: _interfaces__WEBPACK_IMPORTED_MODULE_6__.TeamStateKeys.ENVIRONMENTS,
17791
17830
  value: true
17792
17831
  });
17793
17832
  try {
17794
- var _payload$callback3;
17833
+ var _store$auth$user6, _payload$callback3;
17795
17834
  const {
17796
17835
  vendors: environments
17797
17836
  } = await api.vendor.getAccount();
17798
- actions.setTeamState({
17799
- environments
17800
- });
17837
+ const {
17838
+ environments: currentEnvironments,
17839
+ environmentsTenantId
17840
+ } = store.auth.teamState;
17841
+ const isStoredForTenant = environmentsTenantId === requestTenantId && isSameEnvironments(currentEnvironments, environments);
17842
+ if (isLatestRequest() && requestTenantId === ((_store$auth$user6 = store.auth.user) == null ? void 0 : _store$auth$user6.tenantId) && !isStoredForTenant) {
17843
+ actions.setTeamState({
17844
+ environments,
17845
+ environmentsTenantId: requestTenantId
17846
+ });
17847
+ }
17801
17848
  payload == null ? void 0 : (_payload$callback3 = payload.callback) == null ? void 0 : _payload$callback3.call(payload, environments);
17802
17849
  } catch (e) {
17803
17850
  var _payload$callback4;
17804
17851
  payload == null ? void 0 : (_payload$callback4 = payload.callback) == null ? void 0 : _payload$callback4.call(payload, null, e);
17805
- actions.setTeamError({
17806
- key: _interfaces__WEBPACK_IMPORTED_MODULE_6__.TeamStateKeys.ENVIRONMENTS,
17807
- value: (0,_helpers__WEBPACK_IMPORTED_MODULE_7__.errorHandler)(e)
17808
- });
17852
+ if (isLatestRequest()) {
17853
+ actions.setTeamError({
17854
+ key: _interfaces__WEBPACK_IMPORTED_MODULE_6__.TeamStateKeys.ENVIRONMENTS,
17855
+ value: (0,_helpers__WEBPACK_IMPORTED_MODULE_7__.errorHandler)(e)
17856
+ });
17857
+ }
17809
17858
  } finally {
17810
- actions.setTeamLoader({
17811
- key: _interfaces__WEBPACK_IMPORTED_MODULE_6__.TeamStateKeys.ENVIRONMENTS,
17812
- value: false
17813
- });
17859
+ if (isLatestRequest()) {
17860
+ actions.setTeamLoader({
17861
+ key: _interfaces__WEBPACK_IMPORTED_MODULE_6__.TeamStateKeys.ENVIRONMENTS,
17862
+ value: false
17863
+ });
17864
+ }
17814
17865
  }
17815
17866
  };
17816
17867
  /*** @deprecated loadUsers is deprecated, use loadUsersV3 instead */
@@ -17986,6 +18037,8 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
17986
18037
  pageOffset
17987
18038
  });
17988
18039
  try {
18040
+ var _store$auth$user7;
18041
+ const requestTenantId = (_store$auth$user7 = store.auth.user) == null ? void 0 : _store$auth$user7.tenantId;
17989
18042
  // First fetch users with v3 API
17990
18043
  const {
17991
18044
  items: users,
@@ -18012,7 +18065,8 @@ const _excluded = ["callback", "appIds", "environmentRoles"],
18012
18065
  shouldLoadRoles,
18013
18066
  shouldLoadApps,
18014
18067
  shouldLoadEmails,
18015
- retryConfig
18068
+ retryConfig,
18069
+ tenantId: requestTenantId
18016
18070
  });
18017
18071
  __setUsersStateAndCallback(enrichedUsers, roles, permissions, totalPages, totalItems, callback);
18018
18072
  } catch (e) {
@@ -21612,7 +21666,7 @@ __webpack_require__.r(__webpack_exports__);
21612
21666
  /* harmony import */ var _subscriptions_interfaces__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./subscriptions/interfaces */ "../../dist/@frontegg/redux-store/subscriptions/interfaces.js");
21613
21667
  /* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./vendor */ "../../dist/@frontegg/redux-store/vendor/index.js");
21614
21668
  /* harmony import */ var _audits__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./audits */ "../../dist/@frontegg/redux-store/audits/index.js");
21615
- /** @license Frontegg v7.133.0-alpha.0
21669
+ /** @license Frontegg v7.134.0
21616
21670
  *
21617
21671
  * This source code is licensed under the MIT license found in the
21618
21672
  * LICENSE file in the root directory of this source tree.
@@ -32455,7 +32509,7 @@ __webpack_require__.r(__webpack_exports__);
32455
32509
  /* harmony import */ var _security_center_interfaces__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./security-center/interfaces */ "../../dist/@frontegg/rest-api/security-center/interfaces.js");
32456
32510
  /* harmony import */ var _applications_interfaces__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./applications/interfaces */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
32457
32511
  /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./constants */ "../../dist/@frontegg/rest-api/constants.js");
32458
- /** @license Frontegg v7.133.0-alpha.0
32512
+ /** @license Frontegg v7.134.0
32459
32513
  *
32460
32514
  * This source code is licensed under the MIT license found in the
32461
32515
  * LICENSE file in the root directory of this source tree.
@@ -35312,7 +35366,7 @@ __webpack_require__.r(__webpack_exports__);
35312
35366
  /* harmony export */ });
35313
35367
  /* harmony import */ var _ThemeOptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ThemeOptions */ "../../dist/@frontegg/types/ThemeOptions/index.js");
35314
35368
  /* harmony import */ var _Metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Metadata */ "../../dist/@frontegg/types/Metadata/index.js");
35315
- /** @license Frontegg v7.133.0-alpha.0
35369
+ /** @license Frontegg v7.134.0
35316
35370
  *
35317
35371
  * This source code is licensed under the MIT license found in the
35318
35372
  * LICENSE file in the root directory of this source tree.