diff --git a/src/matrix/ssss/index.ts b/src/matrix/ssss/index.ts index 15e95200..fa09228d 100644 --- a/src/matrix/ssss/index.ts +++ b/src/matrix/ssss/index.ts @@ -16,17 +16,13 @@ limitations under the License. import {KeyDescription, Key} from "./common"; import {keyFromPassphrase} from "./passphrase"; -import {keyFromRecoveryKey} from "./recoveryKey.js"; +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 {Platform} from "../../platform/web/Platform.js"; - -type Olm = { - PRIVATE_KEY_LENGTH: number; - [key: string]: any -}; +import type { Olm } from "./recoveryKey"; const SSSS_KEY = `${SESSION_E2EE_KEY_PREFIX}ssssKey`; diff --git a/src/matrix/ssss/recoveryKey.js b/src/matrix/ssss/recoveryKey.ts similarity index 80% rename from src/matrix/ssss/recoveryKey.js rename to src/matrix/ssss/recoveryKey.ts index b1a746bc..1271a814 100644 --- a/src/matrix/ssss/recoveryKey.js +++ b/src/matrix/ssss/recoveryKey.ts @@ -14,8 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ import {Key} from "./common"; +import {KeyDescription} from "./common"; +import type {Platform} from "../../platform/web/Platform.js"; -const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01]; +export type Olm = { + PRIVATE_KEY_LENGTH: number; + [key: string]: any; +}; + +const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01] as const; /** * @param {Olm} olm @@ -23,7 +30,7 @@ const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01]; * @param {string} recoveryKey * @return {Key} */ -export function keyFromRecoveryKey(keyDescription, recoveryKey, olm, platform) { +export function keyFromRecoveryKey(keyDescription: KeyDescription, recoveryKey: string, olm: Olm, platform: Platform): Key { const result = platform.encoding.base58.decode(recoveryKey.replace(/ /g, '')); let parity = 0;