diff --git a/spec/unit/crypto.spec.ts b/spec/unit/crypto.spec.ts index 17c7bc4f856..bb21efd34b9 100644 --- a/spec/unit/crypto.spec.ts +++ b/spec/unit/crypto.spec.ts @@ -115,6 +115,16 @@ describe("Crypto", function () { expect(Crypto.getOlmVersion()[0]).toEqual(3); }); + it("getVersion() should return the current version of the olm library", async () => { + const client = new TestClient("@alice:example.com", "deviceid").client; + await client.initCrypto(); + + const olmVersionTuple = Crypto.getOlmVersion(); + expect(client.getCrypto()?.getVersion()).toBe( + `Olm ${olmVersionTuple[0]}.${olmVersionTuple[1]}.${olmVersionTuple[2]}`, + ); + }); + describe("encrypted events", function () { it("provides encryption information for events from unverified senders", async function () { const client = new TestClient("@alice:example.com", "deviceid").client; diff --git a/spec/unit/rust-crypto/rust-crypto.spec.ts b/spec/unit/rust-crypto/rust-crypto.spec.ts index d8eae7f4d48..4d6973084f5 100644 --- a/spec/unit/rust-crypto/rust-crypto.spec.ts +++ b/spec/unit/rust-crypto/rust-crypto.spec.ts @@ -132,6 +132,12 @@ describe("initRustCrypto", () => { }); describe("RustCrypto", () => { + it("getVersion() should return the current version of the rust sdk and vodozemac", async () => { + const rustCrypto = await makeTestRustCrypto(); + const versions = RustSdkCryptoJs.getVersions(); + expect(rustCrypto.getVersion()).toBe(`Rust SDK ${versions.matrix_sdk_crypto}, Vodozemac ${versions.vodozemac}`); + }); + describe(".importRoomKeys and .exportRoomKeys", () => { let rustCrypto: RustCrypto; diff --git a/src/crypto-api.ts b/src/crypto-api.ts index b698fc296e6..daa6ad86cf2 100644 --- a/src/crypto-api.ts +++ b/src/crypto-api.ts @@ -39,6 +39,13 @@ export interface CryptoApi { */ globalBlacklistUnverifiedDevices: boolean; + /** + * Return the current version of the crypto module. + * For example: `Rust SDK ${versions.matrix_sdk_crypto}, Vodozemac ${versions.vodozemac}`. + * @returns the formatted version + */ + getVersion(): string; + /** * Perform any background tasks that can be done before a message is ready to * send, in order to speed up sending of the message. diff --git a/src/crypto/index.ts b/src/crypto/index.ts index a2a6469feda..f643491cf05 100644 --- a/src/crypto/index.ts +++ b/src/crypto/index.ts @@ -610,6 +610,14 @@ export class Crypto extends TypedEventEmitter