Convert recoveryKey.js to ts
This commit is contained in:
parent
e45f66a199
commit
814c0bed2e
2 changed files with 11 additions and 8 deletions
|
@ -16,17 +16,13 @@ limitations under the License.
|
||||||
|
|
||||||
import {KeyDescription, Key} from "./common";
|
import {KeyDescription, Key} from "./common";
|
||||||
import {keyFromPassphrase} from "./passphrase";
|
import {keyFromPassphrase} from "./passphrase";
|
||||||
import {keyFromRecoveryKey} from "./recoveryKey.js";
|
import {keyFromRecoveryKey} from "./recoveryKey";
|
||||||
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";
|
||||||
import type {Transaction} from "../storage/idb/Transaction";
|
import type {Transaction} from "../storage/idb/Transaction";
|
||||||
import type {IKeyDescription} from "./common";
|
import type {IKeyDescription} from "./common";
|
||||||
import type {Platform} from "../../platform/web/Platform.js";
|
import type {Platform} from "../../platform/web/Platform.js";
|
||||||
|
import type { Olm } from "./recoveryKey";
|
||||||
type Olm = {
|
|
||||||
PRIVATE_KEY_LENGTH: number;
|
|
||||||
[key: string]: any
|
|
||||||
};
|
|
||||||
|
|
||||||
const SSSS_KEY = `${SESSION_E2EE_KEY_PREFIX}ssssKey`;
|
const SSSS_KEY = `${SESSION_E2EE_KEY_PREFIX}ssssKey`;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,15 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import {Key} from "./common";
|
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
|
* @param {Olm} olm
|
||||||
|
@ -23,7 +30,7 @@ const OLM_RECOVERY_KEY_PREFIX = [0x8B, 0x01];
|
||||||
* @param {string} recoveryKey
|
* @param {string} recoveryKey
|
||||||
* @return {Key}
|
* @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, ''));
|
const result = platform.encoding.base58.decode(recoveryKey.replace(/ /g, ''));
|
||||||
|
|
||||||
let parity = 0;
|
let parity = 0;
|
Reference in a new issue