diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/ControllerHelper.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/ControllerHelper.scala index f617bb6657..353967fa9a 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/ControllerHelper.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/ControllerHelper.scala @@ -34,12 +34,11 @@ trait ControllerHelper { } protected def getPairwiseDIDs( - connectionId: String + connectionId: UUID ): ZIO[WalletAccessContext & ConnectionService, ConnectionServiceError, DidIdPair] = { - val lookupId = UUID.fromString(connectionId) for { connectionService <- ZIO.service[ConnectionService] - maybeConnection <- connectionService.getConnectionRecord(lookupId) + maybeConnection <- connectionService.getConnectionRecord(connectionId) didIdPair <- maybeConnection match case Some(connRecord: ConnectionRecord) => extractDidIdPairFromValidConnection(connRecord) match { @@ -47,7 +46,7 @@ trait ControllerHelper { case None => ZIO.fail(ConnectionServiceError.UnexpectedError("Invalid connection record state for operation")) } - case _ => ZIO.fail(ConnectionServiceError.RecordIdNotFound(lookupId)) + case _ => ZIO.fail(ConnectionServiceError.RecordIdNotFound(connectionId)) } yield didIdPair } diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/IssueControllerImpl.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/IssueControllerImpl.scala index 0830806f74..32572456ff 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/IssueControllerImpl.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/IssueControllerImpl.scala @@ -54,8 +54,8 @@ class IssueControllerImpl( for { issuingDID <- ZIO .fromOption(request.issuingDID) - .flatMap(extractPrismDIDFromString) .mapError(_ => ErrorResponse.badRequest(detail = Some("Missing request parameter: issuingDID"))) + .flatMap(extractPrismDIDFromString) _ <- validatePrismDID(issuingDID, allowUnpublished = true) record <- credentialService .createJWTIssueCredentialRecord( diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/http/CreateIssueCredentialRecordRequest.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/http/CreateIssueCredentialRecordRequest.scala index 02656f8e8b..db7bc105c2 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/http/CreateIssueCredentialRecordRequest.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/issue/controller/http/CreateIssueCredentialRecordRequest.scala @@ -50,7 +50,7 @@ final case class CreateIssueCredentialRecordRequest( issuingDID: Option[String], @description(annotations.connectionId.description) @encodedExample(annotations.connectionId.example) - connectionId: String + connectionId: UUID ) object CreateIssueCredentialRecordRequest { @@ -112,10 +112,10 @@ object CreateIssueCredentialRecordRequest { ) object connectionId - extends Annotation[String]( + extends Annotation[UUID]( description = "The unique identifier of a DIDComm connection that already exists between the issuer and the holder, and that will be used to execute the issue credential protocol.", - example = "null" + example = UUID.fromString("d9569cec-c81e-4779-aa86-0d5994d82676") ) } diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofControllerImpl.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofControllerImpl.scala index 9dc6db9ddc..77d478c648 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofControllerImpl.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofControllerImpl.scala @@ -35,7 +35,7 @@ class PresentProofControllerImpl( pairwiseVerifierDID = didIdPair.myDID, pairwiseProverDID = didIdPair.theirDid, thid = DidCommID(), - connectionId = Some(request.connectionId), + connectionId = Some(request.connectionId.toString), proofTypes = request.proofs.map { e => ProofType( schema = e.schemaId, // TODO rename field to schemaId diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofEndpoints.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofEndpoints.scala index a43df18c2c..2f1836ff16 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofEndpoints.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/PresentProofEndpoints.scala @@ -38,7 +38,7 @@ object PresentProofEndpoints { ) ) .out(jsonBody[PresentationStatus]) - .errorOut(basicFailuresAndForbidden) + .errorOut(basicFailureAndNotFoundAndForbidden) val getAllPresentations: Endpoint[ ApiKeyCredentials, diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala index bac163417a..fd146ac010 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala @@ -6,10 +6,12 @@ import sttp.tapir.{Schema, Validator} import sttp.tapir.Schema.annotations.{description, encodedExample} import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} +import java.util.UUID + final case class RequestPresentationInput( @description(annotations.connectionId.description) @encodedExample(annotations.connectionId.example) - connectionId: String, + connectionId: UUID, @description(annotations.options.description) @encodedExample(annotations.options.example) options: Option[Options] = None, @@ -24,9 +26,9 @@ final case class RequestPresentationInput( object RequestPresentationInput { object annotations { object connectionId - extends Annotation[String]( + extends Annotation[UUID]( description = "The unique identifier of an established connection between the verifier and the prover.", - example = "bc528dc8-69f1-4c5a-a508-5f8019047900" + example = UUID.fromString("bc528dc8-69f1-4c5a-a508-5f8019047900") ) object options extends Annotation[Option[Options]]( diff --git a/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala b/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala index 1f516f8b58..20c8f4f545 100644 --- a/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala +++ b/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala @@ -36,6 +36,8 @@ import zio.json.ast.Json import zio.json.ast.Json.* import zio.test.* +import java.util.UUID + trait IssueControllerTestTools extends PostgresTestContainerSupport { self: ZIOSpecDefault => @@ -143,7 +145,7 @@ trait IssueGen { val gValidityPeriod: Gen[Any, Double] = Gen.double val gAutomaticIssuance: Gen[Any, Boolean] = Gen.boolean val gIssuingDID: Gen[Any, String] = Gen.alphaNumericStringBounded(5, 20) // TODO Make a DID generator - val gConnectionId: Gen[Any, String] = Gen.alphaNumericStringBounded(5, 20) + val gConnectionId: Gen[Any, UUID] = Gen.uuid val claims = Json.Obj( "key1" -> Json.Str("value1"),