@dotenvx/dotenvx 1.72.0 → 1.73.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 +9 -1
- package/README.md +1 -1
- package/package.json +1 -2
- package/src/cli/actions/armor/down.js +37 -0
- package/src/cli/actions/armor/move.js +42 -0
- package/src/cli/actions/armor/pull.js +37 -0
- package/src/cli/actions/armor/push.js +37 -0
- package/src/cli/actions/armor/up.js +37 -0
- package/src/cli/commands/armor.js +72 -0
- package/src/cli/dotenvx.js +3 -0
- package/src/db/session.js +13 -16
- package/src/lib/api/getAccount.js +32 -0
- package/src/lib/api/postArmorDown.js +48 -0
- package/src/lib/api/postArmorMove.js +48 -0
- package/src/lib/api/postArmorPull.js +48 -0
- package/src/lib/api/postArmorPush.js +48 -0
- package/src/lib/api/postArmorUp.js +51 -0
- package/src/lib/api/postKeypair.js +60 -0
- package/src/lib/helpers/armoredKeyDisplay.js +10 -0
- package/src/lib/helpers/cryptography/armorKeypair.js +32 -11
- package/src/lib/helpers/cryptography/armorKeypairSync.js +48 -7
- package/src/lib/helpers/cryptography/provision.js +2 -2
- package/src/lib/helpers/cryptography/provisionSync.js +2 -2
- package/src/lib/helpers/keyResolution/index.js +1 -1
- package/src/lib/helpers/keyResolution/{keyNames.js → keyNamesForEnvFile.js} +2 -2
- package/src/lib/helpers/keyResolution/keyValues.js +2 -2
- package/src/lib/helpers/keyResolution/keyValuesSync.js +2 -2
- package/src/lib/helpers/keypairMetadata.js +77 -0
- package/src/lib/helpers/readEnvKey.js +31 -0
- package/src/lib/helpers/removeEnvKey.js +50 -0
- package/src/lib/helpers/sanitizeCommandForMetadata.js +64 -0
- package/src/lib/helpers/teamChoicesFromMeta.js +8 -0
- package/src/lib/helpers/upsertEnvKey.js +61 -0
- package/src/lib/services/armorDown.js +71 -0
- package/src/lib/services/armorKeypair.js +156 -0
- package/src/lib/services/armorMove.js +54 -0
- package/src/lib/services/armorPull.js +71 -0
- package/src/lib/services/armorPush.js +76 -0
- package/src/lib/services/armorUp.js +73 -0
- package/src/lib/services/decrypt.js +2 -2
- package/src/lib/services/encrypt.js +2 -2
- package/src/lib/services/keypair.js +5 -7
- package/src/lib/services/rotate.js +2 -2
- package/src/lib/services/run.js +3 -3
- package/src/lib/services/sets.js +3 -3
- package/src/lib/extensions/armor.js +0 -204
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
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/v1.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.73.0...main)
|
|
6
|
+
|
|
7
|
+
## [1.73.0](https://github.com/dotenvx/dotenvx/compare/v1.72.0...v1.73.0) (2026-06-16)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Add `dotenvx armor` commands directly inside dotenvx ([#839](https://github.com/dotenvx/dotenvx/pull/839))
|
|
12
|
+
|
|
13
|
+
> `dotenvx` remains local-first: `armor` commands are optional under professional security section
|
|
6
14
|
|
|
7
15
|
## [1.72.0](https://github.com/dotenvx/dotenvx/compare/v1.71.3...v1.72.0) (2026-06-15)
|
|
8
16
|
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
### Quickstart [](https://www.npmjs.com/package/@dotenvx/dotenvx) [](https://www.npmjs.com/package/@dotenvx/dotenvx)
|
|
14
|
+
### Quickstart [](https://www.npmjs.com/package/@dotenvx/dotenvx) [](https://www.npmjs.com/package/@dotenvx/dotenvx)
|
|
15
15
|
|
|
16
16
|
Install and use it in code just like `dotenv`.
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.73.0",
|
|
3
3
|
"name": "@dotenvx/dotenvx",
|
|
4
4
|
"description": "a secure dotenv–from the creator of `dotenv`",
|
|
5
5
|
"author": "@motdotla",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"standard": "standard",
|
|
37
37
|
"standard:fix": "standard --fix",
|
|
38
38
|
"test": "tap run --test-env=DOTENVX_NO_ARMOR=true --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
39
|
-
"test-coverage": "tap run --test-env=DOTENVX_NO_ARMOR=true --show-full-coverage --timeout=60000",
|
|
40
39
|
"testshell": "bash shellspec",
|
|
41
40
|
"release:check": "npm test && npm run testshell",
|
|
42
41
|
"prerelease": "npm run release:check",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { logger } = require('../../../shared/logger')
|
|
2
|
+
const Session = require('./../../../db/session')
|
|
3
|
+
const ArmorDown = require('./../../../lib/services/armorDown')
|
|
4
|
+
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
5
|
+
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
6
|
+
|
|
7
|
+
async function down () {
|
|
8
|
+
const options = this.opts()
|
|
9
|
+
const spinner = await createSpinner({ ...options, text: 'dearmoring' })
|
|
10
|
+
|
|
11
|
+
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
+
|
|
13
|
+
const sesh = new Session()
|
|
14
|
+
await sesh.notifyUpdate()
|
|
15
|
+
const hostname = options.hostname || sesh.hostname()
|
|
16
|
+
const token = options.token || sesh.token()
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const devicePublicKey = sesh.devicePublicKey()
|
|
20
|
+
|
|
21
|
+
const { changed, privateKeyName, publicKeyValue } = await new ArmorDown(hostname, token, devicePublicKey, options.envFile, options.team).run()
|
|
22
|
+
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
23
|
+
|
|
24
|
+
if (spinner) spinner.stop()
|
|
25
|
+
if (changed) {
|
|
26
|
+
logger.success(`◇ dearmored to .env.keys (${keyDisplay})`)
|
|
27
|
+
} else {
|
|
28
|
+
logger.info(`○ no change (${keyDisplay})`)
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (spinner) spinner.stop()
|
|
32
|
+
logger.error(error.message)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = down
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { logger } = require('../../../shared/logger')
|
|
2
|
+
const Session = require('./../../../db/session')
|
|
3
|
+
const ArmorMove = require('./../../../lib/services/armorMove')
|
|
4
|
+
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
5
|
+
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
6
|
+
|
|
7
|
+
async function move () {
|
|
8
|
+
const options = this.opts()
|
|
9
|
+
const spinner = await createSpinner({ ...options, text: 'moving' })
|
|
10
|
+
|
|
11
|
+
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
+
|
|
13
|
+
const sesh = new Session()
|
|
14
|
+
await sesh.notifyUpdate()
|
|
15
|
+
const hostname = options.hostname || sesh.hostname()
|
|
16
|
+
const token = options.token || sesh.token()
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const devicePublicKey = sesh.devicePublicKey()
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
changed,
|
|
23
|
+
privateKeyName,
|
|
24
|
+
publicKeyValue,
|
|
25
|
+
team
|
|
26
|
+
} = await new ArmorMove(hostname, token, devicePublicKey, options.envFile).run()
|
|
27
|
+
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
28
|
+
|
|
29
|
+
if (spinner) spinner.stop()
|
|
30
|
+
if (changed) {
|
|
31
|
+
logger.success(`⛨ moved to ${team} (${keyDisplay})`)
|
|
32
|
+
} else {
|
|
33
|
+
logger.info(`○ no change (${keyDisplay})`)
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (spinner) spinner.stop()
|
|
37
|
+
logger.error(error.message)
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = move
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { logger } = require('../../../shared/logger')
|
|
2
|
+
const Session = require('./../../../db/session')
|
|
3
|
+
const ArmorPull = require('./../../../lib/services/armorPull')
|
|
4
|
+
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
5
|
+
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
6
|
+
|
|
7
|
+
async function pull () {
|
|
8
|
+
const options = this.opts()
|
|
9
|
+
const spinner = await createSpinner({ ...options, text: 'pulling' })
|
|
10
|
+
|
|
11
|
+
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
+
|
|
13
|
+
const sesh = new Session()
|
|
14
|
+
await sesh.notifyUpdate()
|
|
15
|
+
const hostname = options.hostname || sesh.hostname()
|
|
16
|
+
const token = options.token || sesh.token()
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const devicePublicKey = sesh.devicePublicKey()
|
|
20
|
+
|
|
21
|
+
const { changed, privateKeyName, publicKeyValue } = await new ArmorPull(hostname, token, devicePublicKey, options.envFile, options.team).run()
|
|
22
|
+
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
23
|
+
|
|
24
|
+
if (spinner) spinner.stop()
|
|
25
|
+
if (changed) {
|
|
26
|
+
logger.success(`◇ pulled to .env.keys (${keyDisplay})`)
|
|
27
|
+
} else {
|
|
28
|
+
logger.info(`○ no change (${keyDisplay})`)
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (spinner) spinner.stop()
|
|
32
|
+
logger.error(error.message)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = pull
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { logger } = require('../../../shared/logger')
|
|
2
|
+
const Session = require('./../../../db/session')
|
|
3
|
+
const ArmorPush = require('./../../../lib/services/armorPush')
|
|
4
|
+
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
5
|
+
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
6
|
+
|
|
7
|
+
async function push () {
|
|
8
|
+
const options = this.opts()
|
|
9
|
+
const spinner = await createSpinner({ ...options, text: 'pushing' })
|
|
10
|
+
|
|
11
|
+
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
+
|
|
13
|
+
const sesh = new Session()
|
|
14
|
+
await sesh.notifyUpdate()
|
|
15
|
+
const hostname = options.hostname || sesh.hostname()
|
|
16
|
+
const token = options.token || sesh.token()
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const devicePublicKey = sesh.devicePublicKey()
|
|
20
|
+
|
|
21
|
+
const { changed, privateKeyName, publicKeyValue } = await new ArmorPush(hostname, token, devicePublicKey, options.envFile, options.team).run()
|
|
22
|
+
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
23
|
+
|
|
24
|
+
if (spinner) spinner.stop()
|
|
25
|
+
if (changed) {
|
|
26
|
+
logger.success(`⛨ pushed (${keyDisplay})`)
|
|
27
|
+
} else {
|
|
28
|
+
logger.info(`○ no change (${keyDisplay})`)
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (spinner) spinner.stop()
|
|
32
|
+
logger.error(error.message)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = push
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { logger } = require('../../../shared/logger')
|
|
2
|
+
const Session = require('./../../../db/session')
|
|
3
|
+
const ArmorUp = require('./../../../lib/services/armorUp')
|
|
4
|
+
const createSpinner = require('../../../lib/helpers/createSpinner')
|
|
5
|
+
const armoredKeyDisplay = require('../../../lib/helpers/armoredKeyDisplay')
|
|
6
|
+
|
|
7
|
+
async function up () {
|
|
8
|
+
const options = this.opts()
|
|
9
|
+
const spinner = await createSpinner({ ...options, text: 'armoring' })
|
|
10
|
+
|
|
11
|
+
logger.debug(`options: ${JSON.stringify(options)}`)
|
|
12
|
+
|
|
13
|
+
const sesh = new Session()
|
|
14
|
+
await sesh.notifyUpdate()
|
|
15
|
+
const hostname = options.hostname || sesh.hostname()
|
|
16
|
+
const token = options.token || sesh.token()
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const devicePublicKey = sesh.devicePublicKey()
|
|
20
|
+
|
|
21
|
+
const { changed, privateKeyName, publicKeyValue } = await new ArmorUp(hostname, token, devicePublicKey, options.envFile, options.team).run()
|
|
22
|
+
const keyDisplay = armoredKeyDisplay(publicKeyValue) || privateKeyName
|
|
23
|
+
|
|
24
|
+
if (spinner) spinner.stop()
|
|
25
|
+
if (changed) {
|
|
26
|
+
logger.success(`⛨ armored (${keyDisplay})`)
|
|
27
|
+
} else {
|
|
28
|
+
logger.info(`○ no change (${keyDisplay})`)
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (spinner) spinner.stop()
|
|
32
|
+
logger.error(error.message)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = up
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const Session = require('./../../db/session')
|
|
2
|
+
const executeDynamic = require('./../../lib/helpers/executeDynamic')
|
|
3
|
+
|
|
4
|
+
function configureArmorCommand (armor) {
|
|
5
|
+
armor
|
|
6
|
+
.description('move private keys off-device')
|
|
7
|
+
.allowUnknownOption()
|
|
8
|
+
.argument('[command]', 'dotenvx-armor command')
|
|
9
|
+
.argument('[args...]', 'dotenvx-armor command arguments')
|
|
10
|
+
.action(async function (command, args) {
|
|
11
|
+
if (command) {
|
|
12
|
+
return executeDynamic(armor, 'armor', [command, ...(args || [])])
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const sesh = new Session()
|
|
16
|
+
await sesh.notifyUpdate()
|
|
17
|
+
this.help()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// dotenvx armor up
|
|
21
|
+
const upAction = require('./../actions/armor/up')
|
|
22
|
+
armor
|
|
23
|
+
.command('up')
|
|
24
|
+
.description('armor key')
|
|
25
|
+
.option('-f, --env-file <path>', 'path to your env file')
|
|
26
|
+
.option('--token <token>', 'set token')
|
|
27
|
+
.option('--team <team>', 'team to armor private key for')
|
|
28
|
+
.action(upAction)
|
|
29
|
+
|
|
30
|
+
// dotenvx armor down
|
|
31
|
+
const downAction = require('./../actions/armor/down')
|
|
32
|
+
armor
|
|
33
|
+
.command('down')
|
|
34
|
+
.description('dearmor key')
|
|
35
|
+
.option('-f, --env-file <path>', 'path to your env file')
|
|
36
|
+
.option('--token <token>', 'set token')
|
|
37
|
+
.option('--team <team>', 'team to dearmor private key from')
|
|
38
|
+
.action(downAction)
|
|
39
|
+
|
|
40
|
+
// dotenvx armor push
|
|
41
|
+
const pushAction = require('./../actions/armor/push')
|
|
42
|
+
armor
|
|
43
|
+
.command('push')
|
|
44
|
+
.description('push armored key (from .env.keys)')
|
|
45
|
+
.option('-f, --env-file <path>', 'path to your env file')
|
|
46
|
+
.option('--token <token>', 'set token')
|
|
47
|
+
.option('--team <team>', 'team to push armored private key for')
|
|
48
|
+
.action(pushAction)
|
|
49
|
+
|
|
50
|
+
// dotenvx armor pull
|
|
51
|
+
const pullAction = require('./../actions/armor/pull')
|
|
52
|
+
armor
|
|
53
|
+
.command('pull')
|
|
54
|
+
.description('pull armored key (into .env.keys)')
|
|
55
|
+
.option('-f, --env-file <path>', 'path to your env file')
|
|
56
|
+
.option('--token <token>', 'set token')
|
|
57
|
+
.option('--team <team>', 'team to pull armored private key from')
|
|
58
|
+
.action(pullAction)
|
|
59
|
+
|
|
60
|
+
// dotenvx armor move
|
|
61
|
+
const moveAction = require('./../actions/armor/move')
|
|
62
|
+
armor
|
|
63
|
+
.command('move')
|
|
64
|
+
.description('move armored key (to other team)')
|
|
65
|
+
.option('-f, --env-file <path>', 'path to your env file')
|
|
66
|
+
.option('--token <token>', 'set token')
|
|
67
|
+
.action(moveAction)
|
|
68
|
+
|
|
69
|
+
return armor
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = configureArmorCommand
|
package/src/cli/dotenvx.js
CHANGED
|
@@ -244,6 +244,9 @@ program.addHelpText('after', ' logout log out of connected se
|
|
|
244
244
|
program.addHelpText('after', ' armor ⛨ move private keys off-device [www.dotenvx.com/armor]')
|
|
245
245
|
program.addHelpText('after', ' ext ⊕ extensions')
|
|
246
246
|
|
|
247
|
+
// dotenvx armor
|
|
248
|
+
require('./commands/armor')(program.command('armor', { hidden: true }))
|
|
249
|
+
|
|
247
250
|
// dotenvx ext
|
|
248
251
|
program.addCommand(require('./commands/ext'))
|
|
249
252
|
|
package/src/db/session.js
CHANGED
|
@@ -4,7 +4,6 @@ const Conf = require('conf')
|
|
|
4
4
|
const dotenv = require('dotenv')
|
|
5
5
|
const envPaths = require('env-paths')
|
|
6
6
|
|
|
7
|
-
const Armor = require('./../lib/extensions/armor')
|
|
8
7
|
const jsonToEnv = require('./../lib/helpers/jsonToEnv')
|
|
9
8
|
const { logger } = require('./../shared/logger')
|
|
10
9
|
|
|
@@ -13,14 +12,12 @@ const ARMOR = {
|
|
|
13
12
|
USER: 'DOTENVX_ARMOR_USER',
|
|
14
13
|
USERNAME: 'DOTENVX_ARMOR_USERNAME',
|
|
15
14
|
TOKEN: 'DOTENVX_ARMOR_TOKEN',
|
|
16
|
-
ON: 'DOTENVX_ARMOR_ON',
|
|
17
15
|
VERSION: 'DOTENVX_ARMOR_VERSION',
|
|
18
16
|
VERSION_LAST_CHECK: 'DOTENVX_ARMOR_VERSION_LAST_CHECK'
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
class Session {
|
|
22
20
|
constructor () {
|
|
23
|
-
this.armor = new Armor()
|
|
24
21
|
this._store = null
|
|
25
22
|
}
|
|
26
23
|
|
|
@@ -74,7 +71,7 @@ class Session {
|
|
|
74
71
|
|
|
75
72
|
status () {
|
|
76
73
|
// if logged in
|
|
77
|
-
if (this.username() && this.token()
|
|
74
|
+
if (this.username() && this.token()) {
|
|
78
75
|
return 'on'
|
|
79
76
|
}
|
|
80
77
|
|
|
@@ -112,14 +109,6 @@ class Session {
|
|
|
112
109
|
return this._store ? this._store.path : this._configPath()
|
|
113
110
|
}
|
|
114
111
|
|
|
115
|
-
on () {
|
|
116
|
-
return (this.readSetting('ON') || 'true') === 'true'
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
off () {
|
|
120
|
-
return (this.readSetting('ON') || 'true') === 'false'
|
|
121
|
-
}
|
|
122
|
-
|
|
123
112
|
async systemInformation () {
|
|
124
113
|
const si = require('systeminformation')
|
|
125
114
|
const system = await si.system()
|
|
@@ -140,13 +129,23 @@ class Session {
|
|
|
140
129
|
// armor status helpers
|
|
141
130
|
//
|
|
142
131
|
async noArmor () {
|
|
143
|
-
|
|
132
|
+
if (process.env.DOTENVX_NO_ARMOR === 'true') {
|
|
133
|
+
logger.debug('armor: off')
|
|
134
|
+
return true
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const status = this.status()
|
|
144
138
|
logger.debug(`armor: ${status}`)
|
|
145
139
|
return status === 'off'
|
|
146
140
|
}
|
|
147
141
|
|
|
148
142
|
noArmorSync () {
|
|
149
|
-
|
|
143
|
+
if (process.env.DOTENVX_NO_ARMOR === 'true') {
|
|
144
|
+
logger.debug('armor: off')
|
|
145
|
+
return true
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const status = this.status()
|
|
150
149
|
logger.debug(`armor: ${status}`)
|
|
151
150
|
return status === 'off'
|
|
152
151
|
}
|
|
@@ -176,7 +175,6 @@ class Session {
|
|
|
176
175
|
store.set(ARMOR.USERNAME, username)
|
|
177
176
|
store.set(ARMOR.TOKEN, accessToken)
|
|
178
177
|
store.set(ARMOR.HOSTNAME, hostname)
|
|
179
|
-
store.set(ARMOR.ON, 'true')
|
|
180
178
|
|
|
181
179
|
return accessToken
|
|
182
180
|
}
|
|
@@ -201,7 +199,6 @@ class Session {
|
|
|
201
199
|
store.delete(ARMOR.USERNAME)
|
|
202
200
|
store.delete(ARMOR.TOKEN)
|
|
203
201
|
store.delete(ARMOR.HOSTNAME)
|
|
204
|
-
store.delete(ARMOR.ON)
|
|
205
202
|
store.delete(ARMOR.VERSION)
|
|
206
203
|
store.delete(ARMOR.VERSION_LAST_CHECK)
|
|
207
204
|
return true
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
|
|
4
|
+
class GetAccount {
|
|
5
|
+
constructor (hostname, token) {
|
|
6
|
+
this.hostname = hostname
|
|
7
|
+
this.token = token
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run () {
|
|
11
|
+
const token = this.token
|
|
12
|
+
const url = `${this.hostname}/api/account`
|
|
13
|
+
|
|
14
|
+
const resp = await http(url, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${token}`,
|
|
18
|
+
'Content-Type': 'application/json'
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const json = await resp.body.json()
|
|
23
|
+
|
|
24
|
+
if (resp.statusCode >= 400) {
|
|
25
|
+
throw buildApiError(resp.statusCode, json)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return json
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = GetAccount
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
const packageJson = require('../helpers/packageJson')
|
|
4
|
+
const normalizeToken = require('../helpers/normalizeToken')
|
|
5
|
+
|
|
6
|
+
class PostArmorDown {
|
|
7
|
+
constructor (hostname, token, devicePublicKey, publicKey, team) {
|
|
8
|
+
this.hostname = hostname
|
|
9
|
+
this.token = token
|
|
10
|
+
this.devicePublicKey = devicePublicKey
|
|
11
|
+
this.publicKey = publicKey
|
|
12
|
+
this.team = team
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run () {
|
|
16
|
+
const token = normalizeToken(this.token)
|
|
17
|
+
const devicePublicKey = this.devicePublicKey
|
|
18
|
+
const publicKey = this.publicKey
|
|
19
|
+
const team = this.team
|
|
20
|
+
const url = `${this.hostname}/api/armor/down`
|
|
21
|
+
|
|
22
|
+
const body = {
|
|
23
|
+
device_public_key: devicePublicKey,
|
|
24
|
+
cli_version: packageJson.version,
|
|
25
|
+
public_key: publicKey,
|
|
26
|
+
team
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const resp = await http(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${token}`,
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const json = await resp.body.json()
|
|
39
|
+
|
|
40
|
+
if (resp.statusCode >= 400) {
|
|
41
|
+
throw buildApiError(resp.statusCode, json)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return json
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = PostArmorDown
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
const packageJson = require('../helpers/packageJson')
|
|
4
|
+
const normalizeToken = require('../helpers/normalizeToken')
|
|
5
|
+
|
|
6
|
+
class PostArmorMove {
|
|
7
|
+
constructor (hostname, token, devicePublicKey, publicKey, team) {
|
|
8
|
+
this.hostname = hostname
|
|
9
|
+
this.token = token
|
|
10
|
+
this.devicePublicKey = devicePublicKey
|
|
11
|
+
this.publicKey = publicKey
|
|
12
|
+
this.team = team
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run () {
|
|
16
|
+
const token = normalizeToken(this.token)
|
|
17
|
+
const devicePublicKey = this.devicePublicKey
|
|
18
|
+
const publicKey = this.publicKey
|
|
19
|
+
const team = this.team
|
|
20
|
+
const url = `${this.hostname}/api/armor/move`
|
|
21
|
+
|
|
22
|
+
const body = {
|
|
23
|
+
device_public_key: devicePublicKey,
|
|
24
|
+
cli_version: packageJson.version,
|
|
25
|
+
public_key: publicKey,
|
|
26
|
+
team
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const resp = await http(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${token}`,
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const json = await resp.body.json()
|
|
39
|
+
|
|
40
|
+
if (resp.statusCode >= 400) {
|
|
41
|
+
throw buildApiError(resp.statusCode, json)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return json
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = PostArmorMove
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
const packageJson = require('../helpers/packageJson')
|
|
4
|
+
const normalizeToken = require('../helpers/normalizeToken')
|
|
5
|
+
|
|
6
|
+
class PostArmorPull {
|
|
7
|
+
constructor (hostname, token, devicePublicKey, publicKey, team) {
|
|
8
|
+
this.hostname = hostname
|
|
9
|
+
this.token = token
|
|
10
|
+
this.devicePublicKey = devicePublicKey
|
|
11
|
+
this.publicKey = publicKey
|
|
12
|
+
this.team = team
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run () {
|
|
16
|
+
const token = normalizeToken(this.token)
|
|
17
|
+
const devicePublicKey = this.devicePublicKey
|
|
18
|
+
const publicKey = this.publicKey
|
|
19
|
+
const team = this.team
|
|
20
|
+
const url = `${this.hostname}/api/armor/pull`
|
|
21
|
+
|
|
22
|
+
const body = {
|
|
23
|
+
device_public_key: devicePublicKey,
|
|
24
|
+
cli_version: packageJson.version,
|
|
25
|
+
public_key: publicKey,
|
|
26
|
+
team
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const resp = await http(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${token}`,
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const json = await resp.body.json()
|
|
39
|
+
|
|
40
|
+
if (resp.statusCode >= 400) {
|
|
41
|
+
throw buildApiError(resp.statusCode, json)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return json
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = PostArmorPull
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { http } = require('../helpers/http')
|
|
2
|
+
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
+
const packageJson = require('../helpers/packageJson')
|
|
4
|
+
const normalizeToken = require('../helpers/normalizeToken')
|
|
5
|
+
|
|
6
|
+
class PostArmorPush {
|
|
7
|
+
constructor (hostname, token, devicePublicKey, privateKey, team) {
|
|
8
|
+
this.hostname = hostname
|
|
9
|
+
this.token = token
|
|
10
|
+
this.devicePublicKey = devicePublicKey
|
|
11
|
+
this.privateKey = privateKey
|
|
12
|
+
this.team = team
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async run () {
|
|
16
|
+
const token = normalizeToken(this.token)
|
|
17
|
+
const devicePublicKey = this.devicePublicKey
|
|
18
|
+
const privateKey = this.privateKey
|
|
19
|
+
const team = this.team
|
|
20
|
+
const url = `${this.hostname}/api/armor/push`
|
|
21
|
+
|
|
22
|
+
const body = {
|
|
23
|
+
device_public_key: devicePublicKey,
|
|
24
|
+
cli_version: packageJson.version,
|
|
25
|
+
private_key: privateKey,
|
|
26
|
+
team
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const resp = await http(url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${token}`,
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const json = await resp.body.json()
|
|
39
|
+
|
|
40
|
+
if (resp.statusCode >= 400) {
|
|
41
|
+
throw buildApiError(resp.statusCode, json)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return json
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = PostArmorPush
|