Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@nullify/libp2p-rpc
Advanced tools
Readme
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 3 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.