@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.
Files changed (38) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +29 -14
  3. package/package.json +7 -6
  4. package/src/cli/actions/decrypt.js +5 -5
  5. package/src/cli/actions/encrypt.js +13 -13
  6. package/src/cli/actions/get.js +4 -4
  7. package/src/cli/actions/keypair.js +4 -4
  8. package/src/cli/actions/normalizeArmorOptions.js +11 -0
  9. package/src/cli/actions/rotate.js +5 -5
  10. package/src/cli/actions/run.js +5 -4
  11. package/src/cli/actions/set.js +4 -4
  12. package/src/cli/commands/ext.js +1 -1
  13. package/src/cli/dotenvx.js +31 -33
  14. package/src/db/session.js +9 -9
  15. package/src/lib/extensions/{vlt.js → armor.js} +4 -4
  16. package/src/lib/helpers/cryptography/{vltKeypair.js → armorKeypair.js} +4 -4
  17. package/src/lib/helpers/cryptography/armorKeypairSync.js +14 -0
  18. package/src/lib/helpers/cryptography/index.js +2 -2
  19. package/src/lib/helpers/cryptography/mutateKeysSrc.js +1 -1
  20. package/src/lib/helpers/cryptography/mutateKeysSrcSync.js +1 -1
  21. package/src/lib/helpers/cryptography/provision.js +8 -8
  22. package/src/lib/helpers/cryptography/provisionSync.js +6 -6
  23. package/src/lib/helpers/cryptography/provisionWithPrivateKey.js +1 -1
  24. package/src/lib/helpers/executeDynamic.js +41 -12
  25. package/src/lib/helpers/keyResolution/keyValues.js +10 -6
  26. package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +9 -5
  27. package/src/lib/helpers/keyResolution/keyValuesSync.js +11 -8
  28. package/src/lib/main.d.ts +44 -13
  29. package/src/lib/main.js +13 -12
  30. package/src/lib/services/decrypt.js +4 -4
  31. package/src/lib/services/encrypt.js +4 -4
  32. package/src/lib/services/get.js +4 -4
  33. package/src/lib/services/keypair.js +4 -4
  34. package/src/lib/services/rotate.js +9 -9
  35. package/src/lib/services/run.js +12 -9
  36. package/src/lib/services/sets.js +6 -6
  37. package/src/cli/actions/normalizeVltOptions.js +0 -10
  38. 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, noVlt = false) {
8
+ constructor (envFile = '.env', envKeysFilepath = null, noArmor = false) {
9
9
  this.envFile = envFile
10
10
  this.envKeysFilepath = envKeysFilepath
11
- this.noVlt = noVlt
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, noVlt: this.noVlt })
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, noVlt: this.noVlt })
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
- vltKeypair,
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, noVlt = false) {
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.noVlt = noVlt
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, noVlt: this.noVlt })
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.noVlt) {
94
- const kp = await vltKeypair()
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.noVlt) {
150
- // keys src only for vlt
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.noVlt && expectedEnvKeysPath && missingPath === expectedEnvKeysPath) {
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()
@@ -17,13 +17,14 @@ const {
17
17
  } = require('./../helpers/keyResolution')
18
18
 
19
19
  class Run {
20
- constructor (envs = [], overload = false, processEnv = process.env, envKeysFilepath = null, noVlt = false, options = {}) {
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.noVlt = noVlt
25
+ this.noArmor = noArmor
26
26
  this.noSpinner = options.noSpinner
27
+ this.token = options.token
27
28
  this.keypairHooks = options.keypairHooks
28
29
 
29
30
  this.processedEnvs = []
@@ -95,7 +96,7 @@ class Run {
95
96
  privateKeyName: resolvedPrivateKeyName,
96
97
  privateKeyValue,
97
98
  privateKeySource
98
- } = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath, noVlt: this.noVlt, processEnv: this.processEnv })
99
+ } = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath, noArmor: this.noArmor, processEnv: this.processEnv, token: this.token })
99
100
 
100
101
  const {
101
102
  parsed,
@@ -108,7 +109,7 @@ class Run {
108
109
  row.privateKey = privateKeyValue
109
110
  if (privateKeySource) {
110
111
  row.privateKeySource = privateKeySource
111
- row.armoredPrivateKeyUsed = privateKeySource === 'vlt'
112
+ row.armoredPrivateKeyUsed = privateKeySource === 'armor'
112
113
  }
113
114
  row.parsed = parsed
114
115
  row.errors = errors
@@ -143,8 +144,9 @@ class Run {
143
144
  const { privateKeyName } = keyNames(filepath)
144
145
  const { privateKeyValue, privateKeySource } = keyValuesSync(filepath, {
145
146
  keysFilepath: this.envKeysFilepath,
146
- noVlt: this.noVlt,
147
- noSpinner: this.noSpinner
147
+ noArmor: this.noArmor,
148
+ noSpinner: this.noSpinner,
149
+ token: this.token
148
150
  })
149
151
 
150
152
  const {
@@ -158,7 +160,7 @@ class Run {
158
160
  row.privateKey = privateKeyValue
159
161
  if (privateKeySource) {
160
162
  row.privateKeySource = privateKeySource
161
- row.armoredPrivateKeyUsed = privateKeySource === 'vlt'
163
+ row.armoredPrivateKeyUsed = privateKeySource === 'armor'
162
164
  }
163
165
  row.src = src
164
166
  row.parsed = parsed
@@ -196,7 +198,8 @@ class Run {
196
198
  const { privateKeyName } = keyNames(filepath)
197
199
  const { privateKeyValue, privateKeySource } = await keyValues(filepath, {
198
200
  keysFilepath: this.envKeysFilepath,
199
- noVlt: this.noVlt,
201
+ noArmor: this.noArmor,
202
+ token: this.token,
200
203
  keypairHooks: this.keypairHooks
201
204
  })
202
205
 
@@ -211,7 +214,7 @@ class Run {
211
214
  row.privateKey = privateKeyValue
212
215
  if (privateKeySource) {
213
216
  row.privateKeySource = privateKeySource
214
- row.armoredPrivateKeyUsed = privateKeySource === 'vlt'
217
+ row.armoredPrivateKeyUsed = privateKeySource === 'armor'
215
218
  }
216
219
  row.src = src
217
220
  row.parsed = parsed
@@ -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, noVlt = false, noCreate = false) {
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.noVlt = noVlt
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, noVlt: this.noVlt })
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, noVlt: this.noVlt })
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, noVlt: this.noVlt })
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, noVlt: this.noVlt })
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,10 +0,0 @@
1
- function normalizeVltOptions (options) {
2
- if (options.ops === false || options.vlt === false) {
3
- options.ops = false
4
- options.vlt = false
5
- }
6
-
7
- return options
8
- }
9
-
10
- module.exports = normalizeVltOptions
@@ -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