@dotenvx/dotenvx 2.37.0 → 2.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -2
- package/README.md +14 -0
- package/package.json +2 -2
- package/src/cli/actions/check.js +2 -1
- package/src/cli/actions/decrypt.js +3 -10
- package/src/cli/actions/encrypt.js +2 -1
- package/src/cli/actions/get.js +2 -5
- package/src/cli/actions/keypair.js +2 -5
- package/src/cli/actions/run.js +2 -3
- package/src/cli/actions/set.js +2 -1
- package/src/lib/decryptors/armor/index.js +4 -1
- package/src/lib/helpers/selectKeyStorage.js +1 -2
- package/src/lib/helpers/statusReporter.js +8 -0
- package/src/lib/main.d.ts +29 -0
- package/src/lib/main.js +34 -16
- package/src/lib/providers/index.js +1 -0
- package/src/lib/resolvers/get.js +11 -0
- package/src/lib/transforms/set.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.38.1...main)
|
|
6
|
+
|
|
7
|
+
## [2.38.1](https://github.com/dotenvx/dotenvx/compare/v2.38.0...v2.38.1) (2026-10-19)
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* Surface Armor approval prompts to stderr ([#1030](https://github.com/dotenvx/dotenvx/pull/1030))
|
|
12
|
+
|
|
13
|
+
## [2.38.0](https://github.com/dotenvx/dotenvx/compare/v2.37.0...v2.38.0) (2026-10-16)
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* Add `getSync` convenience ([#1029](https://github.com/dotenvx/dotenvx/pull/1029))
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
* Default to file key storage in non-interactive mode ([#1028](https://github.com/dotenvx/dotenvx/pull/1028))
|
|
6
22
|
|
|
7
23
|
## [2.37.0](https://github.com/dotenvx/dotenvx/compare/v2.36.0...v2.37.0) (2026-10-15)
|
|
8
24
|
|
|
@@ -16,7 +32,6 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
16
32
|
❯ ◊ Enclaved
|
|
17
33
|
```
|
|
18
34
|
|
|
19
|
-
|
|
20
35
|
## [2.36.0](https://github.com/dotenvx/dotenvx/compare/v2.35.0...v2.36.0) (2026-10-14)
|
|
21
36
|
|
|
22
37
|
### Added
|
package/README.md
CHANGED
|
@@ -3232,6 +3232,20 @@ console.log(decryptedValue)
|
|
|
3232
3232
|
|
|
3233
3233
|
This is known as *Decryption at Access* and is written about in [the whitepaper](https://dotenvx.com/dotenvx.pdf).
|
|
3234
3234
|
|
|
3235
|
+
</details>
|
|
3236
|
+
<details><summary>`getSync(KEY)` - synchronous access</summary><br>
|
|
3237
|
+
|
|
3238
|
+
Synchronously resolve an environment variable without populating `process.env`. This is useful in configuration files that cannot await `get()`.
|
|
3239
|
+
|
|
3240
|
+
```js
|
|
3241
|
+
const dotenvx = require('@dotenvx/dotenvx')
|
|
3242
|
+
const decryptedValue = dotenvx.getSync('HELLO', { path: '.env.credentials', strict: true })
|
|
3243
|
+
```
|
|
3244
|
+
|
|
3245
|
+
`getSync()` accepts the same options as `get()`, including masking, multiple paths, and error handling. Omit the key to return all values from the selected files. It blocks while files and providers are resolved.
|
|
3246
|
+
|
|
3247
|
+
If you already called `dotenvx.config()`, you can read the loaded value directly from `process.env.HELLO` instead.
|
|
3248
|
+
|
|
3235
3249
|
</details>
|
|
3236
3250
|
<details><summary>`get(KEY, {mask:})`</summary><br>
|
|
3237
3251
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.38.1",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a secure dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"funding": "https://dotenvx.com",
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@dotenvx/primitives": "^3.3.1",
|
|
57
|
-
"@dotenvx/providers": "^0.3.
|
|
57
|
+
"@dotenvx/providers": "^0.3.11",
|
|
58
58
|
"@dotenvx/tooling": "^1.0.5",
|
|
59
59
|
"undici": "^6.28.1",
|
|
60
60
|
"write-file-atomic": "^5.0.1",
|
package/src/cli/actions/check.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
1
2
|
const { logger } = require('./../../shared/logger')
|
|
2
3
|
const catchAndLog = require('./../../lib/helpers/catchAndLog')
|
|
3
4
|
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
@@ -28,7 +29,7 @@ async function check () {
|
|
|
28
29
|
const { processedEnvs, readableFilepaths, requiredFilepaths, validationError, schema, checked: checkedValues } = await prepareValidatedEnv({
|
|
29
30
|
envs: this.envs,
|
|
30
31
|
options,
|
|
31
|
-
onStatus:
|
|
32
|
+
onStatus: statusReporter(spinner)
|
|
32
33
|
})
|
|
33
34
|
checked.push(...readableFilepaths)
|
|
34
35
|
if (processedEnvs.some(row => row.type === 'env' && Object.keys(row.parsed || {}).length)) checked.push('--env')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
1
2
|
const { publickeys, injectsummary } = require('@dotenvx/primitives')
|
|
2
3
|
const fsx = require('./../../lib/helpers/fsx')
|
|
3
4
|
const { logger } = require('./../../shared/logger')
|
|
@@ -34,11 +35,7 @@ async function decrypt () {
|
|
|
34
35
|
fk: options.envKeysFile,
|
|
35
36
|
noArmor,
|
|
36
37
|
noNative,
|
|
37
|
-
onStatus: (
|
|
38
|
-
if (spinner && text) {
|
|
39
|
-
spinner.text = text
|
|
40
|
-
}
|
|
41
|
-
}
|
|
38
|
+
onStatus: statusReporter(spinner)
|
|
42
39
|
})
|
|
43
40
|
|
|
44
41
|
if (spinner) spinner.stop()
|
|
@@ -74,11 +71,7 @@ async function decrypt () {
|
|
|
74
71
|
fk: options.envKeysFile,
|
|
75
72
|
noArmor,
|
|
76
73
|
noNative,
|
|
77
|
-
onStatus: (
|
|
78
|
-
if (spinner && text) {
|
|
79
|
-
spinner.text = text
|
|
80
|
-
}
|
|
81
|
-
}
|
|
74
|
+
onStatus: statusReporter(spinner)
|
|
82
75
|
})
|
|
83
76
|
|
|
84
77
|
for (const processedEnv of processedEnvs) {
|
|
@@ -5,6 +5,7 @@ const encryptTransform = require('./../../lib/transforms/encrypt')
|
|
|
5
5
|
|
|
6
6
|
const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
7
7
|
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
8
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
8
9
|
const keypair = require('../../lib/resolvers/keypair')
|
|
9
10
|
const { publickeys, injectsummary } = require('@dotenvx/primitives')
|
|
10
11
|
|
|
@@ -72,7 +73,7 @@ async function encryptAction () {
|
|
|
72
73
|
for (const row of processedEnvs) {
|
|
73
74
|
if (options.with !== undefined || options.quiet || row.error || row.keySources || !publickeys(row.envSrc || '').length) continue
|
|
74
75
|
try {
|
|
75
|
-
const resolved = await keypair({ ...options, envFile: [row.filepath], envKeysFile: fk, noArmor, noNative, no1Password, noBitwarden, includeProvider: true })
|
|
76
|
+
const resolved = await keypair({ ...options, envFile: [row.filepath], envKeysFile: fk, noArmor, noNative, no1Password, noBitwarden, includeProvider: true, onStatus: statusReporter(null) })
|
|
76
77
|
row.keySources = { [publickeys(row.envSrc)[0]]: resolved.provider }
|
|
77
78
|
} catch {}
|
|
78
79
|
}
|
package/src/cli/actions/get.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
1
2
|
const { logger } = require('./../../shared/logger')
|
|
2
3
|
|
|
3
4
|
const escape = require('./../../lib/helpers/escape')
|
|
@@ -43,11 +44,7 @@ async function get (key) {
|
|
|
43
44
|
noNative,
|
|
44
45
|
no1Password: options['1password'] === false || options.no1Password === true,
|
|
45
46
|
noBitwarden: options.bitwarden === false || options.noBitwarden === true,
|
|
46
|
-
onStatus: (
|
|
47
|
-
if (spinner && text) {
|
|
48
|
-
spinner.text = text
|
|
49
|
-
}
|
|
50
|
-
}
|
|
47
|
+
onStatus: statusReporter(spinner)
|
|
51
48
|
})
|
|
52
49
|
const parsed = filterKeys(resolved, options.includeKey, options.excludeKey)
|
|
53
50
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
1
2
|
const { logger } = require('./../../shared/logger')
|
|
2
3
|
|
|
3
4
|
const keypairResolver = require('./../../lib/resolvers/keypair')
|
|
@@ -29,11 +30,7 @@ async function keypair (key) {
|
|
|
29
30
|
no1Password: options['1password'] === false || options.no1Password === true,
|
|
30
31
|
token: options.token,
|
|
31
32
|
command: process.argv.slice(2),
|
|
32
|
-
onStatus: (
|
|
33
|
-
if (spinner && text) {
|
|
34
|
-
spinner.text = text
|
|
35
|
-
}
|
|
36
|
-
}
|
|
33
|
+
onStatus: statusReporter(spinner)
|
|
37
34
|
})
|
|
38
35
|
|
|
39
36
|
const results = key ? keypairs[key] : keypairs
|
package/src/cli/actions/run.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
1
2
|
const path = require('path')
|
|
2
3
|
const { injectsummary, publickeys } = require('@dotenvx/primitives')
|
|
3
4
|
const { logger } = require('./../../shared/logger')
|
|
@@ -106,9 +107,7 @@ async function run () {
|
|
|
106
107
|
processEnv: process.env,
|
|
107
108
|
requireEnvfile: false,
|
|
108
109
|
command: commandArgs,
|
|
109
|
-
onStatus: (
|
|
110
|
-
if (spinner && text) spinner.text = text
|
|
111
|
-
}
|
|
110
|
+
onStatus: statusReporter(spinner)
|
|
112
111
|
})
|
|
113
112
|
|
|
114
113
|
if (hasEnvfile || options.redact === true) {
|
package/src/cli/actions/set.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const statusReporter = require('../../lib/helpers/statusReporter')
|
|
1
2
|
const fsx = require('./../../lib/helpers/fsx')
|
|
2
3
|
const { logger } = require('./../../shared/logger')
|
|
3
4
|
|
|
@@ -64,7 +65,7 @@ async function set (key, value) {
|
|
|
64
65
|
let errorCount = 0
|
|
65
66
|
|
|
66
67
|
try {
|
|
67
|
-
const { keysSrc, processedEnvs, changedFilepaths, unchangedFilepaths } = await setTransform({ profile: options.profile, envs, key, value, fk, noArmor, token: options.token, noCreate, encrypt, noNative, no1Password, noBitwarden })
|
|
68
|
+
const { keysSrc, processedEnvs, changedFilepaths, unchangedFilepaths } = await setTransform({ profile: options.profile, envs, key, value, fk, noArmor, token: options.token, noCreate, encrypt, noNative, no1Password, noBitwarden, onStatus: statusReporter(spinner) })
|
|
68
69
|
|
|
69
70
|
if (keysSrc) {
|
|
70
71
|
await fsx.writeKeyFile(fk, keysSrc)
|
|
@@ -13,7 +13,10 @@ async function index (src, options = {}) {
|
|
|
13
13
|
hostname,
|
|
14
14
|
token,
|
|
15
15
|
devicePublicKey,
|
|
16
|
-
cliVersion: version
|
|
16
|
+
cliVersion: version,
|
|
17
|
+
onApprovalRequired: options.onStatus && (({ approvalUri, code }) => {
|
|
18
|
+
options.onStatus(`[${code}] open [${approvalUri}] to approve. Waiting for approval…`)
|
|
19
|
+
})
|
|
17
20
|
}).decrypt(src, { publicKey: options.publicKey, grantToken: options.grantToken })
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -10,8 +10,7 @@ const selectConnectionResource = require('./selectConnectionResource')
|
|
|
10
10
|
const nativeNames = { darwin: 'macOS Keychain', win32: 'Windows Credential Manager', linux: 'Linux Secret Service' }
|
|
11
11
|
|
|
12
12
|
async function selectKeyStorage (options = {}) {
|
|
13
|
-
|
|
14
|
-
if (process.env.CI || options.noCreate || !process.stdin.isTTY || !process.stderr.isTTY) return defaultStorage
|
|
13
|
+
if (process.env.CI || options.noCreate || !process.stdin.isTTY || !process.stderr.isTTY) return 'file'
|
|
15
14
|
|
|
16
15
|
const groups = new Map()
|
|
17
16
|
const setup = new Map()
|
package/src/lib/main.d.ts
CHANGED
|
@@ -367,6 +367,12 @@ export function set(
|
|
|
367
367
|
|
|
368
368
|
export interface GetOptions {
|
|
369
369
|
|
|
370
|
+
/** Include all process environment variables when no key is supplied. */
|
|
371
|
+
all?: boolean;
|
|
372
|
+
|
|
373
|
+
/** Format the returned values when no key is supplied. */
|
|
374
|
+
format?: 'eval' | 'eval-export' | 'shell' | 'colon';
|
|
375
|
+
|
|
370
376
|
/**
|
|
371
377
|
* Specify a custom path if your file containing environment variables is located elsewhere.
|
|
372
378
|
* Can also be an array of strings, specifying multiple paths.
|
|
@@ -464,6 +470,29 @@ export function get(
|
|
|
464
470
|
options?: GetOptions
|
|
465
471
|
): Promise<string>;
|
|
466
472
|
|
|
473
|
+
/**
|
|
474
|
+
* Synchronously resolve an environment variable without modifying process.env.
|
|
475
|
+
* Blocks while files and providers are resolved. Uses the same options as get().
|
|
476
|
+
*
|
|
477
|
+
* @example require('@dotenvx/dotenvx').getSync('KEY', { path: '.env.credentials' })
|
|
478
|
+
*/
|
|
479
|
+
export function getSync(
|
|
480
|
+
key: string,
|
|
481
|
+
options?: GetOptions
|
|
482
|
+
): string | undefined;
|
|
483
|
+
export function getSync(
|
|
484
|
+
key: undefined,
|
|
485
|
+
options: GetOptions & { format: NonNullable<GetOptions['format']> }
|
|
486
|
+
): string;
|
|
487
|
+
export function getSync(
|
|
488
|
+
key?: undefined,
|
|
489
|
+
options?: GetOptions & { format?: undefined }
|
|
490
|
+
): Record<string, string>;
|
|
491
|
+
export function getSync(
|
|
492
|
+
key: string | undefined,
|
|
493
|
+
options?: GetOptions
|
|
494
|
+
): string | Record<string, string> | undefined;
|
|
495
|
+
|
|
467
496
|
/**
|
|
468
497
|
* List all env files in the current working directory
|
|
469
498
|
*
|
package/src/lib/main.js
CHANGED
|
@@ -331,8 +331,21 @@ const set = async function (key, value, options = {}, events) {
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
/** @type {import('./main').get} */
|
|
335
335
|
const get = async function (key, options = {}, events) {
|
|
336
|
+
const prepared = prepareGet(key, options)
|
|
337
|
+
const resolved = await getResolver(prepared.resolverOptions)
|
|
338
|
+
return getResult(key, prepared.options, resolved, events)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** @type {import('./main').getSync} */
|
|
342
|
+
const getSync = function (key, options = {}) {
|
|
343
|
+
const prepared = prepareGet(key, options)
|
|
344
|
+
const resolved = getResolver.sync(prepared.resolverOptions)
|
|
345
|
+
return getResult(key, prepared.options, resolved)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function prepareGet (key, options) {
|
|
336
349
|
options = normalizeDotenvConfigConvention(options)
|
|
337
350
|
options = normalizeDotenvConfigIgnore(options)
|
|
338
351
|
|
|
@@ -340,22 +353,26 @@ const get = async function (key, options = {}, events) {
|
|
|
340
353
|
const noArmor = resolveNoArmor(options)
|
|
341
354
|
const noNative = resolveNoNative(options)
|
|
342
355
|
|
|
343
|
-
|
|
344
|
-
|
|
356
|
+
return {
|
|
357
|
+
options,
|
|
358
|
+
resolverOptions: {
|
|
359
|
+
resolveDirectories: false,
|
|
360
|
+
key,
|
|
361
|
+
envs,
|
|
362
|
+
profile: options.profile,
|
|
363
|
+
overload: options.overload,
|
|
364
|
+
all: options.all,
|
|
365
|
+
envKeysFile: options.envKeysFile,
|
|
366
|
+
noArmor,
|
|
367
|
+
noNative,
|
|
368
|
+
no1Password: options.no1Password,
|
|
369
|
+
noBitwarden: options.noBitwarden
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
345
373
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
key,
|
|
349
|
-
envs,
|
|
350
|
-
profile: options.profile,
|
|
351
|
-
overload: options.overload,
|
|
352
|
-
all: options.all,
|
|
353
|
-
envKeysFile: options.envKeysFile,
|
|
354
|
-
noArmor,
|
|
355
|
-
noNative,
|
|
356
|
-
no1Password: options.no1Password,
|
|
357
|
-
noBitwarden: options.noBitwarden
|
|
358
|
-
})
|
|
374
|
+
function getResult (key, options, { parsed, errors }, events) {
|
|
375
|
+
const ignore = options.ignore || []
|
|
359
376
|
|
|
360
377
|
if (options.mask !== undefined) {
|
|
361
378
|
const showChar = options.mask === true ? 6 : options.mask
|
|
@@ -441,6 +458,7 @@ module.exports = {
|
|
|
441
458
|
// actions related
|
|
442
459
|
set,
|
|
443
460
|
get,
|
|
461
|
+
getSync,
|
|
444
462
|
ls,
|
|
445
463
|
// expose for libs depending on @dotenvx/dotenvx
|
|
446
464
|
setLogLevel,
|
|
@@ -28,6 +28,7 @@ function lookup (publicKey, options, sync) {
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
onArmorError (error) { armorError = error },
|
|
31
|
+
// Without CLI presentation, providers reports approval itself (including getSync).
|
|
31
32
|
onApprovalRequired: options.onStatus && (({ approvalUri, code }) => {
|
|
32
33
|
cleanup()
|
|
33
34
|
const display = armoredKeyDisplay(publicKey)
|
package/src/lib/resolvers/get.js
CHANGED
|
@@ -61,6 +61,16 @@ async function get (options = {}) {
|
|
|
61
61
|
const processEnv = { ...(options.processEnv || process.env) }
|
|
62
62
|
const { processedEnvs } = await envsResolver(buildOptions(options, processEnv))
|
|
63
63
|
|
|
64
|
+
return resolveResult(options, processedEnvs, processEnv)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getSync (options = {}) {
|
|
68
|
+
const processEnv = { ...(options.processEnv || process.env) }
|
|
69
|
+
const { processedEnvs } = envsResolver.sync(buildOptions(options, processEnv))
|
|
70
|
+
return resolveResult(options, processedEnvs, processEnv)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function resolveResult (options, processedEnvs, processEnv) {
|
|
64
74
|
const resolved = result({
|
|
65
75
|
key: options.key,
|
|
66
76
|
all: options.all,
|
|
@@ -74,3 +84,4 @@ async function get (options = {}) {
|
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
module.exports = get
|
|
87
|
+
module.exports.sync = getSync
|
|
@@ -94,7 +94,7 @@ async function setTransform (options = {}) {
|
|
|
94
94
|
row.changed = true
|
|
95
95
|
}
|
|
96
96
|
} else {
|
|
97
|
-
//
|
|
97
|
+
// Compare plaintext before rewriting ciphertext; surface any provider approval.
|
|
98
98
|
const { parsed, keySources } = await getResolver({
|
|
99
99
|
includeKeySources: true,
|
|
100
100
|
key,
|
|
@@ -104,7 +104,8 @@ async function setTransform (options = {}) {
|
|
|
104
104
|
noArmor,
|
|
105
105
|
noNative,
|
|
106
106
|
no1Password: options.no1Password,
|
|
107
|
-
noBitwarden: options.noBitwarden
|
|
107
|
+
noBitwarden: options.noBitwarden,
|
|
108
|
+
onStatus: options.onStatus
|
|
108
109
|
})
|
|
109
110
|
|
|
110
111
|
row.keySources = row.keySources || keySources
|