Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nats

Package Overview
Dependencies
Maintainers
2
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nats - npm Package Compare versions

Comparing version 0.7.2 to 0.7.4

7

lib/nats.js

@@ -26,3 +26,3 @@ /*!

var VERSION = '0.7.2',
var VERSION = '0.7.4',

@@ -856,3 +856,4 @@ DEFAULT_PORT = 4222,

client.payload.chunks.push(client.inbound.slice(0, client.payload.psize));
var mbuf = Buffer.concat(client.payload.chunks, client.payload.size + CR_LF_LEN);
// don't append trailing control characters
var mbuf = Buffer.concat(client.payload.chunks, client.payload.size);

@@ -862,3 +863,3 @@ if (client.options.preserveBuffers) {

} else {
client.payload.msg = mbuf.toString(client.encoding, 0, client.payload.size);
client.payload.msg = mbuf.toString(client.encoding);
}

@@ -865,0 +866,0 @@

{
"name": "nats",
"version": "0.7.2",
"version": "0.7.4",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",

@@ -5,0 +5,0 @@ "keywords": [

@@ -98,3 +98,3 @@ # NATS - Node.js Client

// currentServer is the URL of the connected server.
console.log("Connected to " + nc.currentServer.host);
console.log("Connected to " + nc.currentServer.url.host);

@@ -101,0 +101,0 @@ // Preserve order when connecting to servers.

@@ -7,2 +7,3 @@ /* jslint node: true */

nsc = require('./support/nats_server_control'),
crypto = require('crypto'),
should = require('should');

@@ -25,5 +26,4 @@

it('should allow sending and receiving binary data', function(done) {
var nc = NATS.connect({'url': 'nats://localhost:' + PORT, 'encoding': 'binary'});
function binaryDataTests(done, nc) {
// try some invalid utf-8 byte sequences

@@ -34,2 +34,3 @@ var invalid2octet = new Buffer('\xc3\x28', 'binary');

var invalid4octet = new Buffer('\xf0\x90\x28\xbc', 'binary');
var bigBuffer = crypto.randomBytes(128*1024);

@@ -39,7 +40,7 @@ // make sure embedded nulls don't cause truncation

var count = 5;
var count = 6;
var finished = function() {
if (--count <= 0) {
nc.close();
done();
nc.close();
done();
}

@@ -50,3 +51,7 @@ };

msg.length.should.equal(2);
msg.should.equal(invalid2octet.toString('binary'));
if(nc.options.preserveBuffers) {
should.ok(invalid2octet.equals(msg));
} else {
msg.should.equal(invalid2octet.toString('binary'));
}
finished();

@@ -57,3 +62,7 @@ });

msg.length.should.equal(2);
msg.should.equal(invalidsequenceidentifier.toString('binary'));
if(nc.options.preserveBuffers) {
should.ok(invalidsequenceidentifier.equals(msg));
} else {
msg.should.equal(invalidsequenceidentifier.toString('binary'));
}
finished();

@@ -64,3 +73,7 @@ });

msg.length.should.equal(3);
msg.should.equal(invalid3octet.toString('binary'));
if(nc.options.preserveBuffers) {
should.ok(invalid3octet.equals(msg));
} else {
msg.should.equal(invalid3octet.toString('binary'));
}
finished();

@@ -71,3 +84,7 @@ });

msg.length.should.equal(4);
msg.should.equal(invalid4octet.toString('binary'));
if(nc.options.preserveBuffers) {
should.ok(invalid4octet.equals(msg));
} else {
msg.should.equal(invalid4octet.toString('binary'));
}
finished();

@@ -78,6 +95,21 @@ });

msg.length.should.equal(11);
msg.should.equal(embeddednull.toString('binary'));
if(nc.options.preserveBuffers) {
should.ok(embeddednull.equals(msg));
} else {
msg.should.equal(embeddednull.toString('binary'));
}
finished();
});
nc.subscribe('bigbuffer', function(msg) {
msg.length.should.equal(bigBuffer.length);
if(nc.options.preserveBuffers) {
should.ok(bigBuffer.equals(msg));
} else {
msg.should.equal(bigBuffer.toString('binary'));
}
finished();
});
nc.publish('invalid2octet', invalid2octet);

@@ -88,3 +120,40 @@ nc.publish('invalidsequenceidentifier', invalidsequenceidentifier);

nc.publish('embeddednull', embeddednull);
nc.publish('bigbuffer', bigBuffer);
}
it('should allow sending and receiving binary data', function(done) {
var nc = NATS.connect({'url': 'nats://localhost:' + PORT, 'encoding': 'binary'});
binaryDataTests(done, nc);
});
});
it('should allow sending binary buffers', function(done) {
var nc = NATS.connect({'url': 'nats://localhost:' + PORT, 'preserveBuffers': true});
binaryDataTests(done, nc);
});
it('should not append control characters on chunk processing', function(done) {
var nc = NATS.connect({ 'url': 'nats://localhost:' + PORT, 'preserveBuffers': true });
var buffer = crypto.randomBytes(1024);
var count = 0;
var finished = function () {
if (++count == 100) {
nc.close();
done();
}
};
nc.subscribe('trailingData', function (msg) {
should.ok(msg.equals(buffer));
finished();
});
for (var i = 0; i <= 100; i++) {
nc.publish('trailingData', buffer);
}
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc