forked from WikiDeck/wikideck
testnet-ops: TESTNET.md secure-context workaround and counts; identity store under WIKIDECK_DATA_DIR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-2
@@ -25,13 +25,22 @@ Four disposable wallets: **alice**, **bob**, **carol** and **dave**.
|
||||
| carol | `f2d908633c4313bd77e86650c13d11ac3e7e656223ebe881cc34ffba3f3e0524` | leftovers |
|
||||
| dave | `02bb97f202e1616ab97b45e8938e384dcbf622a0b44a7f4c1589f44236d3ccef` | leftovers |
|
||||
|
||||
- Confirmed at height 91: **alice 41, bob 40**, carol 5, dave 5. Block #92 came from the Android emulator (#59).
|
||||
- alice and bob were consolidated to 40 cards each with on-chain NFT transfers from carol and dave, so **production `deckSize` 40 works on the testnet** and no lower-deckSize test mode is needed.
|
||||
- **The encrypted browser backups are in a comment on #63**, not in git.
|
||||
- Backup password: `wikideck-night-testnet`. It is **public and testnet-only**: never reuse it, and never put a real secret next to it.
|
||||
- Re-check counts at any time: `GET http://192.168.1.32:3101/api/decks/<address>?offset=0&limit=24` (pages of 24, follow `next`).
|
||||
|
||||
### Load a wallet in the browser
|
||||
Use a separate browser profile, or a private window, per player, because a browser holds one wallet per origin.
|
||||
**First make the node origins a secure context** (found by night-review on #63).
|
||||
- `http://192.168.1.32:310x` is plain HTTP on a LAN address, so the browser leaves `crypto.subtle` undefined. Open wallet then fails with "Cannot read properties of undefined (reading 'digest')" or "Wallet storage unavailable".
|
||||
- **Chrome/Chromium:** open `chrome://flags/#unsafely-treat-insecure-origin-as-secure`, add `http://192.168.1.32:3101,http://192.168.1.32:3102,http://192.168.1.32:3103`, then relaunch.
|
||||
- **Command line:** `--unsafely-treat-insecure-origin-as-secure=http://192.168.1.32:3101,http://192.168.1.32:3102,http://192.168.1.32:3103 --user-data-dir=<fresh profile dir>`.
|
||||
- **Playwright:** use the full `chromium` channel. The headless shell ignores this flag.
|
||||
- **SSH tunnel to `localhost`:** this also works for the wallet, but it breaks the Dex callback URLs, so you can't do the login/link step that way.
|
||||
- **Firefox** has no per-origin equivalent.
|
||||
|
||||
Use a separate browser profile per player, because a browser holds one wallet per origin.
|
||||
1. Open a node URL, then **Open wallet**.
|
||||
2. **Recover from a local backup**: choose the backup JSON file (save it from the #63 comment as `alice.backup.json`), and enter the backup password above.
|
||||
3. Set a new local encryption password (at least 12 characters, anything testnet-only), then confirm it.
|
||||
@@ -51,7 +60,7 @@ Use a separate browser profile, or a private window, per player, because a brows
|
||||
|
||||
## Card identity pre-bake (engineer WS E)
|
||||
- `server/game/identity.ts` is a persistent per-token store (`node:sqlite`). It freezes each card's off-chain identity at first sight and never rewrites it. The identity covers P31/P279 classes, description, categories, countries, years, coordinates and outlink pageIds. Its fields match duel-cards' `CardProfile` (#70), and `toProfile()` returns that view.
|
||||
- `scripts/night2/prebake-identity.ts --node <url> --store <file> [--cards <cached.json> ...]` reads the canonical chain from one node and freezes what the cached card files know.
|
||||
- `scripts/night2/prebake-identity.ts --node <url> [--store <file>] [--cards <cached.json> ...]` reads the canonical chain from one node and freezes what the cached card files know. The store defaults to `$WIKIDECK_DATA_DIR/card-identity.sqlite` (`identityStoreFile()`), and hosts should open it at the same path.
|
||||
- It **never calls Wikimedia itself**.
|
||||
- Live facts arrive only through the wikimedia team's client on its `background` lane (#62), once that client has merged.
|
||||
- Cards that are still unknown stay unfrozen and are retried on a later run.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// testnet-ops (engineer WS E): pre-bake frozen card identities for every card on a chain.
|
||||
//
|
||||
// node --experimental-strip-types scripts/night2/prebake-identity.ts --node http://192.168.1.32:3101 \
|
||||
// --store ./identity.sqlite [--cards docs/game/card-sample.json] [--batch 50]
|
||||
// --store $WIKIDECK_DATA_DIR/card-identity.sqlite [--cards docs/game/card-sample.json] [--batch 50]
|
||||
//
|
||||
// - Reads the canonical chain from ONE node (GET /api/summary, then /api/canonical pages), so every
|
||||
// card is built from its mint block, never from client JSON.
|
||||
@@ -13,11 +13,11 @@
|
||||
// - Idempotent and freeze-at-first-sight: already frozen tokens are skipped and never rewritten.
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { parseArgs } from 'node:util';
|
||||
import { IdentityStore, cachedSource, prebake, type ChainArticle } from '../../server/game/identity.ts';
|
||||
import { IdentityStore, cachedSource, identityStoreFile, prebake, type ChainArticle } from '../../server/game/identity.ts';
|
||||
|
||||
const { values } = parseArgs({ options: {
|
||||
node: { type: 'string', default: 'http://192.168.1.32:3101' },
|
||||
store: { type: 'string', default: 'identity.sqlite' },
|
||||
store: { type: 'string', default: identityStoreFile() },
|
||||
cards: { type: 'string', multiple: true, default: ['docs/game/card-sample.json'] },
|
||||
batch: { type: 'string', default: '50' },
|
||||
} });
|
||||
|
||||
@@ -10,8 +10,13 @@
|
||||
// - First write wins: `freeze` never overwrites an existing record (data §3 "freeze at first sight").
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { join, resolve } from 'node:path';
|
||||
|
||||
export const IDENTITY_VERSION = 1;
|
||||
/** Where hosts keep the store: next to the ledger, `$WIKIDECK_DATA_DIR/card-identity.sqlite` (default ./data). */
|
||||
export function identityStoreFile(env: NodeJS.ProcessEnv = process.env): string {
|
||||
return join(env.WIKIDECK_DATA_DIR ?? resolve('data'), 'card-identity.sqlite');
|
||||
}
|
||||
|
||||
/** Same shape as shared/duel/classify.ts `WikidataClass` (duel-cards, #70). */
|
||||
export type WikidataClass = { id: string; label: string };
|
||||
|
||||
@@ -4,7 +4,7 @@ import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { IdentityStore, buildIdentity, cachedSource, linksHash, prebake, toProfile,
|
||||
import { identityStoreFile, IdentityStore, buildIdentity, cachedSource, linksHash, prebake, toProfile,
|
||||
type ChainArticle, type IdentitySource } from '../server/game/identity.ts';
|
||||
|
||||
const sample = JSON.parse(readFileSync(new URL('../docs/game/card-sample.json', import.meta.url), 'utf8')).cards as any[];
|
||||
@@ -83,3 +83,8 @@ test('sources are asked in bounded batches and identities persist across reopen'
|
||||
store.close();
|
||||
} finally { rmSync(dir, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('the store file lives under WIKIDECK_DATA_DIR, next to the ledger', () => {
|
||||
assert.equal(identityStoreFile({ WIKIDECK_DATA_DIR: '/srv/wd' }), join('/srv/wd', 'card-identity.sqlite'));
|
||||
assert.ok(identityStoreFile({}).endsWith(join('data', 'card-identity.sqlite')));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user