mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-07 07:27:45 -04:00
Re-expose the vodozemac and matrix-sdk-crypto versions in the bindings
This commit is contained in:
committed by
Ivan Enderlin
parent
fe69948926
commit
3aa1c30f5c
@@ -840,6 +840,9 @@ fn parse_user_id(user_id: &str) -> Result<OwnedUserId, CryptoStoreError> {
|
||||
}
|
||||
|
||||
mod uniffi_types {
|
||||
pub use matrix_sdk_crypto::VERSION;
|
||||
pub use vodozemac::VERSION as VODOZEMAC_VERSION;
|
||||
|
||||
pub use crate::{
|
||||
backup_recovery_key::{
|
||||
BackupRecoveryKey, DecodeError, MegolmV1BackupKey, PassphraseInfo, PkDecryptionError,
|
||||
|
||||
@@ -40,6 +40,27 @@ pub mod vodozemac;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
/// Object containing the versions of the Rust libraries we are using.
|
||||
#[wasm_bindgen(getter_with_clone)]
|
||||
#[derive(Debug)]
|
||||
pub struct Versions {
|
||||
/// The version of the vodozemac crate.
|
||||
#[wasm_bindgen(readonly)]
|
||||
pub vodozemac: &'static str,
|
||||
/// The version of the matrix-sdk-crypto crate.
|
||||
#[wasm_bindgen(readonly)]
|
||||
pub matrix_sdk_crypto: &'static str,
|
||||
}
|
||||
|
||||
/// Get the versions of the Rust libraries we are using.
|
||||
#[wasm_bindgen(js_name = "getVersions")]
|
||||
pub fn get_versions() -> Versions {
|
||||
Versions {
|
||||
vodozemac: matrix_sdk_crypto::vodozemac::VERSION,
|
||||
matrix_sdk_crypto: matrix_sdk_crypto::VERSION,
|
||||
}
|
||||
}
|
||||
|
||||
/// Run some stuff when the Wasm module is instantiated.
|
||||
///
|
||||
/// Right now, it does the following:
|
||||
|
||||
@@ -7,7 +7,6 @@ const {
|
||||
EncryptionSettings,
|
||||
EventId,
|
||||
InboundGroupSession,
|
||||
KeysClaimRequest,
|
||||
KeysQueryRequest,
|
||||
KeysUploadRequest,
|
||||
MaybeSignature,
|
||||
@@ -16,16 +15,30 @@ const {
|
||||
RequestType,
|
||||
RoomId,
|
||||
RoomMessageRequest,
|
||||
ShieldColor,
|
||||
SignatureUploadRequest,
|
||||
ToDeviceRequest,
|
||||
UserId,
|
||||
UserIdentity,
|
||||
VerificationRequest,
|
||||
ShieldColor,
|
||||
VerificationState,
|
||||
Versions,
|
||||
getVersions,
|
||||
} = require("../pkg/matrix_sdk_crypto_js");
|
||||
const { addMachineToMachine } = require("./helper");
|
||||
require("fake-indexeddb/auto");
|
||||
|
||||
describe("Versions", () => {
|
||||
test("can find out the crate versions", async () => {
|
||||
const versions = getVersions();
|
||||
|
||||
expect(versions).toBeInstanceOf(Versions)
|
||||
expect(versions.vodozemac).toBeDefined()
|
||||
expect(versions.matrix_sdk_crypto).toBeDefined()
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe(OlmMachine.name, () => {
|
||||
test("can be instantiated with the async initializer", async () => {
|
||||
expect(await OlmMachine.initialize(new UserId("@foo:bar.org"), new DeviceId("baz"))).toBeInstanceOf(OlmMachine);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
//#![warn(missing_docs, missing_debug_implementations)]
|
||||
|
||||
use napi_derive::napi;
|
||||
|
||||
pub mod attachment;
|
||||
pub mod encryption;
|
||||
mod errors;
|
||||
@@ -31,4 +33,25 @@ pub mod tracing;
|
||||
pub mod types;
|
||||
pub mod vodozemac;
|
||||
|
||||
/// Object containing the versions of the Rust libraries we are using.
|
||||
#[napi(object)]
|
||||
pub struct Versions {
|
||||
/// The version of the vodozemac crate.
|
||||
#[napi(getter)]
|
||||
pub vodozemac: &'static str,
|
||||
|
||||
/// The version of the matrix-sdk-crypto crate.
|
||||
#[napi(getter)]
|
||||
pub matrix_sdk_crypto: &'static str,
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
}
|
||||
|
||||
use crate::errors::into_err;
|
||||
|
||||
@@ -14,8 +14,10 @@ const {
|
||||
VerificationState,
|
||||
CrossSigningStatus,
|
||||
MaybeSignature,
|
||||
StoreType,
|
||||
ShieldColor,
|
||||
StoreType,
|
||||
Versions,
|
||||
getVersions,
|
||||
} = require("../");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
@@ -28,6 +30,17 @@ describe("StoreType", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Versions", () => {
|
||||
test("can find out the crate versions", async () => {
|
||||
const versions = getVersions();
|
||||
|
||||
expect(versions).toBeInstanceOf(Versions)
|
||||
expect(versions.vodozemac).toBeDefined()
|
||||
expect(versions.matrix_sdk_crypto).toBeDefined()
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe(OlmMachine.name, () => {
|
||||
test("cannot be instantiated with the constructor", () => {
|
||||
expect(() => {
|
||||
|
||||
Reference in New Issue
Block a user