@ctrl/qbittorrent 7.0.1 → 7.1.1

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.
@@ -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';
@@ -530,17 +530,20 @@ export class QBittorrent {
530
530
  redirect: 'manual',
531
531
  retry: false,
532
532
  timeout: this.config.timeout,
533
- // ...(this.config.agent ? { agent: this.config.agent } : {}),
533
+ ...(this.config.agent ? { agent: this.config.agent } : {}),
534
534
  });
535
535
  if (!res.headers.get('set-cookie')?.length) {
536
536
  throw new Error('Cookie not found. Auth Failed.');
537
537
  }
538
- const cookie = Cookie.parse(res.headers.get('set-cookie'));
539
- if (!cookie || cookie.key !== 'SID') {
538
+ const cookie = cookieParse(res.headers.get('set-cookie'));
539
+ if (!cookie.SID) {
540
540
  throw new Error('Invalid cookie');
541
541
  }
542
- this._sid = cookie.value;
543
- this._exp = cookie.expiryDate();
542
+ this._sid = cookie.SID;
543
+ // Not sure if it might be lowercase
544
+ const expires = cookie.Expires ?? cookie.expires ?? cookie['Max-Age'];
545
+ // Default expiration is expected to be 1 hour
546
+ this._exp = expires ? new Date(expires) : new Date(Date.now() + 3600000);
544
547
  return true;
545
548
  }
546
549
  logout() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/qbittorrent",
3
- "version": "7.0.1",
3
+ "version": "7.1.1",
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.1",
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.1"
41
+ "ufo": "^1.3.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@ctrl/eslint-config": "4.0.9",
44
+ "@ctrl/eslint-config": "4.0.12",
45
45
  "@sindresorhus/tsconfig": "5.0.0",
46
- "@types/node": "20.8.10",
47
- "@types/tough-cookie": "4.0.4",
48
- "@vitest/coverage-v8": "0.34.6",
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.3",
51
- "typescript": "5.2.2",
52
- "vitest": "0.34.6"
50
+ "typedoc": "0.25.4",
51
+ "typescript": "5.3.3",
52
+ "vitest": "1.1.0"
53
53
  },
54
54
  "release": {
55
55
  "branches": [