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