@dotenvx/dotenvx 2.38.2 → 3.0.0-beta.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/README.md +186 -3315
- package/bin/dotenvx.cjs +34 -0
- package/config.cjs +1 -0
- package/config.d.ts +1 -0
- package/config.mjs +2 -0
- package/index.cjs +139 -0
- package/index.d.ts +66 -0
- package/index.mjs +3 -0
- package/lib/cli.cjs +43 -0
- package/lib/native-package.cjs +21 -0
- package/lib/platforms.cjs +18 -0
- package/{src/lib/helpers/redactOutput.js → lib/redactOutput.cjs} +2 -48
- package/lib/redaction.cjs +64 -0
- package/lib/validateOptions.cjs +57 -0
- package/native.cjs +23 -0
- package/package.json +57 -65
- package/CHANGELOG.md +0 -2733
- package/src/cli/actions/armor/down.js +0 -38
- package/src/cli/actions/armor/invite.js +0 -21
- package/src/cli/actions/armor/move.js +0 -43
- package/src/cli/actions/armor/open.js +0 -28
- package/src/cli/actions/armor/pull.js +0 -38
- package/src/cli/actions/armor/push.js +0 -38
- package/src/cli/actions/armor/status.js +0 -7
- package/src/cli/actions/armor/up.js +0 -38
- package/src/cli/actions/check.js +0 -78
- package/src/cli/actions/curl.js +0 -71
- package/src/cli/actions/decrypt.js +0 -119
- package/src/cli/actions/del.js +0 -54
- package/src/cli/actions/doctor.js +0 -22
- package/src/cli/actions/encrypt.js +0 -104
- package/src/cli/actions/ext/genexample.js +0 -36
- package/src/cli/actions/ext/gitignore.js +0 -106
- package/src/cli/actions/ext/prebuild.js +0 -7
- package/src/cli/actions/ext/precommit.js +0 -38
- package/src/cli/actions/ext/scan.js +0 -33
- package/src/cli/actions/feedback.js +0 -42
- package/src/cli/actions/get.js +0 -128
- package/src/cli/actions/init.js +0 -67
- package/src/cli/actions/keychain/down.js +0 -30
- package/src/cli/actions/keychain/pull.js +0 -30
- package/src/cli/actions/keychain/push.js +0 -30
- package/src/cli/actions/keychain/up.js +0 -30
- package/src/cli/actions/keypair.js +0 -84
- package/src/cli/actions/login.js +0 -64
- package/src/cli/actions/logout.js +0 -37
- package/src/cli/actions/ls.js +0 -76
- package/src/cli/actions/policy.js +0 -14
- package/src/cli/actions/primitivesCheck.js +0 -32
- package/src/cli/actions/primitivesProfile.js +0 -15
- package/src/cli/actions/primitivesRedact.js +0 -19
- package/src/cli/actions/protect.js +0 -75
- package/src/cli/actions/protectDocker.js +0 -30
- package/src/cli/actions/protectProcess.js +0 -126
- package/src/cli/actions/protectStdin.js +0 -80
- package/src/cli/actions/run.js +0 -203
- package/src/cli/actions/set.js +0 -103
- package/src/cli/actions/settings/device.js +0 -23
- package/src/cli/actions/settings/hostname.js +0 -20
- package/src/cli/actions/settings/off.js +0 -14
- package/src/cli/actions/settings/on.js +0 -14
- package/src/cli/actions/settings/path.js +0 -20
- package/src/cli/actions/settings/token.js +0 -23
- package/src/cli/actions/settings/username.js +0 -20
- package/src/cli/actions/update.js +0 -15
- package/src/cli/commandAction.js +0 -16
- package/src/cli/commands/armor.js +0 -129
- package/src/cli/commands/custody.js +0 -45
- package/src/cli/commands/ext.js +0 -88
- package/src/cli/commands/fileOptions.js +0 -22
- package/src/cli/commands/native.js +0 -54
- package/src/cli/commands/primitives.js +0 -73
- package/src/cli/commands/settings.js +0 -63
- package/src/cli/dotenvx.js +0 -443
- package/src/cli/help.js +0 -179
- package/src/db/device.js +0 -67
- package/src/db/session.js +0 -330
- package/src/lib/api/getAccount.js +0 -32
- package/src/lib/api/getConnectionResources.js +0 -21
- package/src/lib/api/getTeamConnections.js +0 -27
- package/src/lib/api/getTeamServices.js +0 -23
- package/src/lib/api/getTeams.js +0 -28
- package/src/lib/api/postArmorDown.js +0 -48
- package/src/lib/api/postArmorMove.js +0 -48
- package/src/lib/api/postArmorPull.js +0 -48
- package/src/lib/api/postArmorPush.js +0 -48
- package/src/lib/api/postArmorUp.js +0 -53
- package/src/lib/api/postConnectionKeypair.js +0 -23
- package/src/lib/api/postFeedback.js +0 -31
- package/src/lib/api/postLogout.js +0 -34
- package/src/lib/api/postOauthDeviceCode.js +0 -38
- package/src/lib/api/postOauthToken.js +0 -35
- package/src/lib/api/postTeamInvitation.js +0 -28
- package/src/lib/api/teamConnectionSetup.js +0 -31
- package/src/lib/config.d.ts +0 -1
- package/src/lib/config.js +0 -1
- package/src/lib/conventions/environment.js +0 -27
- package/src/lib/conventions/filepaths.js +0 -9
- package/src/lib/conventions/keynames.js +0 -38
- package/src/lib/custodians/index.js +0 -75
- package/src/lib/custodians/local/bitwarden.js +0 -165
- package/src/lib/custodians/local/file.js +0 -18
- package/src/lib/custodians/local/native/backend.js +0 -56
- package/src/lib/custodians/local/native/index.js +0 -28
- package/src/lib/custodians/local/native/store.js +0 -24
- package/src/lib/custodians/local/onepassword.js +0 -149
- package/src/lib/custodians/managed/armor/index.js +0 -14
- package/src/lib/custodians/managed/armor/store.js +0 -48
- package/src/lib/custodians/resolveLocalKey.js +0 -67
- package/src/lib/decryptors/armor/index.js +0 -23
- package/src/lib/decryptors/decryptor-worker.js +0 -6
- package/src/lib/decryptors/index.js +0 -69
- package/src/lib/envfile/discovery/discoverEnvFiles.js +0 -29
- package/src/lib/envfile/discovery/extractEnvKeys.js +0 -173
- package/src/lib/envfile/discovery/scanSource.js +0 -79
- package/src/lib/envfile/parsing/formatEnvfileSyntaxError.js +0 -24
- package/src/lib/envfile/parsing/readEnvfile.js +0 -43
- package/src/lib/envfile/parsing/resolveEnvfilePath.js +0 -5
- package/src/lib/envfile/rendering/normalizeEnvfile.js +0 -53
- package/src/lib/envfile/rendering/previewEnvfile.js +0 -43
- package/src/lib/envfile/rendering/renderEnvfile.js +0 -30
- package/src/lib/envfile/validation/diagnosticLocation.js +0 -29
- package/src/lib/envfile/validation/protectEnvfile.js +0 -40
- package/src/lib/envfile/validation/validateEnvfile.js +0 -14
- package/src/lib/events/backends/armor.js +0 -31
- package/src/lib/events/background.js +0 -59
- package/src/lib/events/catalog.js +0 -14
- package/src/lib/events/cli.js +0 -40
- package/src/lib/events/delivery.js +0 -89
- package/src/lib/events/index.js +0 -73
- package/src/lib/events/metadata.js +0 -25
- package/src/lib/events/sdk.js +0 -44
- package/src/lib/events/worker.js +0 -29
- package/src/lib/events/workerEnvironment.js +0 -14
- package/src/lib/helpers/armoredKeyDisplay.js +0 -10
- package/src/lib/helpers/arrayToTree.js +0 -27
- package/src/lib/helpers/buildApiError.js +0 -19
- package/src/lib/helpers/buildCommandEnvs.js +0 -40
- package/src/lib/helpers/buildConfigEnvs.js +0 -13
- package/src/lib/helpers/buildEnvs.js +0 -24
- package/src/lib/helpers/buildOauthError.js +0 -14
- package/src/lib/helpers/canonicalEnvFilename.js +0 -13
- package/src/lib/helpers/catchAndLog.js +0 -16
- package/src/lib/helpers/checklist.js +0 -50
- package/src/lib/helpers/chomp.js +0 -5
- package/src/lib/helpers/colorDepth.js +0 -23
- package/src/lib/helpers/conventions.js +0 -28
- package/src/lib/helpers/createElapsedStatus.js +0 -17
- package/src/lib/helpers/createProtectSpinner.js +0 -13
- package/src/lib/helpers/createSpinner.js +0 -40
- package/src/lib/helpers/cryptography/decryptKeyValue.js +0 -50
- package/src/lib/helpers/cryptography/index.js +0 -7
- package/src/lib/helpers/cryptography/isDotenvPublicKey.js +0 -7
- package/src/lib/helpers/cryptography/isPlainKey.js +0 -7
- package/src/lib/helpers/cryptography/mutateKeysSrc.js +0 -22
- package/src/lib/helpers/cryptography/mutateSrc.js +0 -24
- package/src/lib/helpers/custodySelect.js +0 -25
- package/src/lib/helpers/decryptDeviceValue.js +0 -7
- package/src/lib/helpers/detectEncoding.js +0 -22
- package/src/lib/helpers/detectEncodingSync.js +0 -22
- package/src/lib/helpers/dotenvOptionPaths.js +0 -25
- package/src/lib/helpers/dotenvPrivateKeyNames.js +0 -7
- package/src/lib/helpers/enclavedHint.js +0 -11
- package/src/lib/helpers/encryptDeviceValue.js +0 -7
- package/src/lib/helpers/envResolution/determine.js +0 -49
- package/src/lib/helpers/envResolution/index.js +0 -8
- package/src/lib/helpers/errors.js +0 -374
- package/src/lib/helpers/escape.js +0 -6
- package/src/lib/helpers/execute.js +0 -12
- package/src/lib/helpers/executeCommand.js +0 -208
- package/src/lib/helpers/executeDynamic.js +0 -86
- package/src/lib/helpers/executeExtension.js +0 -39
- package/src/lib/helpers/filterKeys.js +0 -15
- package/src/lib/helpers/findEnvFiles.js +0 -25
- package/src/lib/helpers/formatCode.js +0 -11
- package/src/lib/helpers/fsx.js +0 -110
- package/src/lib/helpers/guessPrivateKeyFilename.js +0 -15
- package/src/lib/helpers/hasPlaintextSecrets.js +0 -7
- package/src/lib/helpers/http.js +0 -14
- package/src/lib/helpers/installPrecommitHook.js +0 -82
- package/src/lib/helpers/installProtectFilter.js +0 -57
- package/src/lib/helpers/installProtectIgnore.js +0 -27
- package/src/lib/helpers/isPublicKey.js +0 -3
- package/src/lib/helpers/isTeamRequiredError.js +0 -10
- package/src/lib/helpers/jsonToEnv.js +0 -7
- package/src/lib/helpers/keypairMetadata.js +0 -90
- package/src/lib/helpers/kits/sample.js +0 -5
- package/src/lib/helpers/linuxSecretService.js +0 -52
- package/src/lib/helpers/listenForOpenKey.js +0 -46
- package/src/lib/helpers/logProtectedFiles.js +0 -9
- package/src/lib/helpers/logSetSummary.js +0 -21
- package/src/lib/helpers/macosKeychain.js +0 -52
- package/src/lib/helpers/mask.js +0 -22
- package/src/lib/helpers/maskEnvSrc.js +0 -15
- package/src/lib/helpers/maskProcessedEnvs.js +0 -29
- package/src/lib/helpers/matchesStoredKey.js +0 -5
- package/src/lib/helpers/nativeStoreError.js +0 -10
- package/src/lib/helpers/normalizeDotenvConfigConvention.js +0 -13
- package/src/lib/helpers/normalizeDotenvConfigIgnore.js +0 -18
- package/src/lib/helpers/normalizeDotenvConfigPath.js +0 -14
- package/src/lib/helpers/normalizeDotenvConfigQuiet.js +0 -13
- package/src/lib/helpers/normalizeToken.js +0 -5
- package/src/lib/helpers/openUrl.js +0 -7
- package/src/lib/helpers/packageJson.js +0 -3
- package/src/lib/helpers/parseWithDecryptor.js +0 -115
- package/src/lib/helpers/plaintextKeys.js +0 -9
- package/src/lib/helpers/precommitEnvPatterns.js +0 -1
- package/src/lib/helpers/prependPublicKey.js +0 -17
- package/src/lib/helpers/preserveShebang.js +0 -16
- package/src/lib/helpers/prompts.js +0 -169
- package/src/lib/helpers/protectSettings.js +0 -64
- package/src/lib/helpers/ptyCommand.js +0 -27
- package/src/lib/helpers/readEnvKey.js +0 -32
- package/src/lib/helpers/redact.js +0 -9
- package/src/lib/helpers/redactProcessOutput.js +0 -58
- package/src/lib/helpers/redactedValues.js +0 -29
- package/src/lib/helpers/removeDynamicHelpSection.js +0 -21
- package/src/lib/helpers/removeEnvKey.js +0 -51
- package/src/lib/helpers/removeLegacyProtectFilter.js +0 -43
- package/src/lib/helpers/removeOptionsHelpParts.js +0 -59
- package/src/lib/helpers/resolveBitwardenPassword.js +0 -165
- package/src/lib/helpers/resolveDirectoryFilepath.js +0 -16
- package/src/lib/helpers/resolveEnvKeysFile.js +0 -11
- package/src/lib/helpers/resolveHome.js +0 -12
- package/src/lib/helpers/resolveOnePassword.js +0 -82
- package/src/lib/helpers/sanitizeCommandForMetadata.js +0 -64
- package/src/lib/helpers/selectConnection.js +0 -51
- package/src/lib/helpers/selectConnectionResource.js +0 -41
- package/src/lib/helpers/selectEnvfileEnvs.js +0 -29
- package/src/lib/helpers/selectKeyStorage.js +0 -140
- package/src/lib/helpers/statusReporter.js +0 -8
- package/src/lib/helpers/storeKeyStorage.js +0 -39
- package/src/lib/helpers/teamChoicesFromMeta.js +0 -8
- package/src/lib/helpers/truncate.js +0 -10
- package/src/lib/helpers/uninstallPrecommitHook.js +0 -67
- package/src/lib/helpers/upsertEnvKey.js +0 -62
- package/src/lib/helpers/windowsCredentialManager.js +0 -166
- package/src/lib/main.d.ts +0 -509
- package/src/lib/main.js +0 -468
- package/src/lib/providers/index.js +0 -86
- package/src/lib/providers/native/index.js +0 -2
- package/src/lib/resolvers/envs.js +0 -416
- package/src/lib/resolvers/get.js +0 -87
- package/src/lib/resolvers/keypair.js +0 -135
- package/src/lib/resolvers/ls.js +0 -69
- package/src/lib/services/armorDown.js +0 -73
- package/src/lib/services/armorInvite.js +0 -36
- package/src/lib/services/armorMove.js +0 -55
- package/src/lib/services/armorOpen.js +0 -26
- package/src/lib/services/armorPull.js +0 -73
- package/src/lib/services/armorPush.js +0 -66
- package/src/lib/services/armorUp.js +0 -71
- package/src/lib/services/custodyTransfer.js +0 -50
- package/src/lib/services/doctor.js +0 -93
- package/src/lib/services/genexample.js +0 -112
- package/src/lib/services/init.js +0 -83
- package/src/lib/services/keychainDown.js +0 -60
- package/src/lib/services/keychainPull.js +0 -46
- package/src/lib/services/keychainPush.js +0 -51
- package/src/lib/services/keychainUp.js +0 -72
- package/src/lib/services/login.js +0 -51
- package/src/lib/services/logout.js +0 -26
- package/src/lib/services/prebuild.js +0 -91
- package/src/lib/services/precommit.js +0 -144
- package/src/lib/services/validate.js +0 -57
- package/src/lib/transforms/decrypt.js +0 -98
- package/src/lib/transforms/del.js +0 -58
- package/src/lib/transforms/encrypt.js +0 -164
- package/src/lib/transforms/set.js +0 -144
- package/src/shared/colors.js +0 -67
- package/src/shared/logger.js +0 -148
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const commandAction = require('../commandAction')
|
|
2
|
-
const executeDynamic = require('./../../lib/helpers/executeDynamic')
|
|
3
|
-
|
|
4
|
-
function configureArmorCommand (armor) {
|
|
5
|
-
armor
|
|
6
|
-
.description('move private keys in/out of Dotenvx Armor [www.dotenvx.com/armor]')
|
|
7
|
-
.allowUnknownOption()
|
|
8
|
-
.argument('[command]', 'dotenvx-armor command')
|
|
9
|
-
.argument('[args...]', 'dotenvx-armor command arguments')
|
|
10
|
-
.action(async function (command, args) {
|
|
11
|
-
if (command) {
|
|
12
|
-
return executeDynamic(armor, 'armor', [command, ...(args || [])])
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Session = require('./../../db/session')
|
|
16
|
-
const sesh = new Session()
|
|
17
|
-
await sesh.notifyUpdate()
|
|
18
|
-
this.help()
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
// dotenvx armor up
|
|
22
|
-
armor
|
|
23
|
-
.command('up')
|
|
24
|
-
.description('armor key')
|
|
25
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
26
|
-
.option('--token <token>', 'set token')
|
|
27
|
-
.option('--team <team>', 'team to armor private key for')
|
|
28
|
-
.action(function (...args) {
|
|
29
|
-
return commandAction(require('./../actions/armor/up')).apply(this, args)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
// dotenvx armor down
|
|
33
|
-
armor
|
|
34
|
-
.command('down')
|
|
35
|
-
.description('dearmor key')
|
|
36
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
37
|
-
.option('--token <token>', 'set token')
|
|
38
|
-
.option('--team <team>', 'team to dearmor private key from')
|
|
39
|
-
.action(function (...args) {
|
|
40
|
-
return commandAction(require('./../actions/armor/down')).apply(this, args)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// dotenvx armor push
|
|
44
|
-
armor
|
|
45
|
-
.command('push')
|
|
46
|
-
.description('push armored key')
|
|
47
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
48
|
-
.option('--token <token>', 'set token')
|
|
49
|
-
.option('--team <team>', 'team to push armored private key for')
|
|
50
|
-
.action(function (...args) {
|
|
51
|
-
return commandAction(require('./../actions/armor/push')).apply(this, args)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
// dotenvx armor pull
|
|
55
|
-
armor
|
|
56
|
-
.command('pull')
|
|
57
|
-
.description('pull armored key (into .env.keys)')
|
|
58
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
59
|
-
.option('--token <token>', 'set token')
|
|
60
|
-
.option('--team <team>', 'team to pull armored private key from')
|
|
61
|
-
.action(function (...args) {
|
|
62
|
-
return commandAction(require('./../actions/armor/pull')).apply(this, args)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// dotenvx armor open
|
|
66
|
-
armor
|
|
67
|
-
.command('open')
|
|
68
|
-
.description('open armored key (in browser)')
|
|
69
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
70
|
-
.action(function (...args) {
|
|
71
|
-
return commandAction(require('./../actions/armor/open')).apply(this, args)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
// dotenvx armor move
|
|
75
|
-
armor
|
|
76
|
-
.command('move')
|
|
77
|
-
.description('move armored key (to other team)')
|
|
78
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
79
|
-
.option('--token <token>', 'set token')
|
|
80
|
-
.action(function (...args) {
|
|
81
|
-
return commandAction(require('./../actions/armor/move')).apply(this, args)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
// dotenvx armor invite
|
|
85
|
-
armor
|
|
86
|
-
.command('invite')
|
|
87
|
-
.description('invite a member to your team')
|
|
88
|
-
.option('--team <team>', 'team to invite member to')
|
|
89
|
-
.option('--email <email>', 'email address to invite')
|
|
90
|
-
.option('--token <token>', 'set token')
|
|
91
|
-
.action(function (...args) {
|
|
92
|
-
return commandAction(require('./../actions/armor/invite')).apply(this, args)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
// dotenvx armor login
|
|
96
|
-
armor
|
|
97
|
-
.command('login')
|
|
98
|
-
.description('log in to Dotenvx Armor')
|
|
99
|
-
.allowUnknownOption()
|
|
100
|
-
.option('--hostname <hostname>', 'set Armor ⛨ hostname')
|
|
101
|
-
.action(function (...args) {
|
|
102
|
-
return commandAction(require('./../actions/login')).apply(this, args)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
// dotenvx armor logout
|
|
106
|
-
armor
|
|
107
|
-
.command('logout')
|
|
108
|
-
.description('log out of Dotenvx Armor')
|
|
109
|
-
.allowUnknownOption()
|
|
110
|
-
.option('--hostname <hostname>', 'set Armor ⛨ hostname')
|
|
111
|
-
.action(function (...args) {
|
|
112
|
-
return commandAction(require('./../actions/logout')).apply(this, args)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
// dotenvx armor status
|
|
116
|
-
armor
|
|
117
|
-
.command('status')
|
|
118
|
-
.description('print armor status')
|
|
119
|
-
.action(function (...args) {
|
|
120
|
-
return commandAction(require('./../actions/armor/status')).apply(this, args)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
// dotenvx armor settings
|
|
124
|
-
require('./settings')(armor.command('settings'))
|
|
125
|
-
|
|
126
|
-
return armor
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = configureArmorCommand
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const commandAction = require('../commandAction')
|
|
2
|
-
|
|
3
|
-
function configureCustodyCommand (command, name, custodianId) {
|
|
4
|
-
command.hook('preAction', async () => {
|
|
5
|
-
const Session = require('../../db/session')
|
|
6
|
-
await new Session().notifyUpdate()
|
|
7
|
-
})
|
|
8
|
-
command.description(`move private keys in/out of ${name}`).action(function () { this.help() })
|
|
9
|
-
const descriptions = {
|
|
10
|
-
up: `move key from .env.keys into ${name}`,
|
|
11
|
-
down: `move key from ${name} to .env.keys`,
|
|
12
|
-
push: `copy key from .env.keys into ${name}`,
|
|
13
|
-
pull: `copy key from ${name} into .env.keys`
|
|
14
|
-
}
|
|
15
|
-
for (const [operation, description] of Object.entries(descriptions)) {
|
|
16
|
-
command.command(operation)
|
|
17
|
-
.description(description)
|
|
18
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
19
|
-
.option('-fk, --env-keys-file <path>', 'path to your .env.keys file', '.env.keys')
|
|
20
|
-
.action(commandAction(async function () {
|
|
21
|
-
const { logger } = require('../../shared/logger')
|
|
22
|
-
const createSpinner = require('../../lib/helpers/createSpinner')
|
|
23
|
-
const armoredKeyDisplay = require('../../lib/helpers/armoredKeyDisplay')
|
|
24
|
-
const transfer = require('../../lib/services/custodyTransfer')
|
|
25
|
-
const options = this.opts()
|
|
26
|
-
const spinner = await createSpinner({ ...this.optsWithGlobals(), text: `${operation === 'up' || operation === 'push' ? 'storing in' : 'reading from'} ${name}` })
|
|
27
|
-
try {
|
|
28
|
-
const result = await transfer(require('../../lib/custodians').get(custodianId), name, operation, options.envFile, options.envKeysFile)
|
|
29
|
-
if (spinner) spinner.stop()
|
|
30
|
-
const display = armoredKeyDisplay(result.publicKeyValue) || result.privateKeyName
|
|
31
|
-
const messages = { up: `stored in ${name}`, down: `moved to ${options.envKeysFile}`, push: `pushed to ${name}`, pull: `pulled to ${options.envKeysFile}` }
|
|
32
|
-
if (result.changed) logger.success(`□ ${messages[operation]} (${display})`)
|
|
33
|
-
else logger.info(`○ no change (${display})`)
|
|
34
|
-
} catch (error) {
|
|
35
|
-
if (spinner) spinner.stop()
|
|
36
|
-
if (error.code === 'PROMPT_CANCELLED') return { exitCode: 130, error }
|
|
37
|
-
logger.error(error.message)
|
|
38
|
-
return { exitCode: 1, error }
|
|
39
|
-
}
|
|
40
|
-
}))
|
|
41
|
-
}
|
|
42
|
-
return command
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = configureCustodyCommand
|
package/src/cli/commands/ext.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const commandAction = require('../commandAction')
|
|
2
|
-
const { Command } = require('@dotenvx/tooling')
|
|
3
|
-
|
|
4
|
-
const help = require('./../help')
|
|
5
|
-
const executeExtension = require('../../lib/helpers/executeExtension')
|
|
6
|
-
const removeDynamicHelpSection = require('../../lib/helpers/removeDynamicHelpSection')
|
|
7
|
-
|
|
8
|
-
const ext = new Command('ext')
|
|
9
|
-
|
|
10
|
-
ext
|
|
11
|
-
.description('🔌 extensions')
|
|
12
|
-
.allowUnknownOption()
|
|
13
|
-
|
|
14
|
-
ext
|
|
15
|
-
.argument('[command]', 'dynamic ext command')
|
|
16
|
-
.argument('[args...]', 'dynamic ext command arguments')
|
|
17
|
-
.action((command, args, cmdObj) => {
|
|
18
|
-
const rawArgs = process.argv.slice(3) // adjust the index based on where actual args start
|
|
19
|
-
executeExtension(ext, command, rawArgs)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
// dotenvx ext ls
|
|
23
|
-
ext.command('ls')
|
|
24
|
-
.description('print all .env files in a tree structure')
|
|
25
|
-
.argument('[directory]', 'directory to list .env files from', '.')
|
|
26
|
-
.option('-f, --env-file <filenames...>', 'path(s) to your env file(s)', '.env*')
|
|
27
|
-
.option('-ef, --exclude-env-file <excludeFilenames...>', 'path(s) to exclude from your env file(s) (default: none)')
|
|
28
|
-
.option('--json', 'output a JSON array of absolute filepaths')
|
|
29
|
-
.action(function (...args) {
|
|
30
|
-
return commandAction(require('./../actions/ls')).apply(this, args)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// dotenvx ext genexample
|
|
34
|
-
ext.command('genexample')
|
|
35
|
-
.description('generate .env.example')
|
|
36
|
-
.argument('[directory]', 'directory to generate from', '.')
|
|
37
|
-
.option('-f, --env-file <paths...>', 'path(s) to your env file(s)', '.env')
|
|
38
|
-
.action(function (...args) {
|
|
39
|
-
return commandAction(require('./../actions/ext/genexample')).apply(this, args)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
// dotenvx ext gitignore
|
|
43
|
-
ext.command('gitignore')
|
|
44
|
-
.description('append to .gitignore')
|
|
45
|
-
.addHelpText('after', help.gitignore)
|
|
46
|
-
.option('--pattern <patterns...>', 'pattern(s) to gitignore', ['.env*'])
|
|
47
|
-
.action(function (...args) {
|
|
48
|
-
return require('./../actions/ext/gitignore').apply(this, args)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
// dotenvx ext prebuild
|
|
52
|
-
ext.command('prebuild')
|
|
53
|
-
.description('deprecated. use [dotenvx protect --docker]')
|
|
54
|
-
.addHelpText('after', help.prebuild)
|
|
55
|
-
.argument('[directory]', 'directory to prevent including .env files from', '.')
|
|
56
|
-
.action(function (...args) {
|
|
57
|
-
return require('./../actions/ext/prebuild').apply(this, args)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
// dotenvx ext precommit
|
|
61
|
-
ext.command('precommit')
|
|
62
|
-
.description('prevent committing .env files to code')
|
|
63
|
-
.addHelpText('after', help.precommit)
|
|
64
|
-
.argument('[directory]', 'directory to prevent committing .env files from', '.')
|
|
65
|
-
.option('-i, --install', 'install a pre-commit hook')
|
|
66
|
-
.option('--uninstall', 'remove the dotenvx pre-commit hook')
|
|
67
|
-
.action(function (...args) {
|
|
68
|
-
return require('./../actions/ext/precommit').apply(this, args)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
// dotenvx ext scan
|
|
72
|
-
ext.command('scan')
|
|
73
|
-
.description('scan for leaked secrets')
|
|
74
|
-
.action(function (...args) {
|
|
75
|
-
return commandAction(require('./../actions/ext/scan')).apply(this, args)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
// override helpInformation to hide dynamic commands
|
|
79
|
-
ext.helpInformation = function () {
|
|
80
|
-
const originalHelp = Command.prototype.helpInformation.call(this)
|
|
81
|
-
const lines = originalHelp.split('\n')
|
|
82
|
-
|
|
83
|
-
removeDynamicHelpSection(lines)
|
|
84
|
-
|
|
85
|
-
return lines.join('\n')
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
module.exports = ext
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Keep the existing envFile option attribute and parsing behavior for both
|
|
2
|
-
// spellings, including mixed repeated flags. Only --file is advertised.
|
|
3
|
-
function configureFileOptions (command) {
|
|
4
|
-
const legacy = command.options.find(option => option.long === '--env-file')
|
|
5
|
-
if (legacy && !command.options.some(option => option.long === '--file')) {
|
|
6
|
-
const index = command.options.indexOf(legacy)
|
|
7
|
-
const visible = command.createOption(legacy.flags.replace('--env-file', '--file'), legacy.description)
|
|
8
|
-
visible.attributeName = () => legacy.attributeName()
|
|
9
|
-
if (legacy.parseArg) visible.argParser(legacy.parseArg)
|
|
10
|
-
if (legacy.defaultValue !== undefined) visible.default(legacy.defaultValue, legacy.defaultValueDescription)
|
|
11
|
-
legacy.short = undefined
|
|
12
|
-
legacy.flags = legacy.flags.replace(/^-f,?\s*/, '')
|
|
13
|
-
legacy.hideHelp()
|
|
14
|
-
command.addOption(visible)
|
|
15
|
-
command.options.pop()
|
|
16
|
-
command.options.splice(index, 0, visible)
|
|
17
|
-
}
|
|
18
|
-
for (const child of command.commands) configureFileOptions(child)
|
|
19
|
-
return command
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = configureFileOptions
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const commandAction = require('../commandAction')
|
|
2
|
-
function configureNativeCommand (native) {
|
|
3
|
-
native.hook('preAction', async () => {
|
|
4
|
-
const Session = require('./../../db/session')
|
|
5
|
-
const sesh = new Session()
|
|
6
|
-
await sesh.notifyUpdate()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
native
|
|
10
|
-
.description('move private keys in/out of your OS secret store')
|
|
11
|
-
.action(function () {
|
|
12
|
-
this.help()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
native
|
|
16
|
-
.command('up')
|
|
17
|
-
.description('store key in OS secret store')
|
|
18
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
19
|
-
.option('-fk, --env-keys-file <path>', 'path to your .env.keys file', '.env.keys')
|
|
20
|
-
.action(function (...args) {
|
|
21
|
-
return commandAction(require('./../actions/keychain/up')).apply(this, args)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
native
|
|
25
|
-
.command('down')
|
|
26
|
-
.description('move key from OS secret store to .env.keys')
|
|
27
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
28
|
-
.option('-fk, --env-keys-file <path>', 'path to your .env.keys file', '.env.keys')
|
|
29
|
-
.action(function (...args) {
|
|
30
|
-
return commandAction(require('./../actions/keychain/down')).apply(this, args)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
native
|
|
34
|
-
.command('push')
|
|
35
|
-
.description('push key to OS secret store from .env.keys')
|
|
36
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
37
|
-
.option('-fk, --env-keys-file <path>', 'path to your .env.keys file', '.env.keys')
|
|
38
|
-
.action(function (...args) {
|
|
39
|
-
return commandAction(require('./../actions/keychain/push')).apply(this, args)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
native
|
|
43
|
-
.command('pull')
|
|
44
|
-
.description('pull key from OS secret store into .env.keys')
|
|
45
|
-
.option('-f, --env-file <path>', 'path to your env file')
|
|
46
|
-
.option('-fk, --env-keys-file <path>', 'path to your .env.keys file', '.env.keys')
|
|
47
|
-
.action(function (...args) {
|
|
48
|
-
return commandAction(require('./../actions/keychain/pull')).apply(this, args)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
return native
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
module.exports = configureNativeCommand
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const { derive, keypair } = require('@dotenvx/primitives')
|
|
2
|
-
const commandAction = require('../commandAction')
|
|
3
|
-
const catchAndLog = require('../../lib/helpers/catchAndLog')
|
|
4
|
-
|
|
5
|
-
function output (operation, required = false) {
|
|
6
|
-
return commandAction(async function (privateKey) {
|
|
7
|
-
try {
|
|
8
|
-
if (this.opts().stdin) {
|
|
9
|
-
if (privateKey !== undefined) throw new Error('Cannot combine a private key argument with --stdin')
|
|
10
|
-
process.stdin.setEncoding('utf8')
|
|
11
|
-
let input = ''
|
|
12
|
-
for await (const chunk of process.stdin) input += chunk
|
|
13
|
-
privateKey = input.trim()
|
|
14
|
-
if (!privateKey) throw new Error('Expected a private key on stdin')
|
|
15
|
-
}
|
|
16
|
-
if (required && privateKey === undefined) throw new Error('Provide a private key argument or use --stdin')
|
|
17
|
-
if (privateKey !== undefined && (privateKey.length !== 64 || !/^[a-f0-9]{64}$/i.test(privateKey))) throw new Error('Expected one 64-character hex private key')
|
|
18
|
-
const result = operation(privateKey)
|
|
19
|
-
console.log(typeof result === 'string' ? result : JSON.stringify(result))
|
|
20
|
-
return { exitCode: 0 }
|
|
21
|
-
} catch (error) {
|
|
22
|
-
catchAndLog(error)
|
|
23
|
-
return { exitCode: 1 }
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = function primitives (command) {
|
|
29
|
-
command
|
|
30
|
-
.description('standalone primitive operations')
|
|
31
|
-
.action(function () { this.help() })
|
|
32
|
-
|
|
33
|
-
command.command('profile')
|
|
34
|
-
.description('resolve an Envfile profile to comma-separated filenames')
|
|
35
|
-
.option('--profile <name>', 'explicit profile name')
|
|
36
|
-
.option('-f, --file <paths>', 'explicit comma-separated files, overriding profile selection', (value, previous) => previous === undefined ? value : `${previous},${value}`)
|
|
37
|
-
.allowExcessArguments(false)
|
|
38
|
-
.action(commandAction(require('../actions/primitivesProfile')))
|
|
39
|
-
|
|
40
|
-
command.command('redact')
|
|
41
|
-
.description('replace secret strings in text with [REDACTED]')
|
|
42
|
-
.argument('[text]', 'text to redact')
|
|
43
|
-
.requiredOption('-s, --secret <value>', 'literal secret to redact (repeat for multiple secrets)', (value, previous) => [...(previous || []), value])
|
|
44
|
-
.option('--stdin', 'read text from stdin')
|
|
45
|
-
.allowExcessArguments(false)
|
|
46
|
-
.action(commandAction(require('../actions/primitivesRedact')))
|
|
47
|
-
|
|
48
|
-
command.command('policy')
|
|
49
|
-
.description('print the Envfile policy for selected files as JSON')
|
|
50
|
-
.option('-f, --file <paths>', 'comma-separated env files, first file wins (default: .env)', (value, previous) => previous === undefined ? value : `${previous},${value}`)
|
|
51
|
-
.allowExcessArguments(false)
|
|
52
|
-
.action(commandAction(require('../actions/policy')))
|
|
53
|
-
|
|
54
|
-
command.command('check')
|
|
55
|
-
.description('check selected env files against Envfile and print redacted JSON')
|
|
56
|
-
.option('-f, --file <paths>', 'comma-separated env files, first file wins (default: .env)', (value, previous) => previous === undefined ? value : `${previous},${value}`)
|
|
57
|
-
.allowExcessArguments(false)
|
|
58
|
-
.action(commandAction(require('../actions/primitivesCheck')))
|
|
59
|
-
|
|
60
|
-
command.command('keypair')
|
|
61
|
-
.description('generate or restore a keypair and print JSON')
|
|
62
|
-
.argument('[privateKey]', 'hex-encoded private key to restore')
|
|
63
|
-
.option('--stdin', 'read the private key from stdin')
|
|
64
|
-
.allowExcessArguments(false)
|
|
65
|
-
.action(output(keypair))
|
|
66
|
-
|
|
67
|
-
command.command('derive')
|
|
68
|
-
.description('derive and print a public key from a private key')
|
|
69
|
-
.argument('[privateKey]', 'hex-encoded private key')
|
|
70
|
-
.option('--stdin', 'read the private key from stdin')
|
|
71
|
-
.allowExcessArguments(false)
|
|
72
|
-
.action(output(derive, true))
|
|
73
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const commandAction = require('../commandAction')
|
|
2
|
-
function configureSettingsCommand (settings) {
|
|
3
|
-
settings
|
|
4
|
-
.description('settings')
|
|
5
|
-
.action(function () {
|
|
6
|
-
this.help()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
settings
|
|
10
|
-
.command('username')
|
|
11
|
-
.description('print your username')
|
|
12
|
-
.action(function (...args) {
|
|
13
|
-
return commandAction(require('./../actions/settings/username')).apply(this, args)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
settings
|
|
17
|
-
.command('token')
|
|
18
|
-
.description('print your access token (--unmask)')
|
|
19
|
-
.option('--unmask', 'unmask access token')
|
|
20
|
-
.action(function (...args) {
|
|
21
|
-
return commandAction(require('./../actions/settings/token')).apply(this, args)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
settings
|
|
25
|
-
.command('device')
|
|
26
|
-
.description('print your device pubkey (--unmask)')
|
|
27
|
-
.option('--unmask', 'unmask device pubkey')
|
|
28
|
-
.action(function (...args) {
|
|
29
|
-
return commandAction(require('./../actions/settings/device')).apply(this, args)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
settings
|
|
33
|
-
.command('hostname')
|
|
34
|
-
.description('print hostname')
|
|
35
|
-
.action(function (...args) {
|
|
36
|
-
return commandAction(require('./../actions/settings/hostname')).apply(this, args)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
settings
|
|
40
|
-
.command('path')
|
|
41
|
-
.description('print path to settings file')
|
|
42
|
-
.action(function (...args) {
|
|
43
|
-
return commandAction(require('./../actions/settings/path')).apply(this, args)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
settings
|
|
47
|
-
.command('on')
|
|
48
|
-
.description('turn armor on')
|
|
49
|
-
.action(function (...args) {
|
|
50
|
-
return commandAction(require('./../actions/settings/on')).apply(this, args)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
settings
|
|
54
|
-
.command('off')
|
|
55
|
-
.description('turn armor off')
|
|
56
|
-
.action(function (...args) {
|
|
57
|
-
return commandAction(require('./../actions/settings/off')).apply(this, args)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
return settings
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = configureSettingsCommand
|