@dotenvx/dotenvx 1.69.2 → 1.70.0
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 +7 -1
- package/README.md +20 -14
- package/package.json +7 -6
- package/src/cli/actions/decrypt.js +5 -5
- package/src/cli/actions/encrypt.js +13 -13
- package/src/cli/actions/get.js +4 -4
- package/src/cli/actions/keypair.js +4 -4
- package/src/cli/actions/normalizeArmorOptions.js +11 -0
- package/src/cli/actions/rotate.js +5 -5
- package/src/cli/actions/run.js +4 -4
- package/src/cli/actions/set.js +4 -4
- package/src/cli/commands/ext.js +1 -1
- package/src/cli/dotenvx.js +30 -33
- package/src/db/session.js +9 -9
- package/src/lib/extensions/{vlt.js → armor.js} +4 -4
- package/src/lib/helpers/cryptography/{vltKeypair.js → armorKeypair.js} +4 -4
- package/src/lib/helpers/cryptography/armorKeypairSync.js +14 -0
- package/src/lib/helpers/cryptography/index.js +2 -2
- package/src/lib/helpers/cryptography/mutateKeysSrc.js +1 -1
- package/src/lib/helpers/cryptography/mutateKeysSrcSync.js +1 -1
- package/src/lib/helpers/cryptography/provision.js +8 -8
- package/src/lib/helpers/cryptography/provisionSync.js +6 -6
- package/src/lib/helpers/cryptography/provisionWithPrivateKey.js +1 -1
- package/src/lib/helpers/executeDynamic.js +41 -12
- package/src/lib/helpers/keyResolution/keyValues.js +6 -6
- package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +5 -5
- package/src/lib/helpers/keyResolution/keyValuesSync.js +8 -8
- package/src/lib/main.d.ts +37 -13
- package/src/lib/main.js +11 -11
- package/src/lib/services/decrypt.js +4 -4
- package/src/lib/services/encrypt.js +4 -4
- package/src/lib/services/get.js +4 -4
- package/src/lib/services/keypair.js +4 -4
- package/src/lib/services/rotate.js +9 -9
- package/src/lib/services/run.js +8 -8
- package/src/lib/services/sets.js +6 -6
- package/src/cli/actions/normalizeVltOptions.js +0 -10
- package/src/lib/helpers/cryptography/vltKeypairSync.js +0 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Armor = require('../../extensions/armor')
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function armorKeypair (existingPublicKey, options = {}) {
|
|
4
4
|
const hooks = options.hooks || {}
|
|
5
5
|
if (hooks.before) await hooks.before()
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ async function vltKeypair (existingPublicKey, options = {}) {
|
|
|
13
13
|
|
|
14
14
|
let kp
|
|
15
15
|
try {
|
|
16
|
-
kp = await new
|
|
16
|
+
kp = await new Armor().keypair(existingPublicKey, keypairOptions)
|
|
17
17
|
} finally {
|
|
18
18
|
if (hooks.after) await hooks.after()
|
|
19
19
|
}
|
|
@@ -27,4 +27,4 @@ async function vltKeypair (existingPublicKey, options = {}) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
module.exports =
|
|
30
|
+
module.exports = armorKeypair
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const Armor = require('../../extensions/armor')
|
|
2
|
+
|
|
3
|
+
function armorKeypairSync (existingPublicKey, options = {}) {
|
|
4
|
+
const kp = new Armor().keypairSync(existingPublicKey, options)
|
|
5
|
+
const publicKey = kp.public_key
|
|
6
|
+
const privateKey = kp.private_key
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
publicKey,
|
|
10
|
+
privateKey
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = armorKeypairSync
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
armorKeypair: require('./armorKeypair'),
|
|
3
|
+
armorKeypairSync: require('./armorKeypairSync'),
|
|
4
4
|
localKeypair: require('./localKeypair'),
|
|
5
5
|
encryptValue: require('./encryptValue'),
|
|
6
6
|
decryptKeyValue: require('./decryptKeyValue'),
|
|
@@ -25,7 +25,7 @@ async function mutateKeysSrc ({ envFilepath, keysFilepath, privateKeyName, priva
|
|
|
25
25
|
keysSrc = keysSrc.length > 1 ? keysSrc : `${FIRST_TIME_KEYS_SRC}\n`
|
|
26
26
|
keysSrc = `${keysSrc}\n${appendPrivateKey}`
|
|
27
27
|
|
|
28
|
-
await fsx.writeFileX(resolvedKeysFilepath, keysSrc) // TODO: don't write if
|
|
28
|
+
await fsx.writeFileX(resolvedKeysFilepath, keysSrc) // TODO: don't write if armor
|
|
29
29
|
|
|
30
30
|
const envKeysFilepath = keysFilepath || path.join(path.dirname(envFilepath), path.basename(resolvedKeysFilepath))
|
|
31
31
|
|
|
@@ -25,7 +25,7 @@ function mutateKeysSrcSync ({ envFilepath, keysFilepath, privateKeyName, private
|
|
|
25
25
|
keysSrc = keysSrc.length > 1 ? keysSrc : `${FIRST_TIME_KEYS_SRC}\n`
|
|
26
26
|
keysSrc = `${keysSrc}\n${appendPrivateKey}`
|
|
27
27
|
|
|
28
|
-
fsx.writeFileXSync(resolvedKeysFilepath, keysSrc) // TODO: don't write if
|
|
28
|
+
fsx.writeFileXSync(resolvedKeysFilepath, keysSrc) // TODO: don't write if armor
|
|
29
29
|
|
|
30
30
|
const envKeysFilepath = keysFilepath || path.join(path.dirname(envFilepath), path.basename(resolvedKeysFilepath))
|
|
31
31
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const mutateSrc = require('./mutateSrc')
|
|
2
2
|
const mutateKeysSrc = require('./mutateKeysSrc')
|
|
3
|
-
const
|
|
3
|
+
const armorKeypair = require('./armorKeypair')
|
|
4
4
|
const localKeypair = require('./localKeypair')
|
|
5
5
|
const { keyNames } = require('../keyResolution')
|
|
6
6
|
|
|
7
|
-
async function provision ({ envSrc, envFilepath, keysFilepath,
|
|
8
|
-
|
|
9
|
-
if (!
|
|
10
|
-
|
|
7
|
+
async function provision ({ envSrc, envFilepath, keysFilepath, noArmor, token, keypairHooks, selectKeyStorage }) {
|
|
8
|
+
noArmor = noArmor !== false
|
|
9
|
+
if (!noArmor && selectKeyStorage) {
|
|
10
|
+
noArmor = await selectKeyStorage() !== 'armored'
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
@@ -19,12 +19,12 @@ async function provision ({ envSrc, envFilepath, keysFilepath, noVlt, token, key
|
|
|
19
19
|
let localPrivateKeyAdded = false
|
|
20
20
|
let remotePrivateKeyAdded = false
|
|
21
21
|
|
|
22
|
-
if (
|
|
22
|
+
if (noArmor) {
|
|
23
23
|
const kp = localKeypair()
|
|
24
24
|
publicKey = kp.publicKey
|
|
25
25
|
privateKey = kp.privateKey
|
|
26
26
|
} else {
|
|
27
|
-
const kp = await
|
|
27
|
+
const kp = await armorKeypair(undefined, { token, envFilepath, hooks: keypairHooks })
|
|
28
28
|
publicKey = kp.publicKey
|
|
29
29
|
privateKey = kp.privateKey
|
|
30
30
|
}
|
|
@@ -32,7 +32,7 @@ async function provision ({ envSrc, envFilepath, keysFilepath, noVlt, token, key
|
|
|
32
32
|
const mutated = mutateSrc({ envSrc, envFilepath, keysFilepath, publicKeyName, publicKeyValue: publicKey })
|
|
33
33
|
envSrc = mutated.envSrc
|
|
34
34
|
|
|
35
|
-
if (
|
|
35
|
+
if (noArmor) {
|
|
36
36
|
const mutated = await mutateKeysSrc({ envFilepath, keysFilepath, privateKeyName, privateKeyValue: privateKey })
|
|
37
37
|
keysSrc = mutated.keysSrc
|
|
38
38
|
envKeysFilepath = mutated.envKeysFilepath
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const mutateSrc = require('./mutateSrc')
|
|
2
2
|
const mutateKeysSrcSync = require('./mutateKeysSrcSync')
|
|
3
|
-
const
|
|
3
|
+
const armorKeypairSync = require('./armorKeypairSync')
|
|
4
4
|
const localKeypair = require('./localKeypair')
|
|
5
5
|
const { keyNames } = require('../keyResolution')
|
|
6
6
|
|
|
7
|
-
function provisionSync ({ envSrc, envFilepath, keysFilepath,
|
|
8
|
-
|
|
7
|
+
function provisionSync ({ envSrc, envFilepath, keysFilepath, noArmor }) {
|
|
8
|
+
noArmor = noArmor !== false
|
|
9
9
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
10
10
|
|
|
11
11
|
let publicKey
|
|
@@ -15,12 +15,12 @@ function provisionSync ({ envSrc, envFilepath, keysFilepath, noVlt }) {
|
|
|
15
15
|
let localPrivateKeyAdded = false
|
|
16
16
|
let remotePrivateKeyAdded = false
|
|
17
17
|
|
|
18
|
-
if (
|
|
18
|
+
if (noArmor) {
|
|
19
19
|
const kp = localKeypair()
|
|
20
20
|
publicKey = kp.publicKey
|
|
21
21
|
privateKey = kp.privateKey
|
|
22
22
|
} else {
|
|
23
|
-
const kp =
|
|
23
|
+
const kp = armorKeypairSync(undefined, { envFilepath })
|
|
24
24
|
publicKey = kp.publicKey
|
|
25
25
|
privateKey = kp.privateKey
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ function provisionSync ({ envSrc, envFilepath, keysFilepath, noVlt }) {
|
|
|
28
28
|
const mutated = mutateSrc({ envSrc, envFilepath, keysFilepath, publicKeyName, publicKeyValue: publicKey })
|
|
29
29
|
envSrc = mutated.envSrc
|
|
30
30
|
|
|
31
|
-
if (
|
|
31
|
+
if (noArmor) {
|
|
32
32
|
const mutated = mutateKeysSrcSync({ envFilepath, keysFilepath, privateKeyName, privateKeyValue: privateKey })
|
|
33
33
|
keysSrc = mutated.keysSrc
|
|
34
34
|
envKeysFilepath = mutated.envKeysFilepath
|
|
@@ -3,7 +3,7 @@ const mutateSrc = require('./mutateSrc')
|
|
|
3
3
|
const localKeypair = require('./localKeypair')
|
|
4
4
|
|
|
5
5
|
function provisionWithPrivateKey ({ envSrc, envFilepath, keysFilepath, privateKeyValue, publicKeyValue, publicKeyName }) {
|
|
6
|
-
const { publicKey, privateKey } = localKeypair(privateKeyValue) //
|
|
6
|
+
const { publicKey, privateKey } = localKeypair(privateKeyValue) // noArmor doesn't matter here since privateKeyValue was already discovered prior (via armor and local) and passed as privateKeyValue
|
|
7
7
|
|
|
8
8
|
// if derivation doesn't match what's in the file (or preset in env)
|
|
9
9
|
if (publicKeyValue && publicKeyValue !== publicKey) {
|
|
@@ -2,12 +2,19 @@ const path = require('path')
|
|
|
2
2
|
const childProcess = require('child_process')
|
|
3
3
|
const { logger } = require('../../shared/logger')
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function armorBanner () {
|
|
6
6
|
const lines = [
|
|
7
|
-
'
|
|
7
|
+
' [www.dotenvx.com/armor]',
|
|
8
8
|
'–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––',
|
|
9
|
+
' __ ____ __ ',
|
|
10
|
+
' | || |',
|
|
11
|
+
' | __||__ |',
|
|
12
|
+
' | ‾‾||‾‾ |',
|
|
13
|
+
' | || |',
|
|
14
|
+
' \\ || /',
|
|
15
|
+
' \\ __ /',
|
|
9
16
|
'',
|
|
10
|
-
' Dotenvx
|
|
17
|
+
' Dotenvx Armor ⛨',
|
|
11
18
|
'',
|
|
12
19
|
' ARMORED KEYS',
|
|
13
20
|
' Private keys. Off device. Under guard.',
|
|
@@ -15,8 +22,8 @@ function vltBanner () {
|
|
|
15
22
|
' -',
|
|
16
23
|
'',
|
|
17
24
|
' Install one',
|
|
18
|
-
'
|
|
19
|
-
'
|
|
25
|
+
' [curl -sfS https://dotenvx.sh/armor | sh]',
|
|
26
|
+
' [npm i @dotenvx/dotenvx-armor --save]',
|
|
20
27
|
'',
|
|
21
28
|
' -',
|
|
22
29
|
'',
|
|
@@ -34,6 +41,26 @@ function vltBanner () {
|
|
|
34
41
|
return `${top}\n${middle}\n${bottom}`
|
|
35
42
|
}
|
|
36
43
|
|
|
44
|
+
function dynamicAttempts (command, forwardedArgs) {
|
|
45
|
+
if (command === 'vlt') {
|
|
46
|
+
return [
|
|
47
|
+
['dotenvx-armor', forwardedArgs],
|
|
48
|
+
['dotenvx-vlt', forwardedArgs],
|
|
49
|
+
['dotenvx-ops', forwardedArgs]
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (command === 'ops') {
|
|
54
|
+
return [
|
|
55
|
+
['dotenvx-armor', forwardedArgs],
|
|
56
|
+
['dotenvx-ops', forwardedArgs],
|
|
57
|
+
['dotenvx-vlt', forwardedArgs]
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return [[`dotenvx-${command}`, forwardedArgs]]
|
|
62
|
+
}
|
|
63
|
+
|
|
37
64
|
function executeDynamic (program, command, rawArgs) {
|
|
38
65
|
if (!command) {
|
|
39
66
|
program.outputHelp()
|
|
@@ -52,18 +79,20 @@ function executeDynamic (program, command, rawArgs) {
|
|
|
52
79
|
const newPath = `${binPath}:${process.env.PATH}`
|
|
53
80
|
const env = { ...process.env, PATH: newPath }
|
|
54
81
|
|
|
55
|
-
|
|
56
|
-
let result
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
result
|
|
82
|
+
const spawnOptions = { stdio: 'inherit', env }
|
|
83
|
+
let result
|
|
84
|
+
for (const [spawnCommand, spawnArgs] of dynamicAttempts(command, forwardedArgs)) {
|
|
85
|
+
result = childProcess.spawnSync(spawnCommand, spawnArgs, spawnOptions)
|
|
86
|
+
if (!result.error) break
|
|
60
87
|
}
|
|
61
88
|
|
|
62
89
|
if (result.error) {
|
|
63
90
|
if (command === 'vlt') {
|
|
64
|
-
console.log(
|
|
91
|
+
console.log(armorBanner())
|
|
65
92
|
} else if (command === 'ops') {
|
|
66
|
-
console.log(
|
|
93
|
+
console.log(armorBanner())
|
|
94
|
+
} else if (command === 'armor') {
|
|
95
|
+
console.log(armorBanner())
|
|
67
96
|
} else {
|
|
68
97
|
logger.info(`error: unknown command '${command}'`)
|
|
69
98
|
}
|
|
@@ -5,7 +5,7 @@ const dotenvParse = require('./../dotenvParse')
|
|
|
5
5
|
const keyNames = require('./keyNames')
|
|
6
6
|
const readProcessKey = require('./readProcessKey')
|
|
7
7
|
const readFileKey = require('./readFileKey')
|
|
8
|
-
const
|
|
8
|
+
const armorKeypair = require('../cryptography/armorKeypair')
|
|
9
9
|
|
|
10
10
|
async function invertForPrivateKeyName (filepath) {
|
|
11
11
|
const PUBLIC_KEY_SCHEMA = 'DOTENV_PUBLIC_KEY'
|
|
@@ -34,7 +34,7 @@ async function invertForPrivateKeyName (filepath) {
|
|
|
34
34
|
|
|
35
35
|
async function keyValues (filepath, opts = {}) {
|
|
36
36
|
let keysFilepath = opts.keysFilepath || null
|
|
37
|
-
const
|
|
37
|
+
const noArmor = opts.noArmor === true
|
|
38
38
|
const names = keyNames(filepath)
|
|
39
39
|
const publicKeyName = names.publicKeyName // DOTENV_PUBLIC_KEY_${ENVIRONMENT}
|
|
40
40
|
let privateKeyName = names.privateKeyName // DOTENV_PRIVATE_KEY_${ENVIRONMENT}
|
|
@@ -71,11 +71,11 @@ async function keyValues (filepath, opts = {}) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
if (!
|
|
76
|
-
const kp = await
|
|
74
|
+
// armor
|
|
75
|
+
if (!noArmor && !privateKey && publicKey && publicKey.length > 0) {
|
|
76
|
+
const kp = await armorKeypair(publicKey, { envFilepath: filepath, hooks: opts.keypairHooks })
|
|
77
77
|
privateKey = kp.privateKey
|
|
78
|
-
privateKeySource = '
|
|
78
|
+
privateKeySource = 'armor'
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const result = {
|
|
@@ -2,7 +2,7 @@ const path = require('path')
|
|
|
2
2
|
|
|
3
3
|
const dotenvParse = require('./../dotenvParse')
|
|
4
4
|
const readFileKeySync = require('./readFileKeySync')
|
|
5
|
-
const
|
|
5
|
+
const armorKeypairSync = require('../cryptography/armorKeypairSync')
|
|
6
6
|
|
|
7
7
|
const PUBLIC_KEY_SCHEMA = 'DOTENV_PUBLIC_KEY'
|
|
8
8
|
const PRIVATE_KEY_SCHEMA = 'DOTENV_PRIVATE_KEY'
|
|
@@ -25,7 +25,7 @@ function publicKeyNameFromEnvSrc (envParsed) {
|
|
|
25
25
|
|
|
26
26
|
function keyValuesFromEnvSrc (src, privateKeyName = null, opts = {}) {
|
|
27
27
|
let keysFilepath = opts.keysFilepath || null
|
|
28
|
-
const
|
|
28
|
+
const noArmor = opts.noArmor === true
|
|
29
29
|
const processEnv = opts.processEnv || process.env
|
|
30
30
|
const envParsed = dotenvParse(src)
|
|
31
31
|
|
|
@@ -52,10 +52,10 @@ function keyValuesFromEnvSrc (src, privateKeyName = null, opts = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (!
|
|
56
|
-
const kp =
|
|
55
|
+
if (!noArmor && !privateKeyValue && publicKeyValue && publicKeyValue.length > 0) {
|
|
56
|
+
const kp = armorKeypairSync(publicKeyValue)
|
|
57
57
|
privateKeyValue = kp.privateKey
|
|
58
|
-
privateKeySource = '
|
|
58
|
+
privateKeySource = 'armor'
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const result = {
|
|
@@ -5,7 +5,7 @@ const dotenvParse = require('./../dotenvParse')
|
|
|
5
5
|
const keyNames = require('./keyNames')
|
|
6
6
|
const readProcessKey = require('./readProcessKey')
|
|
7
7
|
const readFileKeySync = require('./readFileKeySync')
|
|
8
|
-
const
|
|
8
|
+
const armorKeypairSync = require('../cryptography/armorKeypairSync')
|
|
9
9
|
|
|
10
10
|
function invertForPrivateKeyName (filepath) {
|
|
11
11
|
const PUBLIC_KEY_SCHEMA = 'DOTENV_PUBLIC_KEY'
|
|
@@ -34,7 +34,7 @@ function invertForPrivateKeyName (filepath) {
|
|
|
34
34
|
|
|
35
35
|
function keyValuesSync (filepath, opts = {}) {
|
|
36
36
|
let keysFilepath = opts.keysFilepath || null
|
|
37
|
-
const
|
|
37
|
+
const noArmor = opts.noArmor === true
|
|
38
38
|
const names = keyNames(filepath)
|
|
39
39
|
const publicKeyName = names.publicKeyName // DOTENV_PUBLIC_KEY_${ENVIRONMENT}
|
|
40
40
|
let privateKeyName = names.privateKeyName // DOTENV_PRIVATE_KEY_${ENVIRONMENT}
|
|
@@ -71,16 +71,16 @@ function keyValuesSync (filepath, opts = {}) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
if (!
|
|
76
|
-
const
|
|
74
|
+
// armor
|
|
75
|
+
if (!noArmor && !privateKey && publicKey && publicKey.length > 0) {
|
|
76
|
+
const armorOptions = { envFilepath: filepath }
|
|
77
77
|
if (opts.noSpinner) {
|
|
78
|
-
|
|
78
|
+
armorOptions.noSpinner = true
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const kp =
|
|
81
|
+
const kp = armorKeypairSync(publicKey, armorOptions)
|
|
82
82
|
privateKey = kp.privateKey
|
|
83
|
-
privateKeySource = '
|
|
83
|
+
privateKeySource = 'armor'
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
const result = {
|
package/src/lib/main.d.ts
CHANGED
|
@@ -147,7 +147,7 @@ export interface DotenvConfigOptions {
|
|
|
147
147
|
quiet?: boolean;
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Disable spinner output from child Dotenvx
|
|
150
|
+
* Disable spinner output from child Dotenvx Armor commands.
|
|
151
151
|
*
|
|
152
152
|
* @default false
|
|
153
153
|
* @example require('@dotenvx/dotenvx').config({ noSpinner: true })
|
|
@@ -165,21 +165,29 @@ export interface DotenvConfigOptions {
|
|
|
165
165
|
| 'debug';
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
* Turn off Dotenvx
|
|
168
|
+
* Turn off Dotenvx Armor features.
|
|
169
169
|
*
|
|
170
170
|
* @default false
|
|
171
|
-
* @example require('@dotenvx/dotenvx').config({
|
|
171
|
+
* @example require('@dotenvx/dotenvx').config({ noArmor: true })
|
|
172
172
|
*/
|
|
173
|
-
|
|
173
|
+
noArmor?: boolean;
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
* Turn off Dotenvx
|
|
176
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
177
177
|
*
|
|
178
178
|
* @default false
|
|
179
179
|
* @example require('@dotenvx/dotenvx').config({ noVlt: true })
|
|
180
180
|
*/
|
|
181
181
|
noVlt?: boolean;
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
185
|
+
*
|
|
186
|
+
* @default false
|
|
187
|
+
* @example require('@dotenvx/dotenvx').config({ noOps: true })
|
|
188
|
+
*/
|
|
189
|
+
noOps?: boolean;
|
|
190
|
+
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
export type DotenvConfigEnv =
|
|
@@ -248,21 +256,29 @@ export interface SetOptions {
|
|
|
248
256
|
encrypt?: boolean;
|
|
249
257
|
|
|
250
258
|
/**
|
|
251
|
-
* Turn off Dotenvx
|
|
259
|
+
* Turn off Dotenvx Armor features.
|
|
252
260
|
*
|
|
253
261
|
* @default false
|
|
254
|
-
* @example require('@dotenvx/dotenvx').set(key, value, {
|
|
262
|
+
* @example require('@dotenvx/dotenvx').set(key, value, { noArmor: true })
|
|
255
263
|
*/
|
|
256
|
-
|
|
264
|
+
noArmor?: boolean;
|
|
257
265
|
|
|
258
266
|
/**
|
|
259
|
-
* Turn off Dotenvx
|
|
267
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
260
268
|
*
|
|
261
269
|
* @default false
|
|
262
270
|
* @example require('@dotenvx/dotenvx').set(key, value, { noVlt: true })
|
|
263
271
|
*/
|
|
264
272
|
noVlt?: boolean;
|
|
265
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
276
|
+
*
|
|
277
|
+
* @default false
|
|
278
|
+
* @example require('@dotenvx/dotenvx').set(key, value, { noOps: true })
|
|
279
|
+
*/
|
|
280
|
+
noOps?: boolean;
|
|
281
|
+
|
|
266
282
|
}
|
|
267
283
|
|
|
268
284
|
export type SetProcessedEnv = {
|
|
@@ -333,21 +349,29 @@ export interface GetOptions {
|
|
|
333
349
|
strict?: boolean;
|
|
334
350
|
|
|
335
351
|
/**
|
|
336
|
-
* Turn off Dotenvx
|
|
352
|
+
* Turn off Dotenvx Armor features.
|
|
337
353
|
*
|
|
338
354
|
* @default false
|
|
339
|
-
* @example require('@dotenvx/dotenvx').get('KEY', {
|
|
355
|
+
* @example require('@dotenvx/dotenvx').get('KEY', { noArmor: true })
|
|
340
356
|
*/
|
|
341
|
-
|
|
357
|
+
noArmor?: boolean;
|
|
342
358
|
|
|
343
359
|
/**
|
|
344
|
-
* Turn off Dotenvx
|
|
360
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
345
361
|
*
|
|
346
362
|
* @default false
|
|
347
363
|
* @example require('@dotenvx/dotenvx').get('KEY', { noVlt: true })
|
|
348
364
|
*/
|
|
349
365
|
noVlt?: boolean;
|
|
350
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
369
|
+
*
|
|
370
|
+
* @default false
|
|
371
|
+
* @example require('@dotenvx/dotenvx').get('KEY', { noOps: true })
|
|
372
|
+
*/
|
|
373
|
+
noOps?: boolean;
|
|
374
|
+
|
|
351
375
|
}
|
|
352
376
|
|
|
353
377
|
/**
|
package/src/lib/main.js
CHANGED
|
@@ -47,8 +47,8 @@ const config = function (options = {}) {
|
|
|
47
47
|
setLogVersion(options)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// dotenvx-
|
|
51
|
-
const
|
|
50
|
+
// dotenvx-armor related
|
|
51
|
+
const noArmor = resolveNoArmor(options)
|
|
52
52
|
|
|
53
53
|
try {
|
|
54
54
|
let envs = buildEnvs(options)
|
|
@@ -59,7 +59,7 @@ const config = function (options = {}) {
|
|
|
59
59
|
processedEnvs,
|
|
60
60
|
readableFilepaths,
|
|
61
61
|
uniqueInjectedKeys
|
|
62
|
-
} = new Run(envs, overload, processEnv, envKeysFile,
|
|
62
|
+
} = new Run(envs, overload, processEnv, envKeysFile, noArmor, {
|
|
63
63
|
noSpinner: options.noSpinner
|
|
64
64
|
}).runSync()
|
|
65
65
|
|
|
@@ -179,13 +179,13 @@ const set = function (key, value, options = {}) {
|
|
|
179
179
|
|
|
180
180
|
const envs = buildEnvs(options)
|
|
181
181
|
const envKeysFilepath = options.envKeysFile
|
|
182
|
-
const
|
|
182
|
+
const noArmor = resolveNoArmor(options)
|
|
183
183
|
|
|
184
184
|
const {
|
|
185
185
|
processedEnvs,
|
|
186
186
|
changedFilepaths,
|
|
187
187
|
unchangedFilepaths
|
|
188
|
-
} = new Sets(key, value, envs, encrypt, envKeysFilepath,
|
|
188
|
+
} = new Sets(key, value, envs, encrypt, envKeysFilepath, noArmor).runSync()
|
|
189
189
|
|
|
190
190
|
let withEncryption = ''
|
|
191
191
|
|
|
@@ -243,12 +243,12 @@ const set = function (key, value, options = {}) {
|
|
|
243
243
|
/* @type {import('./main').get} */
|
|
244
244
|
const get = function (key, options = {}) {
|
|
245
245
|
const envs = buildEnvs(options)
|
|
246
|
-
const
|
|
246
|
+
const noArmor = resolveNoArmor(options)
|
|
247
247
|
|
|
248
248
|
// ignore
|
|
249
249
|
const ignore = options.ignore || []
|
|
250
250
|
|
|
251
|
-
const { parsed, errors } = new Get(key, envs, options.overload, options.all, options.envKeysFile,
|
|
251
|
+
const { parsed, errors } = new Get(key, envs, options.overload, options.all, options.envKeysFile, noArmor).runSync()
|
|
252
252
|
|
|
253
253
|
for (const error of errors || []) {
|
|
254
254
|
if (ignore.includes(error.code)) {
|
|
@@ -313,8 +313,8 @@ const genexample = function (directory, envFile) {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
/** @type {import('./main').keypair} */
|
|
316
|
-
const keypair = function (envFile, key, envKeysFile = null,
|
|
317
|
-
const keypairs = new Keypair(envFile, envKeysFile,
|
|
316
|
+
const keypair = function (envFile, key, envKeysFile = null, noArmor = false) {
|
|
317
|
+
const keypairs = new Keypair(envFile, envKeysFile, noArmor).runSync()
|
|
318
318
|
if (key) {
|
|
319
319
|
return keypairs[key]
|
|
320
320
|
} else {
|
|
@@ -322,9 +322,9 @@ const keypair = function (envFile, key, envKeysFile = null, noVlt = false) {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
function
|
|
325
|
+
function resolveNoArmor (options = {}) {
|
|
326
326
|
const sesh = new Session()
|
|
327
|
-
return options.noVlt === true || options.noOps === true || sesh.
|
|
327
|
+
return options.noArmor === true || options.noVlt === true || options.noOps === true || sesh.noArmorSync()
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
module.exports = {
|
|
@@ -25,12 +25,12 @@ const dotenvParse = require('./../helpers/dotenvParse')
|
|
|
25
25
|
const detectEncoding = require('./../helpers/detectEncoding')
|
|
26
26
|
|
|
27
27
|
class Decrypt {
|
|
28
|
-
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null,
|
|
28
|
+
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false) {
|
|
29
29
|
this.envs = determine(envs, process.env)
|
|
30
30
|
this.key = key
|
|
31
31
|
this.excludeKey = excludeKey
|
|
32
32
|
this.envKeysFilepath = envKeysFilepath
|
|
33
|
-
this.
|
|
33
|
+
this.noArmor = noArmor
|
|
34
34
|
|
|
35
35
|
this.processedEnvs = []
|
|
36
36
|
this.changedFilepaths = new Set()
|
|
@@ -77,11 +77,11 @@ class Decrypt {
|
|
|
77
77
|
const envParsed = dotenvParse(envSrc, false, false, true)
|
|
78
78
|
|
|
79
79
|
const { privateKeyName } = keyNames(envFilepath)
|
|
80
|
-
const { privateKeyValue, privateKeySource } = await keyValues(envFilepath, { keysFilepath: this.envKeysFilepath,
|
|
80
|
+
const { privateKeyValue, privateKeySource } = await keyValues(envFilepath, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
81
81
|
|
|
82
82
|
row.privateKey = privateKeyValue
|
|
83
83
|
row.privateKeySource = privateKeySource
|
|
84
|
-
row.armoredPrivateKeyUsed = privateKeySource === '
|
|
84
|
+
row.armoredPrivateKeyUsed = privateKeySource === 'armor'
|
|
85
85
|
row.privateKeyName = privateKeyName
|
|
86
86
|
row.changed = false // track possible changes
|
|
87
87
|
|
|
@@ -29,12 +29,12 @@ const detectEncoding = require('./../helpers/detectEncoding')
|
|
|
29
29
|
const SAMPLE_ENV_KIT = require('./../helpers/kits/sample')
|
|
30
30
|
|
|
31
31
|
class Encrypt {
|
|
32
|
-
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null,
|
|
32
|
+
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false, noCreate = false, token = undefined, options = {}) {
|
|
33
33
|
this.envs = determine(envs, process.env)
|
|
34
34
|
this.key = key
|
|
35
35
|
this.excludeKey = excludeKey
|
|
36
36
|
this.envKeysFilepath = envKeysFilepath
|
|
37
|
-
this.
|
|
37
|
+
this.noArmor = noArmor
|
|
38
38
|
this.noCreate = noCreate
|
|
39
39
|
this.token = token
|
|
40
40
|
this.keypairHooks = options.keypairHooks
|
|
@@ -105,7 +105,7 @@ class Encrypt {
|
|
|
105
105
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
106
106
|
const { publicKeyValue, privateKeyValue } = await keyValues(envFilepath, {
|
|
107
107
|
keysFilepath: this.envKeysFilepath,
|
|
108
|
-
|
|
108
|
+
noArmor: this.noArmor,
|
|
109
109
|
keypairHooks: this.keypairHooks
|
|
110
110
|
})
|
|
111
111
|
|
|
@@ -115,7 +115,7 @@ class Encrypt {
|
|
|
115
115
|
envSrc,
|
|
116
116
|
envFilepath,
|
|
117
117
|
keysFilepath: this.envKeysFilepath,
|
|
118
|
-
|
|
118
|
+
noArmor: this.noArmor,
|
|
119
119
|
token: this.token,
|
|
120
120
|
keypairHooks: this.keypairHooks,
|
|
121
121
|
selectKeyStorage: this.selectKeyStorage
|
package/src/lib/services/get.js
CHANGED
|
@@ -3,26 +3,26 @@ const Errors = require('./../helpers/errors')
|
|
|
3
3
|
const { determine } = require('./../helpers/envResolution')
|
|
4
4
|
|
|
5
5
|
class Get {
|
|
6
|
-
constructor (key, envs = [], overload = false, all = false, envKeysFilepath = null,
|
|
6
|
+
constructor (key, envs = [], overload = false, all = false, envKeysFilepath = null, noArmor = false) {
|
|
7
7
|
this.key = key
|
|
8
8
|
this.envs = envs
|
|
9
9
|
this.overload = overload
|
|
10
10
|
this.all = all
|
|
11
11
|
this.envKeysFilepath = envKeysFilepath
|
|
12
|
-
this.
|
|
12
|
+
this.noArmor = noArmor
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
runSync () {
|
|
16
16
|
const processEnv = { ...process.env }
|
|
17
17
|
const envs = determine(this.envs, processEnv)
|
|
18
|
-
const { processedEnvs } = new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.
|
|
18
|
+
const { processedEnvs } = new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor).runSync()
|
|
19
19
|
return this._result(processedEnvs, processEnv)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async run () {
|
|
23
23
|
const processEnv = { ...process.env }
|
|
24
24
|
const envs = determine(this.envs, processEnv)
|
|
25
|
-
const { processedEnvs } = await new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.
|
|
25
|
+
const { processedEnvs } = await new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor).run()
|
|
26
26
|
return this._result(processedEnvs, processEnv)
|
|
27
27
|
}
|
|
28
28
|
|