@dfinity/auth-client
Version:
JavaScript and TypeScript library to provide a simple integration with an IC Internet Identity
48 lines (47 loc) • 1.62 kB
TypeScript
type IDBValidKey = string | number | Date | BufferSource | IDBValidKey[];
export type DBCreateOptions = {
dbName?: string;
storeName?: string;
version?: number;
};
/**
* Simple Key Value store
* Defaults to `'auth-client-db'` with an object store of `'ic-keyval'`
*/
export declare class IdbKeyVal {
private _db;
private _storeName;
/**
* @param {DBCreateOptions} options - DBCreateOptions
* @param {DBCreateOptions['dbName']} options.dbName name for the indexeddb database
* @default
* @param {DBCreateOptions['storeName']} options.storeName name for the indexeddb Data Store
* @default
* @param {DBCreateOptions['version']} options.version version of the database. Increment to safely upgrade
*/
static create(options?: DBCreateOptions): Promise<IdbKeyVal>;
private constructor();
/**
* Basic setter
* @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]
* @param value value to set
* @returns void
*/
set<T>(key: IDBValidKey, value: T): Promise<IDBValidKey>;
/**
* Basic getter
* Pass in a type T for type safety if you know the type the value will have if it is found
* @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]
* @returns `Promise<T | null>`
* @example
* await get<string>('exampleKey') -> 'exampleValue'
*/
get<T>(key: IDBValidKey): Promise<T | null>;
/**
* Remove a key
* @param key {@link IDBValidKey}
* @returns void
*/
remove(key: IDBValidKey): Promise<void>;
}
export {};