Socket
Book a DemoInstallSign in
Socket

@sean-nicholas/encrypted-config

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sean-nicholas/encrypted-config

Loads a config file from disk and decrypts encrypted values

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

Encrypted Config

Loads a config.json file from disk and decrypts encrypted values.

Usage

Encryption

To encrypt settings for your configuration file run encrypter(encryptionKey). This starts a CLI. Enter your secret and the encrypted value will be printed.

Load & Patch Config

Generally, you start with a simple config object that you define in your source code. It is filled with development / standard values.

export let config = {
  mail: {
    config: {
      pool: true,
      host: 'localhost',
      port: 1025,
      secure: false,
      ignoreTLS: true,
      auth: {
        user: '',
        pass: '',
      }
    },
  },
}

Then load the config with:

config = loadConfig({
  config,
  encryptedFields: ['mail.config.auth.pass'],
  encryptionKey: ENCRYPTION_KEY,
  filePath: '/path/to/config.json' // Defaults to process.cwd()/config.json
})

Afterwards you can use the config object as usual:

const password = config.mail.auth.pass

The config.json in this example would look like this:

{
  "mail": {
    "config": {
      "auth": {
        "user": "test@example.com",
        "pass": "c0a15190ec84532eaba420a2bdc269b9:e93wa3c963"
      }
    }
  }
}

FAQs

Package last updated on 21 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.