@ctrl/qbittorrent 7.1.2 → 8.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.
@@ -56,6 +56,7 @@ export function normalizeTorrentData(torrent) {
56
56
  state = NormalizedTorrentState.error;
57
57
  stateMessage = 'The download is missing files';
58
58
  break;
59
+ // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
59
60
  default:
60
61
  break;
61
62
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
3
2
  import type { AddMagnetOptions, AddTorrentOptions, BuildInfo, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPeersResponse, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types.js';
4
3
  export declare class QBittorrent implements TorrentClient {
@@ -151,8 +150,8 @@ export declare class QBittorrent implements TorrentClient {
151
150
  * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#reannounce-torrents}
152
151
  */
153
152
  reannounceTorrent(hashes: string | string[] | 'all'): Promise<boolean>;
154
- addTorrent(torrent: string | Buffer, options?: Partial<AddTorrentOptions>): Promise<boolean>;
155
- normalizedAddTorrent(torrent: string | Buffer, options?: Partial<NormalizedAddTorrentOptions>): Promise<NormalizedTorrent>;
153
+ addTorrent(torrent: string | Uint8Array, options?: Partial<AddTorrentOptions>): Promise<boolean>;
154
+ normalizedAddTorrent(torrent: string | Uint8Array, options?: Partial<NormalizedAddTorrentOptions>): Promise<NormalizedTorrent>;
156
155
  /**
157
156
  * @param hash Hash for desired torrent
158
157
  * @param id id of the file to be renamed
@@ -2,6 +2,7 @@ import { parse as cookieParse } from 'cookie';
2
2
  import { FormData } from 'node-fetch-native';
3
3
  import { ofetch } from 'ofetch';
4
4
  import { joinURL } from 'ufo';
5
+ import { base64ToUint8Array, isUint8Array, stringToUint8Array } from 'uint8array-extras';
5
6
  import { magnetDecode } from '@ctrl/magnet-link';
6
7
  import { hash } from '@ctrl/torrent-file';
7
8
  import { normalizeTorrentData } from './normalizeTorrentData.js';
@@ -346,7 +347,7 @@ export class QBittorrent {
346
347
  }
347
348
  const type = { type: 'application/x-bittorrent' };
348
349
  if (typeof torrent === 'string') {
349
- form.set('file', new File([Buffer.from(torrent, 'base64')], 'file.torrent', type));
350
+ form.set('file', new File([base64ToUint8Array(torrent)], 'file.torrent', type));
350
351
  }
351
352
  else {
352
353
  const file = new File([torrent], options.filename ?? 'torrent', type);
@@ -387,8 +388,8 @@ export class QBittorrent {
387
388
  await this.addMagnet(torrent, torrentOptions);
388
389
  }
389
390
  else {
390
- if (!Buffer.isBuffer(torrent)) {
391
- torrent = Buffer.from(torrent);
391
+ if (!isUint8Array(torrent)) {
392
+ torrent = stringToUint8Array(torrent);
392
393
  }
393
394
  torrentHash = await hash(torrent);
394
395
  await this.addTorrent(torrent, torrentOptions);
@@ -526,7 +527,7 @@ export class QBittorrent {
526
527
  body: new URLSearchParams({
527
528
  username: this.config.username ?? '',
528
529
  password: this.config.password ?? '',
529
- }),
530
+ }).toString(),
530
531
  redirect: 'manual',
531
532
  retry: false,
532
533
  timeout: this.config.timeout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/qbittorrent",
3
- "version": "7.1.2",
3
+ "version": "8.1.0",
4
4
  "description": "TypeScript api wrapper for qbittorrent using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -22,8 +22,12 @@
22
22
  "qbittorrent"
23
23
  ],
24
24
  "scripts": {
25
- "lint": "eslint --ext .js,.ts, .",
26
- "lint:fix": "eslint --fix --ext .js,.ts, .",
25
+ "lint": "pnpm run '/^(lint:biome|lint:eslint)$/'",
26
+ "lint:biome": "biome check .",
27
+ "lint:eslint": "eslint .",
28
+ "lint:fix": "pnpm run '/^(lint:biome|lint:eslint):fix$/'",
29
+ "lint:eslint:fix": "eslint . --fix",
30
+ "lint:biome:fix": "biome check . --apply",
27
31
  "prepare": "npm run build",
28
32
  "build": "tsc",
29
33
  "build:docs": "typedoc",
@@ -32,24 +36,27 @@
32
36
  "test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
33
37
  },
34
38
  "dependencies": {
35
- "@ctrl/magnet-link": "^4.0.1",
36
- "@ctrl/shared-torrent": "^5.0.0",
37
- "@ctrl/torrent-file": "^3.0.0",
39
+ "@ctrl/magnet-link": "^4.0.2",
40
+ "@ctrl/shared-torrent": "^6.0.0",
41
+ "@ctrl/torrent-file": "^4.0.0",
38
42
  "cookie": "^0.6.0",
39
- "node-fetch-native": "^1.6.1",
40
- "ofetch": "^1.3.3",
41
- "ufo": "^1.3.2"
43
+ "node-fetch-native": "^1.6.4",
44
+ "ofetch": "^1.3.4",
45
+ "ufo": "^1.5.3",
46
+ "uint8array-extras": "^1.2.0"
42
47
  },
43
48
  "devDependencies": {
44
- "@ctrl/eslint-config": "4.0.12",
45
- "@sindresorhus/tsconfig": "5.0.0",
49
+ "@biomejs/biome": "1.8.3",
50
+ "@ctrl/eslint-config-biome": "3.1.0",
51
+ "@eslint/compat": "^1.1.0",
52
+ "@sindresorhus/tsconfig": "6.0.0",
46
53
  "@types/cookie": "0.6.0",
47
- "@types/node": "20.10.5",
48
- "@vitest/coverage-v8": "1.1.0",
54
+ "@types/node": "20.14.9",
55
+ "@vitest/coverage-v8": "1.6.0",
49
56
  "p-wait-for": "5.0.2",
50
- "typedoc": "0.25.4",
51
- "typescript": "5.3.3",
52
- "vitest": "1.1.0"
57
+ "typedoc": "0.26.3",
58
+ "typescript": "5.5.3",
59
+ "vitest": "1.6.0"
53
60
  },
54
61
  "release": {
55
62
  "branches": [