Class: PibKeyContainer

PibKeyContainer(identityName, pibImpl, keyNames)

new PibKeyContainer(identityName, pibImpl, keyNames)

A PibKeyContainer is used to search/enumerate the keys of an identity. (A PibKeyContainer object can only be created by PibIdentity.) You should not call this private constructor. Instead, use PibKeyContainer.makePromise().
Parameters:
Name Type Description
identityName Name The name of the identity, which is copied.
pibImpl PibImpl The PIB backend implementation.
keyNames Array.<Name> The set of key names as an array of Name, as returned by getKeysOfIdentityPromise.
Source:

Methods

(static) makePromise(identityName, pibImpl, useSync, A)

Create a PibKeyContainer for an identity with identityName. This method that returns a Promise is needed instead of a normal constructor since it uses asynchronous PibImpl methods to initialize the object. This method should only be called by PibIdentityImpl.
Parameters:
Name Type Description
identityName Name The name of the identity, which is copied.
pibImpl PibImpl The PIB backend implementation.
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.
A Promise | SyncPromise promise which returns the new PibKeyContainer.
Source:

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

Add a key with name keyName into the container. If a key with the same name already exists, this replaces it.
Parameters:
Name Type Description
key Buffer The buffer of encoded key bytes.
keyName Name The name of the key, which is copied.
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 which returns the PibKey object, or a promise rejected with Error if the name of the key does not match the identity name.
Type
Promise | SyncPromise

getKeyNames() → {Array.<Name>}

Get the names of all the keys in the container.
Source:
Returns:
A new list of Name.
Type
Array.<Name>

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

Get the key with name keyName from the container.
Parameters:
Name Type Description
keyName Name The name of the 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 which returns the PibKey object, or a promise rejected with Error if keyName does not match the identity name, or a promise rejected with Pib.Error if the key does not exist.
Type
Promise | SyncPromise

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

Remove the key with name keyName from the container, and its related certificates. If the key does not exist, do nothing.
Parameters:
Name Type Description
keyName Name The name of the 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 which fulfills when finished, or a promise rejected with Error if keyName does not match the identity name.
Type
Promise | SyncPromise

size() → {number}

Get the number of keys in the container.
Source:
Returns:
The number of keys.
Type
number