@frontegg/js 7.80.0 → 7.81.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.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.80.0
1
+ /** @license Frontegg v7.81.0-alpha.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.80.0
1
+ /** @license Frontegg v7.81.0-alpha.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.80.0'
8
+ cdnVersion: '7.81.0-alpha.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.80.0",
3
+ "version": "7.81.0-alpha.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.80.0"
9
+ "@frontegg/types": "7.81.0-alpha.0"
10
10
  },
11
11
  "browserslist": {
12
12
  "production": [
@@ -1788,7 +1788,7 @@ __webpack_require__.r(__webpack_exports__);
1788
1788
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1789
1789
  /* harmony export */ });
1790
1790
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1791
- cdnVersion: '7.80.0'
1791
+ cdnVersion: '7.81.0-alpha.0'
1792
1792
  });
1793
1793
 
1794
1794
  /***/ }),
@@ -3471,18 +3471,30 @@ __webpack_require__.r(__webpack_exports__);
3471
3471
  fetching: true
3472
3472
  });
3473
3473
  try {
3474
- const tenantAppIds = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getTenantsApplications(), retryConfig);
3475
- const appIds = (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.getFlattenAppIds)(tenantAppIds);
3474
+ const tenantAppAssignments = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getTenantsApplicationsV2(), retryConfig);
3475
+
3476
+ // Extract appIds from the new assignments structure
3477
+ const appIds = [...new Set(tenantAppAssignments.flatMap(tenant => tenant.assignments.map(assignment => assignment.appId)))];
3476
3478
  const accountApplications = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getApplicationsData({
3477
3479
  appIds
3478
3480
  }), retryConfig);
3479
3481
  const usersOfApplications = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getUsersOfApplications({
3480
3482
  appIds
3481
3483
  }), retryConfig);
3484
+
3485
+ // Create a map of appId to accessType from tenant assignments (once)
3486
+ const appAccessTypeMap = new Map();
3487
+ tenantAppAssignments.forEach(tenant => {
3488
+ tenant.assignments.forEach(assignment => {
3489
+ appAccessTypeMap.set(assignment.appId, assignment.accessType);
3490
+ });
3491
+ });
3482
3492
  const accountApplicationsWithUsers = accountApplications.map(app => {
3483
3493
  var _usersOfApplications$;
3484
3494
  return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, app, {
3485
- userIds: (_usersOfApplications$ = usersOfApplications.find(u => u.appId === app.id)) == null ? void 0 : _usersOfApplications$.userIds
3495
+ userIds: (_usersOfApplications$ = usersOfApplications.find(u => u.appId === app.id)) == null ? void 0 : _usersOfApplications$.userIds,
3496
+ // Add tenant-specific access type as a separate attribute
3497
+ tenantApplicationAccessType: appAccessTypeMap.get(app.id)
3486
3498
  });
3487
3499
  });
3488
3500
  setApplicationsState({
@@ -15669,7 +15681,7 @@ const _excluded = ["callback", "appIds"],
15669
15681
  });
15670
15682
  }
15671
15683
  };
15672
- /*** @deprecated loadUsers is deprecated, use loadUsersV2 instead */
15684
+ /*** @deprecated loadUsers is deprecated, use loadUsersV3 instead */
15673
15685
  const loadUsers = async payload => {
15674
15686
  var _payload$pageSize, _payload$pageOffset, _payload$filter, _payload$sort;
15675
15687
  const {
@@ -15725,6 +15737,8 @@ const _excluded = ["callback", "appIds"],
15725
15737
  value: false
15726
15738
  });
15727
15739
  };
