open-index/open-npm huggingface dataset:
npm package: @m-onz/cohort-channel
Description: p2p channel using webRTC for node & the browser
Author: m-onz
Latest version: 3.0.0


# cohort-channel

Create p2p event emitter for collaborative mesh networks and sneakernets in the browser
 and node.js using WebRTC data channels.

## Create a channel

```js

var Cohort = require('@m-onz/cohort-channel')

var cohort = Cohort ({
  channel: 'demo-channel',
  signalhubs: [ 'http://localhost:9000' ]
})

```

## Reliable event emitter

This is using ```scuttlebutt/events```

```js

cohort.on('demo', console.log)
cohort.emit('demo', 'hello!')

```

## Local signalhub server

You need a local signalhub server for WebRTC signalling and to run the tests.

```sh
npm install signalhub -g
signalhub listen -p 9000
npm test
```

## Events

* peers => number of connected peers
* peer => incoming ```simple-peer``` duplex stream

```js
cohort.on('peers', console.log)
cohort.on('peer', console.log)
```

## Install

```sh
npm i @m-onz/cohort-channel
```
npm package: @m-onz/cohort-id
Description: p2p identity crypto utils
Author: m-onz
Latest version: 2.0.2


# cohort-id

cohort identity and utils uses: https://www.npmjs.com/package/tweetnacl-blake2b

## Create

```js
var Identity = require('@m-onz/cohort-id')

var cohort = Identity()

console.log(cohort.id) // => { secretKey, publicKey }

cohort.hash('hello world!')

```

## Methods

* newEncryptionKey() => generates 32 bit random password
* encrypt ((blob, password) => { box, nonce }
* decrypt (encrypted, nonce, password) => decrypted
* encryptFor (recipient_pk, message) => { box, nonce }
* decryptFrom (public_key, nonce, message) => decrypted
* sign (message) => signature
* verify (publicKey, signature, message) => boolean
* hash (something) => base64 blake2B hash

## Install

```sh
npm install @m-onz/cohort-id --save
```