this repo has no description

feat: add identity storage and init endpoint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Changed files
+33
src
+33
src/pds.js
··· 263 `) 264 } 265 266 async fetch(request) { 267 const url = new URL(request.url) 268 if (url.pathname === '/test/cbor') { ··· 294 return Response.json({ 295 publicKey: bytesToHex(kp.publicKey), 296 signature: bytesToHex(sig) 297 }) 298 } 299 return new Response('pds running', { status: 200 })
··· 263 `) 264 } 265 266 + async initIdentity(did, privateKeyHex) { 267 + await this.state.storage.put('did', did) 268 + await this.state.storage.put('privateKey', privateKeyHex) 269 + } 270 + 271 + async getDid() { 272 + if (!this._did) { 273 + this._did = await this.state.storage.get('did') 274 + } 275 + return this._did 276 + } 277 + 278 + async getSigningKey() { 279 + const hex = await this.state.storage.get('privateKey') 280 + if (!hex) return null 281 + return importPrivateKey(hexToBytes(hex)) 282 + } 283 + 284 async fetch(request) { 285 const url = new URL(request.url) 286 if (url.pathname === '/test/cbor') { ··· 312 return Response.json({ 313 publicKey: bytesToHex(kp.publicKey), 314 signature: bytesToHex(sig) 315 + }) 316 + } 317 + if (url.pathname === '/init') { 318 + const body = await request.json() 319 + if (!body.did || !body.privateKey) { 320 + return Response.json({ error: 'missing did or privateKey' }, { status: 400 }) 321 + } 322 + await this.initIdentity(body.did, body.privateKey) 323 + return Response.json({ ok: true, did: body.did }) 324 + } 325 + if (url.pathname === '/status') { 326 + const did = await this.getDid() 327 + return Response.json({ 328 + initialized: !!did, 329 + did: did || null 330 }) 331 } 332 return new Response('pds running', { status: 200 })