15740
+
15741
+ /*** @deprecated loadUsersV2 is deprecated, use loadUsersV3 instead */
15728
15742
  const loadUsersV2 = async payload => {
15729
15743
  var _payload$pageSize2, _payload$pageOffset2, _payload$filter2, _payload$sort2, _payload$shouldShowSu;
15730
15744
  const {
@@ -15771,11 +15785,7 @@ const _excluded = ["callback", "appIds"],
15771
15785
  _offset: pageOffset,
15772
15786
  _limit: pageSize,
15773
15787
  _includeSubTenants: shouldIncludeSubTenants
15774
- })), retryConfig), (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.retryIfNeeded)(() => api.teams.loadAvailableRoles(), retryConfig),
15775
- // TODO: check rest-api types
15776
- (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.retryIfNeeded)(() => api.teams.loadAvailablePermissions(), retryConfig),
15777
- // TODO: check rest-api types
15778
- __getGroupsForUsers(retryConfig), shouldLoadRoles ? loadRoles({
15788
+ })), retryConfig), (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.retryIfNeeded)(() => api.teams.loadAvailableRoles(), retryConfig), (0,_helpers__WEBPACK_IMPORTED_MODULE_2__.retryIfNeeded)(() => api.teams.loadAvailablePermissions(), retryConfig), __getGroupsForUsers(retryConfig), shouldLoadRoles ? loadRoles({
15779
15789
  retryConfig
15780
15790
  }) : undefined]);
15781
15791
 
@@ -15820,6 +15830,129 @@ const _excluded = ["callback", "appIds"],
15820
15830
  value: false
15821
15831
  });
15822
15832
  };
