@dotenvx/dotenvx 1.69.2 → 1.71.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 +13 -1
- package/README.md +29 -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 +5 -4
- package/src/cli/actions/set.js +4 -4
- package/src/cli/commands/ext.js +1 -1
- package/src/cli/dotenvx.js +31 -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 +10 -6
- package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +9 -5
- package/src/lib/helpers/keyResolution/keyValuesSync.js +11 -8
- package/src/lib/main.d.ts +44 -13
- package/src/lib/main.js +13 -12
- 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 +12 -9
- 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,15 @@ async function keyValues (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, hooks: opts.keypairHooks }
|
|
77
|
+
if (opts.token) {
|
|
78
|
+
armorOptions.token = opts.token
|
|
79
|
+
}
|
|
80
|
+
const kp = await armorKeypair(publicKey, armorOptions)
|
|
77
81
|
privateKey = kp.privateKey
|
|
78
|
-
privateKeySource = '
|
|
82
|
+
privateKeySource = 'armor'
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
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,14 @@ function keyValuesFromEnvSrc (src, privateKeyName = null, opts = {}) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (!
|
|
56
|
-
const
|
|
55
|
+
if (!noArmor && !privateKeyValue && publicKeyValue && publicKeyValue.length > 0) {
|
|
56
|
+
const armorOptions = {}
|
|
57
|
+
if (opts.token) {
|
|
58
|
+
armorOptions.token = opts.token
|
|
59
|
+
}
|
|
60
|
+
const kp = armorKeypairSync(publicKeyValue, armorOptions)
|
|
57
61
|
privateKeyValue = kp.privateKey
|
|
58
|
-
privateKeySource = '
|
|
62
|
+
privateKeySource = 'armor'
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
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,19 @@ 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
|
+
if (opts.token) {
|
|
78
|
+
armorOptions.token = opts.token
|
|
79
|
+
}
|
|
77
80
|
if (opts.noSpinner) {
|
|
78
|
-
|
|
81
|
+
armorOptions.noSpinner = true
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
const kp =
|
|
84
|
+
const kp = armorKeypairSync(publicKey, armorOptions)
|
|
82
85
|
privateKey = kp.privateKey
|
|
83
|
-
privateKeySource = '
|
|
86
|
+
privateKeySource = 'armor'
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
const result = {
|
package/src/lib/main.d.ts
CHANGED
|
@@ -147,13 +147,20 @@ 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 })
|
|
154
154
|
*/
|
|
155
155
|
noSpinner?: boolean;
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Set Armor token.
|
|
159
|
+
*
|
|
160
|
+
* @example require('@dotenvx/dotenvx').config({ token: process.env.DOTENVX_ARMOR_TOKEN })
|
|
161
|
+
*/
|
|
162
|
+
token?: string;
|
|
163
|
+
|
|
157
164
|
logLevel?:
|
|
158
165
|
| 'error'
|
|
159
166
|
| 'warn'
|
|
@@ -165,21 +172,29 @@ export interface DotenvConfigOptions {
|
|
|
165
172
|
| 'debug';
|
|
166
173
|
|
|
167
174
|
/**
|
|
168
|
-
* Turn off Dotenvx
|
|
175
|
+
* Turn off Dotenvx Armor features.
|
|
169
176
|
*
|
|
170
177
|
* @default false
|
|
171
|
-
* @example require('@dotenvx/dotenvx').config({
|
|
178
|
+
* @example require('@dotenvx/dotenvx').config({ noArmor: true })
|
|
172
179
|
*/
|
|
173
|
-
|
|
180
|
+
noArmor?: boolean;
|
|
174
181
|
|
|
175
182
|
/**
|
|
176
|
-
* Turn off Dotenvx
|
|
183
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
177
184
|
*
|
|
178
185
|
* @default false
|
|
179
186
|
* @example require('@dotenvx/dotenvx').config({ noVlt: true })
|
|
180
187
|
*/
|
|
181
188
|
noVlt?: boolean;
|
|
182
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
192
|
+
*
|
|
193
|
+
* @default false
|
|
194
|
+
* @example require('@dotenvx/dotenvx').config({ noOps: true })
|
|
195
|
+
*/
|
|
196
|
+
noOps?: boolean;
|
|
197
|
+
|
|
183
198
|
}
|
|
184
199
|
|
|
185
200
|
export type DotenvConfigEnv =
|
|
@@ -248,21 +263,29 @@ export interface SetOptions {
|
|
|
248
263
|
encrypt?: boolean;
|
|
249
264
|
|
|
250
265
|
/**
|
|
251
|
-
* Turn off Dotenvx
|
|
266
|
+
* Turn off Dotenvx Armor features.
|
|
252
267
|
*
|
|
253
268
|
* @default false
|
|
254
|
-
* @example require('@dotenvx/dotenvx').set(key, value, {
|
|
269
|
+
* @example require('@dotenvx/dotenvx').set(key, value, { noArmor: true })
|
|
255
270
|
*/
|
|
256
|
-
|
|
271
|
+
noArmor?: boolean;
|
|
257
272
|
|
|
258
273
|
/**
|
|
259
|
-
* Turn off Dotenvx
|
|
274
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
260
275
|
*
|
|
261
276
|
* @default false
|
|
262
277
|
* @example require('@dotenvx/dotenvx').set(key, value, { noVlt: true })
|
|
263
278
|
*/
|
|
264
279
|
noVlt?: boolean;
|
|
265
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
283
|
+
*
|
|
284
|
+
* @default false
|
|
285
|
+
* @example require('@dotenvx/dotenvx').set(key, value, { noOps: true })
|
|
286
|
+
*/
|
|
287
|
+
noOps?: boolean;
|
|
288
|
+
|
|
266
289
|
}
|
|
267
290
|
|
|
268
291
|
export type SetProcessedEnv = {
|
|
@@ -333,21 +356,29 @@ export interface GetOptions {
|
|
|
333
356
|
strict?: boolean;
|
|
334
357
|
|
|
335
358
|
/**
|
|
336
|
-
* Turn off Dotenvx
|
|
359
|
+
* Turn off Dotenvx Armor features.
|
|
337
360
|
*
|
|
338
361
|
* @default false
|
|
339
|
-
* @example require('@dotenvx/dotenvx').get('KEY', {
|
|
362
|
+
* @example require('@dotenvx/dotenvx').get('KEY', { noArmor: true })
|
|
340
363
|
*/
|
|
341
|
-
|
|
364
|
+
noArmor?: boolean;
|
|
342
365
|
|
|
343
366
|
/**
|
|
344
|
-
* Turn off Dotenvx
|
|
367
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
345
368
|
*
|
|
346
369
|
* @default false
|
|
347
370
|
* @example require('@dotenvx/dotenvx').get('KEY', { noVlt: true })
|
|
348
371
|
*/
|
|
349
372
|
noVlt?: boolean;
|
|
350
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Turn off Dotenvx Armor features. Alias for `noArmor`.
|
|
376
|
+
*
|
|
377
|
+
* @default false
|
|
378
|
+
* @example require('@dotenvx/dotenvx').get('KEY', { noOps: true })
|
|
379
|
+
*/
|
|
380
|
+
noOps?: boolean;
|
|
381
|
+
|
|
351
382
|
}
|
|
352
383
|
|
|
353
384
|
/**
|
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,8 +59,9 @@ const config = function (options = {}) {
|
|
|
59
59
|
processedEnvs,
|
|
60
60
|
readableFilepaths,
|
|
61
61
|
uniqueInjectedKeys
|
|
62
|
-
} = new Run(envs, overload, processEnv, envKeysFile,
|
|
63
|
-
noSpinner: options.noSpinner
|
|
62
|
+
} = new Run(envs, overload, processEnv, envKeysFile, noArmor, {
|
|
63
|
+
noSpinner: options.noSpinner,
|
|
64
|
+
token: options.token
|
|
64
65
|
}).runSync()
|
|
65
66
|
|
|
66
67
|
let lastError
|
|
@@ -179,13 +180,13 @@ const set = function (key, value, options = {}) {
|
|
|
179
180
|
|
|
180
181
|
const envs = buildEnvs(options)
|
|
181
182
|
const envKeysFilepath = options.envKeysFile
|
|
182
|
-
const
|
|
183
|
+
const noArmor = resolveNoArmor(options)
|
|
183
184
|
|
|
184
185
|
const {
|
|
185
186
|
processedEnvs,
|
|
186
187
|
changedFilepaths,
|
|
187
188
|
unchangedFilepaths
|
|
188
|
-
} = new Sets(key, value, envs, encrypt, envKeysFilepath,
|
|
189
|
+
} = new Sets(key, value, envs, encrypt, envKeysFilepath, noArmor).runSync()
|
|
189
190
|
|
|
190
191
|
let withEncryption = ''
|
|
191
192
|
|
|
@@ -243,12 +244,12 @@ const set = function (key, value, options = {}) {
|
|
|
243
244
|
/* @type {import('./main').get} */
|
|
244
245
|
const get = function (key, options = {}) {
|
|
245
246
|
const envs = buildEnvs(options)
|
|
246
|
-
const
|
|
247
|
+
const noArmor = resolveNoArmor(options)
|
|
247
248
|
|
|
248
249
|
// ignore
|
|
249
250
|
const ignore = options.ignore || []
|
|
250
251
|
|
|
251
|
-
const { parsed, errors } = new Get(key, envs, options.overload, options.all, options.envKeysFile,
|
|
252
|
+
const { parsed, errors } = new Get(key, envs, options.overload, options.all, options.envKeysFile, noArmor).runSync()
|
|
252
253
|
|
|
253
254
|
for (const error of errors || []) {
|
|
254
255
|
if (ignore.includes(error.code)) {
|
|
@@ -313,8 +314,8 @@ const genexample = function (directory, envFile) {
|
|
|
313
314
|
}
|
|
314
315
|
|
|
315
316
|
/** @type {import('./main').keypair} */
|
|
316
|
-
const keypair = function (envFile, key, envKeysFile = null,
|
|
317
|
-
const keypairs = new Keypair(envFile, envKeysFile,
|
|
317
|
+
const keypair = function (envFile, key, envKeysFile = null, noArmor = false) {
|
|
318
|
+
const keypairs = new Keypair(envFile, envKeysFile, noArmor).runSync()
|
|
318
319
|
if (key) {
|
|
319
320
|
return keypairs[key]
|
|
320
321
|
} else {
|
|
@@ -322,9 +323,9 @@ const keypair = function (envFile, key, envKeysFile = null, noVlt = false) {
|
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
function
|
|
326
|
+
function resolveNoArmor (options = {}) {
|
|
326
327
|
const sesh = new Session()
|
|
327
|
-
return options.noVlt === true || options.noOps === true || sesh.
|
|
328
|
+
return options.noArmor === true || options.noVlt === true || options.noOps === true || (!options.token && sesh.noArmorSync())
|
|
328
329
|
}
|
|
329
330
|
|
|
330
331
|
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
|
|