@frontegg/js 7.82.0-alpha.0 → 7.82.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.82.0-alpha.0
1
+ /** @license Frontegg v7.82.0-alpha.2
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.82.0-alpha.0
1
+ /** @license Frontegg v7.82.0-alpha.2
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.82.0-alpha.0'
8
+ cdnVersion: '7.82.0-alpha.2'
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.82.0-alpha.0",
3
+ "version": "7.82.0-alpha.2",
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.82.0-alpha.0"
9
+ "@frontegg/types": "7.82.0-alpha.2"
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.82.0-alpha.0'
1791
+ cdnVersion: '7.82.0-alpha.2'
1792
1792
  });
1793
1793
 
1794
1794
  /***/ }),
@@ -3420,9 +3420,9 @@ __webpack_require__.r(__webpack_exports__);
3420
3420
  /* 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");
3421
3421
  /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
3422
3422
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/helpers/common.js");
3423
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/helpers/handlers.js");
3423
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../helpers */ "../../dist/@frontegg/redux-store/helpers/handlers.js");
3424
3424
  /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./state */ "../../dist/@frontegg/redux-store/auth/ApplicationsState/state.js");
3425
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./helpers */ "../../dist/@frontegg/redux-store/auth/ApplicationsState/helpers.js");
3425
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helpers */ "../../dist/@frontegg/redux-store/auth/ApplicationsState/helpers.js");
3426
3426
 
3427
3427
 
3428
3428
 
@@ -3436,6 +3436,16 @@ __webpack_require__.r(__webpack_exports__);
3436
3436
  const resetApplicationsState = () => {
3437
3437
  (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.deepResetState)(store, ['auth', 'applicationsState'], _state__WEBPACK_IMPORTED_MODULE_2__.initialState);
3438
3438
  };
3439
+ const updateCombinedUserApplications = () => {
3440
+ const {
3441
+ userApplications,
3442
+ accountApplications
3443
+ } = store.auth.applicationsState;
3444
+ const combinedUserApplications = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.combineUserApplicationsWithTenantFreeAccess)(userApplications, accountApplications);
3445
+ setApplicationsState({
3446
+ combinedUserApplications
3447
+ });
3448
+ };
3439
3449
  const loadUserApplications = async payload => {
3440
3450
  setApplicationsState({
3441
3451
  loading: true,
@@ -3456,11 +3466,12 @@ __webpack_require__.r(__webpack_exports__);
3456
3466
  fetching: false,
3457
3467
  loading: false
3458
3468
  });
3469
+ updateCombinedUserApplications();
3459
3470
  } catch (e) {
3460
3471
  setApplicationsState({
3461
3472
  loading: false,
3462
3473
  fetching: false,
3463
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.errorHandler)(e)
3474
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.errorHandler)(e)
3464
3475
  });
3465
3476
  }
3466
3477
  };
@@ -3502,11 +3513,12 @@ __webpack_require__.r(__webpack_exports__);
3502
3513
  fetching: false,
3503
3514
  loading: false
3504
3515
  });
3516
+ updateCombinedUserApplications();
3505
3517
  } catch (e) {
3506
3518
  setApplicationsState({
3507
3519
  loading: false,
3508
3520
  fetching: false,
3509
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.errorHandler)(e)
3521
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.errorHandler)(e)
3510
3522
  });
3511
3523
  }
3512
3524
  };
@@ -3515,22 +3527,45 @@ __webpack_require__.r(__webpack_exports__);
3515
3527
  retryConfig
