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

@frontegg/rest-api

Package Overview
Dependencies
Maintainers
2
Versions
610
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.1.29 to 3.1.30

auth/constants.d.ts

13

auth/index.d.ts
export * from "./secutiry-poilicy";
export * from "./enums";
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage } from './utils';
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, ILoginResponseV3, IPreVerifyMFAEmailCodeResponse, IVerifyMFAEmailCode, ICreateOrUpdateSSOConfigurationByMetadataUrl, IRefreshToken } 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, IPreVerifyMFAEmailCodeResponse, IVerifyMFAEmailCode, ICreateOrUpdateSSOConfigurationByMetadataUrl } from './interfaces';
import { IGetUserAuthorizationResponse, IUserProfile } from "../users/interfaces";

@@ -115,3 +116,3 @@ /*****************************************

*/
export declare function refreshToken(body?: IRefreshToken): Promise<ILoginResponse>;
export declare function refreshToken(): Promise<ILoginResponse>;
/**

@@ -121,3 +122,3 @@ * refresh token called as authenticated use, access and refresh tokens resolved by the cookies.

*/
export declare function refreshTokenV2(body?: IRefreshToken): Promise<ILoginResponseV2>;
export declare function refreshTokenV2(): Promise<ILoginResponseV2>;
/**

@@ -127,3 +128,3 @@ * refresh token called as authenticated use, access and refresh tokens resolved by the cookies.

*/
export declare function refreshTokenV3(body?: IRefreshToken): Promise<ILoginResponseV3>;
export declare function refreshTokenV3(): Promise<ILoginResponseV3>;
/**

@@ -686,5 +687,5 @@ * logout from server, invalidate access and refresh token, remove it from cookies.

export declare function exchangeOAuthTokensV2(body: IExchangeOAuthTokens): Promise<ILoginResponseV3>;
export declare function silentOAuthRefreshTokenV2(body?: IRefreshToken): Promise<ILoginResponseV3>;
export declare function silentOAuthRefreshTokenV2(): Promise<ILoginResponseV3>;
export declare function exchangeOAuthTokens(body: IExchangeOAuthTokens): Promise<ILoginResponse>;
export declare function silentOAuthRefreshToken(body?: IRefreshToken): Promise<ILoginResponse>;
export declare function silentOAuthRefreshToken(): Promise<ILoginResponse>;
/**

@@ -691,0 +692,0 @@ * reset phone should be called in case user want to reset his phone number

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

export * from "./enums";
export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage } from './utils';
import { urls } from "../constants";

@@ -15,7 +16,6 @@ import { ContextHolder } from "../ContextHolder";

import { LOAD_AUTHORIZATION_FF } from './interfaces';
import { getCurrentUserTenantsV3 } from '../users';
import { loadEntitlements } from '../entitlements';
import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
import { FeatureFlags } from "../feature-flags";
import { executeConditionalPromise } from "./utils";
import { executeConditionalPromise, getCurrentUserTenantsFunction, getTabTenantFromSessionStorage, setTabTenantInSessionStorage } from "./utils";
export async function generateLoginResponse(loginResponse) {

@@ -81,3 +81,3 @@ if (!loginResponse.accessToken) {

ContextHolder.setAccessToken(accessToken);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsV3()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsFunction()()]);
const decodedContent = accessToken ? jwtDecode(accessToken) : {};

@@ -87,2 +87,6 @@

if (ContextHolder.isSessionPerTenantEnabled()) {
setTabTenantInSessionStorage(user.tenantId);
}
ContextHolder.setUser(user);

@@ -113,3 +117,3 @@ return {

ContextHolder.setAccessToken(oauthResponse.id_token);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsV3()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsFunction()()]);
const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};

@@ -125,2 +129,6 @@

if (ContextHolder.isSessionPerTenantEnabled()) {
setTabTenantInSessionStorage(user.tenantId);
}
ContextHolder.setUser(user);

@@ -189,12 +197,21 @@ return {

}
export async function refreshToken(body = {}) {
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, body);
export async function refreshToken() {
const tabTenantId = getTabTenantFromSessionStorage();
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
tenantId: tabTenantId
});
return generateLoginResponse(data);
}
export async function refreshTokenV2(body = {}) {
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, body);
export async function refreshTokenV2() {
const tabTenantId = getTabTenantFromSessionStorage();
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
tenantId: tabTenantId
});
return generateLoginResponseV2(data);
}
export async function refreshTokenV3(body = {}) {
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, body);
export async function refreshTokenV3() {
const tabTenantId = getTabTenantFromSessionStorage();
const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
tenantId: tabTenantId
});
return generateLoginResponseV3(data);

@@ -646,4 +663,7 @@ }

}
export async function silentOAuthRefreshTokenV2(body = {}) {
const data = await Post(`${urls.oauth.v1}/authorize/silent`, body);
export async function silentOAuthRefreshTokenV2() {
const tabTenantId = getTabTenantFromSessionStorage();
const data = await Post(`${urls.oauth.v1}/authorize/silent`, {
tenantId: tabTenantId
});
return generateLoginResponseFromOAuthResponseV2(data);

@@ -655,4 +675,7 @@ }

}
export async function silentOAuthRefreshToken(body = {}) {
const data = await Post(`${urls.oauth.v1}/authorize/silent`, body);
export async function silentOAuthRefreshToken() {
const tabTenantId = getTabTenantFromSessionStorage();
const data = await Post(`${urls.oauth.v1}/authorize/silent`, {
tenantId: tabTenantId
});
return generateLoginResponseFromOAuthResponse(data);

@@ -725,2 +748,8 @@ }

const [me, entitlements, authorization] = await Promise.all(promises);
const tabTenant = getTabTenantFromSessionStorage();
if (tabTenant) {
me.tenantId = tabTenant;
}
return _extends({}, me, authorization != null ? authorization : {}, {

@@ -727,0 +756,0 @@ entitlements

@@ -33,5 +33,2 @@ import { ITenantsResponse, IUserProfile, UserEntitlementsResponse } from "..";

};
export declare type IRefreshToken = {
tenantId?: string;
};
export declare type ILoginResponse = IUserProfile & {

@@ -38,0 +35,0 @@ mfaRequired: boolean;

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

import { GetCurrentUserTenantsResponse } from '../users/interfaces';
export interface ConditionalAction<T = any> {

@@ -6,1 +7,4 @@ action: () => Promise<T>;

export declare function executeConditionalPromise({ shouldLoad, action }: ConditionalAction): Promise<any>;
export declare function setTabTenantInSessionStorage(tenantId: string): void;
export declare function getTabTenantFromSessionStorage(): string | null;
export declare function getCurrentUserTenantsFunction(): () => Promise<GetCurrentUserTenantsResponse>;

@@ -0,1 +1,6 @@

import { ContextHolder } from '../ContextHolder';
import { USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF } from './constants';
import { FeatureFlags } from '../feature-flags';
import { getCurrentUserTenantsV1, getCurrentUserTenantsV3 } from '../users';
import { FRONTEGG_SEPARATE_TABS_BY_TENANT } from './constants';
;

@@ -8,2 +13,25 @@ export async function executeConditionalPromise({

return await action();
}
export function setTabTenantInSessionStorage(tenantId) {
if (!tenantId) {
return;
}
sessionStorage.setItem(FRONTEGG_SEPARATE_TABS_BY_TENANT, tenantId);
}
export function getTabTenantFromSessionStorage() {
if (ContextHolder.isSessionPerTenantEnabled()) {
return null;
}
return sessionStorage.getItem(FRONTEGG_SEPARATE_TABS_BY_TENANT);
}
export function getCurrentUserTenantsFunction() {
const [useCurrentUserTenantsV1] = FeatureFlags.getFeatureFlags([USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF], ContextHolder.getAppName() || '');
if (ContextHolder.isSessionPerTenantEnabled()) {
return getCurrentUserTenantsV1;
}
return useCurrentUserTenantsV1 ? getCurrentUserTenantsV1 : getCurrentUserTenantsV3;
}

@@ -23,2 +23,3 @@ export declare const urls: {

me: {
v1: string;
v3: string;

@@ -25,0 +26,0 @@ };

@@ -23,2 +23,3 @@ export const urls = {

me: {
v1: '/identity/resources/users/v1/me/tenants',
v3: '/identity/resources/users/v3/me/tenants'

@@ -25,0 +26,0 @@ }

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

import { ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
import { SessionContext, ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
import { IUserProfile } from "../users/interfaces";

@@ -19,2 +19,3 @@ /**

private appName;
private sessionContext?;
private constructor();

@@ -34,2 +35,6 @@ static getInstance(): ContextHolder;

/**
* @param sessionContext frontegg options SessionContext config
*/
static setSessionContext(sessionContext: SessionContext): void;
/**
* @param appName for feature flags e.g.

@@ -49,2 +54,6 @@ */

