Class: DIDModule

DIDModule(api, signAndSend)

Class to create, update and destroy DIDs

Constructor

new DIDModule(api, signAndSend)

Creates a new instance of DIDModule and sets the api
Parameters:
Name Type Description
api object PolkadotJS API Reference
signAndSend Function to sign and send transaction
Source:

Methods

(async) addControllers(controllers, targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<*>}

Add controllers to an on-chain DID.
Parameters:
Name Type Default Description
controllers The DIDs that will control the `targetDid`
targetDid The DID to which controllers are being added
signerDid The DID that is adding the controllers by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) addKeys(didKeys, targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<*>}

Add keys to an on-chain DID
Parameters:
Name Type Default Description
didKeys Array.<DidKey> Array of `DidKey`s as expected by the Substrate node
targetDid The DID to which keys are being added
signerDid The DID that is adding the keys by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) addServiceEndpoint(endpointId, endpointType, origins, targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<*>}

Add a new service endpoint
Parameters:
Name Type Default Description
endpointId The id of the service endpoint. Each endpoint has a unique id.
endpointType ServiceEndpointType The type of the endpoint.
origins Array An array of one of URIs encoded as hex.
targetDid The DID to which service endpoint is being added
signerDid The DID that is adding the service endpoint by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) createAddControllersTx(controllers, targetDid, signerDid, signingKeyRef, nonce) → {Promise.<*>}

Create transaction to add controllers to an on-chain DID.
Parameters:
Name Type Description
controllers The DIDs that will control the `targetDid`
targetDid The DID to which keys are being added
signerDid The DID that is adding the controllers by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
Type
Promise.<*>

(async) createAddKeysTx(didKeys, targetDid, signerDid, signingKeyRef, nonce) → {Promise.<*>}

Create transaction to add keys to an on-chain DID.
Parameters:
Name Type Description
didKeys Array.<DidKey> Array of `DidKey`s as expected by the Substrate node
targetDid The DID to which keys are being added
signerDid The DID that is adding the keys by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
Type
Promise.<*>

(async) createAddServiceEndpointTx(endpointId, endpointType, origins, targetDid, signerDid, signingKeyRef, nonce) → {Promise.<*>}

Create a transaction to add a new service endpoint
Parameters:
Name Type Description
endpointId The id of the service endpoint. Each endpoint has a unique id.
endpointType ServiceEndpointType The type of the endpoint.
origins Array An array of one of URIs encoded as hex.
targetDid The DID to which service endpoint is being added
signerDid The DID that is adding the service endpoint by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
Type
Promise.<*>

createNewOffchainTx(did, didDocRef) → {*}

Creates transaction to create a new off-chain DID
Parameters:
Name Type Description
did -
didDocRef OffChainDidDocRef Off chain reference for the DID
Source:
Returns:
Type
*

createNewOnchainTx(did, didKeys, controllers) → {object}

Creates transaction to create a new DID on the Dock chain.
Parameters:
Name Type Description
did string The new DID. Can be a full DID or hex identifier
didKeys Array.<DidKey> Array of `DidKey`s as expected by the Substrate node
controllers array Array of `Did`s as expected by the Substrate node
Source:
Returns:
The extrinsic to sign and send.
Type
object

(async) createRemoveKeysTx(keyIds, targetDid, signerDid, signingKeyRef, nonce) → {Promise.<*>}

Create transaction to remove keys
Parameters:
Name Type Description
keyIds Key indices to remove
targetDid The DID from which keys are being removed
signerDid The DID that is removing the keys by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
Type
Promise.<*>

createRemoveOffchainDidTx(did) → {Promise.<*>}

Create transaction to remove off chain DID
Parameters:
Name Type Description
did
Source:
Returns:
Type
Promise.<*>

(async) createRemoveServiceEndpointTx(endpointId, targetDid, signerDid, signingKeyRef, nonce) → {Promise.<*>}

Create transaction to remove a service endpoint from a DID
Parameters:
Name Type Description
endpointId The endpoint to remove
targetDid The DID from which endpoint is being removed
signerDid The DID that is removing the endpoint by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
Type
Promise.<*>

