@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,40 +0,0 @@
|
|
|
1
|
-
const FRAMES = ['◇', '⬖', '◆', '⬗']
|
|
2
|
-
const FRAME_INTERVAL_MS = 80
|
|
3
|
-
let activeSpinner
|
|
4
|
-
|
|
5
|
-
async function createSpinner (options = {}) {
|
|
6
|
-
const stream = process.stderr
|
|
7
|
-
const hasCursorControls = typeof stream.cursorTo === 'function' && typeof stream.clearLine === 'function'
|
|
8
|
-
const enabled = Boolean(stream.isTTY && hasCursorControls && options.spinner !== false && !options.quiet && !options.verbose && !options.debug)
|
|
9
|
-
if (!enabled) return null
|
|
10
|
-
|
|
11
|
-
const text = options.text || 'thinking'
|
|
12
|
-
const frames = options.frames || FRAMES
|
|
13
|
-
|
|
14
|
-
const { default: yoctoSpinner } = await import('yocto-spinner')
|
|
15
|
-
activeSpinner = yoctoSpinner({
|
|
16
|
-
text,
|
|
17
|
-
spinner: {
|
|
18
|
-
frames,
|
|
19
|
-
interval: FRAME_INTERVAL_MS
|
|
20
|
-
},
|
|
21
|
-
stream
|
|
22
|
-
}).start()
|
|
23
|
-
|
|
24
|
-
return activeSpinner
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
createSpinner.stop = function () {
|
|
28
|
-
if (activeSpinner) activeSpinner.stop()
|
|
29
|
-
activeSpinner = null
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
createSpinner.pause = function () {
|
|
33
|
-
if (activeSpinner) activeSpinner.stop()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
createSpinner.resume = function () {
|
|
37
|
-
if (activeSpinner) activeSpinner.start()
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = createSpinner
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const { decrypt } = require('@dotenvx/primitives')
|
|
2
|
-
|
|
3
|
-
const Errors = require('./../errors')
|
|
4
|
-
|
|
5
|
-
const PREFIX = 'encrypted:'
|
|
6
|
-
|
|
7
|
-
function primitiveMessage (error) {
|
|
8
|
-
return error.message.replace(/^\[[A-Z_]+\] /, '')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function decryptKeyValue (key, value, privateKeyName, privateKey) {
|
|
12
|
-
let decryptedValue
|
|
13
|
-
let decryptionError
|
|
14
|
-
|
|
15
|
-
if (!value.startsWith(PREFIX)) {
|
|
16
|
-
return value
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
privateKey = privateKey || ''
|
|
20
|
-
if (privateKey.length <= 0) {
|
|
21
|
-
decryptionError = new Errors({ key, privateKeyName, privateKey }).missingPrivateKey()
|
|
22
|
-
} else {
|
|
23
|
-
const privateKeys = privateKey.split(',')
|
|
24
|
-
for (const privKey of privateKeys) {
|
|
25
|
-
try {
|
|
26
|
-
decryptedValue = decrypt(privKey, value)
|
|
27
|
-
decryptionError = null // reset to null error (scenario for multiple private keys)
|
|
28
|
-
break
|
|
29
|
-
} catch (e) {
|
|
30
|
-
if (e.code === 'INVALID_PRIVATE_KEY') {
|
|
31
|
-
decryptionError = new Errors({ key, privateKeyName, privateKey }).invalidPrivateKey()
|
|
32
|
-
} else if (e.code === 'WRONG_PRIVATE_KEY') {
|
|
33
|
-
decryptionError = new Errors({ key, privateKeyName, privateKey }).wrongPrivateKey()
|
|
34
|
-
} else if (e.code === 'MALFORMED_ENCRYPTED_DATA' || primitiveMessage(e).startsWith('bad point:')) {
|
|
35
|
-
decryptionError = new Errors({ key, privateKeyName, privateKey }).malformedEncryptedData()
|
|
36
|
-
} else {
|
|
37
|
-
decryptionError = new Errors({ key, privateKeyName, privateKey, message: primitiveMessage(e) }).decryptionFailed()
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (decryptionError) {
|
|
44
|
-
throw decryptionError
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return decryptedValue
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
module.exports = decryptKeyValue
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const FIRST_TIME_KEYS_SRC = [
|
|
2
|
-
'#/------------------!DOTENV_PRIVATE_KEYS!-------------------/',
|
|
3
|
-
'#/ private decryption keys. DO NOT commit to source control /',
|
|
4
|
-
'#/ [how it works](https://dotenvx.com/encryption) /',
|
|
5
|
-
'#/ ⛨ ARMORED KEYS: `dotenvx armor up` /',
|
|
6
|
-
'#/----------------------------------------------------------/'
|
|
7
|
-
].join('\n')
|
|
8
|
-
|
|
9
|
-
function mutateKeysSrc ({ keysSrc, privateKeyName, privateKeyValue, comment }) {
|
|
10
|
-
const appendPrivateKey = [`# ${comment}`, `${privateKeyName}=${privateKeyValue}`, ''].join('\n')
|
|
11
|
-
|
|
12
|
-
if (!keysSrc || keysSrc.length < 1) {
|
|
13
|
-
keysSrc = `${FIRST_TIME_KEYS_SRC}\n`
|
|
14
|
-
}
|
|
15
|
-
keysSrc = `${keysSrc}\n${appendPrivateKey}`
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
keysSrc
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = mutateKeysSrc
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const preserveShebang = require('./../preserveShebang')
|
|
3
|
-
const prependPublicKey = require('./../prependPublicKey')
|
|
4
|
-
|
|
5
|
-
function mutateSrc ({ envSrc, envFilepath, keysFilepath, publicKeyName, publicKeyValue }) {
|
|
6
|
-
const filename = path.basename(envFilepath)
|
|
7
|
-
const filepath = path.resolve(envFilepath)
|
|
8
|
-
let resolvedKeysFilepath = path.join(path.dirname(filepath), '.env.keys')
|
|
9
|
-
if (keysFilepath) {
|
|
10
|
-
resolvedKeysFilepath = path.resolve(keysFilepath)
|
|
11
|
-
}
|
|
12
|
-
const relativeFilepath = path.relative(path.dirname(filepath), resolvedKeysFilepath)
|
|
13
|
-
|
|
14
|
-
const ps = preserveShebang(envSrc)
|
|
15
|
-
const prependedPublicKey = prependPublicKey(publicKeyName, publicKeyValue, filename, relativeFilepath)
|
|
16
|
-
|
|
17
|
-
envSrc = `${ps.firstLinePreserved}${prependedPublicKey}\n${ps.envSrc}`
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
envSrc
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = mutateSrc
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const { Enquirer } = require('@dotenvx/tooling')
|
|
2
|
-
|
|
3
|
-
class CustodySelect extends Enquirer.prompts.Select {
|
|
4
|
-
keypress (input, key = {}) {
|
|
5
|
-
if (key.name === 'escape') return this.cancel(new Error('Cancelled'))
|
|
6
|
-
if (key.name === 'left' && this.options.backValue) {
|
|
7
|
-
this.index = this.choices.findIndex(choice => choice.name === this.options.backValue)
|
|
8
|
-
return this.submit()
|
|
9
|
-
}
|
|
10
|
-
return super.keypress(input, key)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async render () {
|
|
14
|
-
// Replace the previous step instead of leaving a trail of completed menus.
|
|
15
|
-
if (this.state.submitted) {
|
|
16
|
-
this.clear(this.state.size)
|
|
17
|
-
this.state.prompt = ''
|
|
18
|
-
this.state.size = 0
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
return super.render()
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = CustodySelect
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
|
|
3
|
-
async function detectEncoding (filepath) {
|
|
4
|
-
const buffer = await fs.promises.readFile(filepath)
|
|
5
|
-
|
|
6
|
-
// check for UTF-16LE BOM (Byte Order Mark)
|
|
7
|
-
if (buffer.length >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
|
8
|
-
return 'utf16le'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* c8 ignore start */
|
|
12
|
-
// check for UTF-8 BOM
|
|
13
|
-
if (buffer.length >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
|
14
|
-
return 'utf8'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* c8 ignore stop */
|
|
18
|
-
|
|
19
|
-
return 'utf8'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = detectEncoding
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
|
|
3
|
-
function detectEncodingSync (filepath) {
|
|
4
|
-
const buffer = fs.readFileSync(filepath)
|
|
5
|
-
|
|
6
|
-
// check for UTF-16LE BOM (Byte Order Mark)
|
|
7
|
-
if (buffer.length >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
|
8
|
-
return 'utf16le'
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* c8 ignore start */
|
|
12
|
-
// check for UTF-8 BOM
|
|
13
|
-
if (buffer.length >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
|
14
|
-
return 'utf8'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* c8 ignore stop */
|
|
18
|
-
|
|
19
|
-
return 'utf8'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = detectEncodingSync
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const resolveHome = require('./resolveHome')
|
|
2
|
-
|
|
3
|
-
function dotenvOptionPaths (options) {
|
|
4
|
-
let optionPaths = []
|
|
5
|
-
|
|
6
|
-
if (options && options.path) {
|
|
7
|
-
if (!Array.isArray(options.path)) {
|
|
8
|
-
if (typeof options.path === 'string') {
|
|
9
|
-
optionPaths = options.path.split(',').map(filepath => filepath.trim()).filter(Boolean).map(resolveHome)
|
|
10
|
-
} else {
|
|
11
|
-
optionPaths = [resolveHome(options.path)]
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
optionPaths = [] // reset default
|
|
15
|
-
|
|
16
|
-
for (const filepath of options.path) {
|
|
17
|
-
optionPaths.push(resolveHome(filepath))
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return optionPaths
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = dotenvOptionPaths
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const escape = require('./escape')
|
|
2
|
-
|
|
3
|
-
function enclavedHint (error, envFilepath) {
|
|
4
|
-
if (error?.code !== 'ENCLAVED' || !envFilepath) return error
|
|
5
|
-
const file = /^[a-zA-Z0-9_./-]+$/.test(envFilepath) ? envFilepath : escape(envFilepath)
|
|
6
|
-
error.help = `hint: [dotenvx armor open -f ${file}]`
|
|
7
|
-
error.messageWithHelp = `${error.message}. ${error.help}`
|
|
8
|
-
return error
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = enclavedHint
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const dotenvPrivateKeyNames = require('./../dotenvPrivateKeyNames')
|
|
2
|
-
const guessPrivateKeyFilename = require('./../guessPrivateKeyFilename')
|
|
3
|
-
|
|
4
|
-
const TYPE_ENV_FILE = 'envFile'
|
|
5
|
-
const DEFAULT_ENVS = [{ type: TYPE_ENV_FILE, value: '.env' }]
|
|
6
|
-
|
|
7
|
-
function envsFromDotenvPrivateKey (privateKeyNames) {
|
|
8
|
-
const envs = []
|
|
9
|
-
|
|
10
|
-
for (const privateKeyName of privateKeyNames) {
|
|
11
|
-
const filename = guessPrivateKeyFilename(privateKeyName)
|
|
12
|
-
envs.push({ type: TYPE_ENV_FILE, value: filename })
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return envs
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function determine (envs = [], processEnv) {
|
|
19
|
-
const privateKeyNames = dotenvPrivateKeyNames(processEnv)
|
|
20
|
-
|
|
21
|
-
// https://github.com/dotenvx/dotenvx/issues/670
|
|
22
|
-
let defaults = DEFAULT_ENVS // default to .env file expectation
|
|
23
|
-
// if process.env.DOTENV_PRIVATE_KEY or process.env.DOTENV_PRIVATE_KEY_${environment} is set, assume inline encryption methodology
|
|
24
|
-
if (privateKeyNames.length > 0) {
|
|
25
|
-
defaults = envsFromDotenvPrivateKey(privateKeyNames)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!envs || envs.length <= 0) {
|
|
29
|
-
return defaults
|
|
30
|
-
} else {
|
|
31
|
-
let fileAlreadySpecified = false
|
|
32
|
-
|
|
33
|
-
for (const env of envs) {
|
|
34
|
-
if (env.type === TYPE_ENV_FILE) {
|
|
35
|
-
fileAlreadySpecified = true
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// return early since envs array objects already contain 1 .env file
|
|
40
|
-
if (fileAlreadySpecified) {
|
|
41
|
-
return envs
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// no .env file specified as a flag so default to .env
|
|
45
|
-
return [...defaults, ...envs]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
module.exports = determine
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
buildEnvs: require('./../buildEnvs'),
|
|
3
|
-
determine: require('./determine'),
|
|
4
|
-
findEnvFiles: require('./../findEnvFiles'),
|
|
5
|
-
dotenvOptionPaths: require('./../dotenvOptionPaths'),
|
|
6
|
-
environment: require('./../../conventions/environment'),
|
|
7
|
-
conventions: require('./../conventions')
|
|
8
|
-
}
|