@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
|
@@ -5,10 +5,10 @@ const {
|
|
|
5
5
|
} = require('./../helpers/keyResolution')
|
|
6
6
|
|
|
7
7
|
class Keypair {
|
|
8
|
-
constructor (envFile = '.env', envKeysFilepath = null,
|
|
8
|
+
constructor (envFile = '.env', envKeysFilepath = null, noArmor = false) {
|
|
9
9
|
this.envFile = envFile
|
|
10
10
|
this.envKeysFilepath = envKeysFilepath
|
|
11
|
-
this.
|
|
11
|
+
this.noArmor = noArmor
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
runSync () {
|
|
@@ -17,7 +17,7 @@ class Keypair {
|
|
|
17
17
|
const filepaths = this._filepaths()
|
|
18
18
|
for (const filepath of filepaths) {
|
|
19
19
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
20
|
-
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, { keysFilepath: this.envKeysFilepath,
|
|
20
|
+
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
21
21
|
|
|
22
22
|
out[publicKeyName] = publicKeyValue
|
|
23
23
|
out[privateKeyName] = privateKeyValue
|
|
@@ -32,7 +32,7 @@ class Keypair {
|
|
|
32
32
|
const filepaths = this._filepaths()
|
|
33
33
|
for (const filepath of filepaths) {
|
|
34
34
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
35
|
-
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, { keysFilepath: this.envKeysFilepath,
|
|
35
|
+
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
36
36
|
|
|
37
37
|
out[publicKeyName] = publicKeyValue
|
|
38
38
|
out[privateKeyName] = privateKeyValue
|
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
} = require('./../helpers/keyResolution')
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
|
-
|
|
19
|
+
armorKeypair,
|
|
20
20
|
localKeypair,
|
|
21
21
|
encryptValue,
|
|
22
22
|
decryptKeyValue,
|
|
@@ -29,12 +29,12 @@ 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,
|
|
32
|
+
constructor (envs = [], key = [], excludeKey = [], envKeysFilepath = null, noArmor = false) {
|
|
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
|
|
|
39
39
|
this.processedEnvs = []
|
|
40
40
|
this.changedFilepaths = new Set()
|
|
@@ -83,15 +83,15 @@ class Rotate {
|
|
|
83
83
|
const envParsed = dotenvParse(envSrc, false, false, true)
|
|
84
84
|
|
|
85
85
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
86
|
-
const { privateKeyValue } = await keyValues(envFilepath, { keysFilepath: this.envKeysFilepath,
|
|
86
|
+
const { privateKeyValue } = await keyValues(envFilepath, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
87
87
|
|
|
88
88
|
let newPublicKey
|
|
89
89
|
let newPrivateKey
|
|
90
90
|
let envKeysFilepath
|
|
91
91
|
let envKeysSrc
|
|
92
92
|
|
|
93
|
-
if (!this.
|
|
94
|
-
const kp = await
|
|
93
|
+
if (!this.noArmor) {
|
|
94
|
+
const kp = await armorKeypair()
|
|
95
95
|
newPublicKey = kp.publicKey
|
|
96
96
|
newPrivateKey = kp.privateKey
|
|
97
97
|
|
|
@@ -146,8 +146,8 @@ class Rotate {
|
|
|
146
146
|
row.privateKeyName = privateKeyName
|
|
147
147
|
row.privateKey = newPrivateKey
|
|
148
148
|
|
|
149
|
-
if (this.
|
|
150
|
-
// keys src only for
|
|
149
|
+
if (this.noArmor) {
|
|
150
|
+
// keys src only for local key storage
|
|
151
151
|
envKeysSrc = append(envKeysSrc, privateKeyName, newPrivateKey) // append privateKey
|
|
152
152
|
this.envKeysSources[envKeysFilepath] = envKeysSrc
|
|
153
153
|
row.envKeysSrc = envKeysSrc
|
|
@@ -158,7 +158,7 @@ class Rotate {
|
|
|
158
158
|
if (e.code === 'ENOENT') {
|
|
159
159
|
const missingPath = e.path ? path.resolve(e.path) : null
|
|
160
160
|
const expectedEnvKeysPath = row.envKeysFilepath ? path.resolve(row.envKeysFilepath) : null
|
|
161
|
-
if (this.
|
|
161
|
+
if (this.noArmor && expectedEnvKeysPath && missingPath === expectedEnvKeysPath) {
|
|
162
162
|
row.error = new Errors({ envKeysFilepath: row.envKeysFilepath }).missingEnvKeysFile()
|
|
163
163
|
} else {
|
|
164
164
|
row.error = new Errors({ envFilepath, filepath }).missingEnvFile()
|
package/src/lib/services/run.js
CHANGED
|
@@ -17,12 +17,12 @@ const {
|
|
|
17
17
|
} = require('./../helpers/keyResolution')
|
|
18
18
|
|
|
19
19
|
class Run {
|
|
20
|
-
constructor (envs = [], overload = false, processEnv = process.env, envKeysFilepath = null,
|
|
20
|
+
constructor (envs = [], overload = false, processEnv = process.env, envKeysFilepath = null, noArmor = false, options = {}) {
|
|
21
21
|
this.envs = envs
|
|
22
22
|
this.overload = overload
|
|
23
23
|
this.processEnv = processEnv
|
|
24
24
|
this.envKeysFilepath = envKeysFilepath
|
|
25
|
-
this.
|
|
25
|
+
this.noArmor = noArmor
|
|
26
26
|
this.noSpinner = options.noSpinner
|
|
27
27
|
this.keypairHooks = options.keypairHooks
|
|
28
28
|
|
|
@@ -95,7 +95,7 @@ class Run {
|
|
|
95
95
|
privateKeyName: resolvedPrivateKeyName,
|
|
96
96
|
privateKeyValue,
|
|
97
97
|
privateKeySource
|
|
98
|
-
} = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath,
|
|
98
|
+
} = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor, processEnv: this.processEnv })
|
|
99
99
|
|
|
100
100
|
const {
|
|
101
101
|
parsed,
|
|
@@ -108,7 +108,7 @@ class Run {
|
|
|
108
108
|
row.privateKey = privateKeyValue
|
|
109
109
|
if (privateKeySource) {
|
|
110
110
|
row.privateKeySource = privateKeySource
|
|
111
|
-
row.armoredPrivateKeyUsed = privateKeySource === '
|
|
111
|
+
row.armoredPrivateKeyUsed = privateKeySource === 'armor'
|
|
112
112
|
}
|
|
113
113
|
row.parsed = parsed
|
|
114
114
|
row.errors = errors
|
|
@@ -143,7 +143,7 @@ class Run {
|
|
|
143
143
|
const { privateKeyName } = keyNames(filepath)
|
|
144
144
|
const { privateKeyValue, privateKeySource } = keyValuesSync(filepath, {
|
|
145
145
|
keysFilepath: this.envKeysFilepath,
|
|
146
|
-
|
|
146
|
+
noArmor: this.noArmor,
|
|
147
147
|
noSpinner: this.noSpinner
|
|
148
148
|
})
|
|
149
149
|
|
|
@@ -158,7 +158,7 @@ class Run {
|
|
|
158
158
|
row.privateKey = privateKeyValue
|
|
159
159
|
if (privateKeySource) {
|
|
160
160
|
row.privateKeySource = privateKeySource
|
|
161
|
-
row.armoredPrivateKeyUsed = privateKeySource === '
|
|
161
|
+
row.armoredPrivateKeyUsed = privateKeySource === 'armor'
|
|
162
162
|
}
|
|
163
163
|
row.src = src
|
|
164
164
|
row.parsed = parsed
|
|
@@ -196,7 +196,7 @@ class Run {
|
|
|
196
196
|
const { privateKeyName } = keyNames(filepath)
|
|
197
197
|
const { privateKeyValue, privateKeySource } = await keyValues(filepath, {
|
|
198
198
|
keysFilepath: this.envKeysFilepath,
|
|
199
|
-
|
|
199
|
+
noArmor: this.noArmor,
|
|
200
200
|
keypairHooks: this.keypairHooks
|
|
201
201
|
})
|
|
202
202
|
|
|
@@ -211,7 +211,7 @@ class Run {
|
|
|
211
211
|
row.privateKey = privateKeyValue
|
|
212
212
|
if (privateKeySource) {
|
|
213
213
|
row.privateKeySource = privateKeySource
|
|
214
|
-
row.armoredPrivateKeyUsed = privateKeySource === '
|
|
214
|
+
row.armoredPrivateKeyUsed = privateKeySource === 'armor'
|
|
215
215
|
}
|
|
216
216
|
row.src = src
|
|
217
217
|
row.parsed = parsed
|
package/src/lib/services/sets.js
CHANGED
|
@@ -34,13 +34,13 @@ function allValuesForKey (envSrc, key) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
class Sets {
|
|
37
|
-
constructor (key, value, envs = [], encrypt = true, envKeysFilepath = null,
|
|
37
|
+
constructor (key, value, envs = [], encrypt = true, envKeysFilepath = null, noArmor = false, noCreate = false) {
|
|
38
38
|
this.envs = determine(envs, process.env)
|
|
39
39
|
this.key = key
|
|
40
40
|
this.value = value
|
|
41
41
|
this.encrypt = encrypt
|
|
42
42
|
this.envKeysFilepath = envKeysFilepath
|
|
43
|
-
this.
|
|
43
|
+
this.noArmor = noArmor
|
|
44
44
|
this.noCreate = noCreate
|
|
45
45
|
|
|
46
46
|
this.processedEnvs = []
|
|
@@ -131,11 +131,11 @@ class Sets {
|
|
|
131
131
|
let privateKey
|
|
132
132
|
|
|
133
133
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
134
|
-
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, { keysFilepath: this.envKeysFilepath,
|
|
134
|
+
const { publicKeyValue, privateKeyValue } = keyValuesSync(filepath, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
135
135
|
|
|
136
136
|
// first pass - provisionSync
|
|
137
137
|
if (!privateKeyValue && !publicKeyValue) {
|
|
138
|
-
const prov = provisionSync({ envSrc, envFilepath, keysFilepath: this.envKeysFilepath,
|
|
138
|
+
const prov = provisionSync({ envSrc, envFilepath, keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
139
139
|
envSrc = prov.envSrc
|
|
140
140
|
publicKey = prov.publicKey
|
|
141
141
|
privateKey = prov.privateKey
|
|
@@ -238,11 +238,11 @@ class Sets {
|
|
|
238
238
|
let privateKey
|
|
239
239
|
|
|
240
240
|
const { publicKeyName, privateKeyName } = keyNames(filepath)
|
|
241
|
-
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, { keysFilepath: this.envKeysFilepath,
|
|
241
|
+
const { publicKeyValue, privateKeyValue } = await keyValues(filepath, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
242
242
|
|
|
243
243
|
// first pass - provision
|
|
244
244
|
if (!privateKeyValue && !publicKeyValue) {
|
|
245
|
-
const prov = await provision({ envSrc, envFilepath, keysFilepath: this.envKeysFilepath,
|
|
245
|
+
const prov = await provision({ envSrc, envFilepath, keysFilepath: this.envKeysFilepath, noArmor: this.noArmor })
|
|
246
246
|
envSrc = prov.envSrc
|
|
247
247
|
publicKey = prov.publicKey
|
|
248
248
|
privateKey = prov.privateKey
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const Vlt = require('../../extensions/vlt')
|
|
2
|
-
|
|
3
|
-
function vltKeypairSync (existingPublicKey, options = {}) {
|
|
4
|
-
const kp = new Vlt().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 = vltKeypairSync
|