Class: Pib

Pib(scheme, location, pibImpl)

new Pib(scheme, location, pibImpl)

In general, a PIB (Public Information Base) stores the public portion of a user's cryptography keys. The format and location of stored information is indicated by the PIB locator. A PIB is designed to work with a TPM (Trusted Platform Module) which stores private keys. There is a one-to-one association between a PIB and a TPM, and therefore the TPM locator is recorded by the PIB to enforce this association and prevent one from operating on mismatched PIB and TPM. Information in the PIB is organized in a hierarchy of Identity-Key-Certificate. At the top level, this Pib class provides access to identities, and allows setting a default identity. Properties of an identity (such as PibKey objects) can be accessed after obtaining a PibIdentity object. (Likewise, CertificateV2 objects can be obtained from a PibKey object.) Note: A Pib instance is created and managed only by the KeyChain, and is returned by the KeyChain getPib() method. Create a Pib instance. This constructor should only be called by KeyChain.
Parameters:
Name Type Description
scheme string The scheme for the PIB.
location string The location for the PIB.
pibImpl PibImpl The PIB backend implementation.
Source:

Classes

Error

Methods

addIdentityPromise_(identityName, useSync) → {Promise|SyncPromise}

Add an identity with name identityName. Create the identity if it does not exist. This should only be called by KeyChain.
Parameters:
Name Type Description
identityName Name The name of the identity, which is copied.
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 PibIdentity object of the added identity.
Type
Promise | SyncPromise

doSetTpmLocatorPromise_(tpmLocator, useSync) → {Promise|SyncPromise}

Do the work of setTpmLocatorPromise without calling initializePromise_.
Parameters:
Name Type Description
tpmLocator string The TPM locator.
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

getDefaultIdentity(onComplete, onError) → {PibIdentity}

Get the default identity.
Parameters:
Name Type Description
onComplete function (optional) This calls onComplete(identity) with the PibIdentity object. If omitted, the return value is described below. (Some database libraries only use a callback, so onComplete is required to use these.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
onError function (optional) If defined, then onComplete must be defined and if there is an exception, then this calls onError(exception) with the exception. If onComplete is defined but onError is undefined, then this will log any thrown exception. (Some database libraries only use a callback, so onError is required to be notified of an exception.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
Source:
Throws:
Pib.Error for no default identity. However, if onComplete and onError are defined, then if there is an exception return undefined and call onError(exception).
Returns:
If onComplete is omitted, return the PibIdentity object. Otherwise, if onComplete is supplied then return undefined and use onComplete as described above.
Type
PibIdentity

getDefaultIdentityPromise(useSync) → {Promise|SyncPromise}

Get the default 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 PibIdentity object of the default identity, or a promise rejected with Pib.Error for no default identity.
Type
Promise | SyncPromise

getIdentity(identityName, onComplete, onError) → {PibIdentity}

Get the identity with name identityName.
Parameters:
Name Type Description
identityName Name The name of the identity.
onComplete function (optional) This calls onComplete(identity) with the PibIdentity object. If omitted, the return value is described below. (Some database libraries only use a callback, so onComplete is required to use these.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
onError function (optional) If defined, then onComplete must be defined and if there is an exception, then this calls onError(exception) with the exception. If onComplete is defined but onError is undefined, then this will log any thrown exception. (Some database libraries only use a callback, so onError is required to be notified of an exception.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
Source:
Throws:
Pib.Error if the identity does not exist. However, if onComplete and onError are defined, then if there is an exception return undefined and call onError(exception).
Returns:
If onComplete is omitted, return the PibIdentity object. Otherwise, if onComplete is supplied then return undefined and use onComplete as described above.
Type
PibIdentity

getIdentityPromise(identityName, useSync) → {Promise|SyncPromise}

Get the identity with name identityName.
Parameters:
Name Type Description
identityName Name The name of the identity.
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 PibIdentity object, or a promise rejected with Pib.Error if the identity does not exist.
Type
Promise | SyncPromise

getPibLocator() → {string}

Get the PIB locator.
Source:
Returns:
The PIB locator.
Type
string

getScheme() → {string}

Get the scheme of the PIB locator.
Source:
Returns:
The scheme string.
Type
string

getTpmLocatorPromise(useSync) → {Promise|SyncPromise}

Get the TPM Locator.
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 TPM locator string, or a promise rejected with Pib.Error if the TPM locator is empty.
Type
Promise | SyncPromise

initializeFromLocatorsPromise_(useSync) → {Promise|SyncPromise}

Initialize from initializePibLocator_ and initializeTpmLocator_ in the same way that the KeyChain constructor would if it could do async operations. Set up initializeTpm_ and set its isInitialized_ true.
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 fulfills when finished.
Type
Promise | SyncPromise

initializePromise_(useSync) → {Promise|SyncPromise}

If isInitialized_ is false, initialize identities_ using PibIdentityContainer.makePromise and set isInitialized_. However, if isInitialized_ is already true, do nothing. This must be called by each method before using this object. This is necessary because the constructor cannot perform async operations.
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 fulfills when finished.
Type
Promise | SyncPromise

removeIdentityPromise_(identityName, useSync) → {Promise|SyncPromise}

Remove the identity with name identityName, 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. This should only be called by KeyChain.
Parameters:
Name Type Description
identityName Name The name of the identity.
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

resetPromise_(useSync) → {Promise|SyncPromise}

Reset the content in the PIB, including a reset of the TPM locator. This should only be called by initializeFromLocatorsPromise_.
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 fulfills when finished.
Type
Promise | SyncPromise

setDefaultIdentityPromise_(identityName, useSync) → {Promise|SyncPromise}

Set the identity with name identityName as the default identity. Create the identity if it does not exist. This should only be called by KeyChain.
Parameters:
Name Type Description
identityName Name The name of the identity.
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 PibIdentity object of the default identity.
Type
Promise | SyncPromise

setTpmLocatorPromise(tpmLocator, useSync) → {Promise|SyncPromise}

Set the corresponding TPM information to tpmLocator. If the tpmLocator is different from the existing one, the PIB will be reset. Otherwise, nothing will be changed.
Parameters:
Name Type Description
tpmLocator string The TPM locator.
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