@frontegg/rest-api 3.1.13 → 3.1.15

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/auth/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * from "./secutiry-poilicy";
2
2
  export * from "./enums";
3
3
  import { ISamlRolesGroup } from "../teams/interfaces";
4
4
  import { IAcceptInvitation, IActivateAccount, IAllowedToRememberMfaDevice, ICreateSamlGroup, IDeleteApiToken, IDisableMfa, IEnrollMfaResponse, IForgotPassword, IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IGetUserById, IGetUserPasswordConfig, ILogin, ILoginResponse, ILoginViaSocialLogin, ILoginViaSocialLoginResponse, ILoginWithMfa, IOidcPostLogin, IOidcConfiguration, IPostLogin, IPreLogin, IRecoverMFAToken, IResendActivationEmail, IResetPassword, ISamlConfiguration, ISamlVendorConfigResponse, ISignUpResponse, ISignUpUser, ISocialLoginProviderConfiguration, ITenantApiTokensData, IUpdateSamlConfiguration, IUpdateSamlGroup, IUpdateSamlRoles, IUpdateSamlVendorMetadata, IUpdateTenantApiTokensData, IUpdateUserApiTokensData, IUserApiTokensData, IUserIdResponse, IVendorConfig, IVerifyMfa, IVerifyMfaResponse, TestConfig, ISSOPublicConfiguration, IPreLoginWithIdpTypeResponse, IPasswordlessPreLogin, IPasswordlessPostLogin, ICreateSSODomain, IVerifyInviteToken, ISSODomain, ISSOConfigurationDefaultRoles, ISSOConfiguration, IUpdateSSOConfiguration, IOidcPostLoginV2, IExchangeOAuthTokens, IOAuthTokenResponse, ISocialLoginProviderConfigurationV2, ILoginResponseV2, IResetPhoneNumber, IVerifyResetPhoneNumber, IChangePhoneNumber, IVerifyResetPhoneNumberResponse, IResetPhoneNumberResponse, IWebAuthnPreLogin, IWebAuthnPostLogin, IVerifyNewWebAuthnDevice, IWebAuthnPreLoginResponse, ICreateNewDeviceSessionResponse, IAuthStrategiesConfig, ISessionResponse, IChangePhoneNumberWithVerification, IChangePhoneNumberWithVerificationResponse, IVerifyChangePhoneNumber, ISessionConfigurations, IResendInvitationEmail, IPreEnrollMFA, IEnrollMFAAuthenticatorApp, IPreEnrollMFASMS, IEnrollMFASMS, IEnrollMFAWebAuthn, IPreEnrollMFAAuthenticatorAppResponse, IPreEnrollMFAWebAuthnResponse, IVerifyMFAAuthenticatorApp, IPreVerifyMFA, IPreVerifyMFASMSResponse, IVerifyMFASMS, IPreVerifyMFAWebAuthnResponse, IVerifyMFAWebAuthn, IPreEnrollMFASMSResponse, IPreDisableMFASMSResponse, IDisableMFASMS, IDisableMFAWebAuthn, IPreDisableMFAWebAuthnResponse, UserMFADevicesResponse, WithoutMFAToken, IMFAStrategiesResponse, IOAuthLogout, IGetUserAccessTokens, IGetTenantAccessTokens, IDeleteAccessToken, ICreateTenantAccessTokenData, ICreateUserAccessTokenData, IWebAuthnDevices, ICustomSocialLoginProviderConfigurationV1, ILoginResponseV3, IPreVerifyMFAEmailCodeResponse, IVerifyMFAEmailCode, ICreateOrUpdateSSOConfigurationByMetadataUrl } from './interfaces';
5
- import { IUserProfile } from "../users/interfaces";
5
+ import { IGetUserAuthorizationResponse, IUserProfile } from "../users/interfaces";
6
6
  /*****************************************
7
7
  * Authentication
8
8
  *****************************************/
@@ -748,6 +748,15 @@ export declare function getPublicAuthStrategiesConfigForAuthenticatedUser(): Pro
748
748
  */
749
749
  export declare function getMFAStrategiesConfig(): Promise<IMFAStrategiesResponse>;
