@dotenvx/dotenvx-ops 0.41.0 → 0.42.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/CHANGELOG.md CHANGED
@@ -2,7 +2,19 @@
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-ops/compare/v0.41.0...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.42.1...main)
6
+
7
+ ## [0.42.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.42.0...v0.42.1) (2026-04-26)
8
+
9
+ ### Changed
10
+
11
+ * Patch `.get` ([#60](https://github.com/dotenvx/dotenvx-ops/pull/60))
12
+
13
+ ## [0.42.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.41.0...v0.42.0) (2026-04-26)
14
+
15
+ ### Added
16
+
17
+ * Add `armor down` ([#59](https://github.com/dotenvx/dotenvx-ops/pull/59))
6
18
 
7
19
  ## [0.41.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.40.0...v0.41.0) (2026-04-26)
8
20
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.41.0",
2
+ "version": "0.42.1",
3
3
  "name": "@dotenvx/dotenvx-ops",
4
4
  "description": "Secrets for agents–from the creator of `dotenv` and `dotenvx`",
5
5
  "author": "@motdotla",
@@ -1,14 +1,32 @@
1
1
  const { logger } = require('@dotenvx/dotenvx')
2
-
3
2
  const Session = require('./../../../db/session')
3
+ const ArmorDown = require('./../../../lib/services/armorDown')
4
+ const createSpinner = require('../../../lib/helpers/createSpinner2')
5
+
6
+ async function down () {
7
+ const options = this.opts()
8
+ const spinner = await createSpinner({ ...options, text: 'dearmoring' })
9
+
10
+ logger.debug(`options: ${JSON.stringify(options)}`)
11
+
12
+ const sesh = new Session()
13
+ await sesh.notifyUpdate()
14
+ const hostname = options.hostname || sesh.hostname()
15
+ const token = options.token || sesh.token()
4
16
 
5
- function down () {
6
17
  try {
7
- const sesh = new Session()
8
- sesh.notifyUpdate()
18
+ const devicePublicKey = sesh.devicePublicKey()
19
+
20
+ const { changed, privateKeyName } = await new ArmorDown(hostname, token, devicePublicKey, options.envFile).run()
9
21
 
10
- logger.success('⛨ coming soon')
22
+ if (spinner) spinner.stop()
23
+ if (changed) {
24
+ logger.success(`◇ dearmored ${privateKeyName} (.env.keys)`)
25
+ } else {
26
+ logger.info(`○ no change ${privateKeyName} (.env.keys)`)
27
+ }
11
28
  } catch (error) {
29
+ if (spinner) spinner.stop()
12
30
  logger.error(error.message)
13
31
  process.exit(1)
14
32
  }
@@ -24,7 +24,8 @@ armor
24
24
  const downAction = require('./../actions/armor/down')
25
25
  armor
26
26
  .command('down')
27
- .description('soften private key')
27
+ .description('dearmor private key')
28
+ .option('-f, --env-file <path>', 'path to your env file')
28
29
  .action(downAction)
29
30
 
30
31
  // dotenvx-ops armor push
@@ -0,0 +1,45 @@
1
+ const { http } = require('../../lib/helpers/http')
2
+ const buildApiError = require('../../lib/helpers/buildApiError')
3
+ const packageJson = require('../../lib/helpers/packageJson')
4
+ const normalizeToken = require('../../lib/helpers/normalizeToken')
5
+
6
+ class PostArmorDown {
7
+ constructor (hostname, token, devicePublicKey, publicKey) {
8
+ this.hostname = hostname || 'https://ops.dotenvx.com'
9
+ this.token = token
10
+ this.devicePublicKey = devicePublicKey
11
+ this.publicKey = publicKey
12
+ }
13
+
14
+ async run () {
15
+ const token = normalizeToken(this.token)
16
+ const devicePublicKey = this.devicePublicKey
17
+ const publicKey = this.publicKey
18
+ const url = `${this.hostname}/api/armor/down`
19
+
20
+ const body = {
21
+ device_public_key: devicePublicKey,
22
+ cli_version: packageJson.version,
23
+ public_key: publicKey
24
+ }
25
+
26
+ const resp = await http(url, {
27
+ method: 'POST',
28
+ headers: {
29
+ Authorization: `Bearer ${token}`,
30
+ 'Content-Type': 'application/json'
31
+ },
32
+ body: JSON.stringify(body)
33
+ })
34
+
35
+ const json = await resp.body.json()
36
+
37
+ if (resp.statusCode >= 400) {
38
+ throw buildApiError(resp.statusCode, json)
39
+ }
40
+
41
+ return json
42
+ }
43
+ }
44
+
45
+ module.exports = PostArmorDown
@@ -0,0 +1,39 @@
1
+ const dotenvx = require('@dotenvx/dotenvx')
2
+ const PostArmorDown = require('../api/postArmorDown')
3
+ const keyNamesForEnvFile = require('../helpers/keyNamesForEnvFile')
4
+ const upsertEnvKey = require('../helpers/upsertEnvKey')
5
+
6
+ class ArmorDown {
7
+ constructor (hostname, token, devicePublicKey, envFile = '.env') {
8
+ this.hostname = hostname
9
+ this.token = token
10
+ this.devicePublicKey = devicePublicKey
11
+ this.envFile = envFile
12
+ }
13
+
14
+ async run () {
15
+ const hostname = this.hostname
16
+ const token = this.token
17
+ const devicePublicKey = this.devicePublicKey
18
+ const envFile = this.envFile
19
+
20
+ const {
21
+ publicKeyName,
22
+ privateKeyName
23
+ } = keyNamesForEnvFile(envFile)
24
+
25
+ const publicKey = dotenvx.get(publicKeyName, { path: envFile, strict: true, ignore: ['MISSING_PRIVATE_KEY'], noOps: true })
26
+ const json = await new PostArmorDown(hostname, token, devicePublicKey, publicKey).run()
27
+
28
+ upsertEnvKey(privateKeyName, json.private_key)
29
+
30
+ return {
31
+ ...json,
32
+ changed: json.changed,
33
+ privateKeyName,
34
+ privateKeyValue: json.private_key
35
+ }
36
+ }
37
+ }
38
+
39
+ module.exports = ArmorDown
@@ -22,7 +22,7 @@ class ArmorPull {
22
22
  privateKeyName
23
23
  } = keyNamesForEnvFile(envFile)
24
24
 
25
- const publicKey = dotenvx.get(publicKeyName, { path: envFile, strict: true, ignore: ['MISSING_PRIVATE_KEY'] })
25
+ const publicKey = dotenvx.get(publicKeyName, { path: envFile, strict: true, ignore: ['MISSING_PRIVATE_KEY'], noOps: true })
26
26
  const json = await new PostArmorPull(hostname, token, devicePublicKey, publicKey).run()
27
27
 
28
28
  const result = upsertEnvKey(privateKeyName, json.private_key)
@@ -18,7 +18,7 @@ class ArmorPush {
18
18
 
19
19
  const { privateKeyName } = keyNamesForEnvFile(envFile)
20
20
 
21
- const privateKey = dotenvx.get(privateKeyName, { path: '.env.keys', strict: true })
21
+ const privateKey = dotenvx.get(privateKeyName, { path: '.env.keys', strict: true, noOps: true })
22
22
  const json = await new PostArmorPush(hostname, token, devicePublicKey, privateKey).run()
23
23
 
24
24
  return {
@@ -22,8 +22,8 @@ class ArmorUp {
22
22
  privateKeyName
23
23
  } = keyNamesForEnvFile(envFile)
24
24
 
25
- const publicKey = dotenvx.get(publicKeyName, { path: envFile, strict: true, ignore: ['MISSING_PRIVATE_KEY'] })
26
- const privateKey = dotenvx.get(privateKeyName, { path: '.env.keys', strict: true, ignore: ['MISSING_KEY'] })
25
+ const publicKey = dotenvx.get(publicKeyName, { path: envFile, strict: true, ignore: ['MISSING_PRIVATE_KEY'], noOps: true })
26
+ const privateKey = dotenvx.get(privateKeyName, { path: '.env.keys', strict: true, ignore: ['MISSING_KEY'], noOps: true })
27
27
  const json = await new PostArmorUp(hostname, token, devicePublicKey, publicKey, privateKey).run()
28
28
  removeEnvKey(privateKeyName)
29
29