@pega/auth
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -162,3 +162,3 @@ export class PegaAuth { | ||
const moreAuthArgs = bInfinity | ||
? `&enable_psyncId=true${authServiceArg}${sessionIndexArg}${userIdentifierArg}${passwordArg}` | ||
? `&enable_psyncId=true&cookies=none${authServiceArg}${sessionIndexArg}${userIdentifierArg}${passwordArg}` | ||
: isolationIdArg; | ||
@@ -332,3 +332,5 @@ let pkceArgs = ''; | ||
elIframe.setAttribute('sandbox', 'allow-scripts allow-forms allow-same-origin'); | ||
// Adding prompt=none as this is standard OIDC way to communicate no UI is expected (expecting Pega security to support this one day) | ||
// Adding prompt=none as this is standard OIDC way to communicate no UI is expected (With Infinity '23 or better, this is passed on to | ||
// configured OIDC authentication services). cookies=none disables the temporary Pega-Rules cookie otherwise created on auth code | ||
// grant flow. For now these two args are either both set or not set, but might have a cookies="partitioned" one day. | ||
elIframe.setAttribute('src', bDisablePromptNone ? theUrl : `${theUrl}&prompt=none`); | ||
@@ -335,0 +337,0 @@ const svgCloseBtn = `<?xml version="1.0" encoding="UTF-8"?> |
@@ -9,6 +9,10 @@ /** | ||
* Silent or visible login based on login status | ||
* @param {string} appName - unique name for application route (will be used to clear an session storage for another route) | ||
* @param {boolean} noMainRedirect - avoid the initial main window redirect that happens in scenarios where it is OK to transition | ||
* away from the main page | ||
* @param {boolean} deferLogin - defer logging in (if not already authenticated) | ||
* @param {Object} loginProps - extensible props related to alterring login/bootstrap. Includes | ||
* appName - unique name for application route (will be used to clear an session storage for another route) (default: 'undefined') | ||
* mainRedirect - permint the initial main window redirect that happens in scenarios where it is OK to transition | ||
* away from the main page (default: false) | ||
* deferLogin - defer login and bootstrap of Constellation (if not already authenticated)(default:true) | ||
* redirectDoneCB - callback to invoke when a authCode redirect completes on the main window (used to allow app | ||
* to implement a route transition rather than the default location navigation) (default: null) | ||
* locale - use a specific locale override (possibly different than locale specified in operator record) (default: null) | ||
*/ | ||
@@ -15,0 +19,0 @@ export declare const loginIfNecessary: (loginProps: any) => void; |
@@ -22,3 +22,3 @@ // This file wraps various calls related to logging in, logging out, etc. | ||
// state that should be persisted across loads | ||
state = { usePopup: false, noInitialRedirect: false }; | ||
state = { usePopup: false, noInitialRedirect: false, locale: null }; | ||
bC11NBootstrapInProgress = false; | ||
@@ -144,14 +144,9 @@ bCustomAuth = false; | ||
} | ||
// Init/getter for loginStart | ||
set loginStart(msValue) { | ||
if (msValue) { | ||
this.state.msLoginStart = msValue; | ||
} | ||
else if (this.state.msLoginStart) { | ||
delete this.state.msLoginStart; | ||
} | ||
// Setter/getter for locale (override) | ||
set locale(localeOverride) { | ||
this.state.locale = localeOverride; | ||
this.#setStorage(this.#ssKeyState, this.state); | ||
} | ||
get loginStart() { | ||
return this.state.msLoginStart || 0; | ||
get locale() { | ||
return this.state.locale; | ||
} | ||
@@ -184,13 +179,2 @@ // Init/getter for reauthStart | ||
} | ||
/* | ||
// No longer needed (see BUG-861780) | ||
isLoginExpired() { | ||
let bExpired = true; | ||
if (this.loginStart) { | ||
const currTime = Date.now(); | ||
bExpired = currTime - this.loginStart > 60000; | ||
} | ||
return bExpired; | ||
} | ||
*/ | ||
/** | ||
@@ -216,3 +200,2 @@ * Clean up any session storage allocated for the user session. | ||
sessionStorage.removeItem(this.#ssKeyTokenInfo); | ||
this.loginStart = 0; | ||
this.isLoggedIn = false; | ||
@@ -508,2 +491,7 @@ // reset the initial redirect as well by using this setter | ||
} | ||
// Set locale override if specified | ||
const localeOverride = this.locale; | ||
if (localeOverride) { | ||
constellationBootConfig.locale = localeOverride; | ||
} | ||
if (this.bC11NBootstrapInProgress) { | ||
@@ -572,3 +560,2 @@ return; | ||
this.isLoggedIn = true; | ||
this.loginStart = 0; | ||
this.usePopupForRestOfSession = true; | ||
@@ -737,4 +724,2 @@ if (!window.PCore && bLoadC11N) { | ||
return; | ||
// Needed so a redirect to login screen and back will know we are still in process of logging in | ||
this.loginStart = Date.now(); | ||
this.#initialize(!bFullReauth).then(aMgr => { | ||
@@ -774,4 +759,2 @@ const sdkConfigAuth = SdkConfigAccess.getSdkConfigAuth(); | ||
.catch(e => { | ||
// Use setter to update state | ||
this.loginStart = 0; | ||
// eslint-disable-next-line no-console | ||
@@ -815,3 +798,3 @@ console.log(e); | ||
loginIfNecessary(loginProps) { | ||
const { appName, deferLogin, redirectDoneCB } = loginProps; | ||
const { appName, deferLogin, redirectDoneCB, locale } = loginProps; | ||
const noMainRedirect = !loginProps.mainRedirect; | ||
@@ -828,2 +811,6 @@ // We need to load state before making any decisions | ||
this.noInitialRedirect = noMainRedirect; | ||
// Keep current state unless a locale is explicitly specified | ||
if (locale !== undefined) { | ||
this.locale = locale; | ||
} | ||
// If custom auth no need to do any OAuth logic | ||
@@ -854,6 +841,3 @@ if (this.bCustomAuth) { | ||
} | ||
// Reset the loginStart when page is traversed without ?code argument (user invoked app twice, | ||
// without logging in) (BUG-861780) | ||
this.loginStart = 0; | ||
if (!deferLogin /* && (!this.loginStart || this.isLoginExpired()) */) { | ||
if (!deferLogin) { | ||
return this.#initialize(false).then(() => { | ||
@@ -890,8 +874,8 @@ this.#updateLoginStatus(); | ||
.revokeTokens() | ||
.then(() => { | ||
fnClearAndResolve(); | ||
}) | ||
.catch(err => { | ||
// eslint-disable-next-line no-console | ||
console.log('Error:', err?.message); | ||
}) | ||
.finally(() => { | ||
fnClearAndResolve(); | ||
}); | ||
@@ -936,6 +920,10 @@ } | ||
* Silent or visible login based on login status | ||
* @param {string} appName - unique name for application route (will be used to clear an session storage for another route) | ||
* @param {boolean} noMainRedirect - avoid the initial main window redirect that happens in scenarios where it is OK to transition | ||
* away from the main page | ||
* @param {boolean} deferLogin - defer logging in (if not already authenticated) | ||
* @param {Object} loginProps - extensible props related to alterring login/bootstrap. Includes | ||
* appName - unique name for application route (will be used to clear an session storage for another route) (default: 'undefined') | ||
* mainRedirect - permint the initial main window redirect that happens in scenarios where it is OK to transition | ||
* away from the main page (default: false) | ||
* deferLogin - defer login and bootstrap of Constellation (if not already authenticated)(default:true) | ||
* redirectDoneCB - callback to invoke when a authCode redirect completes on the main window (used to allow app | ||
* to implement a route transition rather than the default location navigation) (default: null) | ||
* locale - use a specific locale override (possibly different than locale specified in operator record) (default: null) | ||
*/ | ||
@@ -942,0 +930,0 @@ export const loginIfNecessary = (loginProps) => { |
{ | ||
"name": "@pega/auth", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199220
2185