
Security News
minimatch Patches 3 High-Severity ReDoS Vulnerabilities
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.
conversation-stream
Advanced tools
Conversation-Stream allows you to have a JSON conversation over a stream.
npm install conversation-stream
To listen for messages you just need to listen to the message event
var cs = require('conversation-stream')
var conversation = cs();
fromStream.pipe(conversation).pipe(fromStream);
conversation.on('message', function(message, respond) {
respond(null, {echo:message}); // send a reply back if you want to
});
To send messages you call conversation.send(message)
To send messages and wait for a reply you call conversation.send(message, callback)
var cs = require('conversation-stream');
var conversation = cs();
toStream.pipe(conversation).pipe(toStream);
conversation.send('hello', function(err, reply) {
console.log(err, reply); // prints {echo:'hello'}
});
conversation.send('world', function(err, reply) {
console.log(err, reply); // prints {echo:'world'}
});
Lets try to setup a simple server
var cs = require('conversation-stream');
var net = require('net');
net.createServer(function(socket) {
var conversation = cs();
socket.pipe(conversation).pipe(socket);
conversation.on('message', function(message, respond) {
conversation.send({server:message}, respond);
});
}).listen(9000);
To start a conversation to the server we need to create a socket to the server and pipe our message to that.
var socket = net.connect(9000);
var conversation = cs();
socket.pipe(conversation).pipe(socket);
conversation.on('message', function(message, respond) {
respond(null, {client:message});
});
conversation.send('echo me please', function(err, reply) {
console.log(err, reply); // prints {client:{server:'echo me please'}}
});
conversation.send('echo me please again', function(err, reply) {
console.log(err, reply); // prints {client:{server:'echo me please again'}}
});
If we wanted to use tls instead of tcp we could just have implemented the above example using tls streams.
We could even use WebSockets using shoe.
FAQs
json conversations over a stream
We found that conversation-stream 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
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.

Research
/Security News
Socket uncovered 26 malicious npm packages tied to North Korea's Contagious Interview campaign, retrieving a live 9-module infostealer and RAT from the adversary's C2.

Research
An impersonated golang.org/x/crypto clone exfiltrates passwords, executes a remote shell stager, and delivers a Rekoobe backdoor on Linux.