1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

allow backup algorithm to determine whether restored keys should be trusted

This commit is contained in:
Hubert Chathi
2021-06-09 13:02:47 -04:00
parent c04d79d9a0
commit cf21d64aa8
2 changed files with 8 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ interface BackupAlgorithmClass {
}
interface BackupAlgorithm {
untrusted: boolean;
encryptSession(data: Record<string, any>): Promise<any>;
decryptSessions(ciphertexts: Record<string, any>): Promise<Record<string, any>[]>;
authData: AuthData;
@@ -589,6 +590,8 @@ export class Curve25519 implements BackupAlgorithm {
}
}
public get untrusted() { return true; }
public async encryptSession(data: Record<string, any>): Promise<any> {
const plainText: Record<string, any> = Object.assign({}, data);
delete plainText.session_id;
@@ -716,6 +719,8 @@ export class Aes256 implements BackupAlgorithm {
return [outKey, authData];
}
public get untrusted() { return false; }
async encryptSession(data: Record<string, any>): Promise<any> {
const plainText: Record<string, any> = Object.assign({}, data);
delete plainText.session_id;