New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hypercore-protocol

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypercore-protocol - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

42

index.js

@@ -114,2 +114,6 @@ var events = require('events')

Channel.prototype.destroy = function (err) {
this.protocol.destroy(err)
}
Channel.prototype._onhandshake = function (handshake) {

@@ -120,3 +124,5 @@ this.protocol._onhandshake(handshake)

extensionNames.forEach(function (name, type) {
if (Channel.prototype[name] || name === 'error') throw new Error('Invalid extension name')
if (Channel.prototype[name] || name === 'error' || name === 'tick') {
throw new Error('Invalid extension name')
}

@@ -183,2 +189,3 @@ var enc = isEncoder(extensions[name]) ? extensions[name] : pe

self._finalized = true
self.destroyed = true // defined by duplexify

@@ -210,3 +217,3 @@ clearInterval(this._interval)

Protocol.prototype.setTimeout = function (ms, ontimeout) {
if (this._finalized) return
if (this.destroyed) return
if (ontimeout) this.once('timeout', ontimeout)

@@ -246,3 +253,3 @@

Protocol.prototype.open = function (key, opts) {
if (this._finalized) return null // already finalized
if (this.destroyed) return null // already finalized
if (!opts) opts = {}

@@ -262,2 +269,4 @@

if (opts.state) ch.state = opts.state
ch.key = key

@@ -331,2 +340,3 @@ ch.local = this._local.indexOf(null)

var self = this
this._pause()

@@ -336,5 +346,9 @@ process.nextTick(drain)

function drain () {
if (self._finalized || channel.closed) return
while (channel.buffer.length) self._parse(channel.buffer.shift())
if (!self._finalized) self._resume()
if (self.destroyed || channel.closed) return
var buffer = channel.buffer
channel.buffer = []
while (buffer.length) self._parse(buffer.shift())
if (!self.destroyed) self._resume()
}

@@ -346,3 +360,3 @@ }

if (!data.length || this._finalized) return
if (!data.length || this.destroyed) return

@@ -360,2 +374,9 @@ var remote = varint.decode(data, 0)

Protocol.prototype._tick = function () {
for (var i = 0; i < this._local.length; i++) {
var ch = this._local[i]
if (ch) ch.emit('tick')
}
}
Protocol.prototype._parseType = function (type) {

@@ -396,3 +417,3 @@ if (type > 127) return -1

if (!this._finalized && ch.local === -1) this.emit('open', ch.discoveryKey)
if (!this.destroyed && ch.local === -1) this.emit('open', ch.discoveryKey)
}

@@ -403,3 +424,3 @@

if (!channel.key) {
if (!channel.key || channel.buffer.length) {
if (channel.buffer.length === 16) return this.destroy(new Error('Buffer overflow'))

@@ -447,3 +468,2 @@ channel.buffer.push(data)

var exts = handshake.extensions
// extensions *must* be sorted

@@ -480,3 +500,3 @@ var local = 0

if (!this._finalized) this._sendRaw(channel, Buffer(0))
if (!this.destroyed) this._sendRaw(channel, Buffer(0))

@@ -483,0 +503,0 @@ this._local[channel.local] = null

{
"name": "hypercore-protocol",
"version": "4.1.0",
"version": "4.2.0",
"description": "Stream that implements the hypercore protocol",

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

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