Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ <h1>MiniCrafter</h1>
</details>
<p class="note touch-only">Touch: left stick walks, drag to look, tap to place or flip, hold to mine or attack. Holding a bow or shield? Hold to draw or block.</p>
<p class="note">Your world is saved automatically in this browser. <span id="offline-note"></span> <span id="game-version"></span></p>
<button id="btn-report" class="wide-btn report-btn hidden" type="button">🐞 Report a problem</button>
<p class="note legal-links"><a href="features.html" target="_blank" rel="noopener">✨ All features</a> · <a href="privacy.html" target="_blank" rel="noopener">Privacy Policy</a> · <a href="terms.html" target="_blank" rel="noopener">Terms of Use</a></p>
</div>
</div>
Expand Down Expand Up @@ -238,6 +239,15 @@ <h2>👤 Your account</h2>
</div>
</div>

<div id="report" class="overlay hidden">
<div class="panel report-panel">
<h2>🐞 Report a problem</h2>
<p class="note">What went wrong? Pick one. We'll also get your device type, browser, game version and your last few steps in the game (nothing about who you are) so we can fix it.</p>
<div id="report-choices" class="report-choices"></div>
<button id="report-done" class="wide-btn" type="button">Cancel</button>
</div>
</div>

<div id="photo" class="overlay hidden">
<div class="panel photo-panel">
<h2>📷 Photo Mode</h2>
Expand Down
26 changes: 19 additions & 7 deletions privacy.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h2>🧒 The short version (for kids)</h2>
<li><b>We don't know who you are.</b> We never ask for your real name, email, address, phone number, school or photos.</li>
<li><b>Your worlds stay on your device</b> unless you choose to play online.</li>
<li><b>If you make an account,</b> we keep only a made-up username and your password (scrambled so nobody can read it). Never use your real name as your username!</li>
<li><b>In the online edition we count things, not people.</b> Like "12 visits from tablets today". If the game breaks, it tells us what went wrong so we can fix it, but never who you are.</li>
<li><b>No ads, no tracking, nothing to buy.</b> We never sell anything about you.</li>
<li><b>In Play Together</b> other players only see a colour-and-animal name like "Blue Fox". There's no chat, just emoji.</li>
<li><b>You can delete your account</b> any time, and it's gone straight away.</li>
Expand All @@ -33,8 +34,9 @@ <h2>1. Who we are</h2>

<h2>2. Two ways to play</h2>
<ul>
<li><b>Free edition and playing without an account:</b> everything happens in your browser. We receive nothing about you or your game.</li>
<li><b>Online edition with an account:</b> adds features that need our server, such as Play Together. Only then do we keep the small amount of information below.</li>
<li><b>Free edition:</b> everything happens in your browser. We receive nothing about you or your game.</li>
<li><b>Online edition:</b> sends anonymous usage counts and problem reports (section 6), which say nothing about who you are.</li>
<li><b>Online edition with an account:</b> adds features that need our server, such as Play Together. Only then do we keep the small amount of account information below.</li>
</ul>

<h2>3. What is stored on your device</h2>
Expand All @@ -43,6 +45,7 @@ <h2>3. What is stored on your device</h2>
<li>Your worlds, quest stars, settings and hotbar.</li>
<li>Your Play Together colour-and-animal name.</li>
<li>For Adventure mode, a note that the grown-up check was passed, which is cleared when the browser is closed.</li>
<li>In the online edition, a list of which usage counts this visit already sent (so each is counted once), cleared when the browser is closed.</li>
<li>A copy of the game's files, so it works without internet.</li>
</ul>
<p>You can remove all of this by clearing the site's data in your browser settings.</p>
Expand All @@ -67,14 +70,23 @@ <h2>5. Play Together</h2>
<li>The host lets each player in and can remove players.</li>
</ul>

