@amplifyup/sdk 0.1.8 → 0.1.10
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/AmplifyRenderer.js +35 -10
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +35 -10
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +35 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -10
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +37 -12
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +37 -12
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -200,6 +200,8 @@ declare class AmplifyUpSDK {
|
|
|
200
200
|
* Manually trigger event tracking setup (useful after dynamic content loads)
|
|
201
201
|
*/
|
|
202
202
|
refreshEventTracking(): void;
|
|
203
|
+
/** Origins allowed to send Composer postMessage commands to the SDK. */
|
|
204
|
+
private isAllowedComposerOrigin;
|
|
203
205
|
/**
|
|
204
206
|
* Set up postMessage listener for highlighting commands from orchestrator
|
|
205
207
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -200,6 +200,8 @@ declare class AmplifyUpSDK {
|
|
|
200
200
|
* Manually trigger event tracking setup (useful after dynamic content loads)
|
|
201
201
|
*/
|
|
202
202
|
refreshEventTracking(): void;
|
|
203
|
+
/** Origins allowed to send Composer postMessage commands to the SDK. */
|
|
204
|
+
private isAllowedComposerOrigin;
|
|
203
205
|
/**
|
|
204
206
|
* Set up postMessage listener for highlighting commands from orchestrator
|
|
205
207
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1075,6 +1075,39 @@ Available Console Commands:
|
|
|
1075
1075
|
this.attachEventListeners();
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
|
+
/** Origins allowed to send Composer postMessage commands to the SDK. */
|
|
1079
|
+
isAllowedComposerOrigin(origin) {
|
|
1080
|
+
if (typeof window === "undefined") return false;
|
|
1081
|
+
if (origin === window.location.origin) return true;
|
|
1082
|
+
const staticAllowed = [
|
|
1083
|
+
"http://localhost:5001",
|
|
1084
|
+
"http://localhost:3001",
|
|
1085
|
+
"https://amplifyup.ai",
|
|
1086
|
+
"https://orchestrator.amplifyup.com"
|
|
1087
|
+
];
|
|
1088
|
+
if (staticAllowed.includes(origin)) return true;
|
|
1089
|
+
try {
|
|
1090
|
+
const host = new URL(origin).hostname;
|
|
1091
|
+
if (host === "amplifyup.ai" || host.endsWith(".amplifyup.ai")) return true;
|
|
1092
|
+
} catch {
|
|
1093
|
+
}
|
|
1094
|
+
const orchestratorFromQuery = (() => {
|
|
1095
|
+
try {
|
|
1096
|
+
const value = new URLSearchParams(window.location.search).get("orchestratorUrl");
|
|
1097
|
+
return value ? new URL(value).origin : null;
|
|
1098
|
+
} catch {
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
})();
|
|
1102
|
+
if (orchestratorFromQuery && origin === orchestratorFromQuery) return true;
|
|
1103
|
+
if (this.orchestratorUrl) {
|
|
1104
|
+
try {
|
|
1105
|
+
if (new URL(this.orchestratorUrl).origin === origin) return true;
|
|
1106
|
+
} catch {
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
return false;
|
|
1110
|
+
}
|
|
1078
1111
|
/**
|
|
1079
1112
|
* Set up postMessage listener for highlighting commands from orchestrator
|
|
1080
1113
|
*/
|
|
@@ -1090,18 +1123,10 @@ Available Console Commands:
|
|
|
1090
1123
|
currentOrigin: window.location.origin,
|
|
1091
1124
|
data: event.data
|
|
1092
1125
|
});
|
|
1093
|
-
|
|
1094
|
-
"http://localhost:5001",
|
|
1095
|
-
"http://localhost:3001",
|
|
1096
|
-
"https://orchestrator.amplifyup.com"
|
|
1097
|
-
];
|
|
1098
|
-
const isSameOrigin = event.origin === window.location.origin;
|
|
1099
|
-
const isAllowedOrigin = allowedOrigins.some((origin) => event.origin.startsWith(origin));
|
|
1100
|
-
if (!isSameOrigin && !isAllowedOrigin) {
|
|
1126
|
+
if (!this.isAllowedComposerOrigin(event.origin)) {
|
|
1101
1127
|
console.warn("[AmplifyUp SDK] Rejected message from unauthorized origin:", {
|
|
1102
1128
|
eventOrigin: event.origin,
|
|
1103
|
-
currentOrigin: window.location.origin
|
|
1104
|
-
allowedOrigins
|
|
1129
|
+
currentOrigin: window.location.origin
|
|
1105
1130
|
});
|
|
1106
1131
|
return;
|
|
1107
1132
|
}
|