/**
* @returns isSessionPerTenantEnabled. Default to false.
*/
static isSessionPerTenantEnabled(): boolean;
/**
* @returns app name value

@@ -51,0 +60,0 @@ */

@@ -14,2 +14,3 @@ export class ContextHolder {

this.appName = null;
this.sessionContext = void 0;
}

@@ -59,2 +60,7 @@

static setSessionContext(sessionContext) {
const instance = ContextHolder.getInstance();
instance.sessionContext = sessionContext;
}
static setAppName(appName) {

@@ -100,2 +106,8 @@ ContextHolder.getInstance().appName = appName;

static isSessionPerTenantEnabled() {
var _ContextHolder$getIns3;
return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
}
static getAppName() {

@@ -102,0 +114,0 @@ return ContextHolder.getInstance().appName;

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

/** @license Frontegg v3.1.29
/** @license Frontegg v3.1.30
*

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

@@ -57,2 +57,5 @@ export interface IFronteggRecord {

}
export interface SessionContext {
enableSessionPerTenant?: boolean;
}
export interface ContextOptions {

@@ -59,0 +62,0 @@ baseUrl: string | ((url: string) => string);

@@ -156,3 +156,5 @@ "use strict";

getMeV2: true,
getMeAndEntitlements: true
getMeAndEntitlements: true,
setTabTenantInSessionStorage: true,
getTabTenantFromSessionStorage: true
};

@@ -230,2 +232,8 @@ exports.OAuthLogout = OAuthLogout;

exports.getSocialLoginProvidersV2ForAuthenticatedUser = getSocialLoginProvidersV2ForAuthenticatedUser;
Object.defineProperty(exports, "getTabTenantFromSessionStorage", {
enumerable: true,
get: function () {
return _utils.getTabTenantFromSessionStorage;
}
});
exports.getTenantAccessTokensData = getTenantAccessTokensData;

@@ -277,2 +285,8 @@ exports.getTenantApiTokensData = getTenantApiTokensData;

exports.setSSODefaultRoles = setSSODefaultRoles;
Object.defineProperty(exports, "setTabTenantInSessionStorage", {
enumerable: true,
get: function () {
return _utils.setTabTenantInSessionStorage;
}
});
exports.signUpUser = signUpUser;

@@ -344,2 +358,4 @@ exports.silentOAuthRefreshToken = silentOAuthRefreshToken;

var _utils = require("./utils");
var _constants = require("../constants");

@@ -355,4 +371,2 @@

var _users = require("../users");
var _entitlements = require("../entitlements");

@@ -364,4 +378,2 @@

var _utils = require("./utils");
const _excluded = ["type"],

@@ -437,6 +449,10 @@ _excluded2 = ["type"],

const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _users.getCurrentUserTenantsV3)()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _utils.getCurrentUserTenantsFunction)()()]);
const decodedContent = accessToken ? (0, _jwt.jwtDecode)(accessToken) : {};
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
(0, _utils.setTabTenantInSessionStorage)(user.tenantId);
}
_ContextHolder.ContextHolder.setUser(user);

@@ -472,3 +488,3 @@

const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _users.getCurrentUserTenantsV3)()]);
const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), (0, _utils.getCurrentUserTenantsFunction)()()]);
const decodedContent = oauthResponse.id_token ? (0, _jwt.jwtDecode)(oauthResponse.id_token) : {};

@@ -483,2 +499,6 @@ const user = (0, _extends2.default)({

if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
(0, _utils.setTabTenantInSessionStorage)(user.tenantId);
}
_ContextHolder.ContextHolder.setUser(user);

@@ -563,14 +583,23 @@

async function refreshToken(body = {}) {
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, body);
async function refreshToken() {
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, {
tenantId: tabTenantId
});
return generateLoginResponse(data);
}
async function refreshTokenV2(body = {}) {
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, body);
async function refreshTokenV2() {
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, {
tenantId: tabTenantId
});
return generateLoginResponseV2(data);
}
async function refreshTokenV3(body = {}) {
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, body);
async function refreshTokenV3() {
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
const data = await (0, _fetch.Post)(`${_constants.urls.identity.auth.v1}/user/token/refresh`, {
tenantId: tabTenantId
});
return generateLoginResponseV3(data);

@@ -1125,4 +1154,7 @@ }

async function silentOAuthRefreshTokenV2(body = {}) {
const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`, body);
async function silentOAuthRefreshTokenV2() {
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`, {
tenantId: tabTenantId
});
return generateLoginResponseFromOAuthResponseV2(data);

@@ -1136,4 +1168,7 @@ }

async function silentOAuthRefreshToken(body = {}) {
const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`, body);
async function silentOAuthRefreshToken() {
const tabTenantId = (0, _utils.getTabTenantFromSessionStorage)();
const data = await (0, _fetch.Post)(`${_constants.urls.oauth.v1}/authorize/silent`, {
tenantId: tabTenantId
});
return generateLoginResponseFromOAuthResponse(data);

@@ -1224,2 +1259,8 @@ }

const [me, entitlements, authorization] = await Promise.all(promises);
const tabTenant = (0, _utils.getTabTenantFromSessionStorage)();
if (tabTenant) {
me.tenantId = tabTenant;
}
return (0, _extends2.default)({}, me, authorization != null ? authorization : {}, {

@@ -1226,0 +1267,0 @@ entitlements

@@ -7,2 +7,14 @@ "use strict";

exports.executeConditionalPromise = executeConditionalPromise;
exports.getCurrentUserTenantsFunction = getCurrentUserTenantsFunction;
exports.getTabTenantFromSessionStorage = getTabTenantFromSessionStorage;
exports.setTabTenantInSessionStorage = setTabTenantInSessionStorage;
var _ContextHolder = require("../ContextHolder");
var _constants = require("./constants");
var _featureFlags = require("../feature-flags");
var _users = require("../users");
;

@@ -16,2 +28,28 @@

return await action();
}
function setTabTenantInSessionStorage(tenantId) {
if (!tenantId) {
return;
}
sessionStorage.setItem(_constants.FRONTEGG_SEPARATE_TABS_BY_TENANT, tenantId);
}
function getTabTenantFromSessionStorage() {
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
return null;
}
return sessionStorage.getItem(_constants.FRONTEGG_SEPARATE_TABS_BY_TENANT);
}
function getCurrentUserTenantsFunction() {
const [useCurrentUserTenantsV1] = _featureFlags.FeatureFlags.getFeatureFlags([_constants.USE_CURRENT_USER_TENANTS_V1_ENDPOINT_FF], _ContextHolder.ContextHolder.getAppName() || '');
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
return _users.getCurrentUserTenantsV1;
}
return useCurrentUserTenantsV1 ? _users.getCurrentUserTenantsV1 : _users.getCurrentUserTenantsV3;
}

@@ -29,2 +29,3 @@ "use strict";

me: {
v1: '/identity/resources/users/v1/me/tenants',
v3: '/identity/resources/users/v3/me/tenants'

@@ -31,0 +32,0 @@ }

@@ -21,2 +21,3 @@ "use strict";

this.appName = null;
this.sessionContext = void 0;
}

@@ -66,2 +67,7 @@

static setSessionContext(sessionContext) {
const instance = ContextHolder.getInstance();
instance.sessionContext = sessionContext;
}
static setAppName(appName) {

@@ -107,2 +113,8 @@ ContextHolder.getInstance().appName = appName;

static isSessionPerTenantEnabled() {
var _ContextHolder$getIns3;
return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
}
static getAppName() {

@@ -109,0 +121,0 @@ return ContextHolder.getInstance().appName;

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

/** @license Frontegg v3.1.29
/** @license Frontegg v3.1.30
*

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

@@ -24,3 +24,11 @@ "use strict";

var _utils = require("../auth/utils");
var _ContextHolder = require("../ContextHolder");
async function switchTenant(body) {
if (_ContextHolder.ContextHolder.isSessionPerTenantEnabled()) {
(0, _utils.setTabTenantInSessionStorage)(body.tenantId);
}
return (0, _fetch.Put)(`${_constants.urls.identity.users.v1}/tenant`, body);

@@ -27,0 +35,0 @@ }

@@ -9,2 +9,3 @@ "use strict";

exports.GetUserJwt = GetUserJwt;
exports.getCurrentUserTenantsV1 = getCurrentUserTenantsV1;
exports.getCurrentUserTenantsV3 = getCurrentUserTenantsV3;

@@ -62,2 +63,8 @@ exports.getUsersGroups = getUsersGroups;

async function getCurrentUserTenantsV1(options) {
return (0, _fetch.Get)(_constants.urls.identity.users.tenants.me.v1, undefined, {
headers: (0, _fetch.extractHeadersFromOptions)(options)
});
}
async function sendResetBreachedPasswordEmails() {

@@ -64,0 +71,0 @@ return (0, _fetch.Post)(_constants.urls.identity.users.passwords.resetBreachedPasswords.v1);

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

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

import _extends from "@babel/runtime/helpers/esm/extends";
import { extractHeadersFromOptions, Get, Post, Put } from "../fetch";
import { urls } from "../constants";
import { setTabTenantInSessionStorage } from '../auth/utils';
import { ContextHolder } from '../ContextHolder';
export async function switchTenant(body) {
if (ContextHolder.isSessionPerTenantEnabled()) {
setTabTenantInSessionStorage(body.tenantId);
}
return Put(`${urls.identity.users.v1}/tenant`, body);

@@ -6,0 +12,0 @@ }

@@ -8,4 +8,11 @@ import { GetCurrentUserTenantsResponse, GetUserGroupsParams, GetUserGroupsResponse, GetUserJwtRequestDto, GetUserJwtResponseDto, GetUserRolesResponse, GetUsersRolesParams, IGetUsersV2Response, ISearchUserQueryParamsV2, ISearchUserQueryParamsV3, IUpdateUserDto, IUserProfile, IUsersV3Data } from './interfaces';

export declare function getUsersGroups(queryParams: GetUserGroupsParams, options?: UserJwtOptions): Promise<GetUserGroupsResponse[]>;
/**
* get user tenant and user tenants by user active tenant
*/
export declare function getCurrentUserTenantsV3(options?: UserJwtOptions): Promise<GetCurrentUserTenantsResponse>;
/**
* get user tenant and user tenants by context tenant
*/
export declare function getCurrentUserTenantsV1(options?: UserJwtOptions): Promise<GetCurrentUserTenantsResponse>;
export declare function sendResetBreachedPasswordEmails(): Promise<void>;
export declare function updateUserProfileV2(body: Partial<IUpdateUserDto>): Promise<IUserProfile>;

@@ -36,2 +36,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";

}
export async function getCurrentUserTenantsV1(options) {
return Get(urls.identity.users.tenants.me.v1, undefined, {
headers: extractHeadersFromOptions(options)
});
}
export async function sendResetBreachedPasswordEmails() {

@@ -38,0 +43,0 @@ return Post(urls.identity.users.passwords.resetBreachedPasswords.v1);

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