Config. SecureConfig

new SecureConfig(id, config, timeoutMs, includeActivity, argon)

A secure configuration. This uses an underlying IConfig for storage. Multiple secure configs can be placed within the same IConfig so long as different id is set. By default pbkdf2 is used to generate NaCl keys. If argon is provided then argon2 will be used to generate the NaCl keys. Applications should use argon2.

Parameters:
NameTypeDescription
idstring

The id of this secure config. Multiple secure configs can be stored within a single IConfig

configIConfig

The underlying IConfig to use for storage

timeoutMsnumber

Timeout since last unlock, after which the config will be locked. Defaults to 5 minutes.

includeActivityboolean

When set to true the timeout is reset after any read/write activity. Defaults to true

argonArgon2

Instance of argon2 from either npm:argon2 or npm:argon2-browser

Methods

(async, static) clear()

(async, static) isInitialized() → {boolean}

Checks if the secure config has initialized with a password or key

Returns:
Type: 
boolean

(static) isLocked() → {boolean}

Checks if the secure config is locked. If not locked the secure config can be used without blocking waiting for user to unlock.

Returns:
Type: 
boolean

(static) lock()

Locks the secure config

(async, static) read(key)

Parameters:
NameTypeDescription
keystring

(async, static) readAll() → {object}

Returns:
Type: 
object

(async, static) save()

(async, static) setIdentity(key, defaults)

Initialize the secure config with a key

Parameters:
NameTypeDescription
keydataparty_crypto/IKey
defaultsobject

(async, static) setPassword(password, defaults)

Initialize the secure config with a password

Parameters:
NameTypeDescription
passwordstring
defaultsobject

(async, static) start()

Start the secure storage

(async, static) unlock(password)

Unlocks the secure config

Parameters:
NameTypeDescription
passwordstring

(async, static) waitForUnlocked(reason)

Wait for config to be unlocked

Parameters:
NameTypeDescription
reasonstring

Optional reason message if config is locked

(async, static) write(key, data)

Parameters:
NameTypeDescription
keystring
dataobject

Events

blocked

An read/write operation has been blocked due to the secure config being locked.

intialized

The secure config has been successfully initialized with a passowrd or key.

locked

The secure config has been locked

ready

Ready event. The secure config is ready to be unlocked and have configuration values read or written.

setup-required

Setup required event. The secure config has not yet has a password or key configured.

unlocked

The secure config has been unlocked