@frontegg/rest-api 3.1.29 → 3.1.31
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 +10 -1
- package/ContextHolder/index.js +12 -0
- package/auth/constants.d.ts +5 -0
- package/auth/constants.js +2 -0
- package/auth/index.d.ts +7 -6
- package/auth/index.js +43 -14
- package/auth/interfaces.d.ts +0 -3
- package/auth/utils.d.ts +4 -0
- package/auth/utils.js +28 -0
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/interfaces.d.ts +3 -0
- package/node/ContextHolder/index.js +12 -0
- package/node/auth/constants.js +10 -0
- package/node/auth/index.js +65 -17
- package/node/auth/utils.js +38 -0
- package/node/constants.js +1 -0
- package/node/index.js +22 -1
- package/node/tenants/index.js +8 -0
- package/node/users/index.js +7 -0
- package/package.json +1 -1
- package/tenants/index.js +6 -0
- package/users/index.d.ts +7 -0
- package/users/index.js +5 -0
package/ContextHolder/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
|
|
1
|
+
import { SessionContext, ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
|
|
2
2
|
import { IUserProfile } from "../users/interfaces";
|
|
3
3
|
/**
|
|
4
4
|
* Entitlements config from frontegg provider
|
|
@@ -16,6 +16,7 @@ export declare class ContextHolder {
|
|
|
16
16
|
private logout;
|
|
17
17
|
private entitlementsOptions;
|
|
18
18
|
private appName;
|
|
19
|
+
private sessionContext?;
|
|
19
20
|
private constructor();
|
|
20
21
|
static getInstance(): ContextHolder;
|
|
21
22
|
static setContext(context: ContextOptions): void;
|
|
@@ -29,6 +30,10 @@ export declare class ContextHolder {
|
|
|
29
30
|
* @param entitlementsOptions frontegg options entitlements config
|
|
30
31
|
*/
|
|
31
32
|
static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions): void;
|
|
33
|
+
/**
|
|
34
|
+
* @param sessionContext frontegg options SessionContext config
|
|
35
|
+
*/
|
|
36
|
+
static setSessionContext(sessionContext: SessionContext): void;
|
|
32
37
|
/**
|
|
33
38
|
* @param appName for feature flags e.g.
|
|
34
39
|
*/
|
|
@@ -43,6 +48,10 @@ export declare class ContextHolder {
|
|
|
43
48
|
* @returns shouldLoadEntitlements. Default to false.
|
|
44
49
|
*/
|
|
45
50
|
static shouldLoadEntitlements(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* @returns isSessionPerTenantEnabled. Default to false.
|
|
53
|
+
*/
|
|
54
|
+
static isSessionPerTenantEnabled(): boolean;
|
|
46
55
|
/**
|
|
47
56
|
* @returns app name value
|
|
48
57
|
*/
|
package/ContextHolder/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export class ContextHolder {
|
|
|
11
11
|
|
|
12
12
|
this.entitlementsOptions = null;
|
|
13
13
|
this.appName = null;
|
|
14
|
+
this.sessionContext = void 0;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
static getInstance() {
|
|
@@ -55,6 +56,11 @@ export class ContextHolder {
|
|
|
55
56
|
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
static setSessionContext(sessionContext) {
|
|
60
|
+
const instance = ContextHolder.getInstance();
|
|
61
|
+
instance.sessionContext = sessionContext;
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
static setAppName(appName) {
|
|
59
65
|
ContextHolder.getInstance().appName = appName;
|
|
60
66
|
}
|
|
@@ -95,6 +101,12 @@ export class ContextHolder {
|
|
|
95
101
|
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
|
|
96
102
|
}
|
|
97
103
|
|
|
104
|
+
static isSessionPerTenantEnabled() {
|
|
105
|
+
var _ContextHolder$getIns3;
|
|
106
|
+
|
|
107
|
+
return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
|
|
108
|
+
}
|
|
109
|
+
|
|
98
110
|
static getAppName() {
|
|
99
111
|
return ContextHolder.getInstance().appName;
|
|
100
112
|
}
|
package/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from "./secutiry-poilicy";
|
|
2
2
|
export * from "./enums";
|
|
3
|
+
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction } from './utils';
|
|
3
4
|
import { ISamlRolesGroup } from "../teams/interfaces";
|
|
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
|
|
5
|
+
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
6
|
import { IGetUserAuthorizationResponse, IUserProfile } from "../users/interfaces";
|
|
6
7
|
/*****************************************
|
|
7
8
|
* Authentication
|
|
@@ -112,17 +113,17 @@ export declare function acceptInvitation(body: IAcceptInvitation): Promise<void>
|
|
|
112
113
|
* refresh token called as authenticated use, access and refresh tokens resolved by the cookies.
|
|
113
114
|
* the server will return ILoginResponse with new access Token and refresh token and store it in the browser cookies.
|
|
114
115
|
*/
|
|
115
|
-
export declare function refreshToken(
|
|
116
|
+
export declare function refreshToken(): Promise<ILoginResponse>;
|
|
116
117
|
/**
|
|
117
118
|
* refresh token called as authenticated use, access and refresh tokens resolved by the cookies.
|
|
118
119
|
* the server will return ILoginResponseV2 with new access Token and refresh token and store it in the browser cookies, as well as the tenants.
|
|
119
120
|
*/
|
|
120
|
-
export declare function refreshTokenV2(
|
|
121
|
+
export declare function refreshTokenV2(): Promise<ILoginResponseV2>;
|
|
121
122
|
/**
|
|
122
123
|
* refresh token called as authenticated use, access and refresh tokens resolved by the cookies.
|
|
123
124
|
* the server will return ILoginResponseV3 with new access Token and refresh token and store it in the browser cookies, as well as the tenants and the active tenant.
|
|
124
125
|
*/
|
|
125
|
-
export declare function refreshTokenV3(
|
|
126
|
+
export declare function refreshTokenV3(): Promise<ILoginResponseV3>;
|
|
126
127
|
/**
|
|
127
128
|
* logout from server, invalidate access and refresh token, remove it from cookies.
|
|
128
129
|
*/
|
|
@@ -680,9 +681,9 @@ export declare function preLoginV2(body: IPreLogin): Promise<IPreLoginWithIdpTyp
|
|
|
680
681
|
*/
|
|
681
682
|
export declare function oidcPostLoginV2(body: IOidcPostLoginV2): Promise<ILoginResponse>;
|
|
682
683
|
export declare function exchangeOAuthTokensV2(body: IExchangeOAuthTokens): Promise<ILoginResponseV3>;
|
|
683
|
-
export declare function silentOAuthRefreshTokenV2(
|
|
684
|
+
export declare function silentOAuthRefreshTokenV2(): Promise<ILoginResponseV3>;
|
|
684
685
|
export declare function exchangeOAuthTokens(body: IExchangeOAuthTokens): Promise<ILoginResponse>;
|
|
685
|
-
export declare function silentOAuthRefreshToken(
|
|
686
|
+
export declare function silentOAuthRefreshToken(): Promise<ILoginResponse>;
|
|
686
687
|
/**
|
|
687
688
|
* reset phone should be called in case user want to reset his phone number
|
|
688
689
|
* when using sms authentication strategy. a 6-digits code will be send to the user email.
|
package/auth/index.js
CHANGED
|
@@ -6,16 +6,16 @@ const _excluded = ["type"],
|
|
|
6
6
|
import { getTenants } from "../tenants";
|
|
7
7
|
export * from "./secutiry-poilicy";
|
|
8
8
|
export * from "./enums";
|
|
9
|
+
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction } from './utils';
|
|
9
10
|
import { urls } from "../constants";
|
|
10
11
|
import { ContextHolder } from "../ContextHolder";
|
|
11
12
|
import { Delete, Get, Patch, Post, Put } from "../fetch";
|
|
12
13
|
import { jwtDecode } from "../jwt";
|
|
13
14
|
import { LOAD_AUTHORIZATION_FF } from './interfaces';
|
|
14
|
-
import { getCurrentUserTenantsV3 } from '../users';
|
|
15
15
|
import { loadEntitlements } from '../entitlements';
|
|
16
16
|
import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
|
|
17
17
|
import { FeatureFlags } from "../feature-flags";
|
|
18
|
-
import { executeConditionalPromise } from "./utils";
|
|
18
|
+
import { executeConditionalPromise, getCurrentUserTenantsFunction, getTabTenantFromSessionStorage, setTabTenantInSessionStorage } from "./utils";
|
|
19
19
|
export async function generateLoginResponse(loginResponse) {
|
|
20
20
|
if (!loginResponse.accessToken) {
|
|
21
21
|
return loginResponse;
|
|
@@ -76,11 +76,15 @@ export async function generateLoginResponseV3(loginResponse) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
ContextHolder.setAccessToken(accessToken);
|
|
79
|
-
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(),
|
|
79
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsFunction()()]);
|
|
80
80
|
const decodedContent = accessToken ? jwtDecode(accessToken) : {};
|
|
81
81
|
|
|
82
82
|
const user = _extends({}, loginResponse, decodedContent, me);
|
|
83
83
|
|
|
84
|
+
if (ContextHolder.isSessionPerTenantEnabled()) {
|
|
85
|
+
setTabTenantInSessionStorage(user.tenantId);
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
ContextHolder.setUser(user);
|
|
85
89
|
return {
|
|
86
90
|
user,
|
|
@@ -106,7 +110,7 @@ export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
|
106
110
|
}
|
|
107
111
|
export async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
108
112
|
ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
109
|
-
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(),
|
|
113
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsFunction()()]);
|
|
110
114
|
const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
|
|
111
115
|
|
|
112
116
|
const user = _extends({
|
|
@@ -117,6 +121,10 @@ export async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
|
117
121
|
expiresIn: oauthResponse.expires_in || 300
|
|
118
122
|
});
|
|
119
123
|
|
|
124
|
+
if (ContextHolder.isSessionPerTenantEnabled()) {
|
|
125
|
+
setTabTenantInSessionStorage(user.tenantId);
|
|
126
|
+
}
|
|
127
|
+
|
|
120
128
|
ContextHolder.setUser(user);
|
|
121
129
|
return {
|
|
122
130
|
user,
|
|
@@ -180,16 +188,25 @@ export async function resendInvitationEmail(body) {
|
|
|
180
188
|
export async function acceptInvitation(body) {
|
|
181
189
|
return Post(`${urls.identity.users.v1}/invitation/accept`, body);
|
|
182
190
|
}
|
|
183
|
-
export async function refreshToken(
|
|
184
|
-
const
|
|
191
|
+
export async function refreshToken() {
|
|
192
|
+
const tabTenantId = getTabTenantFromSessionStorage();
|
|
193
|
+
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
|
|
194
|
+
tenantId: tabTenantId
|
|
195
|
+
});
|
|
185
196
|
return generateLoginResponse(data);
|
|
186
197
|
}
|
|
187
|
-
export async function refreshTokenV2(
|
|
188
|
-
const
|
|
198
|
+
export async function refreshTokenV2() {
|
|
199
|
+
const tabTenantId = getTabTenantFromSessionStorage();
|
|
200
|
+
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
|
|
201
|
+
tenantId: tabTenantId
|
|
202
|
+
});
|
|
189
203
|
return generateLoginResponseV2(data);
|
|
190
204
|
}
|
|
191
|
-
export async function refreshTokenV3(
|
|
192
|
-
const
|
|
205
|
+
export async function refreshTokenV3() {
|
|
206
|
+
const tabTenantId = getTabTenantFromSessionStorage();
|
|
207
|
+
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
|
|
208
|
+
tenantId: tabTenantId
|
|
209
|
+
});
|
|
193
210
|
return generateLoginResponseV3(data);
|
|
194
211
|
}
|
|
195
212
|
export async function logout() {
|
|
@@ -636,16 +653,22 @@ export async function exchangeOAuthTokensV2(body) {
|
|
|
636
653
|
const data = await Post(`${urls.oauth.v1}/token`, body);
|
|
637
654
|
return generateLoginResponseFromOAuthResponseV2(data);
|
|
638
655
|
}
|
|
639
|
-
export async function silentOAuthRefreshTokenV2(
|
|
640
|
-
const
|
|
656
|
+
export async function silentOAuthRefreshTokenV2() {
|
|
657
|
+
const tabTenantId = getTabTenantFromSessionStorage();
|
|
658
|
+
const data = await Post(`${urls.oauth.v1}/authorize/silent`, {
|
|
659
|
+
tenantId: tabTenantId
|
|
660
|
+
});
|
|
641
661
|
return generateLoginResponseFromOAuthResponseV2(data);
|
|
642
662
|
}
|
|
643
663
|
export async function exchangeOAuthTokens(body) {
|
|
644
664
|
const data = await Post(`${urls.oauth.v1}/token`, body);
|
|
645
665
|
return generateLoginResponseFromOAuthResponse(data);
|
|
646
666
|
}
|
|
647
|
-
export async function silentOAuthRefreshToken(
|
|
648
|
-
const
|
|
667
|
+
export async function silentOAuthRefreshToken() {
|
|
668
|
+
const tabTenantId = getTabTenantFromSessionStorage();
|
|
669
|
+
const data = await Post(`${urls.oauth.v1}/authorize/silent`, {
|
|
670
|
+
tenantId: tabTenantId
|
|
671
|
+
});
|
|
649
672
|
return generateLoginResponseFromOAuthResponse(data);
|
|
650
673
|
}
|
|
651
674
|
export async function resetPhoneNumber(body) {
|
|
@@ -713,6 +736,12 @@ export async function getMeAndEntitlements() {
|
|
|
713
736
|
}];
|
|
714
737
|
const promises = actions.map(action => executeConditionalPromise(action));
|
|
715
738
|
const [me, entitlements, authorization] = await Promise.all(promises);
|
|
739
|
+
const tabTenant = getTabTenantFromSessionStorage();
|
|
740
|
+
|
|
741
|
+
if (tabTenant) {
|
|
742
|
+
me.tenantId = tabTenant;
|
|
743
|
+
}
|
|
744
|
+
|
|
716
745
|
return _extends({}, me, authorization != null ? authorization : {}, {
|
|
717
746
|
entitlements
|
|
718
747
|
});
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -30,9 +30,6 @@ export declare type ILogin = {
|
|
|
30
30
|
recaptchaToken?: string;
|
|
31
31
|
invitationToken?: string;
|
|
32
32
|
};
|
|
33
|
-
export declare type IRefreshToken = {
|
|
34
|
-
tenantId?: string;
|
|
35
|
-
};
|
|
36
33
|
export declare type ILoginResponse = IUserProfile & {
|
|
37
34
|
mfaRequired: boolean;
|
|
38
35
|
accessToken: string;
|
package/auth/utils.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { GetCurrentUserTenantsResponse } from '../users/interfaces';
|
|
1
2
|
export interface ConditionalAction<T = any> {
|
|
2
3
|
action: () => Promise<T>;
|
|
3
4
|
shouldLoad: boolean;
|
|
4
5
|
}
|
|
5
6
|
export declare function executeConditionalPromise({ shouldLoad, action }: ConditionalAction): Promise<any>;
|
|
7
|
+
export declare function setTabTenantInSessionStorage(tenantId: string): void;
|
|
8
|
+
export declare function getTabTenantFromSessionStorage(): string | null;
|
|
9
|
+
export declare function getCurrentUserTenantsFunction(): () => Promise<GetCurrentUserTenantsResponse>;
|
package/auth/utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { ContextHolder } from '../ContextHolder';
|
|
2
|
+
import { USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF } from './constants';
|
|
3
|
+
import { FeatureFlags } from '../feature-flags';
|
|
4
|
+
import { getCurrentUserTenantsV1, getCurrentUserTenantsV3 } from '../users';
|
|
5
|
+
import { FRONTEGG_SEPARATE_TABS_BY_TENANT } from './constants';
|
|
1
6
|
;
|
|
2
7
|
export async function executeConditionalPromise({
|
|
3
8
|
shouldLoad,
|
|
@@ -5,4 +10,27 @@ export async function executeConditionalPromise({
|
|
|
5
10
|
}) {
|
|
6
11
|
if (!shouldLoad) return;
|
|
7
12
|
return await action();
|
|
13
|
+
}
|
|
14
|
+
export function setTabTenantInSessionStorage(tenantId) {
|
|
15
|
+
if (!tenantId) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
sessionStorage.setItem(FRONTEGG_SEPARATE_TABS_BY_TENANT, tenantId);
|
|
20
|
+
}
|
|
21
|
+
export function getTabTenantFromSessionStorage() {
|
|
22
|
+
if (ContextHolder.isSessionPerTenantEnabled()) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return sessionStorage.getItem(FRONTEGG_SEPARATE_TABS_BY_TENANT);
|
|
27
|
+
}
|
|
28
|
+
export function getCurrentUserTenantsFunction() {
|
|
29
|
+
const [useCurrentUserTenantsV1] = FeatureFlags.getFeatureFlags([USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF], ContextHolder.getAppName() || '');
|
|
30
|
+
|
|
31
|
+
if (ContextHolder.isSessionPerTenantEnabled()) {
|
|
32
|
+
return getCurrentUserTenantsV1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return useCurrentUserTenantsV1 ? getCurrentUserTenantsV1 : getCurrentUserTenantsV3;
|
|
8
36
|
}
|
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import * as userPhoneNumbers from "./user-phone-numbers";
|
|
|
26
26
|
import { ContextHolder, FronteggContext } from "./ContextHolder";
|
|
27
27
|
export * from "./interfaces";
|
|
28
28
|
export * from "./auth/interfaces";
|
|
29
|
+
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction } from './auth';
|
|
29
30
|
export * from "./teams/interfaces";
|
|
30
31
|
export * from "./metadata/interfaces";
|
|
31
32
|
export * from "./reports/interfaces";
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v3.1.
|
|
1
|
+
/** @license Frontegg v3.1.31
|
|
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.
|
|
@@ -31,6 +31,7 @@ import * as userPhoneNumbers from "./user-phone-numbers";
|
|
|
31
31
|
import { ContextHolder, FronteggContext } from "./ContextHolder";
|
|
32
32
|
export * from "./interfaces";
|
|
33
33
|
export * from "./auth/interfaces";
|
|
34
|
+
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction } from './auth';
|
|
34
35
|
export * from "./teams/interfaces";
|
|
35
36
|
export * from "./metadata/interfaces";
|
|
36
37
|
export * from "./reports/interfaces";
|
package/interfaces.d.ts
CHANGED
|
@@ -54,6 +54,9 @@ export interface MetadataHeaders {
|
|
|
54
54
|
framework?: FronteggFrameworks;
|
|
55
55
|
fronteggSdkVersion?: string;
|
|
56
56
|
}
|
|
57
|
+
export interface SessionContext {
|
|
58
|
+
enableSessionPerTenant?: boolean;
|
|
59
|
+
}
|
|
57
60
|
export interface ContextOptions {
|
|
58
61
|
baseUrl: string | ((url: string) => string);
|
|
59
62
|
clientId?: string;
|
|
@@ -18,6 +18,7 @@ class ContextHolder {
|
|
|
18
18
|
|
|
19
19
|
this.entitlementsOptions = null;
|
|
20
20
|
this.appName = null;
|
|
21
|
+
this.sessionContext = void 0;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
static getInstance() {
|
|
@@ -62,6 +63,11 @@ class ContextHolder {
|
|
|
62
63
|
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
static setSessionContext(sessionContext) {
|
|
67
|
+
const instance = ContextHolder.getInstance();
|
|
68
|
+
instance.sessionContext = sessionContext;
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
static setAppName(appName) {
|
|
66
72
|
ContextHolder.getInstance().appName = appName;
|
|
67
73
|
}
|
|
@@ -102,6 +108,12 @@ class ContextHolder {
|
|
|
102
108
|
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
|
|
103
109
|
}
|
|
104
110
|
|
|
111
|
+
static isSessionPerTenantEnabled() {
|
|
112
|
+
var _ContextHolder$getIns3;
|
|
113
|
+
|
|
114
|
+
return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
|
|
115
|
+
}
|
|
116
|
+
|
|
105
117
|
static getAppName() {
|
|
106
118
|
return ContextHolder.getInstance().appName;
|
|
107
119
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF = exports.FRONTEGG_SEPARATE_TABS_BY_TENANT = void 0;
|
|
7
|
+
const FRONTEGG_SEPARATE_TABS_BY_TENANT = 'FRONTEGG_SEPARATE_TABS_BY_TENANT';
|
|
8
|
+
exports.FRONTEGG_SEPARATE_TABS_BY_TENANT = FRONTEGG_SEPARATE_TABS_BY_TENANT;
|
|
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;
|
package/node/auth/index.js
CHANGED
|
@@ -153,7 +153,10 @@ var _exportNames = {
|
|
|
153
153
|
getMFAStrategiesConfig: true,
|
|
154
154
|
getUserAuthorization: true,
|
|
155
155
|
getMeV2: true,
|
|
156
|
-
getMeAndEntitlements: true
|
|
156
|
+
getMeAndEntitlements: true,
|
|
157
|
+
setTabTenantInSessionStorage: true,
|
|
158
|
+
getTabTenantFromSessionStorage: true,
|
|
159
|
+
getCurrentUserTenantsFunction: true
|
|
157
160
|
};
|
|
158
161
|
exports.OAuthLogout = OAuthLogout;
|
|
159
162
|
exports.acceptInvitation = acceptInvitation;
|
|
@@ -207,6 +210,12 @@ exports.generateLoginResponseV3 = generateLoginResponseV3;
|
|
|
207
210
|
exports.getActivateAccountStrategy = getActivateAccountStrategy;
|
|
208
211
|
exports.getCurrentUserSession = getCurrentUserSession;
|
|
209
212
|
exports.getCurrentUserSessions = getCurrentUserSessions;
|
|
213
|
+
Object.defineProperty(exports, "getCurrentUserTenantsFunction", {
|
|
214
|
+
enumerable: true,
|
|
215
|
+
get: function () {
|
|
216
|
+
return _utils.getCurrentUserTenantsFunction;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
210
219
|
exports.getCustomSocialLoginProvidersV1 = getCustomSocialLoginProvidersV1;
|
|
211
220
|
exports.getMFADevices = getMFADevices;
|
|
212
221
|
exports.getMFAStrategiesConfig = getMFAStrategiesConfig;
|
|
@@ -226,6 +235,12 @@ exports.getSessionConfigurations = getSessionConfigurations;
|
|
|
226
235
|
exports.getSocialLoginProviders = getSocialLoginProviders;
|
|
227
236
|
exports.getSocialLoginProvidersV2 = getSocialLoginProvidersV2;
|
|
228
237
|
exports.getSocialLoginProvidersV2ForAuthenticatedUser = getSocialLoginProvidersV2ForAuthenticatedUser;
|
|
238
|
+
Object.defineProperty(exports, "getTabTenantFromSessionStorage", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function () {
|
|
241
|
+
return _utils.getTabTenantFromSessionStorage;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
229
244
|
exports.getTenantAccessTokensData = getTenantAccessTokensData;
|
|
230
245
|
exports.getTenantApiTokensData = getTenantApiTokensData;
|
|
231
246
|
exports.getUserAccessTokensData = getUserAccessTokensData;
|
|
@@ -272,6 +287,12 @@ exports.resetPassword = resetPassword;
|
|
|
272
287
|
exports.resetPhoneNumber = resetPhoneNumber;
|
|
273
288
|
exports.revokeSessionsForUser = revokeSessionsForUser;
|
|
274
289
|
exports.setSSODefaultRoles = setSSODefaultRoles;
|
|
290
|
+
Object.defineProperty(exports, "setTabTenantInSessionStorage", {
|
|
291
|
+
enumerable: true,
|
|
292
|
+
get: function () {
|
|
293
|
+
return _utils.setTabTenantInSessionStorage;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
275
296
|
exports.signUpUser = signUpUser;
|
|
276
297
|
exports.silentOAuthRefreshToken = silentOAuthRefreshToken;
|
|
277
298
|
exports.silentOAuthRefreshTokenV2 = silentOAuthRefreshTokenV2;
|
|
@@ -338,6 +359,8 @@ Object.keys(_enums).forEach(function (key) {
|
|
|
338
359
|
});
|
|
339
360
|
});
|
|
340
361
|
|
|
362
|
+
var _utils = require("./utils");
|
|
363
|
+
|
|
341
364
|
var _constants = require("../constants");
|
|
342
365
|
|
|
343
366
|
var _ContextHolder = require("../ContextHolder");
|
|
@@ -348,16 +371,12 @@ var _jwt = require("../jwt");
|
|
|
348
371
|
|
|
349
372
|
var _interfaces = require("./interfaces");
|
|
350
373
|
|
|
351
|
-
var _users = require("../users");
|
|
352
|
-
|
|
353
374
|
var _entitlements = require("../entitlements");
|
|
354
375
|
|
|
355
376
|
var _interfaces2 = require("../entitlements/interfaces");
|
|
356
377
|
|
|
357
378
|
var _featureFlags = require("../feature-flags");
|
|
358
379
|
|
|
359
|
-
var _utils = require("./utils");
|
|
360
|
-
|
|
361
380
|
const _excluded = ["type"],
|
|
362
381
|
_excluded2 = ["type"],
|
|
363
382
|
_excluded3 = ["type"];
|
|
@@ -428,10 +447,14 @@ async function generateLoginResponseV3(loginResponse) {
|
|
|
428
447
|
|
|
429
448
|
_ContextHolder.ContextHolder.setAccessToken(accessToken);
|
|
430
449
|
|
|
431
|
-
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0,
|
|
450
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _utils.getCurrentUserTenantsFunction)()()]);
|
|
432
451
|
const decodedContent = accessToken ? (0, _jwt.jwtDecode)(accessToken) : {};
|
|
433
452
|
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
|
|
434
453
|
|
|
454
|
+
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
|
|
455
|
+
(0, _utils.setTabTenantInSessionStorage)(user.tenantId);
|
|
456
|
+
}
|
|
457
|
+
|
|
435
458
|
_ContextHolder.ContextHolder.setUser(user);
|
|
436
459
|
|
|
437
460
|
return {
|
|
@@ -462,7 +485,7 @@ async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
|
462
485
|
async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
463
486
|
_ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
464
487
|
|
|
465
|
-
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0,
|
|
488
|
+
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _utils.getCurrentUserTenantsFunction)()()]);
|
|
466
489
|
const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};
|
|
467
490
|
const user = (0, _extends2.default)({
|
|
468
491
|
mfaRequired: false,
|
|
@@ -472,6 +495,10 @@ async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
|
|
|
472
495
|
expiresIn: oauthResponse.expires_in || 300
|
|
473
496
|
});
|
|
474
497
|
|
|
498
|
+
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
|
|
499
|
+
(0, _utils.setTabTenantInSessionStorage)(user.tenantId);
|
|
500
|
+
}
|
|
501
|
+
|
|
475
502
|
_ContextHolder.ContextHolder.setUser(user);
|
|
476
503
|
|
|
477
504
|
return {
|
|
@@ -551,18 +578,27 @@ async function acceptInvitation(body) {
|
|
|
551
578
|
return (0, _fetch.Post)(`${_constants.urls.identity.users.v1}/invitation/accept`, body);
|
|
552
579
|
}
|
|
553
580
|
|
|
554
|
-
async function refreshToken(
|
|
555
|
-
const
|
|
581
|
+
async function refreshToken() {
|
|
582
|
+
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
|
|
583
|
+
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, {
|
|
584
|
+
tenantId: tabTenantId
|
|
585
|
+
});
|
|
556
586
|
return generateLoginResponse(data);
|
|
557
587
|
}
|
|
558
588
|
|
|
559
|
-
async function refreshTokenV2(
|
|
560
|
-
const
|
|
589
|
+
async function refreshTokenV2() {
|
|
590
|
+
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
|
|
591
|
+
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, {
|
|
592
|
+
tenantId: tabTenantId
|
|
593
|
+
});
|
|
561
594
|
return generateLoginResponseV2(data);
|
|
562
595
|
}
|
|
563
596
|
|
|
564
|
-
async function refreshTokenV3(
|
|
565
|
-
const
|
|
597
|
+
async function refreshTokenV3() {
|
|
598
|
+
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
|
|
599
|
+
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, {
|
|
600
|
+
tenantId: tabTenantId
|
|
601
|
+
});
|
|
566
602
|
return generateLoginResponseV3(data);
|
|
567
603
|
}
|
|
568
604
|
|
|
@@ -1112,8 +1148,11 @@ async function exchangeOAuthTokensV2(body) {
|
|
|
1112
1148
|
return generateLoginResponseFromOAuthResponseV2(data);
|
|
1113
1149
|
}
|
|
1114
1150
|
|
|
1115
|
-
async function silentOAuthRefreshTokenV2(
|
|
1116
|
-
const
|
|
1151
|
+
async function silentOAuthRefreshTokenV2() {
|
|
1152
|
+
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
|
|
1153
|
+
const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`, {
|
|
1154
|
+
tenantId: tabTenantId
|
|
1155
|
+
});
|
|
1117
1156
|
return generateLoginResponseFromOAuthResponseV2(data);
|
|
1118
1157
|
}
|
|
1119
1158
|
|
|
@@ -1122,8 +1161,11 @@ async function exchangeOAuthTokens(body) {
|
|
|
1122
1161
|
return generateLoginResponseFromOAuthResponse(data);
|
|
1123
1162
|
}
|
|
1124
1163
|
|
|
1125
|
-
async function silentOAuthRefreshToken(
|
|
1126
|
-
const
|
|
1164
|
+
async function silentOAuthRefreshToken() {
|
|
1165
|
+
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
|
|
1166
|
+
const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`, {
|
|
1167
|
+
tenantId: tabTenantId
|
|
1168
|
+
});
|
|
1127
1169
|
return generateLoginResponseFromOAuthResponse(data);
|
|
1128
1170
|
}
|
|
1129
1171
|
|
|
@@ -1209,6 +1251,12 @@ async function getMeAndEntitlements() {
|
|
|
1209
1251
|
}];
|
|
1210
1252
|
const promises = actions.map(action => (0, _utils.executeConditionalPromise)(action));
|
|
1211
1253
|
const [me, entitlements, authorization] = await Promise.all(promises);
|
|
1254
|
+
const tabTenant = (0, _utils.getTabTenantFromSessionStorage)();
|
|
1255
|
+
|
|
1256
|
+
if (tabTenant) {
|
|
1257
|
+
me.tenantId = tabTenant;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1212
1260
|
return (0, _extends2.default)({}, me, authorization != null ? authorization : {}, {
|
|
1213
1261
|
entitlements
|
|
1214
1262
|
});
|
package/node/auth/utils.js
CHANGED
|
@@ -4,6 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.executeConditionalPromise = executeConditionalPromise;
|
|
7
|
+
exports.getCurrentUserTenantsFunction = getCurrentUserTenantsFunction;
|
|
8
|
+
exports.getTabTenantFromSessionStorage = getTabTenantFromSessionStorage;
|
|
9
|
+
exports.setTabTenantInSessionStorage = setTabTenantInSessionStorage;
|
|
10
|
+
|
|
11
|
+
var _ContextHolder = require("../ContextHolder");
|
|
12
|
+
|
|
13
|
+
var _constants = require("./constants");
|
|
14
|
+
|
|
15
|
+
var _featureFlags = require("../feature-flags");
|
|
16
|
+
|
|
17
|
+
var _users = require("../users");
|
|
18
|
+
|
|
7
19
|
;
|
|
8
20
|
|
|
9
21
|
async function executeConditionalPromise({
|
|
@@ -12,4 +24,30 @@ async function executeConditionalPromise({
|
|
|
12
24
|
}) {
|
|
13
25
|
if (!shouldLoad) return;
|
|
14
26
|
return await action();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function setTabTenantInSessionStorage(tenantId) {
|
|
30
|
+
if (!tenantId) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
sessionStorage.setItem(_constants.FRONTEGG_SEPARATE_TABS_BY_TENANT, tenantId);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getTabTenantFromSessionStorage() {
|
|
38
|
+
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return sessionStorage.getItem(_constants.FRONTEGG_SEPARATE_TABS_BY_TENANT);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getCurrentUserTenantsFunction() {
|
|
46
|
+
const [useCurrentUserTenantsV1] = _featureFlags.FeatureFlags.getFeatureFlags([_constants.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF], _ContextHolder.ContextHolder.getAppName() || '');
|
|
47
|
+
|
|
48
|
+
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
|
|
49
|
+
return _users.getCurrentUserTenantsV1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return useCurrentUserTenantsV1 ? _users.getCurrentUserTenantsV1 : _users.getCurrentUserTenantsV3;
|
|
15
53
|
}
|
package/node/constants.js
CHANGED
package/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v3.1.
|
|
1
|
+
/** @license Frontegg v3.1.31
|
|
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.
|
|
@@ -13,6 +13,9 @@ var _exportNames = {
|
|
|
13
13
|
AuthStrategyEnum: true,
|
|
14
14
|
MachineToMachineAuthStrategy: true,
|
|
15
15
|
SocialLoginProviders: true,
|
|
16
|
+
setTabTenantInSessionStorage: true,
|
|
17
|
+
getTabTenantFromSessionStorage: true,
|
|
18
|
+
getCurrentUserTenantsFunction: true,
|
|
16
19
|
fetch: true,
|
|
17
20
|
ISubscriptionCancellationPolicy: true,
|
|
18
21
|
ISubscriptionStatus: true,
|
|
@@ -83,6 +86,24 @@ Object.defineProperty(exports, "SocialLoginProviders", {
|
|
|
83
86
|
}
|
|
84
87
|
});
|
|
85
88
|
exports.fetch = exports.default = exports.api = void 0;
|
|
89
|
+
Object.defineProperty(exports, "getCurrentUserTenantsFunction", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return auth.getCurrentUserTenantsFunction;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "getTabTenantFromSessionStorage", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return auth.getTabTenantFromSessionStorage;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "setTabTenantInSessionStorage", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return auth.setTabTenantInSessionStorage;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
86
107
|
|
|
87
108
|
var auth = _interopRequireWildcard(require("./auth"));
|
|
88
109
|
|
package/node/tenants/index.js
CHANGED
|
@@ -21,7 +21,15 @@ var _fetch = require("../fetch");
|
|
|
21
21
|
|
|
22
22
|
var _constants = require("../constants");
|
|
23
23
|
|
|
24
|
+
var _utils = require("../auth/utils");
|
|
25
|
+
|
|
26
|
+
var _ContextHolder = require("../ContextHolder");
|
|
27
|
+
|
|
24
28
|
async function switchTenant(body) {
|
|
29
|
+
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
|
|
30
|
+
(0, _utils.setTabTenantInSessionStorage)(body.tenantId);
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
return (0, _fetch.Put)(`${_constants.urls.identity.users.v1}/tenant`, body);
|
|
26
34
|
}
|
|
27
35
|
|
package/node/users/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.GetUserJwt = GetUserJwt;
|
|
9
|
+
exports.getCurrentUserTenantsV1 = getCurrentUserTenantsV1;
|
|
9
10
|
exports.getCurrentUserTenantsV3 = getCurrentUserTenantsV3;
|
|
10
11
|
exports.getUsersGroups = getUsersGroups;
|
|
11
12
|
exports.getUsersRoles = getUsersRoles;
|
|
@@ -58,6 +59,12 @@ async function getCurrentUserTenantsV3(options) {
|
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
async function getCurrentUserTenantsV1(options) {
|
|
63
|
+
return (0, _fetch.Get)(_constants.urls.identity.users.tenants.me.v1, undefined, {
|
|
64
|
+
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
async function sendResetBreachedPasswordEmails() {
|
|
62
69
|
return (0, _fetch.Post)(_constants.urls.identity.users.passwords.resetBreachedPasswords.v1);
|
|
63
70
|
}
|
package/package.json
CHANGED
package/tenants/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { extractHeadersFromOptions, Get, Post, Put } from "../fetch";
|
|
3
3
|
import { urls } from "../constants";
|
|
4
|
+
import { setTabTenantInSessionStorage } from '../auth/utils';
|
|
5
|
+
import { ContextHolder } from '../ContextHolder';
|
|
4
6
|
export async function switchTenant(body) {
|
|
7
|
+
if (ContextHolder.isSessionPerTenantEnabled()) {
|
|
8
|
+
setTabTenantInSessionStorage(body.tenantId);
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
return Put(`${urls.identity.users.v1}/tenant`, body);
|
|
6
12
|
}
|
|
7
13
|
export async function getTenants() {
|
package/users/index.d.ts
CHANGED
|
@@ -5,6 +5,13 @@ export declare function getUsersV2(queryParams: ISearchUserQueryParamsV2, option
|
|
|
5
5
|
export declare function getUsersV3(queryParams: ISearchUserQueryParamsV3, options?: UserJwtOptions): Promise<FronteggPaginationWrapper<IUsersV3Data>>;
|
|
6
6
|
export declare function getUsersRoles(queryParams: GetUsersRolesParams, options?: UserJwtOptions): Promise<GetUserRolesResponse[]>;
|
|
7
7
|
export declare function getUsersGroups(queryParams: GetUserGroupsParams, options?: UserJwtOptions): Promise<GetUserGroupsResponse[]>;
|
|
8
|
+
/**
|
|
9
|
+
* get user tenant and user tenants by user active tenant
|
|
10
|
+
*/
|
|
8
11
|
export declare function getCurrentUserTenantsV3(options?: UserJwtOptions): Promise<GetCurrentUserTenantsResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* get user tenant and user tenants by context tenant
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCurrentUserTenantsV1(options?: UserJwtOptions): Promise<GetCurrentUserTenantsResponse>;
|
|
9
16
|
export declare function sendResetBreachedPasswordEmails(): Promise<void>;
|
|
10
17
|
export declare function updateUserProfileV2(body: Partial<IUpdateUserDto>): Promise<IUserProfile>;
|
package/users/index.js
CHANGED
|
@@ -33,6 +33,11 @@ export async function getCurrentUserTenantsV3(options) {
|
|
|
33
33
|
headers: extractHeadersFromOptions(options)
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
+
export async function getCurrentUserTenantsV1(options) {
|
|
37
|
+
return Get(urls.identity.users.tenants.me.v1, undefined, {
|
|
38
|
+
headers: extractHeadersFromOptions(options)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
36
41
|
export async function sendResetBreachedPasswordEmails() {
|
|
37
42
|
return Post(urls.identity.users.passwords.resetBreachedPasswords.v1);
|
|
38
43
|
}
|