npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shh-signal

v1.0.1

Published

**Decentralized signalling for [simple-peer](https://github.com/feross/simple-peer) using the [Ethereum Whisper protocol](https://github.com/ethereum/wiki/wiki/Whisper-Overview).**

Downloads

6

Readme

shh-signal

Decentralized signalling for simple-peer using the Ethereum Whisper protocol.

Still an open research project, but it works! If you have a local node, try the demo!

Features

  • All signalling data is sent over Whisper. Only STUN servers are used.
  • Video, voice, data and all the features of WebRTC work as normal.
  • Adapts almost all client features from simple-signal.
  • Takes advantage of Whisper's probablistic routing to help obscure identity until a WebRTC connection is accepted.

Install

With Browserify:

npm install shh-signal --save

Without Browserify:

<script src="dist/shh-signal-client.js"></script>

You also need access to the global Web3 object. shh-signal is currently only tested with the version in dist/web3.min.js.

You will also need a local Ethereum node with Websockets JSON-RPC and Whisper enabled.

Example

A common signaling scheme is to connect two clients by having one client "call" the ID of another.

Client:

const web3 = new Web3(new Web3.providers.WebsocketProvider('ws://localhost:8546')) // setup web3
const signalClient = new ShhSignalClient(web3) // setup shh-signal

const allIDs = []
signalClient.on('discover', async (newID) => {
	allIDs.push(newID)

  const id = await promptUserForID(allIDs) // Have the user choose an ID to connect to (you define this)
  const { peer } = await signalClient.connect(id) // connect to target client
  peer // this is a fully-signaled simple-peer object (initiator side)
})

signalClient.on('request', async (request) => {
  const { peer } = await request.accept() // Accept the incoming request
  peer // this is a fully-signaled simple-peer object (non-initiator side)
})

See example.js for a more comprehensive example.

Client API

signalClient = new ShhSignalClient(web3, [options])

Create a new signalling client.

Required web3 is a web3 instance with a provider that supports both Whisper and subscriptions (such as a WebsocketProvider connected to a local geth node started with the --shh option).

Options:

  • connectionTimeout: number = 10000: Defines the time to wait to establish a connection.
  • roomPassword": string = "": A secret passphrase used to encrypt connection messages.

signalClient.id

The identifying string for this client's socket. null until discovery completes. Consists of 2 public keys pubKey and sig, used for encryption and signing respectively.

signalClient.discover(discoveryData)

Initiate discovery.

discoveryData is any discovery data to be sent to all peers with the room password.

{ peer, metadata } = await signalClient.connect(id, [metadata], [peerOptions])

Request to connect to another client. Returns a Promise.

id is the signalClient.id of the other client.

Optional metadata is any serializable object to be passed along with the request.

Optional peerOptions are the options to be passed to the SimplePeer constructor.

signalClient.on('discover', function (remoteID, discoveryData) {})

Fired when the client has discovered a remote peer with the room password, or that peer has restarted discovery.

remoteID is the remote ID of the new peer.

discoveryData is any additional data that has been passed by the remote peer.

signalClient.on('request', function (request) {})

Fired on receiving a request to connect from another client.

request.initiator

The id of the remote client's socket.

request.metadata

Any additional metadata passed by the requesting client.

{ peer, metadata } = await request.accept([metadata], [peerOptions])

Accept the request to connect. Not calling this method will ignore the request. Returns a Promise.

metadata is any serializable object to be passed along with the answer.

peerOptions are the options to be passed to the SimplePeer constructor.

Promise will reject if the other side calls reject().

request.reject([metadata])

Rejects the request to connect. Not calling this method will ignore the request.

metadata is any serializable object to be passed along with the rejection.

signalClient.peers()

List all currently connecting/connected peers. Returns an array of SimplePeer objects.

FAQ

How do I setup the local Ethereum Node?

  1. Download Grid: https://grid.ethereum.org/#downloads
  2. Install and launch Grid.
  3. Go to Geth > Settings and enable Use custom flags.
  4. Add these flags to enable Websockets and Whisper:
--ws --wsorigins=* --shh
  1. Start Geth and wait for the node to sync.
  2. Done! You can now use this library to connect to everyone else on the Ethereum Whisper network!