new BasicIdentityStorage(databaseFilePath, initialCheckPromise)
BasicIdentityStorage extends IdentityStorage to implement basic storage of
identity, public keys and certificates using the Node.js sqlite3 module.
Create a new BasicIdentityStorage to use the SQLite3 file in the default
location, or the optional given file.
Parameters:
Name | Type | Description |
---|---|---|
databaseFilePath |
string | (optional) The path of the SQLite3 file. If omitted, use the default file (~/.ndn/ndnsec-public-info.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. |
Methods
(static) getDefaultDatabaseDirectoryPath() → {string}
Get the default directory that the constructor uses if databaseFilePath is
omitted. This does not try to create the directory.
Returns:
The default database directory path.
- Type
- string
(static) getDefaultDatabaseFilePath() → {string}
Get the default database file path that the constructor uses if
databaseFilePath is omitted.
Returns:
The default database file path.
- Type
- string
(static) getUserHomePath() → {string}
Retrieve the user's current home directory
Returns:
path to the user's home directory
- Type
- string
addCertificatePromise(certificate, useSync) → {Promise}
Add a certificate to the identity storage. Also call addKey to ensure that
the certificate key exists. If the certificate is already installed, don't
replace it.
Parameters:
Name | Type | Description |
---|---|---|
certificate |
IdentityCertificate | The certificate to be added. This makes a copy of the certificate. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when finished.
- Type
- Promise
addIdentityPromise(identityName, useSync) → {Promise}
Add a new identity. Do nothing if the identity already exists.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The identity name to be added. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the identity is added.
- Type
- Promise
addKeyPromise(keyName, keyType, publicKeyDer, useSync) → {Promise}
Add a public key to the identity storage. Also call addIdentity to ensure
that the identityName for the key exists. However, if the key already
exists, do nothing.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the public key to be added. |
keyType |
number | Type of the public key to be added from KeyType, such as KeyType.RSA.. |
publicKeyDer |
Blob | A blob of the public key DER to be added. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when complete.
- Type
- Promise
deleteCertificateInfoPromise(certificateName, useSync) → {Promise}
Delete a certificate.
Parameters:
Name | Type | Description |
---|---|---|
certificateName |
Name | The certificate name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the certificate info is
deleted.
- Type
- Promise
deleteIdentityInfoPromise(identityName, useSync) → {Promise}
Delete an identity and related public keys and certificates.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The identity name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the identity info is deleted.
- Type
- Promise
deletePublicKeyInfoPromise(keyName, useSync) → {Promise}
Delete a public key and related certificates.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The key name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the public key info is
deleted.
- Type
- Promise
doesCertificateExistPromise(certificateName, useSync) → {Promise}
Check if the specified certificate already exists.
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. |
Returns:
A promise which returns true if the certificate exists.
- Type
- Promise
doesIdentityExistPromise(identityName, useSync) → {Promise}
Check if the specified identity already exists.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The identity name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns true if the identity exists.
- Type
- Promise
doesKeyExistPromise(keyName, useSync) → {Promise}
Check if the specified key already exists.
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. |
Returns:
A promise which returns true if the key exists.
- Type
- Promise
eachPromise_()
Call Sqlite3Promise.eachPromise, wrapping an Error in SecurityException.
getAllCertificateNamesOfKeyPromise(keyName, nameList, isDefault, useSync) → {Promise}
Append all the certificate names of a particular key name to the nameList.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The key name to search for. |
nameList |
Array.<Name> | Append result names to nameList. |
isDefault |
boolean | If true, add only the default certificate name. If false, add only the non-default certificate names. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the names are added to
nameList.
- Type
- Promise
getAllIdentitiesPromise(nameList, isDefault, useSync) → {Promise}
Append all the identity names to the nameList.
Parameters:
Name | Type | Description |
---|---|---|
nameList |
Array.<Name> | Append result names to nameList. |
isDefault |
boolean | If true, add only the default identity name. If false, add only the non-default identity names. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the names are added to
nameList.
- Type
- Promise
getAllKeyNamesOfIdentityPromise(identityName, nameList, isDefault, useSync) → {Promise}
Append all the key names of a particular identity to the nameList.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The identity name to search for. |
nameList |
Array.<Name> | Append result names to nameList. |
isDefault |
boolean | If true, add only the default key name. If false, add only the non-default key names. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the names are added to
nameList.
- Type
- Promise
getCertificatePromise(certificateName, useSync) → {Promise}
Get a certificate from the identity storage.
Parameters:
Name | Type | Description |
---|---|---|
certificateName |
Name | The name of the requested certificate. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the requested
IdentityCertificate, or a promise rejected with SecurityException if the
certificate doesn't exist.
- Type
- Promise
getDefaultCertificateNameForKeyPromise(keyName, useSync) → {Promise}
Get the default certificate name for the specified key.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The key name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the default certificate Name, or a
promise rejected with SecurityException if the default certificate name for
the key name is not set.
- 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. |
Returns:
A promise which returns the Name of default identity, or a
promise rejected with SecurityException if the default identity is not set.
- Type
- Promise
getDefaultKeyNameForIdentityPromise(identityName, useSync) → {Promise}
Get the default key name for the specified identity.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The identity name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the default key Name, or a promise
rejected with SecurityException if the default key name for the identity is
not set.
- Type
- Promise
getKeyPromise(keyName, useSync) → {Promise}
Get the public key DER blob from the identity storage.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the requested public key. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the DER Blob, or a promise rejected
with SecurityException if the key doesn't exist.
- Type
- Promise
getPromise_()
Call Sqlite3Promise.getPromise, wrapping an Error in SecurityException.
getTpmLocatorPromise(useSync) → {Promise}
Get the TPM locator associated with this storage.
Parameters:
Name | Type | Description |
---|---|---|
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which returns the TPM locator, or a promise
rejected with SecurityException if the TPM locator doesn't exist.
- Type
- Promise
runPromise_()
Call Sqlite3Promise.runPromise, wrapping an Error in SecurityException.
setDefaultCertificateNameForKeyPromise(keyName, certificateName, useSync) → {Promise}
Set the default key name for the specified identity.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The key name. |
certificateName |
Name | The certificate name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the default certificate name
is set.
- Type
- Promise
setDefaultIdentityPromise(identityName, useSync) → {Promise}
Set the default identity. If the identityName does not exist, then clear the
default identity so that getDefaultIdentity() throws an exception.
Parameters:
Name | Type | Description |
---|---|---|
identityName |
Name | The default identity name. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the default identity is set.
- Type
- Promise
setDefaultKeyNameForIdentityPromise(keyName, identityNameCheck, useSync) → {Promise}
Set a key as the default key of an identity. The identity name is inferred
from keyName.
Parameters:
Name | Type | Description |
---|---|---|
keyName |
Name | The name of the key. |
identityNameCheck |
Name | (optional) The identity name to check that the keyName contains the same identity name. If an empty name, it is ignored. |
useSync |
boolean | (optional) If true then return a rejected promise since this only supports async code. |
Returns:
A promise which fulfills when the default key name is set.
- Type
- Promise