A robust, minimal-server-interaction API for peer routing in the browser

Overview

Membrane



Robust, minimal-server-interaction peer routing in the browser

What is this?

Membrane takes signalling to the browser, creating living peer networks. After just one server-based signal, a node never again needs centrality. The network acts as one giant signaling membrane, connecting far-flung peers at a whim. So long as a node remains a part of the network, it has full contact with every participant. Meanwhile, the network actively stabilizes around each new member, ensuring that severed connections will not damage the network nor cut off nodes, and allowing for an overall seamless "immediate-access-to-anyone" experience.

Taken from Membranexus.com, which was built using Membrane

Membrane leverages the RTCPeerConnection API's agnosticism regarding signaling. You could just as well communicate ICE connectivity data through smoke signals or quantum teleportation (if only), as through a conventional signalling server. That's profound; we forced to use this terribly unreliable, centralized approach. With membrane, just one server-based signal opens an entire realm of peers; each membrane is a single, behemoth router. Distant, unconnected members can exchange arbitrary data in milliseconds, with no clumsy intermediary server, nor any risk of downtime.

To be clear, however, this approach is not perfect. The boon of decentralization may in fact be this project's worst enemy. No singular, trusted ledger to authenticate peers means spoofing, posing, and general manipulation are elementary.

In brief, this tool is robustly functional at enabling anonymous, homogeneous, untrusted data exchange across a network, but poor at most else.

Installation and Integation

Installing the Demo or Building From Source

Prerequisites

  • npm
  • npx
  • node.js

Paste the following commands into a terminal to build a complete directory structure, then install and initialize the demo on 127.0.0.1:8000 anywhere with the prerequisities installed.

curl -LJo Membrane-current.tar.gz https://github.com/Elijah-Bodden/Membrane/tarball/v1.0.5
tar xfv Membrane-current.tar.gz --transform 's!^[^/]\+\($\|/\)!Membrane-current\1!'
cd Membrane-current/src/source/frontend
npm install
cd ../server
npm install
npm run deploy
rm ../../../../Membrane-current.tar.gz

To kill the pm2 daemon created by npm run deploy, run npm run kill.

However, although this demo functions, this does not mean it should be used in production. It is a quick-and-dirty demonstration of the library's promise, and is not made for any serious scalable production situation. quoting ./src/source/frontend's "PLEASENOTE.md",

Excluding the included lib code, the vast majority of the code within this directory and its descendants should never see the light of serious production. It was hastily coded to fit its closed use case. This is nothing more than a demo of the library—far out-of-scope of this project's goal. Please do not treat it as a true part of Membrane. The project begins and ends at lib.
TL;DR: This code is a great risk to the performance and stability of your frontend. Unlike lib, it was not intended as a viable product, and shouldn't be used like one.

Deploying a New Signalling Server

Installing the pre-made server from /src/source/server/index.noStatic.js is a piece of cake! Simply enter the following into a terminal while in the root of your node project, sit back, and relax while the project installs.

npm i membrane-server

Then, to deploy the server over pm2 onto websocket port 8777, enter npm explore membrane-server -- npm run deploy. Simmilarly, to kill the instance created by this command, run npm explore membrane-server -- npm run kill. Now just remember to replace the signalling addresses in your lib script's config with your new server's, and you're ready to go.

Custom Applications

Using the vanilla lib module in a custom use-case is relatively simple. Here is an overview of the typical integration process. First, find the delivery method you like below, then, after you've completed its unique instructions, head down below to the general next steps

Delivery Vector Instructions
npm + Webpack Run npm install @elijah-bodden/membrane | cd node-modules/elijah-bodden/membrane in the root of your webpack project [1]
HTML script tag Enter your project's static file directory, find where you'd like to store the script, then run wget https://raw.githubusercontent.com/Elijah-Bodden/Membrane/main/lib/index.js -o membrane.min.js. Then insert within your HTML head the following tag: <script src="/path/to/membrane.min.js"/>. From here, return to the folder where you installed the script and follow the instructions found after this table
Jsdelivr CDN (not recommended) With this method, you will not need to follow the general instruction which come after the table; however, you will be stuck with the default config and every peer request will be accepted by default. If you wish to proceed, knowing this, simply prepend the following tag to your HTML head's contents. <script src="https://cdn.jsdelivr.net/npm/@elijah-bodden/membrane/index.min.js"

then

  1. (optionally) Modify your script's CONFIG.communication.configLoaderFunction as needed in this form.
  2. (optionally) Create a CONFIG.communication.routeAcceptHeuristic either statically in defaultConfig or dynamically at runtime through CONFIG.constants.configLoadFunction. If you want to allow the user to explicitly accept certain routes, you can include an awaited async function which fetches user responses.

