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

Element-R: Add current version of the rust-sdk and vodozemac #3825

Merged
merged 7 commits into from
Oct 25, 2023
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
10 changes: 10 additions & 0 deletions spec/unit/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/rust-crypto/rust-crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions src/crypto-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/crypto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
this.backupManager.checkAndStart();
}

/**
* Implementation of {@link CryptoApi#getVersion}.
*/
public getVersion(): string {
const olmVersionTuple = Crypto.getOlmVersion();
return `Olm ${olmVersionTuple[0]}.${olmVersionTuple[1]}.${olmVersionTuple[2]}`;
}

/**
* Whether to trust a others users signatures of their devices.
* If false, devices will only be considered 'verified' if we have
Expand Down
8 changes: 8 additions & 0 deletions src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv

public globalBlacklistUnverifiedDevices = false;

/**
* Implementation of {@link CryptoApi#getVersion}.
*/
public getVersion(): string {
const versions = RustSdkCryptoJs.getVersions();
return `Rust SDK ${versions.matrix_sdk_crypto}, Vodozemac ${versions.vodozemac}`;
}

public prepareToEncrypt(room: Room): void {
const encryptor = this.roomEncryptors[room.roomId];

Expand Down
Loading