Manage DIDs
Manage the DIDs which are owned by the Edge Agent for usage in DI protocols
Last updated
Manage the DIDs which are owned by the Edge Agent for usage in DI protocols
Last updated
Many DI protocols require the agent to provide the DID which they want to use for the interaction. Some Edge Agent interactions automatically handle this usage of DIDs in protocols. However in some protocols it is more suitable for the SDK consumer to be explicit about the DID/s they want to use. When this is the case, the SDK's DidsModule
can be used to manage the DIDs owned by the agent.
The functionality of the DidsModule
is accessed via the agent
's fields: agent.dids
.
To create and store DIDs with the Edge Agent SDK, the createDid
API can be used. This API takes a CreateDidOptions
type, which has different data variants for the different DID methods supported. On success, this API returns a DidInformation
data object with the details of the DID that was created.
For instance, to create a did:key DID:
In the above example, the DID's cryptographic key will be generated using the agent's internal software-based key management. For hardware-based key management and other custom options, see .
To retrieve the current full DidInformation
of a specific DID owned by the agent, the getById
API can be used. If a DID cannot be found by the given identifier, then null
is returned:
Similarly, a DID in the wallet can be easily deleted via the deleteById
API:
Each DidInformation
contains a list of RecordTag
(DidInformation.tags
) attached to it, where a RecordTag
is simply a name-value pair stored with the record.
The tags on a DidInformation
can be replaced or updated by using the updateDid
API, and providing a new set to update. This will replace the current set of tags. An example follows:
To list all DIDs owned by the agent, the listAll
API can be used:
More complicated DidInformation
list queries can also be achieved by utilizing the ListDidsFilters
filter. These filters allow for filtering by DID Method, Key Types and record tags.
DidInformation
objects contain storage metadata (local only) that can be controlled by SDK consumers, allowing custom information to be attached to each DidInformation
. It also allows custom to be leveraged.
Like most data in the wallet, RecordTag
will be stored encrypted. Unless, the tag name is prefixed with ~
, then the tag value will be stored unencrypted. Storing a tag value as unencrypted will allow some additional listing queries to be performed ().
To filter by tags
applied to the DidInformation
(i.e. applied ), the tagFilter
field of ListDidsFilters
should be used. This field takes a String
in compliance with a Query.
Continuing from the example in the :