opencord 0.2.1

Open-source ephemeral chat servers with automatic shutdown
Documentation
use serde::{Deserialize, Serialize};

/// Messages exchanged between clients and the server.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum Message {
    /// A client is joining with a chosen display name and access code.
    Join { name: String, code: String },

    /// A text message from a client.
    Text { name: String, content: String },

    /// A client has left.
    Leave { name: String },

    /// Client requests to extend the server lifetime (host only).
    Extend { minutes: u64 },

    /// Server tells a client whether they are the host, sent on connect.
    Welcome { host: bool },

    /// Server notification to all clients (warnings, confirmations).
    SystemMessage { content: String },

    /// A client's ephemeral X25519 public key, broadcast to all peers.
    /// The server relays this but can't do anything with it — only the
    /// corresponding secret key holder can derive a shared secret.
    KeyExchange { name: String, public_key: String },

    /// The host sends the AES-256 group key to a specific peer, encrypted
    /// with their pairwise DH-derived key. Broadcast to all, but only the
    /// named `to` recipient can decrypt it.
    GroupKey { to: String, encrypted_key: String },

    /// An encrypted text message. Replaces `Text` once E2E keys are established.
    /// `name` stays plaintext (server already knows the sender), but the actual
    /// content is AES-256-GCM ciphertext.
    EncryptedText {
        name: String,
        nonce: String,
        ciphertext: String,
    },
}