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 🙏

© 2024 – Pkg Stats / Ryan Hefner

veritas-env

v0.0.12

Published

Encrypted environment variables for node done right

Downloads

14

Readme

npm version

veritas

Encrypted environment variables for node done right.

Install

npm install -g veritas-env

Configure

Veritas supports the following options via environment variables

Required

  • VERITAS_SECRET: The secret used to encrypt each environment variable.
  • VERITAS_SALT The salt to use during encryption.

Optional

  • VERITAS_ENCRYPTION_ALGORITHM: Encryption algorithm to use. Default: aes256
  • VERITAS_SALT_KEY_LENGTH: Salt length (bytes). This must match the requirements of the selected encryption algorithm. Default: 32
  • VERITAS_IV: User provided Initialization Vector string. See below.
  • VERITAS_IV_LENGTH: Initialization Vector length (bytes). Default: 16

By default, a random Initialization Vector is used each time a variable is encrypted. While technically more secure, it has the down side of changing all the values in the output JSON file each time they are encrypted, meaning that if you update just one variable, a git diff will show all variables as being changed. You can change this behavior by providing your own IV via VERITAS_IV.

Usage

To encrypt an existing .env file

$ npx veritas-env encrypt --input=.env --output=./path/to/encrypted.json

To decrypt an existing file encrypted by veritas

$ npx veritas-env decrypt --input=./path/to/encrypted.json --output=.env

Tip: Use something like direnv to automatically expose your secrets when running the above commands.

Motivation

  • Diffs

    The problem similar libaries have is that they encrypt the entire contents of a file, making it opaque to diffing. It can be quite a cumbersome process to merge changes from another branch that updates an encrypted file that your branch has also modified. Multiple this by the number of environments you have, and ... I feel your pain.

  • Vercel

    While I love Vercel and use it for numerous projects, it has the unfortunate limit of only allowing a total of 4KB for environment variables. Use something like a credentials JSON file to work with Google libraries, and you've pretty much blown your entire budget.

    Here's how you can configure your next.config.js to work with Veritas.

    const { decrypt } = require('veritas-env')
    
    const env = decrypt(`./config/${process.env.ENV_FILE}.json`, '.env')
    
    module.exports = { env }

    Then configure your secrets and ENV_FILE in Vercel's envrionment variables for the Preview and Production environments and you're all set. Damn that wasy easy!