You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Fix incorrect TS return type for secret storage and key backup functions (#2082)
This commit is contained in:
@@ -2244,7 +2244,7 @@ export class MatrixClient extends EventEmitter {
|
|||||||
* with, or null if it is not present or not encrypted with a trusted
|
* with, or null if it is not present or not encrypted with a trusted
|
||||||
* key
|
* key
|
||||||
*/
|
*/
|
||||||
public isSecretStored(name: string, checkKey: boolean): Promise<Record<string, ISecretStorageKeyInfo>> {
|
public isSecretStored(name: string, checkKey: boolean): Promise<Record<string, ISecretStorageKeyInfo> | null> {
|
||||||
if (!this.crypto) {
|
if (!this.crypto) {
|
||||||
throw new Error("End-to-end encryption disabled");
|
throw new Error("End-to-end encryption disabled");
|
||||||
}
|
}
|
||||||
@@ -2275,7 +2275,7 @@ export class MatrixClient extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @return {string} The default key ID or null if no default key ID is set
|
* @return {string} The default key ID or null if no default key ID is set
|
||||||
*/
|
*/
|
||||||
public getDefaultSecretStorageKeyId(): Promise<string> {
|
public getDefaultSecretStorageKeyId(): Promise<string | null> {
|
||||||
if (!this.crypto) {
|
if (!this.crypto) {
|
||||||
throw new Error("End-to-end encryption disabled");
|
throw new Error("End-to-end encryption disabled");
|
||||||
}
|
}
|
||||||
@@ -2457,9 +2457,9 @@ export class MatrixClient extends EventEmitter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about the current key backup.
|
* Get information about the current key backup.
|
||||||
* @returns {Promise} Information object from API or null
|
* @returns {Promise<IKeyBackupInfo | null>} Information object from API or null
|
||||||
*/
|
*/
|
||||||
public async getKeyBackupVersion(): Promise<IKeyBackupInfo> {
|
public async getKeyBackupVersion(): Promise<IKeyBackupInfo | null> {
|
||||||
let res;
|
let res;
|
||||||
try {
|
try {
|
||||||
res = await this.http.authedRequest(
|
res = await this.http.authedRequest(
|
||||||
@@ -2578,7 +2578,7 @@ export class MatrixClient extends EventEmitter {
|
|||||||
* encrypted with, or null if it is not present or not encrypted with a
|
* encrypted with, or null if it is not present or not encrypted with a
|
||||||
* trusted key
|
* trusted key
|
||||||
*/
|
*/
|
||||||
public isKeyBackupKeyStored(): Promise<Record<string, ISecretStorageKeyInfo>> {
|
public isKeyBackupKeyStored(): Promise<Record<string, ISecretStorageKeyInfo> | null> {
|
||||||
return Promise.resolve(this.isSecretStored("m.megolm_backup.v1", false /* checkKey */));
|
return Promise.resolve(this.isSecretStored("m.megolm_backup.v1", false /* checkKey */));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export class SecretStorage {
|
|||||||
private readonly baseApis?: MatrixClient,
|
private readonly baseApis?: MatrixClient,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async getDefaultKeyId(): Promise<string> {
|
public async getDefaultKeyId(): Promise<string | null> {
|
||||||
const defaultKey = await this.accountDataAdapter.getAccountDataFromServer<{ key: string }>(
|
const defaultKey = await this.accountDataAdapter.getAccountDataFromServer<{ key: string }>(
|
||||||
'm.secret_storage.default_key',
|
'm.secret_storage.default_key',
|
||||||
);
|
);
|
||||||
@@ -345,7 +345,7 @@ export class SecretStorage {
|
|||||||
* with, or null if it is not present or not encrypted with a trusted
|
* with, or null if it is not present or not encrypted with a trusted
|
||||||
* key
|
* key
|
||||||
*/
|
*/
|
||||||
public async isStored(name: string, checkKey: boolean): Promise<Record<string, ISecretStorageKeyInfo>> {
|
public async isStored(name: string, checkKey: boolean): Promise<Record<string, ISecretStorageKeyInfo> | null> {
|
||||||
// check if secret exists
|
// check if secret exists
|
||||||
const secretInfo = await this.accountDataAdapter.getAccountDataFromServer<ISecretInfo>(name);
|
const secretInfo = await this.accountDataAdapter.getAccountDataFromServer<ISecretInfo>(name);
|
||||||
if (!secretInfo) return null;
|
if (!secretInfo) return null;
|
||||||
|
|||||||
@@ -1024,7 +1024,7 @@ export class Crypto extends EventEmitter {
|
|||||||
public isSecretStored(
|
public isSecretStored(
|
||||||
name: string,
|
name: string,
|
||||||
checkKey?: boolean,
|
checkKey?: boolean,
|
||||||
): Promise<Record<string, ISecretStorageKeyInfo>> {
|
): Promise<Record<string, ISecretStorageKeyInfo> | null> {
|
||||||
return this.secretStorage.isStored(name, checkKey);
|
return this.secretStorage.isStored(name, checkKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1035,7 +1035,7 @@ export class Crypto extends EventEmitter {
|
|||||||
return this.secretStorage.request(name, devices);
|
return this.secretStorage.request(name, devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDefaultSecretStorageKeyId(): Promise<string> {
|
public getDefaultSecretStorageKeyId(): Promise<string | null> {
|
||||||
return this.secretStorage.getDefaultKeyId();
|
return this.secretStorage.getDefaultKeyId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user