Page MenuHomePhorge

D14351.1768623827.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14351.1768623827.diff

diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -75,6 +75,16 @@
let cryptoStore: ?WorkerCryptoStore = null;
function clearCryptoStore() {
+ if (!cryptoStore) {
+ return;
+ }
+
+ const { contentSessions, contentAccount } = cryptoStore;
+ contentAccount.free();
+ for (const deviceID in contentSessions) {
+ contentSessions[deviceID].session.free();
+ }
+
cryptoStore = null;
}
@@ -237,6 +247,8 @@
throw new Error('Database not initialized');
}
+ // This `olm.Account` is created once and is cached for the entire
+ // program lifetime. Freeing is done as part of `clearCryptoStore`.
const account = new olm.Account();
let picklingKey;
@@ -308,6 +320,8 @@
const sessionsData: OlmSessions = {};
for (const persistedSession: OlmPersistSession of dbSessionsData) {
const { sessionData, version } = persistedSession;
+ // This `olm.Session` is created once and is cached for the entire
+ // program lifetime. Freeing is done as part of `clearCryptoStore`.
const session = new olm.Session();
session.unpickle(picklingKey, sessionData);
sessionsData[persistedSession.targetDeviceID] = {
@@ -323,6 +337,8 @@
account: PickledOLMAccount,
): olm.Account {
const { picklingKey, pickledAccount } = account;
+ // This `olm.Account` is created once and is cached for the entire
+ // program lifetime. Freeing is done as part of `clearCryptoStore`.
const olmAccount = new olm.Account();
olmAccount.unpickle(picklingKey, pickledAccount);
return olmAccount;
@@ -719,6 +735,8 @@
}
}
+ // This `olm.Session` is created once and is cached for the entire
+ // program lifetime. Freeing is done as part of `clearCryptoStore`.
const session = new olm.Session();
session.create_inbound_from(
contentAccount,
@@ -755,6 +773,8 @@
const { contentAccount, contentSessions } = cryptoStore;
const existingSession = contentSessions[contentIdentityKeys.ed25519];
+ // This `olm.Session` is created once and is cached for the entire
+ // program lifetime. Freeing is done as part of `clearCryptoStore`.
const session = new olm.Session();
if (contentInitializationInfo.oneTimeKey) {
session.create_outbound(

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 17, 4:23 AM (12 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5947133
Default Alt Text
D14351.1768623827.diff (2 KB)

Event Timeline