ipns-did
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

ipns-did

NOTE: The IPNS-DID spec is unstable.

JavaScript library for publishing, updating, and resolving DID documents over the IPNS method.

API

The library default exports a factory function:

import IPNSDID from "ipns-did";

import * as IPFS from 'ipfs-core'
const ipfs = await IPFS.create()

const ipnsDid = IPNSDID(ipfs, { codecs: [myCodec], hashers: [myHasher] });

By default the library supports DAG-JSON, DAG-CBOR, and DAG-PB codecs, and the sha2-256 hasher.

You can then use this object to perform some DID document operations:

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.

Package Sidebar

Install

npm i ipns-did

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

113 kB

Total Files

13

Last publish

Collaborators

  • misterupkeep