Skip to content

Commit

Permalink
Fix argument types for new signing methods (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine authored Nov 19, 2024
1 parent 0569cd2 commit d319264
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions bindings_node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @xmtp/node-bindings

## 0.0.20

- Fixed argument types for new signing methods

## 0.0.19

- Renamed `Level` to `LogLevel`
Expand Down
2 changes: 1 addition & 1 deletion bindings_node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xmtp/node-bindings",
"version": "0.0.19",
"version": "0.0.20",
"repository": {
"type": "git",
"url": "git+https://[email protected]/xmtp/libxmtp.git",
Expand Down
16 changes: 9 additions & 7 deletions bindings_node/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,37 +292,39 @@ impl Client {
}

#[napi]
pub fn sign_with_installation_key(&self, text: String) -> Result<Vec<u8>> {
pub fn sign_with_installation_key(&self, signature_text: String) -> Result<Uint8Array> {
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<u8>,
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<u8>,
public_key: Vec<u8>,
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."))?;
Expand Down

0 comments on commit d319264

Please sign in to comment.