3516
3528
  }) => {
3517
3529
  try {
3518
- const usersAppIds = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getUsersApplicationsId({
3530
+ // Step 1: Fetch all assignment data in parallel
3531
+ const [usersAppIds, tenantAppAssignments] = await Promise.all([(0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getUsersApplicationsId({
3519
3532
  userIds
3520
- }), retryConfig);
3521
- const appIds = (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.getFlattenAppIds)(usersAppIds);
3522
- const accountApplications = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getApplicationsData({
3523
- appIds
3524
- }), retryConfig);
3533
+ }), retryConfig), (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getTenantsApplicationsV2(), retryConfig)]);
3534
+
3535
+ // Step 2: Identify tenant-level free apps
3536
+ const tenantFreeAppIds = tenantAppAssignments.flatMap(tenant => tenant.assignments).filter(assignment => assignment.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ApplicationAccessType.FREE_ACCESS).map(assignment => assignment.appId);
3537
+
3538
+ // Step 3: Get all app IDs that need to be fetched (user assignments + tenant-free apps)
3539
+ const userAssignedAppIds = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getFlattenAppIds)(usersAppIds);
3540
+ const appIdsToFetch = [...new Set([...userAssignedAppIds, ...tenantFreeAppIds])];
3541
+
3542
+ // Step 4: Fetch details for all apps
3543
+ let fetchedAppsMap = new Map();
3544
+ if (appIdsToFetch.length > 0) {
3545
+ const fetchedApps = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getApplicationsData({
3546
+ appIds: appIdsToFetch
3547
+ }), retryConfig);
3548
+ fetchedAppsMap = new Map(fetchedApps.map(app => [app.id, app]));
3549
+ }
3550
+
3551
+ // Step 5: For each user, assemble their final list of applications.
3525
3552
  return userIds.reduce((acc, userId) => {
3526
- var _usersAppIds$find, _userAppIds$map$filte, _userAppIds$map;
3527
- const userAppIds = (_usersAppIds$find = usersAppIds.find(app => app.userId == userId)) == null ? void 0 : _usersAppIds$find.appIds;
3528
- acc[userId] = [...accountApplications.filter(app => app.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ApplicationAccessType.FREE_ACCESS), ...((_userAppIds$map$filte = userAppIds == null ? void 0 : (_userAppIds$map = userAppIds.map(appId => accountApplications.find(app => appId === app.id))) == null ? void 0 : _userAppIds$map.filter(app => !!app)) != null ? _userAppIds$map$filte : [])];
3553
+ var _usersAppIds$find$app, _usersAppIds$find;
3554
+ const finalApps = [];
3555
+ const userSpecificAppIds = new Set((_usersAppIds$find$app = (_usersAppIds$find = usersAppIds.find(app => app.userId === userId)) == null ? void 0 : _usersAppIds$find.appIds) != null ? _usersAppIds$find$app : []);
3556
+
3557
+ // Add apps that are assigned to the user OR are app-level free OR are tenant-level free
3558
+ fetchedAppsMap.forEach((app, appId) => {
3559
+ if (userSpecificAppIds.has(appId) || app.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ApplicationAccessType.FREE_ACCESS || tenantFreeAppIds.includes(appId)) {
3560
+ finalApps.push(app);
3561
+ }
3562
+ });
3563
+ acc[userId] = finalApps;
3529
3564
  return acc;
3530
3565
  }, {});
3531
3566
  } catch (e) {
3532
3567
  setApplicationsState({
3533
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.errorHandler)(e)
3568
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.errorHandler)(e)
3534
3569
  });
3535
3570
  }
3536
3571
  };
@@ -3565,7 +3600,7 @@ __webpack_require__.r(__webpack_exports__);
3565
3600
  callback == null ? void 0 : callback(true);
3566
3601
  } catch (e) {
3567
3602
  setApplicationsState({
3568
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.errorHandler)(e, ASSIGNMENT_DEFAULT_ERROR_MESSAGE)
3603
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.errorHandler)(e, ASSIGNMENT_DEFAULT_ERROR_MESSAGE)
3569
3604
  });
3570
3605
  callback == null ? void 0 : callback(false);
3571
3606
  }
@@ -3596,7 +3631,7 @@ __webpack_require__.r(__webpack_exports__);
3596
3631
  callback == null ? void 0 : callback(true);
3597
3632
  } catch (e) {
3598
3633
  setApplicationsState({
3599
- error: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.errorHandler)(e, ASSIGNMENT_DEFAULT_ERROR_MESSAGE)
3634
+ error: (0,_helpers__WEBPACK_IMPORTED_MODULE_4__.errorHandler)(e, ASSIGNMENT_DEFAULT_ERROR_MESSAGE)
3600
3635
  });
3601
3636
  callback == null ? void 0 : callback(false);
3602
3637
  }
@@ -3611,7 +3646,7 @@ __webpack_require__.r(__webpack_exports__);
3611
3646
  return;
3612
3647
  }
3613
3648
  const apps = (_store$auth6 = store.auth) == null ? void 0 : (_store$auth6$applicat = _store$auth6.applicationsState) == null ? void 0 : _store$auth6$applicat.accountApplications;
3614
- const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
3649
+ const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ApplicationAccessType.FREE_ACCESS || app.tenantApplicationAccessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__.ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
3615
3650
  if (appIds != null && appIds.length) {
3616
3651
  var _store$auth$user$tena3, _store$auth7, _store$auth7$user;
3617
3652
  const tenantId = (_store$auth$user$tena3 = (_store$auth7 = store.auth) == null ? void 0 : (_store$auth7$user = _store$auth7.user) == null ? void 0 : _store$auth7$user.tenantId) != null ? _store$auth$user$tena3 : '';
@@ -3673,8 +3708,11 @@ __webpack_require__.r(__webpack_exports__);
3673
3708
  "use strict";
3674
3709
  __webpack_require__.r(__webpack_exports__);
3675
3710
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3711
+ /* harmony export */ combineUserApplicationsWithTenantFreeAccess: () => (/* binding */ combineUserApplicationsWithTenantFreeAccess),
3676
3712
  /* harmony export */ getFlattenAppIds: () => (/* binding */ getFlattenAppIds)
3677
3713
  /* harmony export */ });
