diff --git a/src/matrix/e2ee/megolm/decryption/DecryptionChanges.js b/src/matrix/e2ee/megolm/decryption/DecryptionChanges.ts similarity index 72% rename from src/matrix/e2ee/megolm/decryption/DecryptionChanges.js rename to src/matrix/e2ee/megolm/decryption/DecryptionChanges.ts index b45ab6dd..6a5cad04 100644 --- a/src/matrix/e2ee/megolm/decryption/DecryptionChanges.js +++ b/src/matrix/e2ee/megolm/decryption/DecryptionChanges.ts @@ -15,35 +15,31 @@ limitations under the License. */ import {DecryptionError} from "../../common.js"; +import type {DecryptionResult} from "../../DecryptionResult"; +import type {ReplayDetectionEntry} from "./ReplayDetectionEntry"; export class DecryptionChanges { - constructor(roomId, results, errors, replayEntries) { - this._roomId = roomId; - this._results = results; - this._errors = errors; - this._replayEntries = replayEntries; - } + constructor( + private readonly roomId: string, + private readonly results: Map, + private readonly errors: Map | undefined, + private readonly replayEntries: ReplayDetectionEntry[] + ) {} /** - * @type MegolmBatchDecryptionResult - * @property {Map} results a map of event id to decryption result - * @property {Map} errors event id -> errors - * * Handle replay attack detection, and return result - * @param {[type]} txn [description] - * @return {MegolmBatchDecryptionResult} */ - async write(txn) { - await Promise.all(this._replayEntries.map(async replayEntry => { + async write(txn): Promise<{results: Map, errors: Map}> { + await Promise.all(this.replayEntries.map(async replayEntry => { try { - this._handleReplayAttack(this._roomId, replayEntry, txn); + this._handleReplayAttack(this.roomId, replayEntry, txn); } catch (err) { - this._errors.set(replayEntry.eventId, err); + this.errors.set(replayEntry.eventId, err); } })); return { - results: this._results, - errors: this._errors + results: this.results, + errors: this.errors }; }