mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
don't block reenabling 4s if already enabled
This commit is contained in:
parent
fd4eb6b50d
commit
02f06724d0
@ -195,7 +195,8 @@ export class Session {
|
||||
throw new Error("olm required");
|
||||
}
|
||||
if (this._keyBackup.get()) {
|
||||
return false;
|
||||
this._keyBackup.get().dispose();
|
||||
this._keyBackup.set(undefined);
|
||||
}
|
||||
const key = await ssssKeyFromCredential(type, credential, this._storage, this._platform, this._olm);
|
||||
// and create key backup, which needs to read from accountData
|
||||
|
@ -41,8 +41,8 @@ export type SessionData = {
|
||||
|
||||
export class BackupEncryption {
|
||||
constructor(
|
||||
private readonly encryption: Olm.PkEncryption,
|
||||
private readonly decryption: Olm.PkDecryption
|
||||
private encryption?: Olm.PkEncryption,
|
||||
private decryption?: Olm.PkDecryption
|
||||
) {}
|
||||
|
||||
static fromAuthData(authData: AuthData, privateKey: Uint8Array, olm: Olm): BackupEncryption {
|
||||
@ -63,7 +63,7 @@ export class BackupEncryption {
|
||||
}
|
||||
|
||||
decryptRoomKey(sessionData: SessionData): SessionKeyInfo {
|
||||
const sessionInfo = this.decryption.decrypt(
|
||||
const sessionInfo = this.decryption!.decrypt(
|
||||
sessionData.ephemeral,
|
||||
sessionData.mac,
|
||||
sessionData.ciphertext,
|
||||
@ -79,11 +79,13 @@ export class BackupEncryption {
|
||||
forwarding_curve25519_key_chain: [],
|
||||
session_key: sessionKey
|
||||
};
|
||||
return this.encryption.encrypt(JSON.stringify(sessionInfo)) as SessionData;
|
||||
return this.encryption!.encrypt(JSON.stringify(sessionInfo)) as SessionData;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.decryption.free();
|
||||
this.encryption.free();
|
||||
this.decryption?.free();
|
||||
this.decryption = undefined;
|
||||
this.encryption?.free();
|
||||
this.encryption = undefined;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user