Open Source (Self-hosted)

Affinidi provides an open-sourced DIDComm Mediator implementation based on the DIDComm v2.1 protocol.

Deploying the DIDComm Mediator locally enables you to explore and understand how message handling and encryption work under the hood. It allows you to customise the configuration depending on your requirements.

To deploy the DIDComm Mediator from the open-sourced version, follow the steps below:

1. Prerequisites

Before you begin, install the following applications.

  1. Install Rust (1.85.0 2024 Edition) on your machine if you haven’t installed it yet using this guide.

  2. Install Docker on your machine if you haven’t installed it yet using this guide. We will need this to run Redis instance for the mediator to store messages temporarily and mediator configurations.

2. Clone the Mediator Repository

  1. Clone the GitHub repo on your local.
git clone git@github.com:affinidi/affinidi-tdk-rs.git
  1. Navigate to the crates/affinidi-messaging folder.
cd affinidi-tdk-rs/crates/affinidi-messaging

3. Set up the Mediator Instance

  1. Run the Redis Docker container using the command below from your terminal:
docker run --name=redis-local --publish=6380:6380 --hostname=redis --restart=on-failure --detach redis:latest

The latest supported version of Redis is version 8.0.

  1. Run setup_environment to configure the mediator with all the required information to run locally.
cargo run --bin setup_environment
Meeting Place App

Output from setup_environment

Select Local Mediator Configuration and follow the on-screen instructions. Upon successful setup, it will generate the following information:

  • Mediator DID and secrets.
  • Administration DID and secrets.
  • SSL Certificates for local development/testing.
  • Optionally, different users with their DIDs for testing.
  1. After completing the setup, run the following command to navigate to the affinidi-messaging-mediator directory and start the mediator:
cd affinidi-messaging-mediator && cargo run
  1. To verify that the mediator is running, open http://localhost:7037/mediator/v1/.well-known/did.json in your web browser. This page should display your local mediator’s DID document.

4. Test the Mediator Connection

The repository provides examples that you can run to test whether the setup was successful. To do this, follow the steps below:

  1. Open another terminal tab and go to the crates/affinidi-messaging folder.
cd affinidi-tdk-rs/crates/affinidi-messaging
  1. From the terminal, run the following example.
cargo run --example mediator_ping

The above example will execute a code that authenticates to the mediator and send a ping message. If successful, it sends a pong message back.

Enable Logging

To enable logging to see more information when running the example and to learn more about how it works, set the following environment variables from your terminal.

export RUST_LOG=none,affinidi_messaging_helpers=debug,affinidi_messaging_sdk=info

What’s Next

  Explore Meeting Place, an implementation of Affinidi Messaging

  Integrate Affinidi Messaging into your applications