Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frontegg/rest-api

Package Overview
Dependencies
Maintainers
1
Versions
616
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontegg/rest-api - npm Package Compare versions

Comparing version 3.0.141 to 3.1.1

5

auth/index.d.ts

@@ -5,2 +5,3 @@ export * from "./secutiry-poilicy";

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';
import { IUserDTO } from "../users/interfaces";
/*****************************************

@@ -736,1 +737,5 @@ * Authentication

export declare function getMFAStrategiesConfig(): Promise<IMFAStrategiesResponse>;
/**
* @returns me response with entitlements inside user.entitlements
*/
export declare function getMeAndEntitlements(): Promise<IUserDTO>;

44

auth/index.js

@@ -23,3 +23,3 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";

ContextHolder.setAccessToken(loginResponse.accessToken);
const me = await Get(`${urls.identity.users.v2}/me`);
const me = await getMeAndEntitlements();
const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};

@@ -40,3 +40,3 @@

ContextHolder.setAccessToken(loginResponse.accessToken);
const [me, tenants] = await Promise.all([Get(`${urls.identity.users.v2}/me`), getTenants()]);
const [me, tenants] = await Promise.all([getMeAndEntitlements(), getTenants()]);
const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};

@@ -53,3 +53,3 @@

async function shouldLoadEntitlements() {
function shouldLoadEntitlements() {
if (!ContextHolder.shouldLoadEntitlements()) {

@@ -59,3 +59,3 @@ return false;

const [isEntitlementsFFOn] = await FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], ContextHolder.getAppName() || '');
const [isEntitlementsFFOn] = FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], ContextHolder.getAppName() || '');
return isEntitlementsFFOn;

@@ -76,3 +76,3 @@ }

ContextHolder.setAccessToken(accessToken);
const [me, currentUserTenants] = await Promise.all([Get(`${urls.identity.users.v2}/me`), getCurrentUserTenantsV3()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsV3()]);
const decodedContent = accessToken ? jwtDecode(accessToken) : {};

@@ -83,13 +83,6 @@

ContextHolder.setUser(user);
let entitlements;
if (await shouldLoadEntitlements()) {
entitlements = await loadEntitlements();
}
return {
user,
tenants: currentUserTenants.tenants,
activeTenant: currentUserTenants.activeTenant,
entitlements
activeTenant: currentUserTenants.activeTenant
};

@@ -99,3 +92,3 @@ }

ContextHolder.setAccessToken(oauthResponse.id_token);
const me = await Get(`${urls.identity.users.v2}/me`);
const me = await getMeAndEntitlements();
const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};

@@ -116,3 +109,3 @@

ContextHolder.setAccessToken(oauthResponse.id_token);
const [me, currentUserTenants] = await Promise.all([Get(`${urls.identity.users.v2}/me`), getCurrentUserTenantsV3()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsV3()]);
const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};

@@ -129,13 +122,6 @@

ContextHolder.setUser(user);
let entitlements;
if (await shouldLoadEntitlements()) {
entitlements = await loadEntitlements();
}
return {
user,
tenants: currentUserTenants.tenants,
activeTenant: currentUserTenants.activeTenant,
entitlements
activeTenant: currentUserTenants.activeTenant
};

@@ -706,2 +692,14 @@ }

return Get(`${urls.identity.configurations.v1}/mfa/strategies`);
}
export async function getMeAndEntitlements() {
const mePromise = Get(`${urls.identity.users.v2}/me`);
if (shouldLoadEntitlements()) {
const [me, entitlements] = await Promise.all([mePromise, loadEntitlements()]);
return _extends({}, me, {
entitlements
});
}
return await mePromise;
}

@@ -1,2 +0,2 @@

import { ITenantsResponse, IUserProfile, UserEntitlementsResponse } from "..";
import { ITenantsResponse, IUserDTO, UserEntitlementsResponse } from "..";
import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from "./enums";

