@dotenvx/dotenvx-ops 0.31.2 → 0.33.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,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.31.2...main)
5
+ [Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.33.0...main)
6
+
7
+ ## [0.33.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.32.0...v0.33.0) (2026-03-11)
8
+
9
+ ### Added
10
+
11
+ * Add internal `keypair` command that calls remotely ([#27](https://github.com/dotenvx/dotenvx-ops/pull/27))
12
+
13
+ ## [0.32.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.31.2...v0.32.0) (2026-03-11)
14
+
15
+ ### Changed
16
+
17
+ * Hide various commands for now as tooling is simplified ([#26](https://github.com/dotenvx/dotenvx-ops/pull/26))
6
18
 
7
19
  ## [0.31.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.31.1...v0.31.2) (2026-03-07)
8
20
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.31.2",
2
+ "version": "0.33.0",
3
3
  "name": "@dotenvx/dotenvx-ops",
4
4
  "description": "production grade dotenvx–with operational primitives",
5
5
  "author": "@motdotla",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@clack/core": "^0.4.2",
44
- "@dotenvx/dotenvx": "^1.52.0",
44
+ "@dotenvx/dotenvx": "^1.54.1",
45
45
  "@inquirer/prompts": "^7.10.1",
46
46
  "arch": "^2.1.1",
47
47
  "commander": "^11.1.0",
@@ -0,0 +1,42 @@
1
+ const { logger } = require('@dotenvx/dotenvx')
2
+
3
+ const main = require('./../../lib/main')
4
+
5
+ async function keypair () {
6
+ // debug opts
7
+ const options = this.opts()
8
+ logger.debug(`options: ${JSON.stringify(options)}`)
9
+
10
+ const hostname = options.hostname
11
+ const token = options.token
12
+
13
+ try {
14
+ const kp = await main.keypair({ hostname, token })
15
+ const output = {
16
+ public_key: kp.publicKey,
17
+ private_key: kp.privateKey
18
+ }
19
+
20
+ let space = 0
21
+ if (options.prettyPrint) {
22
+ space = 2
23
+ }
24
+
25
+ console.log(JSON.stringify(output, null, space))
26
+ } catch (error) {
27
+ if (error.message) {
28
+ logger.error(error.message)
29
+ } else {
30
+ logger.error(error)
31
+ }
32
+ if (error.help) {
33
+ logger.help(error.help)
34
+ }
35
+ if (error.stack) {
36
+ logger.debug(error.stack)
37
+ }
38
+ process.exit(1)
39
+ }
40
+ }
41
+
42
+ module.exports = keypair
@@ -3,7 +3,7 @@ const { Command } = require('commander')
3
3
  const gateway = new Command('gateway')
4
4
 
5
5
  gateway
6
- .description('🛡️ gateway')
6
+ .description('[INTERNAL] 🛡️ gateway')
7
7
  .allowUnknownOption()
8
8
 
9
9
  // dotenvx-ops gateway start
@@ -6,7 +6,7 @@ const Session = require('./../../db/session')
6
6
  const sesh = new Session()
7
7
 
8
8
  rotate
9
- .description('rotate secret')
9
+ .description('[INTERNAL] rotate secret')
10
10
  .allowUnknownOption()
11
11
 
12
12
  rotate.addCommand(require('./rotate/github'))
@@ -43,7 +43,7 @@ program
43
43
  const openAction = require('./actions/open')
44
44
  program
45
45
  .command('open')
46
- .description('open project')
46
+ .description('[INTERNAL] open project')
47
47
  .option('-h, --hostname <url>', 'set hostname', sesh.hostname())
48
48
  .action(openAction)
49
49
 
@@ -74,7 +74,7 @@ program
74
74
  const getAction = require('./actions/get')
75
75
  program
76
76
  .command('get')
77
- .description('fetch secret')
77
+ .description('[INTERNAL] fetch secret')
78
78
  .argument('URI', 'URI')
79
79
  .option('--hostname <url>', 'set hostname', sesh.hostname())
80
80
  .option('--token <token>', 'set token')
@@ -84,7 +84,7 @@ program
84
84
  const setAction = require('./actions/set')
85
85
  program
86
86
  .command('set')
87
- .description('set secret')
87
+ .description('[INTERNAL] set secret')
88
88
  .argument('URI', 'URI')
89
89
  .argument('value', 'value')
90
90
  .option('--hostname <url>', 'set hostname', sesh.hostname())
@@ -114,9 +114,19 @@ program
114
114
  const statusAction = require('./actions/status')
115
115
  program
116
116
  .command('status')
117
- .description('status')
117
+ .description('[INTERNAL] status')
118
118
  .action(statusAction)
119
119
 
120
+ // dotenvx-ops keypair
121
+ const keypairAction = require('./actions/keypair')
122
+ program
123
+ .command('keypair')
124
+ .description('[INTERNAL] generate keypair')
125
+ .option('-h, --hostname <url>', 'set hostname', sesh.hostname())
126
+ .option('--token <token>', 'set token')
127
+ .option('--pp, --pretty-print', 'pretty print output')
128
+ .action(keypairAction)
129
+
120
130
  program.addCommand(require('./commands/gateway'))
121
131
  program.addCommand(require('./commands/settings'))
122
132
 
@@ -0,0 +1,39 @@
1
+ const { http } = require('../../lib/helpers/http')
2
+ const buildApiError = require('../../lib/helpers/buildApiError')
3
+ const packageJson = require('../../lib/helpers/packageJson')
4
+
5
+ class PostKeypair {
6
+ constructor (hostname, token, devicePublicKey) {
7
+ this.hostname = hostname || 'https://ops.dotenvx.com'
8
+ this.token = token
9
+ this.devicePublicKey = devicePublicKey
10
+ }
11
+
12
+ async run () {
13
+ const token = this.token
14
+ const devicePublicKey = this.devicePublicKey
15
+ const url = `${this.hostname}/api/keypair`
16
+
17
+ const resp = await http(url, {
18
+ method: 'POST',
19
+ headers: {
20
+ Authorization: `Bearer ${token}`,
21
+ 'Content-Type': 'application/json'
22
+ },
23
+ body: JSON.stringify({
24
+ device_public_key: devicePublicKey,
25
+ cli_version: packageJson.version
26
+ })
27
+ })
28
+
29
+ const json = await resp.body.json()
30
+
31
+ if (resp.statusCode >= 400) {
32
+ throw buildApiError(resp.statusCode, json)
33
+ }
34
+
35
+ return json
36
+ }
37
+ }
38
+
39
+ module.exports = PostKeypair
package/src/lib/main.js CHANGED
@@ -5,6 +5,7 @@ const Session = require('./../db/session')
5
5
  const PostObserve = require('./api/postObserve')
6
6
  const PostGet = require('./api/postGet')
7
7
  const PostSet = require('./api/postSet')
8
+ const PostKeypair = require('./api/postKeypair')
8
9
 
9
10
  const gitUrl = require('./helpers/gitUrl')
10
11
  const gitBranch = require('./helpers/gitBranch')
@@ -76,6 +77,29 @@ const set = async function (uri, value, options = {}) {
76
77
  return await new PostSet(hostname, token, devicePublicKey, uri, value).run()
77
78
  }
78
79
 
80
+ const keypair = async function (options = {}) {
81
+ const sesh = new Session() // TODO: handle scenario where constructor fails
82
+
83
+ let hostname = process.env.DOTENVX_OPS_HOSTNAME || options.hostname
84
+ if (!hostname) {
85
+ hostname = sesh.hostname()
86
+ }
87
+
88
+ let token = process.env.DOTENVX_OPS_TOKEN || options.token
89
+ if (!token) {
90
+ token = sesh.token()
91
+ }
92
+
93
+ const devicePublicKey = sesh.devicePublicKey()
94
+
95
+ const json = await new PostKeypair(hostname, token, devicePublicKey).run()
96
+
97
+ return {
98
+ publicKey: json.public_key,
99
+ privateKey: json.private_key
100
+ }
101
+ }
102
+
79
103
  const config = function (options = {}) {
80
104
  return dotenvx.config(options)
81
105
  }
@@ -84,6 +108,7 @@ module.exports = {
84
108
  observe,
85
109
  get,
86
110
  set,
111
+ keypair,
87
112
  // dotenv proxies
88
113
  config
89
114
  }