From d3192641c72fc6a6d5e94fb9c15048cf50e6aff2 Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Tue, 19 Nov 2024 17:25:16 -0600 Subject: [PATCH] Fix argument types for new signing methods (#1295) --- bindings_node/CHANGELOG.md | 4 ++++ bindings_node/package.json | 2 +- bindings_node/src/client.rs | 16 +++++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bindings_node/CHANGELOG.md b/bindings_node/CHANGELOG.md index e88ddd613..4c2dbe669 100644 --- a/bindings_node/CHANGELOG.md +++ b/bindings_node/CHANGELOG.md @@ -1,5 +1,9 @@ # @xmtp/node-bindings +## 0.0.20 + +- Fixed argument types for new signing methods + ## 0.0.19 - Renamed `Level` to `LogLevel` diff --git a/bindings_node/package.json b/bindings_node/package.json index fd7ad00d8..9939f3844 100644 --- a/bindings_node/package.json +++ b/bindings_node/package.json @@ -1,6 +1,6 @@ { "name": "@xmtp/node-bindings", - "version": "0.0.19", + "version": "0.0.20", "repository": { "type": "git", "url": "git+https://git@github.com/xmtp/libxmtp.git", diff --git a/bindings_node/src/client.rs b/bindings_node/src/client.rs index 035bf9923..d2158b57c 100644 --- a/bindings_node/src/client.rs +++ b/bindings_node/src/client.rs @@ -292,37 +292,39 @@ impl Client { } #[napi] - pub fn sign_with_installation_key(&self, text: String) -> Result> { + pub fn sign_with_installation_key(&self, signature_text: String) -> Result { let result = self .inner_client .context() - .sign_with_public_context(text) + .sign_with_public_context(signature_text) .map_err(ErrorWrapper::from)?; - Ok(result) + Ok(result.into()) } #[napi] pub fn verify_signed_with_installation_key( &self, signature_text: String, - signature_bytes: Vec, + signature_bytes: Uint8Array, ) -> Result<()> { let public_key = self.inner_client().installation_public_key(); - self.verify_signed_with_public_key(signature_text, signature_bytes, public_key) + self.verify_signed_with_public_key(signature_text, signature_bytes, public_key.into()) } #[napi] pub fn verify_signed_with_public_key( &self, signature_text: String, - signature_bytes: Vec, - public_key: Vec, + signature_bytes: Uint8Array, + public_key: Uint8Array, ) -> Result<()> { + let signature_bytes = signature_bytes.deref().to_vec(); let signature_bytes: [u8; 64] = signature_bytes .try_into() .map_err(|_| Error::from_reason("signature_bytes is not 64 bytes long."))?; + let public_key = public_key.deref().to_vec(); let public_key: [u8; 32] = public_key .try_into() .map_err(|_| Error::from_reason("public_key is not 32 bytes long."))?;