mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
pass olm, better naming, don't reuse var
This commit is contained in:
parent
5b45c00322
commit
7d6fcfafa8
@ -162,24 +162,24 @@ export class Session {
|
||||
if (!this._olm) {
|
||||
throw new Error("olm required");
|
||||
}
|
||||
const key = await ssssKeyFromCredential(type, credential, this._storage, this._cryptoDriver);
|
||||
const key = await ssssKeyFromCredential(type, credential, this._storage, this._cryptoDriver, this._olm);
|
||||
// and create session backup, which needs to read from accountData
|
||||
txn = await this._storage.readTxn([
|
||||
const readTxn = await this._storage.readTxn([
|
||||
this._storage.storeNames.accountData,
|
||||
]);
|
||||
await this._createSessionBackup(key, txn);
|
||||
await this._createSessionBackup(key, readTxn);
|
||||
// only after having read a secret, write the key
|
||||
// as we only find out if it was good if the MAC verification succeeds
|
||||
let txn = await this._storage.readWriteTxn([
|
||||
const writeTxn = await this._storage.readWriteTxn([
|
||||
this._storage.storeNames.session,
|
||||
]);
|
||||
try {
|
||||
ssssWriteKey(key, txn);
|
||||
ssssWriteKey(key, writeTxn);
|
||||
} catch (err) {
|
||||
txn.abort();
|
||||
writeTxn.abort();
|
||||
throw err;
|
||||
}
|
||||
await txn.complete();
|
||||
await writeTxn.complete();
|
||||
}
|
||||
|
||||
async _createSessionBackup(ssssKey, txn) {
|
||||
|
Loading…
Reference in New Issue
Block a user