@remote-app/qbittorrent-client 0.22.0 → 0.23.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.
- package/dist/index.cjs +12 -5
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +12 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,9 +2,10 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
2
2
|
|
|
3
3
|
//#region src/error.ts
|
|
4
4
|
var HTTPError = class extends Error {
|
|
5
|
-
constructor(status, message) {
|
|
5
|
+
constructor(status, message, body) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.status = status;
|
|
8
|
+
this.body = body;
|
|
8
9
|
this.name = "HTTPError";
|
|
9
10
|
}
|
|
10
11
|
};
|
|
@@ -47,10 +48,13 @@ var QBittorrentClient = class {
|
|
|
47
48
|
Referer: baseUrl,
|
|
48
49
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
49
50
|
},
|
|
50
|
-
credentials: "
|
|
51
|
+
credentials: "omit",
|
|
51
52
|
body: body.toString()
|
|
52
53
|
});
|
|
53
|
-
if (!response.ok)
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
const body = await response.text();
|
|
56
|
+
throw new HTTPError(response.status, response.statusText, body);
|
|
57
|
+
}
|
|
54
58
|
if (await response.text() !== "Ok.") throw new QBittorrentError("Login failed: invalid credentials");
|
|
55
59
|
const cookie = response.headers.get("set-cookie");
|
|
56
60
|
if (cookie) {
|
|
@@ -84,14 +88,17 @@ var QBittorrentClient = class {
|
|
|
84
88
|
method,
|
|
85
89
|
headers,
|
|
86
90
|
body: fetchBody,
|
|
87
|
-
credentials: "
|
|
91
|
+
credentials: "omit"
|
|
88
92
|
});
|
|
89
93
|
if (response.status === 403 && retry) {
|
|
90
94
|
this.sid = null;
|
|
91
95
|
this.loggedIn = false;
|
|
92
96
|
return this.request(method, path, params, body, false);
|
|
93
97
|
}
|
|
94
|
-
if (!response.ok)
|
|
98
|
+
if (!response.ok) {
|
|
99
|
+
const body = await response.text();
|
|
100
|
+
throw new HTTPError(response.status, response.statusText, body);
|
|
101
|
+
}
|
|
95
102
|
const text = await response.text();
|
|
96
103
|
if (!text) return void 0;
|
|
97
104
|
try {
|
package/dist/index.d.cts
CHANGED
|
@@ -53,7 +53,8 @@ declare class QBittorrentClient {
|
|
|
53
53
|
//#region src/error.d.ts
|
|
54
54
|
declare class HTTPError extends Error {
|
|
55
55
|
readonly status: number;
|
|
56
|
-
|
|
56
|
+
readonly body?: string | undefined;
|
|
57
|
+
constructor(status: number, message: string, body?: string | undefined);
|
|
57
58
|
}
|
|
58
59
|
declare class QBittorrentError extends Error {
|
|
59
60
|
constructor(message: string);
|
package/dist/index.d.mts
CHANGED
|
@@ -53,7 +53,8 @@ declare class QBittorrentClient {
|
|
|
53
53
|
//#region src/error.d.ts
|
|
54
54
|
declare class HTTPError extends Error {
|
|
55
55
|
readonly status: number;
|
|
56
|
-
|
|
56
|
+
readonly body?: string | undefined;
|
|
57
|
+
constructor(status: number, message: string, body?: string | undefined);
|
|
57
58
|
}
|
|
58
59
|
declare class QBittorrentError extends Error {
|
|
59
60
|
constructor(message: string);
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
//#region src/error.ts
|
|
2
2
|
var HTTPError = class extends Error {
|
|
3
|
-
constructor(status, message) {
|
|
3
|
+
constructor(status, message, body) {
|
|
4
4
|
super(message);
|
|
5
5
|
this.status = status;
|
|
6
|
+
this.body = body;
|
|
6
7
|
this.name = "HTTPError";
|
|
7
8
|
}
|
|
8
9
|
};
|
|
@@ -45,10 +46,13 @@ var QBittorrentClient = class {
|
|
|
45
46
|
Referer: baseUrl,
|
|
46
47
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
47
48
|
},
|
|
48
|
-
credentials: "
|
|
49
|
+
credentials: "omit",
|
|
49
50
|
body: body.toString()
|
|
50
51
|
});
|
|
51
|
-
if (!response.ok)
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const body = await response.text();
|
|
54
|
+
throw new HTTPError(response.status, response.statusText, body);
|
|
55
|
+
}
|
|
52
56
|
if (await response.text() !== "Ok.") throw new QBittorrentError("Login failed: invalid credentials");
|
|
53
57
|
const cookie = response.headers.get("set-cookie");
|
|
54
58
|
if (cookie) {
|
|
@@ -82,14 +86,17 @@ var QBittorrentClient = class {
|
|
|
82
86
|
method,
|
|
83
87
|
headers,
|
|
84
88
|
body: fetchBody,
|
|
85
|
-
credentials: "
|
|
89
|
+
credentials: "omit"
|
|
86
90
|
});
|
|
87
91
|
if (response.status === 403 && retry) {
|
|
88
92
|
this.sid = null;
|
|
89
93
|
this.loggedIn = false;
|
|
90
94
|
return this.request(method, path, params, body, false);
|
|
91
95
|
}
|
|
92
|
-
if (!response.ok)
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
const body = await response.text();
|
|
98
|
+
throw new HTTPError(response.status, response.statusText, body);
|
|
99
|
+
}
|
|
93
100
|
const text = await response.text();
|
|
94
101
|
if (!text) return void 0;
|
|
95
102
|
try {
|