Skip to content

Commit

Permalink
added protocolVersion and from to header
Browse files Browse the repository at this point in the history
  • Loading branch information
bytespider committed Jan 20, 2025
1 parent df283af commit 207eddc
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function logResponse(response) {

function handleRequestError(error, verbose) {
if (error.code === 'HPE_CR_EXPECTED') {
console.error(`Please append NODE_OPTIONS='--insecure-parser' to your command.`);
console.error(`Please append NODE_OPTIONS='--insecure-http-parser' to your command.`);
process.exit(1);
}

Expand Down Expand Up @@ -170,6 +170,9 @@ module.exports = class API {
const hw = system.hardware;
const fw = system.firmware;

this.hardware = hw;
this.firmware = fw;

let rows = [
[
'Device',
Expand Down Expand Up @@ -204,7 +207,7 @@ module.exports = class API {
async deviceInformationData() {
const packet = this.signPacket({
header: {
from: '',
from: this.calculateFrom(),
method: 'GET',
namespace: 'Appliance.System.All',
},
Expand Down Expand Up @@ -245,7 +248,7 @@ module.exports = class API {
async deviceWifiList() {
const packet = this.signPacket({
header: {
from: '',
from: this.calculateFrom(),
method: 'GET',
namespace: 'Appliance.Config.WifiList',
},
Expand Down Expand Up @@ -339,7 +342,7 @@ module.exports = class API {

const packet = this.signPacket({
header: {
from: '',
from: this.calculateFrom(),
method: 'SET',
namespace: 'Appliance.Config.Key',
},
Expand Down Expand Up @@ -389,7 +392,7 @@ module.exports = class API {

const packet = this.signPacket({
header: {
from: '',
from: this.calculateFrom(),
method: 'SET',
namespace: namespace,
},
Expand Down Expand Up @@ -448,4 +451,11 @@ module.exports = class API {

return encrypted;
}

calculateFrom() {
if (this.hardware) {
return `/app/${this.userId}-${`App_${this.hardware.uuid}/subscribe`.substring(0, 32)}`;
}
return '';
}
};

0 comments on commit 207eddc

Please sign in to comment.