Home Reference Source Test
public class | source

BrowserKeyStore

Static Method Summary

Static Public Methods
public static

Get the ID of the most recently active member.

public static

Keep track of the ID of the most recently active member.

Static Private Methods
private static

async _getObjectStore(storeName: string, mode: string): Promise<IDBObjectStore>

Retrieves an object store from the db

private static

async _openDb(dbName: string, dbVersion: string): Promise<IDBDatabase>

Opens an instance of IndexedDB

Method Summary

Public Methods
public

async clearAllKeys(): Promise<any>

Clears all keys in object store

public

async getById(memberId: string, keyId: string): Promise

Look up a key by memberId and keyId.

public

async getByLevel(memberId: string, level: string): Promise

Look up a key by memberId and level.

public

async listKeys(memberId: string): Promise

Return list of member's keys.

public

async put(memberId: string, keyPair: Object): Promise

Store a member's key pair.

Static Public Methods

public static getActiveMemberId(): string source

Get the ID of the most recently active member.

Return:

string

ID of member

public static setActiveMemberId(memberId: string) source

Keep track of the ID of the most recently active member.

Params:

NameTypeAttributeDescription
memberId string

ID of member

Static Private Methods

private static async _getObjectStore(storeName: string, mode: string): Promise<IDBObjectStore> source

Retrieves an object store from the db

Params:

NameTypeAttributeDescription
storeName string

name of object store

mode string

readonly, readwrite, or readwriteflush, defaults to readonly

Return:

Promise<IDBObjectStore>

promise that resolves into the store object

private static async _openDb(dbName: string, dbVersion: string): Promise<IDBDatabase> source

Opens an instance of IndexedDB

Params:

NameTypeAttributeDescription
dbName string

name of db

dbVersion string

version of db

Return:

Promise<IDBDatabase>

promise that resolves into the database object

Public Methods

public async clearAllKeys(): Promise<any> source

Clears all keys in object store

Return:

Promise<any>

promise that resolves when all keys have been cleared

public async getById(memberId: string, keyId: string): Promise source

Look up a key by memberId and keyId.

Params:

NameTypeAttributeDescription
memberId string

ID of member

keyId string

key ID

Return:

Promise

promise that resolves into the retrieved key pair

public async getByLevel(memberId: string, level: string): Promise source

Look up a key by memberId and level.

Params:

NameTypeAttributeDescription
memberId string

ID of member

level string

'LOW', 'STANDARD', or 'PRIVILEGED'

Return:

Promise

promise that resolves into the retrieved key pair

public async listKeys(memberId: string): Promise source

Return list of member's keys.

Params:

NameTypeAttributeDescription
memberId string

ID of member

Return:

Promise

promise that resolves into the retrieved list of key pairs

public async put(memberId: string, keyPair: Object): Promise source

Store a member's key pair.

Params:

NameTypeAttributeDescription
memberId string

ID of member

keyPair Object

key pair to store

Return:

Promise

promise that resolves into the key pair that was passed in