async-xenapi 1.0.3 → 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 +2 -2
- package/dist/XenAPI.d.ts +1 -1
- package/dist/XenAPI.js +30 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# async-xenapi (JavaScript / TypeScript)
|
|
2
2
|
|
|
3
|
-
An async
|
|
3
|
+
An async library for [XenAPI](https://xapi-project.github.io/xen-api).
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ An async JavaScript/TypeScript library for [XenAPI](https://xapi-project.github.
|
|
|
8
8
|
npm install async-xenapi
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Requires **Node.js 24
|
|
11
|
+
Requires **Node.js 24+**.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
package/dist/XenAPI.d.ts
CHANGED
package/dist/XenAPI.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* An async library for XenAPI
|
|
4
4
|
*
|
|
5
5
|
* Usage mirrors the Python XenAPI:
|
|
6
6
|
*
|
|
@@ -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.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "async-xenapi",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "An async library for XenAPI",
|
|
5
5
|
"homepage": "https://github.com/acefei/async-xenapi",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|