introduce data.type=config_info for the new postMessage in auth

This commit is contained in:
jothisubaramaniam
2020-11-25 16:28:16 -05:00
parent 7e49365080
commit 039970d710
3 changed files with 4 additions and 2 deletions
@@ -161,6 +161,7 @@ describe('showLoginPopup', () => {
source: popupMock,
origin: 'origin',
data: {
type: 'config_info',
targetOrigin: 'http://localhost',
},
} as MessageEvent);
@@ -198,6 +199,7 @@ describe('showLoginPopup', () => {
source: popupMock,
origin: 'origin',
data: {
type: 'config_info',
targetOrigin: 'http://differenthost',
},
} as MessageEvent);
+1 -1
View File
@@ -95,7 +95,7 @@ export function showLoginPopup(options: LoginPopupOptions): Promise<any> {
}
const { data } = event;
if (data.targetOrigin) {
if (data.type === 'config_info') {
targetOrigin = data.targetOrigin;
return;
}
@@ -53,7 +53,7 @@ export const postMessageResponse = (
const script = `
var authResponse = decodeURIComponent('${base64Data}');
var origin = decodeURIComponent('${base64Origin}');
var originInfo = {'targetOrigin': origin};
var originInfo = {'type': 'config_info', 'targetOrigin': origin};
(window.opener || window.parent).postMessage(originInfo, '*');
(window.opener || window.parent).postMessage(JSON.parse(authResponse), origin);
window.close();