Convert passphrase.js to ts

This commit is contained in:
RMidhunSuresh 2021-11-29 15:18:04 +05:30
parent dd4704b818
commit e45f66a199
3 changed files with 5 additions and 2 deletions

View File

@ -22,6 +22,7 @@ export interface IKeyDescription {
algorithm: string; algorithm: string;
iterations: number; iterations: number;
salt: string; salt: string;
bits?: number;
}; };
mac: string; mac: string;
iv: string; iv: string;

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import {KeyDescription, Key} from "./common"; import {KeyDescription, Key} from "./common";
import {keyFromPassphrase} from "./passphrase.js"; import {keyFromPassphrase} from "./passphrase";
import {keyFromRecoveryKey} from "./recoveryKey.js"; import {keyFromRecoveryKey} from "./recoveryKey.js";
import {SESSION_E2EE_KEY_PREFIX} from "../e2ee/common.js"; import {SESSION_E2EE_KEY_PREFIX} from "../e2ee/common.js";
import type {Storage} from "../storage/idb/Storage"; import type {Storage} from "../storage/idb/Storage";

View File

@ -15,6 +15,8 @@ limitations under the License.
*/ */
import {Key} from "./common"; import {Key} from "./common";
import type {KeyDescription} from "./common";
import type {Platform} from "../../platform/web/Platform.js";
const DEFAULT_ITERATIONS = 500000; const DEFAULT_ITERATIONS = 500000;
const DEFAULT_BITSIZE = 256; const DEFAULT_BITSIZE = 256;
@ -25,7 +27,7 @@ const DEFAULT_BITSIZE = 256;
* @param {Platform} platform * @param {Platform} platform
* @return {Key} * @return {Key}
*/ */
export async function keyFromPassphrase(keyDescription, passphrase, platform) { export async function keyFromPassphrase(keyDescription: KeyDescription, passphrase: string, platform: Platform): Promise<Key> {
const {passphraseParams} = keyDescription; const {passphraseParams} = keyDescription;
if (!passphraseParams) { if (!passphraseParams) {
throw new Error("not a passphrase key"); throw new Error("not a passphrase key");