@treeseed/core 0.6.24 → 0.6.25

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/site.js CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  resolveTreeseedSiteResource,
20
20
  resolveTreeseedStyleEntrypoint
21
21
  } from "./site-resources.js";
22
+ import { deriveTreeseedAstroAllowedDomains } from "./utils/astro-security.js";
22
23
  import { isSiteRenderedModel } from "./utils/site-models.js";
23
24
  const TENANT_THEME_VIRTUAL_ID = "virtual:treeseed/tenant-theme.css";
24
25
  const RESOLVED_TENANT_THEME_VIRTUAL_ID = "\0treeseed:tenant-theme.css";
@@ -234,6 +235,7 @@ function createTreeseedSite(tenantConfig, { starlight }) {
234
235
  const injectedDeployConfig = JSON.stringify(deployConfig);
235
236
  const resolvedGlobalCss = resolveTreeseedStyleEntrypoint(siteLayers, "styles/global.css");
236
237
  const serverRendered = deployConfig.surfaces?.web?.provider === "cloudflare" || deployConfig.providers.deploy === "cloudflare";
238
+ const allowedDomains = deriveTreeseedAstroAllowedDomains(deployConfig, { siteUrl: siteConfig.site.siteUrl });
237
239
  const publishedRuntime = getTreeseedContentServingMode() === "published_runtime";
238
240
  const packageRoutes = [
239
241
  ...PACKAGE_ROUTE_ENTRIES,
@@ -246,6 +248,10 @@ function createTreeseedSite(tenantConfig, { starlight }) {
246
248
  adapter: serverRendered ? cloudflare({ imageService: "compile" }) : void 0,
247
249
  output: serverRendered ? "server" : "static",
248
250
  session: serverRendered ? { driver: "null" } : void 0,
251
+ security: {
252
+ checkOrigin: true,
253
+ allowedDomains
254
+ },
249
255
  site: siteConfig.site.siteUrl,
250
256
  image: {
251
257
  service: {
@@ -0,0 +1,37 @@
1
+ const LOCAL_ASTRO_HOSTS = ["localhost", "127.0.0.1"];
2
+ function hostnameFromUrlLike(value) {
3
+ const trimmed = value?.trim();
4
+ if (!trimmed) return null;
5
+ const candidate = URL.canParse(trimmed) ? trimmed : URL.canParse(`https://${trimmed}`) ? `https://${trimmed}` : null;
6
+ if (!candidate) return null;
7
+ const url = new URL(candidate);
8
+ return url.hostname.trim().toLowerCase() || null;
9
+ }
10
+ function appendHostname(hostnames, value) {
11
+ const hostname = hostnameFromUrlLike(value);
12
+ if (hostname && !hostnames.includes(hostname)) {
13
+ hostnames.push(hostname);
14
+ }
15
+ }
16
+ function appendEnvironmentHostnames(hostnames, environments) {
17
+ for (const environment of environments) {
18
+ appendHostname(hostnames, environment?.domain);
19
+ appendHostname(hostnames, environment?.baseUrl);
20
+ }
21
+ }
22
+ function deriveTreeseedAstroAllowedDomains(deployConfig, options = {}) {
23
+ const hostnames = [];
24
+ const webSurface = deployConfig.surfaces?.web;
25
+ appendHostname(hostnames, deployConfig.siteUrl);
26
+ appendHostname(hostnames, options.siteUrl);
27
+ appendHostname(hostnames, webSurface?.publicBaseUrl);
28
+ appendHostname(hostnames, webSurface?.localBaseUrl);
29
+ appendEnvironmentHostnames(hostnames, Object.values(webSurface?.environments ?? {}));
30
+ for (const hostname of LOCAL_ASTRO_HOSTS) {
31
+ appendHostname(hostnames, hostname);
32
+ }
33
+ return hostnames.map((hostname) => ({ hostname }));
34
+ }
35
+ export {
36
+ deriveTreeseedAstroAllowedDomains
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/core",
3
- "version": "0.6.24",
3
+ "version": "0.6.25",
4
4
  "description": "Treeseed integrated platform starter for Astro/Starlight web runtimes and Hono API runtimes.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -76,7 +76,7 @@
76
76
  "@astrojs/sitemap": "3.7.0",
77
77
  "@astrojs/starlight": "0.37.6",
78
78
  "@tailwindcss/vite": "^4.1.4",
79
- "@treeseed/sdk": "0.6.23",
79
+ "@treeseed/sdk": "0.6.24",
80
80
  "astro": "^5.6.1",
81
81
  "esbuild": "^0.28.0",
82
82
  "hono": "^4.8.2",