Skip to content
Snippets Groups Projects
user avatar
authored

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

  • Install Git

    How to install Git on my system.

  • Install NodeJS >= v18.16.0 version

    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.

  • Clone the repo

    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
  • Install Dependencies

    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

  1. Import postman collection from the repo
  2. Connect to Web Socket on the gateway address, to listen for responses
  3. Make a request
  4. Response will be sent to the Web Socket

Send Didcomm messages between two OCMs

  1. Setup Postman as the previous step

  2. Check your local ip - on linux and macos - ifconfig, windows - ipconfig

  3. Edit issuer.env

    • Change AGENT_PEER_URL to use your local ip - http://your-local-ip:8001 - EXAMPLE http://192.168.111.53:8001
    • Change AGENT_NAME and AGENT_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.
  4. Start the issuer with yarn run infra:issuer or npm run infra:issuer

  5. Connect to the socket via postman. ws://localhost:8081

  6. Create new invitation via postman request, on the socket listener you will receive invitation url response

  7. Copy and paste this url in the chat

  8. Another OCM (which performed the same setup steps, but with different values) should get this invitation url

  9. Call accept invitation via postman with this invitation url as a body payload

  10. Response will be returned on the socket, that a connection is made.

  11. Get the connectionId from this response

  12. Send basic message with connectionId and a string message

  13. 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.