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

fix: OutOfBand qrcode with base url #133

Merged
merged 3 commits into from
Oct 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ object EmbeddedMongoDBInstance {
val port = 27777
val hostIp = "localhost"
val connectionString = s"mongodb://$hostIp:$port/messages"
val index = Index(
key = Seq("alias" -> IndexType.Ascending),
name = Some("alias_did"),
unique = true,
background = true,
partialFilter = Some(BSONDocument("alias.0" -> BSONDocument("$exists" -> true)))
)

def layer(
port: Int = 27077,
hostIp: String = "localhost"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import zio.json.*
import zio.test.*
import zio.test.Assertion.*
import io.iohk.atala.mediator.db.EmbeddedMongoDBInstance.*
import io.iohk.atala.mediator.protocols.MessageSetup

import scala.concurrent.ExecutionContext.Implicits.global
object UserAccountRepoSpec extends ZIOSpecDefault with DidAccountStubSetup {
object UserAccountRepoSpec extends ZIOSpecDefault with DidAccountStubSetup with MessageSetup {

override def spec = suite("UserAccountRepoSpec")(
test("insert new Did Account") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ object ForwardMessageExecutorSpec extends ZIOSpecDefault with DidAccountStubSetu
.provideSomeLayer(AgentStub.agentLayer)
.provideLayerShared(dataAccessLayer) @@ TestAspect.sequential

def setupAndClean = {
for {
userAccount <- ZIO.service[UserAccountRepo]
col <- userAccount.collection
_ = col.indexesManager.create(index)
_ = col.delete.one(BSONDocument())
} yield {}
}


val dataAccessLayer = EmbeddedMongoDBInstance.layer(port, hostIp)
>>> AsyncDriverResource.layer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,6 @@ object MediatorCoordinationExecuterSpec extends ZIOSpecDefault with DidAccountSt
.provideLayerShared(dataAccessLayer) @@ TestAspect.sequential
}

def setupAndClean = {
for {
userAccount <- ZIO.service[UserAccountRepo]
col <- userAccount.collection
_ <- ZIO.fromFuture { implicit ec =>
col.indexesManager.create(index)
}
_ <- ZIO.fromFuture { implicit ec =>
col.delete.one(BSONDocument())
}
} yield {}
}

val dataAccessLayer = EmbeddedMongoDBInstance.layer(port, hostIp)
>>> AsyncDriverResource.layer
>>> ReactiveMongoApi.layer(connectionString)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
package io.iohk.atala.mediator.protocols

import fmgp.did.comm.{EncryptedMessage, PlaintextMessage}
import io.iohk.atala.mediator.db.UserAccountRepo
import reactivemongo.api.bson.BSONDocument
import zio.ZIO
import zio.json.*
import reactivemongo.api.indexes.{Index, IndexType}
trait MessageSetup {

val index = Index(
key = Seq("alias" -> IndexType.Ascending),
name = Some("alias_did"),
unique = true,
background = true,
partialFilter = Some(BSONDocument("alias.0" -> BSONDocument("$exists" -> true)))
)
def setupAndClean = {
for {
userAccount <- ZIO.service[UserAccountRepo]
col <- userAccount.collection
_ <- ZIO.fromFuture { implicit ec =>
col.indexesManager.create(index)
}
_ <- ZIO.fromFuture { implicit ec =>
col.delete.one(BSONDocument())
}
} yield {}
}

val mediatorDid =
"did:peer:2.Ez6LSkGy3e2z54uP4U9HyXJXRpaF2ytsnTuVgh6SNNmCyGZQZ.Vz6Mkjdwvf9hWc6ibZndW9B97si92DSk9hWAhGYBgP9kUFk8Z.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9ib2IuZGlkLmZtZ3AuYXBwLyIsInIiOltdLCJhIjpbImRpZGNvbW0vdjIiXX0"
val plaintextForwardNotEnrolledDidMessage: Either[String, PlaintextMessage] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,6 @@ object PickupExecuterSpec extends ZIOSpecDefault with DidAccountStubSetup with M
.provideLayerShared(dataAccessLayer) @@ TestAspect.sequential
}

def setupAndClean = {
for {
userAccount <- ZIO.service[UserAccountRepo]
col <- userAccount.collection
_ <- ZIO.fromFuture { implicit ec =>
col.indexesManager.create(index)
}
_ <- ZIO.fromFuture { implicit ec =>
col.delete.one(BSONDocument())
}
} yield {}
}

val dataAccessLayer = EmbeddedMongoDBInstance.layer(port, hostIp)
>>> AsyncDriverResource.layer
>>> ReactiveMongoApi.layer(connectionString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ object MediatorInfo {
goal = Some("RequestMediate"),
accept = Some(Seq("didcomm/v2")),
)
val qrCodeData = OutOfBandPlaintext.from(invitation.toPlaintextMessage).makeURI("#/")
val host = dom.window.location.host
val scheme = dom.window.location.protocol
val fullPath = s"${scheme}//${host}"
val qrCodeData = OutOfBandPlaintext.from(invitation.toPlaintextMessage).makeURI(s"$fullPath")

val divQRCode = div()
{
Expand All @@ -35,7 +38,7 @@ object MediatorInfo {
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
p(a(href := fullPath, target := "_blank", code(qrCodeData))), // FIXME make it a link to the mobile app
pre(code(invitation.toPlaintextMessage.toJsonPretty)),
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:",
Expand Down
Loading