From 2a39d42c79f1c5f34df35ff07c335c585cdcb74b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 06:40:24 +0000 Subject: [PATCH] Privacy: stop the code editor fetching icons from Google's servers Blockly's default media path is blockly-demo.appspot.com, so opening Bit's code editor sent every player's IP address and browser details to Google (and showed broken trash/zoom icons offline). Bundle sprites.png (blockly@10.4.3), point the editor at it with the media option, and precache it (sw.js v20). The smoke test now fails if the game ever requests a host outside the one serving it, so this can't come back unnoticed. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_012T3WxfAesenfyvWRXYdNKy --- src/robotui.js | 1 + sw.js | 4 ++-- tests/smoke.mjs | 10 ++++++++++ vendor/README.md | 2 ++ vendor/media/sprites.png | Bin 0 -> 2595 bytes 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 vendor/media/sprites.png diff --git a/src/robotui.js b/src/robotui.js index d7a9899..47c29b5 100644 --- a/src/robotui.js +++ b/src/robotui.js @@ -57,6 +57,7 @@ export class RobotUI { renderer: 'zelos', // rounded, chunky blocks that are easy for small hands theme: Blockly.Themes.Zelos || undefined, sounds: false, + media: './vendor/media/', // bundled icons: Blockly would otherwise fetch them from Google's servers }); if (this.savedState) { try { Blockly.serialization.workspaces.load(this.savedState, this.ws); } catch { this.setProgram([]); } diff --git a/sw.js b/sw.js index 843acac..99877d8 100644 --- a/sw.js +++ b/sw.js @@ -1,10 +1,10 @@ // Service worker: caches the whole game so it works offline once loaded. // Bump VERSION whenever files change so players get the update. -const VERSION = 'minicrafter-v19'; +const VERSION = 'minicrafter-v20'; const CORE = [ './', './index.html', './style.css', './manifest.webmanifest', './site-config.json', './icons/icon-192.png', './icons/icon-512.png', './icons/icon-maskable-512.png', './icons/apple-touch-icon.png', './icons/favicon-32.png', - './vendor/three.module.js', './vendor/blockly.min.js', + './vendor/three.module.js', './vendor/blockly.min.js', './vendor/media/sprites.png', './src/adventure.js', './src/audio.js', './src/blocks.js', diff --git a/tests/smoke.mjs b/tests/smoke.mjs index e217fa4..ac4bff8 100644 --- a/tests/smoke.mjs +++ b/tests/smoke.mjs @@ -47,8 +47,16 @@ const browser = await chromium.launch({ args: ['--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'], }); +// Privacy: the game must never contact a host outside the one serving it (no CDN, fonts, analytics). +const outside = new Set(); +const trackOutside = (page) => page.on('request', (rq) => { + const u = new URL(rq.url()); + if (/^(https?|wss?):$/.test(u.protocol) && !['localhost', '127.0.0.1'].includes(u.hostname)) outside.add(u.origin); +}); + async function openGame(query = '', at = base) { const page = await browser.newPage({ viewport: { width: 1280, height: 720 } }); + trackOutside(page); const errors = []; page.on('pageerror', (e) => errors.push(`pageerror: ${e.message}`)); page.on('console', (m) => { if (m.type() === 'error') errors.push(`console: ${m.text()}`); }); @@ -325,5 +333,7 @@ try { server.close(); } +ok(outside.size === 0, 'privacy: the game never contacts an outside host', [...outside].join(', ') || 'same-origin only'); + console.log(failures ? `\n${failures} check(s) failed` : '\nAll smoke checks passed'); process.exit(failures ? 1 : 0); diff --git a/vendor/README.md b/vendor/README.md index e22537a..c7e0162 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -7,4 +7,6 @@ These are copied here so MiniCrafter works offline. They are unmodified copies f | `three.module.js` | [three.js](https://threejs.org/) | 0.160.0 | MIT, see `LICENSE-three.txt` | | `blockly.min.js` | [Blockly](https://developers.google.com/blockly) (core, blocks, English messages, JS generator) | 10.4.3 | Apache License 2.0, © Google LLC: https://www.apache.org/licenses/LICENSE-2.0 | +`media/sprites.png` is Blockly's icon sheet (trash can and zoom buttons) from `blockly@10.4.3/media/`. The game points Blockly at it with the `media` option, because the default would load it from Google's servers. + To update one, download the new version from `https://unpkg.com/@/...`, replace the file, update this table, and bump `VERSION` in `sw.js`. diff --git a/vendor/media/sprites.png b/vendor/media/sprites.png new file mode 100644 index 0000000000000000000000000000000000000000..20aadb6c4c31f4a46f0a3316241788687c2fc444 GIT binary patch literal 2595 z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