nat-upnp-rejetto 2.0.2 → 2.1.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.
@@ -55,22 +55,9 @@ class Device {
55
55
  run(action, args) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
57
  const info = yield this.getService(this.services);
58
- const body = '<?xml version="1.0"?>' +
59
- "<s:Envelope " +
60
- 'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" ' +
61
- 's:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
62
- "<s:Body>" +
63
- "<u:" +
64
- action +
65
- " xmlns:u=" +
66
- JSON.stringify(info.service) +
67
- ">" +
68
- args.reduce((p, [a, b]) => p + `<${a !== null && a !== void 0 ? a : ""}>${b !== null && b !== void 0 ? b : ""}</${a !== null && a !== void 0 ? a : ""}>`, "") +
69
- "</u:" +
70
- action +
71
- ">" +
72
- "</s:Body>" +
73
- "</s:Envelope>";
58
+ const body = `<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
59
+ <s:Body><u:${action} xmlns:u=${JSON.stringify(info.service)}>${args.reduce((p, [a, b]) => p + `<${a !== null && a !== void 0 ? a : ''}>${b !== null && b !== void 0 ? b : ''}</${a !== null && a !== void 0 ? a : ''}>`, '')}</u:${action}>
60
+ </s:Body></s:Envelope>`;
74
61
  return httpRequest(info.controlURL, {
75
62
  method: 'post',
76
63
  headers: {
@@ -80,7 +67,13 @@ class Device {
80
67
  SOAPAction: JSON.stringify(info.service + "#" + action),
81
68
  },
82
69
  }, body)
83
- .then(consumers_1.text).then(data => new fast_xml_parser_1.XMLParser({ removeNSPrefix: true }).parse(data).Envelope.Body);
70
+ .then(consumers_1.text, consumers_1.text).then(data => {
71
+ var _a;
72
+ const res = new fast_xml_parser_1.XMLParser({ removeNSPrefix: true }).parse(data).Envelope.Body;
73
+ if (res.Fault)
74
+ throw ((_a = res.Fault.detail) === null || _a === void 0 ? void 0 : _a.UPnPError) || res.Fault;
75
+ return res;
76
+ });
84
77
  });
85
78
  }
86
79
  parseDescription(info) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nat-upnp-rejetto",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "main": "build/src/index",
5
5
  "author": "Fedor Indutny <fedor@indutny.com>, SimplyLinn <https://github.com/SimplyLinn>, Kaden Sharpin <http://github.com/kaden-sharpin>, Massimo Melina <a@rejetto.com>",
6
6
  "homepage": "https://github.com/kaden-sharpin/nat-upnp-ts",
@@ -16,9 +16,9 @@
16
16
  "scripts": {
17
17
  "build": "tsc",
18
18
  "watch": "tsc --watch",
19
- "test": "node ./build/test/index.test.js"
19
+ "test": "tsc && node ./build/test/index.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "fast-xml-parser": "^4.0.0-beta.8"
22
+ "fast-xml-parser": "^4.5.0"
23
23
  }
24
24
  }