Merge pull request #1244 from thecodingmachine/warning_message_on_iframe_api

Adding a warning message if an unauthorized iFrame tries to communicate with WA
This commit is contained in:
David Négrier 2021-06-28 15:24:55 +02:00 committed by GitHub
commit 49d627ca38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,11 +123,18 @@ class IframeListener {
}
}
const payload = message.data;
if (foundSrc === undefined) {
if (isIframeEventWrapper(payload)) {
console.warn('It seems an iFrame is trying to communicate with WorkAdventure but was not explicitly granted the permission to do so. ' +
'If you are looking to use the WorkAdventure Scripting API inside an iFrame, you should allow the ' +
'iFrame to communicate with WorkAdventure by using the "openWebsiteAllowApi" property in your map (or passing "true" as a second' +
'parameter to WA.nav.openCoWebSite())');
}
return;
}
const payload = message.data;
if (isIframeEventWrapper(payload)) {
if (payload.type === 'showLayer' && isLayerEvent(payload.data)) {
this._showLayerStream.next(payload.data);