@@ -33,3 +33,3 @@ import { ISamlRolesGroup } from "../teams/interfaces";

};
export declare type ILoginResponse = IUserProfile & {
export declare type ILoginResponse = IUserDTO & {
mfaRequired: boolean;

@@ -49,2 +49,3 @@ accessToken: string;

isBreachedPassword?: boolean;
entitlements?: UserEntitlementsResponse;
};

@@ -59,3 +60,2 @@ export declare type ILoginResponseV2 = {

activeTenant?: ITenantsResponse;
entitlements?: UserEntitlementsResponse;
};

@@ -62,0 +62,0 @@ export declare type ILoginWithMfa = {

@@ -1,3 +0,9 @@

import { IUserProfile } from '../teams/interfaces';
import { ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
import { IUserDTO } from "../users/interfaces";
/**
* Entitlements config from frontegg provider
*/
export interface EntitlementsOptions {
enabled?: boolean;
}
export declare class ContextHolder {

@@ -11,3 +17,3 @@ private static instance;

private logout;
private shouldLoadEntitlements;
private entitlementsOptions;
private appName;

@@ -18,3 +24,3 @@ private constructor();

static setAccessToken(accessToken: string | null): void;
static setUser(user: IUserProfile | null): void;
static setUser(user: IUserDTO | null): void;
static setRequestSource(requestSource: RequestSource | null): void;

@@ -25,5 +31,5 @@ static setOnRedirectTo(onRedirectTo: (path: string, opts?: RedirectOptions) => void): void;

* App name should also be set for entitlements
* @param shouldLoadEntitlements
* @param entitlementsOptions frontegg options entitlements config
*/
static setShouldLoadEntitlements(shouldLoadEntitlements: boolean): void;
static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions): void;
/**

@@ -36,9 +42,9 @@ * @param appName for feature flags e.g.

static getRequestSource(): RequestSource | null;
static getUser(): IUserProfile | null;
static getUser(): IUserDTO | null;
static onRedirectTo(path: string, opts?: RedirectOptions): void;
static logout(callback?: () => void): void;
/**
* @returns shouldLoadEntitlements value
* @returns shouldLoadEntitlements. Default to false.
*/
static shouldLoadEntitlements(): boolean | null;
static shouldLoadEntitlements(): boolean;
/**

@@ -52,5 +58,5 @@ * @returns app name value

getAccessToken: () => string | null;
getUser: () => IUserProfile | null;
getUser: () => IUserDTO | null;
onRedirectTo: (path: string, opts: RedirectOptions) => void;
logout: (callback?: (() => void) | undefined) => void;
};

@@ -12,3 +12,3 @@ export class ContextHolder {

this.shouldLoadEntitlements = null;
this.entitlementsOptions = null;
this.appName = null;

@@ -55,4 +55,4 @@ }

static setShouldLoadEntitlements(shouldLoadEntitlements) {
ContextHolder.getInstance().shouldLoadEntitlements = shouldLoadEntitlements;
static setEntitlementsOptions(entitlementsOptions) {
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
}

@@ -95,3 +95,5 @@

static shouldLoadEntitlements() {
return ContextHolder.getInstance().shouldLoadEntitlements;
var _ContextHolder$getIns2;
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
}

@@ -98,0 +100,0 @@

@@ -80,3 +80,3 @@ import * as auth from "./auth";

getAccessToken: () => string | null;
getUser: () => import("./teams/interfaces").IUserProfile | null;
getUser: () => import("./users/interfaces").IUserDTO | null;
onRedirectTo: (path: string, opts: import("./interfaces").RedirectOptions) => void;

@@ -83,0 +83,0 @@ logout: (callback?: (() => void) | undefined) => void;

@@ -1,2 +0,2 @@

/** @license Frontegg v3.0.141
/** @license Frontegg v3.1.1
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

@@ -151,3 +151,4 @@ "use strict";

getPublicAuthStrategiesConfigForAuthenticatedUser: true,
getMFAStrategiesConfig: true
getMFAStrategiesConfig: true,
getMeAndEntitlements: true
};

@@ -208,2 +209,3 @@ exports.OAuthLogout = OAuthLogout;

exports.getMFAStrategiesConfig = getMFAStrategiesConfig;
exports.getMeAndEntitlements = getMeAndEntitlements;
exports.getOidcConfiguration = getOidcConfiguration;

@@ -360,3 +362,3 @@ exports.getPublicAuthStrategiesConfigForAuthenticatedUser = getPublicAuthStrategiesConfigForAuthenticatedUser;

const me = await (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
const me = await getMeAndEntitlements();
const decodedContent = loginResponse.accessToken ? (0, _jwt.jwtDecode)(loginResponse.accessToken) : {};

@@ -379,3 +381,3 @@ const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);

const [me, tenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _tenants.getTenants)()]);
const [me, tenants] = await Promise.all([getMeAndEntitlements(), (0, _tenants.getTenants)()]);
const decodedContent = loginResponse.accessToken ? (0, _jwt.jwtDecode)(loginResponse.accessToken) : {};

@@ -392,3 +394,3 @@ const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);

async function shouldLoadEntitlements() {
function shouldLoadEntitlements() {
if (!_ContextHolder.ContextHolder.shouldLoadEntitlements()) {

@@ -398,3 +400,4 @@ return false;

const [isEntitlementsFFOn] = await _featureFlags.FeatureFlags.getFeatureFlags([_interfaces.ADMIN_PORTAL_ENTITLEMENTS_FF], _ContextHolder.ContextHolder.getAppName() || '');
const [isEntitlementsFFOn] = _featureFlags.FeatureFlags.getFeatureFlags([_interfaces.ADMIN_PORTAL_ENTITLEMENTS_FF], _ContextHolder.ContextHolder.getAppName() || '');
return isEntitlementsFFOn;

@@ -416,3 +419,3 @@ }

const [me, currentUserTenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _users.getCurrentUserTenantsV3)()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _users.getCurrentUserTenantsV3)()]);
const decodedContent = accessToken ? (0, _jwt.jwtDecode)(accessToken) : {};

@@ -423,13 +426,6 @@ const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);

let entitlements;
if (await shouldLoadEntitlements()) {
entitlements = await (0, _entitlements.loadEntitlements)();
}
return {
user,
tenants: currentUserTenants.tenants,
activeTenant: currentUserTenants.activeTenant,
entitlements
activeTenant: currentUserTenants.activeTenant
};

@@ -441,3 +437,3 @@ }

const me = await (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
const me = await getMeAndEntitlements();
const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};

@@ -460,3 +456,3 @@ const user = (0, _extends2.default)({

const [me, currentUserTenants] = await Promise.all([(0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`), (0, _users.getCurrentUserTenantsV3)()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _users.getCurrentUserTenantsV3)()]);
const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};

@@ -473,13 +469,6 @@ const user = (0, _extends2.default)({

let entitlements;
if (await shouldLoadEntitlements()) {
entitlements = await (0, _entitlements.loadEntitlements)();
}
return {
user,
tenants: currentUserTenants.tenants,
activeTenant: currentUserTenants.activeTenant,
entitlements
activeTenant: currentUserTenants.activeTenant
};

@@ -1185,2 +1174,15 @@ }

return (0, _fetch.Get)(`${_constants.urls.identity.configurations.v1}/mfa/strategies`);
}
async function getMeAndEntitlements() {
const mePromise = (0, _fetch.Get)(`${_constants.urls.identity.users.v2}/me`);
if (shouldLoadEntitlements()) {
const [me, entitlements] = await Promise.all([mePromise, (0, _entitlements.loadEntitlements)()]);
return (0, _extends2.default)({}, me, {
entitlements
});
}
return await mePromise;
}

@@ -19,3 +19,3 @@ "use strict";

this.shouldLoadEntitlements = null;
this.entitlementsOptions = null;
this.appName = null;

@@ -62,4 +62,4 @@ }

static setShouldLoadEntitlements(shouldLoadEntitlements) {
ContextHolder.getInstance().shouldLoadEntitlements = shouldLoadEntitlements;
static setEntitlementsOptions(entitlementsOptions) {
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
}

@@ -102,3 +102,5 @@

static shouldLoadEntitlements() {
return ContextHolder.getInstance().shouldLoadEntitlements;
var _ContextHolder$getIns2;
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
}

@@ -105,0 +107,0 @@

@@ -1,2 +0,2 @@

/** @license Frontegg v3.0.141
/** @license Frontegg v3.1.1
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

{
"name": "@frontegg/rest-api",
"version": "3.0.141",
"version": "3.1.1",
"main": "./node/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -1,3 +0,4 @@

import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUserProfile, IUpdateUser, IDeleteUser, ITeamUserPermission, IResendInvitationLink, IInviteUserLinkResponse, ICreateOrUpdateInviteUserLink, IInviteLinkConfiguration } from './interfaces';
import { IAddUser, IChangePassword, ILoadUsers, IResendActivationLink, ITeamUserRole, ITeamStats, ITeamUser, IUpdateProfile, IUpdateUser, IDeleteUser, ITeamUserPermission, IResendInvitationLink, IInviteUserLinkResponse, ICreateOrUpdateInviteUserLink, IInviteLinkConfiguration, IUserProfile } from './interfaces';
import { PaginationResult } from '../interfaces';
import { IUserDTO } from "../users/interfaces";
/*****************************************

@@ -12,3 +13,3 @@ * Profile Api

*/
export declare function getProfile(params?: object): Promise<IUserProfile>;
export declare function getProfile(params?: object): Promise<IUserDTO>;
/**

@@ -15,0 +16,0 @@ * update user profile by providing updated fields.

@@ -71,3 +71,4 @@ import { PaginationOrderEnum } from '../interfaces';

}
export interface IGetUsersV2Response extends IBaseGetUserResponse {
export declare type IGetUsersV2Response = IUserDTO;
export interface IUserDTO extends IBaseGetUserResponse {
roles: IRole[];

@@ -74,0 +75,0 @@ permissions: ITeamUserPermission[];

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc