@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/index.js
CHANGED
|
@@ -11184,11 +11184,10 @@ var Ad4mConnect = class extends EventTarget {
|
|
|
11184
11184
|
setLocal("ad4m-last-host", JSON.stringify({ id: host.id, url: host.url, name: host.name, location: host.location }));
|
|
11185
11185
|
}
|
|
11186
11186
|
initializeEmbeddedMode() {
|
|
11187
|
-
var _a;
|
|
11188
11187
|
console.log("[Ad4m Connect] Running in embedded mode - waiting for AD4M config from parent");
|
|
11189
11188
|
window.addEventListener("message", (event) => __async(this, null, function* () {
|
|
11190
|
-
var
|
|
11191
|
-
if (((
|
|
11189
|
+
var _a;
|
|
11190
|
+
if (((_a = event.data) == null ? void 0 : _a.type) === "AD4M_CONFIG") {
|
|
11192
11191
|
if (event.source !== window.parent) {
|
|
11193
11192
|
console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from invalid source (not parent window)");
|
|
11194
11193
|
return;
|
|
@@ -11225,14 +11224,18 @@ var Ad4mConnect = class extends EventTarget {
|
|
|
11225
11224
|
if (!event.origin || event.origin === "null") {
|
|
11226
11225
|
throw new Error("AD4M proxy mode requires a non-opaque parent origin. Ensure the host iframe is not sandboxed without allow-same-origin.");
|
|
11227
11226
|
}
|
|
11228
|
-
const
|
|
11229
|
-
|
|
11227
|
+
const parentOrigin = event.origin;
|
|
11228
|
+
class WsImpl extends PostMessageWebSocket {
|
|
11229
|
+
constructor(url) {
|
|
11230
|
+
super(url, parentOrigin);
|
|
11231
|
+
}
|
|
11232
|
+
}
|
|
11230
11233
|
this.notifyConnectionChange("connecting");
|
|
11231
11234
|
this.ad4mClient = new Ad4mClient(
|
|
11232
11235
|
"http://proxy",
|
|
11233
11236
|
normalizedToken,
|
|
11234
11237
|
false,
|
|
11235
|
-
{ webSocketImpl:
|
|
11238
|
+
{ webSocketImpl: WsImpl }
|
|
11236
11239
|
);
|
|
11237
11240
|
this.notifyConnectionChange("connected");
|
|
11238
11241
|
yield this.checkAuth();
|
|
@@ -11277,14 +11280,7 @@ var Ad4mConnect = class extends EventTarget {
|
|
|
11277
11280
|
}
|
|
11278
11281
|
}));
|
|
11279
11282
|
console.log("[Ad4m Connect] Requesting AD4M config from parent window");
|
|
11280
|
-
|
|
11281
|
-
const referrerOrigin = document.referrer ? new URL(document.referrer).origin : null;
|
|
11282
|
-
if (referrerOrigin && ((_a = this.options.allowedOrigins) == null ? void 0 : _a.includes(referrerOrigin))) {
|
|
11283
|
-
parentOrigin = referrerOrigin;
|
|
11284
|
-
} else if (this.options.allowedOrigins && this.options.allowedOrigins.length === 1) {
|
|
11285
|
-
parentOrigin = this.options.allowedOrigins[0];
|
|
11286
|
-
}
|
|
11287
|
-
window.parent.postMessage({ type: "REQUEST_AD4M_CONFIG" }, parentOrigin);
|
|
11283
|
+
window.parent.postMessage({ type: "REQUEST_AD4M_CONFIG" }, "*");
|
|
11288
11284
|
}
|
|
11289
11285
|
buildAppInfo() {
|
|
11290
11286
|
return {
|