diff --git a/spec/unit/rust-crypto/backup.spec.ts b/spec/unit/rust-crypto/backup.spec.ts index 4b96c74f7c..ab5b740ee6 100644 --- a/spec/unit/rust-crypto/backup.spec.ts +++ b/spec/unit/rust-crypto/backup.spec.ts @@ -3,13 +3,11 @@ import fetchMock from "fetch-mock-jest"; import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm"; import { HttpApiEvent, HttpApiEventHandlerMap, MatrixHttpApi, TypedEventEmitter } from "../../../src"; -import { CryptoEvent } from "../../../src/crypto-api/index.ts"; +import { CryptoEvent, KeyBackupSession } from "../../../src/crypto-api/index.ts"; import { OutgoingRequestProcessor } from "../../../src/rust-crypto/OutgoingRequestProcessor"; import * as testData from "../../test-utils/test-data"; import * as TestData from "../../test-utils/test-data"; -import { IKeyBackup } from "../../../src/crypto/backup"; -import { IKeyBackupSession } from "../../../src/crypto/keybackup"; -import { RustBackupManager } from "../../../src/rust-crypto/backup"; +import { RustBackupManager, KeyBackup } from "../../../src/rust-crypto/backup"; describe("Upload keys to backup", () => { /** The backup manager under test */ @@ -27,7 +25,7 @@ describe("Upload keys to backup", () => { let idGenerator = 0; function mockBackupRequest(keyCount: number): RustSdkCryptoJs.KeysBackupRequest { - const requestBody: IKeyBackup = { + const requestBody: KeyBackup = { rooms: { "!room1:server": { sessions: {}, @@ -35,7 +33,7 @@ describe("Upload keys to backup", () => { }, }; for (let i = 0; i < keyCount; i++) { - requestBody.rooms["!room1:server"].sessions["session" + i] = {} as IKeyBackupSession; + requestBody.rooms["!room1:server"].sessions["session" + i] = {} as KeyBackupSession; } return { id: "id" + idGenerator++, diff --git a/src/rust-crypto/backup.ts b/src/rust-crypto/backup.ts index d4a91bd0fa..63d1afdb02 100644 --- a/src/rust-crypto/backup.ts +++ b/src/rust-crypto/backup.ts @@ -24,6 +24,7 @@ import { KeyBackupInfo, KeyBackupSession, Curve25519SessionData, + KeyBackupRoomSessions, } from "../crypto-api/keybackup.ts"; import { logger } from "../logger.ts"; import { ClientPrefix, IHttpOpts, MatrixError, MatrixHttpApi, Method } from "../http-api/index.ts"; @@ -34,8 +35,6 @@ import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor.ts"; import { sleep } from "../utils.ts"; import { BackupDecryptor } from "../common-crypto/CryptoBackend.ts"; import { ImportRoomKeyProgressData, ImportRoomKeysOpts, CryptoEvent } from "../crypto-api/index.ts"; -import { IKeyBackupInfo } from "../crypto/keybackup.ts"; -import { IKeyBackup } from "../crypto/backup.ts"; import { AESEncryptedSecretStoragePayload } from "../@types/AESEncryptedSecretStoragePayload.ts"; /** Authentification of the backup info, depends on algorithm */ @@ -488,7 +487,7 @@ export class RustBackupManager extends TypedEventEmitter, -): Promise { +): Promise { try { return await http.authedRequest(Method.Get, "/room_keys/version", undefined, undefined, { prefix: ClientPrefix.V3, @@ -679,3 +678,11 @@ export type RustBackupCryptoEventMap = { [CryptoEvent.KeyBackupFailed]: (errCode: string) => void; [CryptoEvent.KeyBackupDecryptionKeyCached]: (version: string) => void; }; + +/** + * Response from GET `/room_keys/keys` endpoint. + * See https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3room_keyskeys + */ +export interface KeyBackup { + rooms: Record; +}