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

@pega/auth

Package Overview
Dependencies
Maintainers
16
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pega/auth - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

2

lib/sdk-auth-manager/authManager.d.ts

@@ -21,3 +21,3 @@ /**

export declare const sdkSetCustomTokenParamsCB: (fnCustomTokenParamsCB: (() => any) | null) => void;
export declare const getAvailablePortals: () => Promise<void | unknown[]>;
export declare const getAvailablePortals: () => Promise<string[]>;
//# sourceMappingURL=authManager.d.ts.map

@@ -583,55 +583,57 @@ // This file wraps various calls related to logging in, logging out, etc.

async getAvailablePortals() {
return getSdkConfig().then(sdkConfig => {
const serverConfig = sdkConfig.serverConfig;
const userAccessGroup = PCore.getEnvironmentInfo().getAccessGroup();
const dataPageName = 'D_OperatorAccessGroups';
const serverUrl = serverConfig.infinityRestServerUrl;
const appAlias = serverConfig.appAlias;
const appAliasPath = appAlias ? `/app/${appAlias}` : '';
const arExcludedPortals = serverConfig.excludePortals;
const headers = {
Authorization: this.#authHeader === null ? '' : this.#authHeader,
'Content-Type': 'application/json'
};
// Using v1 API here as v2 data_views is not able to access same data page currently. Should move to avoid having this logic to find
// a default portal or constellation portal and rather have Constellation JS Engine API just load the default portal
return fetch(`${serverUrl}${appAliasPath}/api/v1/data/${dataPageName}`, {
method: 'GET',
headers
})
.then(response => {
if (response.ok && response.status === 200) {
return response.json();
}
if (response.status === 401) {
// Might be either a real token expiration or revoke, but more likely that the "api" service package is misconfigured
throw new Error(`Attempt to access ${dataPageName} failed. The "api" service package is likely not configured to use "OAuth 2.0"`);
}
throw new Error(`HTTP Error: ${response.status}`);
})
.then(async (agData) => {
const arAccessGroups = agData.pxResults;
const availablePortals = [];
for (const ag of arAccessGroups) {
if (ag.pyAccessGroup === userAccessGroup) {
// eslint-disable-next-line no-console
console.error(`Default portal for current operator (${ag.pyPortal}) is not compatible with SDK.\nConsider using a different operator, adjusting the default portal for this operator, or using "appPortal" setting within sdk-config.json to specify a specific portal to load.`);
let portal = null;
for (portal of ag.pyUserPortals) {
if (!arExcludedPortals.includes(portal.pyPortalLayout)) {
availablePortals.push(portal.pyPortalLayout);
return new Promise(resolve => {
getSdkConfig().then(sdkConfig => {
const serverConfig = sdkConfig.serverConfig;
const userAccessGroup = PCore.getEnvironmentInfo().getAccessGroup();
const dataPageName = 'D_OperatorAccessGroups';
const serverUrl = serverConfig.infinityRestServerUrl;
const appAlias = serverConfig.appAlias;
const appAliasPath = appAlias ? `/app/${appAlias}` : '';
const arExcludedPortals = serverConfig.excludePortals;
const headers = {
Authorization: this.#authHeader === null ? '' : this.#authHeader,
'Content-Type': 'application/json'
};
// Using v1 API here as v2 data_views is not able to access same data page currently. Should move to avoid having this logic to find
// a default portal or constellation portal and rather have Constellation JS Engine API just load the default portal
return fetch(`${serverUrl}${appAliasPath}/api/v1/data/${dataPageName}`, {
method: 'GET',
headers
})
.then(response => {
if (response.ok && response.status === 200) {
return response.json();
}
if (response.status === 401) {
// Might be either a real token expiration or revoke, but more likely that the "api" service package is misconfigured
throw new Error(`Attempt to access ${dataPageName} failed. The "api" service package is likely not configured to use "OAuth 2.0"`);
}
throw new Error(`HTTP Error: ${response.status}`);
})
.then(async (agData) => {
const arAccessGroups = agData.pxResults;
const availablePortals = [];
for (const ag of arAccessGroups) {
if (ag.pyAccessGroup === userAccessGroup) {
// eslint-disable-next-line no-console
console.error(`Default portal for current operator (${ag.pyPortal}) is not compatible with SDK.\nConsider using a different operator, adjusting the default portal for this operator, or using "appPortal" setting within sdk-config.json to specify a specific portal to load.`);
let portal = null;
for (portal of ag.pyUserPortals) {
if (!arExcludedPortals.includes(portal.pyPortalLayout)) {
availablePortals.push(portal.pyPortalLayout);
}
}
break;
}
break;
}
}
// Found operator's current access group. Use its portal
// eslint-disable-next-line no-console
console.log(`Available portals: ${availablePortals}`);
return availablePortals;
})
.catch(e => {
// eslint-disable-next-line no-console
console.error(e.message);
// check specific error if 401, and wiped out if so stored token is stale. Fetch new tokens.
// Found operator's current access group. Use its portal
// eslint-disable-next-line no-console
console.log(`Available portals: ${availablePortals}`);
resolve(availablePortals);
})
.catch(e => {
// eslint-disable-next-line no-console
console.error(e.message);
// check specific error if 401, and wiped out if so stored token is stale. Fetch new tokens.
});
});

@@ -638,0 +640,0 @@ });

{
"name": "@pega/auth",
"version": "0.1.3",
"version": "0.1.4",
"description": "Pega OAuth 2.0 Client Library (supports Infinity and Launchpad).",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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