@dotenvx/dotenvx 2.36.0 → 2.38.0

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 CHANGED
@@ -2,7 +2,29 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- [Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.36.0...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx/compare/v2.38.0...main)
6
+
7
+ ## [2.38.0](https://github.com/dotenvx/dotenvx/compare/v2.37.0...v2.38.0) (2026-10-16)
8
+
9
+ ### Added
10
+
11
+ * Add `getSync` convenience ([#1029](https://github.com/dotenvx/dotenvx/pull/1029))
12
+
13
+ ### Changed
14
+
15
+ * Default to file key storage in non-interactive mode ([#1028](https://github.com/dotenvx/dotenvx/pull/1028))
16
+
17
+ ## [2.37.0](https://github.com/dotenvx/dotenvx/compare/v2.36.0...v2.37.0) (2026-10-15)
18
+
19
+ ### Added
20
+
21
+ * New: Dotenvx Armor Enclaved Keys - software enclaved on the remote provider like Vercel, GitHub Actions, and more. ([#1026](https://github.com/dotenvx/dotenvx/pull/1026))
22
+
23
+ ```text
24
+ ⛨ Choose key type …
25
+ ⛨ Armored
26
+ ❯ ◊ Enclaved
27
+ ```
6
28
 
7
29
  ## [2.36.0](https://github.com/dotenvx/dotenvx/compare/v2.35.0...v2.36.0) (2026-10-14)
8
30
 
package/README.md CHANGED
@@ -3232,6 +3232,20 @@ console.log(decryptedValue)
3232
3232
 
3233
3233
  This is known as *Decryption at Access* and is written about in [the whitepaper](https://dotenvx.com/dotenvx.pdf).
3234
3234
 
3235
+ </details>
3236
+ <details><summary>`getSync(KEY)` - synchronous access</summary><br>
3237
+
3238
+ Synchronously resolve an environment variable without populating `process.env`. This is useful in configuration files that cannot await `get()`.
3239
+
3240
+ ```js
3241
+ const dotenvx = require('@dotenvx/dotenvx')
3242
+ const decryptedValue = dotenvx.getSync('HELLO', { path: '.env.credentials', strict: true })
3243
+ ```
3244
+
3245
+ `getSync()` accepts the same options as `get()`, including masking, multiple paths, and error handling. Omit the key to return all values from the selected files. It blocks while files and providers are resolved.
3246
+
3247
+ If you already called `dotenvx.config()`, you can read the loaded value directly from `process.env.HELLO` instead.
3248
+
3235
3249
  </details>
3236
3250
  <details><summary>`get(KEY, {mask:})`</summary><br>
3237
3251
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.36.0",
2
+ "version": "2.38.0",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a secure dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -53,8 +53,8 @@
53
53
  },
54
54
  "funding": "https://dotenvx.com",
55
55
  "dependencies": {
56
- "@dotenvx/primitives": "^3.3.0",
57
- "@dotenvx/providers": "^0.3.5",
56
+ "@dotenvx/primitives": "^3.3.1",
57
+ "@dotenvx/providers": "^0.3.8",
58
58
  "@dotenvx/tooling": "^1.0.5",
59
59
  "undici": "^6.28.1",
60
60
  "write-file-atomic": "^5.0.1",
@@ -17,7 +17,9 @@ async function keypair (key) {
17
17
  const prettyPrint = options.prettyPrint || options.pp
18
18
 
19
19
  try {
20
+ const errors = []
20
21
  const keypairs = await keypairResolver({
22
+ onError: error => errors.push(error),
21
23
  includeProvider: key === 'provider' || (!key && !['shell', 'colon'].includes(options.format)),
22
24
  envFile: options.envFile,
23
25
  envKeysFile: options.envKeysFile,
@@ -37,6 +39,7 @@ async function keypair (key) {
37
39
  const results = key ? keypairs[key] : keypairs
38
40
 
39
41
  if (spinner) spinner.stop()
42
+ errors.forEach(catchAndLog)
40
43
  if (typeof results === 'object' && results !== null) {
41
44
  if (options.format === 'shell') {
42
45
  let inline = ''
@@ -73,6 +76,7 @@ async function keypair (key) {
73
76
  console.log(results)
74
77
  }
75
78
  }
79
+ return { exitCode: errors.length > 0 ? 1 : 0, errorCount: errors.length }
76
80
  } catch (error) {
77
81
  if (spinner) spinner.stop()
78
82
  catchAndLog(error)
@@ -2,6 +2,7 @@ const fsx = require('./../../lib/helpers/fsx')
2
2
  const { logger } = require('./../../shared/logger')
3
3
 
4
4
  const setTransform = require('./../../lib/transforms/set')
5
+ const logSetSummary = require('../../lib/helpers/logSetSummary')
5
6
 
6
7
  const catchAndLog = require('../../lib/helpers/catchAndLog')
7
8
  const createSpinner = require('../../lib/helpers/createSpinner')
@@ -88,40 +89,7 @@ async function set (key, value) {
88
89
  }
89
90
  }
90
91
 
91
- // const localKeyAddedEnv = processedEnvs.find((processedEnv) => processedEnv.localPrivateKeyAdded)
92
- // const remoteKeyAddedEnv = processedEnvs.find((processedEnv) => processedEnv.remotePrivateKeyAdded)
93
- // let keyAddedSuffix = ''
94
- // if (remoteKeyAddedEnv) {
95
- // keyAddedSuffix = ' · armored ⛨'
96
- // }
97
-
98
- if (changedFilepaths.length > 0) {
99
- let msg = `◇ set ${key} (${changedFilepaths.join(',')})`
100
- if (encrypt) {
101
- msg = `◈ encrypted ${key} (${changedFilepaths.join(',')})`
102
- }
103
-
104
- logger.success(msg)
105
-
106
- // if (encrypt) {
107
- // logger.success(`◈ encrypted ${key} (${changedFilepaths.join(',')})${keyAddedSuffix}`)
108
- // } else {
109
- // logger.success(`◇ set ${key} (${changedFilepaths.join(',')})`)
110
- // }
111
- } else if (unchangedFilepaths.length > 0) {
112
- logger.info(`○ no change (${unchangedFilepaths})`)
113
- } else {
114
- // do nothing - scenario when no .env files found
115
- }
116
-
117
- // } else if (encrypt && localKeyAddedEnv) {
118
- // const localKeyAddedEnvFilepath = localKeyAddedEnv.envFilepath || changedFilepaths[0] || '.env'
119
- // logger.success(`◈ encrypted ${key} (${localKeyAddedEnvFilepath})${keyAddedSuffix}`)
120
- // } else if (unchangedFilepaths.length > 0) {
121
- // logger.info(`○ no change (${unchangedFilepaths})`)
122
- // } else {
123
- // // do nothing
124
- // }
92
+ await logSetSummary(key, encrypt, { processedEnvs, changedFilepaths, unchangedFilepaths })
125
93
 
126
94
  return { exitCode: errorCount > 0 ? 1 : 0, errorCount }
127
95
  } catch (error) {
@@ -0,0 +1,21 @@
1
+ const { http } = require('../helpers/http')
2
+ const buildApiError = require('../helpers/buildApiError')
3
+ const normalizeToken = require('../helpers/normalizeToken')
4
+
5
+ class GetConnectionResources {
6
+ constructor (hostname, token, team, connectionId) {
7
+ this.url = `${hostname}/api/teams/${encodeURIComponent(team)}/connections/${encodeURIComponent(connectionId)}/resources`
8
+ this.token = token
9
+ }
10
+
11
+ async run (query = '') {
12
+ const response = await http(`${this.url}?${new URLSearchParams({ q: query })}`, {
13
+ method: 'GET', headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
14
+ })
15
+ const json = await response.body.json()
16
+ if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
17
+ return json
18
+ }
19
+ }
20
+
21
+ module.exports = GetConnectionResources
@@ -0,0 +1,27 @@
1
+ const { http } = require('../helpers/http')
2
+ const buildApiError = require('../helpers/buildApiError')
3
+ const normalizeToken = require('../helpers/normalizeToken')
4
+
5
+ class GetTeamConnections {
6
+ constructor (hostname, token, team, service) {
7
+ Object.assign(this, { hostname, token, team, service })
8
+ }
9
+
10
+ async run () {
11
+ const connections = []
12
+ let page = 1
13
+ while (page) {
14
+ const query = new URLSearchParams({ service: this.service, page })
15
+ const response = await http(`${this.hostname}/api/teams/${encodeURIComponent(this.team)}/connections?${query}`, {
16
+ method: 'GET', headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
17
+ })
18
+ const json = await response.body.json()
19
+ if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
20
+ connections.push(...json.connections)
21
+ page = json.meta && json.meta.next_page
22
+ }
23
+ return { connections }
24
+ }
25
+ }
26
+
27
+ module.exports = GetTeamConnections
@@ -0,0 +1,23 @@
1
+ const { http } = require('../helpers/http')
2
+ const buildApiError = require('../helpers/buildApiError')
3
+ const normalizeToken = require('../helpers/normalizeToken')
4
+
5
+ class GetTeamServices {
6
+ constructor (hostname, token, team) {
7
+ this.hostname = hostname
8
+ this.token = token
9
+ this.team = team
10
+ }
11
+
12
+ async run () {
13
+ const resp = await http(`${this.hostname}/api/teams/${encodeURIComponent(this.team)}/services`, {
14
+ method: 'GET',
15
+ headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
16
+ })
17
+ const json = await resp.body.json()
18
+ if (resp.statusCode >= 400) throw buildApiError(resp.statusCode, json)
19
+ return json
20
+ }
21
+ }
22
+
23
+ module.exports = GetTeamServices
@@ -4,13 +4,14 @@ const packageJson = require('../helpers/packageJson')
4
4
  const normalizeToken = require('../helpers/normalizeToken')
5
5
 
6
6
  class PostArmorUp {
7
- constructor (hostname, token, devicePublicKey, publicKey, privateKey, team) {
7
+ constructor (hostname, token, devicePublicKey, publicKey, privateKey, team, metadata) {
8
8
  this.hostname = hostname
9
9
  this.token = token
10
10
  this.devicePublicKey = devicePublicKey
11
11
  this.publicKey = publicKey
12
12
  this.privateKey = privateKey
13
13
  this.team = team
14
+ this.metadata = metadata
14
15
  }
15
16
 
16
17
  async run () {
@@ -26,7 +27,8 @@ class PostArmorUp {
26
27
  cli_version: packageJson.version,
27
28
  public_key: publicKey,
28
29
  private_key: privateKey,
29
- team
30
+ team,
31
+ metadata: this.metadata
30
32
  }
31
33
 
32
34
  const resp = await http(url, {
@@ -0,0 +1,23 @@
1
+ const { http } = require('../helpers/http')
2
+ const buildApiError = require('../helpers/buildApiError')
3
+ const normalizeToken = require('../helpers/normalizeToken')
4
+
5
+ class PostConnectionKeypair {
6
+ constructor (hostname, token, selection, privateKeyName) {
7
+ Object.assign(this, { hostname, token, selection, privateKeyName })
8
+ }
9
+
10
+ async run () {
11
+ const { team, connectionId, resourceId } = this.selection
12
+ const response = await http(`${this.hostname}/api/teams/${encodeURIComponent(team)}/connections/${encodeURIComponent(connectionId)}/keypairs`, {
13
+ method: 'POST',
14
+ headers: { Authorization: `Bearer ${normalizeToken(this.token)}`, 'Content-Type': 'application/json' },
15
+ body: JSON.stringify({ resource_id: resourceId, private_key_name: this.privateKeyName })
16
+ })
17
+ const json = await response.body.json()
18
+ if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
19
+ return json
20
+ }
21
+ }
22
+
23
+ module.exports = PostConnectionKeypair
@@ -0,0 +1,31 @@
1
+ const { http } = require('../helpers/http')
2
+ const buildApiError = require('../helpers/buildApiError')
3
+ const normalizeToken = require('../helpers/normalizeToken')
4
+
5
+ class TeamConnectionSetup {
6
+ constructor (hostname, token, team) {
7
+ this.url = `${hostname}/api/teams/${encodeURIComponent(team)}/connections/setup`
8
+ this.token = token
9
+ }
10
+
11
+ async request (suffix, options) {
12
+ const response = await http(`${this.url}${suffix}`, {
13
+ ...options,
14
+ headers: { Authorization: `Bearer ${normalizeToken(this.token)}`, 'Content-Type': 'application/json' },
15
+ signal: AbortSignal.timeout(30000)
16
+ })
17
+ const json = await response.body.json()
18
+ if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
19
+ return json
20
+ }
21
+
22
+ create (service) {
23
+ return this.request('', { method: 'POST', body: JSON.stringify({ service }) })
24
+ }
25
+
26
+ status (id) {
27
+ return this.request(`/${encodeURIComponent(id)}`, { method: 'GET' })
28
+ }
29
+ }
30
+
31
+ module.exports = TeamConnectionSetup
@@ -1,3 +1,4 @@
1
+ const keypairMetadata = require('../../../helpers/keypairMetadata')
1
2
  const Session = require('../../../../db/session')
2
3
  const PostArmorUp = require('../../../api/postArmorUp')
3
4
  const prompts = require('../../../helpers/prompts')
@@ -10,8 +11,10 @@ async function store (publicKey, privateKey, context = {}) {
10
11
  const token = context.token || sesh.token()
11
12
  const devicePublicKey = sesh.devicePublicKey()
12
13
 
14
+ const metadata = keypairMetadata.file(context.envFilepath)
15
+
13
16
  try {
14
- await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, undefined).run()
17
+ await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, undefined, metadata).run()
15
18
  } catch (error) {
16
19
  if (!isTeamRequiredError(error)) {
17
20
  throw error
@@ -38,7 +41,7 @@ async function store (publicKey, privateKey, context = {}) {
38
41
  throw error
39
42
  }
40
43
 
41
- await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team).run()
44
+ await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team, metadata).run()
42
45
  }
43
46
  }
44
47
 
@@ -0,0 +1,11 @@
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 +1,14 @@
1
1
  const { request } = require('@dotenvx/tooling')
2
+ const { isNetworkError } = require('@dotenvx/providers')
2
3
 
3
4
  async function http (url, opts = {}) {
4
- return await request(url, opts)
5
+ try {
6
+ return await request(url, opts)
7
+ } catch (error) {
8
+ if (!isNetworkError(error)) throw error
9
+ const code = error.code || error.cause?.code || 'NETWORK_ERROR'
10
+ throw Object.assign(new Error(`[${code}] unable to connect to ${new URL(url).origin}. Check your connection and that the server is running.`), { code, cause: error })
11
+ }
5
12
  }
6
13
 
7
14
  module.exports = { http }
@@ -74,4 +74,17 @@ function keypairMetadata (envFile = '.env', metadata = undefined) {
74
74
  })
75
75
  }
76
76
 
77
+ // Descriptive upload context must never prevent storing a key.
78
+ keypairMetadata.file = function (envFile = '.env') {
79
+ try {
80
+ return compact({
81
+ filepath: normalizeFilepath(envFile),
82
+ filename: canonicalEnvFilename(envFile),
83
+ project_name: projectName()
84
+ })
85
+ } catch (_) {
86
+ return {}
87
+ }
88
+ }
89
+
77
90
  module.exports = keypairMetadata
@@ -0,0 +1,21 @@
1
+ const { publickeys, injectsummary } = require('@dotenvx/primitives')
2
+ const { logger } = require('../../shared/logger')
3
+
4
+ function logSetSummary (key, encrypt, result) {
5
+ const { processedEnvs, changedFilepaths, unchangedFilepaths } = result
6
+ const rows = new Map(processedEnvs.map(row => [row.envFilepath, {
7
+ filepath: `(${row.envFilepath})`,
8
+ publicKeys: publickeys(row.envSrc || ''),
9
+ keySources: row.keySources
10
+ }]))
11
+ const paths = changedFilepaths.length ? changedFilepaths : unchangedFilepaths
12
+ if (!paths.length) return
13
+ const summary = encrypt ? injectsummary.sources(paths.map(filepath => rows.get(filepath) || `(${filepath})`)) : { files: [`(${paths.join(',')})`], suffix: '' }
14
+ if (changedFilepaths.length) {
15
+ logger.success(`${encrypt ? '◈ encrypted' : '◇ set'} ${key} ${summary.files.join(',')}${summary.suffix}`)
16
+ } else {
17
+ logger.info(`○ no change ${summary.files.join(',')}${summary.suffix}`)
18
+ }
19
+ }
20
+
21
+ module.exports = logSetSummary
@@ -40,17 +40,18 @@ function clearLastLine (stream) {
40
40
  }
41
41
  }
42
42
 
43
- async function select ({ message, choices, navigation, backValue, initial, prefix }, context) {
43
+ async function select ({ message, choices, navigation, backValue, initial, prefix, footer }, context) {
44
44
  try {
45
45
  if (navigation) {
46
46
  const CustodySelect = require('./custodySelect')
47
- return await new CustodySelect({ message, choices: choicesForSelect(choices), backValue, initial, ...(prefix ? { symbols: { prefix: { pending: prefix } } } : {}), ...enquirerOptions(context) }).run()
47
+ return await new CustodySelect({ message, choices: choicesForSelect(choices), backValue, initial, footer, ...(prefix ? { symbols: { prefix: { pending: prefix } } } : {}), ...enquirerOptions(context) }).run()
48
48
  }
49
49
  const answer = await enquirer.prompt({
50
50
  type: 'select',
51
51
  name: 'value',
52
52
  ...(prefix ? { symbols: { prefix: { pending: prefix } } } : {}),
53
53
  message,
54
+ footer,
54
55
  choices: choicesForSelect(choices),
55
56
  ...enquirerOptions(context)
56
57
  })
@@ -85,11 +86,19 @@ async function multiselect ({ message, choices, initial = [], submitLabel }, con
85
86
  }
86
87
  }
87
88
 
88
- async function input ({ message }, context) {
89
+ async function input ({ message, initial }, context) {
89
90
  try {
90
91
  const answer = await enquirer.prompt({
91
92
  type: 'input',
92
93
  name: 'value',
94
+ ...(initial !== undefined
95
+ ? {
96
+ onRun () {
97
+ this.input = String(initial)
98
+ this.cursor = this.input.length
99
+ }
100
+ }
101
+ : {}),
93
102
  message,
94
103
  ...enquirerOptions(context)
95
104
  })
@@ -0,0 +1,51 @@
1
+ const { setTimeout: delay } = require('node:timers/promises')
2
+ const GetTeamConnections = require('../api/getTeamConnections')
3
+ const TeamConnectionSetup = require('../api/teamConnectionSetup')
4
+ const prompts = require('./prompts')
5
+ const openUrl = require('./openUrl')
6
+
7
+ async function selectConnection (hostname, token, team, service, context) {
8
+ const { connections } = await new GetTeamConnections(hostname, token, team, service.slug).run()
9
+ const selected = await prompts.select({
10
+ message: 'Select connection',
11
+ prefix: '◊',
12
+ choices: [
13
+ ...connections.map(connection => ({ name: connection.name, value: String(connection.id) })),
14
+ { name: `+ Connect to ${service.name}`, value: '__connect' },
15
+ { name: '← back', value: '__back' }
16
+ ],
17
+ navigation: true,
18
+ backValue: '__back'
19
+ }, context)
20
+ if (selected === '__back') return
21
+ if (selected !== '__connect') {
22
+ const connection = connections.find(connection => String(connection.id) === selected)
23
+ if (!connection) throw new Error('Invalid connection selection')
24
+ return connection
25
+ }
26
+
27
+ const api = new TeamConnectionSetup(hostname, token, team)
28
+ const setup = await api.create(service.slug)
29
+ const url = new URL(setup.setup_url, hostname)
30
+ if (!['http:', 'https:'].includes(url.protocol)) throw new Error('Invalid connection setup URL')
31
+ context.output.write(`◇ waiting for ${service.name} connection…\n${url.href}\n`)
32
+ try {
33
+ await openUrl(url.href)
34
+ } catch {
35
+ context.output.write(`Open the URL above to connect ${service.name}.\n`)
36
+ }
37
+ const deadline = Math.min(Date.parse(setup.expires_at), Date.now() + 10 * 60 * 1000)
38
+ while (Date.now() < deadline) {
39
+ const result = await api.status(setup.id)
40
+ if (result.status === 'connected') {
41
+ if (!result.connection || result.connection.service !== service.slug) throw new Error('Invalid connection response')
42
+ return result.connection
43
+ }
44
+ if (result.status === 'expired') break
45
+ if (result.status !== 'pending') throw new Error(`${service.name} connection setup failed`)
46
+ await delay(Math.min(5000, Math.max(1000, (setup.interval || 2) * 1000)))
47
+ }
48
+ throw new Error(`${service.name} connection setup expired. Select Connect to ${service.name} to try again.`)
49
+ }
50
+
51
+ module.exports = selectConnection
@@ -0,0 +1,41 @@
1
+ const GetConnectionResources = require('../api/getConnectionResources')
2
+ const prompts = require('./prompts')
3
+
4
+ async function selectConnectionResource (hostname, token, team, connection, context) {
5
+ const api = new GetConnectionResources(hostname, token, team, connection.id)
6
+ let query = ''
7
+ while (true) {
8
+ const { resources, meta } = await api.run(query)
9
+ const footer = !resources.length
10
+ ? (query ? `No resources found for "${query}".` : 'No resources available for this connection.')
11
+ : (meta?.has_more ? 'Showing 5 resources. Search to narrow the results.' : undefined)
12
+ const shown = resources.slice(0, 5)
13
+ const selected = await prompts.select({
14
+ message: 'Select resource',
15
+ footer,
16
+ prefix: '◊',
17
+ choices: [
18
+ ...shown.map(resource => {
19
+ const contextName = connection.name || resource.organization
20
+ const name = resource.name || String(resource.id)
21
+ const label = contextName ? `${contextName}${name.startsWith('/') ? ' ' : ' / '}${name}` : name
22
+ return { name: label, value: String(resource.id) }
23
+ }),
24
+ { name: query ? 'Search again…' : 'Search…', value: '__search' },
25
+ { name: '← back', value: '__back' }
26
+ ],
27
+ navigation: true,
28
+ backValue: '__back'
29
+ }, context)
30
+ if (selected === '__back') return
31
+ if (selected === '__search') {
32
+ query = (await prompts.input({ message: 'Search resources (blank to reset)' }, context)).trim()
33
+ continue
34
+ }
35
+ const resource = shown.find(resource => String(resource.id) === selected)
36
+ if (!resource) throw new Error('Invalid resource selection')
37
+ return resource
38
+ }
39
+ }
40
+
41
+ module.exports = selectConnectionResource
@@ -1,12 +1,16 @@
1
1
  const prompts = require('./prompts')
2
2
  const custodians = require('../custodians')
3
3
  const createSpinner = require('./createSpinner')
4
+ const Session = require('../../db/session')
5
+ const GetTeams = require('../api/getTeams')
6
+ const GetTeamServices = require('../api/getTeamServices')
7
+ const selectConnection = require('./selectConnection')
8
+ const selectConnectionResource = require('./selectConnectionResource')
4
9
 
5
10
  const nativeNames = { darwin: 'macOS Keychain', win32: 'Windows Credential Manager', linux: 'Linux Secret Service' }
6
11
 
7
12
  async function selectKeyStorage (options = {}) {
8
- const defaultStorage = custodians.get('native').enabled(options) ? 'native' : 'file'
9
- if (process.env.CI || options.noCreate || !process.stdin.isTTY || !process.stderr.isTTY) return defaultStorage
13
+ if (process.env.CI || options.noCreate || !process.stdin.isTTY || !process.stderr.isTTY) return 'file'
10
14
 
11
15
  const groups = new Map()
12
16
  const setup = new Map()
@@ -63,6 +67,69 @@ async function selectKeyStorage (options = {}) {
63
67
  if (!entries.some(choice => choice.value === storage)) throw new Error('Invalid private key storage selection')
64
68
  }
65
69
  if (setup.has(storage)) throw new Error(setup.get(storage))
70
+ if (storage === 'armored') {
71
+ while (true) {
72
+ const keyType = await prompts.select({
73
+ message: 'Choose key type',
74
+ prefix: '⛨',
75
+ choices: [
76
+ { name: '⛨ Armored', value: 'armored' },
77
+ { name: '◊ Enclaved', value: 'enclaved' },
78
+ { name: '← back', value: '__back' }
79
+ ],
80
+ initial: 'armored',
81
+ navigation: true,
82
+ backValue: '__back'
83
+ }, context)
84
+ if (keyType === '__back') {
85
+ initial = 'armored'
86
+ break
87
+ }
88
+ if (keyType === 'enclaved') {
89
+ const session = new Session()
90
+ const { teams } = await new GetTeams(session.hostname(), options.token || session.token()).run()
91
+ if (!teams.length) throw new Error('No teams available for enclave keys')
92
+ const choices = teams.map(team => ({ name: team.slug, value: team.slug }))
93
+ while (true) {
94
+ const team = await prompts.select({
95
+ message: 'Select team',
96
+ prefix: '◊',
97
+ choices: [...choices, { name: '← back', value: '__back' }],
98
+ navigation: true,
99
+ backValue: '__back'
100
+ }, context)
101
+ if (team === '__back') break
102
+ if (!choices.some(choice => choice.value === team)) throw new Error('Invalid team selection')
103
+ const { services } = await new GetTeamServices(session.hostname(), options.token || session.token(), team).run()
104
+ if (!services.length) throw new Error('No services available for this team')
105
+ const serviceChoices = services.map(service => ({ name: service.name, value: service.slug }))
106
+ while (true) {
107
+ const service = await prompts.select({
108
+ message: 'Select service',
109
+ prefix: '◊',
110
+ choices: [...serviceChoices, { name: '← back', value: '__back' }],
111
+ navigation: true,
112
+ backValue: '__back'
113
+ }, context)
114
+ if (service === '__back') break
115
+ if (!serviceChoices.some(choice => choice.value === service)) throw new Error('Invalid service selection')
116
+ const selectedService = services.find(item => item.slug === service)
117
+ while (true) {
118
+ const connection = await selectConnection(session.hostname(), options.token || session.token(), team, selectedService, context)
119
+ if (!connection) break
120
+ const resource = await selectConnectionResource(session.hostname(), options.token || session.token(), team, connection, context)
121
+ if (!resource) continue
122
+ return { id: 'enclaved', team, service, connectionId: connection.id, resourceId: resource.id }
123
+ }
124
+ }
125
+ }
126
+ continue
127
+ }
128
+ if (keyType !== 'armored') throw new Error('Invalid key type selection')
129
+ return storage
130
+ }
131
+ continue
132
+ }
66
133
  return storage
67
134
  }
68
135
  } finally {
@@ -1,13 +1,34 @@
1
1
  const selectKeyStorage = require('./selectKeyStorage')
2
+ const prompts = require('./prompts')
3
+ const createSpinner = require('./createSpinner')
2
4
  const custodians = require('../custodians')
5
+ const { keypair, encrypt } = require('@dotenvx/primitives')
6
+ const Session = require('../../db/session')
7
+ const PostConnectionKeypair = require('../api/postConnectionKeypair')
3
8
 
4
9
  async function storeKeyStorage (storage, publicKey, privateKey, options, context) {
5
10
  context.allowCustodyBack = true
6
11
  while (true) {
7
12
  storage = storage || await selectKeyStorage(options)
13
+ if (storage.id === 'enclaved') {
14
+ let privateKeyName
15
+ createSpinner.pause()
16
+ try {
17
+ privateKeyName = await prompts.input({ message: 'Private key name', initial: context.privateKeyName }, context)
18
+ } finally {
19
+ createSpinner.resume()
20
+ }
21
+ const session = new Session()
22
+ const result = await new PostConnectionKeypair(session.hostname(), options.token || session.token(), storage, privateKeyName).run()
23
+ const remotePublicKey = result.keypair?.public_key
24
+ if (typeof remotePublicKey !== 'string' || !/^(?:0[23][0-9a-f]{64}|04[0-9a-f]{128})$/i.test(remotePublicKey)) throw new Error('Invalid public key returned by Armor')
25
+ encrypt(remotePublicKey, '')
26
+ return { storage, stored: {}, publicKey: remotePublicKey }
27
+ }
28
+ if (!publicKey) ({ publicKey, privateKey } = keypair())
8
29
  try {
9
30
  const stored = await custodians.store(storage, publicKey, privateKey, context)
10
- return { storage, stored }
31
+ return { storage, stored, publicKey }
11
32
  } catch (error) {
12
33
  if (error.code !== 'KEY_CUSTODY_BACK') throw error
13
34
  storage = undefined
package/src/lib/main.d.ts CHANGED
@@ -367,6 +367,12 @@ export function set(
367
367
 
368
368
  export interface GetOptions {
369
369
 
370
+ /** Include all process environment variables when no key is supplied. */
371
+ all?: boolean;
372
+
373
+ /** Format the returned values when no key is supplied. */
374
+ format?: 'eval' | 'eval-export' | 'shell' | 'colon';
375
+
370
376
  /**
371
377
  * Specify a custom path if your file containing environment variables is located elsewhere.
372
378
  * Can also be an array of strings, specifying multiple paths.
@@ -464,6 +470,29 @@ export function get(
464
470
  options?: GetOptions
465
471
  ): Promise<string>;
466
472
 
473
+ /**
474
+ * Synchronously resolve an environment variable without modifying process.env.
475
+ * Blocks while files and providers are resolved. Uses the same options as get().
476
+ *
477
+ * @example require('@dotenvx/dotenvx').getSync('KEY', { path: '.env.credentials' })
478
+ */
479
+ export function getSync(
480
+ key: string,
481
+ options?: GetOptions
482
+ ): string | undefined;
483
+ export function getSync(
484
+ key: undefined,
485
+ options: GetOptions & { format: NonNullable<GetOptions['format']> }
486
+ ): string;
487
+ export function getSync(
488
+ key?: undefined,
489
+ options?: GetOptions & { format?: undefined }
490
+ ): Record<string, string>;
491
+ export function getSync(
492
+ key: string | undefined,
493
+ options?: GetOptions
494
+ ): string | Record<string, string> | undefined;
495
+
467
496
  /**
468
497
  * List all env files in the current working directory
469
498
  *
package/src/lib/main.js CHANGED
@@ -15,6 +15,7 @@ const Session = require('./../db/session')
15
15
 
16
16
  // transforms
17
17
  const setTransform = require('./transforms/set')
18
+ const logSetSummary = require('./helpers/logSetSummary')
18
19
 
19
20
  // helpers
20
21
  const buildEnvs = require('./helpers/buildEnvs')
@@ -321,30 +322,7 @@ const set = async function (key, value, options = {}, events) {
321
322
  }
322
323
  if (events) events.add({ error_count: processedEnvs.filter(env => env.error).length })
323
324
 
324
- let keyAddedSuffix = ''
325
- const localKeyAddedEnv = processedEnvs.find((processedEnv) => processedEnv.localPrivateKeyAdded)
326
- const remoteKeyAddedEnv = processedEnvs.find((processedEnv) => processedEnv.remotePrivateKeyAdded)
327
-
328
- if (remoteKeyAddedEnv) {
329
- keyAddedSuffix = ' · armored ⛨'
330
- }
331
-
332
- if (changedFilepaths.length > 0) {
333
- if (encrypt) {
334
- logger.success(`◈ encrypted ${key} (${changedFilepaths.join(',')})${keyAddedSuffix}`)
335
- } else {
336
- logger.success(`◇ set ${key} (${changedFilepaths.join(',')})`)
337
- }
338
- } else if (encrypt && localKeyAddedEnv) {
339
- const keyAddedEnvFilepath = localKeyAddedEnv.envFilepath || changedFilepaths[0] || '.env'
340
- logger.success(`◈ encrypted ${key} (${keyAddedEnvFilepath})${keyAddedSuffix}`)
341
- } else if (unchangedFilepaths.length > 0) {
342
- logger.info(`○ no change (${unchangedFilepaths})`)
343
- } else {
344
- // do nothing
345
- }
346
-
347
- // intentionally quiet: success line communicates key creation
325
+ await logSetSummary(key, encrypt, { processedEnvs, changedFilepaths, unchangedFilepaths })
348
326
 
349
327
  return {
350
328
  processedEnvs,
@@ -353,8 +331,21 @@ const set = async function (key, value, options = {}, events) {
353
331
  }
354
332
  }
355
333
 
356
- /* @type {import('./main').get} */
334
+ /** @type {import('./main').get} */
357
335
  const get = async function (key, options = {}, events) {
336
+ const prepared = prepareGet(key, options)
337
+ const resolved = await getResolver(prepared.resolverOptions)
338
+ return getResult(key, prepared.options, resolved, events)
339
+ }
340
+
341
+ /** @type {import('./main').getSync} */
342
+ const getSync = function (key, options = {}) {
343
+ const prepared = prepareGet(key, options)
344
+ const resolved = getResolver.sync(prepared.resolverOptions)
345
+ return getResult(key, prepared.options, resolved)
346
+ }
347
+
348
+ function prepareGet (key, options) {
358
349
  options = normalizeDotenvConfigConvention(options)
359
350
  options = normalizeDotenvConfigIgnore(options)
360
351
 
@@ -362,22 +353,26 @@ const get = async function (key, options = {}, events) {
362
353
  const noArmor = resolveNoArmor(options)
363
354
  const noNative = resolveNoNative(options)
364
355
 
365
- // ignore
366
- const ignore = options.ignore || []
356
+ return {
357
+ options,
358
+ resolverOptions: {
359
+ resolveDirectories: false,
360
+ key,
361
+ envs,
362
+ profile: options.profile,
363
+ overload: options.overload,
364
+ all: options.all,
365
+ envKeysFile: options.envKeysFile,
366
+ noArmor,
367
+ noNative,
368
+ no1Password: options.no1Password,
369
+ noBitwarden: options.noBitwarden
370
+ }
371
+ }
372
+ }
367
373
 
368
- const { parsed, errors } = await getResolver({
369
- resolveDirectories: false,
370
- key,
371
- envs,
372
- profile: options.profile,
373
- overload: options.overload,
374
- all: options.all,
375
- envKeysFile: options.envKeysFile,
376
- noArmor,
377
- noNative,
378
- no1Password: options.no1Password,
379
- noBitwarden: options.noBitwarden
380
- })
374
+ function getResult (key, options, { parsed, errors }, events) {
375
+ const ignore = options.ignore || []
381
376
 
382
377
  if (options.mask !== undefined) {
383
378
  const showChar = options.mask === true ? 6 : options.mask
@@ -463,6 +458,7 @@ module.exports = {
463
458
  // actions related
464
459
  set,
465
460
  get,
461
+ getSync,
466
462
  ls,
467
463
  // expose for libs depending on @dotenvx/dotenvx
468
464
  setLogLevel,
@@ -38,7 +38,13 @@ function lookup (publicKey, options, sync) {
38
38
  const keys = provider(providerOptions)
39
39
 
40
40
  function found (ring) {
41
- if (!ring[publicKey] && armorError) throw armorError
41
+ if (!ring[publicKey] && armorError) {
42
+ // This response confirms custody even though the private key cannot be retrieved.
43
+ if (armorError.code === 'ENCLAVED' || (armorError.code === 'BAD_REQUEST' && ['[BAD_REQUEST] private key enclaved ◊', '[BAD_REQUEST] Private key is held exclusively in its remote enclave.'].includes(armorError.message))) {
44
+ if (options.onProvider) options.onProvider('armor', publicKey)
45
+ }
46
+ throw armorError
47
+ }
42
48
  if (ring[publicKey] && options.onProvider) {
43
49
  options.onProvider(source === 'native' ? nativeNames[process.platform] || source : source, publicKey)
44
50
  }
@@ -6,6 +6,7 @@ const TYPE_ENV = 'env'
6
6
  const TYPE_ENV_FILE = 'envFile'
7
7
 
8
8
  const Errors = require('./../helpers/errors')
9
+ const enclavedHint = require('../helpers/enclavedHint')
9
10
  const detectEncoding = require('./../helpers/detectEncoding')
10
11
  const detectEncodingSync = require('./../helpers/detectEncodingSync')
11
12
  const keynames = require('./../conventions/keynames')
@@ -242,6 +243,7 @@ async function injectEnvFile ({ env, overload, processEnv, envKeysFilepath, prov
242
243
  }
243
244
  }
244
245
 
246
+ for (const error of row.errors || []) enclavedHint(error, env.value)
245
247
  return row
246
248
  }
247
249
 
@@ -303,6 +305,7 @@ function injectEnvFileSync ({ env, overload, processEnv, envKeysFilepath, provid
303
305
  }
304
306
  }
305
307
 
308
+ for (const error of row.errors || []) enclavedHint(error, env.value)
306
309
  return row
307
310
  }
308
311
 
@@ -61,12 +61,27 @@ async function get (options = {}) {
61
61
  const processEnv = { ...(options.processEnv || process.env) }
62
62
  const { processedEnvs } = await envsResolver(buildOptions(options, processEnv))
63
63
 
64
- return result({
64
+ return resolveResult(options, processedEnvs, processEnv)
65
+ }
66
+
67
+ function getSync (options = {}) {
68
+ const processEnv = { ...(options.processEnv || process.env) }
69
+ const { processedEnvs } = envsResolver.sync(buildOptions(options, processEnv))
70
+ return resolveResult(options, processedEnvs, processEnv)
71
+ }
72
+
73
+ function resolveResult (options, processedEnvs, processEnv) {
74
+ const resolved = result({
65
75
  key: options.key,
66
76
  all: options.all,
67
77
  processedEnvs,
68
78
  processEnv
69
79
  })
80
+ if (options.includeKeySources) {
81
+ resolved.keySources = Object.assign({}, ...processedEnvs.map(row => row.keySources))
82
+ }
83
+ return resolved
70
84
  }
71
85
 
72
86
  module.exports = get
87
+ module.exports.sync = getSync
@@ -6,6 +6,7 @@ const filepaths = require('./../conventions/filepaths')
6
6
 
7
7
  const { keyring, keyringSync, publickeys } = require('@dotenvx/primitives')
8
8
  const providers = require('./../providers')
9
+ const enclavedHint = require('../helpers/enclavedHint')
9
10
 
10
11
  function buildOptions ({ publicKey, processEnv, fk }) {
11
12
  const ring = {}
@@ -45,7 +46,8 @@ async function keypair (options = {}) {
45
46
  })
46
47
 
47
48
  let origin = 'environment'
48
- const provider = await providers({ ...options, onProvider: name => { origin = name } })
49
+ let confirmedProvider = false
50
+ const provider = await providers({ ...options, onProvider: name => { origin = name; confirmedProvider = true } })
49
51
  const keys = file({ fk: keyringOptions.fk })
50
52
  keyringOptions.provider = async publicKey => {
51
53
  const ring = await keys.get(publicKey)
@@ -58,10 +60,18 @@ async function keypair (options = {}) {
58
60
  }
59
61
  if (publicKey) keyringOptions.fk = []
60
62
 
61
- const ring = await keyring(keyringOptions)
63
+ let ring
64
+ try {
65
+ ring = await keyring(keyringOptions)
66
+ } catch (error) {
67
+ enclavedHint(error, filepath)
68
+ if (!options.onError) throw error
69
+ options.onError(error)
70
+ ring = {}
71
+ }
62
72
 
63
73
  outputKeypair({ out, filepath, publicKey, ring })
64
- origins[filepath] = publicKey && ring[publicKey] ? origin : null
74
+ origins[filepath] = publicKey && (ring[publicKey] || confirmedProvider) ? origin : null
65
75
  }
66
76
 
67
77
  if (options.includeProvider) {
@@ -86,7 +96,8 @@ function keypairSync (options = {}) {
86
96
  fk: options.envKeysFilepath || options.envKeysFile || path.resolve(path.dirname(filepath), '.env.keys')
87
97
  })
88
98
  let origin = 'environment'
89
- const provider = providers.sync({ ...options, onProvider: name => { origin = name } })
99
+ let confirmedProvider = false
100
+ const provider = providers.sync({ ...options, onProvider: name => { origin = name; confirmedProvider = true } })
90
101
  const keys = file({ fk: keyringOptions.fk })
91
102
  keyringOptions.provider = publicKey => {
92
103
  const ring = keys.getSync(publicKey)
@@ -99,10 +110,18 @@ function keypairSync (options = {}) {
99
110
  }
100
111
  if (publicKey) keyringOptions.fk = []
101
112
 
102
- const ring = keyringSync(keyringOptions)
113
+ let ring
114
+ try {
115
+ ring = keyringSync(keyringOptions)
116
+ } catch (error) {
117
+ enclavedHint(error, filepath)
118
+ if (!options.onError) throw error
119
+ options.onError(error)
120
+ ring = {}
121
+ }
103
122
 
104
123
  outputKeypair({ out, filepath, publicKey, ring })
105
- origins[filepath] = publicKey && ring[publicKey] ? origin : null
124
+ origins[filepath] = publicKey && (ring[publicKey] || confirmedProvider) ? origin : null
106
125
  }
107
126
 
108
127
  if (options.includeProvider) {
@@ -1,3 +1,4 @@
1
+ const keypairMetadata = require('../helpers/keypairMetadata')
1
2
  const prompts = require('../helpers/prompts')
2
3
  const resolveLocalKey = require('../custodians/resolveLocalKey')
3
4
  const PostArmorUp = require('../api/postArmorUp')
@@ -23,13 +24,15 @@ class ArmorUp {
23
24
  const source = await resolveLocalKey(envFile, { allowMissing: true })
24
25
  const { publicKey, privateKey, privateKeyName } = source
25
26
 
27
+ const metadata = keypairMetadata.file(envFile)
28
+
26
29
  let json
27
30
 
28
31
  if (team) {
29
- json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team).run()
32
+ json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team, metadata).run()
30
33
  } else {
31
34
  try {
32
- json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, undefined).run()
35
+ json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, undefined, metadata).run()
33
36
  } catch (error) {
34
37
  if (!isTeamRequiredError(error)) {
35
38
  throw error
@@ -49,7 +52,7 @@ class ArmorUp {
49
52
  })
50
53
  }
51
54
 
52
- json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team).run()
55
+ json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey, team, metadata).run()
53
56
  }
54
57
  }
55
58
 
@@ -5,6 +5,7 @@ const { upsert } = require('@dotenvx/primitives')
5
5
  const TYPE_ENV_FILE = 'envFile'
6
6
 
7
7
  const Errors = require('./../helpers/errors')
8
+ const enclavedHint = require('../helpers/enclavedHint')
8
9
  const { determine } = require('./../helpers/envResolution')
9
10
  const detectEncoding = require('./../helpers/detectEncoding')
10
11
  const providers = require('./../providers')
@@ -83,6 +84,7 @@ async function decrypt (options = {}) {
83
84
  }
84
85
  }
85
86
 
87
+ enclavedHint(row.error, envFilepath)
86
88
  processedEnvs.push(row)
87
89
  }
88
90
 
@@ -1,6 +1,6 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const { encrypted, encrypt, scan, upsert, publickeys, keypair } = require('@dotenvx/primitives')
3
+ const { encrypted, encrypt, scan, upsert, publickeys } = require('@dotenvx/primitives')
4
4
 
5
5
  const TYPE_ENV_FILE = 'envFile'
6
6
  const SAMPLE_ENV_KIT = require('../helpers/kits/sample')
@@ -105,18 +105,13 @@ async function encryptTransform (options = {}) {
105
105
  let publicKey = publickeys(row.envSrc)[0]
106
106
 
107
107
  if (!publicKey) {
108
- // upsert public key to .env file
109
- const kp = keypair() // local
110
- publicKey = kp.publicKey
111
- const privateKey = kp.privateKey
112
108
  const { publicKeyName, privateKeyName } = keynames(envFilepath)
113
- const { envSrc } = mutateSrc({ envSrc: row.envSrc, envFilepath, keysFilepath: fk, publicKeyName, publicKeyValue: publicKey })
114
- row.envSrc = envSrc
115
-
116
109
  const comment = path.basename(envFilepath)
117
110
 
118
- const result = await storeKeyStorage(storage, publicKey, privateKey, options, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
111
+ const result = await storeKeyStorage(storage, undefined, undefined, options, Object.assign(custodyContext, { envFilepath: filepath, keysSrc, privateKeyName, comment, keysFilepath: fk }))
119
112
  storage = result.storage
113
+ publicKey = result.publicKey
114
+ row.envSrc = mutateSrc({ envSrc: row.envSrc, envFilepath, keysFilepath: fk, publicKeyName, publicKeyValue: publicKey }).envSrc
120
115
  row.keySources = { [publicKey]: Object.prototype.hasOwnProperty.call(result.stored, 'keysSrc') ? 'file' : (typeof storage === 'string' ? storage : storage.id) }
121
116
  const stored = result.stored
122
117
  if (Object.prototype.hasOwnProperty.call(stored, 'keysSrc')) keysSrc = stored.keysSrc
@@ -1,6 +1,6 @@
1
1
  const fsx = require('./../helpers/fsx')
2
2
  const path = require('path')
3
- const { encrypt, upsert, publickeys, keypair } = require('@dotenvx/primitives')
3
+ const { encrypt, upsert, publickeys } = require('@dotenvx/primitives')
4
4
 
5
5
  const TYPE_ENV_FILE = 'envFile'
6
6
 
@@ -74,18 +74,14 @@ async function setTransform (options = {}) {
74
74
 
75
75
  // only create if missing public key and encryption needed
76
76
  if (!publicKey && !noEncrypt) {
77
- // upsert public key to .env file
78
- const kp = keypair() // local
79
- publicKey = kp.publicKey
80
- const privateKey = kp.privateKey
81
77
  const { publicKeyName, privateKeyName } = keynames(envFilepath)
82
- const { envSrc } = mutateSrc({ envSrc: row.envSrc, envFilepath, keysFilepath: fk, publicKeyName, publicKeyValue: publicKey })
83
- row.envSrc = envSrc
84
-
85
78
  const comment = path.basename(envFilepath)
86
79
 
87
- const result = await storeKeyStorage(storage, publicKey, privateKey, options, Object.assign(custodyContext, { keysSrc, privateKeyName, comment, keysFilepath: fk }))
80
+ const result = await storeKeyStorage(storage, undefined, undefined, options, Object.assign(custodyContext, { envFilepath: filepath, keysSrc, privateKeyName, comment, keysFilepath: fk }))
88
81
  storage = result.storage
82
+ publicKey = result.publicKey
83
+ row.envSrc = mutateSrc({ envSrc: row.envSrc, envFilepath, keysFilepath: fk, publicKeyName, publicKeyValue: publicKey }).envSrc
84
+ row.keySources = { [publicKey]: Object.prototype.hasOwnProperty.call(result.stored, 'keysSrc') ? 'file' : (typeof storage === 'string' ? storage : storage.id) }
89
85
  const stored = result.stored
90
86
  if (Object.prototype.hasOwnProperty.call(stored, 'keysSrc')) keysSrc = stored.keysSrc
91
87
  if (stored.nativePrivateKeyAdded) row.nativePrivateKeyAdded = true
@@ -99,7 +95,8 @@ async function setTransform (options = {}) {
99
95
  }
100
96
  } else {
101
97
  // expensive additional loop
102
- const { parsed } = await getResolver({
98
+ const { parsed, keySources } = await getResolver({
99
+ includeKeySources: true,
103
100
  key,
104
101
  envs: [env],
105
102
  all: true,
@@ -110,6 +107,7 @@ async function setTransform (options = {}) {
110
107
  noBitwarden: options.noBitwarden
111
108
  })
112
109
 
110
+ row.keySources = row.keySources || keySources
113
111
  const before = parsed[key]
114
112
  if (value !== before) {
115
113
  const encryptedValue = encrypt(publicKey, value)
@@ -1,21 +0,0 @@
1
- const NETWORK_ERROR_CODES = new Set([
2
- 'ECONNRESET',
3
- 'ECONNREFUSED',
4
- 'ENOTFOUND',
5
- 'ENETDOWN',
6
- 'ENETUNREACH',
7
- 'EHOSTDOWN',
8
- 'EHOSTUNREACH',
9
- 'EPIPE',
10
- 'ETIMEDOUT',
11
- 'UND_ERR_CONNECT_TIMEOUT',
12
- 'UND_ERR_HEADERS_TIMEOUT',
13
- 'UND_ERR_BODY_TIMEOUT',
14
- 'UND_ERR_SOCKET'
15
- ])
16
-
17
- function isNetworkError (error) {
18
- return NETWORK_ERROR_CODES.has(error && error.code) || NETWORK_ERROR_CODES.has(error && error.cause && error.cause.code)
19
- }
20
-
21
- module.exports = isNetworkError