Class: ConsumerDb

ConsumerDb

new ConsumerDb()

ConsumerDb is a base class the storage of decryption keys for the consumer. A subclass must implement the methods. For example, see Sqlite3ConsumerDb (for Nodejs) or IndexedDbConsumerDb (for the browser).
Source:

Classes

Error

Methods

addKeyPromise(keyName, keyBlob, useSync) → {Promise|SyncPromise}

Add the key with keyName and keyBlob to the database.
Parameters:
Name Type Description
keyName Name The key name.
keyBlob Blob The encoded key.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise that fulfills when the key is added, or that is rejected with ConsumerDb.Error if a key with the same keyName already exists, or other database error.
Type
Promise | SyncPromise

deleteKeyPromise(keyName, useSync) → {Promise|SyncPromise}

Delete the key with keyName from the database. If there is no key with keyName, do nothing.
Parameters:
Name Type Description
keyName Name The key name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise that fulfills when the key is deleted (or there is no such key), or that is rejected with ConsumerDb.Error for a database error.
Type
Promise | SyncPromise

getKeyPromise(keyName, useSync) → {Promise|SyncPromise}

Get the key with keyName from the database.
Parameters:
Name Type Description
keyName Name The key name.
useSync boolean (optional) If true then return a SyncPromise which is already fulfilled. If omitted or false, this may return a SyncPromise or an async Promise.
Source:
Returns:
A promise that returns a Blob with the encoded key (or an isNull Blob if cannot find the key with keyName), or that is rejected with ConsumerDb.Error for a database error.
Type
Promise | SyncPromise