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

extract SecretStorageKeyObject

This commit is contained in:
David Baker
2021-07-07 21:14:34 +01:00
parent 64a1c83acc
commit fd2d106f2a
2 changed files with 5 additions and 2 deletions

View File

@@ -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"; 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 SecretStorageKeyTuple = [keyId: string, keyInfo: ISecretStorageKeyInfo];
export type SecretStorageKeyObject = {keyId: string, keyInfo: ISecretStorageKeyInfo};
export interface ISecretRequest { export interface ISecretRequest {
requestId: string; requestId: string;
@@ -123,7 +125,7 @@ export class SecretStorage {
algorithm: string, algorithm: string,
opts: IAddSecretStorageKeyOpts, opts: IAddSecretStorageKeyOpts,
keyId?: string, keyId?: string,
): Promise<{keyId: string, keyInfo: ISecretStorageKeyInfo}> { ): Promise<SecretStorageKeyObject> {
const keyInfo = { algorithm } as ISecretStorageKeyInfo; const keyInfo = { algorithm } as ISecretStorageKeyInfo;
if (!opts) opts = {} as IAddSecretStorageKeyOpts; if (!opts) opts = {} as IAddSecretStorageKeyOpts;

View File

@@ -38,6 +38,7 @@ import {
SecretStorage, SecretStorage,
SecretStorageKeyTuple, SecretStorageKeyTuple,
ISecretRequest, ISecretRequest,
SecretStorageKeyObject,
} from './SecretStorage'; } from './SecretStorage';
import { IAddSecretStorageKeyOpts, ISecretStorageKeyInfo } from "./api"; import { IAddSecretStorageKeyOpts, ISecretStorageKeyInfo } from "./api";
import { OutgoingRoomKeyRequestManager } from './OutgoingRoomKeyRequestManager'; import { OutgoingRoomKeyRequestManager } from './OutgoingRoomKeyRequestManager';
@@ -981,7 +982,7 @@ export class Crypto extends EventEmitter {
algorithm: string, algorithm: string,
opts: IAddSecretStorageKeyOpts, opts: IAddSecretStorageKeyOpts,
keyID: string, keyID: string,
): Promise<{keyId: string, keyInfo: ISecretStorageKeyInfo}> { ): Promise<SecretStorageKeyObject> {
return this.secretStorage.addKey(algorithm, opts, keyID); return this.secretStorage.addKey(algorithm, opts, keyID);
} }