Skip to content

Commit

Permalink
feat: websockets support (#172)
Browse files Browse the repository at this point in the history
Support DIDComm via Websockets
Support WebSocket URI as endpoints
Update scala-did to 0.1.0-M15
Use of Scala DID framework and Transport
Remove module 'http-utils'
Support multi endpoint in the config file
Better error handling
Configuration update
Cleanup duplicated code
Work for #144

---------

Signed-off-by: Pete Vielhaber <peter.vielhaber@iohk.io>
Co-authored-by: Pete Vielhaber <peter.vielhaber@iohk.io>
Signed-off-by: Fabio Pinheiro <fabiomgpinheiro@gmail.com>

Signed-off-by: Shailesh Patil <shailesh.patil@iohk.io>
  • Loading branch information
FabioPinheiro authored and mineme0110 committed May 1, 2024
1 parent d6c225e commit 3d32b51
Show file tree
Hide file tree
Showing 44 changed files with 797 additions and 1,101 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
REPORTS_DIR: "didcomm-v2-mediator-test-suite/target/site/serenity"
DIDCOMM_V2_TESTSUITE_VERSION: "a6288ef6536cd15181c30896841f5c33ef0c050b" # old "v0.1.0"
MEDIATOR_DID: "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ"
DIDCOMM_V2_TESTSUITE_VERSION: "13882b256bfdbe8ba738c2798dffc0ce25ca52e4"
MEDIATOR_DID: "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ.SeyJ0IjoiZG0iLCJzIjoid3M6Ly9sb2NhbGhvc3Q6ODA4MC93cyIsInIiOltdLCJhIjpbImRpZGNvbW0vdjIiXX0"
steps:
- name: Checkout mediator
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ To set up the mediator identity:
- `KEY_AGREEMENT_X` - is the key agreement public key (MUST be a X25519 OKP key type).
- `KEY_AUTHENTICATION_D` - is the key authentication private key (MUST be an Ed25519 OKP key type).
- `KEY_AUTHENTICATION_X` - is the key authentication public key (MUST be an Ed25519 OKP key type).
- `SERVICE_ENDPOINT` - is the endpoint of the mediator. Where the mediator will be listening to incoming DID Comm messages.
- `SERVICE_ENDPOINTS` - is the list of endpoints of the mediator split by ';' where the mediator will listen to incoming DIDComm messages.

#### mediator-storage
To set up the mediator storage (MongoDB):
Expand Down
21 changes: 4 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ inThisBuild(

/** Versions */
lazy val V = new {
val scalaDID = "0.1.0-M13"
// val scalajsJavaSecureRandom = "1.0.0"
val scalaDID = "0.1.0-M15"

// FIXME another bug in the test framework https://github.com/scalameta/munit/issues/554
val munit = "1.0.0-M10" // "0.7.29"
Expand Down Expand Up @@ -49,6 +48,7 @@ lazy val D = new {
val scalaDID = Def.setting("app.fmgp" %%% "did" % V.scalaDID)
val scalaDID_imp = Def.setting("app.fmgp" %%% "did-imp" % V.scalaDID)
val scalaDID_peer = Def.setting("app.fmgp" %%% "did-method-peer" % V.scalaDID)
val scalaDID_framework = Def.setting("app.fmgp" %%% "did-framework" % V.scalaDID)

// /** The [[java.security.SecureRandom]] is used by the [[java.util.UUID.randomUUID()]] method in [[MsgId]].
// *
Expand Down Expand Up @@ -175,19 +175,6 @@ lazy val buildInfoConfigure: Project => Project = _.enablePlugins(BuildInfoPlugi
),
)

lazy val httpUtils = crossProject(JSPlatform, JVMPlatform) // project
.in(file("http-utils"))
.settings(publish / skip := true)
.settings((setupTestConfig): _*)
.settings(
libraryDependencies += D.scalaDID.value,
)
.jsConfigure(scalaJSBundlerConfigure)
.jsSettings(Compile / npmDependencies ++= NPM.sha256)
.jvmSettings(
libraryDependencies += D.zioHttp.value,
)

lazy val mediator = project
.in(file("mediator"))
.configure(buildInfoConfigure)
Expand All @@ -204,6 +191,7 @@ lazy val mediator = project
.settings(
libraryDependencies += D.scalaDID_imp.value,
libraryDependencies += D.scalaDID_peer.value,
libraryDependencies += D.scalaDID_framework.value,
libraryDependencies += D.zioHttp.value,
libraryDependencies ++= Seq(
D.zioConfig.value,
Expand All @@ -226,7 +214,7 @@ lazy val mediator = project
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
)
.settings(
Compile / mainClass := Some("io.iohk.atala.mediator.app.MediatorStandalone"),
Compile / mainClass := Some("io.iohk.atala.mediator.MediatorStandalone"),
Docker / maintainer := "atala-coredid@iohk.io",
Docker / dockerUsername := Some("input-output-hk"),
Docker / dockerRepository := Some("ghcr.io"),
Expand Down Expand Up @@ -254,7 +242,6 @@ lazy val mediator = project
Runtime / managedClasspath += (Assets / packageBin).value,
)
.enablePlugins(WebScalaJSBundlerPlugin)
.dependsOn(httpUtils.jvm) // did, didExample,
.enablePlugins(JavaAppPackaging, DockerPlugin)

lazy val webapp = project
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- KEY_AGREEMENT_X=Sr4SkIskjN_VdKTn0zkjYbhGTWArdUNE4j_DmUpnQGw
- KEY_AUTHENTICATION_D=INXCnxFEl0atLIIQYruHzGd5sUivMRyQOzu87qVerug
- KEY_AUTHENTICATION_X=MBjnXZxkMcoQVVL21hahWAw43RuAG-i64ipbeKKqwoA
- SERVICE_ENDPOINT=http://localhost:8080
- SERVICE_ENDPOINTS=http://localhost:8080;ws://localhost:8080/ws
- MONGODB_USER=admin
- MONGODB_PASSWORD=admin
- MONGODB_PROTOCOL=mongodb
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions infrastructure/charts/mediator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ spec:
value: "27017"
- name: MONGODB_DB_NAME
value: "mediator"
- name: SERVICE_ENDPOINT
value: "https://{{ index .Values.ingress.applicationUrls 0 }}"
- name: SERVICE_ENDPOINTS
value: "https://{{ index .Values.ingress.applicationUrls 0 }};https://{{ index .Values.ingress.applicationUrls 0 }}/ws"
4 changes: 2 additions & 2 deletions mediator/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ mediator = {
x = "MBjnXZxkMcoQVVL21hahWAw43RuAG-i64ipbeKKqwoA"
x = ${?KEY_AUTHENTICATION_X}
}
endpoint = "http://localhost:8080"
endpoint = ${?SERVICE_ENDPOINT}
endpoints = "http://localhost:8080;ws://localhost:8080/ws"
endpoints = ${?SERVICE_ENDPOINTS}
}
server.http.port = 8080
server.http.port = ${?PORT}
Expand Down
Loading

0 comments on commit 3d32b51

Please sign in to comment.