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
Fix missed conversion fallout
This commit is contained in:
@@ -581,7 +581,7 @@ describe("MegolmBackup", function() {
|
|||||||
const BAD_BACKUP_INFO = Object.assign({}, BACKUP_INFO, {
|
const BAD_BACKUP_INFO = Object.assign({}, BACKUP_INFO, {
|
||||||
algorithm: "this.algorithm.does.not.exist",
|
algorithm: "this.algorithm.does.not.exist",
|
||||||
});
|
});
|
||||||
client._http.authedRequest = function() {
|
client.http.authedRequest = function() {
|
||||||
return Promise.resolve(KEY_BACKUP_DATA);
|
return Promise.resolve(KEY_BACKUP_DATA);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export class BackupManager {
|
|||||||
private backupInfo: BackupInfo | undefined; // The info dict from /room_keys/version
|
private backupInfo: BackupInfo | undefined; // The info dict from /room_keys/version
|
||||||
public checkedForBackup: boolean; // Have we checked the server for a backup we can use?
|
public checkedForBackup: boolean; // Have we checked the server for a backup we can use?
|
||||||
private sendingBackups: boolean; // Are we currently sending backups?
|
private sendingBackups: boolean; // Are we currently sending backups?
|
||||||
constructor(private readonly baseApis, public readonly getKey: GetKey) {
|
constructor(private readonly baseApis: MatrixClient, public readonly getKey: GetKey) {
|
||||||
this.checkedForBackup = false;
|
this.checkedForBackup = false;
|
||||||
this.sendingBackups = false;
|
this.sendingBackups = false;
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ export class BackupManager {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const trustedPubkey = this.baseApis._crypto._sessionStore.getLocalTrustedBackupPubKey();
|
const trustedPubkey = this.baseApis.crypto._sessionStore.getLocalTrustedBackupPubKey();
|
||||||
|
|
||||||
if (backupInfo.auth_data.public_key === trustedPubkey) {
|
if (backupInfo.auth_data.public_key === trustedPubkey) {
|
||||||
logger.info("Backup public key " + trustedPubkey + " is trusted locally");
|
logger.info("Backup public key " + trustedPubkey + " is trusted locally");
|
||||||
@@ -288,12 +288,12 @@ export class BackupManager {
|
|||||||
const sigInfo: SigInfo = { deviceId: keyIdParts[1] };
|
const sigInfo: SigInfo = { deviceId: keyIdParts[1] };
|
||||||
|
|
||||||
// first check to see if it's from our cross-signing key
|
// first check to see if it's from our cross-signing key
|
||||||
const crossSigningId = this.baseApis._crypto._crossSigningInfo.getId();
|
const crossSigningId = this.baseApis.crypto._crossSigningInfo.getId();
|
||||||
if (crossSigningId === sigInfo.deviceId) {
|
if (crossSigningId === sigInfo.deviceId) {
|
||||||
sigInfo.crossSigningId = true;
|
sigInfo.crossSigningId = true;
|
||||||
try {
|
try {
|
||||||
await verifySignature(
|
await verifySignature(
|
||||||
this.baseApis._crypto._olmDevice,
|
this.baseApis.crypto._olmDevice,
|
||||||
backupInfo.auth_data,
|
backupInfo.auth_data,
|
||||||
this.baseApis.getUserId(),
|
this.baseApis.getUserId(),
|
||||||
sigInfo.deviceId,
|
sigInfo.deviceId,
|
||||||
@@ -313,7 +313,7 @@ export class BackupManager {
|
|||||||
// Now look for a sig from a device
|
// Now look for a sig from a device
|
||||||
// At some point this can probably go away and we'll just support
|
// At some point this can probably go away and we'll just support
|
||||||
// it being signed by the cross-signing master key
|
// it being signed by the cross-signing master key
|
||||||
const device = this.baseApis._crypto._deviceList.getStoredDevice(
|
const device = this.baseApis.crypto._deviceList.getStoredDevice(
|
||||||
this.baseApis.getUserId(), sigInfo.deviceId,
|
this.baseApis.getUserId(), sigInfo.deviceId,
|
||||||
);
|
);
|
||||||
if (device) {
|
if (device) {
|
||||||
@@ -323,7 +323,7 @@ export class BackupManager {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
await verifySignature(
|
await verifySignature(
|
||||||
this.baseApis._crypto._olmDevice,
|
this.baseApis.crypto._olmDevice,
|
||||||
backupInfo.auth_data,
|
backupInfo.auth_data,
|
||||||
this.baseApis.getUserId(),
|
this.baseApis.getUserId(),
|
||||||
device.deviceId,
|
device.deviceId,
|
||||||
@@ -400,7 +400,7 @@ export class BackupManager {
|
|||||||
await this.checkKeyBackup();
|
await this.checkKeyBackup();
|
||||||
// Backup version has changed or this backup version
|
// Backup version has changed or this backup version
|
||||||
// has been deleted
|
// has been deleted
|
||||||
this.baseApis._crypto.emit("crypto.keyBackupFailed", err.data.errcode);
|
this.baseApis.crypto.emit("crypto.keyBackupFailed", err.data.errcode);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,13 +423,13 @@ export class BackupManager {
|
|||||||
* @returns {integer} Number of sessions backed up
|
* @returns {integer} Number of sessions backed up
|
||||||
*/
|
*/
|
||||||
private async backupPendingKeys(limit: number): Promise<number> {
|
private async backupPendingKeys(limit: number): Promise<number> {
|
||||||
const sessions = await this.baseApis._crypto._cryptoStore.getSessionsNeedingBackup(limit);
|
const sessions = await this.baseApis.crypto._cryptoStore.getSessionsNeedingBackup(limit);
|
||||||
if (!sessions.length) {
|
if (!sessions.length) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let remaining = await this.baseApis._crypto._cryptoStore.countSessionsNeedingBackup();
|
let remaining = await this.baseApis.crypto._cryptoStore.countSessionsNeedingBackup();
|
||||||
this.baseApis._crypto.emit("crypto.keyBackupSessionsRemaining", remaining);
|
this.baseApis.crypto.emit("crypto.keyBackupSessionsRemaining", remaining);
|
||||||
|
|
||||||
const data = {};
|
const data = {};
|
||||||
for (const session of sessions) {
|
for (const session of sessions) {
|
||||||
@@ -438,7 +438,7 @@ export class BackupManager {
|
|||||||
data[roomId] = { sessions: {} };
|
data[roomId] = { sessions: {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionData = await this.baseApis._crypto._olmDevice.exportInboundGroupSession(
|
const sessionData = await this.baseApis.crypto._olmDevice.exportInboundGroupSession(
|
||||||
session.senderKey, session.sessionId, session.sessionData,
|
session.senderKey, session.sessionId, session.sessionData,
|
||||||
);
|
);
|
||||||
sessionData.algorithm = MEGOLM_ALGORITHM;
|
sessionData.algorithm = MEGOLM_ALGORITHM;
|
||||||
@@ -446,13 +446,13 @@ export class BackupManager {
|
|||||||
const forwardedCount =
|
const forwardedCount =
|
||||||
(sessionData.forwarding_curve25519_key_chain || []).length;
|
(sessionData.forwarding_curve25519_key_chain || []).length;
|
||||||
|
|
||||||
const userId = this.baseApis._crypto._deviceList.getUserByIdentityKey(
|
const userId = this.baseApis.crypto._deviceList.getUserByIdentityKey(
|
||||||
MEGOLM_ALGORITHM, session.senderKey,
|
MEGOLM_ALGORITHM, session.senderKey,
|
||||||
);
|
);
|
||||||
const device = this.baseApis._crypto._deviceList.getDeviceByIdentityKey(
|
const device = this.baseApis.crypto._deviceList.getDeviceByIdentityKey(
|
||||||
MEGOLM_ALGORITHM, session.senderKey,
|
MEGOLM_ALGORITHM, session.senderKey,
|
||||||
);
|
);
|
||||||
const verified = this.baseApis._crypto._checkDeviceInfoTrust(userId, device).isVerified();
|
const verified = this.baseApis.crypto._checkDeviceInfoTrust(userId, device).isVerified();
|
||||||
|
|
||||||
data[roomId]['sessions'][session.sessionId] = {
|
data[roomId]['sessions'][session.sessionId] = {
|
||||||
first_message_index: sessionData.first_known_index,
|
first_message_index: sessionData.first_known_index,
|
||||||
@@ -467,9 +467,9 @@ export class BackupManager {
|
|||||||
{ rooms: data },
|
{ rooms: data },
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.baseApis._crypto._cryptoStore.unmarkSessionsNeedingBackup(sessions);
|
await this.baseApis.crypto._cryptoStore.unmarkSessionsNeedingBackup(sessions);
|
||||||
remaining = await this.baseApis._crypto._cryptoStore.countSessionsNeedingBackup();
|
remaining = await this.baseApis.crypto._cryptoStore.countSessionsNeedingBackup();
|
||||||
this.baseApis._crypto.emit("crypto.keyBackupSessionsRemaining", remaining);
|
this.baseApis.crypto.emit("crypto.keyBackupSessionsRemaining", remaining);
|
||||||
|
|
||||||
return sessions.length;
|
return sessions.length;
|
||||||
}
|
}
|
||||||
@@ -477,7 +477,7 @@ export class BackupManager {
|
|||||||
public async backupGroupSession(
|
public async backupGroupSession(
|
||||||
senderKey: string, sessionId: string,
|
senderKey: string, sessionId: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.baseApis._crypto._cryptoStore.markSessionsNeedingBackup([{
|
await this.baseApis.crypto._cryptoStore.markSessionsNeedingBackup([{
|
||||||
senderKey: senderKey,
|
senderKey: senderKey,
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
}]);
|
}]);
|
||||||
@@ -509,22 +509,22 @@ export class BackupManager {
|
|||||||
* (which will be equal to the number of sessions in the store).
|
* (which will be equal to the number of sessions in the store).
|
||||||
*/
|
*/
|
||||||
public async flagAllGroupSessionsForBackup(): Promise<number> {
|
public async flagAllGroupSessionsForBackup(): Promise<number> {
|
||||||
await this.baseApis._crypto._cryptoStore.doTxn(
|
await this.baseApis.crypto._cryptoStore.doTxn(
|
||||||
'readwrite',
|
'readwrite',
|
||||||
[
|
[
|
||||||
IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,
|
IndexedDBCryptoStore.STORE_INBOUND_GROUP_SESSIONS,
|
||||||
IndexedDBCryptoStore.STORE_BACKUP,
|
IndexedDBCryptoStore.STORE_BACKUP,
|
||||||
],
|
],
|
||||||
(txn) => {
|
(txn) => {
|
||||||
this.baseApis._crypto._cryptoStore.getAllEndToEndInboundGroupSessions(txn, (session) => {
|
this.baseApis.crypto._cryptoStore.getAllEndToEndInboundGroupSessions(txn, (session) => {
|
||||||
if (session !== null) {
|
if (session !== null) {
|
||||||
this.baseApis._crypto._cryptoStore.markSessionsNeedingBackup([session], txn);
|
this.baseApis.crypto._cryptoStore.markSessionsNeedingBackup([session], txn);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const remaining = await this.baseApis._crypto._cryptoStore.countSessionsNeedingBackup();
|
const remaining = await this.baseApis.crypto._cryptoStore.countSessionsNeedingBackup();
|
||||||
this.baseApis.emit("crypto.keyBackupSessionsRemaining", remaining);
|
this.baseApis.emit("crypto.keyBackupSessionsRemaining", remaining);
|
||||||
return remaining;
|
return remaining;
|
||||||
}
|
}
|
||||||
@@ -534,7 +534,7 @@ export class BackupManager {
|
|||||||
* @returns {Promise<int>} Resolves to the number of sessions requiring backup
|
* @returns {Promise<int>} Resolves to the number of sessions requiring backup
|
||||||
*/
|
*/
|
||||||
public countSessionsNeedingBackup(): Promise<number> {
|
public countSessionsNeedingBackup(): Promise<number> {
|
||||||
return this.baseApis._crypto._cryptoStore.countSessionsNeedingBackup();
|
return this.baseApis.crypto._cryptoStore.countSessionsNeedingBackup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user