https://github.com/soyuka/native-messaging-swarm
TCP/UDP swarm on top of WebExtension's native messaging protocol
https://github.com/soyuka/native-messaging-swarm
bridge dat-project hyperdrive swarm tcp udp
Last synced: about 2 months ago
JSON representation
TCP/UDP swarm on top of WebExtension's native messaging protocol
- Host: GitHub
- URL: https://github.com/soyuka/native-messaging-swarm
- Owner: soyuka
- Created: 2018-05-09T16:44:37.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-12T17:15:53.000Z (almost 8 years ago)
- Last Synced: 2025-10-22T07:37:03.376Z (6 months ago)
- Topics: bridge, dat-project, hyperdrive, swarm, tcp, udp
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Native messaging swarm
======================
A swarm library that would allow to replicate a dat stream thorugh tcp/udp from the browser. It uses WebExtension's native messaging protocol.
## Installation
```
npm install native-messaging-swarm
```
## Usage
```javascript
const runtime = require('browser.runtime') // or window.runtime
const hyperdrive = require('hyperdrive')
const swarm = require('native-messaging-swarm')
const archive = hyperdrive('./test')
const port = runtime.connectNative(`${__dirname}/native.js`)
archive.ready(() => {
// shares the archive through tcp/udp from the native app
swarm(archive, port)
})
```
## Example
Thanks to `browser.runtime`, on nodejs it'll `spawn` a new process that mimics the native messaging app. In the future the native app can be packaged (https://github.com/zeit/pkg) and would work through a native messaging manifest (see [WebExtensions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging)).
Test this already by launching `node example.js`. It'll start an archive with a `dat.json` and share it through `hyperdiscovery` with the native app.
To clone using `hyperdiscovery` use `node clone.js [key]`.