@frontegg/rest-api 3.1.13 → 3.1.14
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 +11 -2
- package/auth/index.js +28 -10
- package/auth/interfaces.d.ts +1 -0
- package/auth/interfaces.js +3 -1
- package/auth/utils.d.ts +5 -0
- package/auth/utils.js +8 -0
- package/constants.d.ts +3 -0
- package/constants.js +3 -0
- package/index.js +1 -1
- package/node/auth/index.js +38 -11
- package/node/auth/interfaces.js +7 -3
- package/node/auth/utils.js +15 -0
- package/node/constants.js +3 -0
- package/node/index.js +1 -1
- package/package.json +1 -1
- package/users/interfaces.d.ts +4 -0
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
|
-
*
|
|
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
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
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
|
}
|
package/auth/interfaces.d.ts
CHANGED
package/auth/interfaces.js
CHANGED
|
@@ -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';
|
package/auth/utils.d.ts
ADDED
package/auth/utils.js
ADDED
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
package/index.js
CHANGED
package/node/auth/index.js
CHANGED
|
@@ -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
|
|
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([
|
|
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
|
|
1178
|
-
|
|
1191
|
+
async function getUserAuthorization() {
|
|
1192
|
+
return (0, _fetch.Get)(`${_constants.urls.identity.users.authorization.v1}`);
|
|
1193
|
+
}
|
|
1179
1194
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
entitlements
|
|
1184
|
-
});
|
|
1185
|
-
}
|
|
1195
|
+
async function getMeV2() {
|
|
1196
|
+
return (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
|
|
1197
|
+
}
|
|
1186
1198
|
|
|
1187
|
-
|
|
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
|
}
|
package/node/auth/interfaces.js
CHANGED
|
@@ -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
package/node/index.js
CHANGED
package/package.json
CHANGED
package/users/interfaces.d.ts
CHANGED
|
@@ -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",
|