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
.
Name | Type | Description |
---|---|---|
id | string | The id of this secure config. Multiple secure configs can be stored within a single |
config | IConfig | The underlying IConfig to use for storage |
timeoutMs | number | Timeout since last unlock, after which the config will be locked. Defaults to 5 minutes. |
includeActivity | boolean | When set to |
argon | Argon2 | Instance of argon2 from either |
- Implements
- Source
Methods
(async, static) clear()
- Source
(async, static) isInitialized() → {boolean}
Checks if the secure config has initialized with a password or key
- Source
- 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.
- Source
- Type:
- boolean
(static) lock()
Locks the secure config
- Source
(async, static) read(key)
Name | Type | Description |
---|---|---|
key | string |
- Source
(async, static) readAll() → {object}
- Source
- Type:
- object
(async, static) save()
- Source
(async, static) setIdentity(key, defaults)
Initialize the secure config with a key
Name | Type | Description |
---|---|---|
key | dataparty_crypto/IKey | |
defaults | object |
- Source
(async, static) setPassword(password, defaults)
Initialize the secure config with a password
Name | Type | Description |
---|---|---|
password | string | |
defaults | object |
- Source
(async, static) start()
Start the secure storage
- Source
(async, static) unlock(password)
Unlocks the secure config
Name | Type | Description |
---|---|---|
password | string |
- Source
(async, static) waitForUnlocked(reason)
Wait for config to be unlocked
Name | Type | Description |
---|---|---|
reason | string | Optional reason message if config is locked |
- Source
(async, static) write(key, data)
Name | Type | Description |
---|---|---|
key | string | |
data | object |
- Source
Events
blocked
An read/write operation has been blocked due to the secure config being locked.
- Implements
- Source
intialized
The secure config has been successfully initialized with a passowrd or key.
- Source
locked
The secure config has been locked
- Implements
- Source
ready
Ready event. The secure config is ready to be unlocked and have configuration values read or written.
- Implements
- Source
setup-required
Setup required event. The secure config has not yet has a password or key configured.
- Source
unlocked
The secure config has been unlocked
- Source