@frontegg/rest-api 3.1.31 → 3.1.33

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.
@@ -3,3 +3,7 @@ export declare const FRONTEGG_SEPARATE_TABS_BY_TENANT = "FRONTEGG_SEPARATE_TABS_
3
3
  * use current user tenant v1 feature flag
4
4
  */
5
5
  export declare const USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = "admin_portal_use_current_user_tenants_v1_endpoint";
6
+ /**
7
+ * use entitlements v2 feature flag
8
+ */
9
+ export declare const USE_ENTITLEMENTS_V2_ENDPOINT_FF = "admin_portal_use_entitlements_v2_endpoint";
package/auth/constants.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export const FRONTEGG_SEPARATE_TABS_BY_TENANT = 'FRONTEGG_SEPARATE_TABS_BY_TENANT';
2
- export const USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = 'admin_portal_use_current_user_tenants_v1_endpoint';
2
+ export const USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = 'admin_portal_use_current_user_tenants_v1_endpoint';
3
+ export const USE_ENTITLEMENTS_V2_ENDPOINT_FF = 'admin_portal_use_entitlements_v2_endpoint';
package/auth/index.js CHANGED
@@ -12,10 +12,11 @@ import { ContextHolder } from "../ContextHolder";
12
12
  import { Delete, Get, Patch, Post, Put } from "../fetch";
13
13
  import { jwtDecode } from "../jwt";
14
14
  import { LOAD_AUTHORIZATION_FF } from './interfaces';
15
- import { loadEntitlements } from '../entitlements';
15
+ import { loadEntitlements, loadEntitlementsV2 } from '../entitlements';
16
16
  import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
17
17
  import { FeatureFlags } from "../feature-flags";
18
18
  import { executeConditionalPromise, getCurrentUserTenantsFunction, getTabTenantFromSessionStorage, setTabTenantInSessionStorage } from "./utils";
