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 storage_blob;
19pub mod sync;
20pub mod transport;
21
22mod client;
23
24pub use client::{AdmitChatOutcome, AdmitChatStatus, ClientConfig, MessagingClient};
25pub use clock::Hlc;
26pub use conversation::{Conversation, ConversationId, ConversationMeta, MemberInfo};
27pub use device::{
28 CatchupAppEventEntry, CatchupConversationEntry, CatchupSnapshot, DeviceId, DeviceInfo,
29 GroupSnapshotEntry, GroupStateSnapshot, LinkingTicket, CATCHUP_SNAPSHOT_HARD_CAP,
30 CATCHUP_SNAPSHOT_SOFT_CAP, CATCHUP_SNAPSHOT_VERSION, GROUP_SNAPSHOT_HARD_CAP,
31 GROUP_SNAPSHOT_SOFT_CAP, GROUP_SNAPSHOT_VERSION,
32};
33pub use error::{Error, Result};
34pub use identity::{Identity, UserId};
35pub use message::{IncomingMessage, MessageEnvelope, MessageKind, OutgoingMessage};
36/// [CR-4] re-export so hosts can build `ClientConfig { storage_backend: … }` without
37/// pulling `ping_mls_store` in directly. `AsyncBlobStore` is the async
38/// single-blob trait WASM hosts implement to back `StorageBackend::IndexedDb`;
39/// `BlobFuture` is the matching future-type helper.
40pub use ping_mls_store::{AsyncBlobStore, BlobFuture, StorageBackend};
41pub use storage::Storage;
42/// [CR-4] Wrap an `Arc<dyn Storage>` as the single-blob backend the
43/// persistent provider needs. Hosts pass the result as
44/// `StorageBackend::AsyncBlob { blob_store }` to opt their existing
45/// Storage trait into MLS-state persistence with no extra wiring.
46pub use storage_blob::storage_as_blob_store;
47pub use sync::SyncCursor;
48pub use transport::{Transport, TransportSubscription};
49
50/// Wire-format version. Bumped only on incompatible envelope changes.
51///
52/// **v=2** ([CR-6](../ping-prime-architecture.md#cr-6)): for `MessageKind::Application`,
53/// `content_hash` is computed over the **plaintext** instead of the ciphertext payload.
54/// Handshake kinds (`Commit` / `Welcome` / `Proposal` / `KeyPackage`) keep the v=1 semantics
55/// — `content_hash = SHA-256(kind || payload)`. See `MessageEnvelope::new_application` for
56/// the production constructor.
57///
58/// Receivers run a 90-day dual-accept window per Q-ARCH-02: any envelope with `v ∈ {1, 2}`
59/// is structurally accepted; the validate layer routes hash-check semantics by version.
60/// Clients SHOULD refuse v=1 once the window expires.
61pub const WIRE_VERSION: u8 = 2;
62
63/// The lowest envelope version that receivers will accept during the CR-6 dual-accept
64/// transition. Bumped to `2` after the window closes; until then it stays at `1` so we
65/// keep accepting messages produced by un-updated senders.
66pub const WIRE_VERSION_MIN_ACCEPTED: u8 = 1;