@tokenoftrust/storefront-runner 2.4.33 → 2.4.35

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.
@@ -37,18 +37,10 @@ export interface PublicationTopologyDeclarationV1 {
37
37
  */
38
38
  export const PUBLICATION_SPACE_TOPOLOGY: Readonly<Record<string, PublicationTopologyDeclarationV1>> = {
39
39
  home: { root: { source: { forge: "fixture", repo: "home", defaultBranch: "main" } } },
40
+ // Root-only until its `articles` space goes live: /blog serves from root content. Go-live
41
+ // step 1 applies docs/playbooks/tokenoftrust-articles-mount-go-live.patch.
40
42
  "tokenoftrust.com": {
41
43
  root: { source: { forge: "gitea", repo: "tokenoftrust.com-main", defaultBranch: "main" } },
42
- mounted: [
43
- {
44
- id: "articles",
45
- source: { forge: "gitea", repo: "tokenoftrust.com-publications", defaultBranch: "main" },
46
- mount: "/blog",
47
- visibility: "public",
48
- // Decision m1b-mount-layout-2026-10-12: posts, index and archives at /blog/..., as today.
49
- collections: { blog: "" },
50
- },
51
- ],
52
44
  },
53
45
  "storefront.tokenoftrust.store": {
54
46
  root: { source: { forge: "gitea", repo: "storefront.tokenoftrust.store", defaultBranch: "main" } },
@@ -50,6 +50,16 @@ export function carriesLiveNonce(response: Response): boolean {
50
50
  });
51
51
  }
52
52
 
53
+ /**
54
+ * True for the response Astro replaces with its error page: status 404 or 500 and
55
+ * no body (`astro/dist/core/routing/handler.js`, REROUTABLE_STATUS_CODES). Astro
56
+ * renders that page in a separate middleware pass and then lets THIS response's
57
+ * headers override the page's own, so this response must carry no CSP.
58
+ */
59
+ export function isErrorPageReroute(response: Response): boolean {
60
+ return response.body === null && (response.status === 404 || response.status === 500);
61
+ }
62
+
53
63
  /** A fresh, non-guessable per-response nonce. */
54
64
  export function freshNonce(): string {
55
65
  return crypto.randomUUID();
@@ -92,7 +92,12 @@ import {
92
92
  deriveSiteSurface,
93
93
  cspHeaderName,
94
94
  } from "@/lib/integration/browserEnvironment";
95
- import { carriesLiveNonce, freshNonce, stampResponseNonce } from "@/lib/integration/nonceStamp";
95
+ import {
96
+ carriesLiveNonce,
97
+ freshNonce,
98
+ isErrorPageReroute,
99
+ stampResponseNonce,
100
+ } from "@/lib/integration/nonceStamp";
96
101
  import {
97
102
  composeIntegrationDeclarations,
98
103
  resolveIntegrationRenderState,
@@ -712,12 +717,19 @@ export async function runRenderChain(input: RenderChainInput): Promise<Response>
712
717
  ? await next(rewriteTarget)
713
718
  : await next();
714
719
 
715
- // A nested pass of this middleware — an in-process `rewrite()`, or Astro re-running
716
- // middleware for its error route — already decorated and nonce-stamped the
717
- // response. Serve it verbatim: decorating again would inject preview helpers twice
718
- // and replace the header's nonce while the document keeps the inner one.
720
+ // A nested pass of this middleware (an in-process `rewrite()`) already decorated
721
+ // and nonce-stamped the response. Serve it verbatim: decorating again would inject
722
+ // preview helpers twice and replace the header's nonce while the document keeps
723
+ // the inner one.
719
724
  if (carriesLiveNonce(response)) return response;
720
725
 
726
+ // A body-less 404/500 is Astro's cue to render the error page in its OWN pass of
727
+ // this middleware and then copy THIS response's headers over that page's
728
+ // (astro/dist/core/errors/default-handler.js `mergeResponses`). A CSP set here
729
+ // would win over the error page's, naming this pass's nonce while its document
730
+ // carries the error pass's — so leave it to the pass that renders the document.
731
+ if (isErrorPageReroute(response)) return response;
732
+
721
733
  // On-publish auto-refresh: inject the live-reload client into SHARED preview
722
734
  // (`test`) HTML pages ONLY — never `live` (keeps live clean + edge-cacheable).
723
735
  // It polls /api/preview/version and reloads when this tenant's cache-version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "2.4.33",
3
+ "version": "2.4.35",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",