Library for resolving, creating, and publishing DID documents over IPNS
npm install ipns-didNOTE: The IPNS-DID spec is unstable.
JavaScript library for publishing, updating, and resolving DID documents over
the IPNS method.
The library default exports a factory function:
``ts
import IPNSDID from "ipns-did";
import * as IPFS from 'ipfs-core'
const ipfs = await IPFS.create()
const ipnsDid = IPNSDID(ipfs, { codecs: [myCodec], hashers: [myHasher] });
`DAG-JSON
By default the library supports , DAG-CBOR, and DAG-PB codecs, andsha2-256
the hasher.
You can then use this object to perform some DID document operations:
`ts
await ipnsDid.resolve("did:ipns:did.example.com");
const { ipnsCid, docCid } = await ipnsDid.publishDid(
{ id: ipnsDid.peerIdToDid(peerId) }, // Minimal valid DID document
{ codec: cbor.code, hasher: sha256.code }, // Will default to these two if passed {}
peerId, // You will need to handle your own PeerId
24 60 60 * 1000 // Lifetime of the IPNS record, in milliseconds
);
`
For creating and validating DID documents, you can use the did-doc`
library.