forked from mystiq/hydrogen-web
don't block reenabling 4s if already enabled
This commit is contained in:
parent
fd4eb6b50d
commit
02f06724d0
2 changed files with 10 additions and 7 deletions
|
@ -195,7 +195,8 @@ export class Session {
|
||||||
throw new Error("olm required");
|
throw new Error("olm required");
|
||||||
}
|
}
|
||||||
if (this._keyBackup.get()) {
|
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);
|
const key = await ssssKeyFromCredential(type, credential, this._storage, this._platform, this._olm);
|
||||||
// and create key backup, which needs to read from accountData
|
// and create key backup, which needs to read from accountData
|
||||||
|
|
|
@ -41,8 +41,8 @@ export type SessionData = {
|
||||||
|
|
||||||
export class BackupEncryption {
|
export class BackupEncryption {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly encryption: Olm.PkEncryption,
|
private encryption?: Olm.PkEncryption,
|
||||||
private readonly decryption: Olm.PkDecryption
|
private decryption?: Olm.PkDecryption
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static fromAuthData(authData: AuthData, privateKey: Uint8Array, olm: Olm): BackupEncryption {
|
static fromAuthData(authData: AuthData, privateKey: Uint8Array, olm: Olm): BackupEncryption {
|
||||||
|
@ -63,7 +63,7 @@ export class BackupEncryption {
|
||||||
}
|
}
|
||||||
|
|
||||||
decryptRoomKey(sessionData: SessionData): SessionKeyInfo {
|
decryptRoomKey(sessionData: SessionData): SessionKeyInfo {
|
||||||
const sessionInfo = this.decryption.decrypt(
|
const sessionInfo = this.decryption!.decrypt(
|
||||||
sessionData.ephemeral,
|
sessionData.ephemeral,
|
||||||
sessionData.mac,
|
sessionData.mac,
|
||||||
sessionData.ciphertext,
|
sessionData.ciphertext,
|
||||||
|
@ -79,11 +79,13 @@ export class BackupEncryption {
|
||||||
forwarding_curve25519_key_chain: [],
|
forwarding_curve25519_key_chain: [],
|
||||||
session_key: sessionKey
|
session_key: sessionKey
|
||||||
};
|
};
|
||||||
return this.encryption.encrypt(JSON.stringify(sessionInfo)) as SessionData;
|
return this.encryption!.encrypt(JSON.stringify(sessionInfo)) as SessionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this.decryption.free();
|
this.decryption?.free();
|
||||||
this.encryption.free();
|
this.decryption = undefined;
|
||||||
|
this.encryption?.free();
|
||||||
|
this.encryption = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue