@@ -24,6 +24,7 @@ import {
2424 KeyBackupInfo ,
2525 KeyBackupSession ,
2626 Curve25519SessionData ,
27+ KeyBackupRoomSessions ,
2728} from "../crypto-api/keybackup.ts" ;
2829import { logger } from "../logger.ts" ;
2930import { ClientPrefix , IHttpOpts , MatrixError , MatrixHttpApi , Method } from "../http-api/index.ts" ;
@@ -34,8 +35,6 @@ import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor.ts";
3435import { sleep } from "../utils.ts" ;
3536import { BackupDecryptor } from "../common-crypto/CryptoBackend.ts" ;
3637import { ImportRoomKeyProgressData , ImportRoomKeysOpts , CryptoEvent } from "../crypto-api/index.ts" ;
37- import { IKeyBackupInfo } from "../crypto/keybackup.ts" ;
38- import { IKeyBackup } from "../crypto/backup.ts" ;
3938import { AESEncryptedSecretStoragePayload } from "../@types/AESEncryptedSecretStoragePayload.ts" ;
4039
4140/** Authentification of the backup info, depends on algorithm */
@@ -488,7 +487,7 @@ export class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents,
488487 * @returns The number of keys in the backup request.
489488 */
490489 private keysCountInBatch ( batch : RustSdkCryptoJs . KeysBackupRequest ) : number {
491- const parsedBody : IKeyBackup = JSON . parse ( batch . body ) ;
490+ const parsedBody : KeyBackup = JSON . parse ( batch . body ) ;
492491 let count = 0 ;
493492 for ( const { sessions } of Object . values ( parsedBody . rooms ) ) {
494493 count += Object . keys ( sessions ) . length ;
@@ -653,7 +652,7 @@ export class RustBackupDecryptor implements BackupDecryptor {
653652
654653export async function requestKeyBackupVersion (
655654 http : MatrixHttpApi < IHttpOpts & { onlyData : true } > ,
656- ) : Promise < IKeyBackupInfo | null > {
655+ ) : Promise < KeyBackupInfo | null > {
657656 try {
658657 return await http . authedRequest < KeyBackupInfo > ( Method . Get , "/room_keys/version" , undefined , undefined , {
659658 prefix : ClientPrefix . V3 ,
@@ -679,3 +678,11 @@ export type RustBackupCryptoEventMap = {
679678 [ CryptoEvent . KeyBackupFailed ] : ( errCode : string ) => void ;
680679 [ CryptoEvent . KeyBackupDecryptionKeyCached ] : ( version : string ) => void ;
681680} ;
681+
682+ /**
683+ * Response from GET `/room_keys/keys` endpoint.
684+ * See https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3room_keyskeys
685+ */
686+ export interface KeyBackup {
687+ rooms : Record < string , { sessions : KeyBackupRoomSessions } > ;
688+ }
0 commit comments