At this stage, the script should be capable of standalone function. To verify, serve several instances of it into any relatively-recent window-based environment (i.e. a browser) with the default server. If an instance's livePeers variable contains at least one Object, everything's working.
Then, to interact with the modlue:

  • Use negotiateAgnosticAuthRoute on members of Object.keys(networkMap.nodes) to authenticate arbitrary nodes.
  • Use * Authenticated Peer *.standardSend("consumable", *arbitrary data*) to send consumable data to authenticated peers.
  • Define an output for consumable data with onConsumableAuth((_dontUse, data) => {* useData *(data)}).
  • Provide initial connect and reconnect websocket urls in CONFIG.serverLink.
  • Set up a signaling server with the appropriate endpoints and exchange methods (or use the included one)


1 The following items are able to be imported from the npm module: CONFIG, GossipTransport, authPeers, deauthPeer, defaultConfig, detatchedRoute, eventHandler, eventHandlingMechanism, gossipTransport, hiddenAliasLookup, init, initialReferenceLedger, livePeers, loadConfig, mostRecentServerHeartbeat, networkMap, networkMap, onAuthRejected, onLivePeersUpdated, onPublicError, peerConnection, pubAliasLookup, pubAliasUnparser, routingTableTransport, serverHardRestart, and topologyTransport.

Contributing

Any and all contributions are greatly appreciated. If you want to see this project grow as much as I do, there are several ways to help. Firstly, if you see something you think you can improve within the code, please fork the repository and make a pull request once you have made any changes you'd like to see. If you just have an idea, or spot a bug, that's great too! In this case, please file an issue with a corresponding bug or enhancement tag. Oh, and if you like what you see here, please feel free to leave a star on the project, it would mean a ton to me.

Authors

License

This project is licensed under the MIT License. See the LICENSE file for details.

Built With

  • The core module - 100% Vanilla.js. Additionally, check out kNow, which I spun off of the homebrew event handler made for use in Membrane.
  • Frontend - Standard HTML/SCSS/JS, plus Sigma.js+Graphology to power the gorgeous network visualization graph (and a pinch of Font Awesome for icons)
  • Backend - JS on node using, most notably, Winston Logger for logging and WS as a WebSocket server

Contact

Elijah Bodden - [email protected] / [email protected]
Project - https://github.com/Elijah-Bodden/Membrane

You might also like...

An on-demand peer tutoring platform by students, for students.

