Skip to content

Feature/add nodejs peer#242

Closed
Nkovaturient wants to merge 4 commits intolibp2p:mainfrom
Nkovaturient:feature/add-nodejs-peer
Closed

Feature/add nodejs peer#242
Nkovaturient wants to merge 4 commits intolibp2p:mainfrom
Nkovaturient:feature/add-nodejs-peer

Conversation

@Nkovaturient
Copy link
Copy Markdown

@Nkovaturient Nkovaturient commented Mar 7, 2025

Issue : #214

Description:

This PR adds a Node.js peer to the Universal Connectivity project.

Establishing and accepting server-style TCP connections with Go and Rust peers.
Initiating direct connections to browsers via WebRTC.
Accepting connections from browsers via WebRTC-Direct and WebSockets.

Key Implementations:

  • Libp2p Node Setup: Multi-transport support (TCP, WebRTC, WebSockets)
  • Interoperability: Node.js <-> Go/Rust via TCP ; Node.js <-> Browser via WebRTC/WebTransport (refining)
  • PubSub Messaging: GossipSub-based message exchange
  • Peer Discovery: mDNS, DHT, PubSub Peer Discovery
  • Robust Dialing: Improved error handling & retry logic for cross-peer connections
  • Testing Suite: WebRTC browser-node tests via Puppeteer & Jest

Next Steps for Further Robustness:

🔹 Implement DCUtR (Direct Connection Upgrade through Relay) for NAT traversal
🔹 Enhance WebRTC signaling reliability across peers
🔹 Optimize message streaming performance for large-scale chat/file sharing

Note to Maintainer

🔹 kindly review and guide if I'm on the right track

@Nkovaturient Nkovaturient deleted the feature/add-nodejs-peer branch March 9, 2025 07:55
@Nkovaturient Nkovaturient restored the feature/add-nodejs-peer branch March 9, 2025 08:00
@Nkovaturient Nkovaturient reopened this Mar 9, 2025
@Nkovaturient Nkovaturient force-pushed the feature/add-nodejs-peer branch from 353b91b to c0f4200 Compare March 9, 2025 08:18
@devlux76
Copy link
Copy Markdown

I test this and wanted to say great work! Seems to be working excellent! Here's hoping they merge your PR soon.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a Node.js peer to the Universal Connectivity project to enable multi-transport connectivity (TCP, WebRTC, WebSockets, etc.) and robust peer-to-peer interactions. Key changes include the introduction of integration tests using Puppeteer for WebRTC browser-node connectivity, new stream helper functions, and enhancements to the libp2p node setup with robust dialing and NAT fallback handling.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
nodejs-peer/test/webrtc.test.js Integration test setup using Puppeteer to verify browser-to-node WebRTC connections
nodejs-peer/src/stream.js Helper functions to process stdin and output stream data using length-prefixed encoding
nodejs-peer/src/libp2p.js Configuration of the Node.js peer with multi-transport support and robust dialing
nodejs-peer/src/dialer.js Dialer script for initiating connections to specified peer multiaddrs
nodejs-peer/src/constants.js Centralized definition of protocol topics and peer IDs for the application
nodejs-peer/jest.config.cjs Jest configuration for testing WebRTC handshakes with Puppeteer
Files not reviewed (1)
  • nodejs-peer/package.json: Language not supported
Comments suppressed due to low confidence (1)

nodejs-peer/src/libp2p.js:187

  • The use of node.configure to dynamically apply a new circuit relay transport may not be supported by the API. Please confirm that dynamic reconfiguration is allowed or perform a proper restart/reinitialization if needed.
node.configure(circuitRelayTransport({ discoverRelays: 2 }))

Copy link
Copy Markdown
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this.

This seems more like a demo or sketch than a usable Node.js peer. For example the main libp2p.js script starts two nodes and connects them together whereas the other implementations here have UIs to allow them to discover and connect to other nodes, running the universal connectivity protocols - sending group messages, DMs, etc.

It's possible you are still working on filling out the missing features. I'm going to mark this PR as draft in the interim so as not to discourage others from submitting a working Node.js peer.

The next steps for this PR are to replicate the features implemented by the other implementations in this repo as mentioned above, along with tests.

@achingbrain achingbrain marked this pull request as draft April 10, 2025 06:40
@Nkovaturient
Copy link
Copy Markdown
Author

@achingbrain thank you for guiding!
indeed this PR was intended for initial setup of nodejs peer, then after reviewing, further guidance on enhancing it.

Hence, Moving further, I will implement
— UI
— peer-discovery mechanism
— gossipsub

@achingbrain
Copy link
Copy Markdown
Member

Closing in favour of #268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants