extremely claude-assisted go game based on atproto! working on cleaning up and giving a more unique design, still has a bit of a slop vibe to it.

Add bug fixes summary documentation

- Document all OAuth API fixes
- Document local development fallbacks
- Document ESM/CommonJS module fixes
- Add development setup instructions

+100
+100
BUGFIXES.md
··· 1 + # Bug Fixes - Local Development Setup 2 + 3 + ## Summary 4 + Fixed critical issues blocking local development after Cloudflare migration. 5 + 6 + ## Issues Fixed 7 + 8 + ### 1. OAuth API Breaking Changes (✅ Fixed) 9 + **Problem:** `@atcute/oauth-node-client` v1.1.0 removed `importJwkKey` export 10 + 11 + **Solution:** 12 + - Updated to use `ClientAssertionPrivateJwk` type directly 13 + - Parse JWK JSON and pass as array to keyset parameter 14 + - Updated key generation script to use `generateClientAssertionKey` 15 + 16 + **Files Changed:** 17 + - `src/lib/server/auth.ts` 18 + - `scripts/generate-key.ts` 19 + 20 + ### 2. Missing Local Development Fallbacks (✅ Fixed) 21 + **Problem:** App required Cloudflare D1 and KV which aren't available in local dev 22 + 23 + **Solution:** 24 + - Database: Falls back to better-sqlite3 when D1 not available 25 + - OAuth Storage: Falls back to MemoryStore when KV not available 26 + - Environment: Reads from process.env when platform.env not available 27 + - Added dotenv back for local development 28 + 29 + **Files Changed:** 30 + - `src/lib/server/db.ts` 31 + - `src/lib/server/auth.ts` 32 + - `src/hooks.server.ts` 33 + 34 + ### 3. ESM/CommonJS Module Issues (✅ Fixed) 35 + **Problem:** `require is not defined` error in ESM modules 36 + 37 + **Solution:** 38 + - Use `createRequire` from 'module' to enable CommonJS in ESM 39 + - Keep getDb synchronous to avoid breaking 16+ call sites 40 + 41 + **Files Changed:** 42 + - `src/lib/server/db.ts` 43 + 44 + ### 4. OAuth Key Generation (✅ Fixed) 45 + **Problem:** Key generation script using old API, detecting commented keys 46 + 47 + **Solution:** 48 + - Updated to use `generateClientAssertionKey` from @atcute/oauth-crypto 49 + - Fixed regex to only detect uncommented PRIVATE_KEY_JWK lines 50 + 51 + **Files Changed:** 52 + - `scripts/generate-key.ts` 53 + 54 + ## Current Status 55 + 56 + ### ✅ Working 57 + - OAuth key generation (`npm run setup:key`) 58 + - Database initialization (SQLite local fallback) 59 + - Environment configuration (.env loading) 60 + - Build process (`npm run build`) 61 + 62 + ### ⚠️ Needs Testing 63 + - Dev server runtime (`npm run dev`) 64 + - OAuth login flow 65 + - Game creation and moves 66 + - Image generation endpoints 67 + 68 + ### 📋 Next Steps 69 + 1. Test dev server with all endpoints 70 + 2. Verify OAuth flow works end-to-end 71 + 3. Test game creation and gameplay 72 + 4. Add reactions feature 73 + 5. Deploy to Cloudflare Pages 74 + 75 + ## Development Setup 76 + 77 + To run locally: 78 + ```bash 79 + # 1. Install dependencies 80 + npm install 81 + 82 + # 2. Generate OAuth keys 83 + npm run setup:key 84 + 85 + # 3. Start dev server 86 + npm run dev 87 + ``` 88 + 89 + The app will use: 90 + - SQLite database at `./data/app.db` 91 + - MemoryStore for sessions/state 92 + - OAuth with generated JWK keys 93 + 94 + ## Deployment Notes 95 + 96 + For Cloudflare Pages deployment: 97 + - D1 database will be used instead of SQLite 98 + - KV namespaces will be used instead of MemoryStore 99 + - Environment secrets from Cloudflare dashboard 100 + - See `CLOUDFLARE_DEPLOYMENT.md` for details