Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@nullify/libp2p-rpc
Advanced tools
Bi-directional RPC over libp2p streams.
npm i @nullify/libp2p-rpc
import create from "@nullify/libp2p-rpc";
// We need a libp2p bundle as derived from js-ipfs, js-libp2p, or the below...
import node from "@nullify/libp2p-bundle";
const run = async () => {
// Create two peers for communicating
const node1 = await node({
multiaddrs: ["/ip4/0.0.0.0/tcp/4007", "/ip4/0.0.0.0/tcp/4008/ws"],
});
const node2 = await node();
// Create a "server" peer (all peers can be both client and peer)
await create(node1, { ping: () => "pong" });
// Create a "client" peer and keep reference to dialer function
const dial = create(node2, { pong: () => "ping" });
// Start em up!
await node1.start();
await node2.start();
// Get reference to node1's multiaddress
const addrs = node1.multiaddrs.map(
(ma) => `${ma.toString()}/p2p/${node1.peerId.toB58String()}`
);
// Dial node1 and establish rpc client
const remote = await dial(addrs[0]);
// Ping node1/remote and get result
const result = await remote.ping();
console.log(result);
// Spin em' down
await node1.stop();
await node2.stop();
process.exit();
};
run();
create(host, rpc): (addr: any) => Promise<import('znode')>
/**
* Setup a handler and return a dialer for the specified RPC specification.
* @param {import("libp2p")} host The local host used to dial and make the
* connection.
* @param {any} rpc An object representing a set of RPC methods
* as defined in {@link https://github.com/mikeal/znode}.
*/
const create = (host, rpc) => {
...
}
handler(rpc): ({ stream: { source, sink } }) => Promise<import('znode')>
/**
* Create a handler function to be used by a libp2p host.
* @param {any} rpc An object representing a set of RPC methods
* as defined in {@link https://github.com/mikeal/znode}.
*/
const handler = (rpc) => {
...
}
dialer(host, rpc): (addr: any) => Promise<import('znode')>
/**
* Create a dialer function to setup an RPC connection with a remote libp2p peer.
* @param {import("libp2p")} host The local host used to dial and make the
* connection.
* @param {any} rpc An object representing a set of RPC methods
* as defined in {@link https://github.com/mikeal/znode}.
*/
const dialer = (host, rpc) => {
...
}
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
MIT © 2021 Carson Farmer
FAQs
Bi-directional RPC over libp2p streams
The npm package @nullify/libp2p-rpc receives a total of 1 weekly downloads. As such, @nullify/libp2p-rpc popularity was classified as not popular.
We found that @nullify/libp2p-rpc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.