Class: SafeValue

SafeValue(setup)

Represents a SafeValue object used for encrypting and decrypting sensitive data. Extends _Global class and encapsulates encryption and decryption functionality.

Constructor

new SafeValue(setup)

Creates a new SafeValue instance with the provided setup parameters.

Parameters:
Name Type Description
setup Object

The setup object containing encryption details (encrypted, type, algorithm, iv, salt, derivatedKey, displayValue).

Source:
Throws:

If there's an error during instantiation, it is caught and logged.

Type
Error

Members

(readonly) binString

Returns the binary string representation of the encrypted data.

Source:

Methods

read() → {string|undefined}

Decrypts and returns the original data from the SafeValue object.

Source:
Returns:

The decrypted original data, or undefined if the SafeValue is empty.

Type
string | undefined

(async) setEncrypted(newValue) → {Promise.<Object>}

Updates the encrypted data with a new encrypted value.

Parameters:
Name Type Description
newValue string

The new encrypted value to be set.

Source:
Returns:

A Promise that resolves to the updated SafeValue object.

Type
Promise.<Object>

(async, static) createEncrypt(rawValue) → {Promise.<Object>}

Creates a new encrypted SafeValue instance with the given raw value.

Parameters:
Name Type Description
rawValue string

The raw value to be encrypted.

Source:
Returns:

A Promise that resolves to the created SafeValue object.

Type
Promise.<Object>