feat: esm (#431)

BREAKING CHANGE: ESM only

* feat: esm

* fix: linter oops
This commit is contained in:
Cas 2022-12-05 23:06:54 +01:00 committed by GitHub
parent 4b5299b691
commit e6d3189edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 186 additions and 165 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
const minimist = require('minimist') import minimist from 'minimist'
const Server = require('../').Server import { Server } from '../index.js'
const argv = minimist(process.argv.slice(2), { const argv = minimist(process.argv.slice(2), {
alias: { alias: {

View File

@ -1,14 +1,16 @@
const debug = require('debug')('bittorrent-tracker:client') import Debug from 'debug'
const EventEmitter = require('events') import EventEmitter from 'events'
const once = require('once') import once from 'once'
const parallel = require('run-parallel') import parallel from 'run-parallel'
const Peer = require('simple-peer') import Peer from 'simple-peer'
const queueMicrotask = require('queue-microtask') import queueMicrotask from 'queue-microtask'
const common = require('./lib/common') import common from './lib/common.js'
const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser import HTTPTracker from './lib/client/http-tracker.js' // empty object in browser
const UDPTracker = require('./lib/client/udp-tracker') // empty object in browser import UDPTracker from './lib/client/udp-tracker.js' // empty object in browser
const WebSocketTracker = require('./lib/client/websocket-tracker') import WebSocketTracker from './lib/client/websocket-tracker.js'
const debug = Debug('bittorrent-tracker:client')
/** /**
* BitTorrent tracker client. * BitTorrent tracker client.
@ -289,4 +291,4 @@ Client.scrape = (opts, cb) => {
return client return client
} }
module.exports = Client export default Client

View File

@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
const Server = require('../..').Server import { Server } from '../../index.js'
const express = require('express') import express from 'express'
const app = express() const app = express()
// https://wiki.theory.org/BitTorrentSpecification#peer_id // https://wiki.theory.org/BitTorrentSpecification#peer_id

View File

@ -1,7 +1,6 @@
/*! bittorrent-tracker. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */ /*! bittorrent-tracker. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
const Client = require('./client') import Client from './client.js'
const Server = require('./server') import Server from './server.js'
module.exports = Client export default Client
module.exports.Client = Client export { Client, Server }
module.exports.Server = Server

View File

@ -1,14 +1,15 @@
const arrayRemove = require('unordered-array-remove') import arrayRemove from 'unordered-array-remove'
const bencode = require('bencode') import bencode from 'bencode'
const clone = require('clone') import clone from 'clone'
const compact2string = require('compact2string') import Debug from 'debug'
const debug = require('debug')('bittorrent-tracker:http-tracker') import get from 'simple-get'
const get = require('simple-get') import Socks from 'socks'
const Socks = require('socks')
const common = require('../common') import common from '../common.js'
const Tracker = require('./tracker') import Tracker from './tracker.js'
import compact2string from 'compact2string'
const debug = Debug('bittorrent-tracker:http-tracker')
const HTTP_SCRAPE_SUPPORT = /\/(announce)[^/]*$/ const HTTP_SCRAPE_SUPPORT = /\/(announce)[^/]*$/
/** /**
@ -256,4 +257,4 @@ class HTTPTracker extends Tracker {
HTTPTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes HTTPTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes
module.exports = HTTPTracker export default HTTPTracker

View File

@ -1,4 +1,4 @@
const EventEmitter = require('events') import EventEmitter from 'events'
class Tracker extends EventEmitter { class Tracker extends EventEmitter {
constructor (client, announceUrl) { constructor (client, announceUrl) {
@ -25,4 +25,4 @@ class Tracker extends EventEmitter {
} }
} }
module.exports = Tracker export default Tracker

View File

@ -1,14 +1,16 @@
const arrayRemove = require('unordered-array-remove') import arrayRemove from 'unordered-array-remove'
const BN = require('bn.js') import BN from 'bn.js'
const clone = require('clone') import clone from 'clone'
const compact2string = require('compact2string') import Debug from 'debug'
const debug = require('debug')('bittorrent-tracker:udp-tracker') import dgram from 'dgram'
const dgram = require('dgram') import randombytes from 'randombytes'
const randombytes = require('randombytes') import Socks from 'socks'
const Socks = require('socks')
const common = require('../common') import common from '../common.js'
const Tracker = require('./tracker') import Tracker from './tracker.js'
import compact2string from 'compact2string'
const debug = Debug('bittorrent-tracker:udp-tracker')
/** /**
* UDP torrent tracker client (for an individual tracker) * UDP torrent tracker client (for an individual tracker)
@ -329,4 +331,4 @@ function toUInt64 (n) {
function noop () {} function noop () {}
module.exports = UDPTracker export default UDPTracker

View File

@ -1,12 +1,14 @@
const clone = require('clone') import clone from 'clone'
const debug = require('debug')('bittorrent-tracker:websocket-tracker') import Debug from 'debug'
const Peer = require('simple-peer') import Peer from 'simple-peer'
const randombytes = require('randombytes') import randombytes from 'randombytes'
const Socket = require('simple-websocket') import Socket from 'simple-websocket'
const Socks = require('socks') import Socks from 'socks'
const common = require('../common') import common from '../common.js'
const Tracker = require('./tracker') import Tracker from './tracker.js'
const debug = Debug('bittorrent-tracker:websocket-tracker')
// Use a socket pool, so tracker clients share WebSocket objects for the same server. // Use a socket pool, so tracker clients share WebSocket objects for the same server.
// In practice, WebSockets are pretty slow to establish, so this gives a nice performance // In practice, WebSockets are pretty slow to establish, so this gives a nice performance
@ -439,4 +441,4 @@ WebSocketTracker._socketPool = socketPool
function noop () {} function noop () {}
module.exports = WebSocketTracker export default WebSocketTracker

View File

@ -3,23 +3,23 @@
* These are separate from common.js so they can be skipped when bundling for the browser. * These are separate from common.js so they can be skipped when bundling for the browser.
*/ */
const querystring = require('querystring') import querystring from 'querystring'
exports.IPV4_RE = /^[\d.]+$/ export const IPV4_RE = /^[\d.]+$/
exports.IPV6_RE = /^[\da-fA-F:]+$/ export const IPV6_RE = /^[\da-fA-F:]+$/
exports.REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/ export const REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/
exports.CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)]) export const CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)])
exports.ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 } export const ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 }
exports.EVENTS = { update: 0, completed: 1, started: 2, stopped: 3, paused: 4 } export const EVENTS = { update: 0, completed: 1, started: 2, stopped: 3, paused: 4 }
exports.EVENT_IDS = { export const EVENT_IDS = {
0: 'update', 0: 'update',
1: 'completed', 1: 'completed',
2: 'started', 2: 'started',
3: 'stopped', 3: 'stopped',
4: 'paused' 4: 'paused'
} }
exports.EVENT_NAMES = { export const EVENT_NAMES = {
update: 'update', update: 'update',
completed: 'complete', completed: 'complete',
started: 'start', started: 'start',
@ -31,20 +31,19 @@ exports.EVENT_NAMES = {
* Client request timeout. How long to wait before considering a request to a * Client request timeout. How long to wait before considering a request to a
* tracker server to have timed out. * tracker server to have timed out.
*/ */
exports.REQUEST_TIMEOUT = 15000 export const REQUEST_TIMEOUT = 15000
/** /**
* Client destroy timeout. How long to wait before forcibly cleaning up all * Client destroy timeout. How long to wait before forcibly cleaning up all
* pending requests, open sockets, etc. * pending requests, open sockets, etc.
*/ */
exports.DESTROY_TIMEOUT = 1000 export const DESTROY_TIMEOUT = 1000
function toUInt32 (n) { export function toUInt32 (n) {
const buf = Buffer.allocUnsafe(4) const buf = Buffer.allocUnsafe(4)
buf.writeUInt32BE(n, 0) buf.writeUInt32BE(n, 0)
return buf return buf
} }
exports.toUInt32 = toUInt32
/** /**
* `querystring.parse` using `unescape` instead of decodeURIComponent, since bittorrent * `querystring.parse` using `unescape` instead of decodeURIComponent, since bittorrent
@ -52,7 +51,7 @@ exports.toUInt32 = toUInt32
* @param {string} q * @param {string} q
* @return {Object} * @return {Object}
*/ */
exports.querystringParse = q => querystring.parse(q, null, null, { decodeURIComponent: unescape }) export const querystringParse = q => querystring.parse(q, null, null, { decodeURIComponent: unescape })
/** /**
* `querystring.stringify` using `escape` instead of encodeURIComponent, since bittorrent * `querystring.stringify` using `escape` instead of encodeURIComponent, since bittorrent
@ -60,7 +59,7 @@ exports.querystringParse = q => querystring.parse(q, null, null, { decodeURIComp
* @param {Object} obj * @param {Object} obj
* @return {string} * @return {string}
*/ */
exports.querystringStringify = obj => { export const querystringStringify = obj => {
let ret = querystring.stringify(obj, null, null, { encodeURIComponent: escape }) let ret = querystring.stringify(obj, null, null, { encodeURIComponent: escape })
ret = ret.replace(/[@*/+]/g, char => // `escape` doesn't encode the characters @*/+ so we do it manually ret = ret.replace(/[@*/+]/g, char => // `escape` doesn't encode the characters @*/+ so we do it manually
`%${char.charCodeAt(0).toString(16).toUpperCase()}`) `%${char.charCodeAt(0).toString(16).toUpperCase()}`)

View File

@ -1,18 +1,19 @@
/** /**
* Functions/constants needed by both the client and server. * Functions/constants needed by both the client and server.
*/ */
import * as common from './common-node.js'
exports.DEFAULT_ANNOUNCE_PEERS = 50 export const DEFAULT_ANNOUNCE_PEERS = 50
exports.MAX_ANNOUNCE_PEERS = 82 export const MAX_ANNOUNCE_PEERS = 82
exports.binaryToHex = str => { export const binaryToHex = str => {
if (typeof str !== 'string') { if (typeof str !== 'string') {
str = String(str) str = String(str)
} }
return Buffer.from(str, 'binary').toString('hex') return Buffer.from(str, 'binary').toString('hex')
} }
exports.hexToBinary = str => { export const hexToBinary = str => {
if (typeof str !== 'string') { if (typeof str !== 'string') {
str = String(str) str = String(str)
} }
@ -31,7 +32,7 @@ exports.hexToBinary = str => {
// Bug reports: // Bug reports:
// - Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=734880 // - Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=734880
// - Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1374505 // - Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1374505
exports.parseUrl = str => { export const parseUrl = str => {
const url = new URL(str.replace(/^udp:/, 'http:')) const url = new URL(str.replace(/^udp:/, 'http:'))
if (str.match(/^udp:/)) { if (str.match(/^udp:/)) {
@ -45,5 +46,11 @@ exports.parseUrl = str => {
return url return url
} }
const config = require('./common-node') export default {
Object.assign(exports, config) DEFAULT_ANNOUNCE_PEERS,
MAX_ANNOUNCE_PEERS,
binaryToHex,
hexToBinary,
parseUrl,
...common
}

View File

@ -1,6 +1,6 @@
module.exports = parseHttpRequest import common from '../common.js'
const common = require('../common') export default parseHttpRequest
function parseHttpRequest (req, opts) { function parseHttpRequest (req, opts) {
if (!opts) opts = {} if (!opts) opts = {}

View File

@ -1,7 +1,7 @@
module.exports = parseUdpRequest import ipLib from 'ip'
import common from '../common.js'
const ipLib = require('ip') export default parseUdpRequest
const common = require('../common')
function parseUdpRequest (msg, rinfo) { function parseUdpRequest (msg, rinfo) {
if (msg.length < 16) throw new Error('received packet is too short') if (msg.length < 16) throw new Error('received packet is too short')

View File

@ -1,6 +1,6 @@
module.exports = parseWebSocketRequest import common from '../common.js'
const common = require('../common') export default parseWebSocketRequest
function parseWebSocketRequest (socket, opts, params) { function parseWebSocketRequest (socket, opts, params) {
if (!opts) opts = {} if (!opts) opts = {}

View File

@ -1,7 +1,9 @@
const arrayRemove = require('unordered-array-remove') import arrayRemove from 'unordered-array-remove'
const debug = require('debug')('bittorrent-tracker:swarm') import Debug from 'debug'
const LRU = require('lru') import LRU from 'lru'
const randomIterate = require('random-iterate') import randomIterate from 'random-iterate'
const debug = Debug('bittorrent-tracker:swarm')
// Regard this as the default implementation of an interface that you // Regard this as the default implementation of an interface that you
// need to support when overriding Server.createSwarm() and Server.getSwarm() // need to support when overriding Server.createSwarm() and Server.getSwarm()
@ -159,4 +161,4 @@ class Swarm {
} }
} }
module.exports = Swarm export default Swarm

View File

@ -25,6 +25,7 @@
"bugs": { "bugs": {
"url": "https://github.com/webtorrent/bittorrent-tracker/issues" "url": "https://github.com/webtorrent/bittorrent-tracker/issues"
}, },
"type": "module",
"dependencies": { "dependencies": {
"bencode": "^2.0.1", "bencode": "^2.0.1",
"bittorrent-peerid": "^1.3.3", "bittorrent-peerid": "^1.3.3",
@ -60,7 +61,10 @@
"wrtc": "0.4.7" "wrtc": "0.4.7"
}, },
"engines": { "engines": {
"node": ">=12" "node": ">=12.20.0"
},
"exports": {
"import": "./index.js"
}, },
"keywords": [ "keywords": [
"bittorrent", "bittorrent",

View File

@ -1,19 +1,21 @@
const bencode = require('bencode') import bencode from 'bencode'
const debug = require('debug')('bittorrent-tracker:server') import Debug from 'debug'
const dgram = require('dgram') import dgram from 'dgram'
const EventEmitter = require('events') import EventEmitter from 'events'
const http = require('http') import http from 'http'
const peerid = require('bittorrent-peerid') import peerid from 'bittorrent-peerid'
const series = require('run-series') import series from 'run-series'
const string2compact = require('string2compact') import string2compact from 'string2compact'
const WebSocketServer = require('ws').Server import ws from 'ws'
const common = require('./lib/common') import common from './lib/common.js'
const Swarm = require('./lib/server/swarm') import Swarm from './lib/server/swarm.js'
const parseHttpRequest = require('./lib/server/parse-http') import parseHttpRequest from './lib/server/parse-http.js'
const parseUdpRequest = require('./lib/server/parse-udp') import parseUdpRequest from './lib/server/parse-udp.js'
const parseWebSocketRequest = require('./lib/server/parse-websocket') import parseWebSocketRequest from './lib/server/parse-websocket.js'
const { Server: WebSocketServer } = ws
const debug = Debug('bittorrent-tracker:server')
const hasOwnProperty = Object.prototype.hasOwnProperty const hasOwnProperty = Object.prototype.hasOwnProperty
/** /**
@ -805,4 +807,4 @@ function toNumber (x) {
function noop () {} function noop () {}
module.exports = Server export default Server

View File

@ -1,7 +1,7 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const test = require('tape') import test from 'tape'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')

View File

@ -1,8 +1,8 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const magnet = require('magnet-uri') import magnet from 'magnet-uri'
const test = require('tape') import test from 'tape'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')

View File

@ -1,7 +1,7 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const test = require('tape') import test from 'tape'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')
const port = 6681 const port = 6681

View File

@ -1,9 +1,9 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const http = require('http') import http from 'http'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const net = require('net') import net from 'net'
const test = require('tape') import test from 'tape'
const peerId1 = Buffer.from('01234567890123456789') const peerId1 = Buffer.from('01234567890123456789')
const peerId2 = Buffer.from('12345678901234567890') const peerId2 = Buffer.from('12345678901234567890')

View File

@ -1,6 +1,6 @@
const Server = require('../').Server import { Server } from '../index.js'
exports.createServer = (t, opts, cb) => { export const createServer = (t, opts, cb) => {
if (typeof opts === 'string') opts = { serverType: opts } if (typeof opts === 'string') opts = { serverType: opts }
opts.http = (opts.serverType === 'http') opts.http = (opts.serverType === 'http')
@ -27,7 +27,7 @@ exports.createServer = (t, opts, cb) => {
}) })
} }
exports.mockWebsocketTracker = client => { export const mockWebsocketTracker = client => {
client._trackers[0]._generateOffers = (numwant, cb) => { client._trackers[0]._generateOffers = (numwant, cb) => {
const offers = [] const offers = []
for (let i = 0; i < numwant; i++) { for (let i = 0; i < numwant; i++) {
@ -38,3 +38,5 @@ exports.mockWebsocketTracker = client => {
}) })
} }
} }
export default { mockWebsocketTracker, createServer }

View File

@ -1,7 +1,7 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const test = require('tape') import test from 'tape'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')
const port = 6881 const port = 6881

View File

@ -1,7 +1,7 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const test = require('tape') import test from 'tape'
const wrtc = require('wrtc') import wrtc from 'wrtc'
const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')

View File

@ -1,7 +1,7 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const test = require('tape') import test from 'tape'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')

View File

@ -1,5 +1,5 @@
const common = require('../lib/common') import common from '../lib/common.js'
const test = require('tape') import test from 'tape'
// https://github.com/webtorrent/webtorrent/issues/196 // https://github.com/webtorrent/webtorrent/issues/196
test('encode special chars +* in http tracker urls', t => { test('encode special chars +* in http tracker urls', t => {

View File

@ -1,8 +1,8 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const test = require('tape') import test from 'tape'
const Server = require('../server') import Server from '../server.js'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')

View File

@ -1,16 +1,15 @@
const bencode = require('bencode') import bencode from 'bencode'
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const commonLib = require('../lib/common') import commonLib from '../lib/common.js'
const commonTest = require('./common') import fixtures from 'webtorrent-fixtures'
const fixtures = require('webtorrent-fixtures') import get from 'simple-get'
const get = require('simple-get') import test from 'tape'
const test = require('tape')
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')
function testSingle (t, serverType) { function testSingle (t, serverType) {
commonTest.createServer(t, serverType, (server, announceUrl) => { common.createServer(t, serverType, (server, announceUrl) => {
const client = new Client({ const client = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash, infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl, announce: announceUrl,
@ -52,7 +51,7 @@ test('ws: single info_hash scrape', t => {
}) })
function clientScrapeStatic (t, serverType) { function clientScrapeStatic (t, serverType) {
commonTest.createServer(t, serverType, (server, announceUrl) => { common.createServer(t, serverType, (server, announceUrl) => {
const client = Client.scrape({ const client = Client.scrape({
announce: announceUrl, announce: announceUrl,
infoHash: fixtures.leaves.parsedTorrent.infoHash, infoHash: fixtures.leaves.parsedTorrent.infoHash,
@ -116,7 +115,7 @@ function clientScrapeMulti (t, serverType) {
const infoHash1 = fixtures.leaves.parsedTorrent.infoHash const infoHash1 = fixtures.leaves.parsedTorrent.infoHash
const infoHash2 = fixtures.alice.parsedTorrent.infoHash const infoHash2 = fixtures.alice.parsedTorrent.infoHash
commonTest.createServer(t, serverType, (server, announceUrl) => { common.createServer(t, serverType, (server, announceUrl) => {
Client.scrape({ Client.scrape({
infoHash: [infoHash1, infoHash2], infoHash: [infoHash1, infoHash2],
announce: announceUrl announce: announceUrl
@ -156,7 +155,7 @@ test('server: multiple info_hash scrape (manual http request)', t => {
const binaryInfoHash1 = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash) const binaryInfoHash1 = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash)
const binaryInfoHash2 = commonLib.hexToBinary(fixtures.alice.parsedTorrent.infoHash) const binaryInfoHash2 = commonLib.hexToBinary(fixtures.alice.parsedTorrent.infoHash)
commonTest.createServer(t, 'http', (server, announceUrl) => { common.createServer(t, 'http', (server, announceUrl) => {
const scrapeUrl = announceUrl.replace('/announce', '/scrape') const scrapeUrl = announceUrl.replace('/announce', '/scrape')
const url = `${scrapeUrl}?${commonLib.querystringStringify({ const url = `${scrapeUrl}?${commonLib.querystringStringify({
@ -192,7 +191,7 @@ test('server: all info_hash scrape (manual http request)', t => {
const binaryInfoHash = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash) const binaryInfoHash = commonLib.hexToBinary(fixtures.leaves.parsedTorrent.infoHash)
commonTest.createServer(t, 'http', (server, announceUrl) => { common.createServer(t, 'http', (server, announceUrl) => {
const scrapeUrl = announceUrl.replace('/announce', '/scrape') const scrapeUrl = announceUrl.replace('/announce', '/scrape')
// announce a torrent to the tracker // announce a torrent to the tracker

View File

@ -1,7 +1,7 @@
const Client = require('../') import Client from '../index.js'
const common = require('./common') import common from './common.js'
const test = require('tape') import test from 'tape'
const wrtc = require('wrtc') import wrtc from 'wrtc'
const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' const infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705'
const peerId = Buffer.from('01234567890123456789') const peerId = Buffer.from('01234567890123456789')

View File

@ -1,8 +1,8 @@
const Client = require('../') import Client from '../index.js'
const commonTest = require('./common') import commonTest from './common.js'
const fixtures = require('webtorrent-fixtures') import fixtures from 'webtorrent-fixtures'
const get = require('simple-get') import get from 'simple-get'
const test = require('tape') import test from 'tape'
const peerId = Buffer.from('-WW0091-4ea5886ce160') const peerId = Buffer.from('-WW0091-4ea5886ce160')
const unknownPeerId = Buffer.from('01234567890123456789') const unknownPeerId = Buffer.from('01234567890123456789')