Class: PibSqlite3

PibSqlite3(databaseDirectoryPath, databaseFilename, initialCheckPromise)

new PibSqlite3(databaseDirectoryPath, databaseFilename, initialCheckPromise)

PibSqlite3 extends PibImpl and is used by the Pib class as an implementation of a PIB based on an SQLite3 database. All the contents in the PIB are stored in an SQLite3 database file. This provides more persistent storage than PibMemory. Create a new PibSqlite3 to work with an SQLite3 file. This assumes that the database directory does not contain a PIB database of an older version.
Parameters:
Name Type Description
databaseDirectoryPath string (optional) The directory where the database file is located. If omitted, use $HOME/.ndn . If the directory does not exist, this does not try to create it.
databaseFilename string (optional) The name if the database file in the databaseDirectoryPath. If databaseFilename is supplied, then databaseDirectoryPath must also be supplied. If omitted, use "pib.db".
initialCheckPromise function (optional) If supplied, then after initializing the database this calls initialCheckPromise() which returns a Promise that resolves when the initial check passes or is rejected for a problem.
Source:

Methods

addCertificatePromise(certificate, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the certificate is added.
Type
Promise

addIdentityPromise(identityName, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the identity is added.
Type
Promise

addKeyPromise(identityName, keyName, key, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the key is added.
Type
Promise

clearIdentitiesPromise(useSync) → {Promise}

Erase all certificates, keys, and identities.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the identities are cleared.
Type
Promise

eachPromise_()

Call Sqlite3Promise.eachPromise, wrapping an Error in PibImpl.Error.
Source:

getCertificatePromise(certificateName, useSync) → {Promise}

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 rejected promise since this only supports async code.
Source:
Returns:
A promise which returns the CertificateV2, or a promise rejected with Pib.Error if the certificate does not exist.
Type
Promise

getCertificatesOfKeyPromise(keyName, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

getDefaultCertificateOfKeyPromise(keyName, useSync) → {Promise}

Get the default certificate for the key with eyName.
Parameters:
Name Type Description
keyName Name The name of the key.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

getDefaultIdentityPromise(useSync) → {Promise}

Get the default identity.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

getDefaultKeyOfIdentityPromise(identityName, useSync) → {Promise}

Get the name of the default key for the identity with name identityName.
Parameters:
Name Type Description
identityName Name The name of the identity.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

getIdentitiesPromise(useSync) → {Promise}

Get the names of all the identities.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which returns a fresh set of identity names as an array of Name. The Name objects are fresh copies.
Type
Promise

getKeyBitsPromise(keyName, useSync) → {Promise}

Get the key bits of a key with name keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

getKeysOfIdentityPromise(identityName, useSync)

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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.

getPromise_()

Call Sqlite3Promise.getPromise, wrapping an Error in PibImpl.Error.
Source:

getTpmLocatorPromise(useSync) → {Promise}

Get the TPM Locator.
Parameters:
Name Type Description
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which returns the TPM locator string.
Type
Promise

hasCertificatePromise(certificateName, useSync) → {Promise}

Check for the existence of a certificate with name certificateName.
Parameters:
Name Type Description
certificateName Name The name of the certificate.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which returns true if the certificate exists, otherwise false.
Type
Promise

hasDefaultCertificateOfKeyPromise_(keyName) → {Promise}

Check if there is a default certificate for the key with keyName.
Parameters:
Name Type Description
keyName Name The key Name.
Source:
Returns:
A promise which returns true if there is a default certificate.
Type
Promise

hasDefaultIdentityPromise_() → {Promise}

Check if there is a default identity.
Source:
Returns:
A promise which returns true if there is a default identity.
Type
Promise

hasDefaultKeyOfIdentityPromise_(identityName) → {Promise}

Check if there is a default key for the identity with identityName.
Parameters:
Name Type Description
identityName Name The identity Name.
Source:
Returns:
A promise which returns true if there is a default key.
Type
Promise

hasIdentityPromise(identityName, useSync) → {Promise}

Check for the existence of an identity.
Parameters:
Name Type Description
identityName Name The name of the identity.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which returns true if the identity exists, otherwise false.
Type
Promise

hasKeyPromise(keyName, useSync) → {Promise}

Check for the existence of a key with keyName.
Parameters:
Name Type Description
keyName Name The name of the key.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which returns true if the key exists, otherwise false. Return false if the identity does not exist.
Type
Promise

removeCertificatePromise(certificateName, useSync) → {Promise}

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 rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the certificate is removed.
Type
Promise

removeIdentityPromise(identityName, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the identity is removed.
Type
Promise

removeKeyPromise(keyName, useSync) → {Promise}

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 rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the key is removed.
Type
Promise

runPromise_()

Call Sqlite3Promise.runPromise, wrapping an Error in PibImpl.Error.
Source:

setDefaultCertificateOfKeyPromise(keyName, certificateName, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

setDefaultIdentityPromise(identityName, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the default identity is set.
Type
Promise

setDefaultKeyOfIdentityPromise(identityName, keyName, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
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
Promise

setTpmLocatorPromise(tpmLocator, useSync) → {Promise}

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.
useSync boolean (optional) If true then return a rejected promise since this only supports async code.
Source:
Returns:
A promise which fulfills when the TPM locator is set.
Type
Promise

(static) getDefaultDatabaseDirectoryPath() → {string}

Get the default that the constructor uses if databaseDirectoryPath is omitted. This does not try to create the directory.
Source:
Returns:
The default database directory path.
Type
string

(static) getDefaultDatabaseFilePath() → {string}

Get the default database file path that the constructor uses if databaseDirectoryPath and databaseFilename are omitted.
Source:
Returns:
The default database file path.
Type
string