Class: PibMemory

PibMemory()

new PibMemory()

PibMemory extends PibImpl and is used by the Pib class as an in-memory implementation of a PIB. All the contents in the PIB are stored in memory and have the same lifetime as the PibMemory instance.
Source:

Methods

addCertificatePromise(certificate) → {SyncPromise}

Add the certificate. If a certificate with the same name (without implicit digest) already exists, then overwrite the certificate. If the key or identity does not exist, they will be created. If no default certificate for the key has been set, then set the added certificate as the default for the key. If no default key was set for the identity, it will be set as the default key for the identity. If no default identity was selected, the certificate's identity becomes the default.
Parameters:
Name Type Description
certificate CertificateV2 The certificate to add. This copies the object.
Source:
Returns:
A promise which fulfills when the certificate is added.
Type
SyncPromise

addIdentity_()

Do the work of addIdentityPromise.
Source:

addIdentityPromise(identityName) → {SyncPromise}

Add the identity. If the identity already exists, do nothing. If no default identity has been set, set the added identity as the default.
Parameters:
Name Type Description
identityName Name The name of the identity to add. This copies the name.
Source:
Returns:
A promise which fulfills when the identity is added.
Type
SyncPromise

addKey_()

Do the work of addKeyPromise,
Source:

addKeyPromise(identityName, keyName, key) → {SyncPromise}

Add the key. If a key with the same name already exists, overwrite the key. If the identity does not exist, it will be created. If no default key for the identity has been set, then set the added key as the default for the identity. If no default identity has been set, identity becomes the default.
Parameters:
Name Type Description
identityName Name The name of the identity that the key belongs to. This copies the name.
keyName Name The name of the key. This copies the name.
key Buffer The public key bits. This copies the array.
Source:
Returns:
A promise which fulfills when the key is added.
Type
SyncPromise

clearIdentitiesPromise() → {SyncPromise}

Erase all certificates, keys, and identities.
Source:
Returns:
A promise which fulfills when the identities are cleared.
Type
SyncPromise

getCertificatePromise(certificateName) → {SyncPromise}

Get the certificate with name certificateName.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
Source:
Returns:
A promise which returns the CertificateV2, or a promise rejected with Pib.Error if the certificate does not exist.
Type
SyncPromise

getCertificatesOfKey_()

Do the work of getCertificatesOfKeyPromise.
Source:

getCertificatesOfKeyPromise(keyName) → {SyncPromise}

Get a list of certificate names of the key with id keyName. The returned certificate names can be used to create a PibCertificateContainer. With a certificate name and a backend implementation, one can obtain the certificate.
Parameters:
Name Type Description
keyName Name The name of the key.
Source:
Returns:
A promise which returns the set of certificate names as an array of Name. The Name objects are fresh copies. If the key does not exist, return an empty array.
Type
SyncPromise

getDefaultCertificateOfKeyPromise(keyName) → {SyncPromise}

Get the default certificate for the key with eyName.
Parameters:
Name Type Description
keyName Name The name of the key.
Source:
Returns:
A promise which returns a copy of the default CertificateV2, or a promise rejected with Pib.Error if the default certificate does not exist.
Type
SyncPromise

getDefaultIdentityPromise() → {SyncPromise}

Get the default identity.
Source:
Returns:
A promise which returns the Name of the default identity as a fresh copy, or a promise rejected with Pib.Error for no default identity.
Type
SyncPromise

getDefaultKeyOfIdentityPromise(identityName) → {SyncPromise}

Get the name of the default key for the identity with name identityName.
Parameters:
Name Type Description
identityName Name The name of the identity.
Source:
Returns:
A promise which returns the name of the default key as a fresh copy, or a promise rejected with Pib.Error if the identity does not exist.
Type
SyncPromise

getIdentitiesPromise() → {SyncPromise}

Get the names of all the identities.
Source:
Returns:
A promise which returns a fresh set of identity names as an array of Name. The Name objects are fresh copies.
Type
SyncPromise

getKeyBitsPromise(keyName) → {SyncPromise}

