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