Skip to content

An easy to set-up Aries and DIDComm v1 mediator built on Aries Framework JavaScript.

License

Notifications You must be signed in to change notification settings

openwallet-foundation/didcomm-mediator-credo

Repository files navigation


Credo Logo

DIDComm Mediator Credo

License typescript GitHub release (latest by date)


Getting started  |  Environment Variables  |  Postgres Database  |  Using Docker  |  Roadmap  |  How To Contribute  |  License


This repo contains a Mediator Agent for usage with Hyperledger Aries and DIDComm v1 agents. It is built using Credo.

Why should you use this mediator?

  • Automatically set up mediation with the mediator using the Mediator Coordination Protocol.
  • Pick up messages implicitly using WebSockets, using the Pickup V1 Protocol, and the Pickup V2 Protocol.
  • Configured to persist queued messages for recipient in a postgres.
  • Use the pre-built docker image for easy deployment of your mediator.

Getting Started

If you want to deploy the mediator based on the pre-built docker image, please see the Using Docker section.

Install dependencies:

pnpm install

And run dev to start the development server:

pnpm dev

To reach the mediator externally you need to set up an ngrok tunnel. To do this, create an .env.local file and add an NGROK_AUTH_TOKEN. Read more on obtaining an auth token here: https://dashboard.ngrok.com/get-started/your-authtoken.

Connecting to the Mediator

When you've correctly started the mediator agent, and have extracted the invitation from the console, you can use the invitation to connect to the mediator agent. To connect to the mediator and start receiving messages, there's a few steps that need to be taken:

  1. Connect to the mediator from another agent using the created Out Of Band Invitation
  2. Request mediation from the mediator using the Mediator Coordination Protocol.
  3. Start picking up messages implicitly by connecting using a WebSocket and sending any DIDComm message to authenticate, the Pickup V1 Protocol, or the Pickup V2 Protocol. We recommend using the Pickup V2 Protocol.

If you're using an Credo agent as the client, you can follow the Mediation Tutorial from the Credo docs.

Environment Variables

You can provide a number of environment variables to run the agent. The following table lists the environment variables that can be used.

The POSTGRES_ variables won't be used in development mode (NODE_ENV=development), but are required when NODE_ENV is production. This makes local development easier, but makes sure you have a persistent database when deploying.

Variable Description
AGENT_ENDPOINTS Comma separated list of endpoints, in order of preference. In most cases you want to provide two endpoints, where the first one is an HTTP url, and the second one is an WebSocket url
AGENT_NAME The name of the agent. This will be used in invitations and will be publicly advertised.
AGENT_PORT The port that is exposed for incoming traffic. Both the HTTP and WS inbound transport handlers are exposes on this port, and HTTP traffic will be upgraded to the WebSocket server when applicable.
WALLET_NAME The name of the wallet to use.
WALLET_KEY The key to unlock the wallet.
INVITATION_URL Optional URL that can be used as the base for the invitation url. This would allow you to render a certain web page that can extract the invitation form the oob parameter, and show the QR code, or show useful information to the end-user. Less applicable to mediator URLs.
POSTGRES_HOST Host of the database to use. Should include both host and port.
POSTGRES_USER The postgres user.
POSTGRES_PASSWORD The postgres password.
POSTGRES_ADMIN_USER The postgres admin user.
POSTGRES_ADMIN_PASSWORD The postgres admin password.

Postgres Database

To deploy the mediator, a postgres database is required. Any postgres database will do.

  1. Create a postgres database and make sure it is publicly exposed.
  2. Set the POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_ADMIN_USER, POSTGRES_ADMIN_PASSWORD variables. For the mediator we use the same username and password for the admin user and the regular user, but you might want to create a separate user for the admin user.

Using Docker

Using the pre-built Docker Image

  1. Make sure you're authenticated to the Github Container Registry
  2. Run the docker image using the following command:
docker run \
  -e "AGENT_ENDPOINTS=http://localhost:3000,ws://localhost:3000" \
  -e "WALLET_KEY=<your-wallet-key>" \
  -e "WALLET_NAME=mediator" \
  -e "AGENT_NAME=Mediator" \
  -e "AGENT_PORT=3000" \
  -e "POSTGRES_HOST=mediator-database-xxxx.ondigitalocean.com:25060" \
  -e "POSTGRES_USER=postgres" \
  -e "POSTGRES_PASSWORD=<your-postgres-password>" \
  -e "POSTGRES_ADMIN_USER=postgres" \
  -e "POSTGRES_ADMIN_PASSWORD=<your-postgres-password>" \
  -p 3000:3000 \
  ghcr.io/openwallet-foundation/didcomm-mediator-credo:latest

Make sure to use the correct tag. By default latest will be used which can have unexpected breakage. See the releases for the latest stable tag. Currently the last released tag is GitHub release (latest by date)

You can also adapt the docker-compose.yml file to your needs.

Building the Docker Image

You can build the docker image using the following command:

docker build \
   -t ghcr.io/openwallet-foundation/didcomm-mediator-credo \
   -f Dockerfile \
   .

Roadmap

The contents in this repository started out as a simple mediator built using Credo that can be used for development. Over time we've added some features, but there's still a lot we want to add to this repository over time. Some things on the roadmap:

  • Expose a did:web did, so you can directly connect to the mediator using only a did
  • Allow for customizing the message queue implementation, so it doesn't have to be stored in the Askar database, but rather in high-volume message queue like Kafka.
  • DIDComm v2 support
  • Sending push notifications to the recipient when a message is queued for them
  • Allow to control acceptance of mediation requests

🖇️ How To Contribute

You're welcome to contribute to this repository. Please make sure to open an issue first for bigger changes!

This mediator is open source and you're more than welcome to customize and use it to create your own mediator.

License

The DIDComm Mediator Credo is licensed under the Apache License Version 2.0 (Apache-2.0).