diff --git a/.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch b/.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch index 842c4da7..cd1f9e68 100644 --- a/.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch +++ b/.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch @@ -1,18 +1,136 @@ -diff --git a/build/utils/revocationInterval.js b/build/utils/revocationInterval.js -index 728732d5119b879a2a2399eab6e6430b62796106..5c69ea0731c0fbdc0ff4820891d67773c7105b3b 100644 ---- a/build/utils/revocationInterval.js -+++ b/build/utils/revocationInterval.js -@@ -7,9 +7,9 @@ function assertBestPracticeRevocationInterval(revocationInterval) { - if (!revocationInterval.to) { - throw new core_1.AriesFrameworkError(`Presentation requests proof of non-revocation with no 'to' value specified`); +diff --git a/build/utils/getRevocationRegistries.js b/build/utils/getRevocationRegistries.js +index 659e85e5d206ae9ba291383325403f922b2e9e1d..db94b7312fc764bfad51ebe8344b2cabb9c91c50 100644 +--- a/build/utils/getRevocationRegistries.js ++++ b/build/utils/getRevocationRegistries.js +@@ -33,6 +33,7 @@ async function getRevocationRegistriesForRequest(agentContext, proofRequest, sel + nonRevoked: (_b = proofRequest.requested_predicates[referent].non_revoked) !== null && _b !== void 0 ? _b : proofRequest.non_revoked, + }); + } ++ const revocationRegistryPromises = [] + for (const { referent, selectedCredential, nonRevoked, type } of referentCredentials) { + if (!selectedCredential.credentialInfo) { + throw new core_1.AriesFrameworkError(`Credential for referent '${referent} does not have credential info for revocation state creation`); +@@ -55,38 +56,42 @@ async function getRevocationRegistriesForRequest(agentContext, proofRequest, sel + .resolve(services_1.AnonCredsRegistryService) + .getRegistryForIdentifier(agentContext, revocationRegistryId); + // Fetch revocation registry definition if not in revocation registries list yet +- if (!revocationRegistries[revocationRegistryId]) { +- const { revocationRegistryDefinition, resolutionMetadata } = await registry.getRevocationRegistryDefinition(agentContext, revocationRegistryId); +- if (!revocationRegistryDefinition) { +- throw new core_1.AriesFrameworkError(`Could not retrieve revocation registry definition for revocation registry ${revocationRegistryId}: ${resolutionMetadata.message}`); ++ revocationRegistryPromises.push((async () => { ++ if (!revocationRegistries[revocationRegistryId]) { ++ const { revocationRegistryDefinition, resolutionMetadata } = await registry.getRevocationRegistryDefinition(agentContext, revocationRegistryId); ++ if (!revocationRegistryDefinition) { ++ throw new core_1.AriesFrameworkError(`Could not retrieve revocation registry definition for revocation registry ${revocationRegistryId}: ${resolutionMetadata.message}`); ++ } ++ const { tailsLocation, tailsHash } = revocationRegistryDefinition.value; ++ const { tailsFilePath } = await (0, tails_1.downloadTailsFile)(agentContext, tailsLocation, tailsHash); ++ // const tails = await this.indyUtilitiesService.downloadTails(tailsHash, tailsLocation) ++ revocationRegistries[revocationRegistryId] = { ++ definition: revocationRegistryDefinition, ++ tailsFilePath, ++ revocationStatusLists: {}, ++ }; + } +- const { tailsLocation, tailsHash } = revocationRegistryDefinition.value; +- const { tailsFilePath } = await (0, tails_1.downloadTailsFile)(agentContext, tailsLocation, tailsHash); +- // const tails = await this.indyUtilitiesService.downloadTails(tailsHash, tailsLocation) +- revocationRegistries[revocationRegistryId] = { +- definition: revocationRegistryDefinition, +- tailsFilePath, +- revocationStatusLists: {}, +- }; +- } +- // In most cases we will have a timestamp, but if it's not defined, we use the nonRevoked.to value +- const timestampToFetch = timestamp !== null && timestamp !== void 0 ? timestamp : nonRevoked.to; +- // Fetch revocation status list if we don't already have a revocation status list for the given timestamp +- if (!revocationRegistries[revocationRegistryId].revocationStatusLists[timestampToFetch]) { +- const { revocationStatusList, resolutionMetadata: statusListResolutionMetadata } = await registry.getRevocationStatusList(agentContext, revocationRegistryId, timestampToFetch); +- if (!revocationStatusList) { +- throw new core_1.AriesFrameworkError(`Could not retrieve revocation status list for revocation registry ${revocationRegistryId}: ${statusListResolutionMetadata.message}`); +- } +- revocationRegistries[revocationRegistryId].revocationStatusLists[revocationStatusList.timestamp] = +- revocationStatusList; +- // If we don't have a timestamp on the selected credential, we set it to the timestamp of the revocation status list +- // this way we know which revocation status list to use when creating the proof. +- if (!timestamp) { +- updatedSelectedCredentials = Object.assign(Object.assign({}, updatedSelectedCredentials), { [type]: Object.assign(Object.assign({}, updatedSelectedCredentials[type]), { [referent]: Object.assign(Object.assign({}, updatedSelectedCredentials[type][referent]), { timestamp: revocationStatusList.timestamp }) }) }); ++ // In most cases we will have a timestamp, but if it's not defined, we use the nonRevoked.to value ++ const timestampToFetch = timestamp !== null && timestamp !== void 0 ? timestamp : nonRevoked.to; ++ // Fetch revocation status list if we don't already have a revocation status list for the given timestamp ++ if (!revocationRegistries[revocationRegistryId].revocationStatusLists[timestampToFetch]) { ++ const { revocationStatusList, resolutionMetadata: statusListResolutionMetadata } = await registry.getRevocationStatusList(agentContext, revocationRegistryId, timestampToFetch); ++ if (!revocationStatusList) { ++ throw new core_1.AriesFrameworkError(`Could not retrieve revocation status list for revocation registry ${revocationRegistryId}: ${statusListResolutionMetadata.message}`); ++ } ++ revocationRegistries[revocationRegistryId].revocationStatusLists[revocationStatusList.timestamp] = ++ revocationStatusList; ++ // If we don't have a timestamp on the selected credential, we set it to the timestamp of the revocation status list ++ // this way we know which revocation status list to use when creating the proof. ++ if (!timestamp) { ++ updatedSelectedCredentials = Object.assign(Object.assign({}, updatedSelectedCredentials), { [type]: Object.assign(Object.assign({}, updatedSelectedCredentials[type]), { [referent]: Object.assign(Object.assign({}, updatedSelectedCredentials[type][referent]), { timestamp: revocationStatusList.timestamp }) }) }); ++ } + } +- } ++ })()) + } + } ++ // await all revocation registry statuses asynchronously ++ await Promise.all(revocationRegistryPromises) + agentContext.config.logger.debug(`Retrieved revocation registries for proof request`, { + revocationRegistries, + }); +@@ -104,6 +109,7 @@ async function getRevocationRegistriesForRequest(agentContext, proofRequest, sel + exports.getRevocationRegistriesForRequest = getRevocationRegistriesForRequest; + async function getRevocationRegistriesForProof(agentContext, proof) { + const revocationRegistries = {}; ++ const revocationRegistryPromises = []; + for (const identifier of proof.identifiers) { + const revocationRegistryId = identifier.rev_reg_id; + const timestamp = identifier.timestamp; +@@ -114,25 +120,28 @@ async function getRevocationRegistriesForProof(agentContext, proof) { + .resolve(services_1.AnonCredsRegistryService) + .getRegistryForIdentifier(agentContext, revocationRegistryId); + // Fetch revocation registry definition if not already fetched +- if (!revocationRegistries[revocationRegistryId]) { +- const { revocationRegistryDefinition, resolutionMetadata } = await registry.getRevocationRegistryDefinition(agentContext, revocationRegistryId); +- if (!revocationRegistryDefinition) { +- throw new core_1.AriesFrameworkError(`Could not retrieve revocation registry definition for revocation registry ${revocationRegistryId}: ${resolutionMetadata.message}`); ++ revocationRegistryPromises.push((async () => { ++ if (!revocationRegistries[revocationRegistryId]) { ++ const { revocationRegistryDefinition, resolutionMetadata } = await registry.getRevocationRegistryDefinition(agentContext, revocationRegistryId); ++ if (!revocationRegistryDefinition) { ++ throw new core_1.AriesFrameworkError(`Could not retrieve revocation registry definition for revocation registry ${revocationRegistryId}: ${resolutionMetadata.message}`); ++ } ++ revocationRegistries[revocationRegistryId] = { ++ definition: revocationRegistryDefinition, ++ revocationStatusLists: {}, ++ }; + } +- revocationRegistries[revocationRegistryId] = { +- definition: revocationRegistryDefinition, +- revocationStatusLists: {}, +- }; +- } +- // Fetch revocation status list by timestamp if not already fetched +- if (!revocationRegistries[revocationRegistryId].revocationStatusLists[timestamp]) { +- const { revocationStatusList, resolutionMetadata: statusListResolutionMetadata } = await registry.getRevocationStatusList(agentContext, revocationRegistryId, timestamp); +- if (!revocationStatusList) { +- throw new core_1.AriesFrameworkError(`Could not retrieve revocation status list for revocation registry ${revocationRegistryId}: ${statusListResolutionMetadata.message}`); ++ // Fetch revocation status list by timestamp if not already fetched ++ if (!revocationRegistries[revocationRegistryId].revocationStatusLists[timestamp]) { ++ const { revocationStatusList, resolutionMetadata: statusListResolutionMetadata } = await registry.getRevocationStatusList(agentContext, revocationRegistryId, timestamp); ++ if (!revocationStatusList) { ++ throw new core_1.AriesFrameworkError(`Could not retrieve revocation status list for revocation registry ${revocationRegistryId}: ${statusListResolutionMetadata.message}`); ++ } ++ revocationRegistries[revocationRegistryId].revocationStatusLists[timestamp] = revocationStatusList; + } +- revocationRegistries[revocationRegistryId].revocationStatusLists[timestamp] = revocationStatusList; +- } ++ })()) } -- if ((revocationInterval.from || revocationInterval.from === 0) && revocationInterval.to !== revocationInterval.from) { -- throw new core_1.AriesFrameworkError(`Presentation requests proof of non-revocation with an interval from: '${revocationInterval.from}' that does not match the interval to: '${revocationInterval.to}', as specified in Aries RFC 0441`); -- } -+ // if ((revocationInterval.from || revocationInterval.from === 0) && revocationInterval.to !== revocationInterval.from) { -+ // throw new core_1.AriesFrameworkError(`Presentation requests proof of non-revocation with an interval from: '${revocationInterval.from}' that does not match the interval to: '${revocationInterval.to}', as specified in Aries RFC 0441`); -+ // } ++ await Promise.all(revocationRegistryPromises) + return revocationRegistries; } - exports.assertBestPracticeRevocationInterval = assertBestPracticeRevocationInterval; - //# sourceMappingURL=revocationInterval.js.map -\ No newline at end of file + exports.getRevocationRegistriesForProof = getRevocationRegistriesForProof; diff --git a/yarn.lock b/yarn.lock index 5ea430d4..0270e78d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -53,14 +53,14 @@ __metadata: "@aries-framework/anoncreds@patch:@aries-framework/anoncreds@npm%3A0.4.0#./.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch::locator=bc-wallet-mobile%40workspace%3A.": version: 0.4.0 - resolution: "@aries-framework/anoncreds@patch:@aries-framework/anoncreds@npm%3A0.4.0#./.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch::version=0.4.0&hash=effd16&locator=bc-wallet-mobile%40workspace%3A." + resolution: "@aries-framework/anoncreds@patch:@aries-framework/anoncreds@npm%3A0.4.0#./.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch::version=0.4.0&hash=e11ca4&locator=bc-wallet-mobile%40workspace%3A." dependencies: "@aries-framework/core": 0.4.0 bn.js: ^5.2.1 class-transformer: 0.5.1 class-validator: 0.14.0 reflect-metadata: ^0.1.13 - checksum: 7f4d2e15f86ce64a402c65436f05d9a9a66e7b8dcaf50b9206985f8e5a4544ca1a4a1bbda0a6c953fc683859e2ba270464ece54b0f323fc6c10498cadc67f610 + checksum: c289ae8d2766620f1970d8891c322e8e8ed8f168b513391b67be48e920009c92a90466c401aaf7105eed4bb66dfbdadd17cbc046f0b58500b49199be67625bdd languageName: node linkType: hard