
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A secure peer-to-peer networking NodeJS module based on WebSockets using RSA and AES.
This package aims to create a secure, trusted network among decentralized peers, and make the aforementioned easy to setup and use right out-of-the-box.
npm install ringnet
const { Peer, Message } = require('ringnet');
// See 'Constructor Options' below.
var peer = new Peer(options);
{'key: "https.key.pem", 'cert': "https.cert.pem"}.credentials.key) and cert (credentials.cert) properties for creation of the https server in which to listen for incomming wss (secure) connections. Previously an insecure http server was used for peer-to-peer communcation and has since been deprecated. The peer must have valid https key and certificate in order to run. Self-signed certificates are acceptable for use.httpsServer is provided, and is a valid HTTPS server instance, this option, credentials, will be ignored.falsestdout while running[][26780, 26790]discoveryAddresses does not contain a port, the peer will sequentially try connect to said entry using this range of ports (inclusive). The first index of this array should be the starting port and the second and last index of this array should be the ending portfalse.HTTPS_SERVER_MODES.CREATE,./lib/src/httpsServerModes.jsDSCVRY_LISTEN environment variable with a fallback of 26780peer.pemfalse.peer.pubring.pubpeer.signature{}ws (WebSockets) server. See https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback for more options and additional information./*
Create a peer, `peer`, using `myRingPulicKey.pub`, `myPeerPublicKey.pub`,
`myPeerPublicKey.pem`, and `myPeerSignature` files, that listens on port
`26780` and will attempt to discover the address `127.0.0.1:26781` when
discovering. This peer will, if given an IP to discover with no port, scan
ports 26780-26790 (inclusive) against the IP in order to attempt to
establish a secure connection with said IP. This peer will report that
it's public IP address is "127.0.0.1" and it will also output diagnostics
(`debug`).
*/
var peer = new Peer({
'credentials': {
'key': "myHttpsServer.key.pem",
'cert': "myHttpsServer.cert.pem"
},
'ringPublicKey': "myRingPulicKey.pub",
'publicKey': "myPeerPublicKey.pub",
'privateKey': "myPeerPrivateKey.pem",
'signature': "myPeerSignature.signature",
'port': 26780,
'discoveryAddresses': [ "127.0.0.1:26781" ],
'discoveryRange': [ 26780, 27900 ],
'publicAddress': "127.0.0.1",
'debug': true,
});
peer.on('ready', () => {
/* Indicates the underyling HTTP Server is ready. */
});
peer.on('request', ({connection, request }) => {
/* A new request has been received by the WebSocket server */
});
peer.on('connection', ({connection }) => {
/* A new VERIFIED AND TRUSTED connection has been made */
});
peer.on('message', () => ({ message, connection }) => {
/*
A message has been received by the WebSocket server.
NOTE:
This event is only emitted if the message header's 'type' property is not
set or is not of type string. See custom message header type example below.
*/
});
peer.on('discovering', () => {
/* The peer is discovering based on it's list of known or potential peers */
});
peer.on('discovered', () => {
/* The peer is done discovering */
});
peer.on('your_custom_message_header_type', () => {
/*
The peer has received a message of "unknown" (custom) type and emits the
message header's 'type' property.
NOTE:
These "unknown" (custom) events are only emitted if the message header's 'type'
property is a string.
*/
});
async / awaitClients can also leverage async / await to detemine peer readiness or the completion of the discovery operation.
async function createPeer() {
const peer = new Peer({ /* ... */ });
// Wait for peer to initialize...
await peer.init();
// Wait for Peer to finish discover operation...
await peer.discover();
}
/**
* Creates and sends a new 'MySuperCoolMessage' Message with arbitrary body (object).
*/
async function sendMySuperCoolMessage() {
var message = new Message({
type: "MySuperCoolMessage",
body: {
someProperty: "Some Value!"
}
});
try {
// Broadcast the message to all connected, verified peers
const broadcastResults = await peer.broadcast({ message });
} catch(e) {
console.error(e.stack);
}
}
peer.on("MySuperCoolMessage", ({ message, connection }) => {
// Do something here
});
Generate or bring-your-own HTTPS server key and certificate:
$ npm run setup
In a terminal window, start the first peer (peer1):
$ npm run peer1
In a second terminal window, start the second peer (peer2):
$ npm run peer2
Once the peer-to-peer network has been established (post-HELO handshake), messages from one peer can be sent out to all other peers in the network securely, just as in a typical client-server scenario, but in a decentralized fashion. Every peer is a server and every peer is a client. There is no central management.
Type some text into terminal/prompt while the second peer (peer2) is running and hit enter. The second peer will send the message securely to the first peer (peer1), as the peers have established trust in the decentralized network.
Quit (Ctrl^C or type exit and hit enter) on the second terminal window to quit the second peer.
Verify the encrypted message sent by the second peer made it to the first peer (peer1) by returning to the first terminal window. The last few lines of output will now reflect the message sent by the second peer to the first peer and received by the first peer from the second peer.
Quit (Ctrl^C or type exit and hit enter) on the first terminal window to quit the first peer.
FAQs
A secure peer-to-peer networking NodeJS module based on WebSockets using RSA and AES.
We found that ringnet 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.