Class: PibIdentityImpl

PibIdentityImpl()

new PibIdentityImpl()

A PibIdentityImpl provides the backend implementation for PibIdentity. A PibIdentity has only one backend instance, but may have multiple frontend handles. Each frontend handle is associated with the only one backend PibIdentityImpl. You should not call this private constructor. Instead, use PibIdentityImpl.makePromise().
Source:

Methods

(static) makePromise(identityName, {PibImpl), needInit, useSync, A)

Create a PibIdentityImpl 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.
Parameters:
Name Type Description
identityName Name The name of the identity, which is copied.
{PibImpl) pibImpl: The Pib backend implementation.
needInit boolean If true and the identity does not exist in the pibImpl back end, then create it (and If no default identity has been set, identityName becomes the default). If false, then throw Pib.Error if the identity does not exist in the pibImpl back end.
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 PibIdentityImpl, or a promise which is rejected with Pib.Error if the identity does not exist in the pibImpl back end and needInit is false.
Source:

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

Add the key. If a key with the same name already exists, overwrite the key. If no default key for the identity has been set, then set the added key as default for the identity.
Parameters:
Name Type Description
key Buffer The public key bits. This copies the buffer.
keyName Name The name of the key. This copies the 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 which returns the PibKey object.
Type
Promise | SyncPromise

getDefaultKeyPromise(useSync) → {SyncPromise}

Get the default key of this Identity.
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 which returns the default PibKey, or a promise rejected with Pib.Error if the default key has not been set.
Type
SyncPromise

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

Get the key with name keyName.
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 Pib.Error if the key does not exist.
Type
Promise | SyncPromise

getName() → {Name}

Get the name of the identity.
Source:
Returns:
The name of the identity. You must not change the Name object. If you need to change it then make a copy.
Type
Name

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

Remove the key with keyName 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.
Type
Promise | SyncPromise

setDefaultKeyPromise(key, keyName, useSync) → {SyncPromise}

setDefaultKey has two forms: setDefaultKey(keyName, useSync) - Set the key with name keyName as the default key of the identity. setDefaultKey(key, keyName, useSync) - Add a key with name keyName and set it as the default key of the identity.
Parameters:
Name Type Description
key Buffer The buffer of encoded key bytes. (This is only used when calling setDefaultKey(key, keyName). )
keyName Name The name of the key. This copies the 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 which returns the PibKey object of the default key, or a promise rejected with Error the name of the key does not match the identity name, or a promise rejected with Pib.Error if calling setDefaultKey(keyName) and the key does not exist, or if calling setDefaultKey(key, keyName) and a key with the same name already exists.
Type
SyncPromise