15833
+ const loadUsersV3 = async payload => {
15834
+ var _payload$pageSize3, _payload$pageOffset3, _payload$sort3, _payload$shouldShowSu2;
15835
+ const {
15836
+ silentLoading,
15837
+ callback,
15838
+ shouldLoadRoles = true,
15839
+ shouldLoadApps,
15840
+ retryConfig
15841
+ } = payload;
15842
+ const teamState = store.auth.teamState;
15843
+ const pageSize = (_payload$pageSize3 = payload.pageSize) != null ? _payload$pageSize3 : teamState.pageSize;
15844
+ const pageOffset = (_payload$pageOffset3 = payload.pageOffset) != null ? _payload$pageOffset3 : teamState.pageOffset;
15845
+ const sort = (_payload$sort3 = payload.sort) != null ? _payload$sort3 : teamState.sortV2;
15846
+ const shouldIncludeSubTenants = (_payload$shouldShowSu2 = payload == null ? void 0 : payload.shouldShowSubTenantUsersIfReseller) != null ? _payload$shouldShowSu2 : teamState == null ? void 0 : teamState.shouldShowSubTenantUsersIfReseller;
15847
+ actions.setTeamLoader({
15848
+ key: _interfaces__WEBPACK_IMPORTED_MODULE_4__.TeamStateKeys.USERS,
15849
+ value: !silentLoading
15850
+ });
15851
+ actions.setTeamState({
15852
+ pageSize,
15853
+ pageOffset
15854
+ });
15855
+ try {
15856
+ // First fetch users with v3 API
15857
+ const {
15858
+ items: users,
15859
+ _metadata: {
15860
+ totalPages,
15861
+ totalItems
15862
+ }
15863
+ } = await api.users.getUsersV3((0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, sort && {
15864
+ _sortBy: sort
15865
+ }, payload.order && {
15866
+ _order: payload.order
15867
+ }, {
15868
+ _offset: pageOffset,
15869
+ _limit: pageSize,
15870
+ _includeSubTenants: shouldIncludeSubTenants
15871
+ }, getIdentifierFilterForUsersV3(payload)));
15872
+
15873
+ // Get user IDs for fetching roles and groups
15874
+ const userIds = users.map(user => user.id);
15875
+
15876
+ // Fetch roles, permissions, user roles, user groups, and all groups in parallel
15877
+ const [{
15878
+ items: roles
15879
+ }, permissions, userRoles, userGroups, groups] = await Promise.all([api.teams.loadAvailableRoles(), api.teams.loadAvailablePermissions(), userIds.length > 0 ? api.users.getUsersRoles({
15880
+ ids: userIds
15881
+ }) : [], userIds.length > 0 ? api.users.getUsersGroups({
15882
+ ids: userIds
15883
+ }) : [], __getGroupsForUsers(retryConfig), shouldLoadRoles ? loadRoles({
15884
+ retryConfig
15885
+ }) : undefined]);
15886
+
15887
+ // Map user roles and groups to users
15888
+ const usersWithRolesAndGroups = users.map(user => {
15889
+ // Find user's role IDs
15890
+ const userRoleData = userRoles.find(ur => ur.userId === user.id);
15891
+ const userRoleIds = (userRoleData == null ? void 0 : userRoleData.roleIds) || [];
15892
+ const userRolesFull = roles.filter(role => userRoleIds.includes(role.id));
15893
+
15894
+ // Find user's group IDs
15895
+ const userGroupData = userGroups.find(ug => ug.userId === user.id);
15896
+ const userGroupIds = (userGroupData == null ? void 0 : userGroupData.groupIds) || [];
15897
+ const userGroupsFull = groups.filter(g => userGroupIds.includes(g.id));
15898
+
15899
+ //@ts-ignore
15900
+ return (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, user, {
15901
+ roles: userRolesFull,
15902
+ roleIds: userRoleIds,
15903
+ groups: userGroupsFull,
15904
+ permissions: userRolesFull.flatMap(role => role.permissions)
15905
+ });
15906
+ });
15907
+ const mappedUsers = await sharedActions.mapUsersWithApplicationData({
15908
+ shouldLoadApps,
15909
+ users: usersWithRolesAndGroups,
15910
+ retryConfig
15911
+ });
15912
+ sharedActions.setTeamState({
15913
+ users: mappedUsers,
15914
+ totalPages,
15915
+ totalItems,
15916
+ roles,
15917
+ permissions
15918
+ });
15919
+ callback == null ? void 0 : callback(usersWithRolesAndGroups);
15920
+ } catch (e) {
15921
+ console.error('Failed to load users v3', e);
15922
+ actions.setTeamError({
15923
+ key: _interfaces__WEBPACK_IMPORTED_MODULE_4__.TeamStateKeys.USERS,
15924
+ value: (0,_helpers__WEBPACK_IMPORTED_MODULE_5__.errorHandler)(e)
15925
+ });
15926
+ actions.setTeamState({
15927
+ totalPages: 0,
15928
+ users: []
15929
+ });
15930
+ callback == null ? void 0 : callback(null, e);
15931
+ }
15932
+ actions.setTeamLoader({
15933
+ key: _interfaces__WEBPACK_IMPORTED_MODULE_4__.TeamStateKeys.USERS,
15934
+ value: false
15935
+ });
15936
+ };
15937
+ const getIdentifierFilterForUsersV3 = payload => {
15938
+ const {
15939
+ identifier,
15940
+ identifierType,
15941
+ email
15942
+ } = payload;
15943
+ if (identifierType === 'username' && identifier != null && identifier.length) {
15944
+ return {
15945
+ _identifier: identifier,
15946
+ _identifierType: 'username'
15947
+ };
15948
+ }
15949
+ if (email != null && email.length) {
15950
+ return {
15951
+ _email: email
15952
+ };
15953
+ }
15954
+ return {};
15955
+ };
15823
15956
  const addUser = async payload => {
15824
15957
  const {
15825
15958
  callback,
@@ -15841,7 +15974,9 @@ const _excluded = ["callback", "appIds"],
15841
15974
  userWithoutRoleIds = (0,_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(res, _excluded2);
15842
15975
  const roleIds = (_roles$map = roles == null ? void 0 : roles.map(role => role.id)) != null ? _roles$map : [];
15843
15976
  const newUser = (0,_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_1__["default"])({}, userWithoutRoleIds, {
15844
- roleIds
15977
+ roleIds,
15978
+ roles: roles || [],
15979
+ groups: []
15845
15980
  });
15846
15981
  const apps = await sharedActions.assignNewUserToApps({
15847
15982
  appIds,
@@ -16177,6 +16312,7 @@ const _excluded = ["callback", "appIds"],
16177
16312
  loadRoles,
16178
16313
  loadUsers,
16179
16314
  loadUsersV2,
16315
+ loadUsersV3,
16180
16316
  addUser,
16181
16317
  addUsersBulk,
16182
16318
  updateUser,
@@ -19051,7 +19187,7 @@ __webpack_require__.r(__webpack_exports__);
19051
19187
  /* harmony import */ var _subscriptions_interfaces__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./subscriptions/interfaces */ "../../dist/@frontegg/redux-store/subscriptions/interfaces.js");
19052
19188
  /* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./vendor */ "../../dist/@frontegg/redux-store/vendor/index.js");
19053
19189
  /* harmony import */ var _audits__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./audits */ "../../dist/@frontegg/redux-store/audits/index.js");
19054
- /** @license Frontegg v7.80.0
19190
+ /** @license Frontegg v7.81.0-alpha.0
19055
19191
  *
19056
19192
  * This source code is licensed under the MIT license found in the
19057
19193
  * LICENSE file in the root directory of this source tree.
@@ -21869,7 +22005,7 @@ const _excluded = ["callback"],
21869
22005
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((store, api, actions) => {
21870
22006
  const originalActions = (0,_auth_TeamState__WEBPACK_IMPORTED_MODULE_2__["default"])(store, api, actions);
21871
22007
  const mockedActions = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.mockActionsExpect)(originalActions, ['setTeamState', 'resetTeamState', 'setTeamLoader', 'setTeamError', 'openAddUserDialog', 'closeAddUserDialog', 'openDeleteUserDialog', 'closeDeleteUserDialog']);
21872
- mockedActions.loadUsersV2 = async payload => {
22008
+ mockedActions.loadUsersV3 = async payload => {
21873
22009
  var _payload$pageSize, _payload$pageOffset, _payload$filter, _payload$sort;
21874
22010
  const {
21875
22011
  silentLoading,
@@ -27051,6 +27187,9 @@ class ApplicationsApi extends _BaseApiClient__WEBPACK_IMPORTED_MODULE_0__.BaseAp
27051
27187
  this.getTenantsApplications = async () => {
27052
27188
  return this.get(_constants__WEBPACK_IMPORTED_MODULE_1__.urls.applications.tenant.v1);
27053
27189
  };
27190
+ this.getTenantsApplicationsV2 = async () => {
27191
+ return this.get(_constants__WEBPACK_IMPORTED_MODULE_1__.urls.applications.tenant.v2);
27192
+ };
27054
27193
  this.getApplicationsData = async ({
27055
27194
  appIds,
27056
27195
  includeFreeAccess = true
@@ -28834,7 +28973,8 @@ const urls = {
28834
28973
  applications: {
28835
28974
  v1: '/applications/resources/applications/v1',
28836
28975
  tenant: {
28837
- v1: '/applications/resources/applications/tenant-assignments/v1'
28976
+ v1: '/applications/resources/applications/tenant-assignments/v1',
28977
+ v2: '/applications/resources/applications/tenant-assignments/v2'
28838
28978
  }
28839
28979
  },
28840
28980
  velo: {
@@ -29343,7 +29483,7 @@ __webpack_require__.r(__webpack_exports__);
29343
29483
  /* harmony import */ var _security_center_interfaces__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./security-center/interfaces */ "../../dist/@frontegg/rest-api/security-center/interfaces.js");
29344
29484
  /* harmony import */ var _applications_interfaces__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./applications/interfaces */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
29345
29485
  /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./constants */ "../../dist/@frontegg/rest-api/constants.js");
29346
- /** @license Frontegg v7.80.0
29486
+ /** @license Frontegg v7.81.0-alpha.0
29347
29487
  *
29348
29488
  * This source code is licensed under the MIT license found in the
29349
29489
  * LICENSE file in the root directory of this source tree.
@@ -32081,7 +32221,7 @@ __webpack_require__.r(__webpack_exports__);
32081
32221
  /* harmony export */ });
32082
32222
  /* harmony import */ var _ThemeOptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ThemeOptions */ "../../dist/@frontegg/types/ThemeOptions/index.js");
32083
32223
  /* harmony import */ var _Metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Metadata */ "../../dist/@frontegg/types/Metadata/index.js");
32084
- /** @license Frontegg v7.80.0
32224
+ /** @license Frontegg v7.81.0-alpha.0
32085
32225
  *
32086
32226
  * This source code is licensed under the MIT license found in the
32087
32227
  * LICENSE file in the root directory of this source tree.