Refresh Credential
This method allows the refreshing of a specific credential within the SDK.
Future<void> refreshCredential({
required String genesisDid,
required String privateKey,
required ClaimEntity credential,
});
genesisDid
is the unique ID of the identity.privateKey
is the key used to access all the sensitive information from the identity and also to realize operations like generating proofs.credential
is the ClaimEntity object representing the credential to be refreshed.
This method executes a series of complex operations:
- Retrieves the identity associated with the provided genesisDid and privateKey.
- Finds the nonce associated with the credential's subject.
- Validates the presence of the
refreshService
in the credential's information. IfrefreshService
is not found incredential.info
, or if it is null, aRefreshCredentialException
with the message "Refresh service not found" is thrown. This step ensures that the credential has the necessary information to proceed with the refresh process. - Constructs a credential refresh request and obtains an authentication token.
- Sends a request to the refresh service and obtains a new ClaimEntity.
- Removes the old claim if the refresh was successful and the id of the new claim is different from the old one
- Saves the new claim to the repository.