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.1 to 0.1.2

1

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

@@ -20,3 +20,4 @@ /**

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

87

lib/sdk-auth-manager/authManager.js

@@ -20,2 +20,3 @@ // This file wraps various calls related to logging in, logging out, etc.

#authHeader = null;
#customTokenParamsCB = null;
// state that should be persisted across loads

@@ -118,2 +119,6 @@ state = { usePopup: false, noInitialRedirect: false };

}
// Setter for customTokenParamsCB
set customTokenParamsCB(fn) {
this.#customTokenParamsCB = fn;
}
// Setter/getter for usePopupForRestOfSession

@@ -309,2 +314,6 @@ set usePopupForRestOfSession(usePopup) {

const mashupGrantType = sdkConfigAuth.mashupGrantType || 'authCode';
// Some grant types are only available with confidential registrations and require a client secret
const clientSecret = bNoInitialRedirect
? sdkConfigAuth.mashupClientSecret
: sdkConfigAuth.portalClientSecret;
const pegaAuthConfig = {

@@ -324,2 +333,5 @@ clientId: bNoInitialRedirect

};
if (clientSecret) {
pegaAuthConfig.clientSecret = clientSecret;
}
// Invoke keySuffix setter

@@ -435,3 +447,9 @@ // Was using pegaAuthConfig.clientId as key but more secure to just use a random string as getting

}
if (tokenInfo) {
if (this.#authConfig.grantType === 'customBearer' || !tokenInfo) {
if (tokenInfo) {
this.#authHeader = `${tokenInfo.token_type} ${tokenInfo.access_token}`;
}
constellationBootConfig.authorizationHeader = this.#authHeader;
}
else {
// Pass in auth info to Constellation

@@ -456,5 +474,2 @@ constellationBootConfig.authInfo = {

}
else {
constellationBootConfig.authorizationHeader = this.#authHeader;
}
// Turn off dynamic load components (should be able to do it here instead of after load?)

@@ -467,3 +482,3 @@ constellationBootConfig.dynamicLoadComponents = false;

// Note that staticContentServerUrl already ends with a slash (see above), so no slash added.
// In order to have this import succeed and to have it done with the webpackIgnore magic comment tag.
// In order to have this import succeed needed to use the webpackIgnore magic comment tag.
// See: https://webpack.js.org/api/module-methods/

@@ -542,3 +557,7 @@ import(

}
if (window.PCore) {
if (this.#authConfig.grantType === 'customBearer') {
// authHeader setter will also set #authHeader and invoke getAuthUtils().setAuthorizationHeader
this.authHeader = `${token.token_type} ${token.access_token}`;
}
if (window.PCore && !this.#authHeader) {
PCore.getAuthUtils().setTokens(token);

@@ -550,2 +569,16 @@ }

}
#doCustomTokenParamsCB() {
if (this.#authConfig.grantType === 'customBearer' && this.#customTokenParamsCB) {
try {
const customTokenParams = this.#customTokenParamsCB();
if (customTokenParams) {
this.#authConfig.customTokenParams = customTokenParams;
}
}
catch (e) {
// eslint-disable-next-line no-console
console.error(`Error on customTokenParams callback. ${e}`);
}
}
}
updateRedirectUri(sRedirectUri) {

@@ -673,22 +706,25 @@ this.#authConfig.redirectUri = sRedirectUri;

this.#initialize(!bFullReauth).then(aMgr => {
const bMainRedirect = !this.noInitialRedirect;
const sdkConfigAuth = SdkConfigAccess.getSdkConfigAuth();
let sRedirectUri = sdkConfigAuth.redirectUri;
// If initial main redirect is OK, redirect to main page, otherwise will authorize in a popup window
if (bMainRedirect && !bFullReauth) {
// update redirect uri to be the root
if (this.#authConfig.grantType === 'authCode') {
const bMainRedirect = !this.noInitialRedirect;
let sRedirectUri = sdkConfigAuth.redirectUri;
// If initial main redirect is OK, redirect to main page, otherwise will authorize in a popup window
if (bMainRedirect && !bFullReauth) {
// update redirect uri to be the root
this.updateRedirectUri(sRedirectUri);
aMgr.loginRedirect();
// Don't have token til after the redirect
return Promise.resolve(undefined);
}
// Construct path to redirect uri
const nLastPathSep = sRedirectUri.lastIndexOf('/');
sRedirectUri =
nLastPathSep !== -1
? `${sRedirectUri.substring(0, nLastPathSep + 1)}auth.html`
: `${sRedirectUri}/auth.html`;
// Set redirectUri to static auth.html
this.updateRedirectUri(sRedirectUri);
aMgr.loginRedirect();
// Don't have token til after the redirect
return Promise.resolve(undefined);
}
// Construct path to redirect uri
const nLastPathSep = sRedirectUri.lastIndexOf('/');
sRedirectUri =
nLastPathSep !== -1
? `${sRedirectUri.substring(0, nLastPathSep + 1)}auth.html`
: `${sRedirectUri}/auth.html`;
// Set redirectUri to static auth.html
this.updateRedirectUri(sRedirectUri);
return new Promise((resolve, reject) => {
this.#doCustomTokenParamsCB();
aMgr

@@ -880,2 +916,9 @@ .login()

};
// Set specific call back function to retrieve custom token endpoint params prior to login. This would
// be set with specifying deferLoad='true' and prior to the invocation of the load method
export const sdkSetCustomTokenParamsCB = (fnCustomTokenParamsCB) => {
if (typeof fnCustomTokenParamsCB === 'function') {
gAuthMgr.customTokenParamsCB = fnCustomTokenParamsCB;
}
};
export const getAvailablePortals = async () => {

@@ -882,0 +925,0 @@ return gAuthMgr.getAvailablePortals();

{
"name": "@pega/auth",
"version": "0.1.1",
"version": "0.1.2",
"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