
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@libp2p/interface-stream-muxer
Advanced tools
Stream Muxer interface for libp2p
$ npm i @libp2p/interface-stream-muxer
The primary goal of this module is to enable developers to pick and swap their stream muxing module as they see fit for their application, without having to go through shims or compatibility issues. This module and test suite was heavily inspired by abstract-blob-store.
Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.
The API is presented with both Node.js and Go primitives, however, there is no actual limitations for it to be extended for any other language, pushing forward the cross compatibility and interop through different stacks.
Send a PR to add a new one if you happen to find or write one.
Include this badge in your readme if you make a new module that uses interface-stream-muxer API.
Install interface-stream-muxer
as one of the dependencies of your project and as a test file. Then, using mocha
(for JavaScript) or a test runner with compatible API, do:
const test = require('libp2p-interfaces-compliance-tests/stream-muxer')
const common = {
async setup () {
return yourMuxer
},
async teardown () {
// cleanup
}
}
// use all of the test suits
test(common)
A valid (one that follows this abstraction) stream muxer, must implement the following API:
const muxer = new Muxer([options])
Create a new duplex stream that can be piped together with a connection in order to allow multiplexed communications.
e.g.
const Muxer = require('your-muxer-module')
import { pipe } from 'it-pipe'
// Create a duplex muxer
const muxer = new Muxer()
// Use the muxer in a pipeline
pipe(conn, muxer, conn) // conn is duplex connection to another peer
options
is an optional Object
that may have the following properties:
onStream
- A function called when receiving a new stream from the remote. e.g.
// Receive a new stream on the muxed connection
const onStream = stream => {
// Read from this stream and write back to it (echo server)
pipe(
stream,
source => (async function * () {
for await (const data of source) yield data
})()
stream
)
}
const muxer = new Muxer({ onStream })
// ...
Note: The onStream
function can be passed in place of the options
object. i.e.
new Mplex(stream => { /* ... */ })
onStreamEnd
- A function called when a stream ends.
// Get notified when a stream has ended
const onStreamEnd = stream => {
// Manage any tracking changes, etc
}
const muxer = new Muxer({ onStreamEnd, ... })
signal
- An AbortSignal
which can be used to abort the muxer, including all of it's multiplexed connections. e.g.
const controller = new AbortController()
const muxer = new Muxer({ signal: controller.signal })
pipe(conn, muxer, conn)
controller.abort()
maxMsgSize
- The maximum size in bytes the data field of multiplexed messages may contain (default 1MB)muxer.onStream
Use this property as an alternative to passing onStream
as an option to the Muxer
constructor.
const muxer = new Muxer()
// ...later
muxer.onStream = stream => { /* ... */ }
muxer.onStreamEnd
Use this property as an alternative to passing onStreamEnd
as an option to the Muxer
constructor.
const muxer = new Muxer()
// ...later
muxer.onStreamEnd = stream => { /* ... */ }
const stream = muxer.newStream([options])
Initiate a new stream with the remote. Returns a duplex stream.
e.g.
// Create a new stream on the muxed connection
const stream = muxer.newStream()
// Use this new stream like any other duplex stream:
pipe([1, 2, 3], stream, consume)
const streams = muxer.streams
The streams property returns an array of streams the muxer currently has open. Closed streams will not be returned.
muxer.streams.map(stream => {
// Log out the stream's id
console.log(stream.id)
})
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
Stream Muxer interface for libp2p
The npm package @libp2p/interface-stream-muxer receives a total of 2,718 weekly downloads. As such, @libp2p/interface-stream-muxer popularity was classified as popular.
We found that @libp2p/interface-stream-muxer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.