Skip to content
Snippets Groups Projects
Commit 5e665db5 authored by Alexey Lunin's avatar Alexey Lunin
Browse files

id union

parent ba81f724
No related branches found
No related tags found
No related merge requests found
Showing
with 107 additions and 29 deletions
LEDGERS="BCOVRIN_TEST"
IDUNION_KEY=#add if you are using IDUNION as a ledger
IDUNION_BASIC_USER=
IDUNION_BASIC_PASS=
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
......
......@@ -21,6 +21,7 @@ async function bootstrap() {
const gatewayConfig = configService.get<IGateway>("gateway")!;
const globalPrefix = "api";
app.enableCors();
app.setGlobalPrefix(globalPrefix);
app.enableShutdownHooks();
......
......@@ -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
......@@ -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:
......
LEDGERS="BCOVRIN_TEST"
LEDGERS=BCOVRIN_TEST
IDUNION_KEY=
IDUNION_BASIC_USER=
IDUNION_BASIC_PASS=
AGENT_PEER_URL="http://agent-holder:6001"
AGENT_PEER_URL=http://agent-holder:6001,ws://agent-holder: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
AGENT_DID_SEED=2000000000000000CCA120000000TCuste21jsjs #did private key seed min length 32
AGENT_DB_HOST=pg_db:5432
AGENT_DB_USER=postgres
AGENT_DB_PASS=postgres
......
LEDGERS="BCOVRIN_TEST"
LEDGERS=BCOVRIN_TEST
IDUNION_KEY=
IDUNION_BASIC_USER=
IDUNION_BASIC_PASS=
AGENT_PEER_URL="http://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
AGENT_DID_SEED=200000000000000000000000TCuste21xh #did private key seed min length 32
AGENT_DB_HOST=pg_db:5432
AGENT_DB_USER=postgres
AGENT_DB_PASS=postgres
......
LEDGERS="BCOVRIN_TEST"
LEDGERS=BCOVRIN_TEST
IDUNION_KEY=
IDUNION_BASIC_USER=
IDUNION_BASIC_PASS=
AGENT_PEER_URL="http://agent-issuer:8001"
AGENT_PEER_URL=http://agent-issuer:8001,ws://agent-issuer: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
AGENT_DID_SEED=20000000000000000000000aca0xxaDTCuste21udhasjs #did private key seed min length 32
AGENT_DB_HOST=pg_db:5432
AGENT_DB_USER=postgres
AGENT_DB_PASS=postgres
......
LEDGERS="BCOVRIN_TEST"
LEDGERS=BCOVRIN_TEST
IDUNION_KEY=
IDUNION_BASIC_USER=
IDUNION_BASIC_PASS=
AGENT_PEER_URL="http://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
......
......@@ -13,6 +13,8 @@ import {
V2ProofProtocol,
WalletError,
WalletKeyExistsError,
KeyDidResolver,
KeyDidRegistrar,
} from "@aries-framework/core";
import {
AnonCredsCredentialFormatService,
......@@ -125,8 +127,8 @@ export const getAskarAnonCredsIndyModules = (networks: any) => {
networks,
}),
dids: new DidsModule({
registrars: [new IndyVdrIndyDidRegistrar()],
resolvers: [new IndyVdrIndyDidResolver()],
registrars: [new IndyVdrIndyDidRegistrar(), new KeyDidRegistrar()],
resolvers: [new IndyVdrIndyDidResolver(), new KeyDidResolver()],
}),
askar: new AskarModule({
ariesAskar,
......
......@@ -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;
......
......@@ -14,7 +14,11 @@ import {
TypedArrayEncoder,
WsOutboundTransport,
} from "@aries-framework/core";
import { agentDependencies, HttpInboundTransport } 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,9 +76,20 @@ export class AskarService implements OnModuleInit, OnModuleDestroy {
),
});
this.agent.registerInboundTransport(
new HttpInboundTransport({ port: this.agentConfig.agentPeerPort }),
);
if (this.agentConfig.agentWsPeerPort) {
this.agent.registerInboundTransport(
new WsInboundTransport({
port: this.agentConfig.agentWsPeerPort as number,
}),
);
}
if (this.agentConfig.agentHttpPeerPort) {
this.agent.registerInboundTransport(
new HttpInboundTransport({
port: this.agentConfig.agentHttpPeerPort as number,
}),
);
}
this.agent.registerOutboundTransport(new WsOutboundTransport());
this.agent.registerOutboundTransport(new HttpOutboundTransport());
......
......@@ -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"]!,
......
......@@ -7,5 +7,7 @@ export const ledgersConfig = registerAs(
(): ILedgers => ({
ledgers: process.env["LEDGERS"]!.split(","),
idUnionApiKey: process.env["IDUNION_KEY"]!,
idUnionApiBasicUser: process.env["IDUNION_BASIC_USER"]!,
idUnionApiBasicPass: process.env["IDUNION_BASIC_PASS"]!,
}),
);
......@@ -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;
......
export interface ILedgers {
ledgers: Array<string>;
idUnionApiKey: string;
idUnionApiBasicUser: string;
idUnionApiBasicPass: string;
}
......@@ -3,4 +3,6 @@ import Joi from "joi";
export const ledgersSchema = Joi.object({
LEDGERS: Joi.string().required(),
IDUNION_KEY: Joi.string(),
IDUNION_BASIC_USER: Joi.string(),
IDUNION_BASIC_PASS: Joi.string(),
});
......@@ -30,11 +30,20 @@ export class IdunionProvider implements IRegistrator {
this.logger.log(`Trying to register ${did} to idunion`);
try {
await axios.post(`${URL}?apiKey=${this.config.idUnionApiKey}`, {
role: "ENDORSER",
did: unqualifiedIndyDid,
verkey,
});
await axios.post(
`${URL}?apiKey=${this.config.idUnionApiKey}`,
{
role: "ENDORSER",
did: unqualifiedIndyDid,
verkey,
},
{
auth: {
username: this.config.idUnionApiBasicUser,
password: this.config.idUnionApiBasicPass,
},
},
);
this.logger.log("Registration successful");
return did;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment