Convert interface to type

This commit is contained in:
RMidhunSuresh 2021-12-02 12:01:03 +05:30
parent d2c09933c7
commit 7362e38413
2 changed files with 7 additions and 7 deletions

View file

@ -16,7 +16,7 @@ limitations under the License.
import type {Platform} from "../../platform/web/Platform.js";
export interface IKeyDescription {
export type KeyDescriptionData = {
algorithm: string;
passphrase: {
algorithm: string;
@ -30,9 +30,9 @@ export interface IKeyDescription {
export class KeyDescription {
private readonly _id: string;
private readonly _keyDescription: IKeyDescription;
private readonly _keyDescription: KeyDescriptionData;
constructor(id: string, keyDescription: IKeyDescription) {
constructor(id: string, keyDescription: KeyDescriptionData) {
this._id = id;
this._keyDescription = keyDescription;
}
@ -41,7 +41,7 @@ export class KeyDescription {
return this._id;
}
get passphraseParams(): IKeyDescription["passphrase"] {
get passphraseParams(): KeyDescriptionData["passphrase"] {
return this._keyDescription?.passphrase;
}

View file

@ -20,7 +20,7 @@ import {keyFromRecoveryKey} from "./recoveryKey";
import {SESSION_E2EE_KEY_PREFIX} from "../e2ee/common.js";
import type {Storage} from "../storage/idb/Storage";
import type {Transaction} from "../storage/idb/Transaction";
import type {IKeyDescription} from "./common";
import type {KeyDescriptionData} from "./common";
import type {Platform} from "../../platform/web/Platform.js";
import type {Olm} from "./recoveryKey";
@ -44,7 +44,7 @@ async function readDefaultKeyDescription(storage: Storage): Promise<KeyDescripti
if (!keyAccountData) {
return;
}
return new KeyDescription(id, keyAccountData.content as IKeyDescription);
return new KeyDescription(id, keyAccountData.content as KeyDescriptionData);
}
export async function writeKey(key: Key, txn: Transaction): Promise<void> {
@ -58,7 +58,7 @@ export async function readKey(txn: Transaction): Promise<Key | undefined> {
}
const keyAccountData = await txn.accountData.get(`m.secret_storage.key.${keyData.id}`);
if (keyAccountData) {
return new Key(new KeyDescription(keyData.id, keyAccountData.content as IKeyDescription), keyData.binaryKey);
return new Key(new KeyDescription(keyData.id, keyAccountData.content as KeyDescriptionData), keyData.binaryKey);
}
}