Creates a new key source instance.
Note: The config may be empty/undefined when using ClassFactory. Configuration is typically loaded from the database and passed when retrieving keys.
Optionalconfig: EncryptionKeySourceConfigOptional configuration for the key source
Protected_Configuration passed during instantiation. Contains lookupValue and any source-specific additional config.
Cleans up resources (no-op for config file source).
Retrieves key material from the configuration file.
Keys should be stored as base64-encoded strings in the encryptionKeys section of the configuration file.
For versioned keys, the version is appended with an underscore:
key_name for version 1 (default)key_name_v2 for version 2The key name in the configuration
OptionalkeyVersion: stringOptional version number (defaults to '1')
Promise resolving to the decoded key bytes
Checks if a key exists in the configuration file.
The key name to check
Promise resolving to true if the key exists
Validates that the configuration file was loaded successfully.
true if the config file was loaded and contains encryptionKeys
Validates that the encryption key in the config file is accessible and usable.
Checks: config loaded, key exists, valid base64, and (if specified) correct length. Key material is decoded internally for validation only — never returned to the caller.
OptionalkeyVersion: stringOptionalexpectedKeyLengthBytes: number
Encryption key source that retrieves keys from configuration files.
Uses cosmiconfig to locate configuration in standard locations:
Keys are read from the
encryptionKeyssection of the configuration.Example