Class: PibKeyImpl

PibKeyImpl()

new PibKeyImpl()

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

Methods

(static) makePromise(keyName, keyEncoding, {PibImpl), useSync, A)

Create a PibKeyImpl. This method has two forms: PibKeyImpl(keyName, keyEncoding, pibImpl, useSync) - Create a PibKeyImpl with keyName. If the key does not exist in the backend implementation, add it by creating it from the keyEncoding. If a key with keyName already exists, overwrite it. PibKeyImpl(keyName, pibImpl, useSync) - Create a PibKeyImpl with keyName. Initialize the cached key encoding with pibImpl.getKeyBits(). 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
keyName Name The name of the key, which is copied.
keyEncoding Buffer The buffer of encoded key bytes, which is copied. (This is only used in the constructor form PibKeyImpl(keyName, keyEncoding, pibImpl) .)
{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 PibKeyImpl, or a promise which is rejected with Pib.Error if the constructor is the form PibKeyImpl(keyName, pibImpl) (without the keyEncoding) and the key with keyName does not exist.
Source:

addCertificatePromise(certificate, useSync) → {Promise|SyncPromise}

Add the certificate. If a certificate with the same name (without implicit digest) already exists, then overwrite the certificate. If no default certificate for the key has been set, then set the added certificate as default for the key.
Parameters:
Name Type Description
certificate CertificateV2 The certificate to add. This copies the object.
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 the name of the certificate does not match the key name.
Type
Promise | SyncPromise

getCertificatePromise(certificateName, useSync) → {Promise|SyncPromise}

Get the certificate with name certificateName.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
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 a copy of the CertificateV2, or a promise rejected with Error if certificateName does not match the key name, or a promise rejected with Pib.Error if the certificate does not exist.
Type
Promise | SyncPromise

getDefaultCertificatePromise(useSync) → {Promise|SyncPromise}

Get the default certificate for this Key.
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 CertificateV2, or a promise rejected with Pib.Error if the default certificate does not exist.
Type
Promise | SyncPromise

getIdentityName() → {Name}

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

getKeyType() → {number}

Get the key type.
Source:
Returns:
The key type as an int from the KeyType enum.
Type
number

getName() → {Name}

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

getPublicKey() → {Blob}

Get the public key encoding.
Source:
Returns:
The public key encoding.
Type
Blob

removeCertificatePromise(certificateName, useSync) → {Promise|SyncPromise}

Remove the certificate with name certificateName. If the certificate does not exist, do nothing.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
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 certificateName does not match the key name.
Type
Promise | SyncPromise

setDefaultCertificatePromise(certificateOrCertificateName, certificateName, useSync) → {Promise|SyncPromise}

Set the existing certificate as the default certificate.
Parameters:
Name Type Description
certificateOrCertificateName Name | CertificateV2 If certificateOrCertificateName is a Name, it is the name of the certificate, which must exist. Otherwise certificateOrCertificateName is the CertificateV2 to add (if necessary) and set as the default.
certificateName Name The name of the certificate.
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 CertificateV2, or a promise rejected with Error if certificateName does not match the key name, or a promise rejected with Pib.Error if certificateOrCertificateName is the certificate Name and the certificate does not exist.
Type
Promise | SyncPromise