From e45f66a199d8b4f2948c5829adf28061abb6e2af Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 29 Nov 2021 15:18:04 +0530 Subject: [PATCH] Convert passphrase.js to ts --- src/matrix/ssss/common.ts | 1 + src/matrix/ssss/index.ts | 2 +- src/matrix/ssss/{passphrase.js => passphrase.ts} | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) rename src/matrix/ssss/{passphrase.js => passphrase.ts} (86%) diff --git a/src/matrix/ssss/common.ts b/src/matrix/ssss/common.ts index c4d0adeb..b7c06192 100644 --- a/src/matrix/ssss/common.ts +++ b/src/matrix/ssss/common.ts @@ -22,6 +22,7 @@ export interface IKeyDescription { algorithm: string; iterations: number; salt: string; + bits?: number; }; mac: string; iv: string; diff --git a/src/matrix/ssss/index.ts b/src/matrix/ssss/index.ts index f0c72e0f..15e95200 100644 --- a/src/matrix/ssss/index.ts +++ b/src/matrix/ssss/index.ts @@ -15,7 +15,7 @@ limitations under the License. */ import {KeyDescription, Key} from "./common"; -import {keyFromPassphrase} from "./passphrase.js"; +import {keyFromPassphrase} from "./passphrase"; import {keyFromRecoveryKey} from "./recoveryKey.js"; import {SESSION_E2EE_KEY_PREFIX} from "../e2ee/common.js"; import type {Storage} from "../storage/idb/Storage"; diff --git a/src/matrix/ssss/passphrase.js b/src/matrix/ssss/passphrase.ts similarity index 86% rename from src/matrix/ssss/passphrase.js rename to src/matrix/ssss/passphrase.ts index 9460e4db..00e4801e 100644 --- a/src/matrix/ssss/passphrase.js +++ b/src/matrix/ssss/passphrase.ts @@ -15,6 +15,8 @@ limitations under the License. */ import {Key} from "./common"; +import type {KeyDescription} from "./common"; +import type {Platform} from "../../platform/web/Platform.js"; const DEFAULT_ITERATIONS = 500000; const DEFAULT_BITSIZE = 256; @@ -25,7 +27,7 @@ const DEFAULT_BITSIZE = 256; * @param {Platform} platform * @return {Key} */ -export async function keyFromPassphrase(keyDescription, passphrase, platform) { +export async function keyFromPassphrase(keyDescription: KeyDescription, passphrase: string, platform: Platform): Promise { const {passphraseParams} = keyDescription; if (!passphraseParams) { throw new Error("not a passphrase key");