3714
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
3715
+
3678
3716
  const getFlattenAppIds = listWithAppIds => {
3679
3717
  var _listWithAppIds$map$r;
3680
3718
  return (_listWithAppIds$map$r = listWithAppIds.map(({
@@ -3688,6 +3726,18 @@ const getFlattenAppIds = listWithAppIds => {
3688
3726
  return allAppIds;
3689
3727
  }, [])) != null ? _listWithAppIds$map$r : [];
3690
3728
  };
3729
+ const combineUserApplicationsWithTenantFreeAccess = (userApplications, accountApplications) => {
3730
+ if (!userApplications && !accountApplications) return [];
3731
+ const userAppIds = new Set((userApplications == null ? void 0 : userApplications.map(app => app.id)) || []);
3732
+ const tenantFreeApps = (accountApplications == null ? void 0 : accountApplications.filter(app => app.tenantApplicationAccessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_0__.ApplicationAccessType.FREE_ACCESS)) || [];
3733
+
3734
+ // Add tenant-free apps that aren't already in user apps
3735
+ const additionalApps = tenantFreeApps.filter(app => !userAppIds.has(app.id));
3736
+
3737
+ // Create a combined list
3738
+ const combinedApps = [...(userApplications || []), ...additionalApps];
3739
+ return combinedApps;
3740
+ };
3691
3741
 
3692
3742
  /***/ }),
3693
3743
 
@@ -3710,7 +3760,8 @@ const initialState = {
3710
3760
  fetching: true,
3711
3761
  error: null,
3712
3762
  userApplications: [],
3713
- accountApplications: []
3763
+ accountApplications: [],
3764
+ combinedUserApplications: []
3714
3765
  };
3715
3766
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (overrideState => (0,_toolkit_proxy__WEBPACK_IMPORTED_MODULE_0__.createProxy)(initialState, overrideState));
3716
3767
 
@@ -19187,7 +19238,7 @@ __webpack_require__.r(__webpack_exports__);
19187
19238
  /* harmony import */ var _subscriptions_interfaces__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./subscriptions/interfaces */ "../../dist/@frontegg/redux-store/subscriptions/interfaces.js");
19188
19239
  /* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./vendor */ "../../dist/@frontegg/redux-store/vendor/index.js");
19189
19240
  /* harmony import */ var _audits__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./audits */ "../../dist/@frontegg/redux-store/audits/index.js");
19190
- /** @license Frontegg v7.82.0-alpha.0
19241
+ /** @license Frontegg v7.82.0-alpha.2
19191
19242
  *
19192
19243
  * This source code is licensed under the MIT license found in the
19193
19244
  * LICENSE file in the root directory of this source tree.
@@ -29483,7 +29534,7 @@ __webpack_require__.r(__webpack_exports__);
29483
29534
  /* harmony import */ var _security_center_interfaces__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./security-center/interfaces */ "../../dist/@frontegg/rest-api/security-center/interfaces.js");
29484
29535
  /* harmony import */ var _applications_interfaces__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./applications/interfaces */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
29485
29536
  /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./constants */ "../../dist/@frontegg/rest-api/constants.js");
29486
- /** @license Frontegg v7.82.0-alpha.0
29537
+ /** @license Frontegg v7.82.0-alpha.2
29487
29538
  *
29488
29539
  * This source code is licensed under the MIT license found in the
29489
29540
  * LICENSE file in the root directory of this source tree.
@@ -32221,7 +32272,7 @@ __webpack_require__.r(__webpack_exports__);
32221
32272
  /* harmony export */ });
32222
32273
  /* harmony import */ var _ThemeOptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ThemeOptions */ "../../dist/@frontegg/types/ThemeOptions/index.js");
32223
32274
  /* harmony import */ var _Metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Metadata */ "../../dist/@frontegg/types/Metadata/index.js");
32224
- /** @license Frontegg v7.82.0-alpha.0
32275
+ /** @license Frontegg v7.82.0-alpha.2
32225
32276
  *
32226
32277
  * This source code is licensed under the MIT license found in the
32227
32278
  * LICENSE file in the root directory of this source tree.