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.136 to 3.0.137

32

auth/index.js

@@ -14,2 +14,5 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";

import { getCurrentUserTenantsV3 } from '../users';
import { loadEntitlements } from '../entitlements';
import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
import { FeatureFlags } from "../feature-flags";
export async function generateLoginResponse(loginResponse) {

@@ -48,4 +51,18 @@ if (!loginResponse.accessToken) {

}
async function shouldLoadEntitlements() {
if (!ContextHolder.shouldLoadEntitlements()) {
return false;
}
const [isEntitlementsFFOn] = await FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], ContextHolder.getAppName() || '');
return isEntitlementsFFOn;
}
export async function generateLoginResponseV3(loginResponse) {
if (!loginResponse.accessToken) {
const {
accessToken
} = loginResponse;
if (!accessToken) {
return {

@@ -56,5 +73,5 @@ user: loginResponse

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

@@ -64,6 +81,13 @@ const user = _extends({}, loginResponse, decodedContent, me);

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

@@ -70,0 +94,0 @@ }

3

auth/interfaces.d.ts

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

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

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

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

@@ -59,0 +60,0 @@ export declare type ILoginWithMfa = {

@@ -11,2 +11,4 @@ import { IUserProfile } from '../teams/interfaces';

private logout;
private shouldLoadEntitlements;
private appName;
private constructor();

@@ -20,2 +22,11 @@ static getInstance(): ContextHolder;

static setLogout(logout: (callback?: () => void) => void, logoutUrl: string): void;
/**
* App name should also be set for entitlements
* @param shouldLoadEntitlements
*/
static setShouldLoadEntitlements(shouldLoadEntitlements: boolean): void;
/**
* @param appName for feature flags e.g.
*/
static setAppName(appName: string | null): void;
static getContext(): ContextOptions;

@@ -27,2 +38,10 @@ static getAccessToken(): string | null;

static logout(callback?: () => void): void;
/**
* @returns shouldLoadEntitlements value
*/
static shouldLoadEntitlements(): boolean | null;
/**
* @returns app name value
*/
static getAppName(): string | null;
}

@@ -29,0 +48,0 @@ export declare const FronteggContext: {

@@ -11,2 +11,5 @@ export class ContextHolder {

this.logout = () => window.location.href = '/account/logout';
this.shouldLoadEntitlements = null;
this.appName = null;
}

@@ -52,2 +55,10 @@

static setShouldLoadEntitlements(shouldLoadEntitlements) {
ContextHolder.getInstance().shouldLoadEntitlements = shouldLoadEntitlements;
}
static setAppName(appName) {
ContextHolder.getInstance().appName = appName;
}
static getContext() {

@@ -83,2 +94,10 @@ var _ContextHolder$getIns;

static shouldLoadEntitlements() {
return ContextHolder.getInstance().shouldLoadEntitlements;
}
static getAppName() {
return ContextHolder.getInstance().appName;
}
}

@@ -85,0 +104,0 @@ ContextHolder.instance = void 0;

@@ -22,1 +22,5 @@ /**

}
/**
* entitlements feature flag
*/
export declare const ADMIN_PORTAL_ENTITLEMENTS_FF = "admin_portal_entitlements";

@@ -7,2 +7,4 @@ export let NotEntitledReason;

NotEntitledReason["BUNDLE_EXPIRED"] = "BUNDLE_EXPIRED";
})(NotEntitledReason || (NotEntitledReason = {}));
})(NotEntitledReason || (NotEntitledReason = {}));
export const ADMIN_PORTAL_ENTITLEMENTS_FF = 'admin_portal_entitlements';

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

/** @license Frontegg v3.0.136
/** @license Frontegg v3.0.137
*

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

@@ -341,2 +341,8 @@ "use strict";

var _entitlements = require("../entitlements");
var _interfaces = require("../entitlements/interfaces");
var _featureFlags = require("../feature-flags");
const _excluded = ["type"],

@@ -383,4 +389,17 @@ _excluded2 = ["type"],

async function shouldLoadEntitlements() {
if (!_ContextHolder.ContextHolder.shouldLoadEntitlements()) {
return false;
}
const [isEntitlementsFFOn] = await _featureFlags.FeatureFlags.getFeatureFlags([_interfaces.ADMIN_PORTAL_ENTITLEMENTS_FF], _ContextHolder.ContextHolder.getAppName() || '');
return isEntitlementsFFOn;
}
async function generateLoginResponseV3(loginResponse) {
if (!loginResponse.accessToken) {
const {
accessToken
} = loginResponse;
if (!accessToken) {
return {

@@ -391,6 +410,6 @@ user: loginResponse

_ContextHolder.ContextHolder.setAccessToken(loginResponse.accessToken);
_ContextHolder.ContextHolder.setAccessToken(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 decodedContent = accessToken ? (0, _jwt.jwtDecode)(accessToken) : {};
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);

@@ -400,6 +419,13 @@

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

@@ -406,0 +432,0 @@ }

@@ -18,2 +18,5 @@ "use strict";

this.logout = () => window.location.href = '/account/logout';
this.shouldLoadEntitlements = null;
this.appName = null;
}

@@ -59,2 +62,10 @@

static setShouldLoadEntitlements(shouldLoadEntitlements) {
ContextHolder.getInstance().shouldLoadEntitlements = shouldLoadEntitlements;
}
static setAppName(appName) {
ContextHolder.getInstance().appName = appName;
}
static getContext() {

@@ -90,2 +101,10 @@ var _ContextHolder$getIns;

static shouldLoadEntitlements() {
return ContextHolder.getInstance().shouldLoadEntitlements;
}
static getAppName() {
return ContextHolder.getInstance().appName;
}
}

@@ -92,0 +111,0 @@

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

});
exports.NotEntitledReason = void 0;
exports.NotEntitledReason = exports.ADMIN_PORTAL_ENTITLEMENTS_FF = void 0;
let NotEntitledReason;

@@ -15,2 +15,5 @@ exports.NotEntitledReason = NotEntitledReason;

NotEntitledReason["BUNDLE_EXPIRED"] = "BUNDLE_EXPIRED";
})(NotEntitledReason || (exports.NotEntitledReason = NotEntitledReason = {}));
})(NotEntitledReason || (exports.NotEntitledReason = NotEntitledReason = {}));
const ADMIN_PORTAL_ENTITLEMENTS_FF = 'admin_portal_entitlements';
exports.ADMIN_PORTAL_ENTITLEMENTS_FF = ADMIN_PORTAL_ENTITLEMENTS_FF;

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

/** @license Frontegg v3.0.136
/** @license Frontegg v3.0.137
*

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

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

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

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