@frontegg/rest-api 3.0.118 → 3.0.119
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 +2 -1
- package/auth/index.js +21 -0
- package/auth/interfaces.d.ts +5 -0
- package/constants.d.ts +8 -0
- package/constants.js +8 -0
- package/index.js +1 -1
- package/node/auth/index.js +26 -0
- package/node/constants.js +8 -0
- package/node/index.js +1 -1
- package/node/users/index.js +16 -0
- package/package.json +1 -1
- package/users/index.d.ts +3 -1
- package/users/index.js +12 -0
- package/users/interfaces.d.ts +14 -0
package/auth/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from "./secutiry-poilicy";
|
|
2
2
|
export * from "./enums";
|
|
3
3
|
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 } from
|
|
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 } from './interfaces';
|
|
5
5
|
/*****************************************
|
|
6
6
|
* Authentication
|
|
7
7
|
*****************************************/
|
|
8
8
|
export declare function generateLoginResponse(loginResponse: ILoginResponse): Promise<ILoginResponse>;
|
|
9
9
|
export declare function generateLoginResponseV2(loginResponse: ILoginResponse): Promise<ILoginResponseV2>;
|
|
10
|
+
export declare function generateLoginResponseV3(loginResponse: ILoginResponse): Promise<ILoginResponseV3>;
|
|
10
11
|
export declare function generateLoginResponseFromOAuthResponse(oauthResponse: IOAuthTokenResponse): Promise<ILoginResponse>;
|
|
11
12
|
/**
|
|
12
13
|
* Check if requested email address has sso configuration
|
package/auth/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { urls } from "../constants";
|
|
|
9
9
|
import { ContextHolder } from "../ContextHolder";
|
|
10
10
|
import { Delete, Get, Patch, Post, Put } from "../fetch";
|
|
11
11
|
import { jwtDecode } from "../jwt";
|
|
12
|
+
import { getCurrentUserTenantsV3 } from '../users';
|
|
12
13
|
export async function generateLoginResponse(loginResponse) {
|
|
13
14
|
if (!loginResponse.accessToken) {
|
|
14
15
|
return loginResponse;
|
|
@@ -42,6 +43,26 @@ export async function generateLoginResponseV2(loginResponse) {
|
|
|
42
43
|
tenants
|
|
43
44
|
};
|
|
44
45
|
}
|
|
46
|
+
export async function generateLoginResponseV3(loginResponse) {
|
|
47
|
+
if (!loginResponse.accessToken) {
|
|
48
|
+
return {
|
|
49
|
+
user: loginResponse
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ContextHolder.setAccessToken(loginResponse.accessToken);
|
|
54
|
+
const [me, currentUserTenants] = await Promise.all([Get(`${urls.identity.users.v2}/me`), getCurrentUserTenantsV3()]);
|
|
55
|
+
const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
|
|
56
|
+
|
|
57
|
+
const user = _extends({}, loginResponse, decodedContent, me);
|
|
58
|
+
|
|
59
|
+
ContextHolder.setUser(user);
|
|
60
|
+
return {
|
|
61
|
+
user,
|
|
62
|
+
tenants: currentUserTenants.tenants,
|
|
63
|
+
activeTenant: currentUserTenants.activeTenant
|
|
64
|
+
};
|
|
65
|
+
}
|
|
45
66
|
export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
46
67
|
ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
47
68
|
const me = await Get(`${urls.identity.users.v2}/me`);
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -48,6 +48,11 @@ export declare type ILoginResponseV2 = {
|
|
|
48
48
|
user: ILoginResponse;
|
|
49
49
|
tenants?: ITenantsResponse[];
|
|
50
50
|
};
|
|
51
|
+
export declare type ILoginResponseV3 = {
|
|
52
|
+
user: ILoginResponse;
|
|
53
|
+
tenants?: ITenantsResponse[];
|
|
54
|
+
activeTenant?: ITenantsResponse;
|
|
55
|
+
};
|
|
51
56
|
export declare type ILoginWithMfa = {
|
|
52
57
|
mfaToken: string;
|
|
53
58
|
value: string;
|
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
|
@@ -15,6 +15,14 @@ export const urls = {
|
|
|
15
15
|
roles: {
|
|
16
16
|
v3: '/identity/resources/users/v3/roles'
|
|
17
17
|
},
|
|
18
|
+
groups: {
|
|
19
|
+
v3: '/identity/resources/users/v3/groups'
|
|
20
|
+
},
|
|
21
|
+
tenants: {
|
|
22
|
+
me: {
|
|
23
|
+
v3: '/identity/resources/users/v3/me/tenants'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
18
26
|
apiTokens: {
|
|
19
27
|
v1: '/identity/resources/users/api-tokens/v1'
|
|
20
28
|
},
|
package/index.js
CHANGED
package/node/auth/index.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
var _exportNames = {
|
|
9
9
|
generateLoginResponse: true,
|
|
10
10
|
generateLoginResponseV2: true,
|
|
11
|
+
generateLoginResponseV3: true,
|
|
11
12
|
generateLoginResponseFromOAuthResponse: true,
|
|
12
13
|
preLogin: true,
|
|
13
14
|
preLoginWithIdpType: true,
|
|
@@ -171,6 +172,7 @@ exports.forgotPassword = forgotPassword;
|
|
|
171
172
|
exports.generateLoginResponse = generateLoginResponse;
|
|
172
173
|
exports.generateLoginResponseFromOAuthResponse = generateLoginResponseFromOAuthResponse;
|
|
173
174
|
exports.generateLoginResponseV2 = generateLoginResponseV2;
|
|
175
|
+
exports.generateLoginResponseV3 = generateLoginResponseV3;
|
|
174
176
|
exports.getActivateAccountStrategy = getActivateAccountStrategy;
|
|
175
177
|
exports.getCurrentUserSession = getCurrentUserSession;
|
|
176
178
|
exports.getCurrentUserSessions = getCurrentUserSessions;
|
|
@@ -296,6 +298,8 @@ var _fetch = require("../fetch");
|
|
|
296
298
|
|
|
297
299
|
var _jwt = require("../jwt");
|
|
298
300
|
|
|
301
|
+
var _users = require("../users");
|
|
302
|
+
|
|
299
303
|
const _excluded = ["type"],
|
|
300
304
|
_excluded2 = ["type"];
|
|
301
305
|
|
|
@@ -336,6 +340,28 @@ async function generateLoginResponseV2(loginResponse) {
|
|
|
336
340
|
};
|
|
337
341
|
}
|
|
338
342
|
|
|
343
|
+
async function generateLoginResponseV3(loginResponse) {
|
|
344
|
+
if (!loginResponse.accessToken) {
|
|
345
|
+
return {
|
|
346
|
+
user: loginResponse
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
_ContextHolder.ContextHolder.setAccessToken(loginResponse.accessToken);
|
|
351
|
+
|
|
352
|
+
const [me, currentUserTenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _users.getCurrentUserTenantsV3)()]);
|
|
353
|
+
const decodedContent = loginResponse.accessToken ? (0, _jwt.jwtDecode)(loginResponse.accessToken) : {};
|
|
354
|
+
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
|
|
355
|
+
|
|
356
|
+
_ContextHolder.ContextHolder.setUser(user);
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
user,
|
|
360
|
+
tenants: currentUserTenants.tenants,
|
|
361
|
+
activeTenant: currentUserTenants.activeTenant
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
339
365
|
async function generateLoginResponseFromOAuthResponse(oauthResponse) {
|
|
340
366
|
_ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token);
|
|
341
367
|
|
package/node/constants.js
CHANGED
|
@@ -21,6 +21,14 @@ const urls = {
|
|
|
21
21
|
roles: {
|
|
22
22
|
v3: '/identity/resources/users/v3/roles'
|
|
23
23
|
},
|
|
24
|
+
groups: {
|
|
25
|
+
v3: '/identity/resources/users/v3/groups'
|
|
26
|
+
},
|
|
27
|
+
tenants: {
|
|
28
|
+
me: {
|
|
29
|
+
v3: '/identity/resources/users/v3/me/tenants'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
24
32
|
apiTokens: {
|
|
25
33
|
v1: '/identity/resources/users/api-tokens/v1'
|
|
26
34
|
},
|
package/node/index.js
CHANGED
package/node/users/index.js
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.GetUserJwt = GetUserJwt;
|
|
9
|
+
exports.getCurrentUserTenantsV3 = getCurrentUserTenantsV3;
|
|
10
|
+
exports.getUsersGroups = getUsersGroups;
|
|
9
11
|
exports.getUsersRoles = getUsersRoles;
|
|
10
12
|
exports.getUsersV3 = getUsersV3;
|
|
11
13
|
|
|
@@ -31,4 +33,18 @@ async function getUsersRoles(queryParams, options) {
|
|
|
31
33
|
}), {
|
|
32
34
|
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
33
35
|
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function getUsersGroups(queryParams, options) {
|
|
39
|
+
return (0, _fetch.Get)(_constants.urls.identity.users.groups.v3, (0, _extends2.default)({}, queryParams, {
|
|
40
|
+
ids: queryParams.ids.join(",")
|
|
41
|
+
}), {
|
|
42
|
+
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function getCurrentUserTenantsV3(options) {
|
|
47
|
+
return (0, _fetch.Get)(_constants.urls.identity.users.tenants.me.v3, {
|
|
48
|
+
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
49
|
+
});
|
|
34
50
|
}
|
package/package.json
CHANGED
package/users/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { GetUserJwtRequestDto, GetUserJwtResponseDto, GetUserRolesResponse, GetUsersRolesParams, ISearchUserQueryParamsV3, IUsersV3Data } from "./interfaces";
|
|
1
|
+
import { GetCurrentUserTenantsResponse, GetUserGroupsParams, GetUserGroupsResponse, GetUserJwtRequestDto, GetUserJwtResponseDto, GetUserRolesResponse, GetUsersRolesParams, ISearchUserQueryParamsV3, IUsersV3Data } from "./interfaces";
|
|
2
2
|
import { FronteggPaginationWrapper, UserJwtOptions } from "../interfaces";
|
|
3
3
|
export declare function GetUserJwt(body: GetUserJwtRequestDto): Promise<GetUserJwtResponseDto>;
|
|
4
4
|
export declare function getUsersV3(queryParams: ISearchUserQueryParamsV3, options?: UserJwtOptions): Promise<FronteggPaginationWrapper<IUsersV3Data>>;
|
|
5
5
|
export declare function getUsersRoles(queryParams: GetUsersRolesParams, options?: UserJwtOptions): Promise<GetUserRolesResponse[]>;
|
|
6
|
+
export declare function getUsersGroups(queryParams: GetUserGroupsParams, options?: UserJwtOptions): Promise<GetUserGroupsResponse[]>;
|
|
7
|
+
export declare function getCurrentUserTenantsV3(options?: UserJwtOptions): Promise<GetCurrentUserTenantsResponse>;
|
package/users/index.js
CHANGED
|
@@ -15,4 +15,16 @@ export async function getUsersRoles(queryParams, options) {
|
|
|
15
15
|
}), {
|
|
16
16
|
headers: extractHeadersFromOptions(options)
|
|
17
17
|
});
|
|
18
|
+
}
|
|
19
|
+
export async function getUsersGroups(queryParams, options) {
|
|
20
|
+
return Get(urls.identity.users.groups.v3, _extends({}, queryParams, {
|
|
21
|
+
ids: queryParams.ids.join(",")
|
|
22
|
+
}), {
|
|
23
|
+
headers: extractHeadersFromOptions(options)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export async function getCurrentUserTenantsV3(options) {
|
|
27
|
+
return Get(urls.identity.users.tenants.me.v3, {
|
|
28
|
+
headers: extractHeadersFromOptions(options)
|
|
29
|
+
});
|
|
18
30
|
}
|
package/users/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PaginationOrderEnum } from '../interfaces';
|
|
2
|
+
import { ITenantsResponse } from '../tenants/interfaces';
|
|
2
3
|
export declare enum SortByEnum {
|
|
3
4
|
createdAt = "createdAt",
|
|
4
5
|
name = "name",
|
|
@@ -60,3 +61,16 @@ export interface GetUserRolesResponse {
|
|
|
60
61
|
userId: string;
|
|
61
62
|
roleIds: string[];
|
|
62
63
|
}
|
|
64
|
+
export interface GetUserGroupsParams {
|
|
65
|
+
ids: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface GetUserGroupsResponse {
|
|
68
|
+
vendorId: string;
|
|
69
|
+
tenantId: string;
|
|
70
|
+
userId: string;
|
|
71
|
+
groupIds: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface GetCurrentUserTenantsResponse {
|
|
74
|
+
tenants: ITenantsResponse[];
|
|
75
|
+
activeTenant: ITenantsResponse;
|
|
76
|
+
}
|