Skip to main content

Chrome Storage Module - tKey JS SDK

@tkey/chrome-storage

The Chrome Storage Module helps you store and recall key shares in the chrome extension storage.

Installation

npm install --save @tkey/chrome-storage

Initialization

import { ChromeExtensionStorageModule } from "@tkey/chrome-storage";
const chromeStorageModule = new ChromeExtensionStorageModule();

Usage

With the ChromeExtensionStorageModule, you have access to the multiple functions as mentioned in the type reference, however, the most important ones are:

Get ShareStore from Storage

getStoreFromChromeExtensionStorage(): Promise<ShareStore>;

Example

const share = await tKey.modules.chromeStorage.getStoreFromChromeExtensionStorage();

Store Device Share

storeDeviceShare(deviceShareStore: ShareStore, customDeviceInfo?: StringifiedType): Promise<void>;

  • deviceShareStore: The ShareStore object to store.
  • customDeviceInfo?: Information about the device to store.

Example

const generateShareResult = await tKeyInstance.generateNewShare();
const share = await tKeyInstance.outputShareStore(generateShareResult.newShareIndex);
await tKey.modules.chromeStorage.storeDeviceShare(share);

Type Reference

ChromeExtensionStorageModule

class ChromeExtensionStorageModule implements IModule {
moduleName: string;
tbSDK: ITKeyApi;
constructor();
setModuleReferences(tbSDK: ITKeyApi): void;
initialize(): Promise<void>;
storeDeviceShare(deviceShareStore: ShareStore, customDeviceInfo?: StringifiedType): Promise<void>;
storeShareOnChromeExtensionStorage(share: ShareStore): Promise<void>;
getStoreFromChromeExtensionStorage(): Promise<ShareStore>;
inputShareFromChromeExtensionStorage(): Promise<void>;
}

ShareStore

class ShareStore implements ISerializable {
share: Share;
polynomialID: PolynomialID;
constructor(share: Share, polynomialID: PolynomialID);
static fromJSON(value: StringifiedType): ShareStore;
toJSON(): StringifiedType;
}
interface ISerializable {
toJSON(): StringifiedType;
}