diff --git a/crypto-ffi/bindings/js/src/CoreCrypto.ts b/crypto-ffi/bindings/js/src/CoreCrypto.ts index e56853722e..31b32d4427 100644 --- a/crypto-ffi/bindings/js/src/CoreCrypto.ts +++ b/crypto-ffi/bindings/js/src/CoreCrypto.ts @@ -26,6 +26,7 @@ export { CoreCryptoLogLevel, setMaxLogLevel, buildMetadata, + version, CoreCrypto, } from "./CoreCryptoInstance.js"; export type { diff --git a/crypto-ffi/bindings/js/src/CoreCryptoInstance.ts b/crypto-ffi/bindings/js/src/CoreCryptoInstance.ts index 9eea4a95d7..2e66341500 100644 --- a/crypto-ffi/bindings/js/src/CoreCryptoInstance.ts +++ b/crypto-ffi/bindings/js/src/CoreCryptoInstance.ts @@ -172,6 +172,16 @@ export function setMaxLogLevel(level: CoreCryptoLogLevel): void { export function buildMetadata(): CoreCryptoFfiTypes.BuildMetadata { return CoreCryptoFfi.build_metadata(); } + +/** + * Returns the current version of {@link CoreCrypto} + * + * @returns the CoreCrypto version as a string (e.g. "3.1.2") + */ +export function version(): string { + return CoreCryptoFfi.version(); +} + /** * Wrapper for the WASM-compiled version of CoreCrypto */ @@ -1340,13 +1350,4 @@ export class CoreCrypto { ); return normalizeEnum(E2eiConversationState, state); } - - /** - * Returns the current version of {@link CoreCrypto} - * - * @returns The `core-crypto-ffi` version as defined in its `Cargo.toml` file - */ - static version(): string { - return CoreCryptoFfi.version(); - } } diff --git a/crypto-ffi/bindings/js/test/CoreCrypto.test.ts b/crypto-ffi/bindings/js/test/CoreCrypto.test.ts index 7693f9f988..e88e00ce70 100644 --- a/crypto-ffi/bindings/js/test/CoreCrypto.test.ts +++ b/crypto-ffi/bindings/js/test/CoreCrypto.test.ts @@ -878,6 +878,19 @@ describe("build", () => { }); }); +describe("build", () => { + it("version can be retrieved and is a semantic version number", async () => { + await expect( + browser.execute(async () => window.ccModule.version()) + ).resolves.toMatch( + RegExp( + // Regex for matching semantic versions from https://semver.org + "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$" + ) + ); + }); +}); + describe("Error type mapping", () => { it("should work for conversation already exists", async () => { await ccInit(ALICE_ID);