hakanai_lib/
lib.rs

1//! Zero-knowledge secret sharing client library for Hakanai.
2//!
3//! This library provides a complete client implementation for sending and receiving
4//! ephemeral secrets using the Hakanai service. All encryption and decryption
5//! happens client-side, ensuring the server never has access to plaintext data.
6//!
7//! # Architecture
8//!
9//! The library uses a layered client architecture:
10//! - `WebClient` - Handles HTTP communication
11//! - `CryptoClient` - Adds AES-256-GCM encryption/decryption
12//! - `SecretClient` - Handles `Payload` serialization/deserialization
13//!
14//! # Examples
15//!
16//! ## Basic Usage
17//!
18//! ```no_run
19//! use hakanai_lib::{client, client::Client};
20//! use std::time::Duration;
21//! use url::Url;
22//!
23//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
24//! // Create a client with the default configuration
25//! let client = client::new();
26//!
27//! // Send a text secret
28//! let secret_url = client.send_secret(
29//!     Url::parse("https://example.com")?,
30//!     hakanai_lib::models::Payload {
31//!         data: "My secret message".to_string(),
32//!         filename: None,
33//!     },
34//!     Duration::from_secs(3600), // 1 hour TTL
35//!     "auth-token".to_string(),
36//!     None, // No custom options
37//! ).await?;
38//!
39//! println!("Secret URL: {}", secret_url);
40//!
41//! // Receive the secret (normally done by recipient)
42//! let payload = client.receive_secret(secret_url, None).await?;
43//! println!("Retrieved: {}", payload.data);
44//! # Ok(())
45//! # }
46//! ```
47//!
48//! ## Sending Binary Files
49//!
50//! ```no_run
51//! use hakanai_lib::{client, client::Client, models::Payload};
52//! use std::time::Duration;
53//! use url::Url;
54//!
55//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
56//! let client = client::new();
57//!
58//! // Read file and create payload
59//! let file_contents = std::fs::read("document.pdf")?;
60//! let payload = Payload::from_bytes(&file_contents, Some("document.pdf".to_string()));
61//!
62//! // Send the file
63//! let secret_url = client.send_secret(
64//!     Url::parse("https://example.com")?,
65//!     payload,
66//!     Duration::from_secs(86400), // 24 hour TTL
67//!     "auth-token".to_string(),
68//!     None,
69//! ).await?;
70//!
71//! println!("File shared at: {}", secret_url);
72//! # Ok(())
73//! # }
74//! ```
75//!
76//! ## Using Progress Monitoring
77//!
78//! ```no_run
79//! use hakanai_lib::{client, client::Client, models::Payload, options::SecretSendOptions};
80//! use hakanai_lib::observer::DataTransferObserver;
81//! use std::sync::Arc;
82//! use std::time::Duration;
83//! use url::Url;
84//!
85//! struct ProgressReporter;
86//!
87//! #[async_trait::async_trait]
88//! impl DataTransferObserver for ProgressReporter {
89//!     async fn on_progress(&self, bytes_transferred: u64, total_bytes: u64) {
90//!         println!("Progress: {:.1}%", (bytes_transferred as f64 / total_bytes as f64) * 100.0);
91//!     }
92//! }
93//!
94//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
95//! let client = client::new();
96//! let options = SecretSendOptions::new().with_observer(Arc::new(ProgressReporter));
97//!
98//! client.send_secret(
99//!     Url::parse("https://example.com")?,
100//!     Payload { data: "Secret data".to_string(), filename: None },
101//!     Duration::from_secs(3600),
102//!     "auth-token".to_string(),
103//!     Some(options),
104//! ).await?;
105//! # Ok(())
106//! # }
107//! ```
108//!
109//!
110//!
111
112pub mod client;
113#[cfg(any(test, feature = "testing"))]
114pub mod client_mock;
115mod crypto;
116pub mod models;
117pub mod observer;
118pub mod options;
119pub mod timestamp;
120pub mod utils;
121mod web;