You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
more de-linting and fixing
This commit is contained in:
@@ -264,8 +264,8 @@ MegolmEncryption.prototype._prepareNewSession = async function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (this._crypto.backupInfo) {
|
if (this._crypto.backupInfo) {
|
||||||
// Not strictly necessary to wait for this
|
// don't wait for it to complete
|
||||||
await this._crypto.backupGroupSession(
|
this._crypto.backupGroupSession(
|
||||||
this._roomId, this._olmDevice.deviceCurve25519Key, [],
|
this._roomId, this._olmDevice.deviceCurve25519Key, [],
|
||||||
sessionId, key.key,
|
sessionId, key.key,
|
||||||
);
|
);
|
||||||
@@ -849,7 +849,8 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
|
|||||||
this._retryDecryption(senderKey, sessionId);
|
this._retryDecryption(senderKey, sessionId);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (this._crypto.backupInfo) {
|
if (this._crypto.backupInfo) {
|
||||||
return this._crypto.backupGroupSession(
|
// don't wait for it to complete
|
||||||
|
this._crypto.backupGroupSession(
|
||||||
content.room_id, senderKey, forwardingKeyChain,
|
content.room_id, senderKey, forwardingKeyChain,
|
||||||
content.session_id, content.session_key, keysClaimed,
|
content.session_id, content.session_key, keysClaimed,
|
||||||
exportFormat,
|
exportFormat,
|
||||||
@@ -972,6 +973,18 @@ MegolmDecryption.prototype.importRoomKey = function(session) {
|
|||||||
session.sender_claimed_keys,
|
session.sender_claimed_keys,
|
||||||
true,
|
true,
|
||||||
).then(() => {
|
).then(() => {
|
||||||
|
if (this._crypto.backupInfo) {
|
||||||
|
// don't wait for it to complete
|
||||||
|
this._crypto.backupGroupSession(
|
||||||
|
session.room_id,
|
||||||
|
session.sender_key,
|
||||||
|
session.forwarding_curve25519_key_chain,
|
||||||
|
session.session_id,
|
||||||
|
session.session_key,
|
||||||
|
session.sender_claimed_keys,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
// have another go at decrypting events sent with this session.
|
// have another go at decrypting events sent with this session.
|
||||||
this._retryDecryption(session.sender_key, session.session_id);
|
this._retryDecryption(session.sender_key, session.session_id);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1061,7 +1061,7 @@ Crypto.prototype.backupGroupSession = async function(
|
|||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
this._maybeSendKeyBackup();
|
await this._maybeSendKeyBackup();
|
||||||
};
|
};
|
||||||
|
|
||||||
Crypto.prototype.backupAllGroupSessions = async function(version) {
|
Crypto.prototype.backupAllGroupSessions = async function(version) {
|
||||||
@@ -1077,7 +1077,7 @@ Crypto.prototype.backupAllGroupSessions = async function(version) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this._maybeSendKeyBackup();
|
await this._maybeSendKeyBackup();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* eslint-disable valid-jsdoc */ //https://github.com/eslint/eslint/issues/7307
|
/* eslint-disable valid-jsdoc */ //https://github.com/eslint/eslint/issues/7307
|
||||||
|
|||||||
@@ -501,7 +501,6 @@ export class Backend {
|
|||||||
const objectStore = txn.objectStore("sessions_needing_backup");
|
const objectStore = txn.objectStore("sessions_needing_backup");
|
||||||
return Promise.all(sessions.map((session) => {
|
return Promise.all(sessions.map((session) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
console.log(session);
|
|
||||||
const req = objectStore.delete([session.senderKey, session.sessionId]);
|
const req = objectStore.delete([session.senderKey, session.sessionId]);
|
||||||
req.onsuccess = resolve;
|
req.onsuccess = resolve;
|
||||||
req.onerror = reject;
|
req.onerror = reject;
|
||||||
|
|||||||
@@ -167,43 +167,52 @@ export default class LocalStorageCryptoStore extends MemoryCryptoStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSessionsNeedingBackup(limit) {
|
getSessionsNeedingBackup(limit) {
|
||||||
|
const sessionsNeedingBackup
|
||||||
|
= getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||||
const sessions = [];
|
const sessions = [];
|
||||||
|
|
||||||
for (const session in getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP)) {
|
for (const session in sessionsNeedingBackup) {
|
||||||
const senderKey = session.substr(0, 43);
|
if (Object.prototype.hasOwnProperty.call(sessionsNeedingBackup, session)) {
|
||||||
const sessionId = session.substr(44);
|
const senderKey = session.substr(0, 43);
|
||||||
getEndToEndInboundGroupSession(senderKey, sessionId, null, (sessionData) => {
|
const sessionId = session.substr(44);
|
||||||
sessions.push({
|
this.getEndToEndInboundGroupSession(
|
||||||
senderKey: senderKey,
|
senderKey, sessionId, null,
|
||||||
sessionId: sessionId,
|
(sessionData) => {
|
||||||
sessionData: sessionData,
|
sessions.push({
|
||||||
});
|
senderKey: senderKey,
|
||||||
})
|
sessionId: sessionId,
|
||||||
if (limit && session.length >= limit) {
|
sessionData: sessionData,
|
||||||
break;
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (limit && session.length >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve(sessions);
|
return Promise.resolve(sessions);
|
||||||
}
|
}
|
||||||
|
|
||||||
unmarkSessionsNeedingBackup(sessions) {
|
unmarkSessionsNeedingBackup(sessions) {
|
||||||
const sessionsNeedingBackup = getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
const sessionsNeedingBackup
|
||||||
for(const session of sessions) {
|
= getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||||
|
for (const session of sessions) {
|
||||||
delete sessionsNeedingBackup[session.senderKey + '/' + session.sessionId];
|
delete sessionsNeedingBackup[session.senderKey + '/' + session.sessionId];
|
||||||
}
|
}
|
||||||
setJsonItem(
|
setJsonItem(
|
||||||
this.store, KEY_SESSION_NEEDING_BACKUP, sessionsNeedinBackup,
|
this.store, KEY_SESSIONS_NEEDING_BACKUP, sessionsNeedingBackup,
|
||||||
);
|
);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
markSessionsNeedingBackup(sessions) {
|
markSessionsNeedingBackup(sessions) {
|
||||||
const sessionsNeedingBackup = getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
const sessionsNeedingBackup
|
||||||
for(const session of sessions) {
|
= getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||||
|
for (const session of sessions) {
|
||||||
sessionsNeedingBackup[session.senderKey + '/' + session.sessionId] = true;
|
sessionsNeedingBackup[session.senderKey + '/' + session.sessionId] = true;
|
||||||
}
|
}
|
||||||
setJsonItem(
|
setJsonItem(
|
||||||
this.store, KEY_SESSION_NEEDING_BACKUP, sessionsNeedinBackup,
|
this.store, KEY_SESSIONS_NEEDING_BACKUP, sessionsNeedingBackup,
|
||||||
);
|
);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,15 +315,17 @@ export default class MemoryCryptoStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unmarkSessionsNeedingBackup(sessions) {
|
unmarkSessionsNeedingBackup(sessions) {
|
||||||
for(const session of sessions) {
|
for (const session of sessions) {
|
||||||
delete this._sessionsNeedingBackup[session.senderKey + '/' + session.sessionId];
|
const sessionKey = session.senderKey + '/' + session.sessionId;
|
||||||
|
delete this._sessionsNeedingBackup[sessionKey];
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
markSessionsNeedingBackup(sessions) {
|
markSessionsNeedingBackup(sessions) {
|
||||||
for(const session of sessions) {
|
for (const session of sessions) {
|
||||||
this._sessionsNeedingBackup[session.senderKey + '/' + session.sessionId] = true;
|
const sessionKey = session.senderKey + '/' + session.sessionId;
|
||||||
|
this._sessionsNeedingBackup[sessionKey] = true;
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user