@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/react.mjs
CHANGED
|
@@ -1081,6 +1081,39 @@ Available Console Commands:
|
|
|
1081
1081
|
this.attachEventListeners();
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
1084
|
+
/** Origins allowed to send Composer postMessage commands to the SDK. */
|
|
1085
|
+
isAllowedComposerOrigin(origin) {
|
|
1086
|
+
if (typeof window === "undefined") return false;
|
|
1087
|
+
if (origin === window.location.origin) return true;
|
|
1088
|
+
const staticAllowed = [
|
|
1089
|
+
"http://localhost:5001",
|
|
1090
|
+
"http://localhost:3001",
|
|
1091
|
+
"https://amplifyup.ai",
|
|
1092
|
+
"https://orchestrator.amplifyup.com"
|
|
1093
|
+
];
|
|
1094
|
+
if (staticAllowed.includes(origin)) return true;
|
|
1095
|
+
try {
|
|
1096
|
+
const host = new URL(origin).hostname;
|
|
1097
|
+
if (host === "amplifyup.ai" || host.endsWith(".amplifyup.ai")) return true;
|
|
1098
|
+
} catch {
|
|
1099
|
+
}
|
|
1100
|
+
const orchestratorFromQuery = (() => {
|
|
1101
|
+
try {
|
|
1102
|
+
const value = new URLSearchParams(window.location.search).get("orchestratorUrl");
|
|
1103
|
+
return value ? new URL(value).origin : null;
|
|
1104
|
+
} catch {
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1107
|
+
})();
|
|
1108
|
+
if (orchestratorFromQuery && origin === orchestratorFromQuery) return true;
|
|
1109
|
+
if (this.orchestratorUrl) {
|
|
1110
|
+
try {
|
|
1111
|
+
if (new URL(this.orchestratorUrl).origin === origin) return true;
|
|
1112
|
+
} catch {
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1084
1117
|
/**
|
|
1085
1118
|
* Set up postMessage listener for highlighting commands from orchestrator
|
|
1086
1119
|
*/
|
|
@@ -1096,18 +1129,10 @@ Available Console Commands:
|
|
|
1096
1129
|
currentOrigin: window.location.origin,
|
|
1097
1130
|
data: event.data
|
|
1098
1131
|
});
|
|
1099
|
-
|
|
1100
|
-
"http://localhost:5001",
|
|
1101
|
-
"http://localhost:3001",
|
|
1102
|
-
"https://orchestrator.amplifyup.com"
|
|
1103
|
-
];
|
|
1104
|
-
const isSameOrigin = event.origin === window.location.origin;
|
|
1105
|
-
const isAllowedOrigin = allowedOrigins.some((origin) => event.origin.startsWith(origin));
|
|
1106
|
-
if (!isSameOrigin && !isAllowedOrigin) {
|
|
1132
|
+
if (!this.isAllowedComposerOrigin(event.origin)) {
|
|
1107
1133
|
console.warn("[AmplifyUp SDK] Rejected message from unauthorized origin:", {
|
|
1108
1134
|
eventOrigin: event.origin,
|
|
1109
|
-
currentOrigin: window.location.origin
|
|
1110
|
-
allowedOrigins
|
|
1135
|
+
currentOrigin: window.location.origin
|
|
1111
1136
|
});
|
|
1112
1137
|
return;
|
|
1113
1138
|
}
|
|
@@ -1920,7 +1945,7 @@ function AmplifyRenderer({
|
|
|
1920
1945
|
return /* @__PURE__ */ jsx("main", { children: layoutTree.map((node) => /* @__PURE__ */ jsx("div", { children: renderNode(node) }, node.id)) });
|
|
1921
1946
|
}
|
|
1922
1947
|
function defaultPreviewCanvas() {
|
|
1923
|
-
return /* @__PURE__ */ jsx(
|
|
1948
|
+
return /* @__PURE__ */ jsx(
|
|
1924
1949
|
"div",
|
|
1925
1950
|
{
|
|
1926
1951
|
"data-slot-id": "main",
|
|
@@ -1928,7 +1953,7 @@ function defaultPreviewCanvas() {
|
|
|
1928
1953
|
"data-slot-empty": "true",
|
|
1929
1954
|
className: "min-h-[50vh] w-full"
|
|
1930
1955
|
}
|
|
1931
|
-
)
|
|
1956
|
+
);
|
|
1932
1957
|
}
|
|
1933
1958
|
function hasAmplifyLayout(pageConfig) {
|
|
1934
1959
|
return !!(pageConfig && pageConfig.id !== "default" && Array.isArray(pageConfig.layoutTree) && pageConfig.layoutTree.length > 0);
|