openwallet-foundation / credo-ts

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

AnonCreds which use schemas from other issuer are wrongly stored #1935

Closed icc-romeu closed 2 weeks ago

icc-romeu commented 2 weeks ago

We are using credentials from different issuers but all of them share the same schema. At some point, the indy-vdr is assuming that the DID of the credential definition should be the same as the schema definition, which is not true.

I got the real DID for the schema from the request to the VDR.

Here is the diff that solved my problem:

diff --git a/node_modules/@credo-ts/indy-vdr/build/anoncreds/IndyVdrAnonCredsRegistry.js b/node_modules/@credo-ts/indy-vdr/build/anoncreds/IndyVdrAnonCredsRegistry.js
index 30ded2c..ce29344 100644
--- a/node_modules/@credo-ts/indy-vdr/build/anoncreds/IndyVdrAnonCredsRegistry.js
+++ b/node_modules/@credo-ts/indy-vdr/build/anoncreds/IndyVdrAnonCredsRegistry.js
@@ -637,14 +637,15 @@ class IndyVdrAnonCredsRegistry {
             return null;
         }
         const schema = (_b = response.result.data) === null || _b === void 0 ? void 0 : _b.txn.data;
-        const schemaId = (0, anoncreds_1.getUnqualifiedSchemaId)(did, schema.data.name, schema.data.version);
+        const customDID = _b.txn.metadata.from || did
+        const schemaId = (0, anoncreds_1.getUnqualifiedSchemaId)(customDID, schema.data.name, schema.data.version);
         return {
             schema: {
                 schemaId,
                 attr_name: schema.data.attr_names,
                 name: schema.data.name,
                 version: schema.data.version,
-                issuerId: did,
+                issuerId: customDID,
                 seqNo,
             },
             indyNamespace: pool.indyNamespace,
TimoGlastra commented 2 weeks ago

Which version are you on? I think this was recently solved: https://github.com/openwallet-foundation/credo-ts/commit/000f97853f1338344da9d43654ec63c1ed0b1840

icc-romeu commented 2 weeks ago

Ups! You are right. 0.5.3... We didn't want to update just in case there are breaking changes. But we will probably do. Thx