(async) createRemoveTx(targetDid, signerDid, signingKeyRef, nonce) → {Promise.<object>}

Create a transaction to remove an on-chain DID
Parameters:
Name Type Description
targetDid The DID being removed
signerDid The DID that is removing `targetDid` by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
The extrinsic to sign and send.
Type
Promise.<object>

(async) createSetClaimTx(priority, iri, did, signingKeyRef, nonce) → {Promise.<SubmittableExtrinsic.<ApiType>>}

Parameters:
Name Type Description
priority
iri
did
signingKeyRef
nonce
Source:
Returns:
Type
Promise.<SubmittableExtrinsic.<ApiType>>

createSetOffchainDidRefTx(did, didDocRef) → {*}

Create a transaction to update the DID Doc reference of the off chain DID
Parameters:
Name Type Description
did
didDocRef new reference
Source:
Returns:
Type
*

(async) getAttests(hexId) → {Promise.<(string|null)>}

Fetches the DIDs attestations IRI from the chain
Parameters:
Name Type Description
hexId string DID in hex format
Source:
Returns:
The DID's attestation, if any
Type
Promise.<(string|null)>

(async) getDidKey(did, keyIndex) → {Promise.<DidKey>}

Get the `DidKey` for the DID with given key index. Key indices start from 1 and can have holes
Parameters:
Name Type Description
did
keyIndex number
Source:
Returns:
Type
Promise.<DidKey>

(async) getDocument(did, getOffchainSigKeys) → {Promise.<object>}

Gets a DID from the Dock chain and create a DID document according to W3C spec. Throws NoDID if the DID does not exist on chain.
Parameters:
Name Type Description
did string The DID can be passed as fully qualified DID like `did:dock:` or a 32 byte hex string
getOffchainSigKeys
Source:
Returns:
The DID document.
Type
Promise.<object>

getFullyQualifiedDID(did) → {string}

Create the fully qualified DID like "did:dock:..."
Parameters:
Name Type Description
did string DID
Source:
Returns:
The DID identifier.
Type
string

getFullyQualifiedDIDMethodKey(didMethodKey) → {string}

Create the fully qualified DID like "did:dock:..."
Parameters:
Name Type Description
didMethodKey string DID
Source:
Returns:
The DID identifier.
Type
string

(async) getNextNonceForDid(did) → {Promise.<*>}

Gets the nonce that should be used for sending the next transaction by this DID. Its 1 more than the current nonce.
Parameters:
Name Type Description
did DockDidOrDidMethodKey
Source:
Returns:
Type
Promise.<*>

(async) getNonceForDid(did) → {Promise.<number>}

Gets the current nonce for the DID. It will throw error if the DID does not exist on chain or chain returns null response.
Parameters:
Name Type Description
did DockDidOrDidMethodKey DID identifier as hex. Not accepting full DID intentionally for efficiency as these methods are used internally
Source:
Returns:
Type
Promise.<number>

(async) getOffchainDidDetail(didIdentifier) → {Promise.<{accountId: HexString}>}

Gets the DID detail of an on chain DID
Parameters:
Name Type Description
didIdentifier
Source:
Returns:
Type
Promise.<{accountId: HexString}>

(async) getOnchainDidDetail(didIdentifier) → {Promise.<object>}

Gets the DID detail of an on chain DID the chain and return them. It will throw NoDID if the DID does not exist on chain.
Parameters:
Name Type Description
didIdentifier string DID identifier as hex. Not accepting full DID intentionally for efficiency as these methods are used internally
Source:
Returns:
Type
Promise.<object>

getSerializedAddKeys(addKeys) → {Array}

Serializes a `AddKeys` for signing.
Parameters:
Name Type Description
addKeys object `AddKeys` as expected by the Substrate node
Source:
Returns:
An array of Uint8
Type
Array

getSerializedAttestation(setAttestation) → {Array}

Serializes an `Attestation` for signing.
Parameters:
Name Type Description
setAttestation object `SetAttestationClaim` as expected by the Substrate node
Source:
Returns:
An array of Uint8
Type
Array

