-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
279 changed files
with
4,509 additions
and
5,137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/.git | ||
**/.github | ||
**/.vscode | ||
**/.svn | ||
**/.hg | ||
**/*.md | ||
**/assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Prettier config options: https://prettier.io/docs/en/options.html | ||
// Shared front-end config: https://git.pega.io/projects/FE/repos/configs/browse/packages/prettier-config/index.json | ||
|
||
const pegaPrettierConfig = require('@pega/prettier-config'); | ||
|
||
module.exports = { | ||
...pegaPrettierConfig, | ||
printWidth: 150 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,94 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script> | ||
// This script file is retrieved by the standard html page that is specified as the | ||
// redirect uri for an authorization code grant (with or without PKCE) flow. | ||
// It attempts to pass back the received code, state and error using 3 techniques | ||
// 1) Try to call directly into a callback function (won't work across servers) | ||
// 2) Try to call directly to postMessage (won't work across domains) | ||
// 3) Awaits a message from the host page and when received immediately postMessages back with the code | ||
<head> | ||
<script> | ||
// This script file is retrieved by the standard html page that is specified as the | ||
// redirect uri for an authorization code grant (with or without PKCE) flow. | ||
// It attempts to pass back the received code, state and error using 3 techniques | ||
// 1) Try to call directly into a callback function (won't work across servers) | ||
// 2) Try to call directly to postMessage (won't work across domains) | ||
// 3) Awaits a message from the host page and when received immediately postMessages back with the code | ||
|
||
// For enabling logging via debugger (do not let it be a const...then can't change in debugger) | ||
// eslint-disable-next-line prefer-const | ||
let bDebug = false; | ||
// For enabling logging via debugger (do not let it be a const...then can't change in debugger) | ||
// eslint-disable-next-line prefer-const | ||
let bDebug = false; | ||
|
||
const queryString = window.location.search; | ||
const urlParams = new URLSearchParams(queryString); | ||
const code = urlParams.get('code'); | ||
const state = urlParams.get('state'); | ||
const error = urlParams.get('error'); | ||
const errorDesc = urlParams.get('error_description'); | ||
// Silent authentication will work with just regular console.log | ||
// eslint-disable-next-line no-console | ||
let fnLog = console.log; | ||
try { | ||
// Check if in a popup window. If so use main window console. | ||
if (window.opener.console.log) { | ||
fnLog = window.opener.console.log; | ||
} | ||
// eslint-disable-next-line no-empty | ||
} catch (e0) {} | ||
const doLog = (arg) => { | ||
if (bDebug) { | ||
fnLog(arg); | ||
} | ||
}; | ||
// doLog('Testing do Log'); | ||
let bSuccess = false; | ||
const queryString = window.location.search; | ||
const urlParams = new URLSearchParams(queryString); | ||
const code = urlParams.get('code'); | ||
const state = urlParams.get('state'); | ||
const error = urlParams.get('error'); | ||
const errorDesc = urlParams.get('error_description'); | ||
// Silent authentication will work with just regular console.log | ||
// eslint-disable-next-line no-console | ||
let fnLog = console.log; | ||
try { | ||
// Check if in a popup window. If so use main window console. | ||
if (window.opener.console.log) { | ||
fnLog = window.opener.console.log; | ||
} | ||
// eslint-disable-next-line no-empty | ||
} catch (e0) {} | ||
const doLog = arg => { | ||
if (bDebug) { | ||
fnLog(arg); | ||
} | ||
}; | ||
// doLog('Testing do Log'); | ||
let bSuccess = false; | ||
|
||
const getEmbedOriginFromState = () => { | ||
let embedOrigin = null; | ||
try { | ||
// Expect state to contain the embedding page's origin followed by random state separated by '.' | ||
if (state) { | ||
embedOrigin = window.atob(state.split('.')[0]); | ||
} | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
if (!embedOrigin) { | ||
embedOrigin = window.location.origin; | ||
} | ||
return embedOrigin; | ||
}; | ||
const getEmbedOriginFromState = () => { | ||
let embedOrigin = null; | ||
try { | ||
// Expect state to contain the embedding page's origin followed by random state separated by '.' | ||
if (state) { | ||
embedOrigin = window.atob(state.split('.')[0]); | ||
} | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
if (!embedOrigin) { | ||
embedOrigin = window.location.origin; | ||
} | ||
return embedOrigin; | ||
}; | ||
|
||
// eslint-disable-next-line sonarjs/cognitive-complexity | ||
function main() { | ||
if (code || error) { | ||
try { | ||
window.opener.authCodeCallback(code, state, error, errorDesc); | ||
bSuccess = true; | ||
} catch (e) { | ||
doLog('auth.html: Failed to directly access authCodeCallback.'); | ||
} | ||
// eslint-disable-next-line sonarjs/cognitive-complexity | ||
function main() { | ||
if (code || error) { | ||
try { | ||
window.opener.authCodeCallback(code, state, error, errorDesc); | ||
bSuccess = true; | ||
} catch (e) { | ||
doLog('auth.html: Failed to directly access authCodeCallback.'); | ||
} | ||
|
||
// Post messages require a targetDomain...trying to pass this via state | ||
const embedOrigin = getEmbedOriginFromState(); | ||
if (!bSuccess) { | ||
try { | ||
window.opener.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin); | ||
bSuccess = true; | ||
} catch (e) { | ||
doLog('auth.html: Failed to directly post message to opener'); | ||
} | ||
} | ||
// Post messages require a targetDomain...trying to pass this via state | ||
const embedOrigin = getEmbedOriginFromState(); | ||
if (!bSuccess) { | ||
try { | ||
window.opener.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin); | ||
bSuccess = true; | ||
} catch (e) { | ||
doLog('auth.html: Failed to directly post message to opener'); | ||
} | ||
} | ||
|
||
if (!bSuccess) { | ||
window.addEventListener('message', (event) => { | ||
doLog('authDone.js: received PegaAuth message'); | ||
if (event.data && event.data.type && event.data.type === 'PegaAuth') { | ||
doLog('authDone.js: posting message back'); | ||
event.source.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin); | ||
if (!bSuccess) { | ||
window.addEventListener('message', event => { | ||
doLog('authDone.js: received PegaAuth message'); | ||
if (event.data && event.data.type && event.data.type === 'PegaAuth') { | ||
doLog('authDone.js: posting message back'); | ||
event.source.postMessage({ type: 'PegaAuth', code, state, error, errorDesc }, embedOrigin); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
(() => { | ||
main(); | ||
})(); | ||
</script> | ||
<body> | ||
</body> | ||
(() => { | ||
main(); | ||
})(); | ||
</script> | ||
</head> | ||
<body></body> | ||
</html> |
8 changes: 4 additions & 4 deletions
8
packages/react-sdk-components/src/bridge/Context/StoreContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.