Manage Credentials
Manage the set of verifiable credentials received and owned by the agent
After accepting and storing a credential from a connection, credentials will be available for management under the agent's CredentialsModule
. Credentials available in this module are ready to be used in Decentralized Identity interactions, such as when presenting credential proofs. The CredentialsModule
provides users with an easy way to fetch, edit and delete credentials in the agent's wallet.
The functionality of the CredentialsModule
is accessed via the agent
's fields: agent.credentials
. The functionality provided is described below.
Get a Credential by ID
Received verifiable credentials are represented by Credential
objects. To retrieve the current state of a specific Credential
in the agent's wallet, the getById
API can be used. If a credential cannot be found by the given identifier, then null
is returned:
Credential Formats
Similar to Credential Exchanges, the Credential
object can represent different credential formats. Credential
contains a formatData
field, which is a CredentialFormatData
data structure with variants for the different supported formats. Currently these format variants include:
AnoncredV1
: Contains details of the Anoncreds Credential thisCredential
represents. Includes the credential attributes and Anoncreds specific metadata.W3C
: Contains details of the W3C Verifiable Credential thisCredential
represents. Includes the completeW3cCredential
data structure as defined by the W3C specification.
Delete a Credential by ID
Similarly, a Credential
in the wallet can be easily deleted via the deleteById
API:
Updating the Metadata of a Credential
Credential
s contain metadata that can be controlled by SDK consumers, allowing custom information to be attached to each Credential
, and allowing custom listing functionality to be leveraged.
Each Credential
contains a list of RecordTag
(Credential.tags
) attached to it, where a RecordTag
is simply a name-value pair stored with the record. By default, some tags are attached to a new Credential
, this includes:
tag-name:
~created_timestamp
, tag-value: The UNIX epoch seconds which this credential was stored
The tags on a Credential
can be replaced or updated by using the updateCredential
API, and providing a new set to update. This will replace whatever the current set of tags is:
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 Pending Credentials
To list all credentials in the agent's wallet, the listAll
API can be used:
Filtered Listing
More complicated Credential
list queries can also be achieved by utilizing the ListCredentialsFilters
.
To filter by tags
applied to the Credential
(i.e. applied via the update API), the tagFilter
field of ListCredentialsFilters
should be used. This field takes a String
in compliance with a Wallet Query Langauge (WQL) Query.
Continuing from the example in the Update section:
Last updated