├── .github └── workflows │ ├── ci.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── Dockerfile ├── LICENSE ├── README.md ├── bin └── cmd.js ├── examples ├── node-download.js └── node-seed.js ├── index.js ├── lib └── global.js └── package.json /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | name: Node ${{ matrix.node }} / ${{ matrix.os }} 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | os: 13 | - ubuntu-latest 14 | node: 15 | - '16' 16 | steps: 17 | - uses: actions/checkout@v3 18 | - uses: actions/setup-node@v3 19 | with: 20 | node-version: ${{ matrix.node }} 21 | - run: npm install 22 | - run: npm run build --if-present 23 | - run: npm test 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | name: Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | with: 16 | persist-credentials: false 17 | - name: Setup Node.js 18 | uses: actions/setup-node@v3 19 | with: 20 | node-version: 18 21 | - name: Cache 22 | uses: actions/cache@v3 23 | with: 24 | path: ~/.npm 25 | key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }} 26 | restore-keys: | 27 | ${{ runner.os }}-npm- 28 | - name: Install dependencies 29 | env: 30 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 31 | run: npm i 32 | - name: Release 33 | env: 34 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 35 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 36 | run: npx semantic-release 37 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: '0 12 * * *' 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | pull-requests: write 13 | 14 | steps: 15 | - uses: actions/stale@v8 16 | with: 17 | repo-token: ${{ secrets.GITHUB_TOKEN }} 18 | stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' 19 | stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' 20 | exempt-issue-labels: accepted,blocked,bug,security,meta 21 | exempt-pr-labels: accepted,blocked,bug,'help wanted',security,meta 22 | stale-issue-label: 'stale' 23 | stale-pr-label: 'stale' 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | examples/ 2 | .github/ 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [6.0.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.2...v6.0.0) (2024-06-02) 2 | 3 | 4 | * BREAKING CHANGE: Deprecate webtorrent-hybrid (#195) ([fe511bf](https://github.com/webtorrent/webtorrent-hybrid/commit/fe511bf98a109b5bc7967a2853345a0b23da7b11)), closes [#195](https://github.com/webtorrent/webtorrent-hybrid/issues/195) 5 | 6 | 7 | ### BREAKING CHANGES 8 | 9 | * Deprecate webtorrent-hybrid 10 | 11 | This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the "webtorrent" package. 12 | 13 | * fix: Update ci to use NodeJS 16 to match package.json 14 | 15 | * Update README.md 16 | 17 | Update `Deprecated Warning` to `Deprecation Warning` 18 | 19 | Co-authored-by: Cas_ <6506529+ThaUnknown@users.noreply.github.com> 20 | 21 | * fix: re-add WEBTORRENT_ANNOUNCE which is used for adding websocket trackers to magnetURIs which do not already have them. 22 | 23 | * feat: update webtorrent-cli to v5 24 | 25 | ## [5.0.2](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.1...v5.0.2) (2022-02-01) 26 | 27 | 28 | ### Bug Fixes 29 | 30 | * **deps:** update dependency webtorrent-cli to v4 ([#145](https://github.com/webtorrent/webtorrent-hybrid/issues/145)) ([7da7ddf](https://github.com/webtorrent/webtorrent-hybrid/commit/7da7ddfcb1f163b331f248395319e5fd8ff48752)) 31 | 32 | ## [5.0.1](https://github.com/webtorrent/webtorrent-hybrid/compare/v5.0.0...v5.0.1) (2021-09-14) 33 | 34 | 35 | ### Bug Fixes 36 | 37 | * webrtc import ([#143](https://github.com/webtorrent/webtorrent-hybrid/issues/143)) ([3b5d9bb](https://github.com/webtorrent/webtorrent-hybrid/commit/3b5d9bb0a21fceef76f25a113ebede40fce73338)) 38 | 39 | # [5.0.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.3...v5.0.0) (2021-08-26) 40 | 41 | 42 | ### chore 43 | 44 | * switch to ESM ([#141](https://github.com/webtorrent/webtorrent-hybrid/issues/141)) ([cbe8c3b](https://github.com/webtorrent/webtorrent-hybrid/commit/cbe8c3b8fff52a6fe9c86e531967566c5a889b12)) 45 | 46 | 47 | ### BREAKING CHANGES 48 | 49 | * switch to ESM 50 | 51 | ## [4.1.3](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.2...v4.1.3) (2021-08-18) 52 | 53 | 54 | ### Bug Fixes 55 | 56 | * dockerfile missing dependency ([#137](https://github.com/webtorrent/webtorrent-hybrid/issues/137)) ([2523b48](https://github.com/webtorrent/webtorrent-hybrid/commit/2523b48e1efd580139f27951edb130f96111d8a0)) 57 | 58 | ## [4.1.2](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.1...v4.1.2) (2021-08-06) 59 | 60 | 61 | ### Bug Fixes 62 | 63 | * **deps:** update dependency create-torrent to v5 ([#134](https://github.com/webtorrent/webtorrent-hybrid/issues/134)) ([012f3fd](https://github.com/webtorrent/webtorrent-hybrid/commit/012f3fd702f6cfd70bb6cc29762412f78010daf7)) 64 | 65 | ## [4.1.1](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.1.0...v4.1.1) (2021-07-23) 66 | 67 | 68 | ### Bug Fixes 69 | 70 | * add semantic release, switch CI ([f48c8ca](https://github.com/webtorrent/webtorrent-hybrid/commit/f48c8ca1ae4daa7ebdf5f86e2a59ba29ee3c05e6)) 71 | 72 | # [4.1.0](https://github.com/webtorrent/webtorrent-hybrid/compare/v4.0.3...v4.1.0) (2021-05-31) 73 | 74 | 75 | ### Features 76 | 77 | * renovate and semantic-release, webtorrent@1 ([f175996](https://github.com/webtorrent/webtorrent-hybrid/commit/f175996e4528d57f4c762046291eaf19aee29965)) 78 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:slim 2 | 3 | RUN apt-get update && \ 4 | apt-get full-upgrade -y && \ 5 | apt-get install -y libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb git -y && \ 6 | apt-get autoremove --purge -y && \ 7 | rm -rf /var/lib/apt/lists/* && \ 8 | npm i -g node-pre-gyp 9 | 10 | RUN npm i -g webtorrent-hybrid && \ 11 | mkdir -p /webtorrent 12 | 13 | EXPOSE 8000 14 | WORKDIR /webtorrent 15 | ENTRYPOINT ["/usr/local/bin/webtorrent-hybrid"] 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecation Warning 2 | This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the "webtorrent" package. 3 | 4 | # webtorrent-hybrid [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] 5 | 6 | [ci-image]: https://github.com/webtorrent/webtorrent-hybrid/actions/workflows/ci.yml/badge.svg 7 | [ci-url]: https://github.com/webtorrent/webtorrent-hybrid/actions/workflows/ci.yml 8 | [npm-image]: https://img.shields.io/npm/v/webtorrent-hybrid.svg 9 | [npm-url]: https://npmjs.org/package/webtorrent-hybrid 10 | [downloads-image]: https://img.shields.io/npm/dm/webtorrent-hybrid.svg 11 | [downloads-url]: https://npmjs.org/package/webtorrent-hybrid 12 | [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg 13 | [standard-url]: https://standardjs.com 14 | 15 | ### Streaming torrent client (with WebRTC support in Node.js) 16 | 17 | In node.js, the `webtorrent` package only connects to normal TCP/UDP peers, not WebRTC peers. If you want to connect to all types of peers, including WebRTC peers, from node.js, you need to use this package (`webtorrent-hybrid`). 18 | 19 | ## Install 20 | 21 | To install WebTorrent: 22 | 23 | ```bash 24 | npm install webtorrent-hybrid 25 | ``` 26 | 27 | To install a `webtorrent-hybrid` command line program, run: 28 | 29 | ```bash 30 | npm install webtorrent-hybrid -g 31 | ``` 32 | 33 | ## Usage 34 | 35 | `webtorrent-hybrid` has the same command line interface (CLI) and module API as 36 | [`webtorrent`](https://github.com/webtorrent/webtorrent). Just `import WebTorrent from 'webtorrent-hybrid'` 37 | instead of `import WebTorrent from 'webtorrent'`. 38 | 39 | See the [WebTorrent docs](https://webtorrent.io/docs). 40 | 41 | ## License 42 | 43 | MIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org) and [WebTorrent, LLC](https://webtorrent.io). 44 | -------------------------------------------------------------------------------- /bin/cmd.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import '../lib/global.js' 4 | import 'webtorrent-cli/bin/cmd.js' 5 | -------------------------------------------------------------------------------- /examples/node-download.js: -------------------------------------------------------------------------------- 1 | import WebTorrent from '../index.js' 2 | import fs from 'fs' 3 | 4 | const client = new WebTorrent() 5 | 6 | const torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d' 7 | 8 | console.log('torrentId:\t', torrentId) 9 | 10 | client.add(torrentId, torrent => { 11 | const files = torrent.files 12 | let length = files.length 13 | // Stream each file to the disk 14 | files.forEach(file => { 15 | const source = file.createReadStream() 16 | const destination = fs.createWriteStream(file.name) 17 | source.on('end', () => { 18 | console.log('file:\t\t', file.name) 19 | // close after all files are saved 20 | length -= 1 21 | if (!length) process.exit() 22 | }).pipe(destination) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /examples/node-seed.js: -------------------------------------------------------------------------------- 1 | import WebTorrent from '../index.js' 2 | 3 | const client = new WebTorrent() 4 | const filePath = __filename 5 | 6 | console.log('filePath:', filePath) 7 | 8 | client.seed(filePath, torrent => { 9 | console.log('torrentId (info hash):', torrent.infoHash) 10 | // console.log('torrentId (magnet link):', torrent.magnetURI) 11 | }) 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /*! webtorrent-hybrid. MIT License. WebTorrent LLC */ 2 | import './lib/global.js' 3 | export { default } from 'webtorrent' 4 | -------------------------------------------------------------------------------- /lib/global.js: -------------------------------------------------------------------------------- 1 | import { announceList } from 'create-torrent' 2 | 3 | globalThis.WEBTORRENT_ANNOUNCE = announceList 4 | .map(arr => arr[0]) 5 | .filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0) 6 | 7 | console.warn('webtorrent-hybrid: This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the "webtorrent" package.') 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webtorrent-hybrid", 3 | "type": "module", 4 | "description": "Streaming torrent client", 5 | "version": "6.0.0", 6 | "author": { 7 | "name": "WebTorrent LLC", 8 | "email": "feross@webtorrent.io", 9 | "url": "https://webtorrent.io" 10 | }, 11 | "bin": "./bin/cmd.js", 12 | "bugs": { 13 | "url": "https://github.com/webtorrent/webtorrent-hybrid/issues" 14 | }, 15 | "deprecated": "This package is deprecated as of WebTorrent >= 2.3.0 as native WebRTC support has been added to WebTorrent. Please switch to using the \"webtorrent\" package.", 16 | "dependencies": { 17 | "create-torrent": "^6.0.17", 18 | "webtorrent": "^2.3.0", 19 | "webtorrent-cli": "^5.0.0" 20 | }, 21 | "devDependencies": { 22 | "@webtorrent/semantic-release-config": "1.0.10", 23 | "semantic-release": "21.1.2", 24 | "standard": "*" 25 | }, 26 | "engines": { 27 | "node": ">=16" 28 | }, 29 | "homepage": "https://webtorrent.io", 30 | "keywords": [ 31 | "bittorrent", 32 | "bittorrent client", 33 | "download", 34 | "mad science", 35 | "streaming", 36 | "torrent", 37 | "webrtc", 38 | "webrtc data", 39 | "webtorrent" 40 | ], 41 | "license": "MIT", 42 | "exports": "./index.js", 43 | "repository": { 44 | "type": "git", 45 | "url": "git://github.com/webtorrent/webtorrent-hybrid.git" 46 | }, 47 | "scripts": { 48 | "test": "standard" 49 | }, 50 | "funding": [ 51 | { 52 | "type": "github", 53 | "url": "https://github.com/sponsors/feross" 54 | }, 55 | { 56 | "type": "patreon", 57 | "url": "https://www.patreon.com/feross" 58 | }, 59 | { 60 | "type": "consulting", 61 | "url": "https://feross.org/support" 62 | } 63 | ], 64 | "renovate": { 65 | "extends": [ 66 | "github>webtorrent/renovate-config" 67 | ] 68 | }, 69 | "release": { 70 | "extends": "@webtorrent/semantic-release-config" 71 | } 72 | } 73 | --------------------------------------------------------------------------------