@ctrl/qbittorrent 7.0.0 → 7.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # qBittorrent [![npm](https://badgen.net/npm/v/@ctrl/qbittorrent)](https://www.npmjs.com/package/@ctrl/qbittorrent) [![coverage](https://badgen.net/codecov/c/github/scttcper/qbittorrent)](https://codecov.io/gh/scttcper/qbittorrent)
2
2
 
3
- > TypeScript api wrapper for [qBittorrent](https://www.qbittorrent.org/) using [got](https://github.com/sindresorhus/got)
3
+ > TypeScript api wrapper for [qBittorrent](https://www.qbittorrent.org/) using [ofetch](https://github.com/unjs/ofetch)
4
4
 
5
5
  ### Install
6
6
 
@@ -1,6 +1,6 @@
1
+ import { parse as cookieParse } from 'cookie';
1
2
  import { FormData } from 'node-fetch-native';
2
3
  import { ofetch } from 'ofetch';
3
- import { Cookie } from 'tough-cookie';
4
4
  import { joinURL } from 'ufo';
5
5
  import { magnetDecode } from '@ctrl/magnet-link';
6
6
  import { hash } from '@ctrl/torrent-file';
@@ -187,10 +187,11 @@ export class QBittorrent {
187
187
  * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-location}
188
188
  */
189
189
  async setTorrentLocation(hashes, location) {
190
- await this.request('/torrents/setLocation', 'POST', undefined, undefined, {
190
+ const data = {
191
191
  location,
192
192
  hashes: normalizeHashes(hashes),
193
- });
193
+ };
194
+ await this.request('/torrents/setLocation', 'POST', undefined, objToUrlSearchParams(data));
194
195
  return true;
195
196
  }
196
197
  /**
@@ -529,17 +530,20 @@ export class QBittorrent {
529
530
  redirect: 'manual',
530
531
  retry: false,
531
532
  timeout: this.config.timeout,
532
- // ...(this.config.agent ? { agent: this.config.agent } : {}),
533
+ ...(this.config.agent ? { agent: this.config.agent } : {}),
533
534
  });
534
535
  if (!res.headers.get('set-cookie')?.length) {
535
536
  throw new Error('Cookie not found. Auth Failed.');
536
537
  }
537
- const cookie = Cookie.parse(res.headers.get('set-cookie'));
538
- if (!cookie || cookie.key !== 'SID') {
538
+ const cookie = cookieParse(res.headers.get('set-cookie'));
539
+ if (!cookie.SID) {
539
540
  throw new Error('Invalid cookie');
540
541
  }
541
- this._sid = cookie.value;
542
- this._exp = cookie.expiryDate();
542
+ this._sid = cookie.SID;
543
+ // Not sure if it might be lowercase
544
+ const expires = cookie.Expires ?? cookie.expires;
545
+ // Default expiration is expected to be 1 hour
546
+ this._exp = expires ? new Date(expires) : new Date(Date.now() + 3600000);
543
547
  return true;
544
548
  }
545
549
  logout() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/qbittorrent",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "TypeScript api wrapper for qbittorrent using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -32,24 +32,24 @@
32
32
  "test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
33
33
  },
34
34
  "dependencies": {
35
- "@ctrl/magnet-link": "^3.1.2",
35
+ "@ctrl/magnet-link": "^4.0.1",
36
36
  "@ctrl/shared-torrent": "^5.0.0",
37
37
  "@ctrl/torrent-file": "^3.0.0",
38
- "node-fetch-native": "^1.4.0",
38
+ "cookie": "^0.6.0",
39
+ "node-fetch-native": "^1.6.1",
39
40
  "ofetch": "^1.3.3",
40
- "tough-cookie": "^4.1.3",
41
- "ufo": "^1.3.0"
41
+ "ufo": "^1.3.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@ctrl/eslint-config": "4.0.7",
45
- "@sindresorhus/tsconfig": "4.0.0",
46
- "@types/node": "20.6.5",
47
- "@types/tough-cookie": "4.0.3",
48
- "@vitest/coverage-v8": "0.34.5",
44
+ "@ctrl/eslint-config": "4.0.12",
45
+ "@sindresorhus/tsconfig": "5.0.0",
46
+ "@types/cookie": "0.6.0",
47
+ "@types/node": "20.10.5",
48
+ "@vitest/coverage-v8": "1.1.0",
49
49
  "p-wait-for": "5.0.2",
50
- "typedoc": "0.25.1",
51
- "typescript": "5.2.2",
52
- "vitest": "0.34.5"
50
+ "typedoc": "0.25.4",
51
+ "typescript": "5.3.3",
52
+ "vitest": "1.1.0"
53
53
  },
54
54
  "release": {
55
55
  "branches": [