fix(sdk,client): add listener to current frame window
arcad/edge/pipeline/head This commit looks good Details

This commit is contained in:
wpetit 2023-04-13 12:07:52 +02:00
parent de330c0042
commit dc93c585eb
3 changed files with 17 additions and 14 deletions

View File

@ -3960,25 +3960,26 @@ var Edge = (() => {
reject(new Error("Edge auth token request timed out !"));
}, timeout);
const listener = (evt) => {
const message = evt.data;
if (!message || !message.type || !message.data) {
const message2 = evt.data;
if (!message2 || !message2.type || !message2.data) {
return;
}
if (message.type !== EdgeAuthTokenResponse) {
if (message2.type !== EdgeAuthTokenResponse) {
return;
}
window.parent.removeEventListener("message", listener);
window.removeEventListener("message", listener);
clearTimeout(timeoutId);
if (timedOut)
return;
if (!message.data || !message.data.token) {
if (!message2.data || !message2.data.token) {
reject("Unexpected auth token request response !");
return;
}
resolve(message.data.token);
resolve(message2.data.token);
};
window.parent.addEventListener("message", listener);
window.parent.postMessage({ type: EdgeAuthTokenRequest }, "*");
window.addEventListener("message", listener);
const message = { type: EdgeAuthTokenRequest };
window.parent.postMessage(message, "*");
});
}
_handleEdgeAuthTokenRequest(evt) {

File diff suppressed because one or more lines are too long

View File

@ -143,7 +143,7 @@ export class Client extends EventTarget {
return;
}
window.parent.removeEventListener('message', listener);
window.removeEventListener('message', listener);
clearTimeout(timeoutId);
if (timedOut) return;
@ -156,8 +156,10 @@ export class Client extends EventTarget {
resolve(message.data.token);
}
window.parent.addEventListener('message', listener);
window.parent.postMessage({ type: EdgeAuthTokenRequest }, '*');
window.addEventListener('message', listener);
const message = { type: EdgeAuthTokenRequest };
window.parent.postMessage(message, '*');
})
}