@tokenoftrust/storefront-runner 7.2.0 → 7.2.1
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.
|
@@ -139,7 +139,7 @@ export function buildCspViolationBannerScript(basePath = ""): string {
|
|
|
139
139
|
const BASE = ${jsonForScript(basePath)};
|
|
140
140
|
const path = window.location.pathname || "";
|
|
141
141
|
const relPath = BASE && path.indexOf(BASE + "/") === 0 ? path.slice(BASE.length) : path;
|
|
142
|
-
if (/^\\/admin(?:\\/|$)/.test(relPath)) return;
|
|
142
|
+
if (/^\\/(?:admin|cockpit|dashboard)(?:\\/|$)/.test(relPath) || /(?:^|\\/)admin(?:\\/|$)/.test(path)) return;
|
|
143
143
|
const isStyleGuide = /^\\/_?style-guide(?:\\/|$)/.test(relPath);
|
|
144
144
|
const isPreviewInspectionStyle = (directive, uri) =>
|
|
145
145
|
directive === "style-src-elem" &&
|
|
@@ -147,8 +147,10 @@ export function buildCspViolationBannerScript(basePath = ""): string {
|
|
|
147
147
|
(window.navigator.userAgent.includes("CodexBrowser") ||
|
|
148
148
|
new URLSearchParams(window.location.search).has("__preview") ||
|
|
149
149
|
isStyleGuide);
|
|
150
|
-
const isExtensionOrEvalNoise = (uri, sourceFile) =>
|
|
150
|
+
const isExtensionOrEvalNoise = (directive, uri, sourceFile) =>
|
|
151
151
|
uri === "eval" ||
|
|
152
|
+
uri === "wasm-eval" ||
|
|
153
|
+
(directive === "script-src" && (uri === "inline" || uri === "(inline)")) ||
|
|
152
154
|
/^(?:chrome|moz|safari(?:-web)?|ms-browser)-extension:/i.test(String(sourceFile || ""));
|
|
153
155
|
const ensureBox = () => {
|
|
154
156
|
if (box) return box;
|
|
@@ -175,7 +177,7 @@ export function buildCspViolationBannerScript(basePath = ""): string {
|
|
|
175
177
|
// browser extensions routinely trip script-src eval in injected page scripts.
|
|
176
178
|
// Automated CSP validation remains authoritative for page resources; keep
|
|
177
179
|
// every real resource block visible, and keep normal public routes diagnostic.
|
|
178
|
-
if (isPreviewInspectionStyle(directive, uri) || isExtensionOrEvalNoise(uri, sourceFile)) return;
|
|
180
|
+
if (isPreviewInspectionStyle(directive, uri) || isExtensionOrEvalNoise(directive, uri, sourceFile)) return;
|
|
179
181
|
const key = directive + "|" + uri;
|
|
180
182
|
if (seen.has(key)) return; seen.add(key);
|
|
181
183
|
const li = document.createElement("li");
|
|
@@ -237,11 +239,17 @@ export async function injectPreviewReload(
|
|
|
237
239
|
});
|
|
238
240
|
}
|
|
239
241
|
|
|
242
|
+
/** True when a tenant-relative route is a control-plane operator surface, not a previewed storefront page. */
|
|
243
|
+
export function isPreviewOperatorSurfacePath(renderPath = ""): boolean {
|
|
244
|
+
return /^\/(?:admin|cockpit|dashboard|auth)(?:\/|$)/i.test(renderPath);
|
|
245
|
+
}
|
|
246
|
+
|
|
240
247
|
/**
|
|
241
248
|
* Env-gated entrypoint the middleware calls: inject the reload client ONLY for
|
|
242
|
-
* the SHARED preview (`test`) — NEVER `live
|
|
243
|
-
*
|
|
244
|
-
*
|
|
249
|
+
* the SHARED preview (`test`) — NEVER `live`, and never on operator control-plane
|
|
250
|
+
* surfaces (`/admin`, `/cockpit`, `/dashboard`, `/auth`). Returns the response
|
|
251
|
+
* unchanged for `live` (or any non-HTML response). This is the single guardrail
|
|
252
|
+
* seam, so the "present in test, absent in live" contract is unit-testable here.
|
|
245
253
|
*/
|
|
246
254
|
export async function maybeInjectPreviewReload(
|
|
247
255
|
response: Response,
|
|
@@ -250,9 +258,11 @@ export async function maybeInjectPreviewReload(
|
|
|
250
258
|
tenantId: string;
|
|
251
259
|
basePath: string;
|
|
252
260
|
nonce: string;
|
|
261
|
+
renderPath?: string;
|
|
253
262
|
pollMs?: number;
|
|
254
263
|
},
|
|
255
264
|
): Promise<Response> {
|
|
256
265
|
if (opts.env !== "test") return response;
|
|
266
|
+
if (opts.renderPath && isPreviewOperatorSurfacePath(opts.renderPath)) return response;
|
|
257
267
|
return injectPreviewReload(response, opts);
|
|
258
268
|
}
|
|
@@ -853,6 +853,7 @@ export async function runRenderChain(input: RenderChainInput): Promise<Response>
|
|
|
853
853
|
tenantId: tenant.tenant_id,
|
|
854
854
|
basePath,
|
|
855
855
|
nonce: cspNonce,
|
|
856
|
+
renderPath,
|
|
856
857
|
});
|
|
857
858
|
|
|
858
859
|
// Preview annotations: an authorized interactive preview (shared preview token, or a
|
|
@@ -70,15 +70,22 @@ button {
|
|
|
70
70
|
cursor: pointer;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
summary button > * {
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:where(svg) {
|
|
74
78
|
width: 18px;
|
|
75
79
|
height: 18px;
|
|
80
|
+
flex: 0 0 auto;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:where(svg:not([stroke="none"]):not([fill="currentColor"])) {
|
|
76
84
|
stroke: currentColor;
|
|
77
85
|
stroke-width: 1.9;
|
|
78
86
|
stroke-linecap: round;
|
|
79
87
|
stroke-linejoin: round;
|
|
80
88
|
fill: none;
|
|
81
|
-
flex: 0 0 auto;
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
.shell {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.1",
|
|
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",
|