@dotenvx/dotenvx 2.28.0 → 2.28.2
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 -1
- package/README.md +40 -8
- package/package.json +1 -1
- package/src/cli/actions/define.js +17 -0
- package/src/cli/actions/encrypt.js +1 -1
- package/src/cli/actions/ext/precommit.js +3 -0
- package/src/cli/actions/ext/precommitClean.js +21 -0
- package/src/cli/actions/get.js +2 -1
- package/src/cli/actions/init.js +3 -0
- package/src/cli/actions/lock/down.js +13 -32
- package/src/cli/actions/lock/up.js +13 -30
- package/src/cli/actions/run.js +2 -1
- package/src/cli/actions/set.js +1 -1
- package/src/cli/commands/custody.js +2 -2
- package/src/cli/commands/ext.js +3 -1
- package/src/cli/commands/fileOptions.js +22 -0
- package/src/cli/dotenvx.js +38 -21
- package/src/lib/custodians/index.js +73 -0
- package/src/lib/{helpers/bitwardenCustody.js → custodians/local/bitwarden.js} +12 -7
- package/src/lib/custodians/local/file.js +18 -0
- package/src/lib/custodians/local/native/backend.js +62 -0
- package/src/lib/custodians/local/native/index.js +28 -0
- package/src/lib/{helpers/storeNativePrivateKey.js → custodians/local/native/store.js} +3 -3
- package/src/lib/{helpers/onePasswordCustody.js → custodians/local/onepassword.js} +9 -5
- package/src/lib/custodians/lock.js +80 -0
- package/src/lib/{providers/armor/index.js → custodians/managed/armor/get.js} +6 -6
- package/src/lib/custodians/managed/armor/index.js +24 -0
- package/src/lib/custodians/managed/armor/store.js +37 -0
- package/src/lib/helpers/fsx.js +16 -5
- package/src/lib/helpers/installPrecommitFilter.js +50 -0
- package/src/lib/helpers/installPrecommitHook.js +2 -2
- package/src/lib/helpers/lockedValue.js +24 -0
- package/src/lib/helpers/macosKeychain.js +18 -2
- package/src/lib/helpers/matchesStoredKey.js +16 -0
- package/src/lib/helpers/normalizeDotenvConfigPath.js +1 -1
- package/src/lib/helpers/parseWithDecryptor.js +3 -0
- package/src/lib/helpers/prompts.js +18 -0
- package/src/lib/helpers/removeEnvKey.js +2 -1
- package/src/lib/helpers/resolveLockPassword.js +5 -0
- package/src/lib/helpers/selectKeyStorage.js +9 -21
- package/src/lib/helpers/unlockedValue.js +26 -0
- package/src/lib/helpers/upsertEnvKey.js +2 -1
- package/src/lib/helpers/withLockedKeys.js +41 -0
- package/src/lib/main.d.ts +6 -0
- package/src/lib/main.js +5 -2
- package/src/lib/providers/index.js +9 -66
- package/src/lib/providers/native/index.js +2 -62
- package/src/lib/providers/provider-worker.js +1 -1
- package/src/lib/resolvers/envs.js +14 -5
- package/src/lib/resolvers/get.js +1 -0
- package/src/lib/services/custodyTransfer.js +2 -2
- package/src/lib/services/init.js +49 -0
- package/src/lib/services/precommit.js +12 -1
- package/src/lib/services/validate.js +1 -0
- package/src/lib/transforms/encrypt.js +6 -49
- package/src/lib/transforms/set.js +6 -49
|
@@ -7,19 +7,12 @@ const TYPE_ENV_FILE = 'envFile'
|
|
|
7
7
|
const getResolver = require('./../resolvers/get')
|
|
8
8
|
const { determine } = require('./../helpers/envResolution')
|
|
9
9
|
const detectEncoding = require('./../helpers/detectEncoding')
|
|
10
|
-
const { isPlainKey, mutateSrc
|
|
10
|
+
const { isPlainKey, mutateSrc } = require('../helpers/cryptography')
|
|
11
11
|
const keynames = require('../conventions/keynames')
|
|
12
12
|
const Errors = require('../helpers/errors')
|
|
13
|
-
const PostArmorUp = require('../api/postArmorUp')
|
|
14
|
-
const prompts = require('../helpers/prompts')
|
|
15
|
-
const teamChoicesFromMeta = require('../helpers/teamChoicesFromMeta')
|
|
16
|
-
const isTeamRequiredError = require('../helpers/isTeamRequiredError')
|
|
17
|
-
const Session = require('../../db/session')
|
|
18
13
|
|
|
19
14
|
const selectKeyStorage = require('../helpers/selectKeyStorage')
|
|
20
|
-
const
|
|
21
|
-
const onePasswordCustody = require('../helpers/onePasswordCustody')
|
|
22
|
-
const bitwardenCustody = require('../helpers/bitwardenCustody')
|
|
15
|
+
const custodians = require('../custodians')
|
|
23
16
|
|
|
24
17
|
async function setTransform (options = {}) {
|
|
25
18
|
const envs = options.envs || []
|
|
@@ -28,6 +21,7 @@ async function setTransform (options = {}) {
|
|
|
28
21
|
const fk = options.fk || '.env.keys'
|
|
29
22
|
const noArmor = options.noArmor
|
|
30
23
|
let storage
|
|
24
|
+
const custodyContext = {}
|
|
31
25
|
const noNative = options.noNative
|
|
32
26
|
const noCreate = options.noCreate
|
|
33
27
|
const noEncrypt = !options.encrypt || isPlainKey(key)
|
|
@@ -91,46 +85,9 @@ async function setTransform (options = {}) {
|
|
|
91
85
|
|
|
92
86
|
const comment = path.basename(envFilepath)
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
await onePasswordCustody.set(publicKey, privateKey)
|
|
98
|
-
} else if (storage === 'native' && storeNativePrivateKey(publicKey, privateKey, fk)) {
|
|
99
|
-
row.nativePrivateKeyAdded = true
|
|
100
|
-
} else if (storage !== 'armored') {
|
|
101
|
-
const mutated = mutateKeysSrc({ keysSrc, privateKeyName, privateKeyValue: privateKey, comment })
|
|
102
|
-
keysSrc = mutated.keysSrc
|
|
103
|
-
} else {
|
|
104
|
-
const sesh = new Session()
|
|
105
|
-
const hostname = sesh.hostname()
|
|
106
|
-
const token = sesh.token()
|
|
107
|
-
const devicePublicKey = sesh.devicePublicKey()
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, undefined).run()
|
|
111
|
-
} catch (error) {
|
|
112
|
-
if (!isTeamRequiredError(error)) {
|
|
113
|
-
throw error
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const choices = teamChoicesFromMeta(error.meta)
|
|
117
|
-
|
|
118
|
-
let team = choices[0].value
|
|
119
|
-
if (choices.length > 1) {
|
|
120
|
-
team = await prompts.select({
|
|
121
|
-
message: 'Select team',
|
|
122
|
-
choices
|
|
123
|
-
}, {
|
|
124
|
-
input: process.stdin,
|
|
125
|
-
output: process.stderr
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team).run()
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// don't set keysSrc (in armor)
|
|
133
|
-
}
|
|
88
|
+
const stored = await custodians.store(storage, publicKey, privateKey, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
|
|
89
|
+
if (Object.prototype.hasOwnProperty.call(stored, 'keysSrc')) keysSrc = stored.keysSrc
|
|
90
|
+
if (stored.nativePrivateKeyAdded) row.nativePrivateKeyAdded = true
|
|
134
91
|
}
|
|
135
92
|
|
|
136
93
|
if (noEncrypt) {
|