Skip to content

Commit

Permalink
Move types
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Oct 29, 2024
1 parent 61c1940 commit a0dc1e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 0 additions & 8 deletions src/crypto-api/keybackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ export interface KeyBackupRoomSessions {
[sessionId: string]: KeyBackupSession;
}

export interface RoomKeysResponse {
sessions: KeyBackupRoomSessions;
}

export interface RoomsKeysResponse {
rooms: Record<string, RoomKeysResponse>;
}

export interface KeyBackupRestoreOpts {
progressCallback?: (progress: ImportRoomKeyProgressData) => void;
}
Expand Down
17 changes: 12 additions & 5 deletions src/rust-crypto/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import {
KeyBackupInfo,
KeyBackupSession,
Curve25519SessionData,
RoomKeysResponse,
RoomsKeysResponse,
KeyBackupRestoreOpts,
KeyBackupRestoreResult,
KeyBackupRoomSessions,
} from "../crypto-api/keybackup.ts";
import { logger } from "../logger.ts";
import { ClientPrefix, IHttpOpts, MatrixError, MatrixHttpApi, Method } from "../http-api/index.ts";
Expand All @@ -38,7 +37,7 @@ 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, IKeyBackupRoomSessions } from "../crypto/keybackup.ts";
import { IKeyBackupInfo } from "../crypto/keybackup.ts";
import { IKeyBackup } from "../crypto/backup.ts";
import { AESEncryptedSecretStoragePayload } from "../@types/AESEncryptedSecretStoragePayload.ts";

Expand Down Expand Up @@ -783,9 +782,9 @@ export class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents,
const { rooms } = res;

let groupChunkCount = 0;
let chunkGroupByRoom: Map<string, IKeyBackupRoomSessions> = new Map();
let chunkGroupByRoom: Map<string, KeyBackupRoomSessions> = new Map();

const handleChunkCallback = async (roomChunks: Map<string, IKeyBackupRoomSessions>): Promise<void> => {
const handleChunkCallback = async (roomChunks: Map<string, KeyBackupRoomSessions>): Promise<void> => {
const currentChunk: IMegolmSessionData[] = [];
for (const roomId of roomChunks.keys()) {
const decryptedSessions = await backupDecryptor.decryptSessions(roomChunks.get(roomId)!);
Expand Down Expand Up @@ -917,3 +916,11 @@ export type RustBackupCryptoEventMap = {
[CryptoEvent.KeyBackupFailed]: (errCode: string) => void;
[CryptoEvent.KeyBackupDecryptionKeyCached]: (version: string) => void;
};

interface RoomKeysResponse {
sessions: KeyBackupRoomSessions;
}

interface RoomsKeysResponse {
rooms: Record<string, RoomKeysResponse>;
}

0 comments on commit a0dc1e8

Please sign in to comment.