Skip to main content

Crate deezchatz_sdk

Crate deezchatz_sdk 

Source
Expand description

§DeezChatz SDK for Rust

An asynchronous Rust SDK for the DeezChatz platform, providing end-to-end encryption via the Signal Protocol (X3DH and Double Ratchet), zero-trust REST authentication via VXEdDSA signatures and VRF proofs, and real-time messaging over MQTT.

§Core Architecture

  • End-to-End Cryptography: Deeply integrated with libsignal-dezire to manage Identity Keys, Signed Pre-Keys, One-Time Pre-Keys (OPKs), and active Double Ratchet sessions.
  • Zero-Trust Stateless Authentication: Authenticates every REST request using cryptographic VXEdDSA signatures (X-User-Id, X-Timestamp, X-Signature, X-Vrf).
  • Real-Time MQTT Transport: Connects to the DeezChatz MQTT broker with cryptographic password tokens, receiving events via an asynchronous tokio::sync::mpsc::Receiver.
  • Bring-Your-Own-Storage (BYOS): Abstract async traits for key persistence (KeyStore), session state (SessionStore), incoming message queue (InboxStore), and outgoing queue (OutboxStore).
  • Guaranteed Delivery & Crash Resilience: Unprocessed inbound messages and pending outbound messages are safely persisted to disk to prevent data loss across crashes or network disruptions.
  • Multi-Type Framed Payloads: Native support for UTF-8 text, Opus voice notes, and JPEG image transfers with captions and timestamps.

§Quick Start

use std::sync::Arc;
use deezchatz_sdk::{DeezChatzClient, ClientConfig, Event, decode_payload, DecodedPayload};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::production();
    let store = Arc::new(DummyStore);

    let mut client = DeezChatzClient::new(
        config,
        store.clone(),
        store.clone(),
        store.clone(),
        store.clone(),
    );

    // Connect to the real-time MQTT broker
    let mut event_rx = client.connect("my-user-id", "my-device-id").await?;

    // Process incoming messages
    tokio::spawn(async move {
        while let Some(event) = event_rx.recv().await {
            if let Event::MessageReceived { sender, plaintext } = event {
                if let Ok(payload) = decode_payload(&plaintext) {
                    match payload {
                        DecodedPayload::Text { text } => println!("{}: {}", sender, text),
                        DecodedPayload::Voice { audio_bytes } => println!("Voice note ({} bytes)", audio_bytes.len()),
                        DecodedPayload::Image { caption, image_bytes, .. } => println!("Image '{}' ({} bytes)", caption, image_bytes.len()),
                    }
                }
            }
        }
    });

    // Send an encrypted text message
    let sent = client.send_text_message("recipient-id", "Hello!").await?;
    println!("Message sent with ID: {}", sent.message_id);

    client.disconnect().await?;
    Ok(())
}

Re-exports§

pub use client::ClientConfig;
pub use client::DeezChatzClient;
pub use client::SentMessage;
pub use error::SdkError;
pub use messaging::decode_payload;
pub use messaging::encode_image_payload;
pub use messaging::encode_text_payload;
pub use messaging::encode_voice_payload;
pub use messaging::DecodedPayload;
pub use messaging::InboxEntry;
pub use messaging::InboxStore;
pub use messaging::KeyStore;
pub use messaging::MessageStatus;
pub use messaging::OutboxEntry;
pub use messaging::OutboxStore;
pub use messaging::PayloadError;
pub use messaging::SessionStore;
pub use messaging::PAYLOAD_TYPE_IMAGE;
pub use messaging::PAYLOAD_TYPE_TEXT;
pub use messaging::PAYLOAD_TYPE_VOICE;
pub use transport::Event;
pub use transport::SyncBundleResponse;
pub use base64;
pub use libsignal_dezire;

Modules§

client
crypto
error
messaging
oauth
transport