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 0000000..20aadb6 Binary files /dev/null and b/vendor/media/sprites.png differ