fix(sdk,client): add listener to current frame window
All checks were successful
arcad/edge/pipeline/head This commit looks good
All checks were successful
arcad/edge/pipeline/head This commit looks good
This commit is contained in:
parent
de330c0042
commit
dc93c585eb
17
pkg/sdk/client/dist/client.js
vendored
17
pkg/sdk/client/dist/client.js
vendored
@ -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) {
|
||||
|
6
pkg/sdk/client/dist/client.js.map
vendored
6
pkg/sdk/client/dist/client.js.map
vendored
File diff suppressed because one or more lines are too long
@ -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, '*');
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user