From c0d8bbe27c2f6177acb6c3e55d5d7391829e6654 Mon Sep 17 00:00:00 2001 From: chudasama brijrajsinh Date: Mon, 8 Jan 2024 18:47:36 +0530 Subject: [PATCH] ppg 801 rpl frame issue --- src/assets/rpIFrame.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/assets/rpIFrame.js b/src/assets/rpIFrame.js index 1abe10722..621e2b38e 100644 --- a/src/assets/rpIFrame.js +++ b/src/assets/rpIFrame.js @@ -9,10 +9,10 @@ function onLoad() { function check_session() { let win = window.parent.document.getElementById("opIFrame").contentWindow; - let client_id = this.localStorage.getItem('client_id'); + let client_id = decrypt('client_id'); let session_state = this.localStorage.getItem('session_state'); let mes = client_id + ' ' + session_state; - win.postMessage(mes, 'https://identify.crowncommercial.gov.uk/'); + win.postMessage(mes, '*.crowncommercial.gov.uk'); } function setTimer() { @@ -32,7 +32,7 @@ function noticeToParentWindow(stat) { console.log('changed'); let secApiURl = this.localStorage.getItem('securityapiurl'); let redirect_uri = this.localStorage.getItem('redirect_uri') + '/authsuccess'; - let client_id = this.localStorage.getItem('client_id'); + let client_id = decrypt('client_id'); let secApi = secApiURl + '/security/authorize?client_id=' + client_id + '&redirect_uri=' + redirect_uri + '&response_type=code' + '&scope=email profile openid offline_access&prompt=none'; @@ -41,4 +41,24 @@ function noticeToParentWindow(stat) { } else { console.log('not-changed'); } +} + +function decrypt(key) { + const shift = 3; + var encryptedText = localStorage.getItem(key) || ''; + var decryptedText = ''; + for (var i = 0; i < encryptedText.length; i++) { + var charCode = encryptedText.charCodeAt(i); + if (charCode >= 65 && charCode <= 90) { + decryptedText += String.fromCharCode.apply(null,[((charCode - 65 - shift + 26) % 26) + 65]); + } + else if (charCode >= 97 && charCode <= 122) { + decryptedText += String.fromCharCode.apply(null,[((charCode - 97 - shift + 26) % 26) + 97]); + } + else { + decryptedText += encryptedText[i]; + } + } + + return decryptedText; } \ No newline at end of file