Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move version function to module [WPB-15329] #867

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crypto-ffi/bindings/js/src/CoreCrypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
CoreCryptoLogLevel,
setMaxLogLevel,
buildMetadata,
version,
CoreCrypto,
} from "./CoreCryptoInstance.js";
export type {
Expand Down
19 changes: 10 additions & 9 deletions crypto-ffi/bindings/js/src/CoreCryptoInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
}
}
13 changes: 13 additions & 0 deletions crypto-ffi/bindings/js/test/CoreCrypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading