OCM Engine
Introduction
OCM Engine is a monorepo based on NestJS and Nx, holding applications in apps
directory and libraries
in libs
, which were used to create the applications and can be used for developing additional applications in OCM
project.
Apps list:
- Agent
- Attestation Manager
- Connection Manager
- Proof Manager
- Gateway
Library list:
- Askar
- Clients
- Config
- Dtos
- Ledgers
- Nats
Requirements
- Git
- NodeJS >= v18.16.0
- PostgresDB
- Nats
Architecture
flowchart TD
Postman --http--> Gateway
Gateway --ws--> Postman
Gateway --tcp--> cm[Connection Manager] & am[Attestation Manager] & pm[Proof Manager] --event--> nats[NATS]
nats --event--> Agent
Agent --tcp--> Gateway
Agent <--> db[(PostgresDB)]
Agent <--> Ledger[(Ledger)]
Setup
-
How to install Git on my system.
-
How to install NodeJS on my system. Second option is to use version manager like nvm which will allow you to switch between different NodeJS versions.
-
Once you have installed all Git, Node, Yarn you can clone the project with:
git clone git@code.vereign.com:gaiax/ocm/ocm-engine.git
or
git clone https://code.vereign.com/gaiax/ocm/ocm-engine.git
-
Go inside your cloned repo and install all dependencies with:
yarn install
Local
You can run the entire stack or specific application locally.
Example for entire stack:
1. copy .env.example to .env
2. edit .env to your liking
3. yarn install
4. yarn infra:local or install PostgresDB and Nats broker locally and add them to .env
5. yarn serve:all
Example of running only the agent service as a rest service.
1. copy .env.example to .env
2. edit .env to your liking and change AGENT_IS_REST to true
3. yarn install
4. yarn infra:local or isntall PostgresDB and Nats broker locally and add them to .env
5. yarn serve:agent
Docker
Example:
You can issuer
OCM stack with:
1. edit issuer.env in compose directory
2. yarn infra:issuer
Then the gateway will be at http://localhost:8081 url
Holder
OCM stack can be started with:
1. edit holder.env in compose directory
2. yarn infra:holder
Then the gateway will be at http://localhost:8082 url
You can run the entire stack - issuer
and holder
with:
1. edit issuer.env and holder.env in compose directory
2. yarn infra
Yarn commands are wrapper around docker-compose for easier use. You can still use docker-compose from compose dir.
Usage via Postman
- Import postman collection from the repo
- Connect to Web Socket on the gateway address, to listen for responses
- Make a request
- Response will be sent to the Web Socket
Send Didcomm messages between two OCMs
-
Setup Postman as the previous step
-
Check your local ip - on linux and macos - ifconfig, windows - ipconfig
-
Edit issuer.env
- Change
AGENT_PEER_URL
to use your local ip -http://your-local-ip:8001
- EXAMPLEhttp://192.168.111.53:8001
- Change
AGENT_NAME
andAGENT_KEY
- those are the name and the key of the wallet - Change
AGENT_DID_SEED
- this is a seed for private key from which the DID will be created.
- Change
-
Start the issuer with
yarn run infra:issuer
ornpm run infra:issuer
-
Connect to the socket via postman.
ws://localhost:8081
-
Create new invitation
via postman request, on the socket listener you will receive invitation url response -
Copy and paste this url in the chat
-
Another OCM (which performed the same setup steps, but with different values) should get this invitation url
-
Call
accept invitation
via postman with this invitation url as a body payload -
Response will be returned on the socket, that a connection is made.
-
Get the connectionId from this response
-
Send basic message with connectionId and a string message
-
On the socket of issuer a event will be received with the message and connection id.
License
This project is licensed under the AGPL License - see the LICENSE file for details.