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

fix types

This commit is contained in:
Hubert Chathi
2021-07-07 19:46:01 -04:00
parent 17dc1bda19
commit c8a7820cb3
4 changed files with 15 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ interface BackupAlgorithmClass {
key: string | Uint8Array | null, key: string | Uint8Array | null,
): Promise<[Uint8Array, AuthData]>; ): Promise<[Uint8Array, AuthData]>;
checkBackupVersion(info: BackupInfo): void; checkBackupVersion(info: IKeyBackupInfo): void;
} }
interface BackupAlgorithm { interface BackupAlgorithm {
@@ -112,9 +112,9 @@ export class BackupManager {
* *
* Throws an error if a problem is detected. * Throws an error if a problem is detected.
* *
* @param {BackupInfo} info the key backup info * @param {IKeyBackupInfo} info the key backup info
*/ */
public static checkBackupVersion(info: BackupInfo): void { public static checkBackupVersion(info: IKeyBackupInfo): void {
const Algorithm = algorithmsByName[info.algorithm]; const Algorithm = algorithmsByName[info.algorithm];
if (!Algorithm) { if (!Algorithm) {
throw new Error("Unknown backup algorithm: " + info.algorithm); throw new Error("Unknown backup algorithm: " + info.algorithm);
@@ -273,7 +273,7 @@ export class BackupManager {
/** /**
* Check if the given backup info is trusted. * Check if the given backup info is trusted.
* *
* @param {object} backupInfo key backup info dict from /room_keys/version * @param {IKeyBackupInfo} backupInfo key backup info dict from /room_keys/version
* @return {object} { * @return {object} {
* usable: [bool], // is the backup trusted, true iff there is a sig that is valid & from a trusted device * usable: [bool], // is the backup trusted, true iff there is a sig that is valid & from a trusted device
* sigs: [ * sigs: [
@@ -619,7 +619,7 @@ export class Curve25519 implements BackupAlgorithm {
} }
} }
public static checkBackupVersion(info: BackupInfo): void { public static checkBackupVersion(info: IKeyBackupInfo): void {
if (!info.auth_data.public_key) { if (!info.auth_data.public_key) {
throw new Error("Invalid backup data returned"); throw new Error("Invalid backup data returned");
} }
@@ -754,7 +754,7 @@ export class Aes256 implements BackupAlgorithm {
return [outKey, authData]; return [outKey, authData];
} }
public static checkBackupVersion(info: BackupInfo): void { public static checkBackupVersion(info: IKeyBackupInfo): void {
if (!info.auth_data.iv || !info.auth_data.mac) { if (!info.auth_data.iv || !info.auth_data.mac) {
throw new Error("Invalid backup data returned"); throw new Error("Invalid backup data returned");
} }

View File

@@ -126,6 +126,7 @@ export interface IMegolmSessionData {
session_id: string; session_id: string;
session_key: string; session_key: string;
algorithm: string; algorithm: string;
untrusted?: boolean;
} }
/* eslint-enable camelcase */ /* eslint-enable camelcase */

View File

@@ -15,18 +15,13 @@ limitations under the License.
*/ */
import { randomString } from '../randomstring'; import { randomString } from '../randomstring';
import { IKeyBackupInfo } from "./keybackup";
const DEFAULT_ITERATIONS = 500000; const DEFAULT_ITERATIONS = 500000;
const DEFAULT_BITSIZE = 256; const DEFAULT_BITSIZE = 256;
/* eslint-disable camelcase */ type IAuthData = IKeyBackupInfo["auth_data"];
interface IAuthData {
private_key_salt: string;
private_key_iterations: number;
private_key_bits?: number;
}
/* eslint-enable camelcase */
interface IKey { interface IKey {
key: Uint8Array; key: Uint8Array;

View File

@@ -35,11 +35,13 @@ export interface IKeyBackupRoomSessions {
export interface IKeyBackupInfo { export interface IKeyBackupInfo {
algorithm: string; algorithm: string;
auth_data: { auth_data: {
public_key: string; public_key?: string;
signatures: ISignatures; signatures?: ISignatures;
private_key_salt: string; private_key_salt?: string;
private_key_iterations: number; private_key_iterations?: number;
private_key_bits?: number; private_key_bits?: number;
iv?: string;
mac?: string;
}; };
count?: number; count?: number;
etag?: string; etag?: string;