@dotenvx/dotenvx-ops 0.41.0 → 0.42.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,13 @@
|
|
|
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.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.42.0...main)
|
|
6
|
+
|
|
7
|
+
## [0.42.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.41.0...v0.42.0) (2026-04-26)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add `armor down` ([#59](https://github.com/dotenvx/dotenvx-ops/pull/59))
|
|
6
12
|
|
|
7
13
|
## [0.41.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.40.0...v0.41.0) (2026-04-26)
|
|
8
14
|
|
package/package.json
CHANGED
|
@@ -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
|
|
8
|
-
|
|
18
|
+
const devicePublicKey = sesh.devicePublicKey()
|
|
19
|
+
|
|
20
|
+
const { changed, privateKeyName } = await new ArmorDown(hostname, token, devicePublicKey, options.envFile).run()
|
|
9
21
|
|
|
10
|
-
|
|
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('
|
|
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'] })
|
|
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
|