UCAN
Basic example of how to make a UCAN. Note that the issuer always has to be your DID, because the UCAN will be signed with your private key.
1
import * as wn from "webnative"
2
​
3
// DIDs
4
const ourDID = await wn.did.ucan()
5
const otherDID = "did:key:EXAMPLE"
6
​
7
/**
8
* This can be another UCAN which has a bigger, or equal,
9
* set of permissions than the UCAN we're building later.
10
*/
11
const possibleProof = null // or, other UCAN.
12
​
13
/**
14
* The UCAN, encoded as a string.
15
*/
16
const ucan = await wn.ucan.build({
17
audience: otherDID,
18
issuer: ourDID,
19
lifetimeInSeconds: 60 * 60 * 24, // UCAN expires in 24 hours
20
proof: possibleProof
21
})
Copied!
​
Last modified 11mo ago
Export as PDF
Copy link