diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/AnoncredControllerImpl.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/AnoncredControllerImpl.scala index ccc08b72b3..eb2ec46868 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/AnoncredControllerImpl.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/AnoncredControllerImpl.scala @@ -23,28 +23,7 @@ class AnoncredControllerImpl( with ControllerHelper { override def createCredentialOffer( request: CreateAnoncredRecordRequest - )(implicit rc: RequestContext): IO[ErrorResponse, AnoncredRecord] = { - val result: IO[ConnectionServiceError | CredentialServiceError | ErrorResponse, AnoncredRecord] = for { - didIdPair <- getPairwiseDIDs(request.connectionId).provide(ZLayer.succeed(connectionService)) - issuingDID <- extractPrismDIDFromString(request.issuingDID) - jsonClaims <- ZIO - .fromEither(io.circe.parser.parse(request.claims.toString())) - .mapError(e => ErrorResponse.badRequest(detail = Some(e.getMessage))) - outcome <- credentialService - .createIssueCredentialRecord( // .createAnoncredRecord( FIXME - pairwiseIssuerDID = didIdPair.myDID, - pairwiseHolderDID = didIdPair.theirDid, - thid = DidCommID(), - maybeSchemaId = request.schemaId, - claims = jsonClaims, - validityPeriod = request.validityPeriod, - automaticIssuance = request.automaticIssuance.orElse(Some(true)), - awaitConfirmation = Some(false), - issuingDID = Some(issuingDID.asCanonical) - ) - } yield AnoncredRecord.fromDomain(outcome) - mapIssueErrors(result) - } + )(implicit rc: RequestContext): IO[ErrorResponse, AnoncredRecord] = ??? override def getCredentialRecords(paginationInput: PaginationInput, thid: Option[String])(implicit rc: RequestContext diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/AnoncredRecord.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/AnoncredRecord.scala index 268d85b91b..d23cc6256d 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/AnoncredRecord.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/AnoncredRecord.scala @@ -13,7 +13,7 @@ import zio.json.ast.Json import java.nio.charset.StandardCharsets import java.time.{OffsetDateTime, ZoneOffset} -/** A class to represent an an outgoing response for a created credential offer. +/** A class to represent an outgoing response for a created credential offer. * * @param subjectId * The identifier (e.g DID) of the subject to which the verifiable credential will be issued. for example: diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/CreateAnoncredRecordRequest.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/CreateAnoncredRecordRequest.scala index bf51d4b25b..275036f81f 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/CreateAnoncredRecordRequest.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/anoncred/controller/http/CreateAnoncredRecordRequest.scala @@ -1,60 +1,51 @@ package io.iohk.atala.anoncred.controller.http -import io.iohk.atala.api.http.Annotation import io.iohk.atala.anoncred.controller.http.CreateAnoncredRecordRequest.annotations +import io.iohk.atala.api.http.Annotation import sttp.tapir.Schema -import sttp.tapir.Schema.annotations.{description, encodedExample} +import sttp.tapir.Schema.annotations.description +import sttp.tapir.Schema.annotations.encodedExample import sttp.tapir.json.zio.schemaForZioJsonValue -import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} +import zio.json.DeriveJsonDecoder +import zio.json.DeriveJsonEncoder +import zio.json.JsonDecoder +import zio.json.JsonEncoder /** A class to represent an incoming request to create a new credential offer. * - * @param validityPeriod - * The validity period in seconds of the verifiable credential that will be issued. for example: ''3600'' - * @param claims - * The claims that will be associated with the issued verifiable credential. for example: ''null'' - * @param automaticIssuance - * Specifies whether or not the credential should be automatically generated and issued when receiving the - * `CredentialRequest` from the holder. If set to `false`, a manual approval by the issuer via API call will be - * required for the VC to be issued. for example: ''null'' - * - * @param issuingDID - * The issuer DID of the verifiable credential object. for example: ''did:prism:issuerofverifiablecredentials'' - * @param connectionId - * 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. for example: ''null'' + * @param schemaId + * The unique identifier of the schema used for this credential offer + * @param credDefId + * The unique identifier of the schema used for this credential credDefId + * @param credentialKeyCorrectnessProof + * TODO: FIX ME + * @param methodName + * TODO: FIX ME + * @param nonce + * TODO: FIX ME */ final case class CreateAnoncredRecordRequest( - @description(annotations.validityPeriod.description) - @encodedExample(annotations.validityPeriod.example) - validityPeriod: Option[Double] = None, @description(annotations.schemaId.description) @encodedExample(annotations.schemaId.example) schemaId: Option[String], - @description(annotations.claims.description) - @encodedExample(annotations.claims.example) - claims: zio.json.ast.Json, - @description(annotations.automaticIssuance.description) - @encodedExample(annotations.automaticIssuance.example) - automaticIssuance: Option[Boolean] = None, - @description(annotations.issuingDID.description) - @encodedExample(annotations.issuingDID.example) - issuingDID: String, - @description(annotations.connectionId.description) - @encodedExample(annotations.connectionId.example) - connectionId: String + @description(annotations.credDefId.description) + @encodedExample(annotations.credDefId.example) + credDefId: Option[String], + @description(annotations.credentialKeyCorrectnessProof.description) + @encodedExample(annotations.credentialKeyCorrectnessProof.example) + credentialKeyCorrectnessProof: zio.json.ast.Json, + @description(annotations.nonce.description) + @encodedExample(annotations.nonce.example) + methodName: Option[String], + @description(annotations.nonce.description) + @encodedExample(annotations.nonce.example) + nonce: Option[String] ) object CreateAnoncredRecordRequest { object annotations { - object validityPeriod - extends Annotation[Double]( - description = "The validity period in seconds of the verifiable credential that will be issued.", - example = 3600 - ) - object schemaId extends Annotation[Option[String]]( description = "The unique identifier of the schema used for this credential offer.", @@ -62,35 +53,28 @@ object CreateAnoncredRecordRequest { Some("https://agent-host.com/prism-agent/schema-registry/schemas/d9569cec-c81e-4779-aa86-0d5994d82676") ) - object claims + object credDefId + extends Annotation[Option[String]]( + description = "The unique identifier of the credential definition used for this credential offer.", + example = Some( + "https://agent-host.com/prism-agent/schema-registry/schemas/d9569cec-c81e-4779-aa86-0d5994d82676" + ) // TODO FIX + ) + + object credentialKeyCorrectnessProof extends Annotation[Map[String, String]]( - description = "The claims that will be associated with the issued verifiable credential.", - example = Map( + description = "The claims that will be associated with the issued verifiable credential.", // TODO FIX + example = Map( // TODO FIX "firstname" -> "Alice", "lastname" -> "Wonderland" ) ) - object automaticIssuance - extends Annotation[Boolean]( - description = - "Specifies whether or not the credential should be automatically generated and issued when receiving the `CredentialRequest` from the holder. If set to `false`, a manual approval by the issuer via API call will be required for the VC to be issued.", - example = true - ) - - object issuingDID + object nonce extends Annotation[String]( - description = "The issuer DID of the verifiable credential object.", - example = "did:prism:issuerofverifiablecredentials" + description = "The issuer DID of the verifiable credential object.", // TODO FIX + example = "did:prism:issuerofverifiablecredentials" // TODO FIX ) - - object connectionId - extends Annotation[String]( - 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" - ) - } given encoder: JsonEncoder[CreateAnoncredRecordRequest] =