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

hypercore-protocol-substream

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypercore-protocol-substream - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

npm-shrinkwrap.json

2

index.js

@@ -25,3 +25,3 @@ const _debug = require('debug')

this.cork()
if (typeof key === 'string') key = Buffer.from(key)
this.id = key || randbytes()

@@ -28,0 +28,0 @@ this.state = INIT

{
"name": "hypercore-protocol-substream",
"version": "1.0.0",
"version": "1.0.1",
"description": "Create independent virtual streams on a hypercore-protocol stream",

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

@@ -8,2 +8,5 @@ # hypercore-protocol-substream

```js
// Substreams can be created on any
const substream = require('hypercore-protocol-substream')

@@ -13,3 +16,2 @@ const protocol = require('hypercore-protocol')

// From a replication stream
const core = hypercore(storage, key)

@@ -24,3 +26,3 @@

// Connected event is fired when a virtual stream with the same
// namespace have been initialized by the remote.
// namespace have been initialized on the remote end.
virt1.on('connected', (virt1) => {

@@ -49,10 +51,14 @@ virt1.write('Hello remote!')

// You can listen for incoming streams without any knowledge of the namespace.
stream.on('substream-connected', handshake => {
const connectionHandler = (handshake) => {
if (handshake.payload === 'Please Respond') {
const virtual3 = substream(stream, handshake.id)
virtual3.end('Hey!')
}
})
}
stream.on('substream-connected', connectionHandler)
stream.once('end', () => stream.off('substream-connected', connectionHandler)
// Alternatively create a manual hyperprotocol-stream
/*
* Alternatively create a manual hyperprotocol-stream
*/
const key = Buffer.alloc(32)

@@ -63,2 +69,3 @@ key.write('encryption secret')

const vitual4 = substream(stream2, Buffer.from('dc'))
```

@@ -65,0 +72,0 @@

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