From fd2d106f2ab7968addf0a491246ed70a2a040f2e Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 7 Jul 2021 21:14:34 +0100 Subject: [PATCH] extract SecretStorageKeyObject --- src/crypto/SecretStorage.ts | 4 +++- src/crypto/index.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/crypto/SecretStorage.ts b/src/crypto/SecretStorage.ts index 54b407da5..5ddef3323 100644 --- a/src/crypto/SecretStorage.ts +++ b/src/crypto/SecretStorage.ts @@ -27,7 +27,9 @@ export const SECRET_STORAGE_ALGORITHM_V1_AES = "m.secret_storage.v1.aes-hmac-sha const ZERO_STR = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +// Some of the key functions use a tuple and some use an object... export type SecretStorageKeyTuple = [keyId: string, keyInfo: ISecretStorageKeyInfo]; +export type SecretStorageKeyObject = {keyId: string, keyInfo: ISecretStorageKeyInfo}; export interface ISecretRequest { requestId: string; @@ -123,7 +125,7 @@ export class SecretStorage { algorithm: string, opts: IAddSecretStorageKeyOpts, keyId?: string, - ): Promise<{keyId: string, keyInfo: ISecretStorageKeyInfo}> { + ): Promise { const keyInfo = { algorithm } as ISecretStorageKeyInfo; if (!opts) opts = {} as IAddSecretStorageKeyOpts; diff --git a/src/crypto/index.ts b/src/crypto/index.ts index 85488165f..49fcc5449 100644 --- a/src/crypto/index.ts +++ b/src/crypto/index.ts @@ -38,6 +38,7 @@ import { SecretStorage, SecretStorageKeyTuple, ISecretRequest, + SecretStorageKeyObject, } from './SecretStorage'; import { IAddSecretStorageKeyOpts, ISecretStorageKeyInfo } from "./api"; import { OutgoingRoomKeyRequestManager } from './OutgoingRoomKeyRequestManager'; @@ -981,7 +982,7 @@ export class Crypto extends EventEmitter { algorithm: string, opts: IAddSecretStorageKeyOpts, keyID: string, - ): Promise<{keyId: string, keyInfo: ISecretStorageKeyInfo}> { + ): Promise { return this.secretStorage.addKey(algorithm, opts, keyID); }