@seydx/tr064
Advanced tools
Comparing version 0.4.1-1 to 0.4.1-2
{ | ||
"name": "@seydx/tr064", | ||
"version": "0.4.1-1", | ||
"version": "0.4.1-2", | ||
"author": "Nicolai Schmid <hey@schmid.uno>", | ||
@@ -15,4 +15,4 @@ "description": "TR-064 - UPnP/IGD for node.js", | ||
}, | ||
"main": "build/index.cjs.js", | ||
"module": "build/index.esm.js", | ||
"main": "src/index.js", | ||
"module": "src/index.js", | ||
"publishConfig": { | ||
@@ -19,0 +19,0 @@ "access": "public" |
@@ -6,3 +6,4 @@ const async = require("async"); | ||
class Device { | ||
constructor(deviceInfo){ | ||
constructor(deviceInfo, config){ | ||
this.config = config; | ||
this.meta = deviceInfo; | ||
@@ -112,7 +113,4 @@ this.meta.servicesInfo = []; | ||
delete self.meta.serviceList; | ||
//console.log(results) | ||
resolve(self); | ||
} else { | ||
//console.log(err) | ||
reject(err); | ||
@@ -127,3 +125,4 @@ } | ||
_addService(serviceData, callback){ | ||
new s.Service(this, serviceData, callback); | ||
const self = this; | ||
new s.Service(this, serviceData, self.config, callback); | ||
} | ||
@@ -130,0 +129,0 @@ |
@@ -18,2 +18,3 @@ const parseString = require("xml2js").parseString; | ||
this.password = config.password; | ||
this.config = config; | ||
} | ||
@@ -49,3 +50,3 @@ | ||
devInfo.urlPart = path.substring(0, path.lastIndexOf("/")); | ||
const newDevice = new d.Device(devInfo); | ||
const newDevice = new d.Device(devInfo, self.config); | ||
newDevice._parseServices() | ||
@@ -52,0 +53,0 @@ .then(result => { |
@@ -5,3 +5,3 @@ var parseString = require("xml2js").parseString; | ||
class Service{ | ||
constructor(device, serviceInfo, callback){ | ||
constructor(device, serviceInfo, config, callback){ | ||
this.host = device.meta.host; | ||
@@ -16,2 +16,3 @@ this.port = device.meta.port; | ||
this.logAttempts = []; | ||
this.config = config; | ||
this._parseSCPD(this); | ||
@@ -224,3 +225,3 @@ } | ||
body: body, | ||
timeout: 5000, | ||
timeout: self.config.timeout, | ||
}, | ||
@@ -245,3 +246,3 @@ function(error, response, body) { | ||
for (const i in self.logAttempts) { | ||
if ((self.logAttempts[i].service = serviceType)) { | ||
if ((self.logAttempts[i].service == serviceType && self.logAttempts[i].action == action)) { | ||
if (self.logAttempts[i].attempts >= 1) { | ||
@@ -276,3 +277,3 @@ error = new Error("Credentials incorrect"); | ||
} else { | ||
self.logAttempts.push({ service: serviceType, attempts: 1 }); | ||
self.logAttempts.push({ service: serviceType, action: action, attempts: 1 }); | ||
device._auth.sn = ch.Nonce; | ||
@@ -303,3 +304,3 @@ device._auth.realm = ch.Realm; | ||
for (const i in self.logAttempts) { | ||
if ((self.logAttempts[i].service = serviceType)) { | ||
if ((self.logAttempts[i].service == serviceType && self.logAttempts[i].action == action)) { | ||
self.logAttempts[i].attempts = 0; | ||
@@ -331,3 +332,4 @@ } | ||
var fault = body["s:Fault"]; | ||
error = new Error("Device responded with fault " + error); | ||
let errorStatus = body['s:Fault'].detail.UPnPError.errorDescription; | ||
error = new Error("Device responded with fault: " + errorStatus); | ||
res = fault; | ||
@@ -334,0 +336,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218289
674