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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # async-xenapi (JavaScript / TypeScript)
2
2
 
3
- An async JavaScript/TypeScript library for [XenAPI](https://xapi-project.github.io/xen-api).
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+** (uses the global `fetch` API).
11
+ Requires **Node.js 24+**.
12
12
 
13
13
  ## Usage
14
14
 
package/dist/XenAPI.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Async XenAPI session via JSON-RPC
2
+ * An async library for XenAPI
3
3
  *
4
4
  * Usage mirrors the Python XenAPI:
5
5
  *
package/dist/XenAPI.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Async XenAPI session via JSON-RPC
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 skip TLS verification
24
- // (mirrors Python's ssl.CERT_NONE behaviour).
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
- async function _post(url, payload) {
30
- const response = await fetch(url, {
31
- method: "POST",
32
- headers: { "content-type": "application/json" },
33
- body: JSON.stringify(payload),
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.3",
4
- "description": "Async XenAPI session via JSON-RPC",
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",