@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.mjs
CHANGED
|
@@ -1071,6 +1071,39 @@ Available Console Commands:
|
|
|
1071
1071
|
this.attachEventListeners();
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
|
+
/** Origins allowed to send Composer postMessage commands to the SDK. */
|
|
1075
|
+
isAllowedComposerOrigin(origin) {
|
|
1076
|
+
if (typeof window === "undefined") return false;
|
|
1077
|
+
if (origin === window.location.origin) return true;
|
|
1078
|
+
const staticAllowed = [
|
|
1079
|
+
"http://localhost:5001",
|
|
1080
|
+
"http://localhost:3001",
|
|
1081
|
+
"https://amplifyup.ai",
|
|
1082
|
+
"https://orchestrator.amplifyup.com"
|
|
1083
|
+
];
|
|
1084
|
+
if (staticAllowed.includes(origin)) return true;
|
|
1085
|
+
try {
|
|
1086
|
+
const host = new URL(origin).hostname;
|
|
1087
|
+
if (host === "amplifyup.ai" || host.endsWith(".amplifyup.ai")) return true;
|
|
1088
|
+
} catch {
|
|
1089
|
+
}
|
|
1090
|
+
const orchestratorFromQuery = (() => {
|
|
1091
|
+
try {
|
|
1092
|
+
const value = new URLSearchParams(window.location.search).get("orchestratorUrl");
|
|
1093
|
+
return value ? new URL(value).origin : null;
|
|
1094
|
+
} catch {
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
})();
|
|
1098
|
+
if (orchestratorFromQuery && origin === orchestratorFromQuery) return true;
|
|
1099
|
+
if (this.orchestratorUrl) {
|
|
1100
|
+
try {
|
|
1101
|
+
if (new URL(this.orchestratorUrl).origin === origin) return true;
|
|
1102
|
+
} catch {
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1074
1107
|
/**
|
|
1075
1108
|
* Set up postMessage listener for highlighting commands from orchestrator
|
|
1076
1109
|
*/
|
|
@@ -1086,18 +1119,10 @@ Available Console Commands:
|
|
|
1086
1119
|
currentOrigin: window.location.origin,
|
|
1087
1120
|
data: event.data
|
|
1088
1121
|
});
|
|
1089
|
-
|
|
1090
|
-
"http://localhost:5001",
|
|
1091
|
-
"http://localhost:3001",
|
|
1092
|
-
"https://orchestrator.amplifyup.com"
|
|
1093
|
-
];
|
|
1094
|
-
const isSameOrigin = event.origin === window.location.origin;
|
|
1095
|
-
const isAllowedOrigin = allowedOrigins.some((origin) => event.origin.startsWith(origin));
|
|
1096
|
-
if (!isSameOrigin && !isAllowedOrigin) {
|
|
1122
|
+
if (!this.isAllowedComposerOrigin(event.origin)) {
|
|
1097
1123
|
console.warn("[AmplifyUp SDK] Rejected message from unauthorized origin:", {
|
|
1098
1124
|
eventOrigin: event.origin,
|
|
1099
|
-
currentOrigin: window.location.origin
|
|
1100
|
-
allowedOrigins
|
|
1125
|
+
currentOrigin: window.location.origin
|
|
1101
1126
|
});
|
|
1102
1127
|
return;
|
|
1103
1128
|
}
|