diff --git a/.env.example b/.env.example index 381d0cb6c252c78a7130174c0ed384c5853aba82..7553fff1fc5aed12927489f7562b5956c297c0e5 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ LEDGERS="BCOVRIN_TEST" IDUNION_KEY=#add if you are using IDUNION as a ledger -AGENT_PEER_URL="http://localhost:8001" +AGENT_PEER_URL=http://localhost:8001,ws://localhost:8002 AGENT_NAME=EXAMPTTLE_AGENT_45 AGENT_KEY=EXAMPLE_AGENT_45_KEY AGENT_DID_SEED=200000000000000000000000ExampleT21 #random string min 32 chars diff --git a/apps/web/src/components/App/index.tsx b/apps/web/src/components/App/index.tsx index f28834c37b681dc05bbb7b48032cea1609f4b0a3..73d638339a036e619f951e9bd2e48eec5594f38b 100644 --- a/apps/web/src/components/App/index.tsx +++ b/apps/web/src/components/App/index.tsx @@ -11,7 +11,7 @@ window.api = api; const host = window.location.hostname === "localhost" - ? `new.didgram.pro:8081` + ? `new.didgram.pro:8091` : window.location.host; const websocketUrl = `ws://${host}`; diff --git a/compose/docker-compose.infra.yml b/compose/docker-compose.infra.yml index dcc23f575f2088184ebdc566b7c027b15c03afcd..6128623dc9b785df00a6cded4099326979b57ea1 100644 --- a/compose/docker-compose.infra.yml +++ b/compose/docker-compose.infra.yml @@ -4,7 +4,7 @@ services: pg_db: image: 'postgres:latest' ports: - - '5432:5432' + - '5433:5432' environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres diff --git a/compose/docker-compose.simple.yml b/compose/docker-compose.simple.yml index 0d8d9ad9557fbabc3efc2789d571667cdaf0b2ac..0544a7887f2e118972e289bc1abe4f158d528686 100644 --- a/compose/docker-compose.simple.yml +++ b/compose/docker-compose.simple.yml @@ -21,6 +21,7 @@ services: ports: - "8080:8080" - "8001:8001" + - "8002:8002" depends_on: pg_db: condition: service_started @@ -35,6 +36,7 @@ services: ports: - "8081:8080" - "6001:6001" + - "6002:6002" depends_on: pg_db: condition: service_started diff --git a/compose/docker-compose.yml b/compose/docker-compose.yml index 3646983bfc3f4ac77a3889c748be603a60be8b8d..e9e3bc1f6943ea61a79a03275c7584c830f64796 100644 --- a/compose/docker-compose.yml +++ b/compose/docker-compose.yml @@ -36,6 +36,7 @@ services: ports: - "8080:8080" - "8001:8001" + - "8002:8002" env_file: - ./env/issuer.env depends_on: @@ -141,6 +142,7 @@ services: ports: - "8090:8080" - "6001:6001" + - "6002:6002" env_file: - ./env/holder.env depends_on: diff --git a/compose/env/holder.env b/compose/env/holder.env index bb84883202ad81113a31c5b210af3b9cb20e1ffa..2d6baefb409488da9c470b0b7345fa907b62b151 100644 --- a/compose/env/holder.env +++ b/compose/env/holder.env @@ -1,7 +1,7 @@ LEDGERS="BCOVRIN_TEST" IDUNION_KEY= -AGENT_PEER_URL="ws://new.didgram.pro:6001" +AGENT_PEER_URL=http://new.didgram.pro:6001,ws://new.didgram.pro:6002 AGENT_NAME=DEV_AGENT_HOLDER_OCM_4 # this should be changed to company name AGENT_KEY=DEV_AGENT_HOLDER_OCM_4 #example random string AGENT_DID_SEED=2000000000000000CCA120000000TCuste21jsjs #did private key seed min lenght 32 diff --git a/compose/env/holder.simple.env b/compose/env/holder.simple.env index 0512edd67495ce96b117057529d79a64ab18d0ab..6d8e0ac8947cb05f622f709a4ed5388195e85bdf 100644 --- a/compose/env/holder.simple.env +++ b/compose/env/holder.simple.env @@ -1,7 +1,7 @@ LEDGERS="BCOVRIN_TEST" IDUNION_KEY= -AGENT_PEER_URL="ws://agent-holder:6001" +AGENT_PEER_URL=http://agent-holder:6001,ws://agent-holder:6002 AGENT_NAME=DEV_SIMPLE_AGENT_HOLDER_OCM # this should be changed to company name AGENT_KEY=DEV_SIMPLE_AGENT_HOLDER_OCM #example random string AGENT_DID_SEED=200000000000000000000000TCuste21xh #did private key seed min lenght 32 diff --git a/compose/env/issuer.env b/compose/env/issuer.env index ff74431543723dd76ea57bd8ffbabce02547dbf0..5ddf0c87110bf4b9352a420596d8b29dae7b85e7 100644 --- a/compose/env/issuer.env +++ b/compose/env/issuer.env @@ -1,7 +1,7 @@ LEDGERS="BCOVRIN_TEST" IDUNION_KEY= -AGENT_PEER_URL="ws://new.didgram.pro:8001" +AGENT_PEER_URL=http://new.didgram.pro:8001,ws://new.didgram.pro:8002 AGENT_NAME=DEV_AGENT_ISSUER_OCM_4 # this should be changed to company name AGENT_KEY=DEV_AGENT_ISSUER_OCM_4 #example random string AGENT_DID_SEED=20000000000000000000000aca0xxaDTCuste21udhasjs #did private key seed min lenght 32 diff --git a/compose/env/issuer.simple.env b/compose/env/issuer.simple.env index bfe2d54c7c903fd3fb9c6022be92df66bd55fecc..a974ad464fe7b01cf6451c025250231adafcc8b9 100644 --- a/compose/env/issuer.simple.env +++ b/compose/env/issuer.simple.env @@ -1,7 +1,7 @@ LEDGERS="BCOVRIN_TEST" IDUNION_KEY= -AGENT_PEER_URL="ws://agent-issuer:8001" +AGENT_PEER_URL=http://agent-issuer:8001,ws://agent-issuer:8002 AGENT_NAME=DEV_SIMPLE_AGENT_ISSUER_OCM # this should be changed to company name AGENT_KEY=DEV_SIMPLE_AGENT_ISSUER_OCM #example random string AGENT_DID_SEED=200000000000000000000000TCuste21js #did private key seed min lenght 32 diff --git a/libs/askar/src/askar/agent.service.ts b/libs/askar/src/askar/agent.service.ts index 27fe92a7a1291e7fe9257731ce0f3cd8aea0a9f4..581b81ef8dec33379b18042f07fc888712ddd5e9 100644 --- a/libs/askar/src/askar/agent.service.ts +++ b/libs/askar/src/askar/agent.service.ts @@ -33,7 +33,7 @@ export class AgentService { const i = new CreateInvitationResponseDto(); i.invitationUrl = outOfBoundRecord.outOfBandInvitation.toUrl({ - domain: this.askar.agentConfig.agentPeerAddress, + domain: this.askar.agentConfig.agentHttpPeerAddress || this.askar.agentConfig.agentWsPeerAddress || '', }); return i; diff --git a/libs/askar/src/askar/askar.service.ts b/libs/askar/src/askar/askar.service.ts index 3d7baf755c66d9f443eed4de589db035a1859001..efe4f486944bef64374eb3066fa915b115a16535 100644 --- a/libs/askar/src/askar/askar.service.ts +++ b/libs/askar/src/askar/askar.service.ts @@ -14,7 +14,11 @@ import { TypedArrayEncoder, WsOutboundTransport, } from "@aries-framework/core"; -import {agentDependencies, HttpInboundTransport, WsInboundTransport} from "@aries-framework/node"; +import { + agentDependencies, + HttpInboundTransport, + WsInboundTransport, +} from "@aries-framework/node"; import { ConfigService } from "@nestjs/config"; import { LedgersService } from "@ocm-engine/ledgers"; import { @@ -38,6 +42,12 @@ export class AskarService implements OnModuleInit, OnModuleDestroy { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.agentConfig = configService.get<IConfAgent>("agent")!; + const endpoints: string[] = []; + if (this.agentConfig.agentHttpPeerAddress) + endpoints.push(this.agentConfig.agentHttpPeerAddress); + if (this.agentConfig.agentWsPeerAddress) + endpoints.push(this.agentConfig.agentWsPeerAddress); + const config = { label: this.agentConfig.agentName, logger: new ConsoleLogger(LogLevel.debug), @@ -55,7 +65,7 @@ export class AskarService implements OnModuleInit, OnModuleDestroy { id: this.agentConfig.agentName, key: this.agentConfig.agentKey, }, - endpoints: [this.agentConfig.agentPeerAddress], + endpoints, } satisfies InitConfig; this.agent = new Agent({ @@ -66,15 +76,23 @@ export class AskarService implements OnModuleInit, OnModuleDestroy { ), }); - // this.agent.registerInboundTransport( - // new HttpInboundTransport({ port: this.agentConfig.agentPeerPort }), - // ); - this.agent.registerInboundTransport( - new WsInboundTransport({ port: this.agentConfig.agentPeerPort }), - ); + if (this.agentConfig.agentHttpPeerPort) { + this.agent.registerInboundTransport( + new HttpInboundTransport({ + port: this.agentConfig.agentHttpPeerPort as number, + }), + ); + } + if (this.agentConfig.agentWsPeerPort) { + this.agent.registerInboundTransport( + new WsInboundTransport({ + port: this.agentConfig.agentWsPeerPort as number, + }), + ); + } this.agent.registerOutboundTransport(new WsOutboundTransport()); - // this.agent.registerOutboundTransport(new HttpOutboundTransport()); + this.agent.registerOutboundTransport(new HttpOutboundTransport()); this.logger.log("Agent setup completed"); } diff --git a/libs/config/src/config/agent.config.ts b/libs/config/src/config/agent.config.ts index d71fa86ec0b107a39cfcc8fb60bdb28c8d62c893..c94edb13ee12f8adacf3c06965c34c65d7dc20c7 100644 --- a/libs/config/src/config/agent.config.ts +++ b/libs/config/src/config/agent.config.ts @@ -2,11 +2,34 @@ import { registerAs } from "@nestjs/config"; import * as process from "process"; import { IConfAgent } from "../interfaces/agent.config.interface"; +const endpoints = process.env["AGENT_PEER_URL"]!.split(","); +let agentWsPeerPort: number | null = null; +let agentWsPeerAddress: string | null = null; +let agentHttpPeerPort: number | null = null; +let agentHttpPeerAddress: string | null = null; + +const wsEndpoint = endpoints.find( + (p) => p.startsWith("ws") || p.startsWith("wss"), +); +if (wsEndpoint) { + agentWsPeerPort = parseInt(wsEndpoint.split(":")[2]); + agentWsPeerAddress = wsEndpoint; +} +const httpEndpoint = endpoints.find( + (p) => p.startsWith("http") || p.startsWith("https"), +); +if (httpEndpoint) { + agentHttpPeerPort = parseInt(httpEndpoint.split(":")[2]); + agentHttpPeerAddress = httpEndpoint; +} + export const agentConfig = registerAs( "agent", (): IConfAgent => ({ - agentPeerPort: parseInt(process.env["AGENT_PEER_URL"]!.split(":")[2]), - agentPeerAddress: process.env["AGENT_PEER_URL"]!, + agentWsPeerPort, + agentWsPeerAddress, + agentHttpPeerPort, + agentHttpPeerAddress, agentName: process.env["AGENT_NAME"]!, agentKey: process.env["AGENT_KEY"]!, agentDidSeed: process.env["AGENT_DID_SEED"]!, diff --git a/libs/config/src/interfaces/agent.config.interface.ts b/libs/config/src/interfaces/agent.config.interface.ts index 1f0e7a85caa94710dd23ede1d6ff0d5042870a86..25dee199cebc1364f7bf7603ce95b31df460e5f0 100644 --- a/libs/config/src/interfaces/agent.config.interface.ts +++ b/libs/config/src/interfaces/agent.config.interface.ts @@ -2,8 +2,10 @@ export interface IConfAgent { agentDbHost: string; agentDbUser: string; agentDbPass: string; - agentPeerPort: number; - agentPeerAddress: string; + agentWsPeerPort: number | null; + agentWsPeerAddress: string | null; + agentHttpPeerPort: number | null; + agentHttpPeerAddress: string | null; agentName: string; agentKey: string; agentDidSeed: string;