Skip to content

Commit

Permalink
fix(prism-agent): fix credential schema parsing as spec (#841)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Voiturier <[email protected]>
  • Loading branch information
bvoiturier authored and CryptoKnightIOG committed Feb 9, 2024
1 parent 8263b59 commit b4ef6da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import io.iohk.atala.mercury.protocol.issuecredential.IssueCredentialIssuedForma
import io.iohk.atala.mercury.protocol.presentproof.*
import io.iohk.atala.pollux.anoncreds.*
import io.iohk.atala.pollux.core.model.*
import io.iohk.atala.pollux.core.model.error.CredentialSchemaError.CredentialSchemaParsingError
import io.iohk.atala.pollux.core.model.error.PresentationError
import io.iohk.atala.pollux.core.model.error.PresentationError.*
import io.iohk.atala.pollux.core.model.presentation.*
import io.iohk.atala.pollux.core.model.schema.CredentialDefinition
import io.iohk.atala.pollux.core.model.schema.CredentialSchema.parseCredentialSchema
import io.iohk.atala.pollux.core.model.schema.`type`.anoncred.AnoncredSchemaSerDesV1
import io.iohk.atala.pollux.core.repository.{CredentialRepository, PresentationRepository}
import io.iohk.atala.pollux.core.service.serdes.{
Expand All @@ -27,6 +27,7 @@ import io.iohk.atala.pollux.vc.jwt.*
import io.iohk.atala.shared.models.WalletAccessContext
import io.iohk.atala.shared.utils.aspects.CustomMetricsAspect
import zio.{ZIO, *}
import zio.json.*

import java.net.URI
import java.rmi.UnexpectedException
Expand Down Expand Up @@ -596,10 +597,9 @@ private class PresentationServiceImpl(
for {
uri <- ZIO.attempt(new URI(schemaId)).mapError(e => UnexpectedError(e.getMessage))
content <- uriDereferencer.dereference(uri).mapError(e => UnexpectedError(e.error))
vcSchema <- parseCredentialSchema(content).mapError(e => UnexpectedError(e.message))
anoncredSchema <- AnoncredSchemaSerDesV1.schemaSerDes
.deserialize(vcSchema.schema)
.mapError(e => UnexpectedError(e.error))
anoncredSchema <- ZIO
.fromEither(content.fromJson[AnoncredSchemaSerDesV1])
.mapError(error => UnexpectedError(s"AnonCreds Schema parsing error: $error"))
anoncredLibSchema =
AnoncredSchemaDef(
schemaId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
{
"guid": "1631026d-5d55-3285-8ccd-bd70480cfbdc",
"id": "329da384-b2bb-497f-a605-4118dec75d31",
"longId": "did:prism:4a5b5cf0a513e83b598bbea25cd6196746747f361a73ef77068268bc9bd732ff/329da384-b2bb-497f-a605-4118dec75d31?version=5.0.0",
"name": "DrivingLicense",
"version": "5.0.0",
"tags": [
"string"
"name": "resource:///anoncred-presentation-schema-example.json",
"version": "1.0",
"attrNames": [
"name",
"sex",
"age"
],
"description": "Simple credential schema for the driving licence verifiable credential.",
"type": "AnoncredSchemaV1",
"schema": {
"name": "resource:///anoncred-presentation-schema-example.json",
"version": "1.0",
"attrNames": [
"name",
"sex",
"age"
],
"issuerId": "did:prism:issuer"
},
"author": "did:prism:4a5b5cf0a513e83b598bbea25cd6196746747f361a73ef77068268bc9bd732ff",
"authored": "2023-04-06T08:48:01.654162Z",
"kind": "CredentialSchema",
"self": "/schema-registry/schemas/1631026d-5d55-3285-8ccd-bd70480cfbdc"
}
"issuerId": "did:prism:issuer"
}

0 comments on commit b4ef6da

Please sign in to comment.