Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyperswarm

Package Overview
Dependencies
Maintainers
4
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperswarm - npm Package Compare versions

Comparing version 2.15.2 to 2.15.3

2

package.json
{
"name": "hyperswarm",
"version": "2.15.2",
"version": "2.15.3",
"description": "A distributed networking stack for connecting peers",

@@ -5,0 +5,0 @@ "main": "swarm.js",

@@ -27,4 +27,4 @@ # hyperswarm

swarm.on('connection', (socket, details) => {
console.log('new connection!', details)
swarm.on('connection', (socket, info) => {
console.log('new connection!', info)

@@ -121,3 +121,3 @@ // you can now use the socket as a stream, eg:

#### `swarm.connect(peer, (err, socket, details) => {})`
#### `swarm.connect(peer, (err, socket, info) => {})`

@@ -130,3 +130,3 @@ Establish a connection to the given peer. You usually won't need to use this function, because hyperswarm connects to found peers automatically.

- `socket`. The established TCP or UTP socket.
- `details`. Object describing the connection.
- `info`. Object describing the connection.
- `type`. String. Should be either `'tcp'` or `'utp'`.

@@ -155,3 +155,3 @@ - `client`. Boolean. If true, the connection was initiated by this node.

The `details` argument is a `PeerInfo` object, which will emit events of the form `details.on('topic', topic => ...)` when the `multiplex` flag is `true`.
The `info` argument is a `PeerInfo` object, which will emit events of the form `info.on('topic', topic => ...)` when the `multiplex` flag is `true`.

@@ -158,0 +158,0 @@ #### `info.ban()`

@@ -12,3 +12,3 @@ 'use strict'

const ERR_DESTROYED = 'swarm has been destroyed'
const ERR_MISSING_KEY = 'key is required and must be a buffer'
const ERR_MISSING_KEY = 'key is required and must be a 32-byte buffer'
const ERR_JOIN_OPTS = 'join options must enable lookup, announce or both, but not neither'

@@ -188,3 +188,3 @@

if (Buffer.isBuffer(key) === false) throw Error(ERR_MISSING_KEY)
if (Buffer.isBuffer(key) === false || key.length !== 32) throw Error(ERR_MISSING_KEY)

@@ -224,3 +224,3 @@ const { announce = false, lookup = true } = opts

leave (key, onleave) {
if (Buffer.isBuffer(key) === false) throw Error(ERR_MISSING_KEY)
if (Buffer.isBuffer(key) === false || key.length !== 32) throw Error(ERR_MISSING_KEY)
if (this.destroyed) return

@@ -227,0 +227,0 @@

@@ -81,4 +81,5 @@ 'use strict'

await swarm.listen()
throws(() => swarm.join(), Error('key is required and must be a buffer'))
throws(() => swarm.join('not a buffer.'), Error('key is required and must be a buffer'))
throws(() => swarm.join(), Error('key is required and must be a 32-byte buffer'))
throws(() => swarm.join('not a buffer but still 32 bytes.'), Error('key is required and must be a 32-byte buffer'))
throws(() => swarm.join(Buffer.from('buffer but not 32 bytes.')), Error('key is required and must be a 32-byte buffer'))
swarm.destroy()

@@ -91,3 +92,3 @@ })

swarm.network.bind = () => (bind = true)
swarm.join(Buffer.from('key'))
swarm.join(Buffer.from('key-key-key-key-key-key-key-key-'))
is(bind, true)

@@ -101,3 +102,3 @@ swarm.destroy()

swarm.network.bind = (cb) => process.nextTick(cb, fauxError)
swarm.join(Buffer.from('key'))
swarm.join(Buffer.from('key-key-key-key-key-key-key-key-'))
const err = await once(swarm, 'error')

@@ -111,3 +112,3 @@ is(err, fauxError)

var lookupKey = null
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
swarm.network.lookup = (key) => {

@@ -126,3 +127,3 @@ lookupKey = key

var lookupKey = null
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
swarm.network.lookup = (key) => {

@@ -140,3 +141,3 @@ lookupKey = key

const swarm = hyperswarm({ bootstrap: [] })
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
throws(

@@ -151,3 +152,3 @@ () => swarm.join(key, { announce: false, lookup: false }),

const swarm = hyperswarm({ bootstrap: [] })
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
const topic = new EventEmitter()

@@ -167,3 +168,3 @@ swarm.network.lookup = () => topic

const swarm = hyperswarm({ bootstrap: [] })
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
const topic = new EventEmitter()

@@ -187,3 +188,3 @@ const fauxPeer = { port: 8080, host: '127.0.0.1', local: true, referrer: null, topic: key }

var announceKey = null
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
const topic = new EventEmitter()

@@ -212,3 +213,3 @@ const fauxPeer = { port: 8080, host: '127.0.0.1', local: true, referrer: null, topic: key }

var announceKey = null
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
const topic = new EventEmitter()

@@ -237,4 +238,5 @@ const fauxPeer = { port: 8080, host: '127.0.0.1', local: true, referrer: null, topic: key }

await swarm.listen()
throws(() => swarm.leave(), Error('key is required and must be a buffer'))
throws(() => swarm.leave('not a buffer.'), Error('key is required and must be a buffer'))
throws(() => swarm.leave(), Error('key is required and must be a 32-byte buffer'))
throws(() => swarm.leave('not a buffer but still 32 bytes.'), Error('key is required and must be a 32-byte buffer'))
throws(() => swarm.leave(Buffer.from('buffer but not 32 bytes.')), Error('key is required and must be a 32-byte buffer'))
swarm.destroy()

@@ -269,4 +271,4 @@ })

const swarm = hyperswarm({ bootstrap: [] })
const key = Buffer.from('key1')
const key2 = Buffer.from('key2')
const key = Buffer.from('key1key1key1key1key1key1key1key1')
const key2 = Buffer.from('key2key2key2key2key2key2key2key2')
swarm.join(key)

@@ -280,3 +282,3 @@ await once(swarm, 'listening')

const swarm = hyperswarm({ bootstrap: [] })
const key = Buffer.from('key')
const key = Buffer.from('key-key-key-key-key-key-key-key-')
const { lookup } = swarm.network

@@ -283,0 +285,0 @@ var topicDestroyed = false

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc