@amplifyup/sdk 0.1.9 → 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 +35 -10
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +35 -10
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -1057,6 +1057,39 @@ Available Console Commands:
|
|
|
1057
1057
|
this.attachEventListeners();
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
|
+
/** Origins allowed to send Composer postMessage commands to the SDK. */
|
|
1061
|
+
isAllowedComposerOrigin(origin) {
|
|
1062
|
+
if (typeof window === "undefined") return false;
|
|
1063
|
+
if (origin === window.location.origin) return true;
|
|
1064
|
+
const staticAllowed = [
|
|
1065
|
+
"http://localhost:5001",
|
|
1066
|
+
"http://localhost:3001",
|
|
1067
|
+
"https://amplifyup.ai",
|
|
1068
|
+
"https://orchestrator.amplifyup.com"
|
|
1069
|
+
];
|
|
1070
|
+
if (staticAllowed.includes(origin)) return true;
|
|
1071
|
+
try {
|
|
1072
|
+
const host = new URL(origin).hostname;
|
|
1073
|
+
if (host === "amplifyup.ai" || host.endsWith(".amplifyup.ai")) return true;
|
|
1074
|
+
} catch {
|
|
1075
|
+
}
|
|
1076
|
+
const orchestratorFromQuery = (() => {
|
|
1077
|
+
try {
|
|
1078
|
+
const value = new URLSearchParams(window.location.search).get("orchestratorUrl");
|
|
1079
|
+
return value ? new URL(value).origin : null;
|
|
1080
|
+
} catch {
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
})();
|
|
1084
|
+
if (orchestratorFromQuery && origin === orchestratorFromQuery) return true;
|
|
1085
|
+
if (this.orchestratorUrl) {
|
|
1086
|
+
try {
|
|
1087
|
+
if (new URL(this.orchestratorUrl).origin === origin) return true;
|
|
1088
|
+
} catch {
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1060
1093
|
/**
|
|
1061
1094
|
* Set up postMessage listener for highlighting commands from orchestrator
|
|
1062
1095
|
*/
|
|
@@ -1072,18 +1105,10 @@ Available Console Commands:
|
|
|
1072
1105
|
currentOrigin: window.location.origin,
|
|
1073
1106
|
data: event.data
|
|
1074
1107
|
});
|
|
1075
|
-
|
|
1076
|
-
"http://localhost:5001",
|
|
1077
|
-
"http://localhost:3001",
|
|
1078
|
-
"https://orchestrator.amplifyup.com"
|
|
1079
|
-
];
|
|
1080
|
-
const isSameOrigin = event.origin === window.location.origin;
|
|
1081
|
-
const isAllowedOrigin = allowedOrigins.some((origin) => event.origin.startsWith(origin));
|
|
1082
|
-
if (!isSameOrigin && !isAllowedOrigin) {
|
|
1108
|
+
if (!this.isAllowedComposerOrigin(event.origin)) {
|
|
1083
1109
|
console.warn("[AmplifyUp SDK] Rejected message from unauthorized origin:", {
|
|
1084
1110
|
eventOrigin: event.origin,
|
|
1085
|
-
currentOrigin: window.location.origin
|
|
1086
|
-
allowedOrigins
|
|
1111
|
+
currentOrigin: window.location.origin
|
|
1087
1112
|
});
|
|
1088
1113
|
return;
|
|
1089
1114
|
}
|