+10
-3
src/pds.js
+10
-3
src/pds.js
···
483
483
`)
484
484
}
485
485
486
-
async initIdentity(did, privateKeyHex) {
486
+
async initIdentity(did, privateKeyHex, handle = null) {
487
487
await this.state.storage.put('did', did)
488
488
await this.state.storage.put('privateKey', privateKeyHex)
489
+
if (handle) {
490
+
await this.state.storage.put('handle', handle)
491
+
}
489
492
}
490
493
491
494
async getDid() {
···
493
496
this._did = await this.state.storage.get('did')
494
497
}
495
498
return this._did
499
+
}
500
+
501
+
async getHandle() {
502
+
return this.state.storage.get('handle')
496
503
}
497
504
498
505
async getSigningKey() {
···
638
645
if (!body.did || !body.privateKey) {
639
646
return Response.json({ error: 'missing did or privateKey' }, { status: 400 })
640
647
}
641
-
await this.initIdentity(body.did, body.privateKey)
642
-
return Response.json({ ok: true, did: body.did })
648
+
await this.initIdentity(body.did, body.privateKey, body.handle || null)
649
+
return Response.json({ ok: true, did: body.did, handle: body.handle || null })
643
650
}
644
651
if (url.pathname === '/status') {
645
652
const did = await this.getDid()