All Projects → kunalpanchal → secure-env

kunalpanchal / secure-env

Licence: MIT License
Env encryption tool that will help you prevent attacks from npm-malicious-packages.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to secure-env

angular-environment
AngularJS Environment Plugin
Stars: ✭ 78 (+47.17%)
Mutual labels:  npm-package, environment-variables
Dynamic-Web-TWAIN
Dynamic Web TWAIN for package managers
Stars: ✭ 35 (-33.96%)
Mutual labels:  npm-package
fritz-box
📦 Promise-based JavaScript FRITZ!Box API.
Stars: ✭ 14 (-73.58%)
Mutual labels:  npm-package
add-module-exports-webpack-plugin
Add `module.exports` for Babel and TypeScript compiled code
Stars: ✭ 36 (-32.08%)
Mutual labels:  npm-package
flagga
An extensible Go library for handling program configuration using flags.
Stars: ✭ 28 (-47.17%)
Mutual labels:  environment-variables
react-change-highlight
✨ a react component to highlight changes constantly ⚡️
Stars: ✭ 79 (+49.06%)
Mutual labels:  npm-package
react-native-value-picker
Cross-Platform iOS(ish) style picker for react native.
Stars: ✭ 18 (-66.04%)
Mutual labels:  npm-package
vogels-promisified
DynamoDB library Vogels promisified
Stars: ✭ 19 (-64.15%)
Mutual labels:  npm-package
babel-plugin-source-map-support
A Babel plugin which automatically makes stack traces source-map aware
Stars: ✭ 41 (-22.64%)
Mutual labels:  npm-package
bulk-mail-cli
Do quick, hassle-free email marketing with this small but very powerful tool! 🔥
Stars: ✭ 88 (+66.04%)
Mutual labels:  npm-package
braille
A Node module for converting text to Braille alphabet.
Stars: ✭ 18 (-66.04%)
Mutual labels:  npm-package
react-innertext
Returns the innerText of a React JSX object.
Stars: ✭ 37 (-30.19%)
Mutual labels:  npm-package
gconfigs
gConfigs - Config and Secret parser
Stars: ✭ 42 (-20.75%)
Mutual labels:  environment-variables
ts-dotenv
Strongly-typed environment variables for Node.js
Stars: ✭ 18 (-66.04%)
Mutual labels:  environment-variables
express-mvc-generator
Express' Model View Controller Application Generator.
Stars: ✭ 46 (-13.21%)
Mutual labels:  npm-package
skygear-SDK-JS
Skygear SDK for JavaScript
Stars: ✭ 25 (-52.83%)
Mutual labels:  npm-package
sicher
Sicher is a go module that allows secure storage of encrypted credentials in a version control system.
Stars: ✭ 27 (-49.06%)
Mutual labels:  environment-variables
awesome-starless
A curated list of awesome repositories with few stargazers but has a huge users.
Stars: ✭ 38 (-28.3%)
Mutual labels:  npm-package
spiderable-middleware
🤖 Prerendering for JavaScript powered websites. Great solution for PWAs (Progressive Web Apps), SPAs (Single Page Applications), and other websites based on top of front-end JavaScript frameworks
Stars: ✭ 29 (-45.28%)
Mutual labels:  npm-package
env
A lightweight package for loading OS environment variables into structs for Go projects
Stars: ✭ 24 (-54.72%)
Mutual labels:  environment-variables

npm version JavaScript Style Guide Maintenance GitHub license GitHub release Github all releases

secure-env

Secure-env is a module that loads environment variables from a .env.enc file.A encryption tool that would helps you prevent attacks from npm-malicious-packages.

Usage

Create a .env file in the root directory of your project. Add environment-specific variables on new lines in the form of NAME=VALUE. For example:

DB_HOST=localhost:27017
DB_USER=scott
DB_PASS=tiger

Encrypt .env

$ npm install -g secure-env
$ secure-env .env -s mySecretPassword

Alternatively if you want this installed locally run the command as follows:

$ ./node_modules/secure-env/dist/es5/lib/cli.js .env -s mySecretPassword

If you are running NPM > v5.2. You can use npx:

$ npx secure-env .env -s mySecretPassword

A new encrypted file .env.enc will be created in your project root directory.You can delete the .env file after this,to prevent stealing.

Decrypt .env.enc

As early as possible in your application, require and configure dotenv.

let secureEnv = require('secure-env');
global.env = secureEnv({secret:'mySecretPassword'});

That's it.

global.env now has the keys and values you defined in your .env file.

var db = require('db')
db.connect({
  host: global.env.DB_HOST,
  username: global.env.DB_USER,
  password: global.env.DB_PASS
})

Options

Encryption

$ secure-env --option <VALUE> <file-path-which-is-to-be-encrypted>
Option What does it do Defaults
--secret Specify the secret Key which would be later used to decrypt the file. mySecret
--out The encrypted file path that would be created. env.enc
--algo The encryption algorithm that is to be used to encrypt the env file. aes256
--decrypt prints the decrypted text to stdout

Decryption

Path

Default: .env

You can specify a custom path if your file containing environment variables is named or located differently.

require('secure-env')({path:'/custom/path/to/your/env/vars'});

Decryption Algorithm

Default: aes256

You may specify the encryption algorithm for your file containing environment variables using this option.

require('secure-env')({enc_algo:'aes256'});

Secret

Default: mySecret

Specify the secret Key which was used during encryption of raw file.Having a salt-hashed secret key is recommended.

require('secure-env')({secret:'mySecretPassword'});

Parse rules

Refer https://github.com/motdotla/dotenv/blob/master/README.md#parse

The parsing engine currently supports the following rules:

  • BASIC=basic becomes {BASIC: 'basic'}
  • empty lines are skipped
  • lines beginning with # are treated as comments
  • empty values become empty strings (EMPTY= becomes {EMPTY: ''})
  • single and double quoted values are escaped (SINGLE_QUOTE='quoted' becomes {SINGLE_QUOTE: "quoted"})
  • new lines are expanded if in double quotes (MULTILINE="new\nline" becomes
{MULTILINE: 'new
line'}
  • inner quotes are maintained (think JSON) (JSON={"foo": "bar"} becomes {JSON:"{\"foo\": \"bar\"}")
  • whitespace is removed from both ends of the value (see more on trim) (FOO=" some value " becomes {FOO: 'some value'}) G.md)

License

See LICENSE

Dependencies

Source-env uses these open source projects to work properly:

  • Minimist - Argument parser without all the fanciful decoration.

Contributors

Acknowledgements

Source-env is inspired from and also uses code references from these open source projects:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].