diff --git a/src/lib.rs b/src/lib.rs index 88d0068..c276c25 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,15 +2,25 @@ pub mod crypto; pub mod remote_signing; pub mod signer; +#[cfg(not(target_arch = "wasm32"))] use crypto::decrypt_ecies; +#[cfg(not(target_arch = "wasm32"))] use crypto::encrypt_ecies; +#[cfg(not(target_arch = "wasm32"))] use crypto::generate_keypair; +#[cfg(not(target_arch = "wasm32"))] use crypto::sign_ecdsa; +#[cfg(not(target_arch = "wasm32"))] use crypto::verify_ecdsa; +#[cfg(not(target_arch = "wasm32"))] use crypto::CryptoError; +#[cfg(not(target_arch = "wasm32"))] use lightspark_remote_signing::validation::Validation; +#[cfg(not(target_arch = "wasm32"))] use remote_signing::handle_remote_signing_webhook_event; +#[cfg(not(target_arch = "wasm32"))] use remote_signing::RemoteSigningError; +#[cfg(not(target_arch = "wasm32"))] use remote_signing::RemoteSigningResponse; #[cfg(not(target_arch = "wasm32"))] diff --git a/src/remote_signing.rs b/src/remote_signing.rs index 0bc843a..6710d51 100644 --- a/src/remote_signing.rs +++ b/src/remote_signing.rs @@ -6,12 +6,15 @@ use lightspark_remote_signing::{ signer::{LightsparkSigner, Network, Seed}, validation::Validation, }; +use wasm_bindgen::prelude::*; +use wasm_bindgen::{JsError, JsValue}; pub struct RemoteSigningResponse { pub query: String, pub variables: String, } +#[wasm_bindgen] #[derive(Clone, Copy, Debug)] pub enum RemoteSigningError { WebhookParsingError, @@ -31,6 +34,14 @@ impl fmt::Display for RemoteSigningError { } } +impl std::error::Error for RemoteSigningError {} + +impl From for JsValue { + fn from(val: RemoteSigningError) -> Self { + JsError::from(val).into() + } +} + pub fn handle_remote_signing_webhook_event( webhook_data: Vec, webhook_signature: String,