@dotenvx/dotenvx 2.38.1 → 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.
Files changed (271) hide show
  1. package/README.md +186 -3315
  2. package/bin/dotenvx.cjs +34 -0
  3. package/config.cjs +1 -0
  4. package/config.d.ts +1 -0
  5. package/config.mjs +2 -0
  6. package/index.cjs +139 -0
  7. package/index.d.ts +66 -0
  8. package/index.mjs +3 -0
  9. package/lib/cli.cjs +43 -0
  10. package/lib/native-package.cjs +21 -0
  11. package/lib/platforms.cjs +18 -0
  12. package/{src/lib/helpers/redactOutput.js → lib/redactOutput.cjs} +2 -48
  13. package/lib/redaction.cjs +64 -0
  14. package/lib/validateOptions.cjs +57 -0
  15. package/native.cjs +23 -0
  16. package/package.json +57 -65
  17. package/CHANGELOG.md +0 -2727
  18. package/src/cli/actions/armor/down.js +0 -38
  19. package/src/cli/actions/armor/invite.js +0 -21
  20. package/src/cli/actions/armor/move.js +0 -43
  21. package/src/cli/actions/armor/open.js +0 -28
  22. package/src/cli/actions/armor/pull.js +0 -38
  23. package/src/cli/actions/armor/push.js +0 -38
  24. package/src/cli/actions/armor/status.js +0 -7
  25. package/src/cli/actions/armor/up.js +0 -38
  26. package/src/cli/actions/check.js +0 -78
  27. package/src/cli/actions/curl.js +0 -71
  28. package/src/cli/actions/decrypt.js +0 -119
  29. package/src/cli/actions/del.js +0 -54
  30. package/src/cli/actions/doctor.js +0 -22
  31. package/src/cli/actions/encrypt.js +0 -104
  32. package/src/cli/actions/ext/genexample.js +0 -36
  33. package/src/cli/actions/ext/gitignore.js +0 -106
  34. package/src/cli/actions/ext/prebuild.js +0 -7
  35. package/src/cli/actions/ext/precommit.js +0 -38
  36. package/src/cli/actions/ext/scan.js +0 -33
  37. package/src/cli/actions/feedback.js +0 -42
  38. package/src/cli/actions/get.js +0 -128
  39. package/src/cli/actions/init.js +0 -67
  40. package/src/cli/actions/keychain/down.js +0 -30
  41. package/src/cli/actions/keychain/pull.js +0 -30
  42. package/src/cli/actions/keychain/push.js +0 -30
  43. package/src/cli/actions/keychain/up.js +0 -30
  44. package/src/cli/actions/keypair.js +0 -84
  45. package/src/cli/actions/login.js +0 -64
  46. package/src/cli/actions/logout.js +0 -37
  47. package/src/cli/actions/ls.js +0 -76
  48. package/src/cli/actions/policy.js +0 -14
  49. package/src/cli/actions/primitivesCheck.js +0 -32
  50. package/src/cli/actions/primitivesProfile.js +0 -15
  51. package/src/cli/actions/primitivesRedact.js +0 -19
  52. package/src/cli/actions/protect.js +0 -75
  53. package/src/cli/actions/protectDocker.js +0 -30
  54. package/src/cli/actions/protectProcess.js +0 -126
  55. package/src/cli/actions/protectStdin.js +0 -80
  56. package/src/cli/actions/run.js +0 -203
  57. package/src/cli/actions/set.js +0 -103
  58. package/src/cli/actions/settings/device.js +0 -23
  59. package/src/cli/actions/settings/hostname.js +0 -20
  60. package/src/cli/actions/settings/off.js +0 -14
  61. package/src/cli/actions/settings/on.js +0 -14
  62. package/src/cli/actions/settings/path.js +0 -20
  63. package/src/cli/actions/settings/token.js +0 -23
  64. package/src/cli/actions/settings/username.js +0 -20
  65. package/src/cli/actions/update.js +0 -15
  66. package/src/cli/commandAction.js +0 -16
  67. package/src/cli/commands/armor.js +0 -129
  68. package/src/cli/commands/custody.js +0 -45
  69. package/src/cli/commands/ext.js +0 -88
  70. package/src/cli/commands/fileOptions.js +0 -22
  71. package/src/cli/commands/native.js +0 -54
  72. package/src/cli/commands/primitives.js +0 -73
  73. package/src/cli/commands/settings.js +0 -63
  74. package/src/cli/dotenvx.js +0 -443
  75. package/src/cli/help.js +0 -179
  76. package/src/db/device.js +0 -67
  77. package/src/db/session.js +0 -330
  78. package/src/lib/api/getAccount.js +0 -32
  79. package/src/lib/api/getConnectionResources.js +0 -21
  80. package/src/lib/api/getTeamConnections.js +0 -27
  81. package/src/lib/api/getTeamServices.js +0 -23
  82. package/src/lib/api/getTeams.js +0 -28
  83. package/src/lib/api/postArmorDown.js +0 -48
  84. package/src/lib/api/postArmorMove.js +0 -48
  85. package/src/lib/api/postArmorPull.js +0 -48
  86. package/src/lib/api/postArmorPush.js +0 -48
  87. package/src/lib/api/postArmorUp.js +0 -53
  88. package/src/lib/api/postConnectionKeypair.js +0 -23
  89. package/src/lib/api/postFeedback.js +0 -31
  90. package/src/lib/api/postLogout.js +0 -34
  91. package/src/lib/api/postOauthDeviceCode.js +0 -38
  92. package/src/lib/api/postOauthToken.js +0 -35
  93. package/src/lib/api/postTeamInvitation.js +0 -28
  94. package/src/lib/api/teamConnectionSetup.js +0 -31
  95. package/src/lib/config.d.ts +0 -1
  96. package/src/lib/config.js +0 -1
  97. package/src/lib/conventions/environment.js +0 -27
  98. package/src/lib/conventions/filepaths.js +0 -9
  99. package/src/lib/conventions/keynames.js +0 -38
  100. package/src/lib/custodians/index.js +0 -75
  101. package/src/lib/custodians/local/bitwarden.js +0 -165
  102. package/src/lib/custodians/local/file.js +0 -18
  103. package/src/lib/custodians/local/native/backend.js +0 -56
  104. package/src/lib/custodians/local/native/index.js +0 -28
  105. package/src/lib/custodians/local/native/store.js +0 -24
  106. package/src/lib/custodians/local/onepassword.js +0 -149
  107. package/src/lib/custodians/managed/armor/index.js +0 -14
  108. package/src/lib/custodians/managed/armor/store.js +0 -48
  109. package/src/lib/custodians/resolveLocalKey.js +0 -67
  110. package/src/lib/decryptors/armor/index.js +0 -23
  111. package/src/lib/decryptors/decryptor-worker.js +0 -6
  112. package/src/lib/decryptors/index.js +0 -69
  113. package/src/lib/envfile/discovery/discoverEnvFiles.js +0 -29
  114. package/src/lib/envfile/discovery/extractEnvKeys.js +0 -173
  115. package/src/lib/envfile/discovery/scanSource.js +0 -79
  116. package/src/lib/envfile/parsing/formatEnvfileSyntaxError.js +0 -24
  117. package/src/lib/envfile/parsing/readEnvfile.js +0 -43
  118. package/src/lib/envfile/parsing/resolveEnvfilePath.js +0 -5
  119. package/src/lib/envfile/rendering/normalizeEnvfile.js +0 -53
  120. package/src/lib/envfile/rendering/previewEnvfile.js +0 -43
  121. package/src/lib/envfile/rendering/renderEnvfile.js +0 -30
  122. package/src/lib/envfile/validation/diagnosticLocation.js +0 -29
  123. package/src/lib/envfile/validation/protectEnvfile.js +0 -40
  124. package/src/lib/envfile/validation/validateEnvfile.js +0 -14
  125. package/src/lib/events/backends/armor.js +0 -31
  126. package/src/lib/events/background.js +0 -59
  127. package/src/lib/events/catalog.js +0 -14
  128. package/src/lib/events/cli.js +0 -40
  129. package/src/lib/events/delivery.js +0 -89
  130. package/src/lib/events/index.js +0 -73
  131. package/src/lib/events/metadata.js +0 -25
  132. package/src/lib/events/sdk.js +0 -44
  133. package/src/lib/events/worker.js +0 -29
  134. package/src/lib/events/workerEnvironment.js +0 -14
  135. package/src/lib/helpers/armoredKeyDisplay.js +0 -10
  136. package/src/lib/helpers/arrayToTree.js +0 -27
  137. package/src/lib/helpers/buildApiError.js +0 -19
  138. package/src/lib/helpers/buildCommandEnvs.js +0 -40
  139. package/src/lib/helpers/buildConfigEnvs.js +0 -13
  140. package/src/lib/helpers/buildEnvs.js +0 -24
  141. package/src/lib/helpers/buildOauthError.js +0 -14
  142. package/src/lib/helpers/canonicalEnvFilename.js +0 -13
  143. package/src/lib/helpers/catchAndLog.js +0 -16
  144. package/src/lib/helpers/checklist.js +0 -50
  145. package/src/lib/helpers/chomp.js +0 -5
  146. package/src/lib/helpers/colorDepth.js +0 -23
  147. package/src/lib/helpers/conventions.js +0 -28
  148. package/src/lib/helpers/createElapsedStatus.js +0 -17
  149. package/src/lib/helpers/createProtectSpinner.js +0 -13
  150. package/src/lib/helpers/createSpinner.js +0 -40
  151. package/src/lib/helpers/cryptography/decryptKeyValue.js +0 -50
  152. package/src/lib/helpers/cryptography/index.js +0 -7
  153. package/src/lib/helpers/cryptography/isDotenvPublicKey.js +0 -7
  154. package/src/lib/helpers/cryptography/isPlainKey.js +0 -7
  155. package/src/lib/helpers/cryptography/mutateKeysSrc.js +0 -22
  156. package/src/lib/helpers/cryptography/mutateSrc.js +0 -24
  157. package/src/lib/helpers/custodySelect.js +0 -25
  158. package/src/lib/helpers/decryptDeviceValue.js +0 -7
  159. package/src/lib/helpers/detectEncoding.js +0 -22
  160. package/src/lib/helpers/detectEncodingSync.js +0 -22
  161. package/src/lib/helpers/dotenvOptionPaths.js +0 -25
  162. package/src/lib/helpers/dotenvPrivateKeyNames.js +0 -7
  163. package/src/lib/helpers/enclavedHint.js +0 -11
  164. package/src/lib/helpers/encryptDeviceValue.js +0 -7
  165. package/src/lib/helpers/envResolution/determine.js +0 -49
  166. package/src/lib/helpers/envResolution/index.js +0 -8
  167. package/src/lib/helpers/errors.js +0 -374
  168. package/src/lib/helpers/escape.js +0 -6
  169. package/src/lib/helpers/execute.js +0 -12
  170. package/src/lib/helpers/executeCommand.js +0 -208
  171. package/src/lib/helpers/executeDynamic.js +0 -86
  172. package/src/lib/helpers/executeExtension.js +0 -39
  173. package/src/lib/helpers/filterKeys.js +0 -15
  174. package/src/lib/helpers/findEnvFiles.js +0 -25
  175. package/src/lib/helpers/formatCode.js +0 -11
  176. package/src/lib/helpers/fsx.js +0 -110
  177. package/src/lib/helpers/guessPrivateKeyFilename.js +0 -15
  178. package/src/lib/helpers/hasPlaintextSecrets.js +0 -7
  179. package/src/lib/helpers/http.js +0 -14
  180. package/src/lib/helpers/installPrecommitHook.js +0 -82
  181. package/src/lib/helpers/installProtectFilter.js +0 -57
  182. package/src/lib/helpers/installProtectIgnore.js +0 -27
  183. package/src/lib/helpers/isPublicKey.js +0 -3
  184. package/src/lib/helpers/isTeamRequiredError.js +0 -10
  185. package/src/lib/helpers/jsonToEnv.js +0 -7
  186. package/src/lib/helpers/keypairMetadata.js +0 -90
  187. package/src/lib/helpers/kits/sample.js +0 -5
  188. package/src/lib/helpers/linuxSecretService.js +0 -52
  189. package/src/lib/helpers/listenForOpenKey.js +0 -46
  190. package/src/lib/helpers/logProtectedFiles.js +0 -9
  191. package/src/lib/helpers/logSetSummary.js +0 -21
  192. package/src/lib/helpers/macosKeychain.js +0 -52
  193. package/src/lib/helpers/mask.js +0 -22
  194. package/src/lib/helpers/maskEnvSrc.js +0 -15
  195. package/src/lib/helpers/maskProcessedEnvs.js +0 -29
  196. package/src/lib/helpers/matchesStoredKey.js +0 -5
  197. package/src/lib/helpers/nativeStoreError.js +0 -10
  198. package/src/lib/helpers/normalizeDotenvConfigConvention.js +0 -13
  199. package/src/lib/helpers/normalizeDotenvConfigIgnore.js +0 -18
  200. package/src/lib/helpers/normalizeDotenvConfigPath.js +0 -14
  201. package/src/lib/helpers/normalizeDotenvConfigQuiet.js +0 -13
  202. package/src/lib/helpers/normalizeToken.js +0 -5
  203. package/src/lib/helpers/openUrl.js +0 -7
  204. package/src/lib/helpers/packageJson.js +0 -3
  205. package/src/lib/helpers/parseWithDecryptor.js +0 -115
  206. package/src/lib/helpers/plaintextKeys.js +0 -9
  207. package/src/lib/helpers/precommitEnvPatterns.js +0 -1
  208. package/src/lib/helpers/prependPublicKey.js +0 -17
  209. package/src/lib/helpers/preserveShebang.js +0 -16
  210. package/src/lib/helpers/prompts.js +0 -169
  211. package/src/lib/helpers/protectSettings.js +0 -64
  212. package/src/lib/helpers/ptyCommand.js +0 -27
  213. package/src/lib/helpers/readEnvKey.js +0 -32
  214. package/src/lib/helpers/redact.js +0 -9
  215. package/src/lib/helpers/redactProcessOutput.js +0 -58
  216. package/src/lib/helpers/redactedValues.js +0 -29
  217. package/src/lib/helpers/removeDynamicHelpSection.js +0 -21
  218. package/src/lib/helpers/removeEnvKey.js +0 -51
  219. package/src/lib/helpers/removeLegacyProtectFilter.js +0 -43
  220. package/src/lib/helpers/removeOptionsHelpParts.js +0 -59
  221. package/src/lib/helpers/resolveBitwardenPassword.js +0 -165
  222. package/src/lib/helpers/resolveDirectoryFilepath.js +0 -16
  223. package/src/lib/helpers/resolveEnvKeysFile.js +0 -11
  224. package/src/lib/helpers/resolveHome.js +0 -12
  225. package/src/lib/helpers/resolveOnePassword.js +0 -82
  226. package/src/lib/helpers/sanitizeCommandForMetadata.js +0 -64
  227. package/src/lib/helpers/selectConnection.js +0 -51
  228. package/src/lib/helpers/selectConnectionResource.js +0 -41
  229. package/src/lib/helpers/selectEnvfileEnvs.js +0 -29
  230. package/src/lib/helpers/selectKeyStorage.js +0 -140
  231. package/src/lib/helpers/statusReporter.js +0 -8
  232. package/src/lib/helpers/storeKeyStorage.js +0 -39
  233. package/src/lib/helpers/teamChoicesFromMeta.js +0 -8
  234. package/src/lib/helpers/truncate.js +0 -10
  235. package/src/lib/helpers/uninstallPrecommitHook.js +0 -67
  236. package/src/lib/helpers/upsertEnvKey.js +0 -62
  237. package/src/lib/helpers/windowsCredentialManager.js +0 -166
  238. package/src/lib/main.d.ts +0 -509
  239. package/src/lib/main.js +0 -468
  240. package/src/lib/providers/index.js +0 -86
  241. package/src/lib/providers/native/index.js +0 -2
  242. package/src/lib/resolvers/envs.js +0 -416
  243. package/src/lib/resolvers/get.js +0 -87
  244. package/src/lib/resolvers/keypair.js +0 -135
  245. package/src/lib/resolvers/ls.js +0 -69
  246. package/src/lib/services/armorDown.js +0 -73
  247. package/src/lib/services/armorInvite.js +0 -36
  248. package/src/lib/services/armorMove.js +0 -55
  249. package/src/lib/services/armorOpen.js +0 -26
  250. package/src/lib/services/armorPull.js +0 -73
  251. package/src/lib/services/armorPush.js +0 -66
  252. package/src/lib/services/armorUp.js +0 -71
  253. package/src/lib/services/custodyTransfer.js +0 -50
  254. package/src/lib/services/doctor.js +0 -93
  255. package/src/lib/services/genexample.js +0 -112
  256. package/src/lib/services/init.js +0 -83
  257. package/src/lib/services/keychainDown.js +0 -60
  258. package/src/lib/services/keychainPull.js +0 -46
  259. package/src/lib/services/keychainPush.js +0 -51
  260. package/src/lib/services/keychainUp.js +0 -72
  261. package/src/lib/services/login.js +0 -51
  262. package/src/lib/services/logout.js +0 -26
  263. package/src/lib/services/prebuild.js +0 -91
  264. package/src/lib/services/precommit.js +0 -144
  265. package/src/lib/services/validate.js +0 -57
  266. package/src/lib/transforms/decrypt.js +0 -98
  267. package/src/lib/transforms/del.js +0 -58
  268. package/src/lib/transforms/encrypt.js +0 -164
  269. package/src/lib/transforms/set.js +0 -144
  270. package/src/shared/colors.js +0 -67
  271. 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,7 +0,0 @@
