diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/iam/authentication/oidc/KeycloakAuthenticator.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/iam/authentication/oidc/KeycloakAuthenticator.scala index c692b42b81..29c92ba154 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/iam/authentication/oidc/KeycloakAuthenticator.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/iam/authentication/oidc/KeycloakAuthenticator.scala @@ -7,7 +7,7 @@ import org.hyperledger.identus.iam.authentication.AuthenticationError.{ InvalidCredentials } import org.hyperledger.identus.shared.utils.Traverse.* -import pdi.jwt.{JwtZIOJson, JwtClaim, JwtOptions} +import pdi.jwt.{JwtClaim, JwtOptions, JwtZIOJson} import zio.* import zio.json.ast.Json diff --git a/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationDefinition.scala b/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationDefinition.scala index e6bb34938c..fe801b3eca 100644 --- a/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationDefinition.scala +++ b/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationDefinition.scala @@ -4,7 +4,7 @@ import com.networknt.schema.{JsonSchema, SpecVersion} import org.hyperledger.identus.shared.json.{JsonPath, JsonPathError, JsonSchemaError, JsonSchemaUtils} import zio.* import zio.json.{JsonDecoder, JsonEncoder} -import zio.json.ast.Json as ZioJson +import zio.json.ast.Json opaque type JsonPathValue = String @@ -20,16 +20,16 @@ object JsonPathValue { } } -opaque type FieldFilter = ZioJson +opaque type FieldFilter = Json object FieldFilter { - given Conversion[ZioJson, FieldFilter] = identity + given Conversion[Json, FieldFilter] = identity - given JsonEncoder[FieldFilter] = ZioJson.encoder - given JsonDecoder[FieldFilter] = ZioJson.decoder + given JsonEncoder[FieldFilter] = Json.encoder + given JsonDecoder[FieldFilter] = Json.decoder extension (f: FieldFilter) - def asJsonZio: ZioJson = f + def asJsonZio: Json = f // Json schema draft 7 must be used // https://identity.foundation/presentation-exchange/spec/v2.1.1/#json-schema diff --git a/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationSubmissionVerification.scala b/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationSubmissionVerification.scala index d39e113ca5..63eafb90c7 100644 --- a/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationSubmissionVerification.scala +++ b/pollux/prex/src/main/scala/org/hyperledger/identus/pollux/prex/PresentationSubmissionVerification.scala @@ -5,7 +5,7 @@ import org.hyperledger.identus.pollux.vc.jwt.{JWT, JwtCredential, JwtPresentatio import org.hyperledger.identus.shared.json.{JsonPathError, JsonSchemaValidatorImpl} import org.hyperledger.identus.shared.models.{Failure, StatusCode} import zio.* -import zio.json.ast.Json as ZioJson +import zio.json.ast.Json import zio.json.EncoderOps sealed trait PresentationSubmissionError extends Failure { @@ -81,7 +81,7 @@ object PresentationSubmissionVerification { def verify( pd: PresentationDefinition, ps: PresentationSubmission, - rootTraversalObject: ZioJson, + rootTraversalObject: Json, )(formatVerification: ClaimFormatVerification): IO[PresentationSubmissionError, Unit] = { for { _ <- verifySubmissionId(pd, ps) @@ -118,7 +118,7 @@ object PresentationSubmissionVerification { private def verifyInputConstraints( pd: PresentationDefinition, - entries: Seq[(String, ZioJson)] + entries: Seq[(String, Json)] ): IO[PresentationSubmissionError, Unit] = { val descriptorLookup = pd.input_descriptors.map(d => d.id -> d).toMap val descriptorWithEntry = entries.flatMap { case (id, entry) => descriptorLookup.get(id).map(_ -> entry) } @@ -131,7 +131,7 @@ object PresentationSubmissionVerification { private def verifyInputConstraint( descriptor: InputDescriptor, - entry: ZioJson + entry: Json ): IO[PresentationSubmissionError, Unit] = { val mandatoryFields = descriptor.constraints.fields .getOrElse(Nil) @@ -156,9 +156,9 @@ object PresentationSubmissionVerification { } private def extractSubmissionEntry( - traversalObject: ZioJson, + traversalObject: Json, descriptor: InputDescriptorMapping - )(formatVerification: ClaimFormatVerification): IO[PresentationSubmissionError, ZioJson] = { + )(formatVerification: ClaimFormatVerification): IO[PresentationSubmissionError, Json] = { for { path <- ZIO .fromEither(descriptor.path.toJsonPath) @@ -179,9 +179,9 @@ object PresentationSubmissionVerification { } private def verifyJwtVc( - json: ZioJson, + json: Json, path: JsonPathValue - )(formatVerification: JWT => IO[String, Unit]): IO[PresentationSubmissionError, ZioJson] = { + )(formatVerification: JWT => IO[String, Unit]): IO[PresentationSubmissionError, Json] = { val format = ClaimFormatValue.jwt_vc for { jwt <- ZIO @@ -197,9 +197,9 @@ object PresentationSubmissionVerification { } private def verifyJwtVp( - json: ZioJson, + json: Json, path: JsonPathValue - )(formatVerification: JWT => IO[String, Unit]): IO[PresentationSubmissionError, ZioJson] = { + )(formatVerification: JWT => IO[String, Unit]): IO[PresentationSubmissionError, Json] = { val format = ClaimFormatValue.jwt_vp for { jwt <- ZIO diff --git a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala index f1358b9154..1d21906ab5 100644 --- a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala +++ b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/DidJWT.scala @@ -9,7 +9,7 @@ import org.hyperledger.identus.shared.crypto.{Ed25519KeyPair, Secp256k1PrivateKe import org.hyperledger.identus.shared.models.KeyId import zio.* import zio.json.{EncoderOps, JsonDecoder, JsonEncoder} -import zio.json.ast.Json as ZioJson +import zio.json.ast.Json import java.security.* import java.security.interfaces.ECPublicKey @@ -41,9 +41,9 @@ object JwtSignerImplicits { } trait Signer { - def encode(claim: ZioJson): JWT + def encode(claim: Json): JWT - def generateProofForJson(payload: ZioJson, pk: PublicKey): Task[Proof] + def generateProofForJson(payload: Json, pk: PublicKey): Task[Proof] } // works with java 7, 8, 11 & bouncycastle provider @@ -56,7 +56,7 @@ class ES256KSigner(privateKey: PrivateKey, keyId: Option[KeyId] = None) extends ecdsaSigner } - override def generateProofForJson(payload: ZioJson, pk: PublicKey): Task[Proof] = { + override def generateProofForJson(payload: Json, pk: PublicKey): Task[Proof] = { val err = Throwable("Public key must be secp256k1 EC public key") pk match case pk: ECPublicKey => @@ -64,7 +64,7 @@ class ES256KSigner(privateKey: PrivateKey, keyId: Option[KeyId] = None) extends case _ => ZIO.fail(err) } - override def encode(claim: ZioJson): JWT = { + override def encode(claim: Json): JWT = { val claimSet = JWTClaimsSet.parse(claim.toJson) val signedJwt = SignedJWT( keyId @@ -84,11 +84,11 @@ class EdSigner(ed25519KeyPair: Ed25519KeyPair, keyId: Option[KeyId] = None) exte ed25519Signer } - override def generateProofForJson(payload: ZioJson, pk: PublicKey): Task[Proof] = { + override def generateProofForJson(payload: Json, pk: PublicKey): Task[Proof] = { EddsaJcs2022ProofGenerator.generateProof(payload, ed25519KeyPair) } - override def encode(claim: ZioJson): JWT = { + override def encode(claim: Json): JWT = { val claimSet = JWTClaimsSet.parse(claim.toJson) val signedJwt = SignedJWT( diff --git a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/JsonWebKey.scala b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/JsonWebKey.scala index c5ed29a591..6f839e29bc 100644 --- a/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/JsonWebKey.scala +++ b/pollux/vc-jwt/src/main/scala/org/hyperledger/identus/pollux/vc/jwt/JsonWebKey.scala @@ -18,6 +18,6 @@ case class JsonWebKey( ) object JsonWebKey { - given jsonWebKeyEncoderCirceZioJson: JsonEncoder[JsonWebKey] = DeriveJsonEncoder.gen - given jsonWebKeyDecoderCirceZioJson: JsonDecoder[JsonWebKey] = DeriveJsonDecoder.gen + given JsonEncoder[JsonWebKey] = DeriveJsonEncoder.gen + given JsonDecoder[JsonWebKey] = DeriveJsonDecoder.gen } diff --git a/shared/json/src/main/scala/org/hyperledger/identus/shared/json/JsonOps.scala b/shared/json/src/main/scala/org/hyperledger/identus/shared/json/JsonOps.scala index 27aa34fcaf..5e70affd0f 100644 --- a/shared/json/src/main/scala/org/hyperledger/identus/shared/json/JsonOps.scala +++ b/shared/json/src/main/scala/org/hyperledger/identus/shared/json/JsonOps.scala @@ -1,21 +1,21 @@ package org.hyperledger.identus.shared.json -import zio.json.ast.Json as ZioJson +import zio.json.ast.Json object JsonOps { - extension (json: ZioJson) { - def removeNullValues: ZioJson = json match - case ZioJson.Obj(fields) => - ZioJson.Obj(fields.collect { case (key, value) if value != ZioJson.Null => key -> value.removeNullValues }) - case ZioJson.Arr(elements) => - ZioJson.Arr(elements.map(_.removeNullValues)) + extension (json: Json) { + def removeNullValues: Json = json match + case Json.Obj(fields) => + Json.Obj(fields.collect { case (key, value) if value != Json.Null => key -> value.removeNullValues }) + case Json.Arr(elements) => + Json.Arr(elements.map(_.removeNullValues)) case other => other - def removeField(name: String): ZioJson = json match - case ZioJson.Obj(fields) => - ZioJson.Obj(fields.filterNot { case (key, value) => key == name }) - case ZioJson.Arr(elements) => - ZioJson.Arr(elements.map(_.removeField(name))) + def removeField(name: String): Json = json match + case Json.Obj(fields) => + Json.Obj(fields.filterNot { case (key, value) => key == name }) + case Json.Arr(elements) => + Json.Arr(elements.map(_.removeField(name))) case other => other } }