OURFinals An on-demand peer tutoring platform by students, for students. Database The prisma/ folder contains: migrations/: Past database migrations (

Jan 6, 2022

Group together Tailwind CSS modifiers like focus, peer-checked, dark:hover and more with HTML attributes 👩‍🚀

Tailwind CSS Group Classes Group together Tailwind CSS modifiers like focus, peer-checked, dark:hover and more with HTML attributes 👩‍🚀 Using with a

Sep 15, 2022

Monolithic repo for api server, image server, web server

Onsecondary Market Deployed at https://market.onsecondary.com Monolithic repo for api server, image server, web server TODO -use a script to cull expi

Jan 11, 2022

Gatsby-starter-minimal-blog - Typography driven, feature-rich blogging theme with minimal aesthetics.

Gatsby-starter-minimal-blog - Typography driven, feature-rich blogging theme with minimal aesthetics. Includes tags/categories support and extensive features for code blocks such as live preview, line numbers, and line highlighting.

Jan 29, 2022

An implementation of Interaction Nets in JavaScript.

Interaction Nets An implementation of Interaction Nets in JavaScript. Use S-expression as overall syntax. Use Forth-like postfix stack-based syntax to

Dec 23, 2022

high performance、complex interaction table

功能描述 1、高性能、满足复杂交互的编辑表格 2、基于: antd4(https://ant.design/index-cn) ag-grid(https://www.ag-grid.com/) 3、基于原生ag-grid 的API进行封装 一、主要功能 将按下列顺序逐步迭代 1、通用编辑功能 🚧

Feb 15, 2022

Elrond blockchain CLI helper tools - interaction with APIs, smart contracts and protocol

Buildo Begins 👷 Meet Buildo. He is here to help you start creating in the Elrond blockchain ecosystem. Here is where everything begins. I'm going on

Dec 30, 2022

A simple library to view large images up close using simple mouse interaction, and the full screen.

A simple library to view large images up close using simple mouse interaction, and the full screen.

Intense Images A stand alone javascript library for viewing images on the full, full screen. Using the touch/mouse position for panning. Here's a demo

Dec 31, 2022

wagmi hooks 🤝 Storybook interaction testing

A quick demonstration of how Storybook decorators can be combined with a mocked wagmi client to facilitate automated interaction testing for web3-enab

Dec 13, 2022
Comments
  • Bump loader-utils from 2.0.2 to 2.0.3 in /src/source/frontend

    Bump loader-utils from 2.0.2 to 2.0.3 in /src/source/frontend

    Bumps loader-utils from 2.0.2 to 2.0.3.

    Release notes

    Sourced from loader-utils's releases.

    v2.0.3

    2.0.3 (2022-10-20)

    Bug Fixes

    • security: prototype pollution exploit (#217) (a93cf6f)
    Changelog

    Sourced from loader-utils's changelog.

    2.0.3 (2022-10-20)

    Bug Fixes

    • security: prototype pollution exploit (#217) (a93cf6f)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 1
  • Bump loader-utils from 2.0.2 to 2.0.4 in /src/source/frontend

    Bump loader-utils from 2.0.2 to 2.0.4 in /src/source/frontend

    Bumps loader-utils from 2.0.2 to 2.0.4.

    Release notes

    Sourced from loader-utils's releases.

    v2.0.4

    2.0.4 (2022-11-11)

    Bug Fixes

    v2.0.3

    2.0.3 (2022-10-20)

    Bug Fixes

    • security: prototype pollution exploit (#217) (a93cf6f)
    Changelog

    Sourced from loader-utils's changelog.

    2.0.4 (2022-11-11)

    Bug Fixes

    2.0.3 (2022-10-20)

    Bug Fixes

    • security: prototype pollution exploit (#217) (a93cf6f)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 0
  • Bump vm2 from 3.9.10 to 3.9.11 in /src/source/server

    Bump vm2 from 3.9.10 to 3.9.11 in /src/source/server

    Bumps vm2 from 3.9.10 to 3.9.11.

    Release notes

    Sourced from vm2's releases.

    3.9.11

    New Features

    https://github.com/patriksimek/vm2/commit/58478a58c6f4af3c54faf4117ed5ab72d2cc8cd5: Add option require.strict to allow to load required modules in non strict mode.

    Fixes

    https://github.com/patriksimek/vm2/commit/d9a7f3cc995d3d861e1380eafb886cb3c5e2b873: Security fix.

    Changelog

    Sourced from vm2's changelog.

    v3.9.11 (2022-08-28)

    [new] Add option require.strict to allow to load required modules in non strict mode.
    [fix] Security fix.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 0
  • Bump vm2 from 3.9.10 to 3.9.11 in /.config/server

    Bump vm2 from 3.9.10 to 3.9.11 in /.config/server

    Bumps vm2 from 3.9.10 to 3.9.11.

    Release notes

    Sourced from vm2's releases.

    3.9.11

    New Features

    https://github.com/patriksimek/vm2/commit/58478a58c6f4af3c54faf4117ed5ab72d2cc8cd5: Add option require.strict to allow to load required modules in non strict mode.

    Fixes

    https://github.com/patriksimek/vm2/commit/d9a7f3cc995d3d861e1380eafb886cb3c5e2b873: Security fix.

    Changelog

    Sourced from vm2's changelog.

    v3.9.11 (2022-08-28)

    [new] Add option require.strict to allow to load required modules in non strict mode.
    [fix] Security fix.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 0
Releases(v1.1.2)
Peer-to-peer terminal chat based on DStack

peerchat Peer-to-peer terminal chat based on DStack Recording looks ugly, but in terminal it seems to be fine peerchat Usage Commands Usage $ npm inst

DStack 7 Aug 17, 2022
Quiet Peer-to-Peer Donations

Quiet Peer-to-Peer Donations

Arcade City 7 Jun 6, 2022
An Opensource Peer-to-peer Social Network with Zero-Knowledge-Proof based authentication.

HexHoot This is an attempt to create an Opensource Peer-to-peer Social Network with Zero-Knowledge-Proof based authentication. The objective is to dem

Zenin Easa Panthakkalakath 6 Dec 28, 2022
A peer-to-peer chat app that is serverless, decentralized, and ephemeral

Chitchatter Logo provided by @ramyashreeshetty Chitchatter is a free (as in both price and freedom) communication tool. It is designed with security a

Jeremy Kahn 714 Dec 19, 2022
A minimal routing library designed to sit on top of Bun's fast HTTP server.

siopao A minimal routing library designed to sit on top of Bun's fast HTTP server. Based on Radix Tree. Sio=Hot Pao=Bun Installation bun add siopao Us

Robert Soriano 69 Nov 8, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
It shows how to escape cross-origin issues for web client and API server using CloudFront routing.

AWS CloudFront의 URL Routing을 이용한 Web Client 및 API Server 구현 여기서는 CliendFront의 URL Routing을 이용하여 Web Client와 API Server를 구현하고자 합니다. Web Client는 Amazon

John Park 4 Nov 20, 2022
Suck a DAG out of a peer in the IPFS network.

dagula Suck a DAG out of a peer in the IPFS network. Install npm i dagula Usage import { Dagula } from 'dagula' import { getLibp2p } from 'dagula/p2p

Alan Shaw 11 Nov 2, 2022