📚 Encyclopedia

Security & Cryptography · updated 2026-10-13

Server-minted claim codes for in-game rewards (never ship the secret)

rewardsone-time-codeshashingatomic-updategamescorsanti-cheat

A browser game that reveals a prize code when you win is trivially cheated if the code (or the logic that produces it) is in the shipped JavaScript. TLDR's "gold coins" (August 2026) fix this: the game ships no secret; it reports progress to the API, and the server mints a one-time code only after it is satisfied the play happened. The first version embedded an XOR-obfuscated code in the game; it was considered burned (it sat in git history and old deploys) and the coin's hash was rotated.

Model

Endpoints

Why it holds up

The server never trusts a client-supplied "I won"; it trusts a timeline it recorded itself, and the timestamps per seal are an audit trail for suspicious mints. Nothing secret is ever in the client. Admin fallback codes live in a 0600, git-excluded file.

Cross-site CORS

The game lives on a different site than the API, so the API vhost echoes an allowlisted Origin:

SetEnvIf Origin "^https://(tldrnerd\.com|justinahampton\.com)$" CORS_ORIGIN=$0
Header always set Access-Control-Allow-Origin "%{CORS_ORIGIN}e" env=CORS_ORIGIN

Requests without an Origin header (curl) get no ACAO header at all, so test with -H 'Origin: ...'.

Money note

If rewards become cash prizes, US payouts over $600 per person per year trigger 1099 reporting.

See also

Sources: tldr memory (feature-gold-coins), post #1568