Skip to content

Commit

Permalink
fix: dynamic DID on the web page
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioPinheiro committed Jul 6, 2023
1 parent bf19538 commit d944d8b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion mediator/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mediator = {
x = "MBjnXZxkMcoQVVL21hahWAw43RuAG-i64ipbeKKqwoA"
x = ${?KEY_AUTHENTICATION_X}
}
endpoint = "https://k8s-int.atalaprism.io/mediator"
endpoint = "https://mediator-test-env.atalaprism.io/mediator"
endpoint = ${?SERVICE_ENDPOINT}
}
server.http.port = 8080
Expand Down
33 changes: 0 additions & 33 deletions mediator/src/main/resources/public/index.html

This file was deleted.

31 changes: 31 additions & 0 deletions mediator/src/main/scala/io/iohk/atala/mediator/app/IndexHtml.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.iohk.atala.mediator.app

import zio.http.Response
import fmgp.did.DID

object IndexHtml {
// TODO use the html.Html.fromDomElement()
def html(identity: DID) = Response.html(s"""<html>
|<head>
| <meta charset="UTF-8">
| <title>IOHK Mediator</title>
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
| <meta name="did" content="${identity.did}">
| <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
| <link href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet">
| <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
| <script>
| var callback = function () {
| alert('A callback was triggered');
| }
| </script>
| <!-- My APP -->
| <script type="text/javascript" src="public/webapp-fastopt-bundle.js"></script>
|</head>
|
|<body style="margin:0;">
| <div id="app-container"></div>
|</body>
|
|</html>""".stripMargin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,11 @@ object MediatorAgent {
.setStatus(Status.BadRequest)
)
case req @ Method.GET -> !! => { // html.Html.fromDomElement()
val data = Source.fromResource(s"public/index.html").mkString("")
ZIO.log("index.html") *> ZIO.succeed(Response.html(data))
for {
agent <- ZIO.service[MediatorAgent]
_ <- ZIO.log("index.html")
ret <- ZIO.succeed(IndexHtml.html(agent.id))
} yield ret
}
}: Http[
Operations & Resolver & MessageDispatcher & MediatorAgent & MessageItemRepo & UserAccountRepo,
Expand Down
8 changes: 5 additions & 3 deletions webapp/src/main/scala/fmgp/webapp/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import fmgp.did.comm._

object Global {

def mediatorDID = FROM(
"did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9rOHMtaW50LmF0YWxhcHJpc20uaW8vbWVkaWF0b3IiLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19"
)
var mediatorDID = {
val didSTR = dom.document.querySelector("""meta[name="did"]""")
FROM(didSTR.getAttribute("content"))
}

def clipboardSideEffect(text: => String): Any => Unit =
(_: Any) => { dom.window.navigator.clipboard.writeText(text) }

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/main/scala/fmgp/webapp/MediatorInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object MediatorInfo {
div(
h1("Invite for the DID Comm Mediator:"),
h3("Plaintext out of band invitation:"),
p(code(qrCodeData)),
p(a(href := qrCodeData, target := "_blank", code(qrCodeData))), // FIXME make it a link to the mobile app
pre(code(invitation.toPlaintextMessage.toJsonPretty)),
divQRCode,
h3("Signed out of band invitation:"),
Expand Down

0 comments on commit d944d8b

Please sign in to comment.