@frontegg/rest-api
Advanced tools
Comparing version 3.0.118 to 3.0.119
export * from "./secutiry-poilicy"; | ||
export * from "./enums"; | ||
import { ISamlRolesGroup } from "../teams/interfaces"; | ||
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 "./interfaces"; | ||
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'; | ||
/***************************************** | ||
@@ -10,2 +10,3 @@ * Authentication | ||
export declare function generateLoginResponseV2(loginResponse: ILoginResponse): Promise<ILoginResponseV2>; | ||
export declare function generateLoginResponseV3(loginResponse: ILoginResponse): Promise<ILoginResponseV3>; | ||
export declare function generateLoginResponseFromOAuthResponse(oauthResponse: IOAuthTokenResponse): Promise<ILoginResponse>; | ||
@@ -12,0 +13,0 @@ /** |
@@ -12,2 +12,3 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
import { jwtDecode } from "../jwt"; | ||
import { getCurrentUserTenantsV3 } from '../users'; | ||
export async function generateLoginResponse(loginResponse) { | ||
@@ -46,2 +47,22 @@ if (!loginResponse.accessToken) { | ||
} | ||
export async function generateLoginResponseV3(loginResponse) { | ||
if (!loginResponse.accessToken) { | ||
return { | ||
user: loginResponse | ||
}; | ||
} | ||
ContextHolder.setAccessToken(loginResponse.accessToken); | ||
const [me, currentUserTenants] = await Promise.all([Get(`${urls.identity.users.v2}/me`), getCurrentUserTenantsV3()]); | ||
const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {}; | ||
const user = _extends({}, loginResponse, decodedContent, me); | ||
ContextHolder.setUser(user); | ||
return { | ||
user, | ||
tenants: currentUserTenants.tenants, | ||
activeTenant: currentUserTenants.activeTenant | ||
}; | ||
} | ||
export async function generateLoginResponseFromOAuthResponse(oauthResponse) { | ||
@@ -48,0 +69,0 @@ ContextHolder.setAccessToken(oauthResponse.id_token); |
@@ -51,2 +51,7 @@ import { ITenantsResponse, IUserProfile } from ".."; | ||
}; | ||
export declare type ILoginResponseV3 = { | ||
user: ILoginResponse; | ||
tenants?: ITenantsResponse[]; | ||
activeTenant?: ITenantsResponse; | ||
}; | ||
export declare type ILoginWithMfa = { | ||
@@ -53,0 +58,0 @@ mfaToken: string; |
@@ -18,2 +18,10 @@ export declare const urls: { | ||
}; | ||
groups: { | ||
v3: string; | ||
}; | ||
tenants: { | ||
me: { | ||
v3: string; | ||
}; | ||
}; | ||
apiTokens: { | ||
@@ -20,0 +28,0 @@ v1: string; |
@@ -18,2 +18,10 @@ export const urls = { | ||
}, | ||
groups: { | ||
v3: '/identity/resources/users/v3/groups' | ||
}, | ||
tenants: { | ||
me: { | ||
v3: '/identity/resources/users/v3/me/tenants' | ||
} | ||
}, | ||
apiTokens: { | ||
@@ -20,0 +28,0 @@ v1: '/identity/resources/users/api-tokens/v1' |
@@ -1,2 +0,2 @@ | ||
/** @license Frontegg v3.0.118 | ||
/** @license Frontegg v3.0.119 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -11,2 +11,3 @@ "use strict"; | ||
generateLoginResponseV2: true, | ||
generateLoginResponseV3: true, | ||
generateLoginResponseFromOAuthResponse: true, | ||
@@ -175,2 +176,3 @@ preLogin: true, | ||
exports.generateLoginResponseV2 = generateLoginResponseV2; | ||
exports.generateLoginResponseV3 = generateLoginResponseV3; | ||
exports.getActivateAccountStrategy = getActivateAccountStrategy; | ||
@@ -301,2 +303,4 @@ exports.getCurrentUserSession = getCurrentUserSession; | ||
var _users = require("../users"); | ||
const _excluded = ["type"], | ||
@@ -342,2 +346,24 @@ _excluded2 = ["type"]; | ||
async function generateLoginResponseV3(loginResponse) { | ||
if (!loginResponse.accessToken) { | ||
return { | ||
user: loginResponse | ||
}; | ||
} | ||
_ContextHolder.ContextHolder.setAccessToken(loginResponse.accessToken); | ||
const [me, currentUserTenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _users.getCurrentUserTenantsV3)()]); | ||
const decodedContent = loginResponse.accessToken ? (0, _jwt.jwtDecode)(loginResponse.accessToken) : {}; | ||
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me); | ||
_ContextHolder.ContextHolder.setUser(user); | ||
return { | ||
user, | ||
tenants: currentUserTenants.tenants, | ||
activeTenant: currentUserTenants.activeTenant | ||
}; | ||
} | ||
async function generateLoginResponseFromOAuthResponse(oauthResponse) { | ||
@@ -344,0 +370,0 @@ _ContextHolder.ContextHolder.setAccessToken(oauthResponse.id_token); |
@@ -24,2 +24,10 @@ "use strict"; | ||
}, | ||
groups: { | ||
v3: '/identity/resources/users/v3/groups' | ||
}, | ||
tenants: { | ||
me: { | ||
v3: '/identity/resources/users/v3/me/tenants' | ||
} | ||
}, | ||
apiTokens: { | ||
@@ -26,0 +34,0 @@ v1: '/identity/resources/users/api-tokens/v1' |
@@ -1,2 +0,2 @@ | ||
/** @license Frontegg v3.0.118 | ||
/** @license Frontegg v3.0.119 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -9,2 +9,4 @@ "use strict"; | ||
exports.GetUserJwt = GetUserJwt; | ||
exports.getCurrentUserTenantsV3 = getCurrentUserTenantsV3; | ||
exports.getUsersGroups = getUsersGroups; | ||
exports.getUsersRoles = getUsersRoles; | ||
@@ -35,2 +37,16 @@ exports.getUsersV3 = getUsersV3; | ||
}); | ||
} | ||
async function getUsersGroups(queryParams, options) { | ||
return (0, _fetch.Get)(_constants.urls.identity.users.groups.v3, (0, _extends2.default)({}, queryParams, { | ||
ids: queryParams.ids.join(",") | ||
}), { | ||
headers: (0, _fetch.extractHeadersFromOptions)(options) | ||
}); | ||
} | ||
async function getCurrentUserTenantsV3(options) { | ||
return (0, _fetch.Get)(_constants.urls.identity.users.tenants.me.v3, { | ||
headers: (0, _fetch.extractHeadersFromOptions)(options) | ||
}); | ||
} |
{ | ||
"name": "@frontegg/rest-api", | ||
"version": "3.0.118", | ||
"version": "3.0.119", | ||
"main": "./node/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,2 +0,2 @@ | ||
import { GetUserJwtRequestDto, GetUserJwtResponseDto, GetUserRolesResponse, GetUsersRolesParams, ISearchUserQueryParamsV3, IUsersV3Data } from "./interfaces"; | ||
import { GetCurrentUserTenantsResponse, GetUserGroupsParams, GetUserGroupsResponse, GetUserJwtRequestDto, GetUserJwtResponseDto, GetUserRolesResponse, GetUsersRolesParams, ISearchUserQueryParamsV3, IUsersV3Data } from "./interfaces"; | ||
import { FronteggPaginationWrapper, UserJwtOptions } from "../interfaces"; | ||
@@ -6,1 +6,3 @@ export declare function GetUserJwt(body: GetUserJwtRequestDto): Promise<GetUserJwtResponseDto>; | ||
export declare function getUsersRoles(queryParams: GetUsersRolesParams, options?: UserJwtOptions): Promise<GetUserRolesResponse[]>; | ||
export declare function getUsersGroups(queryParams: GetUserGroupsParams, options?: UserJwtOptions): Promise<GetUserGroupsResponse[]>; | ||
export declare function getCurrentUserTenantsV3(options?: UserJwtOptions): Promise<GetCurrentUserTenantsResponse>; |
@@ -18,2 +18,14 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
}); | ||
} | ||
export async function getUsersGroups(queryParams, options) { | ||
return Get(urls.identity.users.groups.v3, _extends({}, queryParams, { | ||
ids: queryParams.ids.join(",") | ||
}), { | ||
headers: extractHeadersFromOptions(options) | ||
}); | ||
} | ||
export async function getCurrentUserTenantsV3(options) { | ||
return Get(urls.identity.users.tenants.me.v3, { | ||
headers: extractHeadersFromOptions(options) | ||
}); | ||
} |
import { PaginationOrderEnum } from '../interfaces'; | ||
import { ITenantsResponse } from '../tenants/interfaces'; | ||
export declare enum SortByEnum { | ||
@@ -63,1 +64,14 @@ createdAt = "createdAt", | ||
} | ||
export interface GetUserGroupsParams { | ||
ids: string[]; | ||
} | ||
export interface GetUserGroupsResponse { | ||
vendorId: string; | ||
tenantId: string; | ||
userId: string; | ||
groupIds: string[]; | ||
} | ||
export interface GetCurrentUserTenantsResponse { | ||
tenants: ITenantsResponse[]; | ||
activeTenant: ITenantsResponse; | ||
} |
342838
9560