![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
libp2p is the networking stack of IPFS, a modular networking library to solve P2P application needs.
libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, dev have long had to made custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API.
We are in the process of writting better documentation, blog posts, tutorials and a formal specification. Today you can find:
To sum up, libp2p is a "network stack" -- a protocol suite -- that cleanly separates concerns, and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability. libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.
With its modular nature, libp2p can be found being used in different projects with different sets of features, while preserving the same top level API. js-libp2p
is only a skeleton and should not be installed directly, if you are looking for a prebundled libp2p stack, please check:
If you have developed a libp2p bundle, please consider submitting it to this list so that it can be found easily by the users of libp2p.
Again, as noted above, this module is only a skeleton and should not be used directly other than libp2p bundle implementors that want to extend its code.
npm install --save libp2p
libp2p becomes very simple and basically acts as a glue for every module that compose this library. Since it can be highly customized, it requires some setup. What we recommend is to have a libp2p build for the system you are developing taking into account in your needs (e.g. for a browser working version of libp2p that acts as the network layer of IPFS, we have a built and minified version that browsers can require).
Example:
// Creating a bundle that adds:
// transport: websockets + tcp
// stream-muxing: SPDY
// crypto-channel: secio
// discovery: multicast-dns
const libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const WS = require('libp2p-websockets')
const spdy = require('libp2p-spdy')
const secio = require('libp2p-secio')
const MulticastDNS = require('libp2p-mdns')
class Node extends libp2p {
constructor (peerInfo, peerBook, options) {
options = options || {}
const modules = {
transport: [
new TCP(),
new WS()
],
connection: {
muxer: [
spdy
],
crypto: [
secio
]
},
discovery: [
new MulticastDNS(peerInfo, 'your-identifier')
]
}
super(modules, peerInfo, peerBook, options)
}
}
// Now all the nodes you create, will have TCP, WebSockets, SPDY, SECIO and MulticastDNS support.
new libp2p.Node([peerInfo, peerBook, options])
Creates an instance of the libp2p.Node.
peerInfo
: instance of PeerInfo that contains the PeerId, Keys and multiaddrs of the libp2p Node. Optional.peerBook
: instance of PeerBook that contains the PeerInfo of known peers. Optional.options
: Object containing custom options for the bundle.libp2p.start(callback)
Start the libp2p Node.
callback
is a function with the following function (err) {}
signature, where err
is an Error in case starting the node fails.
libp2p.stop(callback)
Stop the libp2p Node.
callback
is a function with the following function (err) {}
signature, where err
is an Error in case stopping the node fails.
libp2p.dial(peer [, protocol, callback])
Dials to another peer in the network.
peer
: can be an instance of PeerInfo, PeerId or multiaddrprotocol
: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')callback
is a function with the following function (err, conn) {}
signature, where err
is an Error in of failure to dial the connection and conn
is a Connection instance in case of a protocol selected, if not it is undefined.
Closes an open connection with a peer, graciously.
callback
is a function with the following function (err) {}
signature, where err
is an Error in case stopping the node fails.
libp2p.handle(protocol, handlerFunc [, matchFunc])
Handle new protocol
protocol
: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')handlerFunc
: Function with signature function (protocol, conn) {}
matchFunc
: Function for matching on protocol (exact matching, semver, etc). Default to exact match.Stop handling protocol
protocol
: String that defines the protocol (e.g '/ipfs/bitswap/1.1.0')libp2p.on('peer', (peer) => {})
Peer has been discovered.
peer
: instance of PeerInfolibp2p.isOn()
Check if libp2p is started
libp2p.ping(peer [, options], callback)
Ping a node in the network
libp2p.peerBook
PeerBook instance of the node
libp2p.peerInfo
PeerInfo instance of the node
SOON™
libp2p.findPeers
libp2p.findProviders
libp2p.record.put
libp2p.record.get
List of packages currently in existence for libp2p
Package | Version | Dependencies | DevDependencies |
---|---|---|---|
Bundles | |||
libp2p-ipfs-nodejs | |||
libp2p-ipfs-browser | |||
Transports | |||
libp2p-utp | |||
libp2p-websockets | |||
libp2p-webrtc-star | |||
Connection Upgrades | |||
interface-connection | |||
Stream Muxers | |||
interface-stream-muxer | |||
libp2p-spdy | |||
libp2p-multiplex | |||
Discovery | |||
libp2p-mdns-discovery | |||
libp2p-railing | |||
Crypto Channels | |||
libp2p-secio | |||
Peer Routing | |||
libp2p-kad-routing | |||
Content Routing | |||
interface-record-store | |||
libp2p-record | |||
libp2p-distributed-record-store | |||
libp2p-kad-record-store | |||
Generics | |||
libp2p-swarm | |||
libp2p-ping | |||
multistream-select | |||
Data Types | |||
peer-book | |||
peer-id |
The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:
MIT © David Dias
FAQs
JavaScript implementation of libp2p, a modular peer to peer network stack
The npm package libp2p receives a total of 30,335 weekly downloads. As such, libp2p popularity was classified as popular.
We found that libp2p demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.