@coasys/ad4m-connect 0.13.0-postmessage-ws-proxy.2 → 0.13.0-postmessage-ws-proxy.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +10 -14
- package/dist/core.js.map +3 -3
- package/dist/index.js +10 -14
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -11095,11 +11095,10 @@ var Ad4mConnect = class extends EventTarget {
|
|
|
11095
11095
|
setLocal("ad4m-last-host", JSON.stringify({ id: host.id, url: host.url, name: host.name, location: host.location }));
|
|
11096
11096
|
}
|
|
11097
11097
|
initializeEmbeddedMode() {
|
|
11098
|
-
var _a;
|
|
11099
11098
|
console.log("[Ad4m Connect] Running in embedded mode - waiting for AD4M config from parent");
|
|
11100
11099
|
window.addEventListener("message", (event) => __async(this, null, function* () {
|
|
11101
|
-
var
|
|
11102
|
-
if (((
|
|
11100
|
+
var _a;
|
|
11101
|
+
if (((_a = event.data) == null ? void 0 : _a.type) === "AD4M_CONFIG") {
|
|
11103
11102
|
if (event.source !== window.parent) {
|
|
11104
11103
|
console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from invalid source (not parent window)");
|
|
11105
11104
|
return;
|
|
@@ -11136,14 +11135,18 @@ var Ad4mConnect = class extends EventTarget {
|
|
|
11136
11135
|
if (!event.origin || event.origin === "null") {
|
|
11137
11136
|
throw new Error("AD4M proxy mode requires a non-opaque parent origin. Ensure the host iframe is not sandboxed without allow-same-origin.");
|
|
11138
11137
|
}
|
|
11139
|
-
const
|
|
11140
|
-
|
|
11138
|
+
const parentOrigin = event.origin;
|
|
11139
|
+
class WsImpl extends PostMessageWebSocket {
|
|
11140
|
+
constructor(url) {
|
|
11141
|
+
super(url, parentOrigin);
|
|
11142
|
+
}
|
|
11143
|
+
}
|
|
11141
11144
|
this.notifyConnectionChange("connecting");
|
|
11142
11145
|
this.ad4mClient = new Ad4mClient(
|
|
11143
11146
|
"http://proxy",
|
|
11144
11147
|
normalizedToken,
|
|
11145
11148
|
false,
|
|
11146
|
-
{ webSocketImpl:
|
|
11149
|
+
{ webSocketImpl: WsImpl }
|
|
11147
11150
|
);
|
|
11148
11151
|
this.notifyConnectionChange("connected");
|
|
11149
11152
|
yield this.checkAuth();
|
|
@@ -11188,14 +11191,7 @@ var Ad4mConnect = class extends EventTarget {
|
|
|
11188
11191
|
}
|
|
11189
11192
|
}));
|
|
11190
11193
|
console.log("[Ad4m Connect] Requesting AD4M config from parent window");
|
|
11191
|
-
|
|
11192
|
-
const referrerOrigin = document.referrer ? new URL(document.referrer).origin : null;
|
|
11193
|
-
if (referrerOrigin && ((_a = this.options.allowedOrigins) == null ? void 0 : _a.includes(referrerOrigin))) {
|
|
11194
|
-
parentOrigin = referrerOrigin;
|
|
11195
|
-
} else if (this.options.allowedOrigins && this.options.allowedOrigins.length === 1) {
|
|
11196
|
-
parentOrigin = this.options.allowedOrigins[0];
|
|
11197
|
-
}
|
|
11198
|
-
window.parent.postMessage({ type: "REQUEST_AD4M_CONFIG" }, parentOrigin);
|
|
11194
|
+
window.parent.postMessage({ type: "REQUEST_AD4M_CONFIG" }, "*");
|
|
11199
11195
|
}
|
|
11200
11196
|
buildAppInfo() {
|
|
11201
11197
|
return {
|