<h2>6. Keeping things safe</h2>
<h2>6. Anonymous usage counts and problem reports (online edition)</h2>
<p>To see which features are used and to fix bugs, the online edition sends us a little information. It is built so that it can't identify anyone:</p>
<ul>
<li><b>No cookies, no player IDs, no fingerprinting, and no internet addresses stored.</b> The free edition sends none of this.</li>
<li><b>Daily counts only.</b> We add 1 to a counter for the day, for example "a visit from a phone using Safari", "Play Together was used" or "Bit ran a program", at most once per visit. We never keep a list of visits or a history for any person.</li>
<li><b>Problem reports.</b> When the game crashes or freezes, or a player presses "🐞 Report a problem" and picks what went wrong from a list (there's no typing), we keep: the error message, where in the game it happened, the game version, the browser and device family (such as "iPhone, Safari"), the screen size, and the last few steps in the game (such as "opened Bit's panel → pressed Run"). Identical reports are grouped and counted.</li>
<li><b>How long:</b> problem reports are deleted after 90 days. Daily counts contain nothing about any person, so we keep them to see how the game is used over time.</li>
</ul>

<h2>7. Keeping things safe</h2>
<ul>
<li>To stop people guessing passwords or flooding the service, our server briefly remembers internet addresses <b>in memory only, for up to one hour</b>. They are never written to disk.</li>
<li>We switch off request logs for the game. Technical error logs may briefly contain an internet address while we fix a problem.</li>
<li>Our account database is backed up every night in encrypted cloud storage. Backups are kept for up to 30 days, so a deleted account fully disappears from backups within 30 days.</li>
</ul>

<h2>7. Services that help us run MiniCrafter</h2>
<h2>8. Services that help us run MiniCrafter</h2>
<p>We don't sell or share your information for advertising, ever. These providers process data only to run the service for us:</p>
<ul>
<li><b>Cloudflare</b> delivers the website and protects it from attacks. It handles internet addresses and may set a short-lived security cookie.</li>
Expand All @@ -84,21 +96,21 @@ <h2>7. Services that help us run MiniCrafter</h2>
</ul>
<p>These providers may be located outside your country. We use them with protections required by law.</p>

<h2>8. Children</h2>
<h2>9. Children</h2>
<ul>
<li>MiniCrafter is made for children, so we collect as little as possible and never use anything for advertising or profiling.</li>
<li>Players under 13 can make an account only with a parent or guardian, who confirms when the account is made.</li>
<li>Grown-ups can ask us to see or delete a child's account at <a href="mailto:info@dynamicweblab.com">info@dynamicweblab.com</a>. Please include the username.</li>
</ul>

<h2>9. Your rights</h2>
<h2>10. Your rights</h2>
<ul>
<li><b>Delete:</b> open the 👤 account screen in the game, choose "Delete my account" and enter your password. Your account, sessions and agreement record are deleted straight away.</li>
<li><b>See, correct or ask questions:</b> email <a href="mailto:info@dynamicweblab.com">info@dynamicweblab.com</a>. Depending on where you live (for example the UAE, the EU, the UK or the US), you may have more rights. We'll help with all of them.</li>
<li>You can also complain to your local data protection authority.</li>
</ul>

<h2>10. Changes</h2>
<h2>11. Changes</h2>
<p>If we change this policy, we'll update the date at the top. If a change is important, we'll show a notice in the game before it applies.</p>

<p class="foot"><a href="terms.html">Terms of Use</a> · <a href="./">Back to the game</a></p>
Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM node:22-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
COPY rooms.mjs accounts.mjs ./
COPY rooms.mjs accounts.mjs stats.mjs ./
USER node
CMD ["node", "rooms.mjs"]
10 changes: 9 additions & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Two small services for the hosted online edition, plus a database. Single-player
|---|---|---|
| Relay | `rooms.mjs` | Play Together rooms for up to 4 logged-in players (zero dependencies, nothing stored) |
| Accounts | `accounts.mjs` | Register, log in, log out and delete an account (Postgres; only dependency: `pg`) |
| Insights | `stats.mjs` | Anonymous daily usage counts and problem reports, mounted in the accounts service |
| Database | Postgres 16 | Usernames, password hashes and sessions. **Back it up.** |
| Dev server | `dev.mjs` | All of the above on one local address, with accounts in memory |

Expand All @@ -17,6 +18,13 @@ Two small services for the hosted online edition, plus a database. Single-player
- Rate limits: new accounts per address per hour, and wrong passwords per address and per username.
- Deleting an account deletes its sessions too, straight away.

## Insights: anonymous counts and problem reports
- `POST /api/events` adds 1 to daily counters ("a visit from a phone using Safari", "Bit ran"). No cookies, no IDs, nothing per person.
- `POST /api/errors` keeps crashes, freezes (the game stopped for over 5 s) and "Report a problem" picks (a fixed list, no typing), with the message, place, game version, browser/device family, screen size and the last 12 game steps. Grouped per day and deleted after 90 days.
- Both are same-origin only and rate-limited; internet addresses are held in memory for one minute and never stored.
- `GET /api/stats` needs `Authorization: Bearer $STATS_TOKEN`. Open `stats.html` on the site and enter the key. Without `STATS_TOKEN` in `.env` it is closed.
- Only the hosted site sends any of this (`"insights": true` in its `site-config.json`). The free edition sends nothing.

# The Play Together relay

## Why a relay (and not direct peer-to-peer)
Expand All @@ -36,7 +44,7 @@ For the whole online edition locally, run `node server/dev.mjs` and open http://
## Deploy (Docker, behind a reverse proxy)
```bash
cd server
printf "ALLOWED_ORIGINS=https://your-site.example\nPOSTGRES_PASSWORD=%s\n" "$(openssl rand -hex 24)" > .env
printf "ALLOWED_ORIGINS=https://your-site.example\nPOSTGRES_PASSWORD=%s\nSTATS_TOKEN=%s\n" "$(openssl rand -hex 24)" "$(openssl rand -hex 24)" > .env
chmod 600 .env
docker compose up -d --build
```
Expand Down
9 changes: 8 additions & 1 deletion server/accounts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,17 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
for (let i = 1; ; i++) { // the database may still be starting up
try { await store.init(); break; } catch (e) { if (i >= 30) throw e; await new Promise((r) => setTimeout(r, 2000)); }
}
const acc = createAccounts({ store, origins: (process.env.ALLOWED_ORIGINS || '').split(',').map((s) => s.trim()).filter(Boolean), secureCookie: process.env.SECURE_COOKIE !== '0' });
const origins = (process.env.ALLOWED_ORIGINS || '').split(',').map((s) => s.trim()).filter(Boolean);
const acc = createAccounts({ store, origins, secureCookie: process.env.SECURE_COOKIE !== '0' });
// Anonymous usage counts and error reports share the database (see stats.mjs).
const { createStats, PgStats, MemoryStats } = await import('./stats.mjs');
const statsStore = store.pool ? new PgStats(store.pool) : new MemoryStats();
await statsStore.init();
const stats = createStats({ store: statsStore, origins, token: process.env.STATS_TOKEN || '' });
const server = http.createServer(async (req, res) => {
if (req.url === '/health') { res.writeHead(200); return res.end('ok'); }
if (await acc.handleInternal(req, res)) return;
if (await stats.handle(req, res)) return;
if (await acc.handle(req, res)) return;
res.writeHead(404); res.end();
});
Expand Down
10 changes: 7 additions & 3 deletions server/dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ import { extname, join, normalize, sep } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { createAccounts, MemoryStore } from './accounts.mjs';
import { attachRelay } from './rooms.mjs';
import { createStats, MemoryStats } from './stats.mjs';

const ROOT = fileURLToPath(new URL('..', import.meta.url));
const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.webmanifest': 'application/manifest+json', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml' };
const SERVE = ['index.html', 'style.css', 'privacy.html', 'terms.html', 'legal.css', 'features.html', 'features.css', 'llms.txt', 'docs', 'sw.js', 'manifest.webmanifest', 'icons', 'src', 'vendor'];
const SERVE = ['index.html', 'stats.html', 'style.css', 'privacy.html', 'terms.html', 'legal.css', 'features.html', 'features.css', 'llms.txt', 'docs', 'sw.js', 'manifest.webmanifest', 'icons', 'src', 'vendor'];

