1.2.3 • Published 5 years ago

ipfs-did-document v1.2.3

Weekly downloads
613
License
MIT
Repository
github
Last release
5 years ago

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.

ParamTypeDescription
ipfsObjectAn js-ipfs instance
methodStringThe name of the DID Method

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

Add a new public key

Kind: instance method of DidDocument

ParamTypeDescription
idStringThe id of the key, e.g. "key1"
typeStringThe type of the key
encodingStringThe encoding of the key
keyStringThe encoded public key
ownerStringThe owner of the key (optional)

didDocument.removePublicKey(id)

Remove a public key

Kind: instance method of DidDocument

ParamTypeDescription
idStringThe id of the key, e.g. "key1"

didDocument.addAuthentication(type, id)

Add a new authentication

Kind: instance method of DidDocument

ParamTypeDescription
typeStringThe type of the authentication
idStringThe id of the key to be used, e.g. "key1"

didDocument.removeAuthentication(id)

Remove an authentication

Kind: instance method of DidDocument

ParamTypeDescription
idStringThe id of the key, e.g. "key1"

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

Add a new service

Kind: instance method of DidDocument

ParamTypeDescription
idStringThe id of the key to be used, e.g. "key1"
typeStringThe type of the service
serviceEndpointStringThe endpoint of the service
additionalFieldsObjectAny additional fields (optional)

didDocument.removeService(id)

Remove a service

Kind: instance method of DidDocument

ParamTypeDescription
idStringThe 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

ParamTypeDescription
methodDescriptorObjectthe object that defines the revocation method

didDocument.addCustomProperty(propName, propValue)

Add a new property

Kind: instance method of DidDocument

ParamTypeDescription
propNameStringThe name of the property
propValueObjectThe value of the property

didDocument.removeCustomProperty(propName)

Remove a property

Kind: instance method of DidDocument

ParamTypeDescription
propNameStringThe 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

ParamTypeDescription
ipfsObjectAn js-ipfs instance
documentCidStringThe 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

ParamTypeDescription
ipfsObjectAn js-ipfs instance
documentCidStringThe CID of the document