mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Convert passphrase.js to ts
This commit is contained in:
parent
dd4704b818
commit
e45f66a199
@ -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;
|
||||||
|
@ -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";
|
||||||
|
@ -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");
|
Loading…
Reference in New Issue
Block a user