status-dev-cli
Advanced tools
Comparing version 3.2.8 to 3.2.9
26
cli.js
#!/usr/bin/env node | ||
const cli = require("commander"); | ||
const child = require('child_process'); | ||
const watchman = require('fb-watchman'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const request = require('request'); | ||
const chalk = require('chalk'); | ||
@@ -14,6 +11,15 @@ const mdns = require('mdns'); | ||
const client = new watchman.Client(); | ||
const defaultIp = "localhost"; | ||
const defaultIp = process.env.STATUS_DEVICE_IP; | ||
const statusDebugServerPort = 5561; | ||
const StatusDev = require('./index.js'); | ||
function createStatusDev() { | ||
const ip = cli.ip || defaultIp; | ||
if (ip == null) { | ||
console.error(chalk.red("You have provide your device IP using --ip.")); | ||
process.exit(1); | ||
} | ||
return new StatusDev({ip: ip}); | ||
} | ||
function fromAscii(str) { | ||
@@ -108,3 +114,3 @@ var hex = ""; | ||
.action(function (contact) { | ||
var statusDev = new StatusDev({ip: cli.ip || defaultIp}); | ||
var statusDev = createStatusDev(); | ||
var contactData = getPackageData(contact); | ||
@@ -127,3 +133,3 @@ if (contactData) { | ||
.action(function (contactIdentity) { | ||
var statusDev = new StatusDev({ip: cli.ip || defaultIp}); | ||
var statusDev = createStatusDev(); | ||
@@ -151,3 +157,3 @@ var contact = null; | ||
.action(function (contactIdentity) { | ||
var statusDev = new StatusDev({ip: cli.ip || defaultIp}); | ||
var statusDev = createStatusDev(); | ||
@@ -175,3 +181,3 @@ var contact = null; | ||
.action(function (url) { | ||
var statusDev = new StatusDev({ip: cli.ip || defaultIp}); | ||
var statusDev = createStatusDev(); | ||
statusDev.switchNode(url, function(err, body) { | ||
@@ -191,3 +197,3 @@ if (err) { | ||
.action(function () { | ||
var statusDev = new StatusDev({ip: cli.ip || defaultIp}); | ||
var statusDev = createStatusDev(); | ||
statusDev.listDApps(function (err, body) { | ||
@@ -217,3 +223,3 @@ if (err) { | ||
.action(function (contactIdentity) { | ||
var statusDev = new StatusDev({ip: cli.ip || defaultIp}); | ||
var statusDev = createStatusDev(); | ||
statusDev.getLog(contactIdentity, function (err, body) { | ||
@@ -220,0 +226,0 @@ if (err) { |
55
index.js
@@ -17,9 +17,14 @@ const request = require('request'); | ||
StatusDev.prototype.addContact = function(contactData, cb) { | ||
request({ | ||
url: this.url + "/add-dapp", | ||
function requestOptions(url, body) { | ||
return { | ||
url: url, | ||
method: "POST", | ||
timeout: 3000, | ||
json: true, | ||
body: { encoded: fromAscii(contactData) } | ||
}, function (error, response, body) { | ||
body: body}; | ||
} | ||
StatusDev.prototype.addContact = function(contactData, cb) { | ||
request(requestOptions(this.url + "/add-dapp", { encoded: fromAscii(contactData) }) | ||
, function (error, response, body) { | ||
if (cb === undefined) { return } | ||
@@ -31,8 +36,4 @@ cb(error, body); | ||
StatusDev.prototype.removeContact = function(contactData, cb) { | ||
request({ | ||
url: this.url + "/remove-dapp", | ||
method: "POST", | ||
json: true, | ||
body: { encoded: fromAscii(contactData) } | ||
}, function (error, response, body) { | ||
request(requestOptions(this.url + "/remove-dapp", { encoded: fromAscii(contactData) }) | ||
, function (error, response, body) { | ||
if (cb === undefined) { return } | ||
@@ -44,8 +45,4 @@ cb(error, body); | ||
StatusDev.prototype.refreshContact = function(contactData, cb) { | ||
request({ | ||
url: this.url + "/dapp-changed", | ||
method: "POST", | ||
json: true, | ||
body: { encoded: fromAscii(contactData) } | ||
}, function (error, response, body) { | ||
request(requestOptions(this.url + "/dapp-changed", { encoded: fromAscii(contactData) }) | ||
, function (error, response, body) { | ||
if (cb === undefined) { return } | ||
@@ -57,8 +54,4 @@ cb(error, body); | ||
StatusDev.prototype.switchNode = function(rpcUrl, cb) { | ||
request({ | ||
url: this.url + "/switch-node", | ||
method: "POST", | ||
json: true, | ||
body: {encoded: fromAscii(JSON.stringify({"url": rpcUrl}))} | ||
}, function (error, response, body) { | ||
request(requestOptions(this.url + "/switch-node", {encoded: fromAscii(JSON.stringify({"url": rpcUrl}))}) | ||
, function (error, response, body) { | ||
if (cb === undefined) { return } | ||
@@ -70,8 +63,4 @@ cb(error, body); | ||
StatusDev.prototype.listDApps = function(cb) { | ||
request({ | ||
url: this.url + "/list", | ||
json: true, | ||
method: "POST", | ||
body: {} | ||
}, function (error, response, body) { | ||
request(requestOptions(this.url + "/list", {}) | ||
, function (error, response, body) { | ||
if (cb === undefined) { return } | ||
@@ -83,8 +72,4 @@ cb(error, body); | ||
StatusDev.prototype.getLog = function(identity, cb) { | ||
request({ | ||
url: this.url + "/log", | ||
method: "POST", | ||
json: true, | ||
body: { identity: identity } | ||
}, function (error, response, body) { | ||
request(requestOptions(this.url + "/log", { identity: identity }) | ||
, function (error, response, body) { | ||
if (cb === undefined) { return } | ||
@@ -91,0 +76,0 @@ cb(error, body); |
{ | ||
"name": "status-dev-cli", | ||
"version": "3.2.8", | ||
"version": "3.2.9", | ||
"description": "CLI for Status", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,6 +19,8 @@ # Status CLI | ||
**Common additional parameters:** | ||
**Common parameters:** | ||
* `--ip <device-ip>` to specify your device's IP address. If you don't know your device's IP address, just run `status-dev-cli scan`. | ||
* `--ip <device-ip>` to specify your device's IP address. If you don't know your device's IP address, just run `status-dev-cli scan`. The IP should be provided for every command you try to execute (except `scan`, of course) | ||
Device IP can also be provided using the `STATUS_DEVICE_IP` environment variable (e.g. `STATUS_DEVICE_IP=192.168.0.2 status-dev-cli list`) | ||
#### 1. Scanning the network | ||
@@ -34,3 +36,3 @@ | ||
`status-dev-cli add [contact]` | ||
`status-dev-cli add [contact] --ip [device ip]` | ||
@@ -41,3 +43,3 @@ * `contact` — JSON containing contact information. It is not required if you develop a DApp and this DApp contains `package.json` file. Otherwise, this map should contain `whisper-identity`, `name` and `dapp-url` or `bot-url` fields (see the example in **Scenario** section) | ||
`status-dev-cli remove [whisper-identity]` | ||
`status-dev-cli remove [whisper-identity] --ip [device ip]` | ||
@@ -48,3 +50,3 @@ * `whisper-identity` — the identity of your DApp/bot. It is not required if you develop a DApp and this DApp contains `package.json` file. | ||
`status-dev-cli watch [dir] [whisper-identity]` | ||
`status-dev-cli watch [dir] [whisper-identity] --ip [device ip]` | ||
@@ -60,3 +62,3 @@ * `dir` — dir that should be observed. Not required; | ||
`status-dev-cli refresh [whisper-identity]` | ||
`status-dev-cli refresh [whisper-identity] --ip [device ip]` | ||
@@ -73,3 +75,3 @@ * `whisper-identity` — the identity of your DApp/bot. It is not required if your DApp contains `package.json` file. | ||
`status-dev-cli switch-node <url>` | ||
`status-dev-cli switch-node <url> --ip [device ip]` | ||
@@ -84,3 +86,3 @@ * `url` (required) — the network that will be used instead of `http://localhost:8545` | ||
`status-dev-cli list` | ||
`status-dev-cli list --ip [device ip]` | ||
@@ -93,3 +95,3 @@ #### 8. Extracting logs | ||
`status-dev-cli log <whisper-identity>` | ||
`status-dev-cli log <whisper-identity> --ip [device ip]` | ||
@@ -96,0 +98,0 @@ * `whisper-identity` — identity of your DApp or bot. |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
18249
140
0
347
4