// Types for the WebTorrent-ecosystem packages release 21 uses, which ship // none: only the surface the code calls. declare module "create-torrent" { export type CreateTorrentOptions = { name?: string; comment?: string; createdBy?: string; creationDate?: Date | number; private?: boolean; pieceLength?: number; announceList?: string[][]; urlList?: string[]; info?: Record; }; export default function createTorrent( input: string | string[] | Uint8Array, opts: CreateTorrentOptions, cb: (err: Error | null, torrent: Uint8Array) => void, ): void; } declare module "webtorrent" { import type { EventEmitter } from "node:events"; export type WebTorrentOptions = { maxConns?: number; uploadLimit?: number; downloadLimit?: number; dht?: boolean | Record; lsd?: boolean; natUpnp?: boolean; natPmp?: boolean; utp?: boolean; utPex?: boolean; webSeeds?: boolean; tracker?: boolean | Record; torrentPort?: number; }; export type AddOptions = { path?: string; announce?: string[]; skipVerify?: boolean; private?: boolean; }; export interface Wire { isSeeder: boolean; peerId?: string; remoteAddress?: string; type?: string; } export interface Torrent extends EventEmitter { infoHash: string; name: string; ready: boolean; done: boolean; progress: number; downloaded: number; uploaded: number; numPeers: number; wires: Wire[]; destroyed: boolean; destroy(opts?: { destroyStore?: boolean } | null, cb?: (err?: Error | null) => void): void; } export default class WebTorrent extends EventEmitter { static WEBRTC_SUPPORT: boolean; static VERSION: string; constructor(opts?: WebTorrentOptions); torrents: Torrent[]; torrentPort: number; destroyed: boolean; add(torrentId: Uint8Array | string, opts?: AddOptions, onTorrent?: (t: Torrent) => void): Torrent; seed(input: string | Uint8Array, opts?: Record, onSeed?: (t: Torrent) => void): Torrent; remove(torrentId: Torrent | string, opts?: { destroyStore?: boolean } | null, cb?: (err?: Error | null) => void): Promise; throttleUpload(rate: number): void; destroy(cb?: (err?: Error | null) => void): void; address(): { address: string; family: string; port: number } | null; } } declare module "bittorrent-tracker" { import type { EventEmitter } from "node:events"; export type ScrapeData = { announce: string; infoHash: string; complete: number; incomplete: number; downloaded: number }; export class Client extends EventEmitter { static scrape( opts: { announce: string; infoHash: string | string[] }, cb: (err: Error | null, data: ScrapeData | Record) => void, ): Client; destroy(cb?: () => void): void; } export type ServerOptions = { http?: boolean; udp?: boolean; ws?: boolean; stats?: boolean; trustProxy?: boolean; interval?: number; filter?: (infoHash: string, params: unknown, cb: (err?: Error | null) => void) => void; }; export class Server extends EventEmitter { constructor(opts?: ServerOptions); torrents: Record; listen(port: number, hostname: string, cb?: () => void): void; address(): { address: string; port: number } | null; http: { address(): { address: string; port: number } | null } | null; close(cb?: () => void): void; } export default Client; } declare module "parse-torrent" { export type ParsedTorrent = { infoHash: string; name?: string; length?: number; pieceLength?: number; announce?: string[]; urlList?: string[]; created?: Date; createdBy?: string; comment?: string; private?: boolean; info?: Record; files?: { path: string; name: string; length: number; offset: number }[]; }; export default function parseTorrent(torrent: Uint8Array | string): Promise; export function toTorrentFile(parsed: ParsedTorrent): Uint8Array; export function toMagnetURI(parsed: Partial): string; }