Skip to content

Commit

Permalink
Add current version of the rust-sdk and vodozemac
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Oct 23, 2023
1 parent 2f3f0b3 commit 75e06fd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/unit/rust-crypto/rust-crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ describe("RustCrypto", () => {
10000,
);

it("should return the current version of the rust sdk and vodozemac", async () => {
const versions = RustSdkCryptoJs.getVersions();
expect(rustCrypto.getVersion()).toBe(
`Rust SDK ${versions.matrix_sdk_crypto}, Vodozemac ${versions.vodozemac}`,
);
});

it("should import and export keys", async () => {
const someRoomKeys = testData.MEGOLM_SESSION_DATA_ARRAY;
let importTotal = 0;
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 Rust SDK and the Vodozemac library
* @returns the version in the format `Rust SDK ${versions.matrix_sdk_crypto}, Vodozemac ${versions.vodozemac}`
* XXXX: Remove `null` when the old crypto is removed
*/
getVersion(): string | null;

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

/**
* Implementation of {@link CryptoApi#getVersion}.
*/
public getVersion(): null {
// `Crypto.getOlmVersion()` is used by the old crypto
// This API is for the new crypto
return null;
}

/**
* 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 @@ -329,6 +329,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

0 comments on commit 75e06fd

Please sign in to comment.