libp2p / libp2p/js-libp2p-examples

Enhance WebRTC Pvt-to-Pvt example by WebRTC Direct SDP Exchange via QR Code

Open
#210 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
105
Forks
63
PR merge metrics
No merged PRs in 30d

Description

## **Description** [Discussed here- #208 ]
This proposal aims to enable **browser-to-browser WebRTC connections without a relay server**, allowing users to establish **private, offline, peer-to-peer communication**. The SDP exchange happens **via QR codes instead of a centralized signaling server**, making it ideal for censorship-heavy regions, offline scenarios, or restricted networks (e.g., Bluetooth-based networks). The proposal can enhance **libp2p and IPFS** use cases by enabling peer discovery and direct communication when traditional internet-based methods fail.

---

## **How It Works**
1. **Browser A (Initiator)**
- Generates an **SDP offer** using WebRTC APIs.
- Optionally gathers **ICE candidates** (STUN helps but is not mandatory).
- Encodes the **SDP offer** as a **QR Code** (or a sharable text file).

2. **Browser B (Receiver)**
- Scans the **QR code** (or manually imports the SDP file).
- Creates an **SDP answer** based on the received offer.
- Encodes its **SDP answer** as another **QR Code** (or shares it manually).
- **Both browsers exchange ICE candidates manually if needed**.

3. **Establishing Connection**
- Once both browsers have exchanged **SDP offers/answers & ICE candidates**, WebRTC establishes a **direct P2P connection**.
- The connection is now independent of the initial exchange method.

---

## **Features**
- **Decentralized WebRTC Connection**: No signaling server or relay node required.
- **Offline Communication**: Works without WiFi, internet, or public relays.
- **QR Code-based SDP Exchange**: Secure and simple method for peer-to-peer connection setup.
- **Manual ICE Candidate Exchange**: Enables direct connections even in NAT-restricted environments.
- **Bluetooth/NFC Support (Future Scope)**: Enhance SDP exchange for truly offline networking.
- **Improved Privacy**: No third-party server involvement.
- **libp2p/IPFS Compatibility**: Can be integrated with libp2p for ad-hoc network formation.

---

## **Challenges**
- **NAT Traversal Issues**: If both peers are behind a strict NAT, connection may fail without a TURN server.
- **Manual ICE Candidate Exchange**: Some setups may require multiple QR code scans.
- **QR Code Size Limitations**: Long SDPs may require text-based exchange instead.
- **Limited Browser Bluetooth API**: Current Web Bluetooth APIs may not support large SDP exchanges.
- **User Experience Considerations**: Multiple scans or manual text pasting may affect usability.

---

## **Advantages**
✅ **No relay servers** → Works in censorship-heavy areas.
✅ **Offline-first** → Works in areas with no internet.
✅ **No central authority** → Ensures privacy & security.
✅ **Supports Bluetooth/NFC** → Expands connectivity options.
✅ **Can integrate with libp2p** → Enables decentralized peer discovery.

---

## **Next Steps**
- Implementing a **proof-of-concept WebRTC QR Code exchange demo**.
- Exploring **Bluetooth API/NFC for local SDP transfer**.
- Investigating **libp2p integration for identity & multi-hop networking**.

---

**Relevant Links:**
- [WebRTC.org Examples](https://webrtc.org/getting-started/peer-connections)
- [libp2p WebRTC Direct Transport](https://github.com/libp2p/js-libp2p-webrtc-direct)
- [Web Bluetooth API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No project files or tests are named; begin by reviewing the linked WebRTC.org example and libp2p WebRTC Direct Transport reference. Done would be a working proof-of-concept for browser SDP offer and answer exchange through QR codes or shared text, including manual ICE exchange where needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
audio-video-rtc, networking, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.