mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
prevent leaking resources in olm worker
This commit is contained in:
parent
5f6ad91ff2
commit
f13f1cd593
@ -116,14 +116,13 @@ class MessageHandler {
|
|||||||
|
|
||||||
_megolmDecrypt(sessionKey, ciphertext) {
|
_megolmDecrypt(sessionKey, ciphertext) {
|
||||||
return this._toMessage(() => {
|
return this._toMessage(() => {
|
||||||
let session;
|
const session = new this._olm.InboundGroupSession();
|
||||||
try {
|
try {
|
||||||
session = new this._olm.InboundGroupSession();
|
|
||||||
session.import_session(sessionKey);
|
session.import_session(sessionKey);
|
||||||
// returns object with plaintext and message_index
|
// returns object with plaintext and message_index
|
||||||
return session.decrypt(ciphertext);
|
return session.decrypt(ciphertext);
|
||||||
} finally {
|
} finally {
|
||||||
session?.free();
|
session.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -132,10 +131,17 @@ class MessageHandler {
|
|||||||
return this._toMessage(() => {
|
return this._toMessage(() => {
|
||||||
this._feedRandomValues(randomValues);
|
this._feedRandomValues(randomValues);
|
||||||
const account = new this._olm.Account();
|
const account = new this._olm.Account();
|
||||||
account.create();
|
try {
|
||||||
account.generate_one_time_keys(otkAmount);
|
account.create();
|
||||||
this._checkRandomValuesUsed();
|
account.generate_one_time_keys(otkAmount);
|
||||||
return account.pickle("");
|
this._checkRandomValuesUsed();
|
||||||
|
return account.pickle("");
|
||||||
|
} finally {
|
||||||
|
account.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_olmCreateOutbound(accountPickle, theirIdentityKey, theirOneTimeKey) {
|
_olmCreateOutbound(accountPickle, theirIdentityKey, theirOneTimeKey) {
|
||||||
return this._toMessage(() => {
|
return this._toMessage(() => {
|
||||||
const account = new this._olm.Account();
|
const account = new this._olm.Account();
|
||||||
|
Loading…
Reference in New Issue
Block a user