getSerializedDidRemoval(didRemoval) → {Array}

Serializes a `DidRemoval` for signing.
Parameters:
Name Type Description
didRemoval object `DidRemoval` as expected by the Substrate node
Source:
Returns:
An array of Uint8
Type
Array

(async) getServiceEndpoint(did, endpointId) → {Promise}

Returns the service endpoint of the DID and known by `endpointId`
Parameters:
Name Type Description
did
endpointId
Source:
Returns:
Type
Promise

(async) isController(controlled, controller) → {Promise.<boolean>}

Returns true if DID `controller` is a controller of DID `controlled`, false otherwise
Parameters:
Name Type Description
controlled
controller
Source:
Returns:
Type
Promise.<boolean>

(async) new(did, didKeys, controllers, waitForFinalization, params) → {Promise.<object>}

Creates a new DID on the Dock chain.
Parameters:
Name Type Default Description
did string The new DID. Can be a full DID or hex identifier
didKeys Array.<DidKey> Array of `DidKey`s as expected by the Substrate node
controllers array Array of `Did`s as expected by the Substrate node.
waitForFinalization true
params
Source:
Returns:
Promise to the pending transaction
Type
Promise.<object>

(async) newDidMethodKey(did, waitForFinalization, params) → {Promise.<object>}

Creates a new `did:key:` on the Dock chain.
Parameters:
Name Type Description
did Object | Object The new DID. Can be either `PublicKeyEd25519` or `PublicKeySecp256k1`.
waitForFinalization
params
Source:
Returns:
Promise to the pending transaction
Type
Promise.<object>

(async) newOffchain(did, didDocRef, waitForFinalization, params) → {Promise.<*>}

Create a new off-chain DID
Parameters:
Name Type Default Description
did
didDocRef Off chain reference for the DID
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) remove(targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<object>}

Removes an on-chain DID.
Parameters:
Name Type Default Description
targetDid The DID being removed
signerDid The DID that is removing `targetDid` by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Promise to the pending transaction
Type
Promise.<object>

(async) removeControllers(controllers, targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<*>}

Remove controllers from a DID
Parameters:
Name Type Default Description
controllers Controller DIDs to remove.
targetDid The DID from which controllers are being removed
signerDid The DID that is removing the controllers by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) removeControllersTx(controllers, targetDid, signerDid, signingKeyRef, nonce) → {Promise.<*>}

Create transaction to remove controllers from a DID
Parameters:
Name Type Description
controllers Controller DIDs to remove.
targetDid The DID from which controllers are being removed
signerDid The DID that is removing the controllers by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
Source:
Returns:
Type
Promise.<*>

(async) removeKeys(keyIds, targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<*>}

Remove keys from a DID
Parameters:
Name Type Default Description
keyIds Key indices to remove
targetDid The DID from which keys are being removed
signerDid The DID that is removing the keys by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) removeOffchainDid(did, waitForFinalization, params) → {Promise.<*>}

Remove off-chain DID
Parameters:
Name Type Default Description
did
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) removeServiceEndpoint(endpointId, targetDid, signerDid, signingKeyRef, nonce, waitForFinalization, params) → {Promise.<*>}

Remove a service endpoint from a DID
Parameters:
Name Type Default Description
endpointId The endpoint to remove
targetDid The DID from which endpoint is being removed
signerDid The DID that is removing the endpoint by signing the payload because it controls `targetDid`
signingKeyRef Signer's keypair reference
nonce The nonce to be used for sending this transaction. If not provided then an appropriate nonce will be fetched from chain before creating the transaction
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>

(async) setClaim(priority, iri, did, signingKeyRef, nonce, waitForFinalization, params)

Creates an attestation claim on chain for a specific DID
Parameters:
Name Type Default Description
priority
iri
did
signingKeyRef
nonce
waitForFinalization true
params
Source:

(async) setOffchainDidRef(did, didDocRef, waitForFinalization, params) → {Promise.<*>}

Update the DID Doc reference of the off chain DID
Parameters:
Name Type Default Description
did
didDocRef
waitForFinalization true
params
Source:
Returns:
Type
Promise.<*>