/** Starts the dev server. Returns { server, port, url }. */
export async function startDevServer(port = 8770) {
const cfg = { origins: [] };
const accounts = createAccounts({ store: new MemoryStore(), get origins() { return cfg.origins; }, secureCookie: false });
const statsStore = new MemoryStats();
const stats = createStats({ store: statsStore, get origins() { return cfg.origins; }, token: 'dev' });
const server = http.createServer(async (req, res) => {
if (await stats.handle(req, res)) return;
if (await accounts.handle(req, res)) return;
try {
let p = decodeURIComponent(new URL(req.url, 'http://x').pathname);
if (p === '/site-config.json') {
res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
return res.end('{ "online": true, "rooms": "/rooms", "accounts": true }\n');
return res.end('{ "online": true, "rooms": "/rooms", "accounts": true, "insights": true }\n');
}
if (p.endsWith('/')) p += 'index.html';
const file = normalize(join(ROOT, p));
Expand All @@ -37,7 +41,7 @@ export async function startDevServer(port = 8770) {
await new Promise((r) => server.listen(port, '127.0.0.1', r));
const p = server.address().port;
cfg.origins = [`http://127.0.0.1:${p}`, `http://localhost:${p}`];
return { server, port: p, url: `http://127.0.0.1:${p}/` };
return { server, port: p, url: `http://127.0.0.1:${p}/`, stats: statsStore };
}

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
Expand Down
2 changes: 2 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Settings come from a .env file next to this one (never commit it):
# ALLOWED_ORIGINS=https://your-site.example
# POSTGRES_PASSWORD=<long random password>
# STATS_TOKEN=<long random key for /api/stats and stats.html>
services:
minicrafter-rooms:
build: .
Expand All @@ -25,6 +26,7 @@ services:
environment:
ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:?set ALLOWED_ORIGINS in .env}
DATABASE_URL: postgres://minicrafter:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@minicrafter-db:5432/minicrafter
STATS_TOKEN: ${STATS_TOKEN:-} # empty = /api/stats is closed
networks: [minicrafter_net]
read_only: true
mem_limit: 256m
Expand Down
Loading
Loading