55 releases (12 breaking)

Uses new Rust 2024

new 0.18.2 May 9, 2026
0.17.0 May 2, 2026
0.16.2 Mar 28, 2026
0.14.0 Dec 17, 2025
0.7.6 Sep 24, 2024

#110 in Cryptography

Download history 57/week @ 2026-01-23 78/week @ 2026-01-30 83/week @ 2026-02-06 169/week @ 2026-02-13 158/week @ 2026-02-20 301/week @ 2026-02-27 240/week @ 2026-03-06 510/week @ 2026-03-13 1014/week @ 2026-03-20 759/week @ 2026-03-27 350/week @ 2026-04-03 748/week @ 2026-04-10 860/week @ 2026-04-17 745/week @ 2026-04-24 974/week @ 2026-05-01 908/week @ 2026-05-08

3,641 downloads per month
Used in 9 crates (6 directly)

Apache-2.0

1.5MB
30K SLoC

affinidi-messaging-sdk

Crates.io Documentation Rust License

SDK for integrating Affinidi Messaging into your application. Provides a high-level API for sending and receiving end-to-end encrypted DIDComm v2 messages via a mediator service.

Note: This SDK focuses on the DIDComm protocol. For Trust Spanning Protocol (TSP) messaging, see the affinidi-tsp crate directly, or use affinidi-messaging-core for a protocol-agnostic API that works with both DIDComm and TSP.

Installation

[dependencies]
affinidi-messaging-sdk = "0.17"

Quick Start

use affinidi_messaging_sdk::{ATM, config::Config};

let config = Config::builder()
    .with_ssl_certificates(&mut vec!["path/to/client.chain".into()])
    .with_my_did("did:peer:2...")
    .with_atm_did("did:peer:2...")
    .build()?;

let mut atm = ATM::new(config, vec![]).await?;

// Send a trust ping
atm.send_ping("did:peer:2...", true, true).await?;

Transport

The SDK supports both WebSocket and HTTPS REST transports:

  • WebSocket (default) — used for sending messages and receiving inbound message streams
  • REST — used for authentication (JWT tokens) and as a fallback

WebSocket is created automatically when ATM::new() is called. You can disable it or manage it manually:

let config = Config::builder()
    .with_websocket_disabled()
    .build()?;
let mut atm = ATM::new(config, vec![]).await?;

// Send via REST
atm.send_ping("did:peer:2...", true, true).await?;

// Start WebSocket later if needed
atm.start_websocket().await?;
atm.send_ping("did:peer:2...", true, true).await?;
atm.close_websocket().await?;

Core API

Sending Messages

Method Description
send_ping(to, signed, response) Send a DIDComm Trust Ping
send_didcomm_message(msg) Send a packed DIDComm message via REST
ws_send_didcomm_message(msg) Send a packed DIDComm message via WebSocket

Message Management

Method Description
list_messages(did, folder) List messages in Inbox or Outbox
get_messages(request) Retrieve messages by ID
delete_messages(request) Delete messages by ID

Packing & Unpacking

Method Description
pack_encrypted(msg, from, sign_by) Encrypt (and optionally sign) a message
pack_signed(msg, sign_by) Sign a plaintext message
pack_plaintext(msg) Create an unencrypted DIDComm message
unpack(msg) Unpack any DIDComm message

Debug Logging

export RUST_LOG=none,affinidi_messaging_sdk=debug

Examples

Set up a mediator first (see mediator README), then:

export MEDIATOR_DID=<your-mediator-did>
export MEDIATOR_ENDPOINT=https://localhost:7037/mediator/v1

cargo run --example ping
cargo run --example send_message_to_me
cargo run --example message_pickup

See affinidi-messaging-helpers for more examples.

License

Apache-2.0

Dependencies

~138MB
~3M SLoC