@frontegg/rest-api 3.0.141 → 3.1.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/ContextHolder/index.d.ts +15 -9
- package/ContextHolder/index.js +6 -4
- package/auth/index.d.ts +5 -0
- package/auth/index.js +21 -23
- package/auth/interfaces.d.ts +3 -3
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/node/ContextHolder/index.js +6 -4
- package/node/auth/index.js +26 -24
- package/node/index.js +1 -1
- package/package.json +1 -1
- package/teams/index.d.ts +3 -2
- package/users/interfaces.d.ts +3 -2
package/ContextHolder/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { IUserProfile } from '../teams/interfaces';
|
|
2
1
|
import { ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
|
|
2
|
+
import { IUserDTO } from "../users/interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Entitlements config from frontegg provider
|
|
5
|
+
*/
|
|
6
|
+
export interface EntitlementsOptions {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
3
9
|
export declare class ContextHolder {
|
|
4
10
|
private static instance;
|
|
5
11
|
private context;
|
|
@@ -8,21 +14,21 @@ export declare class ContextHolder {
|
|
|
8
14
|
private requestSource;
|
|
9
15
|
private onRedirectTo;
|
|
10
16
|
private logout;
|
|
11
|
-
private
|
|
17
|
+
private entitlementsOptions;
|
|
12
18
|
private appName;
|
|
13
19
|
private constructor();
|
|
14
20
|
static getInstance(): ContextHolder;
|
|
15
21
|
static setContext(context: ContextOptions): void;
|
|
16
22
|
static setAccessToken(accessToken: string | null): void;
|
|
17
|
-
static setUser(user:
|
|
23
|
+
static setUser(user: IUserDTO | null): void;
|
|
18
24
|
static setRequestSource(requestSource: RequestSource | null): void;
|
|
19
25
|
static setOnRedirectTo(onRedirectTo: (path: string, opts?: RedirectOptions) => void): void;
|
|
20
26
|
static setLogout(logout: (callback?: () => void) => void, logoutUrl: string): void;
|
|
21
27
|
/**
|
|
22
28
|
* App name should also be set for entitlements
|
|
23
|
-
* @param
|
|
29
|
+
* @param entitlementsOptions frontegg options entitlements config
|
|
24
30
|
*/
|
|
25
|
-
static
|
|
31
|
+
static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions): void;
|
|
26
32
|
/**
|
|
27
33
|
* @param appName for feature flags e.g.
|
|
28
34
|
*/
|
|
@@ -30,13 +36,13 @@ export declare class ContextHolder {
|
|
|
30
36
|
static getContext(): ContextOptions;
|
|
31
37
|
static getAccessToken(): string | null;
|
|
32
38
|
static getRequestSource(): RequestSource | null;
|
|
33
|
-
static getUser():
|
|
39
|
+
static getUser(): IUserDTO | null;
|
|
34
40
|
static onRedirectTo(path: string, opts?: RedirectOptions): void;
|
|
35
41
|
static logout(callback?: () => void): void;
|
|
36
42
|
/**
|
|
37
|
-
* @returns shouldLoadEntitlements
|
|
43
|
+
* @returns shouldLoadEntitlements. Default to false.
|
|
38
44
|
*/
|
|
39
|
-
static shouldLoadEntitlements(): boolean
|
|
45
|
+
static shouldLoadEntitlements(): boolean;
|
|
40
46
|
/**
|
|
41
47
|
* @returns app name value
|
|
42
48
|
*/
|
|
@@ -45,7 +51,7 @@ export declare class ContextHolder {
|
|
|
45
51
|
export declare const FronteggContext: {
|
|
46
52
|
getContext: () => ContextOptions;
|
|
47
53
|
getAccessToken: () => string | null;
|
|
48
|
-
getUser: () =>
|
|
54
|
+
getUser: () => IUserDTO | null;
|
|
49
55
|
onRedirectTo: (path: string, opts: RedirectOptions) => void;
|
|
50
56
|
logout: (callback?: (() => void) | undefined) => void;
|
|
51
57
|
};
|
package/ContextHolder/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export class ContextHolder {
|
|
|
9
9
|
|
|
10
10
|
this.logout = () => window.location.href = '/account/logout';
|
|
11
11
|
|
|
12
|
-
this.
|
|
12
|
+
this.entitlementsOptions = null;
|
|
13
13
|
this.appName = null;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -51,8 +51,8 @@ export class ContextHolder {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
static
|
|
55
|
-
ContextHolder.getInstance().
|
|
54
|
+
static setEntitlementsOptions(entitlementsOptions) {
|
|
55
|
+
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
static setAppName(appName) {
|
|
@@ -90,7 +90,9 @@ export class ContextHolder {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
static shouldLoadEntitlements() {
|
|
93
|
-
|
|
93
|
+
var _ContextHolder$getIns2;
|
|
94
|
+
|
|
95
|
+
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
static getAppName() {
|
package/auth/index.d.ts
CHANGED
|
@@ -2,6 +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 } from './interfaces';
|
|
5
|
+
import { IUserDTO } from "../users/interfaces";
|
|
5
6
|
/*****************************************
|
|
6
7
|
* Authentication
|
|
7
8
|
*****************************************/
|
|
@@ -732,3 +733,7 @@ export declare function getPublicAuthStrategiesConfigForAuthenticatedUser(): Pro
|
|
|
732
733
|
* Get vendor mfa strategies configuration
|
|
733
734
|
*/
|
|
734
735
|
export declare function getMFAStrategiesConfig(): Promise<IMFAStrategiesResponse>;
|
|
736
|
+
/**
|
|
737
|
+
* @returns me response with entitlements inside user.entitlements
|
|
738
|
+
*/
|
|
739
|
+
export declare function getMeAndEntitlements(): Promise<IUserDTO>;
|
package/auth/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export async function generateLoginResponse(loginResponse) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
ContextHolder.setAccessToken(loginResponse.accessToken);
|
|
23
|
-
const me = await
|
|
23
|
+
const me = await getMeAndEntitlements();
|
|
24
24
|
const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
|
|
25
25
|
|
|
26
26
|
const user = _extends({}, loginResponse, decodedContent, me);
|
|
@@ -36,7 +36,7 @@ export async function generateLoginResponseV2(loginResponse) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
ContextHolder.setAccessToken(loginResponse.accessToken);
|
|
39
|
-
const [me, tenants] = await Promise.all([
|
|
39
|
+
const [me, tenants] = await Promise.all([getMeAndEntitlements(), getTenants()]);
|
|
40
40
|
const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
|
|
41
41
|
|
|
42
42
|
const user = _extends({}, loginResponse, decodedContent, me);
|
|
@@ -48,12 +48,12 @@ export async function generateLoginResponseV2(loginResponse) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
function shouldLoadEntitlements() {
|
|
52
52
|
if (!ContextHolder.shouldLoadEntitlements()) {
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const [isEntitlementsFFOn] =
|
|
56
|
+
const [isEntitlementsFFOn] = FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], ContextHolder.getAppName() || '');
|
|
57
57
|
return isEntitlementsFFOn;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -69,28 +69,21 @@ export async function generateLoginResponseV3(loginResponse) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
ContextHolder.setAccessToken(accessToken);
|
|
72
|
-
const [me, currentUserTenants] = await Promise.all([
|
|
72
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsV3()]);
|
|
73
73
|
const decodedContent = accessToken ? jwtDecode(accessToken) : {};
|
|
74
74
|
|
|
75
75
|
const user = _extends({}, loginResponse, decodedContent, me);
|
|
76
76
|
|
|
77
77
|
ContextHolder.setUser(user);
|
|
78
|
-
let entitlements;
|
|
79
|
-
|
|
80
|
-
if (await shouldLoadEntitlements()) {
|
|
81
|
-
entitlements = await loadEntitlements();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
78
|
return {
|
|
85
79
|
user,
|
|
86
80
|
tenants: currentUserTenants.tenants,
|
|
87
|
-
activeTenant: currentUserTenants.activeTenant
|
|
88
|
-
entitlements
|
|
81
|
+
activeTenant: currentUserTenants.activeTenant
|
|
89
82
|
};
|
|
90
83
|
}
|
|
91
84
|
export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
92
85
|
ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
93
|
-
const me = await
|
|
86
|
+
const me = await getMeAndEntitlements();
|
|
94
87
|
const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
|
|
95
88
|
|
|
96
89
|
const user = _extends({
|
|
@@ -106,7 +99,7 @@ export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
|
106
99
|
}
|
|
107
100
|
export async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
108
101
|
ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
109
|
-
const [me, currentUserTenants] = await Promise.all([
|
|
102
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsV3()]);
|
|
110
103
|
const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
|
|
111
104
|
|
|
112
105
|
const user = _extends({
|
|
@@ -118,17 +111,10 @@ export async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
|
118
111
|
});
|
|
119
112
|
|
|
120
113
|
ContextHolder.setUser(user);
|
|
121
|
-
let entitlements;
|
|
122
|
-
|
|
123
|
-
if (await shouldLoadEntitlements()) {
|
|
124
|
-
entitlements = await loadEntitlements();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
114
|
return {
|
|
128
115
|
user,
|
|
129
116
|
tenants: currentUserTenants.tenants,
|
|
130
|
-
activeTenant: currentUserTenants.activeTenant
|
|
131
|
-
entitlements
|
|
117
|
+
activeTenant: currentUserTenants.activeTenant
|
|
132
118
|
};
|
|
133
119
|
}
|
|
134
120
|
export async function preLogin(body) {
|
|
@@ -694,4 +680,16 @@ export async function getPublicAuthStrategiesConfigForAuthenticatedUser() {
|
|
|
694
680
|
}
|
|
695
681
|
export async function getMFAStrategiesConfig() {
|
|
696
682
|
return Get(`${urls.identity.configurations.v1}/mfa/strategies`);
|
|
683
|
+
}
|
|
684
|
+
export async function getMeAndEntitlements() {
|
|
685
|
+
const mePromise = Get(`${urls.identity.users.v2}/me`);
|
|
686
|
+
|
|
687
|
+
if (shouldLoadEntitlements()) {
|
|
688
|
+
const [me, entitlements] = await Promise.all([mePromise, loadEntitlements()]);
|
|
689
|
+
return _extends({}, me, {
|
|
690
|
+
entitlements
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return await mePromise;
|
|
697
695
|
}
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ITenantsResponse,
|
|
1
|
+
import { ITenantsResponse, IUserDTO, UserEntitlementsResponse } from "..";
|
|
2
2
|
import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from "./enums";
|
|
3
3
|
import { ISamlRolesGroup } from "../teams/interfaces";
|
|
4
4
|
export * from "./secutiry-poilicy/interfaces";
|
|
@@ -30,7 +30,7 @@ export declare type ILogin = {
|
|
|
30
30
|
recaptchaToken?: string;
|
|
31
31
|
invitationToken?: string;
|
|
32
32
|
};
|
|
33
|
-
export declare type ILoginResponse =
|
|
33
|
+
export declare type ILoginResponse = IUserDTO & {
|
|
34
34
|
mfaRequired: boolean;
|
|
35
35
|
accessToken: string;
|
|
36
36
|
refreshToken: string;
|
|
@@ -45,6 +45,7 @@ export declare type ILoginResponse = IUserProfile & {
|
|
|
45
45
|
mfaStrategies?: MFAStrategyEnum[];
|
|
46
46
|
mfaDevices?: UserMFADevicesResponse;
|
|
47
47
|
isBreachedPassword?: boolean;
|
|
48
|
+
entitlements?: UserEntitlementsResponse;
|
|
48
49
|
};
|
|
49
50
|
export declare type ILoginResponseV2 = {
|
|
50
51
|
user: ILoginResponse;
|
|
@@ -54,7 +55,6 @@ export declare type ILoginResponseV3 = {
|
|
|
54
55
|
user: ILoginResponse;
|
|
55
56
|
tenants?: ITenantsResponse[];
|
|
56
57
|
activeTenant?: ITenantsResponse;
|
|
57
|
-
entitlements?: UserEntitlementsResponse;
|
|
58
58
|
};
|
|
59
59
|
export declare type ILoginWithMfa = {
|
|
60
60
|
mfaToken: string;
|
package/index.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ declare const _default: {
|
|
|
77
77
|
FronteggContext: {
|
|
78
78
|
getContext: () => import("./interfaces").ContextOptions;
|
|
79
79
|
getAccessToken: () => string | null;
|
|
80
|
-
getUser: () => import("./
|
|
80
|
+
getUser: () => import("./users/interfaces").IUserDTO | null;
|
|
81
81
|
onRedirectTo: (path: string, opts: import("./interfaces").RedirectOptions) => void;
|
|
82
82
|
logout: (callback?: (() => void) | undefined) => void;
|
|
83
83
|
};
|
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@ class ContextHolder {
|
|
|
16
16
|
|
|
17
17
|
this.logout = () => window.location.href = '/account/logout';
|
|
18
18
|
|
|
19
|
-
this.
|
|
19
|
+
this.entitlementsOptions = null;
|
|
20
20
|
this.appName = null;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -58,8 +58,8 @@ class ContextHolder {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
static
|
|
62
|
-
ContextHolder.getInstance().
|
|
61
|
+
static setEntitlementsOptions(entitlementsOptions) {
|
|
62
|
+
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
static setAppName(appName) {
|
|
@@ -97,7 +97,9 @@ class ContextHolder {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
static shouldLoadEntitlements() {
|
|
100
|
-
|
|
100
|
+
var _ContextHolder$getIns2;
|
|
101
|
+
|
|
102
|
+
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
static getAppName() {
|
package/node/auth/index.js
CHANGED
|
@@ -148,7 +148,8 @@ var _exportNames = {
|
|
|
148
148
|
verifyNewDeviceSession: true,
|
|
149
149
|
getVendorPublicAuthStrategiesConfig: true,
|
|
150
150
|
getPublicAuthStrategiesConfigForAuthenticatedUser: true,
|
|
151
|
-
getMFAStrategiesConfig: true
|
|
151
|
+
getMFAStrategiesConfig: true,
|
|
152
|
+
getMeAndEntitlements: true
|
|
152
153
|
};
|
|
153
154
|
exports.OAuthLogout = OAuthLogout;
|
|
154
155
|
exports.acceptInvitation = acceptInvitation;
|
|
@@ -204,6 +205,7 @@ exports.getCurrentUserSessions = getCurrentUserSessions;
|
|
|
204
205
|
exports.getCustomSocialLoginProvidersV1 = getCustomSocialLoginProvidersV1;
|
|
205
206
|
exports.getMFADevices = getMFADevices;
|
|
206
207
|
exports.getMFAStrategiesConfig = getMFAStrategiesConfig;
|
|
208
|
+
exports.getMeAndEntitlements = getMeAndEntitlements;
|
|
207
209
|
exports.getOidcConfiguration = getOidcConfiguration;
|
|
208
210
|
exports.getPublicAuthStrategiesConfigForAuthenticatedUser = getPublicAuthStrategiesConfigForAuthenticatedUser;
|
|
209
211
|
exports.getSSOConfigurations = getSSOConfigurations;
|
|
@@ -355,7 +357,7 @@ async function generateLoginResponse(loginResponse) {
|
|
|
355
357
|
|
|
356
358
|
_ContextHolder.ContextHolder.setAccessToken(loginResponse.accessToken);
|
|
357
359
|
|
|
358
|
-
const me = await (
|
|
360
|
+
const me = await getMeAndEntitlements();
|
|
359
361
|
const decodedContent = loginResponse.accessToken ? (0, _jwt.jwtDecode)(loginResponse.accessToken) : {};
|
|
360
362
|
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
|
|
361
363
|
|
|
@@ -373,7 +375,7 @@ async function generateLoginResponseV2(loginResponse) {
|
|
|
373
375
|
|
|
374
376
|
_ContextHolder.ContextHolder.setAccessToken(loginResponse.accessToken);
|
|
375
377
|
|
|
376
|
-
const [me, tenants] = await Promise.all([(
|
|
378
|
+
const [me, tenants] = await Promise.all([getMeAndEntitlements(), (0, _tenants.getTenants)()]);
|
|
377
379
|
const decodedContent = loginResponse.accessToken ? (0, _jwt.jwtDecode)(loginResponse.accessToken) : {};
|
|
378
380
|
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
|
|
379
381
|
|
|
@@ -385,12 +387,13 @@ async function generateLoginResponseV2(loginResponse) {
|
|
|
385
387
|
};
|
|
386
388
|
}
|
|
387
389
|
|
|
388
|
-
|
|
390
|
+
function shouldLoadEntitlements() {
|
|
389
391
|
if (!_ContextHolder.ContextHolder.shouldLoadEntitlements()) {
|
|
390
392
|
return false;
|
|
391
393
|
}
|
|
392
394
|
|
|
393
|
-
const [isEntitlementsFFOn] =
|
|
395
|
+
const [isEntitlementsFFOn] = _featureFlags.FeatureFlags.getFeatureFlags([_interfaces.ADMIN_PORTAL_ENTITLEMENTS_FF], _ContextHolder.ContextHolder.getAppName() || '');
|
|
396
|
+
|
|
394
397
|
return isEntitlementsFFOn;
|
|
395
398
|
}
|
|
396
399
|
|
|
@@ -407,30 +410,23 @@ async function generateLoginResponseV3(loginResponse) {
|
|
|
407
410
|
|
|
408
411
|
_ContextHolder.ContextHolder.setAccessToken(accessToken);
|
|
409
412
|
|
|
410
|
-
const [me, currentUserTenants] = await Promise.all([(
|
|
413
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _users.getCurrentUserTenantsV3)()]);
|
|
411
414
|
const decodedContent = accessToken ? (0, _jwt.jwtDecode)(accessToken) : {};
|
|
412
415
|
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
|
|
413
416
|
|
|
414
417
|
_ContextHolder.ContextHolder.setUser(user);
|
|
415
418
|
|
|
416
|
-
let entitlements;
|
|
417
|
-
|
|
418
|
-
if (await shouldLoadEntitlements()) {
|
|
419
|
-
entitlements = await (0, _entitlements.loadEntitlements)();
|
|
420
|
-
}
|
|
421
|
-
|
|
422
419
|
return {
|
|
423
420
|
user,
|
|
424
421
|
tenants: currentUserTenants.tenants,
|
|
425
|
-
activeTenant: currentUserTenants.activeTenant
|
|
426
|
-
entitlements
|
|
422
|
+
activeTenant: currentUserTenants.activeTenant
|
|
427
423
|
};
|
|
428
424
|
}
|
|
429
425
|
|
|
430
426
|
async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
431
427
|
_ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
432
428
|
|
|
433
|
-
const me = await (
|
|
429
|
+
const me = await getMeAndEntitlements();
|
|
434
430
|
const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};
|
|
435
431
|
const user = (0, _extends2.default)({
|
|
436
432
|
mfaRequired: false,
|
|
@@ -448,7 +444,7 @@ async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
|
448
444
|
async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
449
445
|
_ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
450
446
|
|
|
451
|
-
const [me, currentUserTenants] = await Promise.all([(
|
|
447
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _users.getCurrentUserTenantsV3)()]);
|
|
452
448
|
const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};
|
|
453
449
|
const user = (0, _extends2.default)({
|
|
454
450
|
mfaRequired: false,
|
|
@@ -460,17 +456,10 @@ async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
|
460
456
|
|
|
461
457
|
_ContextHolder.ContextHolder.setUser(user);
|
|
462
458
|
|
|
463
|
-
let entitlements;
|
|
464
|
-
|
|
465
|
-
if (await shouldLoadEntitlements()) {
|
|
466
|
-
entitlements = await (0, _entitlements.loadEntitlements)();
|
|
467
|
-
}
|
|
468
|
-
|
|
469
459
|
return {
|
|
470
460
|
user,
|
|
471
461
|
tenants: currentUserTenants.tenants,
|
|
472
|
-
activeTenant: currentUserTenants.activeTenant
|
|
473
|
-
entitlements
|
|
462
|
+
activeTenant: currentUserTenants.activeTenant
|
|
474
463
|
};
|
|
475
464
|
}
|
|
476
465
|
|
|
@@ -1171,4 +1160,17 @@ async function getPublicAuthStrategiesConfigForAuthenticatedUser() {
|
|
|
1171
1160
|
|
|
1172
1161
|
async function getMFAStrategiesConfig() {
|
|
1173
1162
|
return (0, _fetch.Get)(`${_constants.urls.identity.configurations.v1}/mfa/strategies`);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
async function getMeAndEntitlements() {
|
|
1166
|
+
const mePromise = (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
|
|
1167
|
+
|
|
1168
|
+
if (shouldLoadEntitlements()) {
|
|
1169
|
+
const [me, entitlements] = await Promise.all([mePromise, (0, _entitlements.loadEntitlements)()]);
|
|
1170
|
+
return (0, _extends2.default)({}, me, {
|
|
1171
|
+
entitlements
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
return await mePromise;
|
|
1174
1176
|
}
|
package/node/index.js
CHANGED
package/package.json
CHANGED
package/teams/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile,
|
|
1
|
+
import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUpdateUser, IDeleteUser, ITeamUserPermission, IResendInvitationLink, IInviteUserLinkResponse, ICreateOrUpdateInviteUserLink, IInviteLinkConfiguration, IUserProfile } from './interfaces';
|
|
2
2
|
import { PaginationResult } from '../interfaces';
|
|
3
|
+
import { IUserDTO } from "../users/interfaces";
|
|
3
4
|
/*****************************************
|
|
4
5
|
* Profile Api
|
|
5
6
|
*****************************************/
|
|
@@ -9,7 +10,7 @@ import { PaginationResult } from '../interfaces';
|
|
|
9
10
|
* @throws exception if the current password incorrect or new password validation failed.
|
|
10
11
|
* ``authorized user``
|
|
11
12
|
*/
|
|
12
|
-
export declare function getProfile(params?: object): Promise<
|
|
13
|
+
export declare function getProfile(params?: object): Promise<IUserDTO>;
|
|
13
14
|
/**
|
|
14
15
|
* update user profile by providing updated fields.
|
|
15
16
|
* ``authorized user``
|
package/users/interfaces.d.ts
CHANGED
|
@@ -63,12 +63,13 @@ export interface IBaseGetUserResponse extends IBaseUserData {
|
|
|
63
63
|
managedBy?: UserManagedByEnum;
|
|
64
64
|
invisible?: true;
|
|
65
65
|
superUser?: true;
|
|
66
|
-
metadata
|
|
66
|
+
metadata: string;
|
|
67
67
|
createdAt?: Date;
|
|
68
68
|
lastLogin?: Date;
|
|
69
69
|
subAccountAccessAllowed?: boolean;
|
|
70
70
|
}
|
|
71
|
-
export
|
|
71
|
+
export declare type IGetUsersV2Response = IUserDTO;
|
|
72
|
+
export interface IUserDTO extends IBaseGetUserResponse {
|
|
72
73
|
roles: IRole[];
|
|
73
74
|
permissions: ITeamUserPermission[];
|
|
74
75
|
groups?: Pick<IGroupResponse, 'id' | 'roles'>[];
|