Skip to content

Commit

Permalink
Add a couple wasm bindgens and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
coreymartin committed Sep 26, 2023
1 parent 7077dca commit 2b276b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down
11 changes: 11 additions & 0 deletions src/remote_signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,6 +34,14 @@ impl fmt::Display for RemoteSigningError {
}
}

impl std::error::Error for RemoteSigningError {}

impl From<RemoteSigningError> for JsValue {
fn from(val: RemoteSigningError) -> Self {
JsError::from(val).into()
}
}

pub fn handle_remote_signing_webhook_event(
webhook_data: Vec<u8>,
webhook_signature: String,
Expand Down

0 comments on commit 2b276b1

Please sign in to comment.