1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

some linting

This commit is contained in:
Hubert Chathi
2021-05-18 18:31:19 -04:00
parent 747723c8fb
commit 9e6b72bf38
2 changed files with 5 additions and 27 deletions

View File

@@ -35,7 +35,6 @@ import {StubStore} from "./store/stub";
import {createNewMatrixCall} from "./webrtc/call"; import {createNewMatrixCall} from "./webrtc/call";
import {CallEventHandler} from './webrtc/callEventHandler'; import {CallEventHandler} from './webrtc/callEventHandler';
import * as utils from './utils'; import * as utils from './utils';
import {sleep} from './utils';
import { import {
MatrixError, MatrixError,
PREFIX_MEDIA_R0, PREFIX_MEDIA_R0,
@@ -64,29 +63,6 @@ export const CRYPTO_ENABLED = isCryptoAvailable();
const CAPABILITIES_CACHE_MS = 21600000; // 6 hours - an arbitrary value const CAPABILITIES_CACHE_MS = 21600000; // 6 hours - an arbitrary value
const TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes const TURN_CHECK_INTERVAL = 10 * 60 * 1000; // poll for turn credentials every 10 minutes
function keysFromRecoverySession(sessions, decryptionKey, roomId) {
const keys = [];
for (const [sessionId, sessionData] of Object.entries(sessions)) {
try {
const decrypted = keyFromRecoverySession(sessionData, decryptionKey);
decrypted.session_id = sessionId;
decrypted.room_id = roomId;
keys.push(decrypted);
} catch (e) {
logger.log("Failed to decrypt megolm session from backup", e);
}
}
return keys;
}
function keyFromRecoverySession(session, decryptionKey) {
return JSON.parse(decryptionKey.decrypt(
session.session_data.ephemeral,
session.session_data.mac,
session.session_data.ciphertext,
));
}
/** /**
* Construct a Matrix Client. Only directly construct this if you want to use * Construct a Matrix Client. Only directly construct this if you want to use
* custom modules. Normally, {@link createClient} should be used * custom modules. Normally, {@link createClient} should be used
@@ -1843,13 +1819,15 @@ MatrixClient.prototype.getKeyBackupEnabled = function() {
* getKeyBackupVersion. * getKeyBackupVersion.
* *
* @param {object} info Backup information object as returned by getKeyBackupVersion * @param {object} info Backup information object as returned by getKeyBackupVersion
*
* @returns {Promise<void>}
*/ */
MatrixClient.prototype.enableKeyBackup = function(info) { MatrixClient.prototype.enableKeyBackup = async function(info) {
if (this._crypto === null) { if (this._crypto === null) {
throw new Error("End-to-end encryption disabled"); throw new Error("End-to-end encryption disabled");
} }
return this._crypto.backupManager.enableKeyBackup(); await this._crypto.backupManager.enableKeyBackup();
}; };
/** /**

View File

@@ -174,7 +174,7 @@ export function Crypto(baseApis, sessionStore, userId, deviceId,
await this.storeSecret("m.megolm_backup.v1", fixedKey, [keyId]); await this.storeSecret("m.megolm_backup.v1", fixedKey, [keyId]);
} }
return decodeBase64(fixedKey || storedKey); return olmlib.decodeBase64(fixedKey || storedKey);
} }
// try to get key from app // try to get key from app