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.
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.
Using npm:
$ npm install ipfs-did-document
A class for creating ipfs based DID Documents. Based on the DID spec: https://w3c-ccg.github.io/did-spec/
Kind: global class
- DidDocument
- new DidDocument(ipfs, method)
- instance
- .addPublicKey(id, type, encoding, key, owner)
- .removePublicKey(id)
- .addAuthentication(type, id)
- .removeAuthentication(id)
- .addService(id, type, serviceEndpoint, additionalFields)
- .removeService(id)
- .setRevocationMethod(methodDescriptor)
- .addCustomProperty(propName, propValue)
- .removeCustomProperty(propName)
- .commit() ⇒
Promise.<CID>
- static
- .load(ipfs, documentCid) ⇒
Promise.<DidDocument>
- .cidToDocument(ipfs, documentCid) ⇒
Promise.<Object>
- .load(ipfs, documentCid) ⇒
Create a new DID Document.
Param | Type | Description |
---|---|---|
ipfs | Object |
An js-ipfs instance |
method | String |
The name of the DID Method |
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) |
Remove a public key
Kind: instance method of DidDocument
Param | Type | Description |
---|---|---|
id | String |
The id of the key, e.g. "key1" |
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" |
Remove an authentication
Kind: instance method of DidDocument
Param | Type | Description |
---|---|---|
id | String |
The id of the key, e.g. "key1" |
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) |
Remove a service
Kind: instance method of DidDocument
Param | Type | Description |
---|---|---|
id | String |
The id of the key, e.g. "key1" |
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 |
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 |
Remove a property
Kind: instance method of DidDocument
Param | Type | Description |
---|---|---|
propName | String |
The name of the property |
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 |
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 |