Class: GroupManagerDb

GroupManagerDb()

new GroupManagerDb()

GroupManagerDb is a base class for the storage of data used by the GroupManager. It contains two tables to store Schedules and Members. This is an abstract base class. A subclass must implement the methods. For example, see Sqlite3GroupManagerDb (for Nodejs) or IndexedDbGroupManagerDb (for the browser).
Source:

Classes

Error

Methods

addEKeyPromise(eKeyName, publicKey, privateKey, useSync) → {Promise|SyncPromise}

Add the EKey with name eKeyName to the database.
Parameters:
Name Type Description
eKeyName Name The name of the EKey. This copies the Name.
publicKey Blob The encoded public Key of the group key pair.
privateKey Blob The encoded private Key of the group key pair.
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 EKey is added, or that is rejected with GroupManagerDb.Error if a key with name eKeyName already exists in the database, or other database error.
Type
Promise | SyncPromise

addMemberPromise(scheduleName, keyName, key, useSync) → {Promise|SyncPromise}

Add a new member with the given key named keyName into a schedule named scheduleName. The member's identity name is keyName.getPrefix(-1).
Parameters:
Name Type Description
scheduleName string The schedule name.
keyName Name The name of the key.
key Blob A Blob of the public key DER.
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 member is added, or that is rejected with GroupManagerDb.Error if there's no schedule named scheduleName, if the member's identity name already exists, or other database error.
Type
Promise | SyncPromise

addSchedulePromise(name, schedule, useSync) → {Promise|SyncPromise}

Add a schedule with the given name.
Parameters:
Name Type Description
name string The name of the schedule. The name cannot be empty.
schedule Schedule The Schedule to add.
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 schedule is added, or that is rejected with GroupManagerDb.Error if a schedule with the same name already exists, if the name is empty, or other database error.
Type
Promise | SyncPromise

cleanEKeysPromise(useSync) → {Promise|SyncPromise}

Delete all the EKeys in the database. The database will keep growing because EKeys will keep being added, so this method should be called periodically.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise that fulfills when the EKeys are deleted, or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

cleanEKeysPromise(useSync) → {Promise|SyncPromise}

Delete all the EKeys in the database. The database will keep growing because EKeys will keep being added, so this method should be called periodically.
Parameters:
Name Type Description
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 EKeys are deleted, or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

deleteEKeyPromise(eKeyName, useSync) → {Promise|SyncPromise}

Delete the EKey with name eKeyName from the database. If no key with the name exists in the database, do nothing.
Parameters:
Name Type Description
eKeyName Name The name of the EKey.
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 EKey is deleted (or there is no such key), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

deleteMemberPromise(identity, useSync) → {Promise|SyncPromise}

Delete a member with the given identity name. If there is no member with the identity name, then do nothing.
Parameters:
Name Type Description
identity Name The member's identity 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 member is deleted (or there is no such member), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

deleteSchedulePromise(name, useSync) → {Promise|SyncPromise}

Delete the schedule with the given name. Also delete members which use this schedule. If there is no schedule with the name, then do nothing.
Parameters:
Name Type Description
name string The name of the schedule.
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 schedule is deleted (or there is no such schedule), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

getEKeyPromise(eKeyName, useSync) → {Promise|SyncPromise}

Get the group key pair with the name eKeyName from the database.
Parameters:
Name Type Description
eKeyName Name The name of the EKey.
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 an object (where "publicKey" is the public key Blob and "privateKey" is the private key Blob), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

getMemberSchedulePromise(identity, useSync) → {Promise|SyncPromise}

Get the name of the schedule for the given member's identity name.
Parameters:
Name Type Description
identity Name The member's identity 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 the string schedule name, or that is rejected with GroupManagerDb.Error if there's no member with the given identity name in the database, or other database error.
Type
Promise | SyncPromise

getScheduleMembersPromise(name, useSync) → {Promise|SyncPromise}

For each member using the given schedule, get the name and public key DER of the member's key.
Parameters:
Name Type Description
name string The name of the schedule.
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 new array of object (where "keyName" is the Name of the public key and "publicKey" is the Blob of the public key DER), or that is rejected with GroupManagerDb.Error for a database error. Note that the member's identity name is keyName.getPrefix(-1). If the schedule name is not found, the list is empty.
Type
Promise | SyncPromise

getSchedulePromise(name, useSync) → {Promise|SyncPromise}

Get a schedule with the given name.
Parameters:
Name Type Description
name string The name of the schedule.
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 new Schedule object, or that is rejected with GroupManagerDb.Error if the schedule does not exist or other database error.
Type
Promise | SyncPromise

hasEKeyPromise(eKeyName, useSync) → {Promise|SyncPromise}

Check if there is an EKey with the name eKeyName in the database.
Parameters:
Name Type Description
eKeyName Name The name of the EKey.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise that returns true if the EKey exists (else false), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

hasEKeyPromise(eKeyName, useSync) → {Promise|SyncPromise}

Check if there is an EKey with the name eKeyName in the database.
Parameters:
Name Type Description
eKeyName Name The name of the EKey.
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 true if the EKey exists (else false), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

hasMemberPromise(identity, useSync) → {Promise|SyncPromise}

Check if there is a member with the given identity name.
Parameters:
Name Type Description
identity Name The member's identity 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 true if there is a member (else false), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

hasSchedulePromise(name, useSync) → {Promise|SyncPromise}

Check if there is a schedule with the given name.
Parameters:
Name Type Description
name string The name of the schedule.
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 true if there is a schedule (else false), or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

listAllMembersPromise(useSync) → {Promise|SyncPromise}

List all the members.
Parameters:
Name Type Description
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 new array of Name with the names of all members, or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

listAllScheduleNamesPromise(useSync) → {Promise|SyncPromise}

List all the names of the schedules.
Parameters:
Name Type Description
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 new array of string with the names of all schedules, or that is rejected with GroupManagerDb.Error for a database error.
Type
Promise | SyncPromise

renameSchedulePromise(oldName, newName, useSync) → {Promise|SyncPromise}

Rename a schedule with oldName to newName.
Parameters:
Name Type Description
oldName string The name of the schedule to be renamed.
newName string The new name of the schedule. The name cannot be empty.
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 schedule is renamed, or that is rejected with GroupManagerDb.Error if a schedule with newName already exists, if the schedule with oldName does not exist, if newName is empty, or other database error.
Type
Promise | SyncPromise

updateMemberSchedulePromise(identity, scheduleName, useSync) → {Promise|SyncPromise}

Change the name of the schedule for the given member's identity name.
Parameters:
Name Type Description
identity Name The member's identity name.
scheduleName string The new schedule 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 member is updated, or that is rejected with GroupManagerDb.Error if there's no member with the given identity name in the database, or there's no schedule named scheduleName, or other database error.
Type
Promise | SyncPromise

updateSchedulePromise(name, schedule, useSync) → {Promise|SyncPromise}

Update the schedule with name and replace the old object with the given schedule. Otherwise, if no schedule with name exists, a new schedule with name and the given schedule will be added to database.
Parameters:
Name Type Description
name string The name of the schedule. The name cannot be empty.
schedule Schedule The Schedule to update or add.
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 schedule is updated, or that is rejected with GroupManagerDb.Error if the name is empty, or other database error.
Type
Promise | SyncPromise