Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.
/ js-ipfs-did-document Public archive

A module for creating ipfs based DID Documents

License

Notifications You must be signed in to change notification settings

3box/js-ipfs-did-document

Repository files navigation

⚠️ ⚠️ Deprecated in favor of Ceramic ⚠️ ⚠️

3box.js and related tools built by 3Box Labs are deprecated and no loger supported. Developers are encurraged to build with https://ceramic.network which is a more secure and decentralized protocol for sovereign data.

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

About

A module for creating ipfs based DID Documents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published