1
- module.exports = {
2
- decryptKeyValue: require('./decryptKeyValue'),
3
- isDotenvPublicKey: require('./isDotenvPublicKey'),
4
- isPlainKey: require('./isPlainKey'),
5
- mutateKeysSrc: require('./mutateKeysSrc'),
6
- mutateSrc: require('./mutateSrc')
7
- }
@@ -1,7 +0,0 @@
1
- const PUBLIC_KEY_PATTERN = /^DOTENV_PUBLIC_KEY/
2
-
3
- function isDotenvPublicKey (key) {
4
- return PUBLIC_KEY_PATTERN.test(key)
5
- }
6
-
7
- module.exports = isDotenvPublicKey
@@ -1,7 +0,0 @@
1
- const PLAIN_KEY_PATTERN = /_PLAIN$/
2
-
3
- function isPlainKey (key) {
4
- return PLAIN_KEY_PATTERN.test(key)
5
- }
6
-
7
- module.exports = isPlainKey
@@ -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,7 +0,0 @@
1
- const { decrypt } = require('@dotenvx/primitives')
2
-
3
- function decryptDeviceValue (value, privateKey) {
4
- return decrypt(privateKey, value, { prefix: false })
5
- }
6
-
7
- module.exports = decryptDeviceValue
@@ -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,7 +0,0 @@
1
- const PRIVATE_KEY_NAME_SCHEMA = 'DOTENV_PRIVATE_KEY'
2
-
3
- function dotenvPrivateKeyNames (processEnv) {
4
- return Object.keys(processEnv).filter(key => key.startsWith(PRIVATE_KEY_NAME_SCHEMA))
5
- }
6
-
7
- module.exports = dotenvPrivateKeyNames
@@ -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,7 +0,0 @@
1
- const { encrypt } = require('@dotenvx/primitives')
2
-
3
- function encryptDeviceValue (value, publicKey) {
4
- return encrypt(publicKey, value, { prefix: false })
5
- }
6
-
7
- module.exports = encryptDeviceValue
@@ -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
- }