mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
fixes
This commit is contained in:
parent
5752cca69c
commit
a205ae8841
@ -34,8 +34,8 @@ import {
|
|||||||
keyFromCredential as ssssKeyFromCredential,
|
keyFromCredential as ssssKeyFromCredential,
|
||||||
readKey as ssssReadKey,
|
readKey as ssssReadKey,
|
||||||
writeKey as ssssWriteKey,
|
writeKey as ssssWriteKey,
|
||||||
SecretStorage
|
} from "./ssss/index.js";
|
||||||
} from "./ssss/index.js"
|
import {SecretStorage} from "./ssss/SecretStorage.js";
|
||||||
|
|
||||||
const PICKLE_KEY = "DEFAULT_KEY";
|
const PICKLE_KEY = "DEFAULT_KEY";
|
||||||
|
|
||||||
@ -155,8 +155,14 @@ export class Session {
|
|||||||
if (!this._olm) {
|
if (!this._olm) {
|
||||||
throw new Error("olm required");
|
throw new Error("olm required");
|
||||||
}
|
}
|
||||||
const key = ssssKeyFromCredential(type, credential, this._storage, this._cryptoDriver);
|
const key = await ssssKeyFromCredential(type, credential, this._storage, this._cryptoDriver);
|
||||||
// write the key
|
// and create session backup, which needs to read from accountData
|
||||||
|
txn = await this._storage.readTxn([
|
||||||
|
this._storage.storeNames.accountData,
|
||||||
|
]);
|
||||||
|
await this._createSessionBackup(key, txn);
|
||||||
|
// 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([
|
let txn = await this._storage.readWriteTxn([
|
||||||
this._storage.storeNames.session,
|
this._storage.storeNames.session,
|
||||||
]);
|
]);
|
||||||
@ -167,11 +173,6 @@ export class Session {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
await txn.complete();
|
await txn.complete();
|
||||||
// and create session backup, which needs to read from accountData
|
|
||||||
txn = await this._storage.readTxn([
|
|
||||||
this._storage.storeNames.accountData,
|
|
||||||
]);
|
|
||||||
await this._createSessionBackup(key, txn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _createSessionBackup(ssssKey, txn) {
|
async _createSessionBackup(ssssKey, txn) {
|
||||||
|
@ -178,10 +178,11 @@ export class HomeServerApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
roomKeysVersion(version = null, options = null) {
|
roomKeysVersion(version = null, options = null) {
|
||||||
if (!version) {
|
let versionPart = "";
|
||||||
version = "";
|
if (version) {
|
||||||
|
versionPart = `/${encodeURIComponent(version)}`;
|
||||||
}
|
}
|
||||||
return this._get(`/room_keys/version/${encodeURIComponent(version)}`, null, null, options);
|
return this._get(`/room_keys/version${versionPart}`, null, null, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
roomKeyForRoomAndSession(version, roomId, sessionId, options = null) {
|
roomKeyForRoomAndSession(version, roomId, sessionId, options = null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user