Skip to content

Commit 49dd76b

Browse files
authored
Remove redundant checkKey param on isSecretStored (#2360)
1 parent 34cfa51 commit 49dd76b

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/client.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -2388,18 +2388,15 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
23882388
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
23892389
*
23902390
* @param {string} name the name of the secret
2391-
* @param {boolean} checkKey check if the secret is encrypted by a trusted
2392-
* key
2393-
*
23942391
* @return {object?} map of key name to key info the secret is encrypted
23952392
* with, or null if it is not present or not encrypted with a trusted
23962393
* key
23972394
*/
2398-
public isSecretStored(name: string, checkKey: boolean): Promise<Record<string, ISecretStorageKeyInfo> | null> {
2395+
public isSecretStored(name: string): Promise<Record<string, ISecretStorageKeyInfo> | null> {
23992396
if (!this.crypto) {
24002397
throw new Error("End-to-end encryption disabled");
24012398
}
2402-
return this.crypto.isSecretStored(name, checkKey);
2399+
return this.crypto.isSecretStored(name);
24032400
}
24042401

24052402
/**
@@ -2728,7 +2725,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
27282725
* trusted key
27292726
*/
27302727
public isKeyBackupKeyStored(): Promise<Record<string, ISecretStorageKeyInfo> | null> {
2731-
return Promise.resolve(this.isSecretStored("m.megolm_backup.v1", false /* checkKey */));
2728+
return Promise.resolve(this.isSecretStored("m.megolm_backup.v1"));
27322729
}
27332730

27342731
/**

src/crypto/CrossSigning.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class CrossSigningInfo {
171171
*/
172172
public async isStoredInSecretStorage(secretStorage: SecretStorage): Promise<Record<string, object>> {
173173
// check what SSSS keys have encrypted the master key (if any)
174-
const stored = await secretStorage.isStored("m.cross_signing.master", false) || {};
174+
const stored = await secretStorage.isStored("m.cross_signing.master") || {};
175175
// then check which of those SSSS keys have also encrypted the SSK and USK
176176
function intersect(s: Record<string, ISecretStorageKeyInfo>) {
177177
for (const k of Object.keys(stored)) {
@@ -181,7 +181,7 @@ export class CrossSigningInfo {
181181
}
182182
}
183183
for (const type of ["self_signing", "user_signing"]) {
184-
intersect(await secretStorage.isStored(`m.cross_signing.${type}`, false) || {});
184+
intersect(await secretStorage.isStored(`m.cross_signing.${type}`) || {});
185185
}
186186
return Object.keys(stored).length ? stored : null;
187187
}

src/crypto/SecretStorage.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,12 @@ export class SecretStorage {
339339
* Check if a secret is stored on the server.
340340
*
341341
* @param {string} name the name of the secret
342-
* @param {boolean} checkKey check if the secret is encrypted by a trusted key
343342
*
344343
* @return {object?} map of key name to key info the secret is encrypted
345344
* with, or null if it is not present or not encrypted with a trusted
346345
* key
347346
*/
348-
public async isStored(name: string, checkKey = true): Promise<Record<string, ISecretStorageKeyInfo> | null> {
347+
public async isStored(name: string): Promise<Record<string, ISecretStorageKeyInfo> | null> {
349348
// check if secret exists
350349
const secretInfo = await this.accountDataAdapter.getAccountDataFromServer<ISecretInfo>(name);
351350
if (!secretInfo?.encrypted) return null;

src/crypto/index.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,8 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
10761076
return this.secretStorage.get(name);
10771077
}
10781078

1079-
public isSecretStored(
1080-
name: string,
1081-
checkKey?: boolean,
1082-
): Promise<Record<string, ISecretStorageKeyInfo> | null> {
1083-
return this.secretStorage.isStored(name, checkKey);
1079+
public isSecretStored(name: string): Promise<Record<string, ISecretStorageKeyInfo> | null> {
1080+
return this.secretStorage.isStored(name);
10841081
}
10851082

10861083
public requestSecret(name: string, devices: string[]): ISecretRequest {

0 commit comments

Comments
 (0)