UNPKG

@browser-network/database

Version:

A type of distributed database built on top of the distributed browser-network

43 lines (42 loc) 1.29 kB
import * as t from './types.d'; export type WrappedState<S = unknown> = { /** * @description Identify this bit of state by who it belongs to */ id: t.IDString; /** * @description Every state has a timestamp to represent when it was last updated. * If there's a newer timestamp than the one we have on file, we check * its veracity and save it. */ timestamp: t.TimeStamp; /** * @description Every state has to be signed by the user. This is how we verify * the veracity of each state. */ signature: t.HexString; /** * @description This will be hashed and included in signature to ensure the veracity * of someone's data. */ state: S; /** * @description To ensure veracity of state */ publicKey: t.PublicKey; }; declare const buildStorageShim: () => Storage; export declare class LocalDB { keyPrefix: string; localStorage: ReturnType<typeof buildStorageShim>; appId: t.GUID; constructor(appId: t.GUID); set(val: WrappedState, address: t.IDString): void; get(address: t.IDString): WrappedState | undefined; getAll(): WrappedState[]; remove(address: t.IDString): void; clear(): void; buildKey(address: t.IDString): string; private getByKey; } export {};