openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
262 stars 199 forks source link

feature: Actively check revocation status of anoncreds credential #1863

Open icc-romeu opened 4 months ago

icc-romeu commented 4 months ago

Hi,

I was wondering whether there is some way of getting the revocation status of an Indy credential. I saw there is a revocationNotification in the CredentialExchangeRecord attributes but, is there an option to actively check whether a credential has been revoked?

GHkrishna commented 3 months ago

Maybe this can be helpful, having an observable event

TimoGlastra commented 3 months ago

Hey @icc-romeu,

Sorry for the late reply, i missed your issue.

What you can do is get the credential, extract the revocationRegistryId and fetch the status list (using anoncreds api), then look up the index of the credential (revocationIndex i think) in the status list.

We could also add a convenience method for this

icc-romeu commented 3 months ago

Thx for the reply @TimoGlastra. Because if you miss the revocation notification, credential seems to be ok, but it's not.

I think it would be awesome to create a convenience method for it. In the meantime, I will do as suggested.

icc-romeu commented 3 months ago

For the sake of completion, just in case someone wants to do the same, this is what I am doing. Not 100% sure it is ok but it works on my side for Anoncreds:

      const credential = await agent.credentials.getById(id);

      const meta: Metadata<AnonCredsCredentialMetadata> = credential.metadata;
      const rev = meta.data['_anoncreds/credential'];
      const revocationRegistryId = rev.revocationRegistryId;
      const credentialRevocationId = rev.credentialRevocationId;

      const revocationStatus = await fetchRevocationStatusList(
        agent.context,
        revocationRegistryId,
        dayjs().unix(),
      );
TimoGlastra commented 3 months ago

Thanks for the example, I've reopened the issue as a feature request so we can add a method to the AnonCredsApi