@moloodev/platform 0.2.2 → 0.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moloodev/platform",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -23,7 +23,7 @@
23
23
  "@types/node": "^24.13.3",
24
24
  "tsx": "^4.23.13",
25
25
  "typescript": "^7.0.2",
26
- "@moloodev/typescript-config": "0.2.2"
26
+ "@moloodev/typescript-config": "0.4.0"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
@@ -0,0 +1,12 @@
1
+ /** Dev views are local capabilities, never arbitrary user-hosted code origins. */
2
+ export function loopbackOrigin(input: unknown): string {
3
+ if (typeof input !== "string") throw new Error("Invalid loopback origin");
4
+ const url = new URL(input);
5
+ if (
6
+ !["http:", "https:"].includes(url.protocol) ||
7
+ !["localhost", "127.0.0.1", "[::1]"].includes(url.hostname) ||
8
+ url.username || url.password || url.pathname !== "/" || url.search || url.hash ||
9
+ input !== url.origin
10
+ ) throw new Error("Expected a loopback origin (localhost, 127.0.0.1, or [::1])");
11
+ return url.origin;
12
+ }
package/src/index.ts CHANGED
@@ -86,3 +86,5 @@ export * from "./occupancy-protocol";
86
86
  export * from "./file-content";
87
87
  export * from "./bundle";
88
88
  export * from "./file-delivery";
89
+
90
+ export { loopbackOrigin } from "./editor-dev";