Socket
Socket
Sign inDemoInstall

dotenv

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv - npm Package Compare versions

Comparing version 16.1.3 to 16.3.1

27

CHANGELOG.md

@@ -5,4 +5,29 @@ # Changelog

## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.1.0...master)
## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.3.1...master)
## [16.3.1](https://github.com/motdotla/dotenv/compare/v16.3.0...v16.3.1) (2023-06-17)
### Added
- Add missing type definitions for `processEnv` and `DOTENV_KEY` options. [#756](https://github.com/motdotla/dotenv/pull/756)
## [16.3.0](https://github.com/motdotla/dotenv/compare/v16.2.0...v16.3.0) (2023-06-16)
### Added
- Optionally pass `DOTENV_KEY` to options rather than relying on `process.env.DOTENV_KEY`. Defaults to `process.env.DOTENV_KEY` [#754](https://github.com/motdotla/dotenv/pull/754)
## [16.2.0](https://github.com/motdotla/dotenv/compare/v16.1.4...v16.2.0) (2023-06-15)
### Added
- Optionally write to your own target object rather than `process.env`. Defaults to `process.env`. [#753](https://github.com/motdotla/dotenv/pull/753)
- Add import type URL to types file [#751](https://github.com/motdotla/dotenv/pull/751)
## [16.1.4](https://github.com/motdotla/dotenv/compare/v16.1.3...v16.1.4) (2023-06-04)
### Added
- Added `.github/` to `.npmignore` [#747](https://github.com/motdotla/dotenv/pull/747)
## [16.1.3](https://github.com/motdotla/dotenv/compare/v16.1.2...v16.1.3) (2023-05-31)

@@ -9,0 +34,0 @@

2

lib/cli-options.js

@@ -1,2 +0,2 @@

const re = /^dotenv_config_(encoding|path|debug|override)=(.+)$/
const re = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/

@@ -3,0 +3,0 @@ module.exports = function optionMatcher (args) {

@@ -20,2 +20,6 @@ // ../config.js accepts options via environment variables

if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY
}
module.exports = options
// TypeScript Version: 3.0
/// <reference types="node" />
import type { URL } from 'node:url';

@@ -57,2 +58,20 @@ export interface DotenvParseOutput {

override?: boolean;
/**
* Default: `process.env`
*
* Specify an object to write your secrets to. Defaults to process.env environment variables.
*
* example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
*/
processEnv?: DotenvPopulateInput;
/**
* Default: `undefined`
*
* Pass the DOTENV_KEY directly to config options. Defaults to looking for process.env.DOTENV_KEY environment variable. Note this only applies to decrypting .env.vault files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a .env file.
*
* example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production' })`
*/
DOTENV_KEY?: string;
}

@@ -59,0 +78,0 @@

@@ -61,3 +61,3 @@ const fs = require('fs')

// example: DOTENV_KEY="dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenv.org/vault/.env.vault?environment=prod"
const keys = _dotenvKey().split(',')
const keys = _dotenvKey(options).split(',')
const length = keys.length

@@ -103,3 +103,9 @@

function _dotenvKey () {
function _dotenvKey (options) {
// prioritize developer directly setting options.DOTENV_KEY
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
return options.DOTENV_KEY
}
// secondary infra already contains a DOTENV_KEY environment variable
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {

@@ -109,2 +115,3 @@ return process.env.DOTENV_KEY

// fallback to empty string
return ''

@@ -168,4 +175,9 @@ }

DotenvModule.populate(process.env, parsed, options)
let processEnv = process.env
if (options && options.processEnv != null) {
processEnv = options.processEnv
}
DotenvModule.populate(processEnv, parsed, options)
return { parsed }

@@ -192,4 +204,9 @@ }

DotenvModule.populate(process.env, parsed, options)
let processEnv = process.env
if (options && options.processEnv != null) {
processEnv = options.processEnv
}
DotenvModule.populate(processEnv, parsed, options)
return { parsed }

@@ -210,3 +227,3 @@ } catch (e) {

// fallback to original dotenv if DOTENV_KEY is not set
if (_dotenvKey().length === 0) {
if (_dotenvKey(options).length === 0) {
return DotenvModule.configDotenv(options)

@@ -213,0 +230,0 @@ }

{
"name": "dotenv",
"version": "16.1.3",
"version": "16.3.1",
"description": "Loads environment variables from .env file",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

@@ -245,2 +245,4 @@ <div align="center">

* [nodejs (override on)](https://github.com/dotenv-org/examples/tree/master/dotenv-nodejs-override)
* [nodejs (processEnv override)](https://github.com/dotenv-org/examples/tree/master/dotenv-custom-target)
* [nodejs (DOTENV_KEY override)](https://github.com/dotenv-org/examples/tree/master/dotenv-vault-custom-target)
* [esm](https://github.com/dotenv-org/examples/tree/master/dotenv-esm)

@@ -261,3 +263,3 @@ * [esm (preload)](https://github.com/dotenv-org/examples/tree/master/dotenv-esm-preload)

Dotenv exposes three functions:
Dotenv exposes four functions:

@@ -267,2 +269,3 @@ * `config`

* `populate`
* `decrypt`

@@ -289,3 +292,3 @@ ### Config

##### Path
##### path

@@ -300,3 +303,3 @@ Default: `path.resolve(process.cwd(), '.env')`

##### Encoding
##### encoding

@@ -311,3 +314,3 @@ Default: `utf8`

##### Debug
##### debug

@@ -322,3 +325,3 @@ Default: `false`

##### Override
##### override

@@ -333,2 +336,26 @@ Default: `false`

##### processEnv
Default: `process.env`
Specify an object to write your secrets to. Defaults to `process.env` environment variables.
```js
const myObject = {}
require('dotenv').config({ processEnv: myObject })
console.log(myObject) // values from .env or .env.vault live here now.
console.log(process.env) // this was not changed or written to
```
##### DOTENV_KEY
Default: `process.env.DOTENV_KEY`
Pass the `DOTENV_KEY` directly to config options. Defaults to looking for `process.env.DOTENV_KEY` environment variable. Note this only applies to decrypting `.env.vault` files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a `.env` file.
```js
require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production' })
```
### Parse

@@ -349,3 +376,3 @@

##### Debug
##### debug

@@ -391,3 +418,3 @@ Default: `false`

#### Options
#### options

@@ -400,3 +427,3 @@ ##### Debug

##### Override
##### override

@@ -407,2 +434,18 @@ Default: `false`

### Decrypt
The engine which decrypts the ciphertext contents of your .env.vault file is available for use. It accepts a ciphertext and a decryption key. It uses AES-256-GCM encryption.
For example, decrypting a simple ciphertext:
```js
const dotenv = require('dotenv')
const ciphertext = 's7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R'
const decryptionKey = 'ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00'
const decrypted = dotenv.decrypt(ciphertext, decryptionKey)
console.log(decrypted) // # development@v6\nALPHA="zeta"
```
## ❓ FAQ

@@ -409,0 +452,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc