Member Junction
    Preparing search index...

    Encryption key source that retrieves keys from configuration files.

    Uses cosmiconfig to locate configuration in standard locations:

    • mj.config.cjs (recommended)
    • mj.config.js
    • .mjrc.json
    • .mjrc.yaml

    Keys are read from the encryptionKeys section of the configuration.

    // Configuration file (mj.config.cjs):
    module.exports = {
    encryptionKeys: {
    pii_master: 'base64-encoded-key-here',
    financial_data: 'another-base64-key'
    }
    };

    // Usage (typically automatic via ClassFactory):
    const source = new ConfigFileKeySource();
    await source.Initialize(); // Load the config file

    const key = await source.GetKey('pii_master');

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Configuration passed during instantiation. Contains lookupValue and any source-specific additional config.

    Accessors

    Methods

    • 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 2

      Parameters

      • lookupValue: string

        The key name in the configuration

      • OptionalkeyVersion: string

        Optional version number (defaults to '1')

      Returns Promise<Buffer>

      Promise resolving to the decoded key bytes

      Error if Initialize() was not called

      Error if the key is not found

      Error if the value is not valid base64

      // Config file has: encryptionKeys: { pii_master: '...' }
      const key = await source.GetKey('pii_master');

      // For versioned keys during rotation:
      // Config has: pii_master, pii_master_v2
      const newKey = await source.GetKey('pii_master', '2');