@dotenvx/dotenvx 1.71.1 → 1.71.3
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/package.json +1 -1
- package/src/cli/actions/decrypt.js +8 -2
- package/src/cli/actions/encrypt.js +8 -2
- package/src/cli/actions/get.js +4 -1
- package/src/cli/actions/keypair.js +3 -1
- package/src/cli/actions/rotate.js +8 -2
- package/src/cli/actions/run.js +2 -1
- package/src/cli/actions/set.js +4 -1
- package/src/lib/extensions/armor.js +13 -0
- package/src/lib/helpers/cryptography/armorKeypair.js +2 -1
- package/src/lib/helpers/cryptography/provision.js +2 -2
- package/src/lib/helpers/cryptography/provisionSync.js +2 -2
- package/src/lib/helpers/keyResolution/keyValues.js +3 -0
- package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +3 -0
- package/src/lib/helpers/keyResolution/keyValuesSync.js +3 -0
- package/src/lib/services/decrypt.js +7 -2
- package/src/lib/services/encrypt.js +5 -2
- package/src/lib/services/get.js +8 -3
- package/src/lib/services/keypair.js +12 -3
- package/src/lib/services/rotate.js +10 -3
- package/src/lib/services/run.js +12 -3
- package/src/lib/services/sets.js +26 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
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/v1.71.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.71.3...main)
|
|
6
|
+
|
|
7
|
+
## [1.71.3](https://github.com/dotenvx/dotenvx/compare/v1.71.2...v1.71.3) (2026-06-11)
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* Forward command to Dotenvx Armor Key Guard approvals ([#835](https://github.com/dotenvx/dotenvx/pull/835))
|
|
12
|
+
|
|
13
|
+
## [1.71.2](https://github.com/dotenvx/dotenvx/compare/v1.71.1...v1.71.2) (2026-06-08)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* touch up `get`, `set`, and `decrypt` when armor installed ([#834](https://github.com/dotenvx/dotenvx/pull/834))
|
|
6
18
|
|
|
7
19
|
## [1.71.1](https://github.com/dotenvx/dotenvx/compare/v1.71.0...v1.71.1) (2026-06-08)
|
|
8
20
|
|
package/package.json
CHANGED
|
@@ -21,9 +21,12 @@ async function decrypt () {
|
|
|
21
21
|
|
|
22
22
|
// stdout - should not have a try so that exit codes can surface to stdout
|
|
23
23
|
if (options.stdout) {
|
|
24
|
+
if (spinner) spinner.stop()
|
|
24
25
|
const {
|
|
25
26
|
processedEnvs
|
|
26
|
-
} = await new Decrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor
|
|
27
|
+
} = await new Decrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, {
|
|
28
|
+
command: process.argv.slice(2)
|
|
29
|
+
}).run()
|
|
27
30
|
if (spinner) spinner.stop()
|
|
28
31
|
for (const processedEnv of processedEnvs) {
|
|
29
32
|
if (processedEnv.error) {
|
|
@@ -41,11 +44,14 @@ async function decrypt () {
|
|
|
41
44
|
}
|
|
42
45
|
} else {
|
|
43
46
|
try {
|
|
47
|
+
if (spinner) spinner.stop()
|
|
44
48
|
const {
|
|
45
49
|
processedEnvs,
|
|
46
50
|
changedFilepaths,
|
|
47
51
|
unchangedFilepaths
|
|
48
|
-
} = await new Decrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor
|
|
52
|
+
} = await new Decrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, {
|
|
53
|
+
command: process.argv.slice(2)
|
|
54
|
+
}).run()
|
|
49
55
|
|
|
50
56
|
for (const processedEnv of processedEnvs) {
|
|
51
57
|
logger.verbose(`decrypting ${processedEnv.envFilepath} (${processedEnv.filepath})`)
|
|
@@ -56,7 +56,10 @@ async function encrypt () {
|
|
|
56
56
|
if (spinner) spinner.stop()
|
|
57
57
|
const {
|
|
58
58
|
processedEnvs
|
|
59
|
-
} = await new Encrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, noCreate, options.token,
|
|
59
|
+
} = await new Encrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, noCreate, options.token, {
|
|
60
|
+
...encryptOptions(noArmor),
|
|
61
|
+
command: process.argv.slice(2)
|
|
62
|
+
}).run()
|
|
60
63
|
if (spinner) spinner.stop()
|
|
61
64
|
for (const processedEnv of processedEnvs) {
|
|
62
65
|
console.log(processedEnv.envSrc)
|
|
@@ -69,7 +72,10 @@ async function encrypt () {
|
|
|
69
72
|
processedEnvs,
|
|
70
73
|
changedFilepaths,
|
|
71
74
|
unchangedFilepaths
|
|
72
|
-
} = await new Encrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, noCreate, options.token,
|
|
75
|
+
} = await new Encrypt(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, noCreate, options.token, {
|
|
76
|
+
...encryptOptions(noArmor),
|
|
77
|
+
command: process.argv.slice(2)
|
|
78
|
+
}).run()
|
|
73
79
|
|
|
74
80
|
for (const processedEnv of processedEnvs) {
|
|
75
81
|
logger.verbose(`encrypting ${processedEnv.envFilepath} (${processedEnv.filepath})`)
|
package/src/cli/actions/get.js
CHANGED
|
@@ -31,7 +31,10 @@ async function get (key) {
|
|
|
31
31
|
try {
|
|
32
32
|
const sesh = new Session()
|
|
33
33
|
const noArmor = options.armor === false || (await sesh.noArmor())
|
|
34
|
-
|
|
34
|
+
if (spinner) spinner.stop()
|
|
35
|
+
const { parsed, errors } = await new Get(key, envs, options.overload, options.all, options.envKeysFile, noArmor, {
|
|
36
|
+
command: process.argv.slice(2)
|
|
37
|
+
}).run()
|
|
35
38
|
|
|
36
39
|
for (const error of errors || []) {
|
|
37
40
|
if (options.strict) throw error // throw immediately if strict
|
|
@@ -19,7 +19,9 @@ async function keypair (key) {
|
|
|
19
19
|
const sesh = new Session()
|
|
20
20
|
const noArmor = options.armor === false || await sesh.noArmor()
|
|
21
21
|
if (spinner) spinner.stop()
|
|
22
|
-
const keypairs = await new Keypair(options.envFile, options.envKeysFile, noArmor
|
|
22
|
+
const keypairs = await new Keypair(options.envFile, options.envKeysFile, noArmor, {
|
|
23
|
+
command: process.argv.slice(2)
|
|
24
|
+
}).run()
|
|
23
25
|
const results = key ? keypairs[key] : keypairs
|
|
24
26
|
|
|
25
27
|
if (spinner) spinner.stop()
|
|
@@ -20,9 +20,12 @@ async function rotate () {
|
|
|
20
20
|
|
|
21
21
|
// stdout - should not have a try so that exit codes can surface to stdout
|
|
22
22
|
if (options.stdout) {
|
|
23
|
+
if (spinner) spinner.stop()
|
|
23
24
|
const {
|
|
24
25
|
processedEnvs
|
|
25
|
-
} = await new Rotate(envs, options.key, options.excludeKey, options.envKeysFile, noArmor
|
|
26
|
+
} = await new Rotate(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, {
|
|
27
|
+
command: process.argv.slice(2)
|
|
28
|
+
}).run()
|
|
26
29
|
if (spinner) spinner.stop()
|
|
27
30
|
for (const processedEnv of processedEnvs) {
|
|
28
31
|
console.log(processedEnv.envSrc)
|
|
@@ -34,11 +37,14 @@ async function rotate () {
|
|
|
34
37
|
process.exit(0) // exit early
|
|
35
38
|
} else {
|
|
36
39
|
try {
|
|
40
|
+
if (spinner) spinner.stop()
|
|
37
41
|
const {
|
|
38
42
|
processedEnvs,
|
|
39
43
|
changedFilepaths,
|
|
40
44
|
unchangedFilepaths
|
|
41
|
-
} = await new Rotate(envs, options.key, options.excludeKey, options.envKeysFile, noArmor
|
|
45
|
+
} = await new Rotate(envs, options.key, options.excludeKey, options.envKeysFile, noArmor, {
|
|
46
|
+
command: process.argv.slice(2)
|
|
47
|
+
}).run()
|
|
42
48
|
|
|
43
49
|
for (const processedEnv of processedEnvs) {
|
|
44
50
|
logger.verbose(`rotating ${processedEnv.envFilepath} (${processedEnv.filepath})`)
|
package/src/cli/actions/run.js
CHANGED
|
@@ -56,7 +56,8 @@ async function run () {
|
|
|
56
56
|
readableFilepaths,
|
|
57
57
|
uniqueInjectedKeys
|
|
58
58
|
} = await new Run(envs, options.overload, process.env, options.envKeysFile, noArmor, {
|
|
59
|
-
token: options.token
|
|
59
|
+
token: options.token,
|
|
60
|
+
command: commandArgs
|
|
60
61
|
}).run()
|
|
61
62
|
|
|
62
63
|
for (const processedEnv of processedEnvs) {
|
package/src/cli/actions/set.js
CHANGED
|
@@ -30,11 +30,14 @@ async function set (key, value) {
|
|
|
30
30
|
const noArmor = options.armor === false || (await sesh.noArmor())
|
|
31
31
|
const noCreate = options.create === false
|
|
32
32
|
|
|
33
|
+
if (spinner) spinner.stop()
|
|
33
34
|
const {
|
|
34
35
|
processedEnvs,
|
|
35
36
|
changedFilepaths,
|
|
36
37
|
unchangedFilepaths
|
|
37
|
-
} = await new Sets(key, value, envs, encrypt, envKeysFilepath, noArmor, noCreate
|
|
38
|
+
} = await new Sets(key, value, envs, encrypt, envKeysFilepath, noArmor, noCreate, {
|
|
39
|
+
command: process.argv.slice(2)
|
|
40
|
+
}).run()
|
|
38
41
|
|
|
39
42
|
let withEncryption = ''
|
|
40
43
|
|
|
@@ -43,6 +43,7 @@ class Armor {
|
|
|
43
43
|
if (options.noSpinner) args.push('--no-spinner')
|
|
44
44
|
if (options.token) args.push('--token', options.token)
|
|
45
45
|
if (options.envFilepath) args.push('-f', options.envFilepath)
|
|
46
|
+
if (options.command) args.push('--metadata', this._serializeMetadata(options))
|
|
46
47
|
if (publicKey) args.push(publicKey)
|
|
47
48
|
|
|
48
49
|
try {
|
|
@@ -62,6 +63,7 @@ class Armor {
|
|
|
62
63
|
if (options.noSpinner) args.push('--no-spinner')
|
|
63
64
|
if (options.token) args.push('--token', options.token)
|
|
64
65
|
if (options.envFilepath) args.push('-f', options.envFilepath)
|
|
66
|
+
if (options.command) args.push('--metadata', this._serializeMetadata(options))
|
|
65
67
|
if (publicKey) args.push(publicKey)
|
|
66
68
|
|
|
67
69
|
try {
|
|
@@ -97,6 +99,17 @@ class Armor {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
_serializeMetadata (options) {
|
|
103
|
+
return JSON.stringify({
|
|
104
|
+
command: this._serializeCommand(options.command)
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_serializeCommand (command) {
|
|
109
|
+
if (Array.isArray(command)) return command.map((arg) => `${arg}`).join(' ')
|
|
110
|
+
return `${command}`
|
|
111
|
+
}
|
|
112
|
+
|
|
100
113
|
async _exec (binary, args) {
|
|
101
114
|
const { stdout, stderr } = await execFile(binary, args)
|
|
102
115
|
if (stderr && stderr.length > 0) {
|
|
@@ -3,7 +3,8 @@ const Armor = require('../../extensions/armor')
|
|
|
3
3
|
async function armorKeypair (existingPublicKey, options = {}) {
|
|
4
4
|
const keypairOptions = {
|
|
5
5
|
token: options.token,
|
|
6
|
-
envFilepath: options.envFilepath
|
|
6
|
+
envFilepath: options.envFilepath,
|
|
7
|
+
command: options.command
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
const kp = await new Armor().keypair(existingPublicKey, keypairOptions)
|
|
@@ -4,7 +4,7 @@ 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, noArmor, token, selectKeyStorage }) {
|
|
7
|
+
async function provision ({ envSrc, envFilepath, keysFilepath, noArmor, token, selectKeyStorage, command }) {
|
|
8
8
|
noArmor = noArmor !== false
|
|
9
9
|
if (!noArmor && selectKeyStorage) {
|
|
10
10
|
noArmor = await selectKeyStorage() !== 'armored'
|
|
@@ -24,7 +24,7 @@ async function provision ({ envSrc, envFilepath, keysFilepath, noArmor, token, s
|
|
|
24
24
|
publicKey = kp.publicKey
|
|
25
25
|
privateKey = kp.privateKey
|
|
26
26
|
} else {
|
|
27
|
-
const armorOptions = { token, envFilepath }
|
|
27
|
+
const armorOptions = { token, envFilepath, command }
|
|
28
28
|
const kp = await armorKeypair(undefined, armorOptions)
|
|
29
29
|
publicKey = kp.publicKey
|
|
30
30
|
privateKey = kp.privateKey
|
|
@@ -4,7 +4,7 @@ const armorKeypairSync = require('./armorKeypairSync')
|
|
|
4
4
|
const localKeypair = require('./localKeypair')
|
|
5
5
|
const { keyNames } = require('../keyResolution')
|
|
6
6
|
|
|
7
|
-
function provisionSync ({ envSrc, envFilepath, keysFilepath, noArmor }) {
|
|
7
|
+
function provisionSync ({ envSrc, envFilepath, keysFilepath, noArmor, command }) {
|
|
8
8
|
noArmor = noArmor !== false
|
|
9
9
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ function provisionSync ({ envSrc, envFilepath, keysFilepath, noArmor }) {
|
|
|
20
20
|
publicKey = kp.publicKey
|
|
21
21
|
privateKey = kp.privateKey
|
|
22
22
|
} else {
|
|
23
|
-
const kp = armorKeypairSync(undefined, { envFilepath })
|
|
23
|
+
const kp = armorKeypairSync(undefined, { envFilepath, command })
|
|
24
24
|
publicKey = kp.publicKey
|
|
25
25
|
privateKey = kp.privateKey
|
|
26
26
|
}
|
|
@@ -77,6 +77,9 @@ async function keyValues (filepath, opts = {}) {
|
|
|
77
77
|
if (opts.token) {
|
|
78
78
|
armorOptions.token = opts.token
|
|
79
79
|
}
|
|
80
|
+
if (opts.command) {
|
|
81
|
+
armorOptions.command = opts.command
|
|
82
|
+
}
|
|
80
83
|
const kp = await armorKeypair(publicKey, armorOptions)
|
|
81
84
|
privateKey = kp.privateKey
|
|
82
85
|
privateKeySource = 'armor'
|
|
@@ -57,6 +57,9 @@ function keyValuesFromEnvSrc (src, privateKeyName = null, opts = {}) {
|
|
|
57
57
|
if (opts.token) {
|
|
58
58
|
armorOptions.token = opts.token
|
|
59
59
|
}
|
|
60
|
+
if (opts.command) {
|
|
61
|
+
armorOptions.command = opts.command
|
|
62
|
+
}
|
|
60
63
|
const kp = armorKeypairSync(publicKeyValue, armorOptions)
|
|
61
64
|
privateKeyValue = kp.privateKey
|
|
62
65
|
privateKeySource = 'armor'
|
|
@@ -25,12 +25,13 @@ 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, noArmor = false) {
|
|
28
|
+
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false, options = {}) {
|
|
29
29
|
this.envs = determine(envs, process.env)
|
|
30
30
|
this.key = key
|
|
31
31
|
this.excludeKey = excludeKey
|
|
32
32
|
this.envKeysFilepath = envKeysFilepath
|
|
33
33
|
this.noArmor = noArmor
|
|
34
|
+
this.command = options.command
|
|
34
35
|
|
|
35
36
|
this.processedEnvs = []
|
|
36
37
|
this.changedFilepaths = new Set()
|
|
@@ -77,7 +78,11 @@ class Decrypt {
|
|
|
77
78
|
const envParsed = dotenvParse(envSrc, false, false, true)
|
|
78
79
|
|
|
79
80
|
const { privateKeyName } = keyNames(envFilepath)
|
|
80
|
-
const { privateKeyValue, privateKeySource } = await keyValues(envFilepath, {
|
|
81
|
+
const { privateKeyValue, privateKeySource } = await keyValues(envFilepath, {
|
|
82
|
+
keysFilepath: this.envKeysFilepath,
|
|
83
|
+
noArmor: this.noArmor,
|
|
84
|
+
command: this.command
|
|
85
|
+
})
|
|
81
86
|
|
|
82
87
|
row.privateKey = privateKeyValue
|
|
83
88
|
row.privateKeySource = privateKeySource
|
|
@@ -38,6 +38,7 @@ class Encrypt {
|
|
|
38
38
|
this.noCreate = noCreate
|
|
39
39
|
this.token = token
|
|
40
40
|
this.selectKeyStorage = options.selectKeyStorage
|
|
41
|
+
this.command = options.command
|
|
41
42
|
|
|
42
43
|
this.processedEnvs = []
|
|
43
44
|
this.changedFilepaths = new Set()
|
|
@@ -104,7 +105,8 @@ class Encrypt {
|
|
|
104
105
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
105
106
|
const { publicKeyValue, privateKeyValue } = await keyValues(envFilepath, {
|
|
106
107
|
keysFilepath: this.envKeysFilepath,
|
|
107
|
-
noArmor: this.noArmor
|
|
108
|
+
noArmor: this.noArmor,
|
|
109
|
+
command: this.command
|
|
108
110
|
})
|
|
109
111
|
|
|
110
112
|
// first pass - provision
|
|
@@ -115,7 +117,8 @@ class Encrypt {
|
|
|
115
117
|
keysFilepath: this.envKeysFilepath,
|
|
116
118
|
noArmor: this.noArmor,
|
|
117
119
|
token: this.token,
|
|
118
|
-
selectKeyStorage: this.selectKeyStorage
|
|
120
|
+
selectKeyStorage: this.selectKeyStorage,
|
|
121
|
+
command: this.command
|
|
119
122
|
})
|
|
120
123
|
envSrc = prov.envSrc
|
|
121
124
|
publicKey = prov.publicKey
|
package/src/lib/services/get.js
CHANGED
|
@@ -3,26 +3,31 @@ 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, noArmor = false) {
|
|
6
|
+
constructor (key, envs = [], overload = false, all = false, envKeysFilepath = null, noArmor = false, options = {}) {
|
|
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
12
|
this.noArmor = noArmor
|
|
13
|
+
this.command = options.command
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
runSync () {
|
|
16
17
|
const processEnv = { ...process.env }
|
|
17
18
|
const envs = determine(this.envs, processEnv)
|
|
18
|
-
const { processedEnvs } = new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor
|
|
19
|
+
const { processedEnvs } = new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor, {
|
|
20
|
+
command: this.command
|
|
21
|
+
}).runSync()
|
|
19
22
|
return this._result(processedEnvs, processEnv)
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
async run () {
|
|
23
26
|
const processEnv = { ...process.env }
|
|
24
27
|
const envs = determine(this.envs, processEnv)
|
|
25
|
-
const { processedEnvs } = await new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor
|
|
28
|
+
const { processedEnvs } = await new Run(envs, this.overload, processEnv, this.envKeysFilepath, this.noArmor, {
|
|
29
|
+
command: this.command
|
|
30
|
+
}).run()
|
|
26
31
|
return this._result(processedEnvs, processEnv)
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -5,10 +5,11 @@ const {
|
|
|
5
5
|
} = require('./../helpers/keyResolution')
|
|
6
6
|
|
|
7
7
|
class Keypair {
|
|
8
|
-
constructor (envFile = '.env', envKeysFilepath = null, noArmor = false) {
|
|
8
|
+
constructor (envFile = '.env', envKeysFilepath = null, noArmor = false, options = {}) {
|
|
9
9
|
this.envFile = envFile
|
|
10
10
|
this.envKeysFilepath = envKeysFilepath
|
|
11
11
|
this.noArmor = noArmor
|
|
12
|
+
this.command = options.command
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
runSync () {
|
|
@@ -17,7 +18,11 @@ class Keypair {
|
|
|
17
18
|
const filepaths = this._filepaths()
|
|
18
19
|
for (const filepath of filepaths) {
|
|
19
20
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
20
|
-
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, {
|
|
21
|
+
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, {
|
|
22
|
+
keysFilepath: this.envKeysFilepath,
|
|
23
|
+
noArmor: this.noArmor,
|
|
24
|
+
command: this.command
|
|
25
|
+
})
|
|
21
26
|
|
|
22
27
|
out[publicKeyName] = publicKeyValue
|
|
23
28
|
out[privateKeyName] = privateKeyValue
|
|
@@ -32,7 +37,11 @@ class Keypair {
|
|
|
32
37
|
const filepaths = this._filepaths()
|
|
33
38
|
for (const filepath of filepaths) {
|
|
34
39
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
35
|
-
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, {
|
|
40
|
+
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, {
|
|
41
|
+
keysFilepath: this.envKeysFilepath,
|
|
42
|
+
noArmor: this.noArmor,
|
|
43
|
+
command: this.command
|
|
44
|
+
})
|
|
36
45
|
|
|
37
46
|
out[publicKeyName] = publicKeyValue
|
|
38
47
|
out[privateKeyName] = privateKeyValue
|
|
@@ -29,12 +29,13 @@ const dotenvParse = require('./../helpers/dotenvParse')
|
|
|
29
29
|
const detectEncoding = require('./../helpers/detectEncoding')
|
|
30
30
|
|
|
31
31
|
class Rotate {
|
|
32
|
-
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false) {
|
|
32
|
+
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false, 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
37
|
this.noArmor = noArmor
|
|
38
|
+
this.command = options.command
|
|
38
39
|
|
|
39
40
|
this.processedEnvs = []
|
|
40
41
|
this.changedFilepaths = new Set()
|
|
@@ -83,7 +84,11 @@ class Rotate {
|
|
|
83
84
|
const envParsed = dotenvParse(envSrc, false, false, true)
|
|
84
85
|
|
|
85
86
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
86
|
-
const { privateKeyValue } = await keyValues(envFilepath, {
|
|
87
|
+
const { privateKeyValue } = await keyValues(envFilepath, {
|
|
88
|
+
keysFilepath: this.envKeysFilepath,
|
|
89
|
+
noArmor: this.noArmor,
|
|
90
|
+
command: this.command
|
|
91
|
+
})
|
|
87
92
|
|
|
88
93
|
let newPublicKey
|
|
89
94
|
let newPrivateKey
|
|
@@ -91,7 +96,9 @@ class Rotate {
|
|
|
91
96
|
let envKeysSrc
|
|
92
97
|
|
|
93
98
|
if (!this.noArmor) {
|
|
94
|
-
const kp = await armorKeypair(
|
|
99
|
+
const kp = await armorKeypair(undefined, {
|
|
100
|
+
command: this.command
|
|
101
|
+
})
|
|
95
102
|
newPublicKey = kp.publicKey
|
|
96
103
|
newPrivateKey = kp.privateKey
|
|
97
104
|
|
package/src/lib/services/run.js
CHANGED
|
@@ -25,6 +25,7 @@ class Run {
|
|
|
25
25
|
this.noArmor = noArmor
|
|
26
26
|
this.noSpinner = options.noSpinner
|
|
27
27
|
this.token = options.token
|
|
28
|
+
this.command = options.command
|
|
28
29
|
|
|
29
30
|
this.processedEnvs = []
|
|
30
31
|
this.readableFilepaths = new Set()
|
|
@@ -95,7 +96,13 @@ class Run {
|
|
|
95
96
|
privateKeyName: resolvedPrivateKeyName,
|
|
96
97
|
privateKeyValue,
|
|
97
98
|
privateKeySource
|
|
98
|
-
} = keyValuesFromEnvSrc(env, privateKeyName, {
|
|
99
|
+
} = keyValuesFromEnvSrc(env, privateKeyName, {
|
|
100
|
+
keysFilepath: this.envKeysFilepath,
|
|
101
|
+
noArmor: this.noArmor,
|
|
102
|
+
processEnv: this.processEnv,
|
|
103
|
+
token: this.token,
|
|
104
|
+
command: this.command
|
|
105
|
+
})
|
|
99
106
|
|
|
100
107
|
const {
|
|
101
108
|
parsed,
|
|
@@ -145,7 +152,8 @@ class Run {
|
|
|
145
152
|
keysFilepath: this.envKeysFilepath,
|
|
146
153
|
noArmor: this.noArmor,
|
|
147
154
|
noSpinner: this.noSpinner,
|
|
148
|
-
token: this.token
|
|
155
|
+
token: this.token,
|
|
156
|
+
command: this.command
|
|
149
157
|
})
|
|
150
158
|
|
|
151
159
|
const {
|
|
@@ -198,7 +206,8 @@ class Run {
|
|
|
198
206
|
const { privateKeyValue, privateKeySource } = await keyValues(filepath, {
|
|
199
207
|
keysFilepath: this.envKeysFilepath,
|
|
200
208
|
noArmor: this.noArmor,
|
|
201
|
-
token: this.token
|
|
209
|
+
token: this.token,
|
|
210
|
+
command: this.command
|
|
202
211
|
})
|
|
203
212
|
|
|
204
213
|
const {
|
package/src/lib/services/sets.js
CHANGED
|
@@ -34,7 +34,7 @@ function allValuesForKey (envSrc, key) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
class Sets {
|
|
37
|
-
constructor (key, value, envs = [], encrypt = true, envKeysFilepath = null, noArmor = false, noCreate = false) {
|
|
37
|
+
constructor (key, value, envs = [], encrypt = true, envKeysFilepath = null, noArmor = false, noCreate = false, options = {}) {
|
|
38
38
|
this.envs = determine(envs, process.env)
|
|
39
39
|
this.key = key
|
|
40
40
|
this.value = value
|
|
@@ -42,6 +42,7 @@ class Sets {
|
|
|
42
42
|
this.envKeysFilepath = envKeysFilepath
|
|
43
43
|
this.noArmor = noArmor
|
|
44
44
|
this.noCreate = noCreate
|
|
45
|
+
this.command = options.command
|
|
45
46
|
|
|
46
47
|
this.processedEnvs = []
|
|
47
48
|
this.changedFilepaths = new Set()
|
|
@@ -131,11 +132,21 @@ class Sets {
|
|
|
131
132
|
let privateKey
|
|
132
133
|
|
|
133
134
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
134
|
-
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, {
|
|
135
|
+
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, {
|
|
136
|
+
keysFilepath: this.envKeysFilepath,
|
|
137
|
+
noArmor: this.noArmor,
|
|
138
|
+
command: this.command
|
|
139
|
+
})
|
|
135
140
|
|
|
136
141
|
// first pass - provisionSync
|
|
137
142
|
if (!privateKeyValue && !publicKeyValue) {
|
|
138
|
-
const prov = provisionSync({
|
|
143
|
+
const prov = provisionSync({
|
|
144
|
+
envSrc,
|
|
145
|
+
envFilepath,
|
|
146
|
+
keysFilepath: this.envKeysFilepath,
|
|
147
|
+
noArmor: this.noArmor,
|
|
148
|
+
command: this.command
|
|
149
|
+
})
|
|
139
150
|
envSrc = prov.envSrc
|
|
140
151
|
publicKey = prov.publicKey
|
|
141
152
|
privateKey = prov.privateKey
|
|
@@ -238,11 +249,21 @@ class Sets {
|
|
|
238
249
|
let privateKey
|
|
239
250
|
|
|
240
251
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
241
|
-
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, {
|
|
252
|
+
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, {
|
|
253
|
+
keysFilepath: this.envKeysFilepath,
|
|
254
|
+
noArmor: this.noArmor,
|
|
255
|
+
command: this.command
|
|
256
|
+
})
|
|
242
257
|
|
|
243
258
|
// first pass - provision
|
|
244
259
|
if (!privateKeyValue && !publicKeyValue) {
|
|
245
|
-
const prov = await provision({
|
|
260
|
+
const prov = await provision({
|
|
261
|
+
envSrc,
|
|
262
|
+
envFilepath,
|
|
263
|
+
keysFilepath: this.envKeysFilepath,
|
|
264
|
+
noArmor: this.noArmor,
|
|
265
|
+
command: this.command
|
|
266
|
+
})
|
|
246
267
|
envSrc = prov.envSrc
|
|
247
268
|
publicKey = prov.publicKey
|
|
248
269
|
privateKey = prov.privateKey
|