Skip to main content

ping_core/
lib.rs

1//! Platform-agnostic core for the Ping messaging SDK.
2//!
3//! This crate owns OpenMLS state machines and exposes a transport-/storage-agnostic API.
4//! Native and WASM bindings are thin wrappers around [`MessagingClient`].
5
6#![deny(unsafe_code)]
7#![warn(rust_2018_idioms, missing_debug_implementations)]
8
9pub mod clock;
10pub mod codec;
11pub mod conversation;
12pub mod device;
13pub mod error;
14pub mod identity;
15pub mod log_filter;
16pub mod message;
17pub mod storage;
18pub mod sync;
19pub mod transport;
20
21mod client;
22
23pub use client::{ClientConfig, MessagingClient};
24pub use clock::Hlc;
25pub use conversation::{Conversation, ConversationId, ConversationMeta};
26pub use device::{
27    CatchupAppEventEntry, CatchupConversationEntry, CatchupSnapshot, DeviceId, DeviceInfo,
28    GroupSnapshotEntry, GroupStateSnapshot, LinkingTicket, CATCHUP_SNAPSHOT_HARD_CAP,
29    CATCHUP_SNAPSHOT_SOFT_CAP, CATCHUP_SNAPSHOT_VERSION, GROUP_SNAPSHOT_HARD_CAP,
30    GROUP_SNAPSHOT_SOFT_CAP, GROUP_SNAPSHOT_VERSION,
31};
32pub use error::{Error, Result};
33pub use identity::{Identity, UserId};
34pub use message::{IncomingMessage, MessageEnvelope, MessageKind, OutgoingMessage};
35/// [CR-4] re-export so hosts can build `ClientConfig { storage_backend: … }` without
36/// pulling `ping_mls_store` in directly.
37pub use ping_mls_store::StorageBackend;
38pub use storage::Storage;
39pub use sync::SyncCursor;
40pub use transport::{Transport, TransportSubscription};
41
42/// Wire-format version. Bumped only on incompatible envelope changes.
43///
44/// **v=2** ([CR-6](../ping-prime-architecture.md#cr-6)): for `MessageKind::Application`,
45/// `content_hash` is computed over the **plaintext** instead of the ciphertext payload.
46/// Handshake kinds (`Commit` / `Welcome` / `Proposal` / `KeyPackage`) keep the v=1 semantics
47/// — `content_hash = SHA-256(kind || payload)`. See `MessageEnvelope::new_application` for
48/// the production constructor.
49///
50/// Receivers run a 90-day dual-accept window per Q-ARCH-02: any envelope with `v ∈ {1, 2}`
51/// is structurally accepted; the validate layer routes hash-check semantics by version.
52/// Clients SHOULD refuse v=1 once the window expires.
53pub const WIRE_VERSION: u8 = 2;
54
55/// The lowest envelope version that receivers will accept during the CR-6 dual-accept
56/// transition. Bumped to `2` after the window closes; until then it stays at `1` so we
57/// keep accepting messages produced by un-updated senders.
58pub const WIRE_VERSION_MIN_ACCEPTED: u8 = 1;