npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

secure-config-vault

v1.0.0

Published

Encrypt and decrypt .env configuration files using AES-256-GCM. Store encrypted vault files safely in Git.

Readme

secure-config-vault

Encrypt and decrypt .env configuration files using AES-256-GCM encryption. Store encrypted .env.vault files safely in Git — no more leaking secrets!

Uses only Node.js built-in crypto module — zero external dependencies.

Features

  • 🔐 AES-256-GCM Encryption — military-grade authenticated encryption.
  • 🔑 Key or Password — use a random 256-bit key or any password string (PBKDF2 derived).
  • 📦 Vault Files — encrypt .env.env.vault, commit safely to Git.
  • 🔓 Runtime Decryption — decrypt vault at runtime and inject into process.env.
  • 🔄 Smart LoaderloadConfig() tries vault first, falls back to .env automatically.
  • 🛡️ Tamper Detection — GCM auth tags detect any tampering of the encrypted file.
  • 🧹 Clean API — also exports raw encrypt()/decrypt() for any use case.

Installation

npm install secure-config-vault

Quick Start

1. Generate a Key

const { generateKey } = require('secure-config-vault');
const key = generateKey();
console.log('Your vault key:', key);
// Save this somewhere safe (NOT in your repo)

2. Encrypt your .env file

const { encryptFile } = require('secure-config-vault');

encryptFile('your-64-char-hex-key', {
  envPath: '.env',
  vaultPath: '.env.vault'
});
// .env.vault is now safe to commit to Git!

3. Decrypt at Runtime

const { loadConfig } = require('secure-config-vault');

// Set VAULT_KEY as an environment variable in production
// e.g., VAULT_KEY=abc123... node app.js
loadConfig();

console.log(process.env.DATABASE_URL); // Decrypted value

Alternative: Use a Password

const { encryptFile, decryptFile } = require('secure-config-vault');

// Encrypt with password
encryptFile('my-super-secret-password', { envPath: '.env' });

// Decrypt with same password
const config = decryptFile('my-super-secret-password');
console.log(config);

API

generateKey()string

Returns a random 64-character hex key (256 bits).

encrypt(plaintext, keyOrPassword)string

Encrypts a string. Returns salt:iv:authTag:ciphertext (hex encoded).

decrypt(payload, keyOrPassword)string

Decrypts a payload from encrypt().

encryptFile(keyOrPassword, options){ envPath, vaultPath, variables }

Encrypts a .env file to a .env.vault file.

decryptFile(keyOrPassword, options)Object

Decrypts a .env.vault file and returns parsed key-value pairs.

| Option | Default | Description | |---|---|---| | vaultPath | '.env.vault' | Path to vault file. | | inject | false | Inject into process.env. | | override | false | Override existing env vars. |

loadConfig(options)Object

Smart loader: tries vault first, falls back to .env.

| Option | Default | Description | |---|---|---| | key | process.env.VAULT_KEY | Decryption key. | | vaultPath | '.env.vault' | Vault file path. | | envPath | '.env' | Fallback .env path. | | inject | true | Inject into process.env. | | override | false | Override existing vars. |

parseEnv(content)Object

Parses .env file content into key-value pairs.

serializeEnv(obj)string

Converts an object back to .env format.

License

MIT