From c2d3afffffe9f3385bb768b97599057aa48b0253 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 16 Mar 2023 10:33:41 +0100 Subject: [PATCH] feat(crypto-nodejs): Make `Versions` a class, not a JS object. --- bindings/matrix-sdk-crypto-nodejs/src/lib.rs | 10 +++++----- .../matrix-sdk-crypto-nodejs/tests/machine.test.js | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bindings/matrix-sdk-crypto-nodejs/src/lib.rs b/bindings/matrix-sdk-crypto-nodejs/src/lib.rs index 98a90bcea..540204be7 100644 --- a/bindings/matrix-sdk-crypto-nodejs/src/lib.rs +++ b/bindings/matrix-sdk-crypto-nodejs/src/lib.rs @@ -34,23 +34,23 @@ pub mod types; pub mod vodozemac; /// Object containing the versions of the Rust libraries we are using. -#[napi(object)] +#[napi] pub struct Versions { /// The version of the vodozemac crate. #[napi(getter)] - pub vodozemac: &'static str, + pub vodozemac: String, /// The version of the matrix-sdk-crypto crate. #[napi(getter)] - pub matrix_sdk_crypto: &'static str, + pub matrix_sdk_crypto: String, } /// Get the versions of the Rust libraries we are using. #[napi(js_name = "getVersions")] pub fn get_versions() -> Versions { Versions { - vodozemac: matrix_sdk_crypto::vodozemac::VERSION, - matrix_sdk_crypto: matrix_sdk_crypto::VERSION, + vodozemac: matrix_sdk_crypto::vodozemac::VERSION.to_owned(), + matrix_sdk_crypto: matrix_sdk_crypto::VERSION.to_owned(), } } diff --git a/bindings/matrix-sdk-crypto-nodejs/tests/machine.test.js b/bindings/matrix-sdk-crypto-nodejs/tests/machine.test.js index 50a4a83b9..86b93533b 100644 --- a/bindings/matrix-sdk-crypto-nodejs/tests/machine.test.js +++ b/bindings/matrix-sdk-crypto-nodejs/tests/machine.test.js @@ -36,8 +36,9 @@ describe("Versions", () => { expect(versions).toBeInstanceOf(Versions); expect(versions.vodozemac).toBeDefined(); - expect(versions.matrix_sdk_crypto).toBeDefined(); + expect(versions.matrixSdkCrypto).toBeDefined(); }); + }); describe(OlmMachine.name, () => {