Skip to content

Commit

Permalink
losing sanity with ZIO-config
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioPinheiro committed Nov 21, 2023
1 parent 9b86d85 commit e74600d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
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 be listening to incoming DID Comm messages.

#### mediator-storage
To set up the mediator storage (MongoDB):
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", "ws://localhost:8080/ws"]
- SERVICE_ENDPOINTS=http://localhost:8080
- MONGODB_USER=admin
- MONGODB_PASSWORD=admin
- MONGODB_PROTOCOL=mongodb
Expand Down
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", "ws://localhost:8080/ws"] #, "http://localhost:8080/http"]
endpoint = ${?SERVICE_ENDPOINT}
endpoints = "http://localhost:8080;ws://localhost:8080/ws" #, "http://localhost:8080/http"]
endpoints = ${?SERVICE_ENDPOINTS}
}
server.http.port = 8080
server.http.port = ${?PORT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import zio.stream.*
import java.time.format.DateTimeFormatter
import scala.io.Source
import fmgp.did.framework.TransportFactoryImp
case class MediatorConfig(endpoint: Seq[java.net.URI], keyAgreement: OKPPrivateKey, keyAuthentication: OKPPrivateKey) {
case class MediatorConfig(endpoints: String, keyAgreement: OKPPrivateKey, keyAuthentication: OKPPrivateKey) {
val did = DIDPeer2.makeAgent(
Seq(keyAgreement, keyAuthentication),
endpoint.map(e => DIDPeerServiceEncoded(s = e.toString))
endpoints.split(";").toSeq.map(e => DIDPeerServiceEncoded(s = e.toString))
)
val agentLayer: ZLayer[Any, Nothing, MediatorAgent] =
ZLayer(MediatorAgent.make(id = did.id, keyStore = did.keyStore))
Expand Down Expand Up @@ -67,6 +67,7 @@ object MediatorStandalone extends ZIOAppDefault {
)
configs = ConfigProvider.fromResourcePath()
mediatorConfig <- configs.nested("identity").nested("mediator").load(deriveConfig[MediatorConfig])
agentLayer = mediatorConfig.agentLayer
_ <- ZIO.log(s"Mediator APP. See https://github.com/input-output-hk/atala-prism-mediator")
_ <- ZIO.log(s"MediatorConfig: $mediatorConfig")
_ <- ZIO.log(s"DID: ${mediatorConfig.did.id.string}")
Expand Down Expand Up @@ -94,8 +95,8 @@ object MediatorStandalone extends ZIOAppDefault {
myServer <- Server
.serve((MediatorAgent.didCommApp ++ DIDCommRoutes.app) @@ (Middleware.cors))
.provideSomeLayer(DidPeerResolver.layerDidPeerResolver)
.provideSomeLayer(mediatorConfig.agentLayer)
.provideSomeLayer((mediatorConfig.agentLayer ++ transportFactory ++ repos) >>> OperatorImp.layer)
.provideSomeLayer(agentLayer)
.provideSomeLayer((agentLayer ++ transportFactory ++ repos) >>> OperatorImp.layer)
.provideSomeLayer(
AsyncDriverResource.layer
>>> ReactiveMongoApi.layer(mediatorDbConfig.connectionString)
Expand Down

0 comments on commit e74600d

Please sign in to comment.