Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@network-stackify/libp2p-net
Advanced tools
A port of node's net module for the browser using libp2p
@network-stackify/libp2p-net
Drop in replacement for net module
This module is inspired by go-ipfs experimental p2p streams.
Generally, you will need a go-ipfs node to expose a port through libp2p
ipfs p2p listen /x/<host> /dns4/<host-fqdn>/tcp/80
In nodejs, use like the native net module:
HTTP
const net = require("@network-stackify/libp2p-net");
const http = require("http"); //require('@network-stackify/http')
function readResponse(response) {
var str = "";
response.on("data", (chunk) => {
str += chunk;
});
response.on("end", () => {
console.log(str);
});
}
const exampleMultiaddr = "/dns4/localhost/tcp/4003/ws/p2p/" + peerId;
const libp2p = await createLibp2pInstance(opts);
//The following options are required but can be omitted when using an agent
// results in EPERM (piping) or TLS errors if not strictly correct
const tlsOptions = {
path: undefined,
port: 443,
servername: "google.com",
};
//go-ipfs: ipfs p2p listen /x/httpGoogle /dns4/google.com/tcp/80
const httpOptions = {
createConnection: net.createConnection,
libp2p,
multiaddr: exampleMultiaddr,
hops: [],
proto: "/x/httpGoogle",
};
http.get("http://google.com", httpOptions, readResponse);
HTTPS
const net = require("@network-stackify/libp2p-net");
const https = require("https"); //require('@network-stackify/https')
const tls = require("tls"); //require('@network-stackify/tls')
function readResponse(response) {
var str = "";
response.on("data", (chunk) => {
str += chunk;
});
response.on("end", () => {
console.log(str);
});
}
const exampleMultiaddr = "/dns4/localhost/tcp/4003/ws/p2p/" + peerId;
const libp2p = await createLibp2pInstance(opts);
//go-ipfs: ipfs p2p listen /x/httpsGoogle /dns4/google.com/tcp/443
const httpsOptions = {
createConnection: (opts) => {
const socket = net.createConnection(opts);
//Override net in tls module
return tls.connect({ ...opts, ...tlsOptions, socket });
},
libp2p,
multiaddr: exampleMultiaddr,
hops: [],
proto: "/x/httpsGoogle",
//The following options are required but can be omitted when using an agent
// results in EPERM (piping) or TLS errors if not strictly correct
path: undefined,
port: 443,
servername: "google.com",
};
https.get("https://google.com", httpsOptions, readResponse);
module.export = {
resolve: {
fallback: {
net: require.resolve("@network-stackify/libp2p-net"),
//for https using net bundle
tls: require.resolve("@network-stackify/tls"),
https: require.resolve("@network-stackify/https"),
//for http using libp2p-net
http: require.resolve("@network-stackify/http"),
},
},
};
const ws = require("ws");
const libp2p = createInstance();
let client = new ws("wss://endpoint.tld", {
//Options for libp2p-net
libp2p,
multiaddr,
proto,
hops,
});
For easy front-end bundling, network-stackify uses native modules by default. This way, modules can be replaced selectively.
Other network-stackify modules like http, https, tls will require shimming the native net module or overriding defaults by passing opts.connect/createConnection or opts.socket.
FAQs
A port of node's net module for the browser using libp2p
The npm package @network-stackify/libp2p-net receives a total of 0 weekly downloads. As such, @network-stackify/libp2p-net popularity was classified as not popular.
We found that @network-stackify/libp2p-net 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.