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

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.1
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.1
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.1'
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.1",
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.1"
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.1'
1792
1792
  });
1793
1793
 
1794
1794
  /***/ }),
@@ -3418,11 +3418,11 @@ __webpack_require__.r(__webpack_exports__);
3418
3418
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
3419
3419
  /* harmony export */ });
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
- /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @frontegg/rest-api */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
3421
+ /* harmony import */ var _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__ = __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
3423
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __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_5__ = __webpack_require__(/*! ./helpers */ "../../dist/@frontegg/redux-store/auth/ApplicationsState/helpers.js");
3426
3426
 
3427
3427
 
3428
3428
 
@@ -3515,17 +3515,40 @@ __webpack_require__.r(__webpack_exports__);
3515
3515
  retryConfig
3516
3516
  }) => {
3517
3517
  try {
3518
- const usersAppIds = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getUsersApplicationsId({
3518
+ // Step 1: Fetch all assignment data in parallel
3519
+ const [usersAppIds, tenantAppAssignments] = await Promise.all([(0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getUsersApplicationsId({
3519
3520
  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);
3521
+ }), retryConfig), (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getTenantsApplicationsV2(), retryConfig)]);
3522
+
3523
+ // Step 2: Identify tenant-level free apps
3524
+ const tenantFreeAppIds = tenantAppAssignments.flatMap(tenant => tenant.assignments).filter(assignment => assignment.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__.ApplicationAccessType.FREE_ACCESS).map(assignment => assignment.appId);
3525
+
3526
+ // Step 3: Get all app IDs that need to be fetched (user assignments + tenant-free apps)
3527
+ const userAssignedAppIds = (0,_helpers__WEBPACK_IMPORTED_MODULE_5__.getFlattenAppIds)(usersAppIds);
3528
+ const appIdsToFetch = [...new Set([...userAssignedAppIds, ...tenantFreeAppIds])];
3529
+
3530
+ // Step 4: Fetch details for all apps
3531
+ let fetchedAppsMap = new Map();
3532
+ if (appIdsToFetch.length > 0) {
3533
+ const fetchedApps = await (0,_helpers__WEBPACK_IMPORTED_MODULE_1__.retryIfNeeded)(() => api.applications.getApplicationsData({
3534
+ appIds: appIdsToFetch
3535
+ }), retryConfig);
3536
+ fetchedAppsMap = new Map(fetchedApps.map(app => [app.id, app]));
3537
+ }
3538
+
3539
+ // Step 5: For each user, assemble their final list of applications.
3525
3540
  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 : [])];
3541
+ var _usersAppIds$find$app, _usersAppIds$find;
3542
+ const finalApps = [];
3543
+ 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 : []);
3544
+
3545
+ // Add apps that are assigned to the user OR are app-level free OR are tenant-level free
3546
+ fetchedAppsMap.forEach((app, appId) => {
3547
+ if (userSpecificAppIds.has(appId) || app.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__.ApplicationAccessType.FREE_ACCESS || tenantFreeAppIds.includes(appId)) {
3548
+ finalApps.push(app);
3549
+ }
3550
+ });
3551
+ acc[userId] = finalApps;
3529
3552
  return acc;
3530
3553
  }, {});
3531
3554
  } catch (e) {
@@ -3611,7 +3634,7 @@ __webpack_require__.r(__webpack_exports__);
3611
3634
  return;
3612
3635
  }
3613
3636
  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 : [];
3637
+ const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__.ApplicationAccessType.FREE_ACCESS || app.tenantApplicationAccessType === _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_4__.ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
3615
3638
  if (appIds != null && appIds.length) {
3616
3639
  var _store$auth$user$tena3, _store$auth7, _store$auth7$user;
3617
3640
  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 : '';
@@ -19187,7 +19210,7 @@ __webpack_require__.r(__webpack_exports__);
19187
19210
  /* harmony import */ var _subscriptions_interfaces__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./subscriptions/interfaces */ "../../dist/@frontegg/redux-store/subscriptions/interfaces.js");
19188
19211
  /* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./vendor */ "../../dist/@frontegg/redux-store/vendor/index.js");
19189
19212
  /* 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
19213
+ /** @license Frontegg v7.82.0-alpha.1
19191
19214
  *
19192
19215
  * This source code is licensed under the MIT license found in the
19193
19216
  * LICENSE file in the root directory of this source tree.
@@ -29483,7 +29506,7 @@ __webpack_require__.r(__webpack_exports__);
29483
29506
  /* harmony import */ var _security_center_interfaces__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./security-center/interfaces */ "../../dist/@frontegg/rest-api/security-center/interfaces.js");
29484
29507
  /* harmony import */ var _applications_interfaces__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./applications/interfaces */ "../../dist/@frontegg/rest-api/applications/interfaces.js");
29485
29508
  /* 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
29509
+ /** @license Frontegg v7.82.0-alpha.1
29487
29510
  *
29488
29511
  * This source code is licensed under the MIT license found in the
29489
29512
  * LICENSE file in the root directory of this source tree.
@@ -32221,7 +32244,7 @@ __webpack_require__.r(__webpack_exports__);
32221
32244
  /* harmony export */ });
32222
32245
  /* harmony import */ var _ThemeOptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ThemeOptions */ "../../dist/@frontegg/types/ThemeOptions/index.js");
32223
32246
  /* 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
32247
+ /** @license Frontegg v7.82.0-alpha.1
32225
32248
  *
32226
32249
  * This source code is licensed under the MIT license found in the
32227
32250
  * LICENSE file in the root directory of this source tree.