async-xenapi 1.0.4 → 1.0.5
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.
- package/README.md +1 -1
- package/dist/XenAPI.js +29 -12
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/XenAPI.js
CHANGED
|
@@ -20,22 +20,39 @@ exports.AsyncXenAPISession = void 0;
|
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
// JSON-RPC helpers
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
23
|
-
// XenServer typically uses self-signed certificates
|
|
24
|
-
|
|
25
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
23
|
+
// XenServer typically uses self-signed certificates with TLS verification
|
|
24
|
+
const node_https_1 = require("node:https");
|
|
26
25
|
function _jsonrpcReq(method, params) {
|
|
27
26
|
return { jsonrpc: "2.0", method, params, id: crypto.randomUUID() };
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
function _post(url, payload) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const body = JSON.stringify(payload);
|
|
31
|
+
const req = (0, node_https_1.request)(url, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"content-type": "application/json",
|
|
35
|
+
"content-length": Buffer.byteLength(body),
|
|
36
|
+
},
|
|
37
|
+
rejectUnauthorized: false,
|
|
38
|
+
}, (res) => {
|
|
39
|
+
let data = "";
|
|
40
|
+
res.on("data", (chunk) => {
|
|
41
|
+
data += chunk;
|
|
42
|
+
});
|
|
43
|
+
res.on("end", () => {
|
|
44
|
+
try {
|
|
45
|
+
resolve(JSON.parse(data));
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
req.on("error", reject);
|
|
53
|
+
req.write(body);
|
|
54
|
+
req.end();
|
|
34
55
|
});
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
37
|
-
}
|
|
38
|
-
return response.json();
|
|
39
56
|
}
|
|
40
57
|
// Accumulates dotted property access (e.g. xenapi.VM.get_all) and dispatches
|
|
41
58
|
// the final call as an authenticated JSON-RPC request.
|