Skip to main content

max / synckit-client

1.8 KB · 58 lines History Blame Raw
1 //! SyncKit Client SDK — end-to-end encrypted cloud sync.
2 //!
3 //! All row data is encrypted client-side before leaving the device.
4 //! The server only ever sees ciphertext.
5 //!
6 //! # Quick start
7 //!
8 //! ```no_run
9 //! use synckit_client::{SyncKitClient, SyncKitConfig, ChangeEntry, ChangeOp};
10 //! use chrono::Utc;
11 //!
12 //! # async fn example() -> synckit_client::Result<()> {
13 //! let client = SyncKitClient::new(SyncKitConfig {
14 //! server_url: "https://makenot.work".into(),
15 //! api_key: "your-api-key".into(),
16 //! });
17 //!
18 //! // Authenticate
19 //! let (user_id, app_id) = client.authenticate("user@example.com", "password").await?;
20 //!
21 //! // Set up encryption (first device)
22 //! client.setup_encryption_new("password").await?;
23 //!
24 //! // Register this device
25 //! let device = client.register_device("MacBook Pro", "macos").await?;
26 //!
27 //! // Push encrypted data
28 //! let cursor = client.push(device.id, vec![
29 //! ChangeEntry {
30 //! table: "tasks".into(),
31 //! op: ChangeOp::Insert,
32 //! row_id: uuid::Uuid::new_v4().to_string(),
33 //! timestamp: Utc::now(),
34 //! data: Some(serde_json::json!({"title": "Buy milk"})),
35 //! },
36 //! ]).await?;
37 //!
38 //! // Pull and auto-decrypt
39 //! let (changes, cursor, has_more) = client.pull(device.id, 0).await?;
40 //! # Ok(())
41 //! # }
42 //! ```
43
44 pub mod client;
45 pub mod conflict;
46 pub mod crypto;
47 pub mod error;
48 pub mod keystore;
49 pub mod types;
50
51 // Re-exports for convenience
52 pub use client::{validate_api_key, SessionInfo, SyncKitClient, SyncKitConfig, SyncNotifyStream};
53 pub use conflict::{
54 detect_conflicts, resolve_field_merge, resolve_lww, ConflictPair, ConflictResolver, Resolution,
55 };
56 pub use error::{Result, SyncKitError};
57 pub use types::{ChangeEntry, ChangeOp, Device, PullFilter, PulledChange, SyncStatus};
58