Skip to content

Commit

Permalink
minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Jul 26, 2023
1 parent a3234c3 commit 3db0167
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion spec/integ/crypto/megolm-backup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("megolm-keys backup (%s)", (backe

await backupEnabled;

const backupStatus = aliceClient.getCrypto()!.getActiveSessionBackupVersion();
const backupStatus = await aliceClient.getCrypto()!.getActiveSessionBackupVersion();
expect(backupStatus).toBeDefined();
expect(backupStatus).toStrictEqual(backupVersion);
});
Expand Down
10 changes: 5 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3354,12 +3354,12 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
password?: string | Uint8Array | null,
opts: IKeyBackupPrepareOpts = { secureSecretStorage: false },
): Promise<Pick<IPreparedKeyBackupVersion, "algorithm" | "auth_data" | "recovery_key">> {
if (!this.getCrypto()) {
if (!this.cryptoBackend) {
throw new Error("End-to-end encryption disabled");
}

// eslint-disable-next-line camelcase
const { algorithm, auth_data, recovery_key, privateKey } = await this.getCrypto()!.prepareKeyBackupVersion(
const { algorithm, auth_data, recovery_key, privateKey } = await this.cryptoBackend.prepareKeyBackupVersion(
password,
);

Expand Down Expand Up @@ -3395,11 +3395,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @returns Object with 'version' param indicating the version created
*/
public async createKeyBackupVersion(info: IKeyBackupInfo): Promise<IKeyBackupInfo> {
if (!this.getCrypto()) {
if (!this.cryptoBackend) {
throw new Error("End-to-end encryption disabled");
}

await this.getCrypto()!.getBackupManager().createKeyBackupVersion(info);
await this.cryptoBackend.backupManager.createKeyBackupVersion(info);

const data = {
algorithm: info.algorithm,
Expand All @@ -3414,7 +3414,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
// we run the same signature verification that will be used for future
// sessions.
await this.checkKeyBackup();
if (!this.getKeyBackupEnabled()) {
if (!(await this.cryptoBackend.getActiveSessionBackupVersion())) {
logger.error("Key backup not usable even though we just created it");
}

Expand Down

0 comments on commit 3db0167

Please sign in to comment.