Skip to content
A module for creating ipfs based DID Documents
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
.gitignore
LICENSE
README.md
index.js
package-lock.json
package.json
readme-template.md

README.md

js-ipfs-did-document

This is a module for creating ipfs based DID Documents. The CID of the first document created will become the identifier of the DID. Any subsequent updates to a DID document will link back to the previous document CID. In order to create a complete DID Method this module needs to be paired with a revocation module that handles revocation and rotation of keys.

Install

Using npm:

$ npm install ipfs-did-document

API

DidDocument

A class for creating ipfs based DID Documents. Based on the DID spec: https://w3c-ccg.github.io/did-spec/

Kind: global class

new DidDocument(ipfs, method)

Create a new DID Document.

Param Type Description
ipfs Object An js-ipfs instance
method String The name of the DID Method

didDocument.addPublicKey(id, type, encoding, key, owner)

Add a new public key

Kind: instance method of DidDocument

Param Type Description
id String The id of the key, e.g. "key1"
type String The type of the key
encoding String The encoding of the key
key String The encoded public key
owner String The owner of the key (optional)

didDocument.removePublicKey(id)

Remove a public key

Kind: instance method of DidDocument

Param Type Description
id String The id of the key, e.g. "key1"

didDocument.addAuthentication(type, id)

Add a new authentication

Kind: instance method of DidDocument

Param Type Description
type String The type of the authentication
id String The id of the key to be used, e.g. "key1"

didDocument.removeAuthentication(id)

Remove an authentication

Kind: instance method of DidDocument

Param Type Description
id String The id of the key, e.g. "key1"

didDocument.addService(id, type, serviceEndpoint, additionalFields)

Add a new service

Kind: instance method of DidDocument

Param Type Description
id String The id of the key to be used, e.g. "key1"
type String The type of the service
serviceEndpoint String The endpoint of the service
additionalFields Object Any additional fields (optional)

didDocument.removeService(id)

Remove a service

Kind: instance method of DidDocument

Param Type Description
id String The id of the key, e.g. "key1"

didDocument.setRevocationMethod(methodDescriptor)

Set the revocationMethod. This can be of any js object and is determined by the implementer of a revocation module.

Kind: instance method of DidDocument

Param Type Description
methodDescriptor Object the object that defines the revocation method

didDocument.addCustomProperty(propName, propValue)

Add a new property

Kind: instance method of DidDocument

Param Type Description
propName String The name of the property
propValue Object The value of the property

didDocument.removeCustomProperty(propName)

Remove a property

Kind: instance method of DidDocument

Param Type Description
propName String The name of the property

didDocument.commit() ⇒ Promise.<CID>

Commit all changes and create a new ipfs dag object.

Kind: instance method of DidDocument
Returns: Promise.<CID> - The CID of the object

DidDocument.load(ipfs, documentCid) ⇒ Promise.<DidDocument>

Load an already existing DID Document.

Kind: static method of DidDocument
Returns: Promise.<DidDocument> - self

Param Type Description
ipfs Object An js-ipfs instance
documentCid String The CID of the document

DidDocument.cidToDocument(ipfs, documentCid) ⇒ Promise.<Object>

Returns the DID document of a document CID

Kind: static method of DidDocument
Returns: Promise.<Object> - The DID document as a js object

Param Type Description
ipfs Object An js-ipfs instance
documentCid String The CID of the document
You can’t perform that action at this time.