fix(mindspace): guard published pages against blocked CDN scripts

Pre-bundle Chart.js, auto-rewrite common CDN references at publish and serve time, and block unknown external script src during publication scans so interactive dashboards keep working under CSP.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-10 10:27:42 +08:00
parent eea14c1855
commit aede1e6fcb
12 changed files with 392 additions and 5 deletions
+2
View File
@@ -109,6 +109,7 @@ import {
stripPublicationHtmlCspMeta,
} from './plaza-embed.mjs';
import { publishedPageCsp } from './mindspace-published-page-csp.mjs';
import { rewriteKnownCdnScriptSources } from './mindspace-published-script-localize.mjs';
import { createMindSpaceAgentRunner } from './mindspace-agent-runner.mjs';
import {
analyzeChatMessageForSave,
@@ -5833,6 +5834,7 @@ async function sendPublishFile(req, res, filePath, { isOwner = true } = {}) {
return;
}
html = await ensurePublicHtmlPrivateAssetsMaterialized(filePath, html);
html = rewriteKnownCdnScriptSources(html).html;
html = preparePublicHtmlAssetDelivery(html, INTERNAL_AGENT_SECRET);
const embed = isPlazaEmbedRequest(req.query);
if (embed) {