Skip to main content

max / makenotwork

2.2 KB · 65 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 (the third arg is the developer-defined SDK key for
19 //! // billing attribution — typically one per workspace/org/end-user).
20 //! let (user_id, app_id) = client.authenticate("user@example.com", "password", "workspace-42").await?;
21 //!
22 //! // Set up encryption (first device)
23 //! client.setup_encryption_new("password").await?;
24 //!
25 //! // Register this device
26 //! let device = client.register_device("MacBook Pro", "macos").await?;
27 //!
28 //! // Push encrypted data
29 //! let cursor = client.push(device.id, vec![
30 //! ChangeEntry {
31 //! table: "tasks".into(),
32 //! op: ChangeOp::Insert,
33 //! row_id: uuid::Uuid::new_v4().to_string(),
34 //! timestamp: Utc::now(),
35 //! data: Some(serde_json::json!({"title": "Buy milk"})),
36 //! },
37 //! ]).await?;
38 //!
39 //! // Pull and auto-decrypt
40 //! let (changes, cursor, has_more) = client.pull(device.id, 0).await?;
41 //! # Ok(())
42 //! # }
43 //! ```
44
45 pub mod client;
46 pub mod conflict;
47 pub mod crypto;
48 pub mod error;
49 pub mod keystore;
50 pub mod oauth;
51 pub mod types;
52
53 // Re-exports for convenience
54 pub use client::{validate_api_key, SessionInfo, SyncKitClient, SyncKitConfig, SyncNotifyStream};
55 pub use client::{OtaArtifactUpload, OtaManifest, OtaRelease};
56 pub use oauth::{generate_oauth_state, generate_pkce, Pkce};
57 pub use client::subscription::{
58 AccountInfo, AppPricing, BillingInterval, CheckoutResponse, PriceQuote, SubscriptionStatus,
59 };
60 pub use conflict::{
61 detect_conflicts, resolve_field_merge, resolve_lww, ConflictPair, ConflictResolver, Resolution,
62 };
63 pub use error::{Result, SyncKitError};
64 pub use types::{ChangeEntry, ChangeOp, Device, PullFilter, PulledChange, SyncStatus};
65