summaryrefslogtreecommitdiffstats
path: root/web/play/README.md
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-08 03:29:35 +0100
committersalmonik <salmonik@tuta.io>2026-11-08 03:29:35 +0100
commit058432130628d00764663ecf819a9adc6793768d (patch)
treed3f49f111fbfaa48647cca2600adcf9017af2d30 /web/play/README.md
parentweb: serve latest.php through PHP and refuse stray PHP files (diff)
downloadzagan-bet-058432130628d00764663ecf819a9adc6793768d.tar.gz
zagan-bet-058432130628d00764663ecf819a9adc6793768d.zip
v5.0.0: protocol v5 and the browser frontend
Protocol v5 replaces newline lines with bounded [u32 len][text] frames and REQ/RES/EVT envelopes. Requests carry correlation ids and the server replays the last 256 replies per connection, so a gateway retry cannot double-debit and a late reply cannot clobber a newer request. HELLO/PONG carry server time; crash rounds announce started_at and push coalesced 10 Hz ticks. Crash now commits sha256(seed) before a round and reveals the seed when it ends, so clients recompute the crash point. Adds the webd/ gateway: one blocking thread, one ClientCore and one pinned upstream TLS connection per session, an HttpOnly session cookie, takeover, and a 60-second grace window. The browser sends Command JSON and renders View JSON; it never speaks the game protocol or stores credentials. Adds the vanilla TypeScript browser app at /play/ (login, lobby, all four games, history, notices, crash verification), the nginx /play and /ws routes, and the headless DOM smoke test. webd and the app stay out of the TUI/GUI/server build graph. The client/server version moves to 5.0.0 in lockstep; v4 peers are refused at HELLO.
Diffstat (limited to '')
-rw-r--r--web/play/README.md56
1 files changed, 56 insertions, 0 deletions
diff --git a/web/play/README.md b/web/play/README.md
new file mode 100644
index 0000000..610c7a8
--- /dev/null
+++ b/web/play/README.md
@@ -0,0 +1,56 @@
1# `web/play` — browser frontend
2
3Vanilla TypeScript + esbuild. The browser sends `Command` JSON and renders
4`View` JSON; it contains no game rules, no payout math and no wire protocol.
5The gateway in `webd/` owns the upstream TLS connection.
6
7## Build
8
9```sh
10npm ci
11npm run build # writes app.js
12npm run typecheck
13npm test # headless DOM smoke test (jsdom)
14```
15
16Commit the generated `app.js` so the site deploys without Node.
17
18## Local development
19
20Serve the repository's `web/` directory (for `/play/`) and put the gateway
21behind the same origin at `/ws`. The simplest local setup is nginx with the
22`web/nginx.conf.example` block pointed at a staging root and
23`ZAGAN_WEB_ORIGIN=http://127.0.0.1:8899`. For the app alone:
24
25```sh
26python3 -m http.server 8900 -d web/play
27```
28
29It will load, but the WebSocket will only connect through nginx or another
30proxy that routes `/ws` to `webd`.
31
32## Screens
33
34- Auth: login/register. The password is hashed with Web Crypto (`SHA-256`)
35 before it leaves the page; the gateway and browser never store it.
36- Lobby: four games, per-game bet, history.
37- Slots: five reels, win cells and paylines.
38- Roulette: canvas felt with straight, dozen, column and outside chips;
39 left click adds, right click removes.
40- Blackjack: dealer/player cards, hit/stand/double/forfeit.
41- Crash: curve, live multiplier, cash-out, commit/seed verification.
42- History: settled plays with net result.
43
44## Theme
45
46`style.css` mirrors the palette in `gui/src/theme.rs`: near-black ground,
47cyan focus, green for wins, gold for chips, felt green only for roulette.
48Do not introduce a second palette or hard-code colours in the render modules.
49
50## Security
51
52- The session cookie is HttpOnly and SameSite=Strict; JavaScript never reads
53 it and never stores a credential.
54- Notices are inserted with `textContent`, not HTML.
55- The app is play-money only. Do not add deposits, withdrawals, KYC or
56 real-money claims without a product decision and an ADR.