Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add MediatorBuildInfo & /did and /version endpoints #120

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ lazy val scalaJSBundlerConfigure: Project => Project =
lazy val buildInfoConfigure: Project => Project = _.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoPackage := "io.iohk.atala.mediator",
// buildInfoObject := "BuildInfo",
buildInfoObject := "MediatorBuildInfo",
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
BuildInfoKey.action("buildTime") { System.currentTimeMillis }, // re-computed each time at compile
// BuildInfoKey.action("buildTime") { System.currentTimeMillis }, // re-computed each time at compile
),
)

Expand All @@ -194,6 +194,7 @@ lazy val httpUtils = crossProject(JSPlatform, JVMPlatform) // project

lazy val mediator = project
.in(file("mediator"))
.configure(buildInfoConfigure)
.settings(publish / skip := true)
.settings(
// FIX TODO (maybe the next version of the library will hide this compilation error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ object MediatorAgent {
def didCommApp = {
Http.collectZIO[Request] {
case req @ Method.GET -> Root / "headers" =>
println(req.headers.size)
val data = req.headers.toSeq.map(e => (e.headerName, e.renderedValue))
ZIO.succeed(Response.text("HEADERS:\n" + data.mkString("\n") + "\nRemoteAddress:" + req.remoteAddress)).debug
case req @ Method.GET -> Root / "health" => ZIO.succeed(Response.ok)

case Method.GET -> Root / "version" => ZIO.succeed(Response.text(MediatorBuildInfo.version))
case Method.GET -> Root / "did" =>
for {
agent <- ZIO.service[MediatorAgent]
ret <- ZIO.succeed(Response.text(agent.id.string))
} yield (ret)
case Method.GET -> Root / "invitation" =>
for {
agent <- ZIO.service[MediatorAgent]
Expand All @@ -208,7 +212,6 @@ object MediatorAgent {
)
_ <- ZIO.log("New mediate invitation MsgID: " + invitation.id.value)
ret <- ZIO.succeed(Response.json(invitation.toPlaintextMessage.toJson))

} yield (ret)
case Method.GET -> Root / "invitationOOB" =>
for {
Expand Down
13 changes: 11 additions & 2 deletions webapp/src/main/scala/io/iohk/atala/mediator/MediatorInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,25 @@ object MediatorInfo {
def apply(): HtmlElement = // rootElement
div(
h1("Invite for the DID Comm Mediator:"),
div(
h3("Mediator identity (DID):"),
code(invitation.from.value),
),
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(
p(
"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'"
" '/invitation' and '/invitationOOB'.",
"You can also get the DID of the mediator in '/did' or the build version (of the backend) in '/version'."
),
divQRCode,
h3("Signed out of band invitation:"),
code("TODO"),
footerTag(
textAlign.center,
p("Mediator Version: ", code("'" + MediatorBuildInfo.version + "'"))
),
)

}