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.
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.
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:
- Connect to the mediator from another agent using the created Out Of Band Invitation
- Request mediation from the mediator using the Mediator Coordination Protocol.
- 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.
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. |
To deploy the mediator, a postgres database is required. Any postgres database will do.
- Create a postgres database and make sure it is publicly exposed.
- 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.
- Make sure you're authenticated to the Github Container Registry
- 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
You can also adapt the docker-compose.yml
file to your needs.
You can build the docker image using the following command:
docker build \
-t ghcr.io/openwallet-foundation/didcomm-mediator-credo \
-f Dockerfile \
.
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
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.
The DIDComm Mediator Credo is licensed under the Apache License Version 2.0 (Apache-2.0).