19
+ import { USE_ENTITLEMENTS_V2_ENDPOINT_FF } from "./constants";
19
20
  export async function generateLoginResponse(loginResponse) {
20
21
  if (!loginResponse.accessToken) {
21
22
  return loginResponse;
@@ -724,11 +725,12 @@ export async function getMeV2() {
724
725
  return Get(`${urls.identity.users.v2}/me`);
725
726
  }
726
727
  export async function getMeAndEntitlements() {
728
+ const [useEntitlementsV2] = FeatureFlags.getFeatureFlags([USE_ENTITLEMENTS_V2_ENDPOINT_FF], ContextHolder.getAppName() || '');
727
729
  const actions = [{
728
730
  action: getMeV2,
729
731
  shouldLoad: true
730
732
  }, {
731
- action: loadEntitlements,
733
+ action: useEntitlementsV2 ? loadEntitlementsV2 : loadEntitlements,
732
734
  shouldLoad: shouldLoadEntitlements()
733
735
  }, {
734
736
  action: getUserAuthorization,
@@ -1,3 +1,4 @@
1
+ import { UserEntitlementsContext as UserEntitlementsResponseV2 } from "@frontegg/entitlements-javascript-commons";
1
2
  import { ITenantsResponse, IUserProfile, UserEntitlementsResponse } from "..";
2
3
  import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from "./enums";
3
4
  import { ISamlRolesGroup } from "../teams/interfaces";
@@ -45,7 +46,7 @@ export declare type ILoginResponse = IUserProfile & {
45
46
  mfaStrategies?: MFAStrategyEnum[];
46
47
  mfaDevices?: UserMFADevicesResponse;
47
48
  isBreachedPassword?: boolean;
48
- entitlements?: UserEntitlementsResponse;
49
+ entitlements?: UserEntitlementsResponse | UserEntitlementsResponseV2;
49
50
  };
50
51
  export declare type ILoginResponseV2 = {
51
52
  user: ILoginResponse;
package/auth/utils.js CHANGED
@@ -19,7 +19,7 @@ export function setTabTenantInSessionStorage(tenantId) {
19
19
  sessionStorage.setItem(FRONTEGG_SEPARATE_TABS_BY_TENANT, tenantId);
20
20
  }
21
21
  export function getTabTenantFromSessionStorage() {
22
- if (ContextHolder.isSessionPerTenantEnabled()) {
22
+ if (!ContextHolder.isSessionPerTenantEnabled()) {
23
23
  return null;
24
24
  }
25
25
 
package/constants.d.ts CHANGED
@@ -249,6 +249,7 @@ export declare const urls: {
249
249
  };
250
250
  entitlements: {
251
251
  v1: string;
252
+ v2: string;
252
253
  };
253
254
  securityCenter: {
254
255
  recommendations: {
package/constants.js CHANGED
@@ -248,7 +248,8 @@ export const urls = {
248
248
  temp: '/directory/resources/scim/temp'
249
249
  },
250
250
  entitlements: {
251
- v1: '/entitlements/api/v1/user-entitlements'
251
+ v1: '/entitlements/api/v1/user-entitlements',
252
+ v2: '/entitlements/api/v2/user-entitlements'
252
253
  },
253
254
  securityCenter: {
254
255
  recommendations: {
@@ -1,4 +1,5 @@
1
1
  import { UserEntitlementsResponse } from './interfaces';
2
+ import { UserEntitlementsContext as UserEntitlementsResponseV2 } from "@frontegg/entitlements-javascript-commons";
2
3
  /**
3
4
  * Load user entitlements data.
4
5
  * Including all user permissions, features and bundles data.
@@ -7,3 +8,11 @@ import { UserEntitlementsResponse } from './interfaces';
7
8
  * ``authorized user``
8
9
  */
9
10
  export declare function loadEntitlements(): Promise<UserEntitlementsResponse>;
11
+ /**
12
+ * Load user entitlements data v2.
13
+ * Including all user permissions and features data.
14
+ * Now the final isEntitled response is not part of it, but includes the data needed to calculate it.
15
+ *
16
+ * ``authorized user``
17
+ */
18
+ export declare function loadEntitlementsV2(): Promise<UserEntitlementsResponseV2>;
@@ -2,4 +2,7 @@ import { urls } from '../constants';
2
2
  import { Get } from '../fetch';
3
3
  export async function loadEntitlements() {
4
4
  return Get(urls.entitlements.v1);
5
+ }
6
+ export async function loadEntitlementsV2() {
7
+ return Get(urls.entitlements.v2);
5
8
  }
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.1.31
1
+ /** @license Frontegg v3.1.33
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.
@@ -3,8 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = exports.FRONTEGG_SEPARATE_TABS_BY_TENANT = void 0;
6
+ exports.USE_ENTITLEMENTS_V2_ENDPOINT_FF = exports.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = exports.FRONTEGG_SEPARATE_TABS_BY_TENANT = void 0;
7
7
  const FRONTEGG_SEPARATE_TABS_BY_TENANT = 'FRONTEGG_SEPARATE_TABS_BY_TENANT';
8
8
  exports.FRONTEGG_SEPARATE_TABS_BY_TENANT = FRONTEGG_SEPARATE_TABS_BY_TENANT;
9
9
  const USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = 'admin_portal_use_current_user_tenants_v1_endpoint';
10
- exports.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF;
10
+ exports.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF;
11
+ const USE_ENTITLEMENTS_V2_ENDPOINT_FF = 'admin_portal_use_entitlements_v2_endpoint';
12
+ exports.USE_ENTITLEMENTS_V2_ENDPOINT_FF = USE_ENTITLEMENTS_V2_ENDPOINT_FF;
@@ -377,6 +377,8 @@ var _interfaces2 = require("../entitlements/interfaces");
377
377
 
378
378
  var _featureFlags = require("../feature-flags");
379
379
 
380
+ var _constants2 = require("./constants");
381
+
380
382
  const _excluded = ["type"],
381
383
  _excluded2 = ["type"],
382
384
  _excluded3 = ["type"];
@@ -1239,11 +1241,13 @@ async function getMeV2() {
1239
1241
  }
1240
1242
 
1241
1243
  async function getMeAndEntitlements() {
1244
+ const [useEntitlementsV2] = _featureFlags.FeatureFlags.getFeatureFlags([_constants2.USE_ENTITLEMENTS_V2_ENDPOINT_FF], _ContextHolder.ContextHolder.getAppName() || '');
1245
+
1242
1246
  const actions = [{
1243
1247
  action: getMeV2,
1244
1248
  shouldLoad: true
1245
1249
  }, {
1246
- action: _entitlements.loadEntitlements,
1250
+ action: useEntitlementsV2 ? _entitlements.loadEntitlementsV2 : _entitlements.loadEntitlements,
1247
1251
  shouldLoad: shouldLoadEntitlements()
1248
1252
  }, {
1249
1253
  action: getUserAuthorization,
@@ -35,7 +35,7 @@ function setTabTenantInSessionStorage(tenantId) {
35
35
  }
36
36
 
37
37
  function getTabTenantFromSessionStorage() {
38
- if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
38
+ if (!_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
39
39
  return null;
40
40
  }
41
41
 
package/node/constants.js CHANGED
@@ -254,7 +254,8 @@ const urls = {
254
254
  temp: '/directory/resources/scim/temp'
255
255
  },
256
256
  entitlements: {
257
- v1: '/entitlements/api/v1/user-entitlements'
257
+ v1: '/entitlements/api/v1/user-entitlements',
258
+ v2: '/entitlements/api/v2/user-entitlements'
258
259
  },
259
260
  securityCenter: {
260
261
  recommendations: {
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.loadEntitlements = loadEntitlements;
7
+ exports.loadEntitlementsV2 = loadEntitlementsV2;
7
8
 
8
9
  var _constants = require("../constants");
9
10
 
@@ -11,4 +12,8 @@ var _fetch = require("../fetch");
11
12
 
12
13
  async function loadEntitlements() {
13
14
  return (0, _fetch.Get)(_constants.urls.entitlements.v1);
15
+ }
16
+
17
+ async function loadEntitlementsV2() {
18
+ return (0, _fetch.Get)(_constants.urls.entitlements.v2);
14
19
  }
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.1.31
1
+ /** @license Frontegg v3.1.33
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/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
- "version": "3.1.31",
3
+ "version": "3.1.33",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@babel/runtime": "^7.17.2"
7
+ "@babel/runtime": "^7.17.2",
8
+ "@frontegg/entitlements-javascript-commons": "1.0.0-alpha.7"
8
9
  },
9
10
  "sideEffects": false,
10
11
  "private": false,
@@ -3,6 +3,7 @@ import { ITenantsResponse } from '../tenants/interfaces';
3
3
  import { IRole } from '../roles/interfaces';
4
4
  import { ITeamUserPermission, UserManagedByEnum } from '../teams/interfaces';
5
5
  import { IGroupResponse } from '../groups/interfaces';
6
+ import { UserEntitlementsContext as UserEntitlementsResponseV2 } from "@frontegg/entitlements-javascript-commons";
6
7
  import { UserEntitlementsResponse } from '../entitlements/interfaces';
7
8
  export declare enum SortByEnum {
8
9
  createdAt = "createdAt",
@@ -75,7 +76,7 @@ export interface IBaseGetUserResponse extends IBaseUserData {
75
76
  createdAt?: Date;
76
77
  lastLogin?: Date;
77
78
  subAccountAccessAllowed?: boolean;
78
- entitlements?: UserEntitlementsResponse;
79
+ entitlements?: UserEntitlementsResponse | UserEntitlementsResponseV2;
79
80
  }
80
81
  export declare type IUserProfile = IGetUsersV2Response;
81
82
  export interface IGetUsersV2Response extends IBaseGetUserResponse {