//! # SigSocket Client //! //! A WebSocket client library for connecting to sigsocket servers with WASM-first support. //! //! This library provides a unified interface for both native and WASM environments, //! allowing applications to connect to sigsocket servers using a public key and handle //! incoming signature requests. //! //! ## Features //! //! - **WASM-first design**: Optimized for browser environments //! - **Native support**: Works in native Rust applications //! - **No signing logic**: Delegates signing to the application //! - **User approval flow**: Notifies applications about incoming requests //! - **sigsocket compatible**: Fully compatible with sigsocket server protocol //! //! ## Example //! //! ```rust,no_run //! use sigsocket_client::{SigSocketClient, SignRequest, SignRequestHandler, Result}; //! //! struct MyHandler; //! impl SignRequestHandler for MyHandler { //! fn handle_sign_request(&self, _request: &SignRequest) -> Result> { //! Ok(b"fake_signature".to_vec()) //! } //! } //! //! #[tokio::main] //! async fn main() -> Result<()> { //! // Create client with public key //! let public_key = hex::decode("02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9").unwrap(); //! let mut client = SigSocketClient::new("ws://localhost:8080/ws", public_key)?; //! //! // Set up request handler //! client.set_sign_handler(MyHandler); //! //! // Connect to server //! client.connect().await?; //! Ok(()) //! } //! ``` #![cfg_attr(target_arch = "wasm32", no_std)] #[cfg(target_arch = "wasm32")] extern crate alloc; #[cfg(target_arch = "wasm32")] use alloc::{string::String, vec::Vec}; mod error; mod protocol; mod client; #[cfg(not(target_arch = "wasm32"))] mod native; #[cfg(target_arch = "wasm32")] mod wasm; pub use error::{SigSocketError, Result}; pub use protocol::{SignRequest, SignResponse, ManagedSignRequest, RequestStatus}; pub use client::{SigSocketClient, SignRequestHandler, ConnectionState}; // Re-export for convenience pub mod prelude { pub use crate::{ SigSocketClient, SignRequest, SignResponse, ManagedSignRequest, RequestStatus, SignRequestHandler, ConnectionState, SigSocketError, Result }; }