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