smartfritz-promise
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -7,5 +7,2 @@ /** | ||
* @author Andreas Goetz <cpuidle@gmx.de> | ||
* | ||
* Examples. To use install xml2json: | ||
* npm install xml2json | ||
*/ | ||
@@ -12,0 +9,0 @@ |
{ | ||
"name": "smartfritz-promise", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "SmartHome for Fritz!Box and Dect!200 Node to communicate with AVM FritzBox over the aha-http-interface", | ||
@@ -29,3 +29,3 @@ "author": { | ||
"type": "git", | ||
"url": "https://github.com/andig/smartfritz" | ||
"url": "git+https://github.com/andig/smartfritz.git" | ||
}, | ||
@@ -37,5 +37,6 @@ "dependencies": { | ||
"request": ">=2.45.*", | ||
"xml2json": "^0.9.0" | ||
"xml2json-light": "^1.0.4" | ||
}, | ||
"keywords": [ | ||
"Fritz!Box", | ||
"FritzBox", | ||
@@ -42,0 +43,0 @@ "SmartHome", |
@@ -19,3 +19,3 @@ /** | ||
var cheerio = require('cheerio'); | ||
var parser = require('xml2json'); | ||
var parser = require('xml2json-light'); | ||
@@ -104,3 +104,3 @@ // ############################################################################# | ||
return module.exports.getDeviceListInfo(sid, options).then(function(devicelistinfo) { | ||
var devices = parser.toJson(devicelistinfo, {object:true}); | ||
var devices = parser.xml2json(devicelistinfo); | ||
// extract devices as array | ||
@@ -351,31 +351,31 @@ devices = [].concat((devices.devicelist || {}).device || []); | ||
return executeCommand(sid, null, null, options, '/wlan/guest_access.lua?0=0').then(function(body) { | ||
var settings = {}; | ||
var settings = extend(parseHTML(body), { | ||
activate_guest_access: enable | ||
}); | ||
if (enable) { | ||
settings = parseHTML(body); | ||
// checkboxes | ||
for (var property in settings) { | ||
if (settings[property] === true) | ||
settings[property] = 'on'; | ||
else if (settings[property] === false) | ||
delete settings[property]; | ||
} | ||
settings.activate_guest_access = 'on'; | ||
// convert boolean to checkbox | ||
for (var property in settings) { | ||
if (settings[property] === true) | ||
settings[property] = 'on'; | ||
else if (settings[property] === false) | ||
delete settings[property]; | ||
} | ||
// add "save" hints for various FB versions | ||
settings.validate = 'apply'; | ||
settings.btnSave = ''; | ||
settings.xhr = 1; | ||
// additional settings to apply values | ||
settings = extend(settings, { | ||
'sid': sid, | ||
xhr: 1, | ||
apply: '', | ||
no_sidrenew: '', | ||
oldpage: '/wlan/guest_access.lua' | ||
}); | ||
var req = extend({ | ||
url: 'http://fritz.box', | ||
method: 'POST', | ||
form: settings | ||
}, options || {}); | ||
req.url += '/wlan/guest_access.lua?sid=' + sid; | ||
return new Promise(function(resolve, reject) { | ||
var req = extend({ | ||
url: 'http://fritz.box', | ||
method: 'POST', | ||
form: settings | ||
}, options || {}); | ||
req.url += '/data.lua'; | ||
return new Promise(function(resolve, reject) { | ||
request(req, function(error, response, body) { | ||
@@ -394,3 +394,3 @@ if (error || !(/^2/.test('' + response.statusCode)) || /action=".?login.lua"/.test(body)) { | ||
else { | ||
resolve(body.trim()); | ||
resolve(parseHTML(body)); | ||
} | ||
@@ -397,0 +397,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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
24434
11
523
1
+ Addedxml2json-light@^1.0.4
+ Addedxml2json-light@1.0.6(transitive)
- Removedxml2json@^0.9.0
- Removedbindings@1.5.0(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removedhoek@4.3.1(transitive)
- Removedisemail@2.2.1(transitive)
- Removeditems@2.2.1(transitive)
- Removedjoi@9.2.0(transitive)
- Removedmoment@2.30.1(transitive)
- Removednan@2.22.0(transitive)
- Removednode-expat@2.4.1(transitive)
- Removedtopo@2.1.1(transitive)
- Removedxml2json@0.9.2(transitive)