Manage DIDs
Manage the DIDs which are owned by the Edge Agent for usage in DI protocols
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
.
Create 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:
See the Standards and Protocols section for a list of DID methods supported for creation by the Edge Agent SDK.
Get full DID Information by ID
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:
Delete a DID
Similarly, a DID in the wallet can be easily deleted via the deleteById
API:
Updating the Storage Metadata of a DID
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 listing functionality to be leveraged.
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:
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 (see below).
Listing DIDs
To list all DIDs owned by the agent, the listAll
API can be used:
Filtered Listing
More complicated DidInformation
list queries can also be achieved by utilizing the ListDidsFilters
filter.
To filter by tags
applied to the DidInformation
(i.e. applied via the update API), the tagFilter
field of ListDidsFilters
should be used. This field takes a String
in compliance with a Wallet Query Language (WQL) Query.
Continuing from the example in the Update section:
Last updated