Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@deconet/libp2p-webrtc-direct

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deconet/libp2p-webrtc-direct

Dial using WebRTC without the need to set up any Signalling Rendezvous Point!

latest
Source
npmnpm
Version
0.6.1
Version published
Maintainers
1
Created
Source

js-libp2p-webrtc-direct

Discourse posts Dependency Status js-standard-style

A WebRTC transport built for libp2p (not mandatory to use with libp2p) that doesn't require the set up a signalling server. Caveat, you can only establish Browser to Node.js and Node.js to Node.js connections.

Lead Maintainer

Vasco Santos.

Table of Contents

Install

npm

> npm install libp2p-webrtc-direct

Usage

const WebRTCDirect = require('libp2p-webrtc-direct')
const multiaddr = require('multiaddr')
const pipe = require('pull-stream')
const { collect } = require('streaming-iterables')

const addr = multiaddr('/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct')

const webRTCDirect = new WebRTCDirect()

const listener = webRTCDirect.createListener((socket) => {
  console.log('new connection opened')
  pipe(
    ['hello'],
    socket
  )
})

await listener.listen(addr)
console.log('listening')

const conn = await webRTCDirect.dial(addr)
const values = await pipe(
  conn,
  collect
)
console.log(`Value: ${values.toString()}`)

// Close connection after reading
await listener.close()

Outputs:

listening
new connection opened
Value: hello

Note that it may take some time for the connection to be established.

API

Transport

Connection

Contribute

The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:

  • Go through the modules and check out existing issues. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
  • Perform code reviews.
  • Add tests. There can never be enough tests.

License

MIT © Protocol Labs

Keywords

libp2p

FAQs

Package last updated on 13 May 2021

Did you know?

Socket

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.

Install

Related posts