Skip to content

Commit

Permalink
fix(prism-agent): fallback to OEA proprietary format for JWT VC schem…
Browse files Browse the repository at this point in the history
…a when spec-format parsing fails

Signed-off-by: Benjamin Voiturier <benjamin.voiturier@iohk.io>
  • Loading branch information
bvoiturier committed Jan 12, 2024
1 parent 22e3f8d commit fb1592d
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,19 @@ object CredentialSchema {
for {
uri <- ZIO.attempt(new URI(schemaId)).mapError(t => URISyntaxError(t.getMessage))
content <- uriDereferencer.dereference(uri).mapError(err => UnexpectedError(err.toString))
jsonSchema <- ZIO
json <- ZIO
.fromEither(content.fromJson[Json])
.mapError(error => CredentialSchemaError.CredentialSchemaParsingError(s"Json Schema parsing error: $error"))
schemaValidator <- JsonSchemaValidatorImpl.from(jsonSchema).mapError(SchemaError.apply)
.mapError(error =>
CredentialSchemaError.CredentialSchemaParsingError(s"Failed to parse resolved schema content as Json: $error")
)
schemaValidator <- JsonSchemaValidatorImpl
.from(json)
.orElse(
ZIO
.fromEither(json.as[CredentialSchema])
.mapError(error => CredentialSchemaParsingError(s"Failed to parse schema content as Json or OEA: $error"))
.flatMap(cs => JsonSchemaValidatorImpl.from(cs.schema).mapError(SchemaError.apply))
)
_ <- schemaValidator.validate(claims).mapError(SchemaError.apply)
} yield ()
}
Expand Down

0 comments on commit fb1592d

Please sign in to comment.