Use olm type from dependency

This commit is contained in:
RMidhunSuresh 2021-12-02 12:23:22 +05:30
parent 7362e38413
commit e06a0e9e5a
3 changed files with 7 additions and 10 deletions

View File

@ -22,7 +22,7 @@ import type {Storage} from "../storage/idb/Storage";
import type {Transaction} from "../storage/idb/Transaction"; import type {Transaction} from "../storage/idb/Transaction";
import type {KeyDescriptionData} from "./common"; import type {KeyDescriptionData} from "./common";
import type {Platform} from "../../platform/web/Platform.js"; import type {Platform} from "../../platform/web/Platform.js";
import type {Olm} from "./recoveryKey"; import type * as Olm from "@matrix-org/olm"
const SSSS_KEY = `${SESSION_E2EE_KEY_PREFIX}ssssKey`; const SSSS_KEY = `${SESSION_E2EE_KEY_PREFIX}ssssKey`;
@ -67,7 +67,7 @@ export async function removeKey(txn: Transaction): Promise<void> {
txn.session.remove(SSSS_KEY); txn.session.remove(SSSS_KEY);
} }
export async function keyFromCredential(type: KeyType, credential: string, storage: Storage, platform: Platform, olm: Olm): Promise<Key> { export async function keyFromCredential(type: KeyType, credential: string, storage: Storage, platform: Platform, olm: typeof Olm): Promise<Key> {
const keyDescription = await readDefaultKeyDescription(storage); const keyDescription = await readDefaultKeyDescription(storage);
if (!keyDescription) { if (!keyDescription) {
throw new Error("Could not find a default secret storage key in account data"); throw new Error("Could not find a default secret storage key in account data");
@ -75,7 +75,7 @@ export async function keyFromCredential(type: KeyType, credential: string, stora
return await keyFromCredentialAndDescription(type, credential, keyDescription, platform, olm); return await keyFromCredentialAndDescription(type, credential, keyDescription, platform, olm);
} }
export async function keyFromCredentialAndDescription(type: KeyType, credential: string, keyDescription: KeyDescription, platform: Platform, olm: Olm): Promise<Key> { export async function keyFromCredentialAndDescription(type: KeyType, credential: string, keyDescription: KeyDescription, platform: Platform, olm: typeof Olm): Promise<Key> {
let key: Key; let key: Key;
if (type === KeyType.Passphrase) { if (type === KeyType.Passphrase) {
key = await keyFromPassphrase(keyDescription, credential, platform); key = await keyFromPassphrase(keyDescription, credential, platform);

View File

@ -16,11 +16,7 @@ limitations under the License.
import {Key} from "./common"; import {Key} from "./common";
import {KeyDescription} from "./common"; import {KeyDescription} from "./common";
import type {Platform} from "../../platform/web/Platform.js"; import type {Platform} from "../../platform/web/Platform.js";
import type * as Olm from "@matrix-org/olm"
export type Olm = {
PRIVATE_KEY_LENGTH: number;
[key: string]: any;
};
const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01] as const; const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01] as const;
@ -30,7 +26,7 @@ const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01] as const;
* @param {string} recoveryKey * @param {string} recoveryKey
* @return {Key} * @return {Key}
*/ */
export function keyFromRecoveryKey(keyDescription: KeyDescription, recoveryKey: string, olm: Olm, platform: Platform): Key { export function keyFromRecoveryKey(keyDescription: KeyDescription, recoveryKey: string, olm: typeof Olm, platform: Platform): Key {
const result = platform.encoding.base58.decode(recoveryKey.replace(/ /g, '')); const result = platform.encoding.base58.decode(recoveryKey.replace(/ /g, ''));
let parity = 0; let parity = 0;

View File

@ -2,7 +2,8 @@
"compilerOptions": { "compilerOptions": {
"strictNullChecks": true, "strictNullChecks": true,
"noEmit": true, "noEmit": true,
"target": "ES2020" "target": "ES2020",
"moduleResolution": "node"
}, },
"exclude": [ "exclude": [
"src/sdk/paths/*" "src/sdk/paths/*"