@pega/react-sdk-components 8.23.11-debug3 → 8.23.11-debug5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/components/helpers/auth.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAA6B;AAC7B,MAAM,OAAO,QAAQ;IAOjB,gDAAgD;IAChD,4FAA4F;IAE5F,YAAY,WAAW,EAAE,aAAa,GAAG,EAAE;;QAT3C,oGAAoG;QACpG,uDAAuD;QACvD,2BAAU,IAAI,EAAC;QACf,qGAAqG;QACrG,gCAAgC;QAChC,6BAAY,EAAE,EAAC;QAKb,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,GAAG,WAAW,KAAK,CAAC;YAC1D,uBAAA,IAAI,mDAAc,MAAlB,IAAI,CAAgB,CAAC;SACtB;aAAM;YACL,4CAA4C;YAC5C,uBAAA,IAAI,oBAAW,WAAW,MAAA,CAAC;YAC3B,uBAAA,IAAI,sBAAa,aAAa,IAAI,EAAE,MAAA,CAAC;SACtC;QACD,IAAI,CAAC,UAAU,GAAG,mCAAmC,CAAC;QACtD,IAAI,CAAC,UAAU,GAAG,sBAAsB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;QAE5C,kFAAkF;QAClF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;SACpC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,uBAAA,IAAI,wBAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACxC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E;QAClD,MAAM,OAAO,GAAG,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;QAC9C,IAAI,uBAAA,IAAI,wBAAQ,CAAC,SAAS,EAAE;YAC1B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,4BAA4B,CAAC;SAC5E;QACD,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACtC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAGH,eAAe,QAAQ,CAAC","sourcesContent":["/* eslint-disable no-undef */\nexport class PegaAuth {\n // The properties within config structure are expected to be more static config values that are then\n // used to properly make various OAuth endpoint calls.\n #config = null;\n // Any dynamic state is stored separately in its own structure. If a sessionStorage key is passed in\n // without a Dynamic State key.\n #dynState = {};\n // Current properties within dynState structure:\n // codeVerifier, state, sessionIndex, sessionIndexAttempts, acRedirectUri, silentAuthFailed\n\n constructor(ssKeyConfig, ssKeyDynState = '') {\n if (typeof ssKeyConfig === 'string') {\n this.ssKeyConfig = ssKeyConfig;\n this.ssKeyDynState = ssKeyDynState || `${ssKeyConfig}_DS`;\n this.#reloadConfig();\n } else {\n // object with config structure is passed in\n this.#config = ssKeyConfig;\n this.#dynState = ssKeyDynState || {};\n }\n this.urlencoded = 'application/x-www-form-urlencoded';\n this.tokenError = 'Token endpoint error';\n this.isNode = typeof window === 'undefined';\n\n // For isNode path the below attributes are initialized on first method invocation\n if (!this.isNode) {\n this.crypto = window.crypto;\n this.subtle = window.crypto.subtle;\n }\n if (Object.keys(this.#config).length > 0) {\n if (!this.#config.serverType) {\n this.#config.serverType = 'infinity';\n }\n } else {\n throw new Error('invalid config settings');\n }\n }\n\n #reloadSS(ssKey) {\n const sItem = window.sessionStorage.getItem(ssKey);\n let obj = {};\n if (sItem) {\n try {\n obj = JSON.parse(sItem);\n } catch (e) {\n try {\n obj = JSON.parse(atob(sItem));\n } catch (err) {\n obj = {};\n }\n }\n }\n if (ssKey === this.ssKeyConfig) {\n this.#config = sItem ? obj : {};\n } else {\n this.#dynState = sItem ? obj : {};\n }\n }\n\n #reloadConfig() {\n if (this.ssKeyConfig) {\n this.#reloadSS(this.ssKeyConfig);\n }\n if (this.ssKeyDynState) {\n this.#reloadSS(this.ssKeyDynState);\n }\n }\n\n #updateConfig() {\n // transform must occur unless it is explicitly disabled\n const transform = this.#config.transform !== false;\n // May not need to write out Config info all the time, but there is a scenario where a\n // non obfuscated value is passed in and then it needs to be obfuscated\n if (this.ssKeyConfig) {\n const sConfig = JSON.stringify(this.#config);\n window.sessionStorage.setItem(this.ssKeyConfig, transform ? btoa(sConfig) : sConfig);\n }\n if (this.ssKeyDynState) {\n const sDynState = JSON.stringify(this.#dynState);\n window.sessionStorage.setItem(this.ssKeyDynState, transform ? btoa(sDynState) : sDynState);\n }\n if (this.#config.fnDynStateChangedCB) {\n this.#config.fnDynStateChangedCB();\n }\n }\n\n async #importSingleLib(libName, libProp, bLoadAlways = false) {\n if (!bLoadAlways && typeof (this.isNode ? global : window)[libProp] !== 'undefined') {\n this[libProp] = (this.isNode ? global : window)[libProp];\n return this[libProp];\n }\n // Needed to explicitly make import argument a string by using template literals to fix a compile\n // error: Critical dependency: the request of a dependency is an expression\n return import(/* webpackIgnore: true */ `${libName}`)\n .then((mod) => {\n this[libProp] = mod.default;\n })\n .catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Library ${libName} failed to load. ${e}`);\n throw e;\n });\n }\n\n async #importNodeLibs() {\n // Also current assumption is using Node 18 or better\n // With 18.3 there is now a native fetch (but may want to force use of node-fetch)\n const useNodeFetch = !!this.#config.useNodeFetch;\n\n return Promise.all([\n this.#importSingleLib('node-fetch', 'fetch', useNodeFetch),\n this.#importSingleLib('open', 'open'),\n this.#importSingleLib('node:crypto', 'crypto', true),\n this.#importSingleLib('node:https', 'https'),\n this.#importSingleLib('node:http', 'http'),\n this.#importSingleLib('node:fs', 'fs')\n ]).then(() => {\n this.subtle = this.crypto?.subtle || this.crypto.webcrypto.subtle;\n if ((typeof fetch === 'undefined' || useNodeFetch) && this.fetch) {\n /* eslint-disable-next-line no-global-assign */\n fetch = this.fetch;\n }\n });\n }\n\n // For PKCE the authorize includes a code_challenge & code_challenge_method as well\n async #buildAuthorizeUrl(state) {\n const {\n serverType,\n clientId,\n redirectUri,\n authorizeUri,\n userinfoUri,\n authService,\n appAlias,\n userIdentifier,\n password,\n noPKCE,\n isolationId\n } = this.#config;\n const { sessionIndex } = this.#dynState;\n const bInfinity = serverType === 'infinity';\n\n if (!noPKCE) {\n // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars\n const buf = new Uint8Array(64);\n this.crypto.getRandomValues(buf);\n this.#dynState.codeVerifier = this.#base64UrlSafeEncode(buf);\n }\n\n // If sessionIndex exists then increment attempts count (we will stop sending session_index after two failures)\n // With Infinity '24 we can now properly detect a invalid_session_index error, but can't for earlier versions\n if (sessionIndex) {\n this.#dynState.sessionIndexAttempts += 1;\n }\n\n // We use state to verify that the received code is for the right authorize transaction\n this.#dynState.state = `${state || ''}.${this.#getRandomString(32)}`;\n\n // The same redirectUri needs to be provided to token endpoint, so save this away incase redirectUri is\n // adjusted for next authorize\n this.#dynState.acRedirectUri = redirectUri;\n\n // Persist codeVerifier in session storage so it survives the redirects that are to follow\n this.#updateConfig();\n\n // Trim alias to include just the real alias piece\n const additionalScope =\n (userinfoUri ? '+profile' : '') + (appAlias ? `+app.alias.${appAlias.replace(/^app\\//, '')}` : '');\n const scope = bInfinity ? `openid+email${additionalScope}` : 'user_info';\n\n // Add explicit creds if specified to try to avoid login popup\n const authServiceArg = authService ? `&authentication_service=${encodeURIComponent(authService)}` : '';\n const sessionIndexArg =\n sessionIndex && this.#dynState.sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : '';\n const userIdentifierArg = userIdentifier ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}` : '';\n const passwordArg = password && userIdentifier ? `&Password=${encodeURIComponent(atob(password))}` : '';\n const isolationIdArg = !bInfinity && isolationId ? `&isolationID=${isolationId}` : '';\n const moreAuthArgs = bInfinity\n ? `&enable_psyncId=true&cookies=none${authServiceArg}${sessionIndexArg}${userIdentifierArg}${passwordArg}`\n : isolationIdArg;\n\n let pkceArgs = '';\n if (!noPKCE) {\n const cc = await this.#getCodeChallenge(this.#dynState.codeVerifier);\n pkceArgs = `&code_challenge=${cc}&code_challenge_method=S256`;\n }\n return `${authorizeUri}?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&scope=${scope}&state=${encodeURIComponent(\n this.#dynState.state\n )}${pkceArgs}${moreAuthArgs}`;\n }\n\n async login() {\n if (this.isNode && !this.crypto) {\n // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor\n await this.#importNodeLibs();\n }\n const { grantType, noPKCE } = this.#config;\n if (grantType && grantType !== 'authCode') {\n return this.getToken();\n }\n // Make sure browser in a secure context, else PKCE will fail\n if (!this.isNode && !noPKCE && !window.isSecureContext) {\n throw new Error(\n `Authorization code grant flow failed due to insecure browser context at ${window.location.origin}. Use localhost or https.`\n );\n }\n return this.#authCodeStart();\n }\n\n // authCode login issues the authorize endpoint transaction and deals with redirects\n async #authCodeStart() {\n const fnGetRedirectUriOrigin = () => {\n const redirectUri = this.#config.redirectUri;\n const nRootOffset = redirectUri.indexOf('//');\n const nFirstPathOffset = nRootOffset !== -1 ? redirectUri.indexOf('/', nRootOffset + 2) : -1;\n return nFirstPathOffset !== -1 ? redirectUri.substring(0, nFirstPathOffset) : redirectUri;\n };\n\n const redirectOrigin = fnGetRedirectUriOrigin();\n const startState = this.isNode ? '' : btoa(window.location.origin);\n\n return new Promise((resolve, reject) => {\n let theUrl = null; // holds the crafted authorize url\n\n let myWindow = null; // popup or iframe\n let elIframe = null;\n let elCloseBtn = null;\n const iframeTimeout = this.#config.silentTimeout !== undefined ? this.#config.silentTimeout : 5000;\n let bWinIframe = true;\n let tmrAuthComplete = null;\n let checkWindowClosed = null;\n let bDisablePromptNone = false;\n const myWinOnLoad = () => {\n try {\n if (bWinIframe) {\n elIframe.contentWindow.postMessage({ type: 'PegaAuth' }, redirectOrigin);\n } else {\n myWindow.postMessage({ type: 'PegaAuth' }, redirectOrigin);\n }\n } catch (e) {\n // Exception trying to postMessage on load (perhaps should console.warn)\n }\n };\n const fnSetSilentAuthFailed = (bSet) => {\n this.#dynState.silentAuthFailed = bSet;\n this.#updateConfig();\n };\n /* eslint-disable prefer-promise-reject-errors */\n const fnOpenPopup = () => {\n if (this.#config.noPopups) {\n return reject('no-popups');\n }\n // Since displaying a visible window, clear the silent auth failed flag\n fnSetSilentAuthFailed(false);\n myWindow = (this.isNode ? this.open : window.open)(theUrl, '_blank', 'width=700,height=500,left=200,top=100');\n if (!myWindow) {\n // Blocked by popup-blocker\n return reject('blocked');\n }\n checkWindowClosed = setInterval(() => {\n if (myWindow.closed) {\n clearInterval(checkWindowClosed);\n reject('closed');\n }\n }, 500);\n if (!this.isNode) {\n try {\n myWindow.addEventListener('load', myWinOnLoad, true);\n } catch (e) {\n // Exception trying to add onload handler to opened window\n // eslint-disable-next-line no-console\n console.error(`Error adding event listener on popup window: ${e}`);\n }\n }\n };\n\n /* eslint-enable prefer-promise-reject-errors */\n const fnCloseIframe = () => {\n elIframe.parentNode.removeChild(elIframe);\n elCloseBtn.parentNode.removeChild(elCloseBtn);\n elIframe = null;\n elCloseBtn = null;\n bWinIframe = false;\n };\n\n const fnCloseAndReject = () => {\n fnCloseIframe();\n /* eslint-disable-next-line prefer-promise-reject-errors */\n reject('closed');\n };\n\n const fnAuthMessageReceiver = (event) => {\n // Check origin to make sure it is the redirect origin\n if (event.origin !== redirectOrigin) {\n if (event.data?.type === 'PegaAuth') {\n // eslint-disable-next-line no-console\n console.error(\n `Authorization code grant flow error: Unexpected origin: ${event.origin} ... expecting: ${redirectOrigin}`\n );\n }\n return;\n }\n if (!event.data || !event.data.type || event.data.type !== 'PegaAuth') return;\n const aArgs = ['code', 'state', 'error', 'errorDesc'];\n const aValues = [];\n for (let i = 0; i < aArgs.length; i += 1) {\n const arg = aArgs[i];\n aValues[arg] = event.data[arg] ? event.data[arg].toString() : null;\n }\n const { code, state, error, errorDesc } = aValues;\n if (error) {\n // eslint-disable-next-line no-console\n console.error(`Authorization code grant flow error (${error}): ${errorDesc}`);\n }\n if (code && state !== this.#dynState.state) {\n // eslint-disable-next-line no-console\n console.error(\n `Authorization code transfer error: state mismatch: ${state} ... expecting: ${this.#dynState.state}`\n );\n }\n if (error || (code && state === this.#dynState.state)) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n fnGetTokenAndFinish(code, error, errorDesc);\n }\n };\n\n const fnEnableMessageReceiver = (bEnable) => {\n if (bEnable) {\n window.addEventListener('message', fnAuthMessageReceiver, false);\n window.authCodeCallback = (code, state, error, errorDesc) => {\n if (error) {\n // eslint-disable-next-line no-console\n console.error(`Authorization code grant flow error (${error}): ${errorDesc}`);\n }\n if (code && state !== this.#dynState.state) {\n // eslint-disable-next-line no-console\n console.error(\n `Authorization code transfer error: state mismatch: ${state} ... expecting: ${this.#dynState.state}`\n );\n }\n if (error || (code && state === this.#dynState.state)) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n fnGetTokenAndFinish(code, error, errorDesc);\n }\n };\n } else {\n window.removeEventListener('message', fnAuthMessageReceiver, false);\n delete window.authCodeCallback;\n }\n };\n\n const doAuthorize = () => {\n // If there is a userIdentifier and password specified or an external SSO auth service,\n // we can try to use this silently in an iFrame first\n bWinIframe =\n !this.isNode &&\n !this.#dynState.silentAuthFailed &&\n iframeTimeout > 0 &&\n ((!!this.#config.userIdentifier && !!this.#config.password) ||\n this.#config.iframeLoginUI ||\n this.#config.authService !== 'pega');\n // Enable message receiver\n if (!this.isNode) {\n fnEnableMessageReceiver(true);\n }\n if (bWinIframe) {\n const nFrameZLevel = 99999;\n elIframe = document.createElement('iframe');\n elIframe.id = `pe${this.#config.clientId}`;\n const loginBoxWidth = 500;\n const loginBoxHeight = 700;\n const oStyle = elIframe.style;\n oStyle.position = 'absolute';\n oStyle.display = 'none';\n oStyle.zIndex = nFrameZLevel;\n oStyle.top = `${Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2)}px`;\n oStyle.left = `${Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2)}px`;\n oStyle.width = '500px';\n oStyle.height = '700px';\n // Add Iframe to top of document DOM to have it load\n document.body.insertBefore(elIframe, document.body.firstChild);\n // document.getElementsByTagName('body')[0].appendChild(elIframe);\n elIframe.addEventListener('load', myWinOnLoad, true);\n // Disallow iframe content attempts to navigate main window\n elIframe.setAttribute('sandbox', 'allow-scripts allow-forms allow-same-origin');\n // 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\n // configured OIDC authentication services). cookies=none disables the temporary Pega-Rules cookie otherwise created on auth code\n // grant flow. For now these two args are either both set or not set, but might have a cookies=\"partitioned\" one day.\n elIframe.setAttribute('src', bDisablePromptNone ? theUrl : `${theUrl}&prompt=none`);\n\n const svgCloseBtn = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <svg width=\"34px\" height=\"34px\" viewBox=\"0 0 34 34\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <title>Dismiss - Black</title>\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1.000000, 1.000000)\">\n <circle fill=\"#252C32\" cx=\"16\" cy=\"16\" r=\"16\"></circle>\n <g transform=\"translate(9.109375, 9.214844)\" fill=\"#FFFFFF\" fill-rule=\"nonzero\">\n <path d=\"M12.7265625,0 L0,12.6210938 L1.0546875,13.5703125 L13.78125,1.0546875 L12.7265625,0 Z M13.7460938,12.5507812 L1.01953125,0 L0,1.01953125 L12.7617188,13.6054688 L13.7460938,12.5507812 Z\"></path>\n </g>\n </g>\n </g>\n </svg>`;\n const bCloseWithinFrame = false;\n elCloseBtn = document.createElement('img');\n elCloseBtn.onclick = fnCloseAndReject;\n elCloseBtn.src = `data:image/svg+xml;base64,${btoa(svgCloseBtn)}`;\n const oBtnStyle = elCloseBtn.style;\n oBtnStyle.cursor = 'pointer';\n // If svg doesn't set width and height might want to set oBtStyle width and height to something like '2em'\n oBtnStyle.position = 'absolute';\n oBtnStyle.display = 'none';\n oBtnStyle.zIndex = nFrameZLevel + 1;\n const nTopOffset = bCloseWithinFrame ? 5 : -10;\n const nRightOffset = bCloseWithinFrame ? -34 : -20;\n const nTop = Math.round(Math.max(window.innerHeight - loginBoxHeight, 0) / 2) + nTopOffset;\n oBtnStyle.top = `${nTop}px`;\n const nLeft = Math.round(Math.max(window.innerWidth - loginBoxWidth, 0) / 2) + loginBoxWidth + nRightOffset;\n oBtnStyle.left = `${nLeft}px`;\n document.body.insertBefore(elCloseBtn, document.body.firstChild);\n // If the password was wrong, then the login screen will be in the iframe\n // ..and with Pega without realization of US-372314 it may replace the top (main portal) window\n // For now set a timer and if the timer expires, remove the iFrame and use same url within\n // visible window\n tmrAuthComplete = setTimeout(() => {\n clearTimeout(tmrAuthComplete);\n /*\n // remove password from config\n if (this.#config.password) {\n delete this.#config.password;\n this.#updateConfig();\n }\n */\n // Display the iframe where the redirects did not succeed (or invoke a popup window)\n if (this.#config.iframeLoginUI) {\n elIframe.style.display = 'block';\n elCloseBtn.style.display = 'block';\n } else {\n fnCloseIframe();\n fnOpenPopup();\n }\n }, iframeTimeout);\n } else {\n if (this.isNode) {\n // Determine port to listen to by extracting it from redirect uri\n const { redirectUri, cert, key } = this.#config;\n const isHttp = redirectUri.startsWith('http:');\n const nLocalhost = redirectUri.indexOf('localhost:');\n const nSlash = redirectUri.indexOf('/', nLocalhost + 10);\n const nPort = parseInt(redirectUri.substring(nLocalhost + 10, nSlash), 10);\n if (nLocalhost !== -1) {\n const options =\n key && cert && !isHttp\n ? {\n key: this.fs.readFileSync(key),\n cert: this.fs.readFileSync(cert)\n }\n : {};\n const server = (isHttp ? this.http : this.https).createServer(options, (req, res) => {\n const { winTitle, winBodyHtml } = this.#config;\n res.writeHead(200, { 'Content-Type': 'text/html' });\n // Auto closing window for now. Can always leave it up and allow authConfig props to set title and bodyHtml\n res.end(\n `<html><head><title>${winTitle}</title><script>window.close();</script></head><body>${winBodyHtml}</body></html>`\n );\n const queryString = req.url.split('?')[1];\n const urlParams = new URLSearchParams(queryString);\n const code = urlParams.get('code');\n const state = urlParams.get('state');\n const error = urlParams.get('error');\n const errorDesc = urlParams.get('error_description');\n if (error || (code && state === this.#dynState.state)) {\n // Stop receiving connections and close when all are handled.\n server.close();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n fnGetTokenAndFinish(code, error, errorDesc);\n }\n });\n server.listen(nPort);\n }\n }\n fnOpenPopup();\n }\n };\n\n /* Retrieve token(s) and close login window */\n const fnGetTokenAndFinish = (code, error, errorDesc) => {\n // Can clear state in session info at this point\n delete this.#dynState.state;\n this.#updateConfig();\n\n if (!this.isNode) {\n fnEnableMessageReceiver(false);\n if (bWinIframe) {\n clearTimeout(tmrAuthComplete);\n fnCloseIframe();\n } else {\n clearInterval(checkWindowClosed);\n try {\n if (myWindow) {\n myWindow.close();\n myWindow = null;\n }\n } catch (e) {\n // keep going and process code or error even though issue closing popup\n // eslint-disable-next-line no-console\n console.warn(`Error closing window: ${e}`);\n }\n }\n }\n if (code) {\n this.getToken(code)\n .then((token) => {\n resolve(token);\n })\n .catch((e) => {\n reject(e);\n });\n } else if (error) {\n // Handle some errors in a special manner and pass others back to client\n if (error === 'login_required') {\n // eslint-disable-next-line no-console\n console.warn('silent authentication failed...starting full authentication');\n const bSpecialDebugPath = false;\n if (bSpecialDebugPath) {\n fnSetSilentAuthFailed(false);\n bDisablePromptNone = true;\n } else {\n fnSetSilentAuthFailed(true);\n bDisablePromptNone = false;\n }\n this.#buildAuthorizeUrl(startState).then((url) => {\n theUrl = url;\n doAuthorize();\n });\n } else if (error === 'invalid_session_index') {\n // eslint-disable-next-line no-console\n console.warn('auth session no longer valid...starting new session');\n // In these scenarios, not much user can do without just starting a new session, so do that\n this.#updateSessionIndex(null);\n fnSetSilentAuthFailed(false);\n this.#buildAuthorizeUrl(startState).then((url) => {\n theUrl = url;\n doAuthorize();\n });\n } else {\n // eslint-disable-next-line no-console\n console.warn(`Authorize failed: ${error}. ${errorDesc}\\nFailing authorize url: ${theUrl}`);\n throw new Error(error, { cause: errorDesc });\n }\n }\n };\n\n this.#buildAuthorizeUrl(startState).then((url) => {\n theUrl = url;\n doAuthorize();\n });\n });\n }\n\n // Login redirect\n loginRedirect() {\n // eslint-disable-next-line no-restricted-globals\n const state = btoa(location.origin);\n this.#buildAuthorizeUrl(state).then((url) => {\n // eslint-disable-next-line no-restricted-globals\n location.href = url;\n });\n }\n\n // check state\n checkStateMatch(state) {\n return state === this.#dynState.state;\n }\n\n // Clear session index within config\n #updateSessionIndex(sessionIndex) {\n if (sessionIndex) {\n this.#dynState.sessionIndex = sessionIndex;\n this.#dynState.sessionIndexAttempts = 0;\n } else if (this.#dynState.sessionIndex) {\n delete this.#dynState.sessionIndex;\n }\n this.#updateConfig();\n }\n\n // For PKCE token endpoint includes code_verifier\n\n getToken(authCode) {\n // Reload config to pick up the previously stored codeVerifier\n this.#reloadConfig();\n\n const {\n serverType,\n isolationId,\n clientId,\n clientSecret,\n tokenUri,\n grantType,\n customTokenParams,\n userIdentifier,\n password,\n noPKCE,\n secureCookie\n } = this.#config;\n\n const { sessionIndex, acRedirectUri, codeVerifier } = this.#dynState;\n\n const bAuthCode = !grantType || grantType === 'authCode';\n if (bAuthCode && !authCode && !this.isNode) {\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n authCode = urlParams.get('code');\n }\n\n const formData = new URLSearchParams();\n formData.append('client_id', clientId);\n if (clientSecret) {\n formData.append('client_secret', clientSecret);\n }\n if (secureCookie) {\n formData.append('send_token_as_cookie', 'true');\n }\n\n const fullGTName = {\n authCode: 'authorization_code',\n clientCreds: 'client_credentials',\n customBearer: 'custom-bearer',\n passwordCreds: 'password'\n }[grantType];\n formData.append('grant_type', fullGTName || grantType || 'authorization_code');\n if (serverType === 'launchpad' && grantType !== 'authCode' && isolationId) {\n formData.append('isolation_ids', isolationId);\n }\n if (bAuthCode) {\n formData.append('code', authCode);\n formData.append('redirect_uri', acRedirectUri);\n if (!noPKCE) {\n formData.append('code_verifier', codeVerifier);\n }\n } else if (sessionIndex) {\n formData.append('session_index', sessionIndex);\n }\n\n if (grantType === 'customBearer' && customTokenParams) {\n Object.keys(customTokenParams).forEach((param) => {\n formData.append(param, customTokenParams[param]);\n });\n }\n if (grantType !== 'authCode') {\n formData.append('enable_psyncId', 'true');\n }\n if (grantType === 'passwordCreds') {\n formData.append('username', userIdentifier);\n formData.append('password', atob(password));\n }\n\n return fetch(tokenUri, {\n agent: this.#getAgent(),\n method: 'POST',\n headers: new Headers({\n 'content-type': this.urlencoded\n }),\n credentials: secureCookie ? 'include' : 'omit',\n body: formData.toString()\n })\n .then((response) => {\n if (response.ok) {\n return response.json();\n }\n throw Error(`${this.tokenError}.`, { cause: response.status });\n })\n .then((token) => {\n if (token.errors || token.error) {\n // eslint-disable-next-line no-console\n console.error(`${this.tokenError}: ${JSON.stringify(token.errors || token.error)}`);\n } else {\n // .expires_in contains the # of seconds before access token expires\n // add property to keep track of current time when the token expires\n token.eA = Date.now() + token.expires_in * 1000;\n // Clear authCode related config state: state, codeVerifier, acRedirectUri\n if (this.#dynState.state) {\n delete this.#dynState.state;\n }\n if (this.#dynState.codeVerifier) {\n delete this.#dynState.codeVerifier;\n }\n if (this.#dynState.acRedirectUri) {\n delete this.#dynState.acRedirectUri;\n }\n // If there is a session_index then move this to the peConfig structure (as used on authorize)\n if (token.session_index) {\n this.#updateSessionIndex(token.session_index);\n // does an #updateConfig within #updateSessionIndex\n } else {\n this.#updateConfig();\n }\n }\n return token;\n })\n .catch((e) => {\n const msg = `${e}`;\n // eslint-disable-next-line no-console\n console.error(msg.indexOf(this.tokenError) !== -1 ? msg : `${this.tokenError}: ${msg}`);\n throw e;\n });\n }\n\n async refreshToken(refreshToken) {\n const { clientId, clientSecret, tokenUri, secureCookie } = this.#config;\n\n if (this.isNode && !this.crypto) {\n // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor\n await this.#importNodeLibs();\n }\n\n if (!secureCookie && !refreshToken) {\n return null;\n }\n\n const formData = new URLSearchParams();\n formData.append('client_id', clientId);\n if (clientSecret) {\n formData.append('client_secret', clientSecret);\n }\n formData.append('grant_type', 'refresh_token');\n if (secureCookie) {\n formData.append('send_token_as_cookie', 'true');\n }\n if (refreshToken) {\n formData.append('refresh_token', refreshToken);\n }\n\n return fetch(tokenUri, {\n agent: this.#getAgent(),\n method: 'POST',\n headers: new Headers({\n 'content-type': this.urlencoded\n }),\n credentials: secureCookie ? 'include' : 'omit',\n body: formData.toString()\n })\n .then((response) => {\n if (!response.ok && response.status === 401) {\n return null;\n }\n return response.json();\n })\n .then((token) => {\n if (token) {\n // .expires_in contains the # of seconds before access token expires\n // add property to keep track of current time when the token expires\n token.eA = Date.now() + token.expires_in * 1000;\n }\n return token;\n })\n .catch((e) => {\n // eslint-disable-next-line no-console\n console.warn(`Refresh token failed: ${e}`);\n return null;\n });\n }\n\n /**\n * Revokes tokens (useful as part of a logout operation). For non-secureCookie, the accessToken and\n * the optional refreshToken would be passed in and the routine will generate two separate revoke\n * transactions. For secureCookie scenario, will issue just one for the accessToken, but this will\n * also revoke the refresh token if present.\n * @param {string} accessToken - the access token (or any string value for secureCookie scenario)\n * @param {string} refreshToken - optional refresh token (or any string value for non secureCookie\n * scenario, when a refreshToken exists)\n * @returns\n */\n async revokeTokens(accessToken, refreshToken = null) {\n if (Object.keys(this.#config).length === 0) {\n // Must have a config structure to proceed\n return;\n }\n const { clientId, clientSecret, revokeUri, secureCookie } = this.#config;\n\n if (this.isNode && !this.crypto) {\n // Deferring dynamic loading of node libraries til this first method to avoid doing this in constructor\n await this.#importNodeLibs();\n }\n\n const headers = { 'content-type': this.urlencoded };\n if (clientSecret) {\n const basicCreds = btoa(`${clientId}:${clientSecret}`);\n headers.authorization = `Basic ${basicCreds}`;\n }\n\n // A revoke of a refresh_token will also revoke any associated access_tokens, so only one\n // transaction is necessary.\n const prop = refreshToken ? 'refresh_token' : 'access_token';\n const formData = new URLSearchParams();\n if (!clientSecret) {\n formData.append('client_id', clientId);\n }\n if (secureCookie) {\n formData.append('send_token_as_cookie', 'true');\n }\n const token = prop === 'access_token' ? accessToken : refreshToken;\n if (!secureCookie && token) {\n formData.append('token', token);\n }\n formData.append('token_type_hint', prop);\n return fetch(revokeUri, {\n agent: this.#getAgent(),\n method: 'POST',\n headers: new Headers(headers),\n credentials: secureCookie ? 'include' : 'omit',\n body: formData.toString()\n })\n .then((response) => {\n if (!response.ok) {\n // eslint-disable-next-line no-console\n console.error(`Error revoking ${prop}:${response.status}`);\n }\n })\n .catch((e) => {\n // eslint-disable-next-line no-console\n console.error(`Error revoking ${prop}; ${e}`);\n })\n .finally(() => {\n this.#dynState.silentAuthFailed = false;\n // Also clobber any sessionIndex\n this.#updateSessionIndex(null);\n });\n }\n\n // For userinfo endpoint to return meaningful data, endpoint must include appAlias (if specified) and authorize must\n // specify profile and optionally email scope to get such info returned\n async getUserinfo(accessToken) {\n if (!this.#config || !this.#config.userinfoUri) {\n // Must have a config structure and userInfo to proceed\n return {};\n }\n const headers = {\n authorization: `bearer ${accessToken}`,\n 'content-type': 'application/json;charset=UTF-8'\n };\n return fetch(this.#config.userinfoUri, {\n agent: this.#getAgent(),\n method: 'GET',\n headers: new Headers(headers)\n })\n .then((response) => {\n if (response.ok) {\n return response.json();\n }\n // eslint-disable-next-line no-console\n console.log(`Error invoking userinfo: ${response.status}`);\n })\n .then((data) => {\n return data;\n })\n .catch((e) => {\n // eslint-disable-next-line no-console\n console.log(e);\n });\n }\n\n #sha256Hash(str) {\n // Found that the Node implementation of subtle.digest is yielding incorrect results\n // so using a different set of apis to get expected results.\n if (this.isNode) {\n return new Promise((resolve) => {\n resolve(this.crypto.createHash('sha256').update(str).digest());\n });\n }\n return this.subtle.digest('SHA-256', new TextEncoder().encode(str));\n }\n\n // Base64 encode\n /* eslint-disable-next-line class-methods-use-this */\n #encode64(buff) {\n return btoa(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));\n }\n\n /*\n * Base64 url safe encoding of an array\n */\n #base64UrlSafeEncode(buf) {\n return this.#encode64(buf).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n }\n\n /*\n * Get Random string starting with buffer of specified size\n */\n #getRandomString(nSize) {\n const buf = new Uint8Array(nSize);\n this.crypto.getRandomValues(buf);\n return this.#base64UrlSafeEncode(buf);\n }\n\n /*\n * Calc code verifier if necessary\n */\n async #getCodeChallenge(codeVerifier) {\n return this.#sha256Hash(codeVerifier)\n .then((hashed) => {\n return this.#base64UrlSafeEncode(hashed);\n })\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.error(`Error calculation code challenge for PKCE: ${error}`);\n })\n .finally(() => {\n return null;\n });\n }\n\n /*\n * Return agent value for POST commands\n */\n #getAgent() {\n if (this.isNode && this.#config.ignoreInvalidCerts) {\n const options = { rejectUnauthorized: false };\n if (this.#config.legacyTLS) {\n options.secureOptions = this.crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT;\n }\n return new this.https.Agent(options);\n }\n return undefined;\n }\n }\n\n export default PegaAuth;\n"]}
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/components/helpers/auth.js"],"names":[],"mappings":";;;;;;AAAA,MAAM,QAAQ;IAEZ,YAAY,WAAW;;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,YAAY;QACR,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjE,IAAI,GAAG,GAAG,EAAE,CAAC;QAC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DAIS,IAAI;IACV,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9F,CAAC,yEAKoB,GAAG;IACpB,MAAM,CAAC,GAAG,uBAAA,IAAI,+CAAU,MAAd,IAAI,EAAW,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,CAAC;AACb,CAAC,mEAKiB,aAAa;IAC3B,OAAO,uBAAA,IAAI,iDAAY,MAAhB,IAAI,EAAa,aAAa,CAAC,CAAC,IAAI,CACvC,CAAC,MAAM,EAAE,EAAE;QACT,OAAO,uBAAA,IAAI,0DAAqB,MAAzB,IAAI,EAAsB,MAAM,CAAC,CAAA;IAC1C,CAAC,CACJ,CAAC,KAAK,CACH,CAAC,KAAK,EAAE,EAAE;QACR,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC,CACJ,CAAC,OAAO,CACL,GAAG,EAAE,GAAG,OAAO,IAAI,CAAA,CAAC,CAAC,CACxB,CAAA;AACL,CAAC;AAKH,eAAe,QAAQ,CAAC","sourcesContent":["class PegaAuth {\n\n constructor(ssKeyConfig) {\n this.ssKeyConfig = ssKeyConfig;\n this.bEncodeSI = false;\n this.reloadConfig();\n }\n\n reloadConfig() {\n const peConfig = window.sessionStorage.getItem(this.ssKeyConfig);\n let obj = {};\n if( peConfig ) {\n try {\n obj = JSON.parse(peConfig);\n } catch (e) {\n try {\n obj = JSON.parse(window.atob(peConfig));\n } catch(e2) {\n obj = {};\n }\n }\n }\n\n this.config = peConfig ? obj : null;\n }\n\n #updateConfig() {\n const sSI = JSON.stringify(this.config);\n window.sessionStorage.setItem(this.ssKeyConfig, this.bEncodeSI ? window.btoa(sSI) : sSI);\n }\n\n // For PKCE the authorize includes a code_challenge & code_challenge_method as well\n async #buildAuthorizeUrl(state) {\n const {clientId, redirectUri, authorizeUri, authService, sessionIndex, appAlias, useLocking,\n userIdentifier, password} = this.config;\n\n // Generate random string of 64 chars for verifier. RFC 7636 says from 43-128 chars\n let buf = new Uint8Array(64);\n window.crypto.getRandomValues(buf);\n this.config.codeVerifier = this.#base64UrlSafeEncode(buf);\n // If sessionIndex exists then increment attempts count (we will stop sending session_index after two failures)\n if( sessionIndex ) {\n this.config.sessionIndexAttempts += 1;\n }\n // Persist codeVerifier in session storage so it survives the redirects that are to follow\n this.#updateConfig();\n\n if( !state ) {\n // Calc random state variable\n buf = new Uint8Array(32);\n window.crypto.getRandomValues(buf);\n state = this.#base64UrlSafeEncode(buf);\n }\n\n // Trim alias to include just the real alias piece\n const addtlScope = appAlias ? `+app.alias.${appAlias.replace(/^app\\//, '')}` : \"\";\n\n // Add explicit creds if specified to try to avoid login popup\n const moreAuthArgs =\n (authService ? `&authentication_service=${encodeURIComponent(authService)}` : \"\") +\n (sessionIndex && this.config.sessionIndexAttempts < 3 ? `&session_index=${sessionIndex}` : \"\") +\n (useLocking ? `&enable_psyncId=true` : '') +\n (userIdentifier ? `&UserIdentifier=${encodeURIComponent(userIdentifier)}` : '') +\n (userIdentifier && password ? `&Password=${encodeURIComponent(window.atob(password))}` : '');\n\n return this.#getCodeChallenge(this.config.codeVerifier).then( cc => {\n // Now includes new enable_psyncId=true and session_index params\n return `${authorizeUri}?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&scope=openid+email+profile${addtlScope}&state=${state}&code_challenge=${cc}&code_challenge_method=S256${moreAuthArgs}`;\n });\n }\n\n async login() {\n const fnGetRedirectUriOrigin = () => {\n const redirectUri = this.config.redirectUri;\n const nRootOffset = redirectUri.indexOf(\"//\");\n const nFirstPathOffset = nRootOffset !== -1 ? redirectUri.indexOf(\"/\",nRootOffset+2) : -1;\n return nFirstPathOffset !== -1 ? redirectUri.substring(0,nFirstPathOffset) : redirectUri;\n };\n\n const redirectOrigin = fnGetRedirectUriOrigin();\n // eslint-disable-next-line no-restricted-globals\n const state = window.btoa(location.origin);\n\n return new Promise( (resolve, reject) => {\n\n this.#buildAuthorizeUrl(state).then((url) => {\n let myWindow = null; // popup or iframe\n let elIframe = null;\n let elCloseBtn = null\n const iframeTimeout = this.config.silentTimeout !== undefined ? this.config.silentTimeout : 5000;\n let bWinIframe = iframeTimeout > 0 && ((!!this.config.userIdentifier && !!this.config.password) || this.config.iframeLoginUI || this.config.authService !== \"pega\");\n let tmrAuthComplete = null;\n let checkWindowClosed = null;\n const myWinOnLoad = () => {\n try{\n if( bWinIframe ) {\n // eslint-disable-next-line no-console\n console.log(\"authjs(login): loaded a page in iFrame\");\n elIframe.contentWindow.postMessage({type:\"PegaAuth\"}, redirectOrigin);\n } else {\n // eslint-disable-next-line no-console\n console.log(`authjs(login): loaded a page in popup window...sending 'PegaAuth' message. redirectOrigin: ${redirectOrigin}`);\n myWindow.postMessage({type:\"PegaAuth\"}, redirectOrigin);\n }\n } catch(e) {\n // eslint-disable-next-line no-console\n console.log(\"authjs(login): Exception trying to postMessage on load\");\n }\n };\n const fnOpenPopup = () => {\n myWindow = window.open(url, '_blank', 'width=700,height=500,left=200,top=100');\n if( !myWindow ) {\n // Blocked by popup-blocker\n // eslint-disable-next-line prefer-promise-reject-errors\n return reject(\"blocked\");\n }\n checkWindowClosed = setInterval( () => {\n if( myWindow.closed ) {\n clearInterval(checkWindowClosed);\n // eslint-disable-next-line prefer-promise-reject-errors\n reject(\"closed\");\n }\n try {\n // eslint-disable-next-line no-console\n console.log(`authjs(login): Posting message to popup window. redirectOrigin: ${redirectOrigin}`);\n myWindow.postMessage({type:\"PegaAuth\"}, redirectOrigin);\n } catch(e) {\n // eslint-disable-next-line no-console\n console.log(`authjs(login): Failed to post message to popup window. redirectOrigin: ${redirectOrigin}`);\n }\n }, 500);\n try {\n myWindow.addEventListener(\"load\", myWinOnLoad, true);\n } catch(e) {\n // eslint-disable-next-line no-console\n console.log(\"authjs(login): Exception trying to add onload handler to opened window;\")\n }\n };\n\n const fnCloseIframe = () => {\n elIframe.parentNode.removeChild(elIframe);\n elCloseBtn.parentNode.removeChild(elCloseBtn);\n // eslint-disable-next-line no-multi-assign\n elIframe = elCloseBtn = null;\n bWinIframe = false;\n };\n const fnCloseAndReject = () => {\n fnCloseIframe();\n // eslint-disable-next-line prefer-promise-reject-errors\n reject(\"closed\");\n };\n // If there is a userIdentifier and password specified or an external SSO auth service,\n // we can try to use this silently in an iFrame first\n if( bWinIframe ) {\n const nFrameZLevel = 99999;\n elIframe = document.createElement('iframe');\n // eslint-disable-next-line prefer-template\n elIframe.id = 'pe'+this.config.clientId;\n const loginBoxWidth=500;\n const loginBoxHeight=700;\n const oStyle = elIframe.style;\n oStyle.position = 'absolute';\n oStyle.display = 'none';\n oStyle.zIndex = nFrameZLevel;\n oStyle.top=`${Math.round(Math.max(window.innerHeight-loginBoxHeight,0)/2)}px`;\n oStyle.left=`${Math.round(Math.max(window.innerWidth-loginBoxWidth,0)/2)}px`;\n oStyle.width='500px';\n oStyle.height='700px';\n // Add Iframe to top of document DOM to have it load\n document.body.insertBefore(elIframe,document.body.firstChild);\n // Add Iframe to DOM to have it load\n document.getElementsByTagName('body')[0].appendChild(elIframe);\n elIframe.addEventListener(\"load\", myWinOnLoad, true);\n // Disallow iframe content attempts to navigate main window\n elIframe.setAttribute(\"sandbox\",\"allow-scripts allow-forms allow-same-origin\");\n elIframe.setAttribute('src', url);\n\n const svgCloseBtn =\n `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <svg width=\"34px\" height=\"34px\" viewBox=\"0 0 34 34\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <title>Dismiss - Black</title>\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1.000000, 1.000000)\">\n <circle fill=\"#252C32\" cx=\"16\" cy=\"16\" r=\"16\"></circle>\n <g transform=\"translate(9.109375, 9.214844)\" fill=\"#FFFFFF\" fill-rule=\"nonzero\">\n <path d=\"M12.7265625,0 L0,12.6210938 L1.0546875,13.5703125 L13.78125,1.0546875 L12.7265625,0 Z M13.7460938,12.5507812 L1.01953125,0 L0,1.01953125 L12.7617188,13.6054688 L13.7460938,12.5507812 Z\"></path>\n </g>\n </g>\n </g>\n </svg>`;\n const bCloseWithinFrame = false;\n elCloseBtn = document.createElement('img');\n elCloseBtn.onclick = fnCloseAndReject;\n // eslint-disable-next-line prefer-template\n elCloseBtn.src = 'data:image/svg+xml;base64,' + window.btoa(svgCloseBtn);\n const oBtnStyle = elCloseBtn.style;\n oBtnStyle.cursor = 'pointer';\n // If svg doesn't set width and height might want to set oBtStyle width and height to something like '2em'\n oBtnStyle.position = 'absolute';\n oBtnStyle.display = 'none';\n oBtnStyle.zIndex = nFrameZLevel+1;\n const nTopOffset = bCloseWithinFrame ? 5 : -10;\n const nRightOffset = bCloseWithinFrame ? -34 : -20;\n oBtnStyle.top = `${Math.round(Math.max(window.innerHeight-loginBoxHeight,0)/2)+nTopOffset}px`;\n oBtnStyle.left = `${Math.round(Math.max(window.innerWidth-loginBoxWidth,0)/2)+loginBoxWidth+nRightOffset}px`;\n document.body.insertBefore(elCloseBtn,document.body.firstChild);\n // If the password was wrong, then the login screen will be in the iframe\n // ..and with Pega without realization of US-372314 it may replace the top (main portal) window\n // For now set a timer and if the timer expires, remove the iFrame and use same url within\n // visible window\n tmrAuthComplete = setTimeout( () => {\n clearTimeout(tmrAuthComplete);\n // remove password from config\n if( this.config.password ) {\n delete this.config.password;\n this.#updateConfig();\n }\n\n if( this.config.iframeLoginUI ) {\n elIframe.style.display=\"block\";\n elCloseBtn.style.display=\"block\";\n } else {\n fnCloseIframe();\n // eslint-disable-next-line no-console\n console.log(`Opening popup inside tmrAuthComplete (bWinIframe: ${bWinIframe})`);\n fnOpenPopup();\n }\n }, iframeTimeout);\n } else {\n // eslint-disable-next-line no-console\n console.log(`Opening popup outside tmrAuthComplete (bWinIframe: ${bWinIframe})`);\n fnOpenPopup();\n }\n\n let authMessageReceiver = null;\n /* Retrieve token(s) and close login window */\n const fnGetTokenAndFinish = (code) => {\n window.removeEventListener(\"message\", authMessageReceiver, false);\n this.getToken(code).then(token => {\n if( bWinIframe ) {\n clearTimeout(tmrAuthComplete);\n fnCloseIframe();\n } else {\n clearInterval(checkWindowClosed);\n try {\n myWindow.close();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(`attempt to close opened window failed`);\n }\n }\n resolve(token);\n })\n .catch(e => {\n reject(e);\n });\n };\n /* Handler to receive the auth code */\n authMessageReceiver = (event) => {\n // Check origin to make sure it is the redirect origin\n if( event.origin !== redirectOrigin ) {\n // eslint-disable-next-line no-console\n console.info(`Received event from unexpected origin: ${event.origin} (was expecting: ${redirectOrigin})`);\n }\n if( !event.data || !event.data.type || event.data.type !== \"PegaAuth\" )\n return;\n // eslint-disable-next-line no-console\n console.log(\"authjs(login): postMessage received with code\");\n const code = event.data.code.toString();\n fnGetTokenAndFinish(code);\n };\n window.addEventListener(\"message\", authMessageReceiver, false);\n window.authCodeCallback = (code) => {\n // eslint-disable-next-line no-console\n console.log(\"authjs(login): authCodeCallback used with code\");\n fnGetTokenAndFinish(code);\n };\n });\n });\n }\n\n // Login redirect\n loginRedirect() {\n // eslint-disable-next-line no-restricted-globals\n const state = btoa(location.origin);\n this.#buildAuthorizeUrl(state).then((url) => {\n // eslint-disable-next-line no-restricted-globals\n location.href = url;\n });\n }\n\n\n // For PKCE token endpoint includes code_verifier\n getToken(authCode) {\n // Reload config to pick up the previously stored codeVerifier\n this.reloadConfig();\n\n const {clientId, clientSecret, redirectUri, tokenUri, codeVerifier} = this.config;\n\n // eslint-disable-next-line no-restricted-globals\n const queryString = location.search;\n const urlParams = new URLSearchParams(queryString);\n const code = authCode || urlParams.get(\"code\");\n\n const formData = new URLSearchParams();\n formData.append(\"client_id\", clientId);\n if( clientSecret ) {\n formData.append(\"client_secret\", clientSecret);\n }\n formData.append(\"grant_type\", \"authorization_code\");\n formData.append(\"code\", code);\n formData.append(\"redirect_uri\", redirectUri);\n formData.append(\"code_verifier\", codeVerifier);\n\n return fetch(tokenUri, {\n method: \"POST\",\n headers: new Headers({\n \"content-type\": \"application/x-www-form-urlencoded\",\n }),\n\n body: formData.toString(),\n })\n .then((response) => response.json())\n .then(token => {\n // .expires_in contains the # of seconds before access token expires\n // add property to keep track of current time when the token expires\n token.eA = Date.now() + (token.expires_in * 1000);\n if( this.config.codeVerifier ) {\n delete this.config.codeVerifier;\n }\n // If there is a session_index then move this to the peConfig structure (as used on authorize)\n if( token.session_index ) {\n this.config.sessionIndex = token.session_index;\n }\n // If we got a token and have a session index, then reset the sessionIndexAttempts\n if( this.config.sessionIndex ) {\n this.config.sessionIndexAttempts = 0;\n }\n this.#updateConfig();\n return token;\n })\n .catch(e => {\n // eslint-disable-next-line no-console\n console.log(e)\n });\n }\n\n /* eslint-disable camelcase */\n async refreshToken(refresh_token) {\n const {clientId, clientSecret, tokenUri} = this.config;\n\n const formData = new URLSearchParams();\n formData.append(\"client_id\", clientId);\n if( clientSecret ) {\n formData.append(\"client_secret\", clientSecret);\n }\n formData.append(\"grant_type\", \"refresh_token\");\n formData.append(\"refresh_token\", refresh_token);\n\n return fetch(tokenUri, {\n method: \"POST\",\n headers: new Headers({\n \"content-type\": \"application/x-www-form-urlencoded\",\n }),\n\n body: formData.toString(),\n })\n .then((response) => {\n if( !response.ok && response.status === 401 ) {\n return null;\n }\n return response.json();\n })\n .then(token => {\n if( token ) {\n // .expires_in contains the # of seconds before access token expires\n // add property to keep track of current time when the token expires\n token.eA = Date.now() + (token.expires_in * 1000);\n }\n return token;\n })\n .catch(e => {\n // eslint-disable-next-line no-console\n console.log(e)\n });\n }\n\n async revokeTokens(access_token, refresh_token = null) {\n if( !this.config || !this.config.revokeUri) {\n // Must have a config structure and revokeUri to proceed\n return;\n }\n const {clientId, clientSecret, revokeUri} = this.config;\n\n const hdrs = {\"content-type\":\"application/x-www-form-urlencoded\"};\n if( clientSecret ) {\n const creds = `${clientId}:${clientSecret}`;\n hdrs.authorization = `Basic ${window.btoa(creds)}`;\n }\n const aTknProps = [\"access_token\"];\n if( refresh_token ) {\n aTknProps.push(\"refresh_token\");\n }\n aTknProps.forEach( (prop) => {\n const formData = new URLSearchParams();\n if( !clientSecret ) {\n formData.append(\"client_id\", clientId);\n }\n formData.append(\"token\", prop===\"access_token\" ? access_token : refresh_token);\n formData.append(\"token_type_hint\", prop);\n fetch(revokeUri, {\n method: \"POST\",\n headers: new Headers(hdrs),\n body: formData.toString(),\n })\n .then((response) => {\n if( !response.ok ) {\n // eslint-disable-next-line no-console\n console.log( `Error revoking ${prop}:${response.status}` );\n }\n })\n .catch(e => {\n // eslint-disable-next-line no-console\n console.log(e);\n });\n } );\n // Also clobber any sessionIndex\n if( this.config.sessionIndex ) {\n delete this.config.sessionIndex;\n this.#updateConfig();\n }\n }\n\n // For userinfo endpoint to return meaningful data, endpoint must include appAlias (if specified) and authorize must\n // specify profile and optionally email scope to get such info returned\n async getUserinfo(access_token) {\n if( !this.config || !this.config.userinfoUri ) {\n // Must have a config structure and userInfo to proceed\n return {};\n }\n const hdrs = {'authorization':`bearer ${access_token}`,'content-type':'application/json;charset=UTF-8'};\n return fetch(this.config.userinfoUri, {\n method: \"GET\",\n headers: new Headers(hdrs)})\n .then( response => {\n if( response.ok) {\n return response.json();\n } else {\n // eslint-disable-next-line no-console\n console.log( `Error invoking userinfo: ${response.status}` );\n }\n })\n .then( data => {\n return data;\n })\n .catch(e => {\n // eslint-disable-next-line no-console\n console.log(e);\n });\n }\n\n /* eslint-enable camelcase */\n\n // eslint-disable-next-line class-methods-use-this\n #sha256Hash(str) {\n return window.crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(str));\n }\n\n // Base64 encode\n // eslint-disable-next-line class-methods-use-this\n #encode64(buff) {\n return window.btoa(new Uint8Array(buff).reduce((s, b) => s + String.fromCharCode(b), ''));\n }\n\n /*\n * Base64 url safe encoding of an array\n */\n #base64UrlSafeEncode(buf) {\n const s = this.#encode64(buf).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=/g, \"\");\n return s;\n }\n\n /* Calc code verifier if necessary\n */\n /* eslint-disable camelcase */\n #getCodeChallenge(code_verifier) {\n return this.#sha256Hash(code_verifier).then (\n (hashed) => {\n return this.#base64UrlSafeEncode(hashed)\n }\n ).catch(\n (error) => {\n // eslint-disable-next-line no-console\n console.log(error)\n }\n ).finally(\n () => { return null }\n )\n }\n /* eslint-enable camelcase */\n\n}\n\nexport default PegaAuth;\n"]}
|
package/package.json
CHANGED
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|