-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wadeking98 <[email protected]>
- Loading branch information
1 parent
237e1a3
commit 80a8e9e
Showing
2 changed files
with
136 additions
and
18 deletions.
There are no files selected for viewing
150 changes: 134 additions & 16 deletions
150
.yarn/patches/@aries-framework-anoncreds-npm-0.4.0-4d3b4e769d.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters