Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anoncreds-rs): revocation status list as JSON #1422

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AgentContext } from '@aries-framework/core'
import type { JsonObject } from '@hyperledger/anoncreds-shared'

import { injectable } from '@aries-framework/core'
import { Presentation, RevocationRegistryDefinition, RevocationStatusList } from '@hyperledger/anoncreds-shared'
import { Presentation } from '@hyperledger/anoncreds-shared'

@injectable()
export class AnonCredsRsVerifierService implements AnonCredsVerifierService {
Expand All @@ -24,27 +24,15 @@ export class AnonCredsRsVerifierService implements AnonCredsVerifierService {
rsSchemas[schemaId] = schemas[schemaId] as unknown as JsonObject
}

const revocationRegistryDefinitions: Record<string, RevocationRegistryDefinition> = {}
const lists = []
const revocationRegistryDefinitions: Record<string, JsonObject> = {}
const lists: JsonObject[] = []

for (const revocationRegistryDefinitionId in revocationRegistries) {
const { definition, revocationStatusLists } = options.revocationRegistries[revocationRegistryDefinitionId]

revocationRegistryDefinitions[revocationRegistryDefinitionId] = RevocationRegistryDefinition.fromJson(
definition as unknown as JsonObject
)

for (const timestamp in revocationStatusLists) {
lists.push(
RevocationStatusList.create({
issuerId: definition.issuerId,
issuanceByDefault: true,
revocationRegistryDefinition: revocationRegistryDefinitions[revocationRegistryDefinitionId],
revocationRegistryDefinitionId,
timestamp: Number(timestamp),
})
)
}
revocationRegistryDefinitions[revocationRegistryDefinitionId] = definition as unknown as JsonObject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can improve the casting? If we do as unknown as... it is very close to just using any and should be avoided whenever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree, it's something we are still missing in anoncreds-rs JS API. I think we'll need to complete AnonCreds object modeling in AFJ and replicate it in anoncreds-rs javascript wrapper so they match.


lists.push(...(Object.values(revocationStatusLists) as unknown as Array<JsonObject>))
}

return presentation.verify({
Expand Down