750
750
  /**
751
- * @returns me response with entitlements inside user.entitlements
751
+ * Get user permissions and roles
752
+ */
753
+ export declare function getUserAuthorization(): Promise<IGetUserAuthorizationResponse>;
754
+ /**
755
+ * Get user profile
756
+ */
757
+ export declare function getMeV2(): Promise<IUserProfile>;
758
+ /**
759
+ * @returns me and authorization response with entitlements inside user.entitlements
760
+ * Me request will be executed, and me authorization and entitlements will be executed according to FF and configuration.
752
761
  */
753
762
  export declare function getMeAndEntitlements(): Promise<IUserProfile>;
package/auth/index.js CHANGED
@@ -10,10 +10,12 @@ import { urls } from "../constants";
10
10
  import { ContextHolder } from "../ContextHolder";
11
11
  import { Delete, Get, Patch, Post, Put } from "../fetch";
12
12
  import { jwtDecode } from "../jwt";
13
+ import { LOAD_AUTHORIZATION_FF } from './interfaces';
13
14
  import { getCurrentUserTenantsV3 } from '../users';
14
15
  import { loadEntitlements } from '../entitlements';
15
16
  import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
16
17
  import { FeatureFlags } from "../feature-flags";
18
+ import { executeConditionalPromise } from "./utils";
17
19
  export async function generateLoginResponse(loginResponse) {
18
20
  if (!loginResponse.accessToken) {
19
21
  return loginResponse;
@@ -57,6 +59,11 @@ function shouldLoadEntitlements() {
57
59
  return isEntitlementsFFOn;
58
60
  }
59
61
 
62
+ function shouldLoadMeAuthorization() {
63
+ const [shouldLoadAuthorization] = FeatureFlags.getFeatureFlags([LOAD_AUTHORIZATION_FF], ContextHolder.getAppName() || '');
64
+ return shouldLoadAuthorization;
65
+ }
66
+
60
67
  export async function generateLoginResponseV3(loginResponse) {
61
68
  const {
62
69
  accessToken
@@ -687,15 +694,26 @@ export async function getPublicAuthStrategiesConfigForAuthenticatedUser() {
687
694
  export async function getMFAStrategiesConfig() {
688
695
  return Get(`${urls.identity.configurations.v1}/mfa/strategies`);
689
696
  }
697
+ export async function getUserAuthorization() {
698
+ return Get(`${urls.identity.users.authorization.v1}`);
699
+ }
700
+ export async function getMeV2() {
701
+ return Get(`${urls.identity.users.v2}/me`);
702
+ }
690
703
  export async function getMeAndEntitlements() {
691
- const mePromise = Get(`${urls.identity.users.v2}/me`);
692
-
693
- if (shouldLoadEntitlements()) {
694
- const [me, entitlements] = await Promise.all([mePromise, loadEntitlements()]);
695
- return _extends({}, me, {
696
- entitlements
697
- });
698
- }
699
-
700
- return await mePromise;
704
+ const actions = [{
705
+ action: getMeV2,
706
+ shouldLoad: true
707
+ }, {
708
+ action: loadEntitlements,
709
+ shouldLoad: shouldLoadEntitlements()
710
+ }, {
711
+ action: getUserAuthorization,
712
+ shouldLoad: shouldLoadMeAuthorization()
713
+ }];
714
+ const promises = actions.map(action => executeConditionalPromise(action));
715
+ const [me, entitlements, authorization] = await Promise.all(promises);
716
+ return _extends({}, me, authorization != null ? authorization : {}, {
717
+ entitlements
718
+ });
701
719
  }
@@ -657,3 +657,4 @@ export interface IMFAStrategyResponse {
657
657
  export interface IMFAStrategiesResponse {
658
658
  strategies: IMFAStrategyResponse[];
659
659
  }
660
+ export declare const LOAD_AUTHORIZATION_FF = "admin_portal_should_load_authorization";
@@ -24,4 +24,6 @@ export let MFAStrategyEnum;
24
24
  MFAStrategyEnum["WebAuthnCrossPlatform"] = "WebAuthnCrossPlatform";
25
25
  MFAStrategyEnum["SMS"] = "SMS";
26
26
  MFAStrategyEnum["EmailCode"] = "EmailCode";
27
- })(MFAStrategyEnum || (MFAStrategyEnum = {}));
27
+ })(MFAStrategyEnum || (MFAStrategyEnum = {}));
28
+
29
+ export const LOAD_AUTHORIZATION_FF = 'admin_portal_should_load_authorization';
@@ -0,0 +1,5 @@
1
+ export interface ConditionalAction<T = any> {
2
+ action: () => Promise<T>;
3
+ shouldLoad: boolean;
4
+ }
5
+ export declare function executeConditionalPromise({ shouldLoad, action }: ConditionalAction): Promise<any>;
package/auth/utils.js ADDED
@@ -0,0 +1,8 @@
1
+ ;
2
+ export async function executeConditionalPromise({
3
+ shouldLoad,
4
+ action
5
+ }) {
6
+ if (!shouldLoad) return;
7
+ return await action();
8
+ }
package/constants.d.ts CHANGED
@@ -48,6 +48,9 @@ export declare const urls: {
48
48
  v1: string;
49
49
  };
50
50
  };
51
+ authorization: {
52
+ v1: string;
53
+ };
51
54
  };
52
55
  configurations: {
53
56
  v1: string;
package/constants.js CHANGED
@@ -47,6 +47,9 @@ export const urls = {
47
47
  resetBreachedPasswords: {
48
48
  v1: 'identity/resources/users/v1/passwords/breached/reset/bulk'
49
49
  }
50
+ },
51
+ authorization: {
52
+ v1: '/identity/resources/users/v1/me/authorization'
50
53
  }
51
54
  },
52
55
  configurations: {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.1.13
1
+ /** @license Frontegg v3.1.15
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.
@@ -151,6 +151,8 @@ var _exportNames = {
151
151
  getVendorPublicAuthStrategiesConfig: true,
152
152
  getPublicAuthStrategiesConfigForAuthenticatedUser: true,
153
153
  getMFAStrategiesConfig: true,
154
+ getUserAuthorization: true,
155
+ getMeV2: true,
154
156
  getMeAndEntitlements: true
155
157
  };
156
158
  exports.OAuthLogout = OAuthLogout;
@@ -209,6 +211,7 @@ exports.getCustomSocialLoginProvidersV1 = getCustomSocialLoginProvidersV1;
209
211
  exports.getMFADevices = getMFADevices;
210
212
  exports.getMFAStrategiesConfig = getMFAStrategiesConfig;
211
213
  exports.getMeAndEntitlements = getMeAndEntitlements;
214
+ exports.getMeV2 = getMeV2;
212
215
  exports.getOidcConfiguration = getOidcConfiguration;
213
216
  exports.getPublicAuthStrategiesConfigForAuthenticatedUser = getPublicAuthStrategiesConfigForAuthenticatedUser;
214
217
  exports.getSSOConfigurations = getSSOConfigurations;
@@ -227,6 +230,7 @@ exports.getTenantAccessTokensData = getTenantAccessTokensData;
227
230
  exports.getTenantApiTokensData = getTenantApiTokensData;
228
231
  exports.getUserAccessTokensData = getUserAccessTokensData;
229
232
  exports.getUserApiTokensData = getUserApiTokensData;
233
+ exports.getUserAuthorization = getUserAuthorization;
230
234
  exports.getUserById = getUserById;
231
235
  exports.getVendorConfig = getVendorConfig;
232
236
  exports.getVendorPublicAuthStrategiesConfig = getVendorPublicAuthStrategiesConfig;
@@ -342,14 +346,18 @@ var _fetch = require("../fetch");
342
346
 
343
347
  var _jwt = require("../jwt");
344
348
 
349
+ var _interfaces = require("./interfaces");
350
+
345
351
  var _users = require("../users");
346
352
 
347
353
  var _entitlements = require("../entitlements");
348
354
 
349
- var _interfaces = require("../entitlements/interfaces");
355
+ var _interfaces2 = require("../entitlements/interfaces");
350
356
 
351
357
  var _featureFlags = require("../feature-flags");
352
358
 
359
+ var _utils = require("./utils");
360
+
353
361
  const _excluded = ["type"],
354
362
  _excluded2 = ["type"],
355
363
  _excluded3 = ["type"];
@@ -396,11 +404,17 @@ function shouldLoadEntitlements() {
396
404
  return false;
397
405
  }
398
406
 
399
- const [isEntitlementsFFOn] = _featureFlags.FeatureFlags.getFeatureFlags([_interfaces.ADMIN_PORTAL_ENTITLEMENTS_FF], _ContextHolder.ContextHolder.getAppName() || '');
407
+ const [isEntitlementsFFOn] = _featureFlags.FeatureFlags.getFeatureFlags([_interfaces2.ADMIN_PORTAL_ENTITLEMENTS_FF], _ContextHolder.ContextHolder.getAppName() || '');
400
408
 
401
409
  return isEntitlementsFFOn;
402
410
  }
403
411
 
412
+ function shouldLoadMeAuthorization() {
413
+ const [shouldLoadAuthorization] = _featureFlags.FeatureFlags.getFeatureFlags([_interfaces.LOAD_AUTHORIZATION_FF], _ContextHolder.ContextHolder.getAppName() || '');
414
+
415
+ return shouldLoadAuthorization;
416
+ }
417
+
404
418
  async function generateLoginResponseV3(loginResponse) {
405
419
  const {
406
420
  accessToken
@@ -1174,15 +1188,28 @@ async function getMFAStrategiesConfig() {
1174
1188
  return (0, _fetch.Get)(`${_constants.urls.identity.configurations.v1}/mfa/strategies`);
1175
1189
  }
1176
1190
 
1177
- async function getMeAndEntitlements() {
1178
- const mePromise = (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
1191
+ async function getUserAuthorization() {
1192
+ return (0, _fetch.Get)(`${_constants.urls.identity.users.authorization.v1}`);
1193
+ }
1179
1194
 
1180
- if (shouldLoadEntitlements()) {
1181
- const [me, entitlements] = await Promise.all([mePromise, (0, _entitlements.loadEntitlements)()]);
1182
- return (0, _extends2.default)({}, me, {
1183
- entitlements
1184
- });
1185
- }
1195
+ async function getMeV2() {
1196
+ return (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
1197
+ }
1186
1198
 
1187
- return await mePromise;
1199
+ async function getMeAndEntitlements() {
1200
+ const actions = [{
1201
+ action: getMeV2,
1202
+ shouldLoad: true
1203
+ }, {
1204
+ action: _entitlements.loadEntitlements,
1205
+ shouldLoad: shouldLoadEntitlements()
1206
+ }, {
1207
+ action: getUserAuthorization,
1208
+ shouldLoad: shouldLoadMeAuthorization()
1209
+ }];
1210
+ const promises = actions.map(action => (0, _utils.executeConditionalPromise)(action));
1211
+ const [me, entitlements, authorization] = await Promise.all(promises);
1212
+ return (0, _extends2.default)({}, me, authorization != null ? authorization : {}, {
1213
+ entitlements
1214
+ });
1188
1215
  }
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  SecondaryAuthStrategy: true,
8
8
  WebAuthnDeviceType: true,
9
- MFAStrategyEnum: true
9
+ MFAStrategyEnum: true,
10
+ LOAD_AUTHORIZATION_FF: true
10
11
  };
11
- exports.WebAuthnDeviceType = exports.SecondaryAuthStrategy = exports.MFAStrategyEnum = void 0;
12
+ exports.WebAuthnDeviceType = exports.SecondaryAuthStrategy = exports.MFAStrategyEnum = exports.LOAD_AUTHORIZATION_FF = void 0;
12
13
 
13
14
  var _interfaces = require("./secutiry-poilicy/interfaces");
14
15
 
@@ -51,4 +52,7 @@ exports.MFAStrategyEnum = MFAStrategyEnum;
51
52
  MFAStrategyEnum["WebAuthnCrossPlatform"] = "WebAuthnCrossPlatform";
52
53
  MFAStrategyEnum["SMS"] = "SMS";
53
54
  MFAStrategyEnum["EmailCode"] = "EmailCode";
54
- })(MFAStrategyEnum || (exports.MFAStrategyEnum = MFAStrategyEnum = {}));
55
+ })(MFAStrategyEnum || (exports.MFAStrategyEnum = MFAStrategyEnum = {}));
56
+
57
+ const LOAD_AUTHORIZATION_FF = 'admin_portal_should_load_authorization';
58
+ exports.LOAD_AUTHORIZATION_FF = LOAD_AUTHORIZATION_FF;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.executeConditionalPromise = executeConditionalPromise;
7
+ ;
8
+
9
+ async function executeConditionalPromise({
10
+ shouldLoad,
11
+ action
12
+ }) {
13
+ if (!shouldLoad) return;
14
+ return await action();
15
+ }
package/node/constants.js CHANGED
@@ -53,6 +53,9 @@ const urls = {
53
53
  resetBreachedPasswords: {
54
54
  v1: 'identity/resources/users/v1/passwords/breached/reset/bulk'
55
55
  }
56
+ },
57
+ authorization: {
58
+ v1: '/identity/resources/users/v1/me/authorization'
56
59
  }
57
60
  },
58
61
  configurations: {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v3.1.13
1
+ /** @license Frontegg v3.1.15
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.
@@ -50,6 +50,7 @@ exports.InsightCode = InsightCode;
50
50
  InsightCode["NO_DOMAIN_RESTRICTIONS"] = "NO_DOMAIN_RESTRICTIONS";
51
51
  InsightCode["DOMAIN_ALLOWLIST"] = "DOMAIN_ALLOWLIST";
52
52
  InsightCode["DOMAIN_DENYLIST"] = "DOMAIN_DENYLIST";
53
+ InsightCode["FULL_PASSWORD_SETTINGS"] = "FULL_PASSWORD_SETTINGS";
53
54
  })(InsightCode || (exports.InsightCode = InsightCode = {}));
54
55
 
55
56
  let RecommendationActionKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontegg/rest-api",
3
- "version": "3.1.13",
3
+ "version": "3.1.15",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -73,7 +73,8 @@ export declare enum InsightCode {
73
73
  IP_DENYLIST = "IP_DENYLIST",
74
74
  NO_DOMAIN_RESTRICTIONS = "NO_DOMAIN_RESTRICTIONS",
75
75
  DOMAIN_ALLOWLIST = "DOMAIN_ALLOWLIST",
76
- DOMAIN_DENYLIST = "DOMAIN_DENYLIST"
76
+ DOMAIN_DENYLIST = "DOMAIN_DENYLIST",
77
+ FULL_PASSWORD_SETTINGS = "FULL_PASSWORD_SETTINGS"
77
78
  }
78
79
  export interface RecommendationAction {
79
80
  key: RecommendationActionKey;
@@ -42,6 +42,7 @@ export let InsightCode;
42
42
  InsightCode["NO_DOMAIN_RESTRICTIONS"] = "NO_DOMAIN_RESTRICTIONS";
43
43
  InsightCode["DOMAIN_ALLOWLIST"] = "DOMAIN_ALLOWLIST";
44
44
  InsightCode["DOMAIN_DENYLIST"] = "DOMAIN_DENYLIST";
45
+ InsightCode["FULL_PASSWORD_SETTINGS"] = "FULL_PASSWORD_SETTINGS";
45
46
  })(InsightCode || (InsightCode = {}));
46
47
 
47
48
  export let RecommendationActionKey;
@@ -87,6 +87,10 @@ export interface IGetUsersV2Response extends IBaseGetUserResponse {
87
87
  permissions: ITeamUserPermission[];
88
88
  groups?: Pick<IGroupResponse, 'id' | 'roles'>[];
89
89
  }
90
+ export interface IGetUserAuthorizationResponse {
91
+ permissions: ITeamUserPermission[];
92
+ roles: IRole[];
93
+ }
90
94
  export declare type IUsersV3Data = IBaseGetUserResponse;
91
95
  export declare enum GetUsersFilterPreset {
92
96
  MFA_UNENROLLED = "mfa-unenrolled",