diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala index 85106e084f..341ec0a33a 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala @@ -324,7 +324,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { None, _, _, - credentialsToUse, + _, _, _, _, @@ -970,7 +970,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { record.from.getOrElse(throw new RuntimeException("from is None is not possible")) ) result <- for { - didOps <- ZIO.service[DidOps] didCommAgent <- buildDIDCommAgent( record.from.getOrElse(throw new RuntimeException("from is None is not possible")) ).provideSomeLayer(ZLayer.succeed(walletAccessContext)) @@ -1291,11 +1290,4 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { } } -// val syncDIDPublicationStateFromDlt: ZIO[WalletAccessContext & ManagedDIDService, GetManagedDIDError, Unit] = -// for { -// managedDidService <- ZIO.service[ManagedDIDService] -// _ <- managedDidService.syncManagedDIDState -// _ <- managedDidService.syncUnconfirmedUpdateOperations -// } yield () - } diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatus.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatus.scala index 559b6c7c23..56a53fe398 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatus.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatus.scala @@ -2,6 +2,7 @@ package org.hyperledger.identus.presentproof.controller.http import org.hyperledger.identus.api.http.{Annotation, ErrorResponse} import org.hyperledger.identus.mercury.model.Base64 +import org.hyperledger.identus.mercury.protocol.presentproof.AttachmentBasedPresentation import org.hyperledger.identus.pollux.core.model.PresentationRecord import org.hyperledger.identus.presentproof.controller.http.PresentationStatus.annotations import org.hyperledger.identus.shared.models.{FailureInfo, StatusCode} @@ -30,6 +31,9 @@ final case class PresentationStatus( @description(annotations.data.description) @encodedExample(annotations.data.example) data: Seq[String], + @description(annotations.requestData.description) + @encodedExample(annotations.requestData.example) + requestData: Seq[String], @description(annotations.connectionId.description) @encodedExample(annotations.connectionId.example) connectionId: Option[String] = None, @@ -54,15 +58,8 @@ final case class PresentationStatus( object PresentationStatus { def fromDomain(domain: PresentationRecord): PresentationStatus = { - val data = domain.presentationData match - case Some(p) => - p.attachments.head.data match { - case Base64(data) => - val base64Decoded = new String(java.util.Base64.getUrlDecoder.decode(data)) - Seq(base64Decoded) - case any => FeatureNotImplemented - } - case None => Seq.empty + val data = extractData(domain.presentationData) + val requestData = extractData(domain.requestPresentationData) PresentationStatus( domain.id.value, thid = domain.thid.value, @@ -70,6 +67,7 @@ object PresentationStatus { status = domain.protocolState.toString, proofs = Seq.empty, data = data, + requestData = requestData, connectionId = domain.connectionId, invitation = domain.invitation.map(invitation => OOBPresentationInvitation.fromDomain(invitation)), goalCode = domain.invitation.flatMap(_.body.goal_code), @@ -80,6 +78,18 @@ object PresentationStatus { ) } + private def extractData(maybePresentation: Option[AttachmentBasedPresentation]): Seq[String] = { + maybePresentation match + case Some(p) => + p.attachments.head.data match { + case Base64(data) => + val base64Decoded = new String(java.util.Base64.getUrlDecoder.decode(data)) + Seq(base64Decoded) + case any => FeatureNotImplemented + } + case None => Seq.empty + } + given Conversion[PresentationRecord, PresentationStatus] = fromDomain object annotations { @@ -143,6 +153,11 @@ object PresentationStatus { description = "The list of proofs presented by the prover to the verifier.", example = Seq.empty ) + object requestData + extends Annotation[Seq[String]]( + description = "The list of request presented by the verifier to the prover.", + example = Seq.empty + ) object connectionId extends Annotation[String]( description = "The unique identifier of an established connection between the verifier and the prover.", diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatusPage.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatusPage.scala index e7c34c1689..d9cf2d1986 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatusPage.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/presentproof/controller/http/PresentationStatusPage.scala @@ -71,6 +71,7 @@ object PresentationStatusPage { status = "RequestSent", proofs = Seq.empty, data = Seq.empty, + requestData = Seq.empty, connectionId = Some("e0d81be9-47ca-4e0b-b8a7-325e8c3abc2f"), invitation = None, metaRetries = 5 @@ -81,6 +82,7 @@ object PresentationStatusPage { role = "Prover", status = "RequestReceived", proofs = Seq.empty, + requestData = Seq.empty, data = Seq.empty, metaRetries = 5 ), @@ -90,6 +92,7 @@ object PresentationStatusPage { role = "Prover", status = "PresentationPending", proofs = Seq.empty, + requestData = Seq.empty, data = Seq.empty, metaRetries = 5 ), @@ -99,6 +102,7 @@ object PresentationStatusPage { role = "Verifier", status = "PresentationVerified", proofs = Seq.empty, + requestData = Seq.empty, data = Seq( "{\"claimsToDisclose\":{\"emailAddress\":{},\"givenName\":{}},\"presentation\":\"{\\\"protected\\\":\\\"eyJhbGciOiJFZERTQSJ9\\\",\\\"payload\\\":\\\"eyJfc2QiOlsiMGl4d0tIV0dzbzFvZThFR0hQd2tGYW9EZE1TRFQ3SmgyNkZGSm1ZbGRnRSIsIjQ4VlFXZS1tcjBibHMyOWpicHFKeDNxX2dYY0k5N3dHcEpsZnRoNXQwMGciLCI0Wk9xanFNZVNUVHRKQTNJRExsc3ZXN0dTNzRIemNxY3N2NVFoZk1valE4IiwiUjhGRE0ydXB1V09mNmVJMVA5ckNPdG12c3puVWFFYXpncVNuN0JfeTE0MCIsIlU5MmpfUHlpcHN2TERNQTlDaVRWbnl3bUFzYTM4S2lDWm5TeVhyUE5mNG8iLCJldFB1Mmc5ajdRd01rZ3g5VnpEX1RnNTNUV3UydVpadk1KeHRnNEJ1WGJBIiwidGV3RG1LWklNcS10bUNrMkpqZU0wajNYbU1aUUFLN01heENVNlF4dm9OMCJdLCJfc2RfYWxnIjoic2hhLTI1NiIsImlzcyI6ImRpZDpwcmlzbToxMmEzOWI1YWEwZTcxODI3ZmMxYzYwMjg1ZDVlZWJjMTk0Yjg2NzFhYTJmY2QxZDM2NDBkMGYwMTBlMzliZmVlIiwiaWF0IjoxNzE3NDEwMzgzLCJleHAiOjE3MjAwMDIzODN9\\\",\\\"signature\\\":\\\"953FfSRU_0Y2q0ERrFPzbXJ_hkF0YQe5efwESaZwtXDCn8aanD3MUstp3lzqGZkhvcWRdtCCpIxzhy0zgKwLBg\\\",\\\"disclosures\\\":[\\\"WyI0SHF6MDZCeG5fRlJMb2hWX2lWNXp3IiwgImdpdmVuTmFtZSIsICJBbGljZSJd\\\",\\\"WyJLUnNYYU01c3NXZTl4UEhqQnNjT213IiwgImVtYWlsQWRkcmVzcyIsICJhbGljZUB3b25kZXJsYW5kLmNvbSJd\\\"],\\\"kb_jwt\\\":null}\"}" ), @@ -112,6 +116,7 @@ object PresentationStatusPage { status = "InvitationGenerated", proofs = Seq.empty, data = Seq.empty, + requestData = Seq.empty, connectionId = None, myDid = Some("did:peer:veriferPeerDID1234567890"), invitation = Some( diff --git a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/AttachmentBasedPresentation.scala b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/AttachmentBasedPresentation.scala new file mode 100644 index 0000000000..deeb181652 --- /dev/null +++ b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/AttachmentBasedPresentation.scala @@ -0,0 +1,6 @@ +package org.hyperledger.identus.mercury.protocol.presentproof +import org.hyperledger.identus.mercury.model.AttachmentDescriptor + +trait AttachmentBasedPresentation { + val attachments: Seq[AttachmentDescriptor] +} diff --git a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/Presentation.scala b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/Presentation.scala index 4cfa7db744..d0886a4b05 100644 --- a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/Presentation.scala +++ b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/Presentation.scala @@ -38,7 +38,7 @@ final case class Presentation( thid: Option[String] = None, from: DidId, to: DidId, -) { +) extends AttachmentBasedPresentation { assert(`type` == Presentation.`type`) def makeMessage: Message = Message( diff --git a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/ProposePresentation.scala b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/ProposePresentation.scala index 2172186118..714a6127fa 100644 --- a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/ProposePresentation.scala +++ b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/ProposePresentation.scala @@ -23,7 +23,7 @@ final case class ProposePresentation( thid: Option[String] = None, from: DidId, to: DidId, -) { +) extends AttachmentBasedPresentation { assert(`type` == ProposePresentation.`type`) def makeMessage: Message = Message( diff --git a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/RequestPresentation.scala b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/RequestPresentation.scala index 1548d08800..c635352b94 100644 --- a/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/RequestPresentation.scala +++ b/mercury/protocol-present-proof/src/main/scala/org/hyperledger/identus/mercury/protocol/presentproof/RequestPresentation.scala @@ -14,7 +14,7 @@ final case class RequestPresentation( thid: Option[String] = None, from: Option[DidId], to: Option[DidId], -) { +) extends AttachmentBasedPresentation { def makeMessage: Message = Message( id = this.id,