
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
dotenv-sync
Advanced tools
This library is a layer on top of [dotenv](https://www.npmjs.com/package/dotenv), that lets you safely and easily share .env files with your team.
This library is a layer on top of dotenv, that lets you safely and easily share .env files with your team.
It works by encrypting all of your secret ENV vars using a private key, that can then be stored in 1Password, or LastPass etc.
npm install dotenv-sync
to install it$(npm bin)/dotenv-sync --init
to initialise the projectChange your existing code from:
import dotenv from "dotenv";
dotenv.config();
to
import dotenv from "dotenv-sync";
dotenv.config();
DO commit:
.env-encrypted
— this file is what keeps your team in sync. It's securely encrypted, and safe to commit publiclyDo NOT commit:
.env-unencrypted.env
— this file contains all of your secret keys. If you commit this, you might as well not use this library at all and just commit your .env
directly.A sample .gitignore
you might want to use is as follows:
# .gitignore
*.env
!.env-encrypted
When new teammates attempt to run your codebase, if they haven't created a .env-unencrypted.env
file, then they will hit an error.
If you want to customise this error message, so your teammates know where to get the file from, you can create a .dotenv-sync.missing-secret-key
message in your workspace.
For example:
echo "Check the shared 1Password, in the item titled 'space jam website'" > .dotenv-sync.missing-secret-key
In production-mode, dotenv-sync
defers entirely to dotenv
, making it effectively zero in additional bundle size.
This library encrypts your ENV vars using 256-bit AES.
For reference, this is the same encryption that 1Password uses. In other words, using this package is cryptographically as secure as storing all of your ENV vars directly in a 1Password vault.
If your repo is public, then this is obviously a bad idea, as anyone can e.g. log into your database.
If your repo is private, then this is still a bad idea. All it takes is one person to get hacked, and suddenly the hacker has access to all of your databases. By using this package, even if someone hacks their way to your source-code, they won't be able to decrypt your ENV vars.
To update ENV vars locally just for you, then you should just add to your .env
file.
To update ENV vars for your team, you can:
.env-unencrypted.env
file.env-encrypted
file.env-encrypted
file, and push this to source controlAnything in your .env
takes top priority, and will override anything else.
For example, in:
# .env
TEST=hello
# .env-unencrypted.env
TEST=goodbye
then process.env.TEST === 'hello'
The .env-unencrypted.env
offers groups, as an optional feature. You can specify an active group with the _ENV_GROUP_TARGET
environment variable.
For example, in:
# .env
_ENV_GROUP_TARGET=Local
# .env-unencrypted.env
#~~~ Local
TEST=hello
#~~~ Development
TEST=goodbye
then process.env.TEST === 'hello'
FAQs
This library is a layer on top of [dotenv](https://www.npmjs.com/package/dotenv), that lets you safely and easily share .env files with your team.
The npm package dotenv-sync receives a total of 6 weekly downloads. As such, dotenv-sync popularity was classified as not popular.
We found that dotenv-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.