# libp2p-websocket-star

> libp2p-webrtc-star without webrtc. Just plain socket.io.

Latest version **0.10.2** (published 2019-01-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install libp2p-websocket-star
pnpm add libp2p-websocket-star
yarn add libp2p-websocket-star
bun add libp2p-websocket-star
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.10.2 |
| Published | 2019-01-10 |
| First published | 2017-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 6.4 MB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 39 |
| Maintainers | daviddias, mkg20001 |
| Keywords | libp2p, transport, websocket |

## Links

- npm: https://www.npmjs.com/package/libp2p-websocket-star
- Repository: https://github.com/libp2p/js-libp2p-websocket-star
- Homepage: https://github.com/libp2p/js-libp2p-websocket-star#readme
- Issues: https://github.com/libp2p/js-libp2p-websocket-star/issues
- npm.io page: https://npm.io/package/libp2p-websocket-star

## Dependencies (14)

- [once](https://npm.io/package/once.md) ^1.4.0
- [async](https://npm.io/package/async.md) ^2.6.1
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [mafmt](https://npm.io/package/mafmt.md) ^6.0.4
- [nanoid](https://npm.io/package/nanoid.md) ^2.0.0
- [peer-id](https://npm.io/package/peer-id.md) ~0.12.2
- [class-is](https://npm.io/package/class-is.md) ^1.1.0
- [multiaddr](https://npm.io/package/multiaddr.md) ^6.0.3
- [peer-info](https://npm.io/package/peer-info.md) ~0.15.1
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.9
- [libp2p-crypto](https://npm.io/package/libp2p-crypto.md) ~0.16.0
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.1.1
- [interface-connection](https://npm.io/package/interface-connection.md) ~0.3.2
- [socket.io-pull-stream](https://npm.io/package/socket.io-pull-stream.md) ~0.1.5

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.10.2 (latest) — 2019-01-10
- 0.10.1 — 2019-01-04
- 0.10.0 — 2018-11-28
- 0.9.1 — 2018-11-26
- 0.9.0 — 2018-10-02
- 0.8.1 — 2018-06-19
- 0.8.0 — 2018-04-05
- 0.7.7 — 2018-02-20
- 0.7.6 — 2018-02-12
- 0.7.5 — 2018-02-12
- 0.7.2 — 2017-12-05
- 0.7.1 — 2017-11-30
- 0.7.0 — 2017-11-30
- 0.6.0 — 2017-11-27
- 0.5.1 — 2017-11-19
- … 20 more at https://npm.io/package/libp2p-websocket-star/versions

## README

# libp2p-websocket-star

[![](https://img.shields.io/badge/made%20by-mkg20001-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Travis](https://travis-ci.org/libp2p/js-libp2p-websocket-star.svg?style=flat-square)](https://travis-ci.org/libp2p/js-libp2p-websocket-star)
[![Circle](https://circleci.com/gh/libp2p/js-libp2p-websocket-star.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-websocket-star)
[![Coverage](https://coveralls.io/repos/github/libp2p/js-libp2p-websocket-star/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-websocket-star?branch=master)
[![david-dm](https://david-dm.org/libp2p/js-libp2p-websocket-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star)

[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/interface-transport)
[![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)](https://github.com/libp2p/interface-connection)
[![](https://github.com/libp2p/interface-peer-discovery/raw/master/img/badge.png)](https://github.com/libp2p/interface-peer-discovery)

> libp2p-webrtc-star without webrtc. Just  WebSockets with a relay point in the middle.

## Lead Maintainer

[Jacob Heun](https://github.com/jacobheun)

## Description

`libp2p-websocket-star` is one of the multiple transports available for libp2p. `libp2p-websocket-star` incorporates both a transport and a discovery service that is facilitated by the rendezvous server, also available in this repo and module.

## Usage

### Example

```
TODO
```

### Install

```bash
> npm install libp2p-websocket-star
```

### API

### Transport

[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/interface-transport)

### Connection

[![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)](https://github.com/libp2p/interface-connection)

### Peer Discovery - `ws.discovery`

[![](https://github.com/libp2p/interface-peer-discovery/raw/master/img/badge.png)](https://github.com/libp2p/interface-peer-discovery)

### Example

```js
const libp2p = require("libp2p")
const Id = require("peer-id")
const Info = require("peer-info")
const multiaddr = require("multiaddr")
const pull = require('pull-stream')

const WSStar = require('libp2p-websocket-star')

Id.create((err, id) => {
  if (err) throw err

  const peerInfo = new Info(id)
  peerInfo.multiaddrs.add(multiaddr("/dns4/ws-star-signal-1.servep2p.com/tcp/443/wss/p2p-websocket-star/"))

  // TODO -> review why the ID can not be passed by the .listen call
  const ws = new WSStar({ id: id }) // the id is required for the crypto challenge

  const modules = {
    transport: [
      ws
    ],
    discovery: [
      ws.discovery
    ]
  }

  const node = new libp2p(modules, peerInfo)

  node.handle("/test/1.0.0", (protocol, conn) => {
    pull(
      pull.values(['hello']),
      conn,
      pull.map((s) => s.toString()),
      pull.log()
    )
  })

  node.start((err) => {
    if (err) {
      throw err
    }

    node.dial(peerInfo, "/test/1.0.0", (err, conn) => {
      if (err) {
        throw err
      }

      pull(
        pull.values(['hello from the other side']),
        conn,
        pull.map((s) => s.toString()),
        pull.log()
      )
    })
  })
})
```

Outputs:
```
hello
hello from the other side
```

## [Rendezvous server](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#usage)

## Usage

To reduce dependencies `libp2p-websocket-star` comes without the rendezvous server, that means that you need to install `libp2p-websocket-star-rendezvous` to start a rendezvous server. To do that, first install the module globally in your machine with:

```bash
> npm install --global libp2p-websocket-star-rendezvous
```

This will install a `rendezvous` CLI tool. Now you can spawn the server with:

```bash
> rendezvous --port=9090 --host=127.0.0.1
```

Defaults:

- `port` - 13579
- `host` - '0.0.0.0'

## Hosted Rendezvous server

We host a rendezvous server at `/dns4/ws-star.discovery.libp2p.io` that can be used for practical demos and experimentation, it **should not be used for apps in production**.

A libp2p-websocket-star address, using the signalling server we provide, looks like:

`/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star/ipfs/<your-peer-id>`

Note: The address above indicates WebSockets Secure, which can be accessed from both http and https.

LICENSE MIT

---
_Source: https://npm.io/package/libp2p-websocket-star · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