Get the key bits of a key with name keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
Source:
Returns:
A promise which returns the key bits as a Blob, or a promise rejected with Pib.Error if the key does not exist.
Type
SyncPromise

getKeysOfIdentity_()

Do the work of getKeysOfIdentityPromise
Source:

getKeysOfIdentityPromise(identityName)

Get all the key names of the identity with the name identityName. The returned key names can be used to create a KeyContainer. With a key name and a backend implementation, one can create a Key front end instance.
Parameters:
Name Type Description
identityName Name The name of the identity.
Source:
Returns:
SyncPromise} A promise which returns the set of key names as an array of Name. The Name objects are fresh copies. If the identity does not exist, return an empty array.

getTpmLocatorPromise() → {SyncPromise}

Get the TPM Locator.
Source:
Returns:
A promise which returns the TPM locator string.
Type
SyncPromise

hasCertificate_()

Do the work of hasCertificatePromise.
Source:

hasCertificatePromise(certificateName) → {SyncPromise}

Check for the existence of a certificate with name certificateName.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
Source:
Returns:
A promise which returns true if the certificate exists, otherwise false.
Type
SyncPromise

hasIdentity_()

Do the work of hasIdentityPromise.
Source:

hasIdentityPromise(identityName) → {SyncPromise}

Check for the existence of an identity.
Parameters:
Name Type Description
identityName Name The name of the identity.
Source:
Returns:
A promise which returns true if the identity exists, otherwise false.
Type
SyncPromise

hasKey_()

Do the work of hasKeyPromise.
Source:

hasKeyPromise(keyName) → {SyncPromise}

Check for the existence of a key with keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
Source:
Returns:
A promise which returns true if the key exists, otherwise false. Return false if the identity does not exist.
Type
SyncPromise

removeCertificate_()

Do the work of removeCertificatePromise.
Source:

removeCertificatePromise(certificateName) → {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.
Source:
Returns:
A promise which fulfills when the certificate is removed.
Type
SyncPromise

removeIdentityPromise(identityName) → {SyncPromise}

Remove the identity and its related keys and certificates. If the default identity is being removed, no default identity will be selected. If the identity does not exist, do nothing.
Parameters:
Name Type Description
identityName Name The name of the identity to remove.
Source:
Returns:
A promise which fulfills when the identity is removed.
Type
SyncPromise

removeKey_()

Do the work of removeKeyPromise.
Source:

removeKeyPromise(keyName) → {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.
Source:
Returns:
A promise which fulfills when the key is removed.
Type
SyncPromise

setDefaultCertificateOfKeyPromise(keyName, certificateName) → {SyncPromise}

Set the cert with name certificateName as the default for the key with keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
certificateName Name The name of the certificate. This copies the name.
Source:
Returns:
A promise which fulfills when the default certificate is set, or a promise rejected with Pib.Error if the certificate with name certificateName does not exist.
Type
SyncPromise

setDefaultIdentityPromise(identityName) → {SyncPromise}

Set the identity with the identityName as the default identity. If the identity with identityName does not exist, then it will be created.
Parameters:
Name Type Description
identityName Name The name for the default identity. This copies the name.
Source:
Returns:
A promise which fulfills when the default identity is set.
Type
SyncPromise

setDefaultKeyOfIdentityPromise(identityName, keyName) → {SyncPromise}

Set the key with keyName as the default key for the identity with name identityName.
Parameters:
Name Type Description
identityName Name The name of the identity. This copies the name.
keyName Name The name of the key. This copies the name.
Source:
Returns:
A promise which fulfills when the default key is set, or a promise rejected with Pib.Error if the key does not exist.
Type
SyncPromise

setTpmLocatorPromise(tpmLocator) → {SyncPromise}

Set the corresponding TPM information to tpmLocator. This method does not reset the contents of the PIB.
Parameters:
Name Type Description
tpmLocator string The TPM locator string.
Source:
Returns:
A promise which fulfills when the TPM locator is set.
Type
SyncPromise