From 0d3e2043b0283b5ce5d00d7041fbd8cb2a5351b9 Mon Sep 17 00:00:00 2001 From: ieow Date: Fri, 1 Nov 2024 13:40:18 +0800 Subject: [PATCH] fix: remove unrelated changes --- src/helper/browserStorage.ts | 45 +----------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/src/helper/browserStorage.ts b/src/helper/browserStorage.ts index e576572..6a5555d 100644 --- a/src/helper/browserStorage.ts +++ b/src/helper/browserStorage.ts @@ -1,8 +1,4 @@ -import { TKeyTSS } from "@tkey/tss"; -import BN from "bn.js"; - -import { FIELD_ELEMENT_HEX_LEN } from "../constants"; -import { IAsyncStorage, IStorage, TkeyLocalStoreData } from "../interfaces"; +import { IAsyncStorage, IStorage } from "../interfaces"; import CoreKitError from "./errors"; export class MemoryStorage implements IStorage { @@ -70,42 +66,3 @@ export class AsyncStorage { await this.storage.setItem(this._storeKey, JSON.stringify(store)); } } - -export class DeviceStorage { - private tKey: TKeyTSS; - - private currentStorage: AsyncStorage; - - constructor(tkeyInstance: TKeyTSS, currentStorage: AsyncStorage) { - this.tKey = tkeyInstance; - this.currentStorage = currentStorage; - } - - // device factor - async setDeviceFactor(factorKey: BN, replace = false): Promise { - if (!replace) { - const existingFactor = await this.getDeviceFactor(); - if (existingFactor) { - throw CoreKitError.default("Device factor already exists"); - } - } - - const metadata = this.tKey.getMetadata(); - const tkeyPubX = metadata.pubKey.x.toString(16, FIELD_ELEMENT_HEX_LEN); - await this.currentStorage.set( - tkeyPubX, - JSON.stringify({ - factorKey: factorKey.toString("hex").padStart(64, "0"), - } as TkeyLocalStoreData) - ); - } - - async getDeviceFactor(): Promise { - const metadata = this.tKey.getMetadata(); - - const tkeyPubX = metadata.pubKey.x.toString(16, FIELD_ELEMENT_HEX_LEN); - const tKeyLocalStoreString = await this.currentStorage.get(tkeyPubX); - const tKeyLocalStore = JSON.parse(tKeyLocalStoreString || "{}") as TkeyLocalStoreData; - return tKeyLocalStore.factorKey; - } -}