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