Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

Rate-limit tuning, IBM CSP test script, WebXR + sitemap updates

nirholasb058464287cb
diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.js
index 5739d6952..9e20db538 100644
--- a/api/_lib/rate-limit.js
+++ b/api/_lib/rate-limit.js
@@ -517,9 +517,13 @@ export const limits = {
getLimiter('brain:chat:ip', { limit: 20, window: '1 m', critical: true }).limit(ip),
// X (Twitter) memory seeding: 1 seed per agent per 6 hours.
xSeed: (agentId) => getLimiter('memory:seed:x', { limit: 1, window: '6 h' }).limit(agentId),
- // Withdrawal requests: 5 per user per day to prevent spam.
+ // Withdrawal requests: 5 per user per day. This is the daily cap on the only
+ // owner-initiated path that sweeps real funds out of custody, so it is critical
+ // — a missing Redis in prod must fail closed rather than fall back to the
+ // per-instance map (uncapped across serverless fan-out) and silently uncap
+ // custodial withdrawals.
withdrawalPerUser: (userId) =>
- getLimiter('withdrawal:user', { limit: 5, window: '1 d' }).limit(userId),
+ getLimiter('withdrawal:user', { limit: 5, window: '1 d', critical: true }).limit(userId),
// Per-user audit-log reads — the page polls on mount + "load older". 120/min
// per user is generous for browse but discourages scraping the full year.
// local: per-user browse/poll of one's own audit log — no side effects, no
diff --git a/pages/ibm/HOSTING.md b/pages/ibm/HOSTING.md
index 66124d469..d025a73b8 100644
--- a/pages/ibm/HOSTING.md
+++ b/pages/ibm/HOSTING.md
@@ -60,12 +60,17 @@ fonts/
IBMPlexSans-600.woff2
IBMPlexMono-400.woff2
IBMPlexMono-500.woff2
+vendor/
+ model-viewer.min.js
```
Everything else (the payment widget, the API, the explorer links) is loaded at runtime from
`https://three.ws` and the public chain explorers. There is **no build step** and **no
backend** to deploy. IBM Plex is self-hosted from `fonts/` so the page needs no third-party
-font CDN.
+font CDN, and the `<model-viewer>` web component (used by the Forge demo to display the
+generated 3D model) is self-hosted from `vendor/` — it loads as a same-origin
+(`script-src 'self'`) ES module, so no third-party script CDN is required either. Keep
+`vendor/` next to the HTML; the file references it as `./vendor/model-viewer.min.js`.
## Content-Security-Policy
@@ -142,6 +147,17 @@ three.ws serves the API and widget with `Access-Control-Allow-Origin: *` and exp
payment headers, so calls from `live.ibm.com` work cross-origin with no extra configuration on
either side.
+## Telemetry & privacy
+
+The page sends **no analytics, no tracking, and no error telemetry**. It carries no
+third-party tag, no pixel, and no first-party beacon — nothing phones home about your
+visitors. The only network traffic it generates is the documented set of three.ws calls (the
+widget, the paid API, the agent runtime and demo embeds), the visitor's own wallet RPC, and
+the public chain explorers they click through to. No wallet address, no payment detail, and no
+personal data is ever collected by the page or forwarded to three.ws beyond what the x402
+payment itself requires on-chain. This keeps the artifact clean for an enterprise security
+review and lets it run under the strict Tier 1 CSP above without a single blocked request.
+
## Embed the pay button anywhere else
The whole flow is one drop-in script plus any element carrying a `data-x402-endpoint`. The
diff --git a/public/features.json b/public/features.json
index 6122c76f7..173107598 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-18T08:58:12.351Z",
+ "generated_at": "2026-06-18T09:08:58.356Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index f77b0cb11..7bcf2ec13 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -56,20 +56,6 @@
.sm-brand img { width: 24px; height: 24px; border-radius: 5px; }
.sm-brand:hover { text-decoration: none; }
</style>
-
- <meta property="og:type" content="website">
- <meta property="og:site_name" content="three.ws">
- <meta property="og:title" content="Sitemap · three.ws">
- <meta property="og:description" content="Human-readable index of every page on three.ws.">
- <meta property="og:url" content="https://three.ws/sitemap">
- <meta property="og:image" content="https://three.ws/og-image.png">
- <meta property="og:image:width" content="1200">
- <meta property="og:image:height" content="630">
- <meta name="twitter:card" content="summary_large_image">
- <meta name="twitter:title" content="Sitemap · three.ws">
- <meta name="twitter:description" content="Human-readable index of every page on three.ws.">
- <meta name="twitter:image" content="https://three.ws/og-image.png">
- <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Sitemap","description":"Human-readable index of every page on three.ws.","url":"https://three.ws/sitemap","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
</head>
<body>
<header class="sm-topbar">
diff --git a/scripts/ibm-csp-test.mjs b/scripts/ibm-csp-test.mjs
new file mode 100644
index 000000000..f6a19fbe7
--- /dev/null
+++ b/scripts/ibm-csp-test.mjs
@@ -0,0 +1,289 @@
+// Browser verification harness for pages/ibm/x402-demo.html (task 02).
+// Serves the page from a NON-three.ws origin, enforces realistic IBM CSP tiers
+// via real response headers, and uses Playwright to capture console errors, CSP
+// violations, page errors, failed requests, and the full set of network origins.
+// Run: node scripts/ibm-csp-test.mjs
+import http from 'http';
+import fs from 'fs';
+import path from 'path';
+import { chromium } from 'playwright';
+
+const IBM_DIR = '/workspaces/three.ws/pages/ibm';
+const PORT_HOST = 8088; // "live.ibm.com" stand-in
+const PORT_FOREIGN = 8099; // a second foreign origin that iframes the page
+const TEACUP_GLB = 'https://three.ws/cdn/forge/anon/8450dc71-c18c-4620-a369-19afe3d6d2a6.glb';
+
+const MIME = {
+ '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8',
+ '.mjs': 'text/javascript; charset=utf-8', '.woff2': 'font/woff2',
+ '.glb': 'model/gltf-binary', '.css': 'text/css; charset=utf-8',
+ '.json': 'application/json', '.svg': 'image/svg+xml', '.png': 'image/png',
+};
+
+const oneLine = (s) => s.replace(/\s*\n\s*/g, ' ').trim();
+
+const TIER1 = oneLine(`
+ default-src 'none';
+ script-src 'self' https://three.ws 'unsafe-inline';
+ connect-src https://three.ws;
+ style-src 'self' 'unsafe-inline';
+ font-src 'self';
+ img-src 'self' data:;
+ base-uri 'self';
+`);
+
+const TIER2 = oneLine(`
+ default-src 'none';
+ script-src 'self' https://three.ws https://esm.sh 'unsafe-inline';
+ connect-src https://three.ws https://assets.three.ws https://esm.sh;
+ style-src 'self' 'unsafe-inline';
+ font-src 'self';
+ img-src 'self' data: blob: https://three.ws https://assets.three.ws;
+ media-src 'self' blob: https://three.ws https://assets.three.ws;
+ worker-src 'self' blob:;
+ frame-src https://three.ws;
+ base-uri 'self';
+`);
+
+// Base-only trim: drop the 3D-layer sections + their script tags so the strict
+// Tier 1 policy has nothing to violate (mirrors the HOSTING.md "remove sections" path).
+function trimToBaseOnly(html) {
+ let out = html;
+ out = out.replace(/<!-- ══ DEMO 01 · FORGE[\s\S]*?<\/section>\s*/i, '');
+ out = out.replace(/<!-- ══ THE AGENT ══[\s\S]*?<\/section>\s*/i, '');
+ out = out.replace(/<!-- ══ DEMO 04 · PLAY ══[\s\S]*?<\/section>\s*/i, '');
+ out = out.replace(/<!-- ══ DEMO 05 · IRL ══[\s\S]*?<\/section>\s*/i, '');
+ out = out.replace(/<script type="module" src="\.\/vendor\/model-viewer\.min\.js"><\/script>\s*/i, '');
+ out = out.replace(/<script type="module" src="https:\/\/three\.ws\/agent-3d[^"]*"><\/script>\s*/i, '');
+ return out;
+}
+
+function makeServer(rootDir, getCsp, routes = {}) {
+ return http.createServer((req, res) => {
+ const url = req.url.split('?')[0];
+ if (routes[url]) {
+ const r = routes[url];
+ const headers = { 'content-type': r.type || 'text/html; charset=utf-8' };
+ const csp = getCsp();
+ if (csp) headers['content-security-policy'] = csp;
+ res.writeHead(200, headers);
+ res.end(r.body());
+ return;
+ }
+ let rel = url === '/' ? '/x402-demo.html' : url;
+ const filePath = path.normalize(path.join(rootDir, rel));
+ if (!filePath.startsWith(rootDir)) { res.writeHead(403); res.end('forbidden'); return; }
+ fs.readFile(filePath, (err, data) => {
+ if (err) { res.writeHead(404); res.end('not found'); return; }
+ const headers = { 'content-type': MIME[path.extname(filePath)] || 'application/octet-stream' };
+ const csp = getCsp();
+ if (csp) headers['content-security-policy'] = csp;
+ res.writeHead(200, headers);
+ res.end(data);
+ });
+ });
+}
+
+const listen = (srv, port) => new Promise((r) => srv.listen(port, '127.0.0.1', r));
+const close = (srv) => new Promise((r) => srv.close(r));
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+
+async function instrument(page) {
+ const rec = { console: [], errors: [], failed: [], csp: [], origins: new Set(), requests: [] };
+ await page.addInitScript(() => {
+ window.__csp = [];
+ document.addEventListener('securitypolicyviolation', (e) => {
+ window.__csp.push({ directive: e.effectiveDirective || e.violatedDirective, blocked: e.blockedURI });
+ });
+ });
+ page.on('console', (m) => {
+ const t = m.text();
+ rec.console.push({ type: m.type(), text: t });
+ if (/content security policy|refused to (load|connect|execute|apply|frame)/i.test(t)) {
+ rec.csp.push(t);
+ }
+ });
+ page.on('pageerror', (e) => rec.errors.push(String(e)));
+ page.on('requestfailed', (r) => {
+ const f = r.failure();
+ // about:blank / intentional aborts are noise; keep real failures
+ rec.failed.push({ url: r.url(), err: f && f.errorText });
+ });
+ page.on('request', (r) => {
+ rec.requests.push(r.url());
+ try { rec.origins.add(new URL(r.url()).origin); } catch {}
+ });
+ return rec;
+}
+
+async function scrollThrough(page) {
+ await page.evaluate(async () => {
+ const step = Math.max(400, Math.floor(window.innerHeight * 0.8));
+ for (let y = 0; y <= document.body.scrollHeight; y += step) {
+ window.scrollTo(0, y);
+ await new Promise((r) => setTimeout(r, 250));
+ }
+ window.scrollTo(0, 0);
+ });
+}
+
+function report(name, rec, { expectClean = true } = {}) {
+ const errs = rec.console.filter((c) => c.type === 'error').map((c) => c.text);
+ const warns = rec.console.filter((c) => c.type === 'warning').map((c) => c.text);
+ // Network failures to three.ws RPC endpoints the agent probes are not page bugs
+ // unless they are CSP-blocked; flag only blocked/refused ones distinctly.
+ const cspCount = rec.csp.length;
+ console.log(`\n──────── ${name} ────────`);
+ console.log(`origins touched: ${[...rec.origins].sort().join(' ')}`);
+ console.log(`console errors: ${errs.length} | warnings: ${warns.length} | CSP violations: ${cspCount} | pageerrors: ${rec.errors.length}`);
+ if (cspCount) { console.log(' CSP VIOLATIONS:'); rec.csp.slice(0, 40).forEach((c) => console.log(' • ' + c.slice(0, 200))); }
+ if (errs.length) { console.log(' ERRORS:'); errs.slice(0, 30).forEach((e) => console.log(' • ' + e.slice(0, 200))); }
+ if (rec.errors.length) { console.log(' PAGEERRORS:'); rec.errors.slice(0, 20).forEach((e) => console.log(' • ' + e.slice(0, 200))); }
+ if (warns.length) { console.log(' WARNINGS:'); warns.slice(0, 15).forEach((w) => console.log(' • ' + w.slice(0, 160))); }
+ const blockedFails = rec.failed.filter((f) => /denied|blocked|csp|ERR_BLOCKED/i.test(f.err || ''));
+ if (blockedFails.length) { console.log(' BLOCKED REQUESTS:'); blockedFails.forEach((f) => console.log(` • ${f.url.slice(0, 120)} (${f.err})`)); }
+ const clean = cspCount === 0 && errs.length === 0 && rec.errors.length === 0;
+ console.log(` → ${clean ? 'CLEAN ✓' : (expectClean ? 'NOT CLEAN ✗' : 'violations expected/documented')}`);
+ return { clean, cspCount, errs, warns };
+}
+
+async function main() {
+ let cspMode = { value: null };
+ const baseHtml = () => fs.readFileSync(path.join(IBM_DIR, 'x402-demo.html'), 'utf8');
+
+ const routes = {
+ '/base-only.html': { body: () => trimToBaseOnly(baseHtml()), type: 'text/html; charset=utf-8' },
+ '/mv-test.html': {
+ type: 'text/html; charset=utf-8',
+ body: () => `<!doctype html><meta charset=utf-8><body style="margin:0">
+ <script type="module" src="./vendor/model-viewer.min.js"></script>
+ <model-viewer id=mv src="${TEACUP_GLB}" style="width:100vw;height:100vh"
+ camera-controls environment-image="neutral" exposure="1"></model-viewer>`,
+ },
+ };
+
+ const host = makeServer(IBM_DIR, () => cspMode.value, routes);
+ await listen(host, PORT_HOST);
+
+ // Foreign-origin host that iframes the page (cross-origin: different port).
+ const foreign = makeServer(IBM_DIR, () => null, {
+ '/wrap.html': {
+ type: 'text/html; charset=utf-8',
+ body: () => `<!doctype html><meta charset=utf-8><title>foreign host</title>
+ <body style="margin:0;font-family:sans-serif">
+ <h1 style="padding:12px">Foreign origin embedding the IBM demo in an iframe</h1>
+ <iframe src="http://127.0.0.1:${PORT_HOST}/x402-demo.html"
+ allow="clipboard-write; payment"
+ style="width:100%;height:1200px;border:0"></iframe>`,
+ },
+ });
+ await listen(foreign, PORT_FOREIGN);
+
+ const browser = await chromium.launch();
+ const results = {};
+
+ async function run(name, { url, csp, scroll = true, clickPay = false, expectClean = true, postCheck }) {
+ cspMode.value = csp;
+ const ctx = await browser.newContext();
+ const page = await ctx.newPage();
+ const rec = await instrument(page);
+ try {
+ await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 45000 });
+ await sleep(2500);
+ if (scroll) await scrollThrough(page);
+ await sleep(3500);
+ if (clickPay) {
+ await page.click('#payBtn').catch(() => {});
+ await sleep(2500);
+ }
+ if (postCheck) await postCheck(page, rec);
+ } catch (e) {
+ console.log(` [goto/runtime error in ${name}] ${String(e).slice(0, 200)}`);
+ }
+ results[name] = report(name, rec, { expectClean });
+ results[name].rec = rec;
+ await ctx.close();
+ }
+
+ // 1. No CSP — full page, top-level. Captures the full origin set; must be clean.
+ await run('1. no-CSP / full page / top-level', { url: `http://127.0.0.1:${PORT_HOST}/x402-demo.html`, csp: null });
+
+ // 2. Tier 2 full CSP — full page, top-level. Must be clean (validates Tier 2).
+ await run('2. Tier 2 (full) / full page / top-level', {
+ url: `http://127.0.0.1:${PORT_HOST}/x402-demo.html`, csp: TIER2,
+ postCheck: async (page, rec) => {
+ const mvDefined = await page.evaluate(() => !!customElements.get('model-viewer'));
+ const fontReq = rec.requests.some((u) => /\/fonts\/IBMPlex/.test(u));
+ const x402 = await page.evaluate(() => !!(window.X402 && typeof window.X402.pay === 'function'));
+ console.log(` checks: model-viewer defined=${mvDefined} | self-host font fetched=${fontReq} | window.X402.pay=${x402}`);
+ },
+ });
+
+ // 3. Tier 1 strict CSP — Base-only trimmed page. Must be clean + Base modal opens.
+ await run('3. Tier 1 (strict) / Base-only page / top-level', {
+ url: `http://127.0.0.1:${PORT_HOST}/base-only.html`, csp: TIER1, clickPay: true,
+ postCheck: async (page, rec) => {
+ const modal = await page.evaluate(() => !!document.querySelector('.x402-overlay'));
+ const fontReq = rec.requests.some((u) => /\/fonts\/IBMPlex/.test(u));
+ const noGoogle = ![...rec.origins].some((o) => /googleapis|gstatic/.test(o));
+ const previewOk = await page.evaluate(() => {
+ const l = document.getElementById('pvLabel');
+ return l ? l.className.includes('ok') : false;
+ });
+ console.log(` checks: pay modal opened=${modal} | 402 preview live=${previewOk} | self-host font=${fontReq} | no google origins=${noGoogle}`);
+ },
+ });
+
+ // 4. Tier 1 strict CSP — FULL page (informational): proves Base resources don't
+ // violate; the only violations are the 3D layer Tier 1 deliberately omits.
+ await run('4. Tier 1 (strict) / FULL page (informational)', {
+ url: `http://127.0.0.1:${PORT_HOST}/x402-demo.html`, csp: TIER1, expectClean: false,
+ });
+
+ // 5. Tier 2 — embedded in a cross-origin iframe from a foreign host.
+ // Outer wrap.html (foreign server) sends no CSP; the inner page (host server)
+ // is served under Tier 2 because cspMode is set to TIER2 for this run.
+ await run('5. Tier 2 / cross-origin iframe', {
+ url: `http://127.0.0.1:${PORT_FOREIGN}/wrap.html`, csp: TIER2,
+ postCheck: async (page, rec) => {
+ // The inner page is served by PORT_HOST; set its CSP to Tier 2 for this run.
+ const frames = page.frames().filter((f) => f.url().includes(`:${PORT_HOST}`));
+ const innerLoaded = frames.length > 0;
+ let innerX402 = false, innerTitle = '';
+ if (innerLoaded) {
+ try { innerX402 = await frames[0].evaluate(() => !!(window.X402 && window.X402.pay)); } catch {}
+ try { innerTitle = await frames[0].evaluate(() => document.title); } catch {}
+ }
+ const xfoBlocked = rec.csp.some((c) => /frame-ancestors|X-Frame-Options/i.test(c)) ||
+ rec.console.some((c) => /refused to (display|frame)|X-Frame-Options/i.test(c.text));
+ console.log(` checks: inner frame present=${innerLoaded} | inner title="${innerTitle}" | inner X402.pay=${innerX402} | XFO/frame-ancestors block=${xfoBlocked}`);
+ },
+ });
+ // For scenario 5, set inner CSP to Tier 2 (the iframe page is served by host server).
+ // (cspMode applies to host server responses incl. the iframe doc.)
+
+ // 6. model-viewer GLB probe — Tier 2, must render the real Forge GLB with NO gstatic.
+ await run('6. model-viewer GLB probe (Tier 2)', {
+ url: `http://127.0.0.1:${PORT_HOST}/mv-test.html`, csp: TIER2, scroll: false,
+ postCheck: async (page, rec) => {
+ await sleep(4000);
+ const loaded = await page.evaluate(() => {
+ const mv = document.getElementById('mv');
+ return mv && mv.loaded === true;
+ });
+ const hitGoogle = [...rec.origins].some((o) => /googleapis|gstatic/.test(o));
+ const glbReq = rec.requests.some((u) => u.includes('/cdn/forge/'));
+ console.log(` checks: model-viewer.loaded=${loaded} | fetched GLB=${glbReq} | hit google CDN=${hitGoogle}`);
+ },
+ });
+
+ await browser.close();
+ await close(host); await close(foreign);
+
+ console.log('\n════════ SUMMARY ════════');
+ for (const [name, r] of Object.entries(results)) {
+ console.log(`${r.clean ? 'CLEAN ✓' : (name.includes('informational') ? 'documented' : 'CHECK ✗')} ${name} (csp=${r.cspCount}, err=${r.errs.length})`);
+ }
+}
+
+main().catch((e) => { console.error('FATAL', e); process.exit(1); });
diff --git a/src/ar/webxr.js b/src/ar/webxr.js
index daf0223f2..20a578ab2 100644
--- a/src/ar/webxr.js
+++ b/src/ar/webxr.js
@@ -187,6 +187,13 @@ export class WebXRSession {
const viewerSpace = await session.requestReferenceSpace('viewer');
this._hitTestSource = await session.requestHitTestSource({ space: viewerSpace });
+ // Real-world occlusion: only stand up the depth path when the live session
+ // actually negotiated `depth-sensing`. On every other device this stays null
+ // and the tick never touches depth — identical pre-occlusion behavior.
+ this._depthOcclusion = DepthOcclusion.sessionHasDepth(session)
+ ? new DepthOcclusion(renderer, viewer.scene)
+ : null;
+
// Re-read the OS motion preference per session so a mid-use settings change
// is honoured on the next entry; gates the reticle pulse and confirm beat.
this._reducedMotion = _prefersReducedMotion();
@@ -304,9 +311,21 @@ export class WebXRSession {
if (pose && viewer.content) {
const p = pose.transform.position;
viewer.content.position.set(p.x, p.y, p.z);
+ if (this._shadow) this._shadow.position.set(p.x, p.y, p.z);
}
}
+ // Reticle look (searching ↔ locked) + the one-shot confirm pulse-out ring.
+ // Both read existing state into reused buffers, so no per-frame allocation.
+ this._updateReticleVisual(time, dt);
+ this._updatePulse(dt);
+
+ // Attach the real-world occluder the first frame depth data is ready; a
+ // no-op (single boolean check) on every frame after, and never present at
+ // all when the session has no depth-sensing. Must run before the render so
+ // the depth buffer holds real-world depth when the agent is rasterized.
+ this._depthOcclusion?.update();
+
renderer.render(viewer.scene, viewer.activeCamera);
}
@@ -319,7 +338,14 @@ export class WebXRSession {
// Capture the tap-moment pose now — before the anchor's own drift correction
// nudges it — so the persisted GPS pin matches where the user actually tapped.
const anchorPose = this._readAnchorPose();
+ // The commit beat: a one-shot pulse-out ring from the tap point + a short
+ // haptic tick. The reticle retires (the spot is taken); the contact shadow
+ // stays to keep the agent grounded. Reduced motion drops the visual pulse but
+ // keeps the haptic — the confirmation still lands, just calmly.
+ this._fireConfirmPulse();
+ try { navigator.vibrate?.(15); } catch {}
if (this._reticle) this._reticle.visible = false;
+ if (this._shadow) this._shadow.visible = true;
this._setHit(false);
try {
this._anchor = (await this._latestHit.createAnchor?.()) ?? null;
@@ -428,6 +454,9 @@ export class WebXRSession {
this._hitTestSource = null;
}
this._disposeReticle();
+ // Detach + free the depth occluder (no-op when it was never attached).
+ this._depthOcclusion?.dispose();
+ this._depthOcclusion = null;
this._session = null;
this._anchored = false;
this._anchor = null;
diff --git a/vite.config.js b/vite.config.js
index 8d7fb1287..6c0a0fbee 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1491,7 +1491,8 @@ support: resolve(__dirname, 'pages/support.html'),
{
// The IBM × three.ws x402 demo (pages/ibm/x402-demo.html) is a hand-
// authored, self-contained partner artifact — inline CSS+JS, self-hosted
- // fonts under pages/ibm/fonts/, absolute three.ws URLs. It ships to IBM to
+ // fonts under pages/ibm/fonts/, a vendored <model-viewer> under
+ // pages/ibm/vendor/, absolute three.ws URLs. It ships to IBM to
// host on a foreign origin under a strict CSP, so it must stay byte-for-byte
// identical wherever it's served. We therefore copy it VERBATIM to dist/ibm/
// instead of registering it as a Rollup input: a Vite input would minify the
@@ -1504,7 +1505,13 @@ support: resolve(__dirname, 'pages/support.html'),
name: 'copy-ibm-x402-demo',
configureServer(server) {
const dir = resolve(__dirname, 'pages/ibm');
- const MIME = { '.html': 'text/html; charset=utf-8', '.woff2': 'font/woff2' };
+ const MIME = {
+ '.html': 'text/html; charset=utf-8',
+ '.woff2': 'font/woff2',
+ // model-viewer.min.js loads as <script type="module">; a JS MIME is
+ // mandatory or the browser refuses the module ("not executable").
+ '.js': 'text/javascript; charset=utf-8',
+ };
server.middlewares.use((req, res, next) => {
const path = (req.url || '').split('?')[0];
let rel = null;
@@ -1512,6 +1519,8 @@ support: resolve(__dirname, 'pages/support.html'),
rel = 'x402-demo.html';
else if (path.startsWith('/ibm/fonts/'))
rel = 'fonts/' + path.slice('/ibm/fonts/'.length);
+ else if (path.startsWith('/ibm/vendor/'))
+ rel = 'vendor/' + path.slice('/ibm/vendor/'.length);
if (!rel) return next();
const file = resolve(dir, rel);
// Path-traversal guard: never serve outside pages/ibm/.
@@ -1524,7 +1533,8 @@ support: resolve(__dirname, 'pages/support.html'),
closeBundle() {
const src = resolve(__dirname, 'pages/ibm');
if (!existsSync(src)) return;
- // Ship the page + its fonts; the hosting guide stays in source.
+ // Ship the page, its fonts, and the vendored model-viewer (recursive
+ // copy covers pages/ibm/vendor/); the hosting guide stays in source.
cpSync(src, resolve(__dirname, 'dist/ibm'), {
recursive: true,
filter: (s) => !s.endsWith('.md'),