@dotenvx/dotenvx 1.68.1 → 1.69.1
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 +14 -2
- package/README.md +14 -14
- package/package.json +3 -3
- package/src/cli/actions/decrypt.js +5 -4
- package/src/cli/actions/encrypt.js +12 -11
- package/src/cli/actions/get.js +4 -3
- package/src/cli/actions/keypair.js +4 -3
- package/src/cli/actions/normalizeVltOptions.js +10 -0
- package/src/cli/actions/rotate.js +5 -4
- package/src/cli/actions/run.js +4 -3
- package/src/cli/actions/set.js +4 -3
- package/src/cli/dotenvx.js +12 -6
- package/src/db/session.js +9 -9
- package/src/lib/extensions/{ops.js → vlt.js} +25 -28
- 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/cryptography/{opsKeypair.js → vltKeypair.js} +4 -4
- package/src/lib/helpers/cryptography/vltKeypairSync.js +14 -0
- package/src/lib/helpers/executeDynamic.js +16 -13
- package/src/lib/helpers/keyResolution/keyValues.js +5 -5
- package/src/lib/helpers/keyResolution/keyValuesFromEnvSrc.js +4 -4
- package/src/lib/helpers/keyResolution/keyValuesSync.js +7 -7
- package/src/lib/main.d.ts +21 -9
- package/src/lib/main.js +11 -11
- package/src/lib/services/decrypt.js +3 -3
- 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 +5 -5
- package/src/lib/services/sets.js +6 -6
- package/src/lib/helpers/cryptography/opsKeypairSync.js +0 -14
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const mutateSrc = require('./mutateSrc')
|
|
2
2
|
const mutateKeysSrc = require('./mutateKeysSrc')
|
|
3
|
-
const
|
|
3
|
+
const vltKeypair = require('./vltKeypair')
|
|
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, noVlt, token, keypairHooks, selectKeyStorage }) {
|
|
8
|
+
noVlt = noVlt !== false
|
|
9
|
+
if (!noVlt && selectKeyStorage) {
|
|
10
|
+
noVlt = await selectKeyStorage() !== 'armored'
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
@@ -19,12 +19,12 @@ async function provision ({ envSrc, envFilepath, keysFilepath, noOps, token, key
|
|
|
19
19
|
let localPrivateKeyAdded = false
|
|
20
20
|
let remotePrivateKeyAdded = false
|
|
21
21
|
|
|
22
|
-
if (
|
|
22
|
+
if (noVlt) {
|
|
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 vltKeypair(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, noOps, token, key
|
|
|
32
32
|
const mutated = mutateSrc({ envSrc, envFilepath, keysFilepath, publicKeyName, publicKeyValue: publicKey })
|
|
33
33
|
envSrc = mutated.envSrc
|
|
34
34
|
|
|
35
|
-
if (
|
|
35
|
+
if (noVlt) {
|
|
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 vltKeypairSync = require('./vltKeypairSync')
|
|
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, noVlt }) {
|
|
8
|
+
noVlt = noVlt !== false
|
|
9
9
|
const { publicKeyName, privateKeyName } = keyNames(envFilepath)
|
|
10
10
|
|
|
11
11
|
let publicKey
|
|
@@ -15,12 +15,12 @@ function provisionSync ({ envSrc, envFilepath, keysFilepath, noOps }) {
|
|
|
15
15
|
let localPrivateKeyAdded = false
|
|
16
16
|
let remotePrivateKeyAdded = false
|
|
17
17
|
|
|
18
|
-
if (
|
|
18
|
+
if (noVlt) {
|
|
19
19
|
const kp = localKeypair()
|
|
20
20
|
publicKey = kp.publicKey
|
|
21
21
|
privateKey = kp.privateKey
|
|
22
22
|
} else {
|
|
23
|
-
const kp =
|
|
23
|
+
const kp = vltKeypairSync(undefined, { envFilepath })
|
|
24
24
|
publicKey = kp.publicKey
|
|
25
25
|
privateKey = kp.privateKey
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ function provisionSync ({ envSrc, envFilepath, keysFilepath, noOps }) {
|
|
|
28
28
|
const mutated = mutateSrc({ envSrc, envFilepath, keysFilepath, publicKeyName, publicKeyValue: publicKey })
|
|
29
29
|
envSrc = mutated.envSrc
|
|
30
30
|
|
|
31
|
-
if (
|
|
31
|
+
if (noVlt) {
|
|
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) // noVlt doesn't matter here since privateKeyValue was already discovered prior (via vlt 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) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Vlt = require('../../extensions/vlt')
|
|
2
2
|
|
|
3
|
-
async function
|
|
3
|
+
async function vltKeypair (existingPublicKey, options = {}) {
|
|
4
4
|
const hooks = options.hooks || {}
|
|
5
5
|
if (hooks.before) await hooks.before()
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ async function opsKeypair (existingPublicKey, options = {}) {
|
|
|
13
13
|
|
|
14
14
|
let kp
|
|
15
15
|
try {
|
|
16
|
-
kp = await new
|
|
16
|
+
kp = await new Vlt().keypair(existingPublicKey, keypairOptions)
|
|
17
17
|
} finally {
|
|
18
18
|
if (hooks.after) await hooks.after()
|
|
19
19
|
}
|
|
@@ -27,4 +27,4 @@ async function opsKeypair (existingPublicKey, options = {}) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
module.exports =
|
|
30
|
+
module.exports = vltKeypair
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -2,23 +2,23 @@ const path = require('path')
|
|
|
2
2
|
const childProcess = require('child_process')
|
|
3
3
|
const { logger } = require('../../shared/logger')
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
return 'curl -sfS https://dotenvx.sh/
|
|
5
|
+
function installCommandForVlt () {
|
|
6
|
+
return 'curl -sfS https://dotenvx.sh/vlt | sh'
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function vltBanner (installCommand) {
|
|
10
10
|
const lines = [
|
|
11
11
|
'',
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
' ██║
|
|
15
|
-
' ██║
|
|
16
|
-
'
|
|
17
|
-
'
|
|
12
|
+
' ██╗ ██╗██╗ ████████╗',
|
|
13
|
+
' ██║ ██║██║ ╚══██╔══╝',
|
|
14
|
+
' ██║ ██║██║ ██║ ',
|
|
15
|
+
' ╚██╗ ██╔╝██║ ██║ [www.dotenvx.com/vlt]',
|
|
16
|
+
' ╚████╔╝ ███████╗██║ ',
|
|
17
|
+
' ╚═══╝ ╚══════╝╚═╝ ',
|
|
18
18
|
'',
|
|
19
19
|
' ⛨ ARMORED KEYS: Harden your private keys.',
|
|
20
20
|
` ⮕ install [${installCommand}]`,
|
|
21
|
-
' ⮕ then run [dotenvx-
|
|
21
|
+
' ⮕ then run [dotenvx-vlt login]'
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
const innerWidth = Math.max(67, ...lines.map((line) => line.length))
|
|
@@ -49,9 +49,12 @@ function executeDynamic (program, command, rawArgs) {
|
|
|
49
49
|
|
|
50
50
|
const result = childProcess.spawnSync(`dotenvx-${command}`, forwardedArgs, { stdio: 'inherit', env })
|
|
51
51
|
if (result.error) {
|
|
52
|
-
if (command === '
|
|
53
|
-
const installCommand =
|
|
54
|
-
console.log(
|
|
52
|
+
if (command === 'vlt') {
|
|
53
|
+
const installCommand = installCommandForVlt()
|
|
54
|
+
console.log(vltBanner(installCommand))
|
|
55
|
+
} else if (command === 'ops') {
|
|
56
|
+
const installCommand = installCommandForVlt()
|
|
57
|
+
console.log(vltBanner(installCommand))
|
|
55
58
|
} else {
|
|
56
59
|
logger.info(`error: unknown command '${command}'`)
|
|
57
60
|
}
|
|
@@ -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 vltKeypair = require('../cryptography/vltKeypair')
|
|
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 noVlt = opts.noVlt === 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}
|
|
@@ -70,9 +70,9 @@ async function keyValues (filepath, opts = {}) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
//
|
|
74
|
-
if (!
|
|
75
|
-
const kp = await
|
|
73
|
+
// vlt
|
|
74
|
+
if (!noVlt && !privateKey && publicKey && publicKey.length > 0) {
|
|
75
|
+
const kp = await vltKeypair(publicKey, { envFilepath: filepath, hooks: opts.keypairHooks })
|
|
76
76
|
privateKey = kp.privateKey
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -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 vltKeypairSync = require('../cryptography/vltKeypairSync')
|
|
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 noVlt = opts.noVlt === true
|
|
29
29
|
const processEnv = opts.processEnv || process.env
|
|
30
30
|
const envParsed = dotenvParse(src)
|
|
31
31
|
|
|
@@ -51,8 +51,8 @@ function keyValuesFromEnvSrc (src, privateKeyName = null, opts = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (!
|
|
55
|
-
const kp =
|
|
54
|
+
if (!noVlt && !privateKeyValue && publicKeyValue && publicKeyValue.length > 0) {
|
|
55
|
+
const kp = vltKeypairSync(publicKeyValue)
|
|
56
56
|
privateKeyValue = kp.privateKey
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -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 vltKeypairSync = require('../cryptography/vltKeypairSync')
|
|
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 noVlt = opts.noVlt === 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}
|
|
@@ -70,14 +70,14 @@ function keyValuesSync (filepath, opts = {}) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
//
|
|
74
|
-
if (!
|
|
75
|
-
const
|
|
73
|
+
// vlt
|
|
74
|
+
if (!noVlt && !privateKey && publicKey && publicKey.length > 0) {
|
|
75
|
+
const vltOptions = { envFilepath: filepath }
|
|
76
76
|
if (opts.noSpinner) {
|
|
77
|
-
|
|
77
|
+
vltOptions.noSpinner = true
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const kp =
|
|
80
|
+
const kp = vltKeypairSync(publicKey, vltOptions)
|
|
81
81
|
privateKey = kp.privateKey
|
|
82
82
|
}
|
|
83
83
|
|
package/src/lib/main.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ export interface DotenvConfigOptions {
|
|
|
165
165
|
| 'debug';
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
* Turn off Dotenvx Ops features
|
|
168
|
+
* Turn off Dotenvx Vlt Ops features. Alias for `noVlt`.
|
|
169
169
|
*
|
|
170
170
|
* @default false
|
|
171
171
|
* @example require('@dotenvx/dotenvx').config({ noOps: true })
|
|
@@ -173,9 +173,13 @@ export interface DotenvConfigOptions {
|
|
|
173
173
|
noOps?: boolean;
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
|
-
*
|
|
176
|
+
* Turn off Dotenvx Vlt Ops features.
|
|
177
|
+
*
|
|
178
|
+
* @default false
|
|
179
|
+
* @example require('@dotenvx/dotenvx').config({ noVlt: true })
|
|
177
180
|
*/
|
|
178
|
-
|
|
181
|
+
noVlt?: boolean;
|
|
182
|
+
|
|
179
183
|
}
|
|
180
184
|
|
|
181
185
|
export type DotenvConfigEnv =
|
|
@@ -244,7 +248,7 @@ export interface SetOptions {
|
|
|
244
248
|
encrypt?: boolean;
|
|
245
249
|
|
|
246
250
|
/**
|
|
247
|
-
* Turn off Dotenvx Ops features
|
|
251
|
+
* Turn off Dotenvx Vlt Ops features. Alias for `noVlt`.
|
|
248
252
|
*
|
|
249
253
|
* @default false
|
|
250
254
|
* @example require('@dotenvx/dotenvx').set(key, value, { noOps: true })
|
|
@@ -252,9 +256,13 @@ export interface SetOptions {
|
|
|
252
256
|
noOps?: boolean;
|
|
253
257
|
|
|
254
258
|
/**
|
|
255
|
-
*
|
|
259
|
+
* Turn off Dotenvx Vlt Ops features.
|
|
260
|
+
*
|
|
261
|
+
* @default false
|
|
262
|
+
* @example require('@dotenvx/dotenvx').set(key, value, { noVlt: true })
|
|
256
263
|
*/
|
|
257
|
-
|
|
264
|
+
noVlt?: boolean;
|
|
265
|
+
|
|
258
266
|
}
|
|
259
267
|
|
|
260
268
|
export type SetProcessedEnv = {
|
|
@@ -325,7 +333,7 @@ export interface GetOptions {
|
|
|
325
333
|
strict?: boolean;
|
|
326
334
|
|
|
327
335
|
/**
|
|
328
|
-
* Turn off Dotenvx Ops features
|
|
336
|
+
* Turn off Dotenvx Vlt Ops features. Alias for `noVlt`.
|
|
329
337
|
*
|
|
330
338
|
* @default false
|
|
331
339
|
* @example require('@dotenvx/dotenvx').get('KEY', { noOps: true })
|
|
@@ -333,9 +341,13 @@ export interface GetOptions {
|
|
|
333
341
|
noOps?: boolean;
|
|
334
342
|
|
|
335
343
|
/**
|
|
336
|
-
*
|
|
344
|
+
* Turn off Dotenvx Vlt Ops features.
|
|
345
|
+
*
|
|
346
|
+
* @default false
|
|
347
|
+
* @example require('@dotenvx/dotenvx').get('KEY', { noVlt: true })
|
|
337
348
|
*/
|
|
338
|
-
|
|
349
|
+
noVlt?: boolean;
|
|
350
|
+
|
|
339
351
|
}
|
|
340
352
|
|
|
341
353
|
/**
|
package/src/lib/main.js
CHANGED
|
@@ -48,8 +48,8 @@ const config = function (options = {}) {
|
|
|
48
48
|
setLogVersion(options)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// dotenvx-
|
|
52
|
-
const
|
|
51
|
+
// dotenvx-vlt related
|
|
52
|
+
const noVlt = resolveNoVlt(options)
|
|
53
53
|
|
|
54
54
|
try {
|
|
55
55
|
let envs = buildEnvs(options)
|
|
@@ -60,7 +60,7 @@ const config = function (options = {}) {
|
|
|
60
60
|
processedEnvs,
|
|
61
61
|
readableFilepaths,
|
|
62
62
|
uniqueInjectedKeys
|
|
63
|
-
} = new Run(envs, overload, processEnv, envKeysFile,
|
|
63
|
+
} = new Run(envs, overload, processEnv, envKeysFile, noVlt, {
|
|
64
64
|
noSpinner: options.noSpinner
|
|
65
65
|
}).runSync()
|
|
66
66
|
|
|
@@ -180,13 +180,13 @@ const set = function (key, value, options = {}) {
|
|
|
180
180
|
|
|
181
181
|
const envs = buildEnvs(options)
|
|
182
182
|
const envKeysFilepath = options.envKeysFile
|
|
183
|
-
const
|
|
183
|
+
const noVlt = resolveNoVlt(options)
|
|
184
184
|
|
|
185
185
|
const {
|
|
186
186
|
processedEnvs,
|
|
187
187
|
changedFilepaths,
|
|
188
188
|
unchangedFilepaths
|
|
189
|
-
} = new Sets(key, value, envs, encrypt, envKeysFilepath,
|
|
189
|
+
} = new Sets(key, value, envs, encrypt, envKeysFilepath, noVlt).runSync()
|
|
190
190
|
|
|
191
191
|
let withEncryption = ''
|
|
192
192
|
|
|
@@ -247,12 +247,12 @@ const set = function (key, value, options = {}) {
|
|
|
247
247
|
/* @type {import('./main').get} */
|
|
248
248
|
const get = function (key, options = {}) {
|
|
249
249
|
const envs = buildEnvs(options)
|
|
250
|
-
const
|
|
250
|
+
const noVlt = resolveNoVlt(options)
|
|
251
251
|
|
|
252
252
|
// ignore
|
|
253
253
|
const ignore = options.ignore || []
|
|
254
254
|
|
|
255
|
-
const { parsed, errors } = new Get(key, envs, options.overload, options.all, options.envKeysFile,
|
|
255
|
+
const { parsed, errors } = new Get(key, envs, options.overload, options.all, options.envKeysFile, noVlt).runSync()
|
|
256
256
|
|
|
257
257
|
for (const error of errors || []) {
|
|
258
258
|
if (ignore.includes(error.code)) {
|
|
@@ -317,8 +317,8 @@ const genexample = function (directory, envFile) {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/** @type {import('./main').keypair} */
|
|
320
|
-
const keypair = function (envFile, key, envKeysFile = null,
|
|
321
|
-
const keypairs = new Keypair(envFile, envKeysFile,
|
|
320
|
+
const keypair = function (envFile, key, envKeysFile = null, noVlt = false) {
|
|
321
|
+
const keypairs = new Keypair(envFile, envKeysFile, noVlt).runSync()
|
|
322
322
|
if (key) {
|
|
323
323
|
return keypairs[key]
|
|
324
324
|
} else {
|
|
@@ -326,9 +326,9 @@ const keypair = function (envFile, key, envKeysFile = null, noOps = false) {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
function
|
|
329
|
+
function resolveNoVlt (options = {}) {
|
|
330
330
|
const sesh = new Session()
|
|
331
|
-
return options.
|
|
331
|
+
return options.noVlt === true || options.noOps === true || sesh.noVltSync()
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
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, noVlt = 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.noVlt = noVlt
|
|
34
34
|
|
|
35
35
|
this.processedEnvs = []
|
|
36
36
|
this.changedFilepaths = new Set()
|
|
@@ -77,7 +77,7 @@ class Decrypt {
|
|
|
77
77
|
const envParsed = dotenvParse(envSrc, false, false, true)
|
|
78
78
|
|
|
79
79
|
const { privateKeyName } = keyNames(envFilepath)
|
|
80
|
-
const { privateKeyValue } = await keyValues(envFilepath, { keysFilepath: this.envKeysFilepath,
|
|
80
|
+
const { privateKeyValue } = await keyValues(envFilepath, { keysFilepath: this.envKeysFilepath, noVlt: this.noVlt })
|
|
81
81
|
|
|
82
82
|
row.privateKey = privateKeyValue
|
|
83
83
|
row.privateKeyName = privateKeyName
|
|
@@ -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, noVlt = 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.noVlt = noVlt
|
|
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
|
+
noVlt: this.noVlt,
|
|
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
|
+
noVlt: this.noVlt,
|
|
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, noVlt = 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.noVlt = noVlt
|
|
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.noVlt).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.noVlt).run()
|
|
26
26
|
return this._result(processedEnvs, processEnv)
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -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, noVlt = false) {
|
|
9
9
|
this.envFile = envFile
|
|
10
10
|
this.envKeysFilepath = envKeysFilepath
|
|
11
|
-
this.
|
|
11
|
+
this.noVlt = noVlt
|
|
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, noVlt: this.noVlt })
|
|
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, noVlt: this.noVlt })
|
|
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
|
+
vltKeypair,
|
|
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, noVlt = 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.noVlt = noVlt
|
|
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, noVlt: this.noVlt })
|
|
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.noVlt) {
|
|
94
|
+
const kp = await vltKeypair()
|
|
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.noVlt) {
|
|
150
|
+
// keys src only for vlt
|
|
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.noVlt && 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, noVlt = 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.noVlt = noVlt
|
|
26
26
|
this.noSpinner = options.noSpinner
|
|
27
27
|
this.keypairHooks = options.keypairHooks
|
|
28
28
|
|
|
@@ -94,7 +94,7 @@ class Run {
|
|
|
94
94
|
const {
|
|
95
95
|
privateKeyName: resolvedPrivateKeyName,
|
|
96
96
|
privateKeyValue
|
|
97
|
-
} = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath,
|
|
97
|
+
} = keyValuesFromEnvSrc(env, privateKeyName, { keysFilepath: this.envKeysFilepath, noVlt: this.noVlt, processEnv: this.processEnv })
|
|
98
98
|
|
|
99
99
|
const {
|
|
100
100
|
parsed,
|
|
@@ -138,7 +138,7 @@ class Run {
|
|
|
138
138
|
const { privateKeyName } = keyNames(filepath)
|
|
139
139
|
const { privateKeyValue } = keyValuesSync(filepath, {
|
|
140
140
|
keysFilepath: this.envKeysFilepath,
|
|
141
|
-
|
|
141
|
+
noVlt: this.noVlt,
|
|
142
142
|
noSpinner: this.noSpinner
|
|
143
143
|
})
|
|
144
144
|
|
|
@@ -187,7 +187,7 @@ class Run {
|
|
|
187
187
|
const { privateKeyName } = keyNames(filepath)
|
|
188
188
|
const { privateKeyValue } = await keyValues(filepath, {
|
|
189
189
|
keysFilepath: this.envKeysFilepath,
|
|
190
|
-
|
|
190
|
+
noVlt: this.noVlt,
|
|
191
191
|
keypairHooks: this.keypairHooks
|
|
192
192
|
})
|
|
193
193
|
|