You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
RustCrypto | Implement keybackup loop (#3652)
* Implement `CryptoApi.checkKeyBackup` * Deprecate `MatrixClient.enableKeyBackup`. * fix integ test * more tests * Implement keybackup loop * cleaning * update matrix-sdk-crypto-wasm to 1.2.1 * fix lint * avoid real timer stuff * Simplify test * post merge lint fix * revert change on yarn.lock * code review * Generate test data for exported keys * code review cleaning * cleanup legacy backup loop * Update spec/test-utils/test-data/generate-test-data.py Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Update spec/test-utils/test-data/generate-test-data.py Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * update yarn.lock for new wasm bindings --------- Co-authored-by: Richard van der Hoff <richard@matrix.org> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
@@ -118,8 +118,12 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
|
||||
this.keyClaimManager = new KeyClaimManager(olmMachine, this.outgoingRequestProcessor);
|
||||
this.eventDecryptor = new EventDecryptor(olmMachine);
|
||||
|
||||
this.backupManager = new RustBackupManager(olmMachine, http);
|
||||
this.reemitter.reEmit(this.backupManager, [CryptoEvent.KeyBackupStatus]);
|
||||
this.backupManager = new RustBackupManager(olmMachine, http, this.outgoingRequestProcessor);
|
||||
this.reemitter.reEmit(this.backupManager, [
|
||||
CryptoEvent.KeyBackupStatus,
|
||||
CryptoEvent.KeyBackupSessionsRemaining,
|
||||
CryptoEvent.KeyBackupFailed,
|
||||
]);
|
||||
|
||||
// Fire if the cross signing keys are imported from the secret storage
|
||||
const onCrossSigningKeysImport = (): void => {
|
||||
@@ -148,6 +152,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
|
||||
this.stopped = true;
|
||||
|
||||
this.keyClaimManager.stop();
|
||||
this.backupManager.stop();
|
||||
|
||||
// make sure we close() the OlmMachine; doing so means that all the Rust objects will be
|
||||
// cleaned up; in particular, the indexeddb connections will be closed, which means they
|
||||
@@ -1022,9 +1027,11 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
|
||||
for (const key of keys) {
|
||||
this.onRoomKeyUpdated(key);
|
||||
}
|
||||
this.backupManager.maybeUploadKey();
|
||||
}
|
||||
|
||||
private onRoomKeyUpdated(key: RustSdkCryptoJs.RoomKeyInfo): void {
|
||||
if (this.stopped) return;
|
||||
logger.debug(`Got update for session ${key.senderKey.toBase64()}|${key.sessionId} in ${key.roomId.toString()}`);
|
||||
const pendingList = this.eventDecryptor.getEventsPendingRoomKey(key);
|
||||
if (pendingList.length === 0) return;
|
||||
|
||||
Reference in New Issue
Block a user