1.0.1 • Published 2 years ago

node-secret-service v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

node-secret-service

Library to store secrets with encryption for node

Usage

Example

  • create a secrets folder to store all JSON files
  • add unencrypted JSON files from secrets folder and the encryption key to .gitignore
  • Encryption key (master.key) will be created on initializing of SecretService in the config.key_file_path path, if not already created

Example .gitignore file

secrets/*.json
master.key

and use this code snippet to configure secrets encryption

import SecretService from "node-secret-service";

const config = {
  key_file_path: `${__dirname}/master.key`,
  folder_path: `${__dirname}/secrets`
}

// initiate secret service
const secret_service = new SecretService(config)

// encrypt JSON files in secrets folder path
secret_service.encryptSecrets()

// get all encrypted secrets from secrets folder as a JSON Object
secret_service.getSecrets()
  • Encrypted JSON files are created on running the secret_service.encryptSecrets() line with .enc extension

Working with a Team using Secret Service

  • push the .enc files to git.
  • don't push encryption key or unencrypted json files to git.
  • share the encryption key between team members manually and ask them to place it in the location defined in code.