development diary -- UCAN
nichoth/fission-did is a repo I made to test the fission DID and UCAN libraries. See that readme & example.js
file for discussion & examples.
fission-suite/ucan is the newer fission library for creating & working with UCANs. The difficult part is that the UCAN library and the webnative
library each return a different interface for UCANs.
The ucans
library has and API like this:
// in-memory keypair
const keypair = await ucan.keypair.create(ucan.KeyType.Edwards)
const u = await ucan.build({
audience: audience.did(), //recipient
issuer: keypair, //signing key
// ...
You'll notice that the keypair
returned by ucans
has a method .did
.
Which is great for testing, because it makes it easy to create a temporary, in memory keypair. But how do you keep the same keypair over time?
Normally you would use the webnative library, which uses the keystore-idb library to get a key. It stores the keys in the browser via local forage
, and you would get the did like this:
webnative.did.ucan().then(ourDID => // ...
But keystore-idb
has a different keypair API than ucans
. That's why I made nichoth/keystore-idb. It has a method getKeypair that returns the same keypair API as ucans
.
I would submit this as a PR, but I don't really know what direction the rest of the team wants to go in regarding reconciling the webnative and ucans
APIs. Also my test is a little wonky because I'm using a totally different bundler and test library.