diff --git a/mediator/src/main/resources/logback.xml b/mediator/src/main/resources/logback.xml index cb9246d1..adefab30 100644 --- a/mediator/src/main/resources/logback.xml +++ b/mediator/src/main/resources/logback.xml @@ -4,7 +4,7 @@ true - %d{yyyy-MM-dd_HH:mm:ss.SSS} [%highlight(%-5level)] %cyan(%logger{5}@[%-4.30thread]) msgHash[%X{msgHash}] - %msg%xException%n + %d{yyyy-MM-dd_HH:mm:ss.SSS} [%highlight(%-5level)] %cyan(%logger{5}@L%line:[%-4.30thread]) %mdc - %msg%xException%n @@ -17,6 +17,6 @@ - + \ No newline at end of file diff --git a/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala b/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala index 125b2483..692b65ef 100644 --- a/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala +++ b/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala @@ -5,6 +5,7 @@ import fmgp.crypto.error.* import fmgp.did.* import fmgp.did.comm.* import fmgp.did.comm.protocol.* +import fmgp.did.comm.protocol.oobinvitation.OOBInvitation import io.iohk.atala.mediator.* import io.iohk.atala.mediator.actions.* import io.iohk.atala.mediator.comm.* @@ -23,6 +24,7 @@ import zio.json.* import scala.concurrent.ExecutionContext.Implicits.global import scala.util.Try import scala.io.Source + case class MediatorAgent( override val id: DID, override val keyStore: KeyStore, // Should we make it lazy with ZIO @@ -233,6 +235,38 @@ object MediatorAgent { annotationMap <- ZIO.logAnnotations.map(_.map(e => LogAnnotation(e._1, e._2)).toSeq) ret <- agent.websocketListenerApp(annotationMap) } yield (ret) + case Method.GET -> !! / "invitation" => + for { + agent <- ZIO.service[MediatorAgent] + annotationMap <- ZIO.logAnnotations.map(_.map(e => LogAnnotation(e._1, e._2)).toSeq) + invitation = OOBInvitation( + from = agent.id, + goal_code = Some("request-mediate"), + goal = Some("RequestMediate"), + accept = Some(Seq("didcomm/v2")), + ) + _ <- ZIO.log("New mediate invitation MsgID: " + invitation.id.value) + ret <- ZIO.succeed(Response.json(invitation.toPlaintextMessage.toJson)) + + } yield (ret) + case Method.GET -> !! / "invitationOOB" => + for { + agent <- ZIO.service[MediatorAgent] + annotationMap <- ZIO.logAnnotations.map(_.map(e => LogAnnotation(e._1, e._2)).toSeq) + invitation = OOBInvitation( + from = agent.id, + goal_code = Some("request-mediate"), + goal = Some("RequestMediate"), + accept = Some(Seq("didcomm/v2")), + ) + _ <- ZIO.log("New mediate invitation MsgID: " + invitation.id.value) + ret <- ZIO.succeed( + Response.text( + OutOfBandPlaintext.from(invitation.toPlaintextMessage).makeURI("") + ) + ) + + } yield (ret) case req @ Method.POST -> !! if req.headersAsList.exists { h => h.key.toString.toLowerCase == "content-type" && (h.value.toString.startsWith(MediaTypes.SIGNED.typ) || diff --git a/webapp/src/main/scala/io/iohk/atala/mediator/MediatorInfo.scala b/webapp/src/main/scala/io/iohk/atala/mediator/MediatorInfo.scala index 428afd62..7fea6385 100644 --- a/webapp/src/main/scala/io/iohk/atala/mediator/MediatorInfo.scala +++ b/webapp/src/main/scala/io/iohk/atala/mediator/MediatorInfo.scala @@ -33,6 +33,10 @@ object MediatorInfo { h3("Plaintext out of band invitation:"), p(a(href := qrCodeData, target := "_blank", code(qrCodeData))), // FIXME make it a link to the mobile app pre(code(invitation.toPlaintextMessage.toJsonPretty)), + pre( + "To facilitate the integration with other systems you can get the plain text invitation and the out-of-band invitation on the following endpoints:", + " '/invitation' and '/invitationOOB'" + ), divQRCode, h3("Signed out of band invitation:"), code("TODO"),