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

nats

Package Overview
Dependencies
Maintainers
3
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 1.3.0 to 1.3.2

10

package.json
{
"name": "nats",
"version": "1.3.0",
"version": "1.3.2",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",

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

"devDependencies": {
"@types/node": "^12.0.7",
"coveralls": "^3.0.4",
"dependency-check": "^3.3.0",
"@types/node": "^12.6.2",
"coveralls": "^3.0.5",
"dependency-check": "^3.4.1",
"eslint": "^5.16.0",

@@ -62,3 +62,3 @@ "js-beautify": "^1.10.0",

"should": "^13.2.3",
"typescript": "^3.5.1"
"typescript": "^3.5.3"
},

@@ -65,0 +65,0 @@ "typings": "./index.d.ts",

@@ -36,2 +36,17 @@ # NATS.js - Node.js Client

// Subscription/Request callbacks are given multiple arguments:
// - msg is the payload for the message
// - reply is an optional reply subject set by the sender (could be undefined)
// - subject is the subject the message was sent (which may be more specific
// than the subscription subject - see "Wildcard Subscriptions".
// - finally the subscription id is the local id for the subscription
// this is the same value returned by the subscribe call.
nats.subscribe('foo', function(msg, reply, subject, sid) {
if(reply) {
nats.publish(reply, "got " + msg + " on " + subject + " in subscription id " + sid);
return;
}
console.log('Received a message: ' + msg + " it wasn't a request.");
});
// Request Streams

@@ -42,2 +57,3 @@ var sid = nats.request('request', function(response) {

// Request with Auto-Unsubscribe. Will unsubscribe after

@@ -105,3 +121,3 @@ // the first response is received via {'max':1}

}
// of course this is no different than using a value that is

@@ -181,12 +197,12 @@ // expected in one format (say a number), but the client provides

```javascript
// Unsubscribing removes the subscription handler for a subscription
// and cancels the subscription. Any pending messages on the client's
// buffer are discarded.
//
// Unsubscribing removes the subscription handler for a subscription
// and cancels the subscription. Any pending messages on the client's
// buffer are discarded.
//
// Draining is similar to unsubscribe, but the client instead
// sends the unsubscribe request followed by a flush. When the flush
// returns, the subscription handler is removed. Thus the client is
// able to process all messages sent by the server before the subscription
// handler is removed.
//
// sends the unsubscribe request followed by a flush. When the flush
// returns, the subscription handler is removed. Thus the client is
// able to process all messages sent by the server before the subscription
// handler is removed.
//
// Draining is particularly valuable with queue subscriptions preventing

@@ -200,4 +216,4 @@ // messages from being lost.

nc1.drainSubscription(sid1, () => {
// subscription drained - possible arguments are an error or
// the sid (number) and subject identifying the drained
// subscription drained - possible arguments are an error or
// the sid (number) and subject identifying the drained
// subscription

@@ -212,3 +228,3 @@ });

// - after calling drain it is impossible to make subscriptions or requests
// - when all subscriptions are drained, it is impossible to publish
// - when all subscriptions are drained, it is impossible to publish
// messages and drained connection is closed.

@@ -342,2 +358,6 @@ // - finally, the callback handler is called (with possibly an error).

// Timeout unless a certain number of messages have been received
// the callback for the timeout. The callback for the timeout
// provides one argument, the subscription id (sid) for the
// subscription. This allows a generic callback to identify
// where the timeout triggered.
nats.timeout(sid, timeout_ms, expected, function() {

@@ -348,3 +368,3 @@ timeout = true;

// Auto-unsubscribe after MAX_WANTED messages received
nats.subscribe('foo', {'max':MAX_WANTED});
var sid = nats.subscribe('foo', {'max':MAX_WANTED});
nats.unsubscribe(sid, MAX_WANTED);

@@ -387,2 +407,4 @@

// emitted whenever there's an error. if you don't implement at least
// the error handler, your program will crash if an error is emitted.
nc.on('error', function(err) {

@@ -392,2 +414,3 @@ console.log(err);

// connect callback provides a reference to the connection as an argument
nc.on('connect', function(nc) {

@@ -397,2 +420,3 @@ console.log('connected');

// emitted whenever the client disconnects from a server
nc.on('disconnect', function() {

@@ -402,2 +426,3 @@ console.log('disconnect');

// emitted whenever the client is attempting to reconnect
nc.on('reconnecting', function() {

@@ -407,2 +432,4 @@ console.log('reconnecting');

// emitted whenever the client reconnects
// reconnect callback provides a reference to the connection as an argument
nc.on('reconnect', function(nc) {

@@ -412,2 +439,4 @@ console.log('reconnect');

// emitted when the connection is closed - once a connection is closed
// the client has to create a new connection.
nc.on('close', function() {

@@ -417,2 +446,15 @@ console.log('close');

// emitted whenever the client unsubscribes
nc.on('unsubscribe', function(sid, subject) {
console.log("unsubscribed subscription", sid, "for subject", subject);
});
// emitted whenever the server returns a permission error for
// a publish/subscription for the current user. This sort of error
// means that the client cannot subscribe and/or publish/request
// on the specific subject
nc.on("permission_error", function(err) {
console.error("got a permissions error", err.message);
});
```

@@ -428,3 +470,2 @@

|-------- |--------- |--------- |------------
| `noEcho` | | `false` | Subscriptions receive messages published by the client. Requires server support (1.2.0). If set to true, and the server does not support the feature, an error with code `NO_ECHO_NOT_SUPPORTED` is emitted, and the connection is aborted. Note that it is possible for this error to be emitted on reconnect when the server reconnects to a server that does not support the feature.
| `encoding` | | `"utf8"` | Encoding specified by the client to encode/decode data

@@ -435,2 +476,4 @@ | `json` | | `false` | If true, message payloads are converted to/from JSON

| `name` | `client` | | Optional client name
| `nkey` | | `` | See [NKeys/User Credentials](https://github.com/nats-io/nats.js#new-authentication-nkeys-and-user-credentials)
| `noEcho` | | `false` | Subscriptions receive messages published by the client. Requires server support (1.2.0). If set to true, and the server does not support the feature, an error with code `NO_ECHO_NOT_SUPPORTED` is emitted, and the connection is aborted. Note that it is possible for this error to be emitted on reconnect when the server reconnects to a server that does not support the feature.
| `noRandomize` | `dontRandomize`, `NoRandomize` | `false` | If set, the order of user-specified servers is randomized.

@@ -444,2 +487,3 @@ | `pass` | `password` | | Sets the password for a connection

| `servers` | `urls` | | Array of connection `url`s
| `sigCB` | | `` | See [NKeys/User Credentials](https://github.com/nats-io/nats.js#new-authentication-nkeys-and-user-credentials)
| `tls` | `secure` | `false` | This property can be a boolean or an Object. If true the client requires a TLS connection. If false a non-tls connection is required. The value can also be an object specifying TLS certificate data. The properties `ca`, `key`, `cert` should contain the certificate file data. `ca` should be provided for self-signed certificates. `key` and `cert` are required for client provided certificates. `rejectUnauthorized` if `true` validates server's credentials

@@ -450,2 +494,4 @@ | `token` | | | Sets a authorization token for a connection

| `user` | | | Sets the username for a connection
| `usercreds` | | `` | See [NKeys/User Credentials](https://github.com/nats-io/nats.js#new-authentication-nkeys-and-user-credentials). Set with `NATS.creds()`.
| `userjwt` | | `` | See [NKeys/User Credentials](https://github.com/nats-io/nats.js#new-authentication-nkeys-and-user-credentials)
| `verbose` | | `false` | Turns on `+OK` protocol acknowledgements

@@ -456,3 +502,2 @@ | `waitOnFirstConnect` | | `false` | If `true` the server will fall back to a reconnect mode if it fails its first connection attempt.

## Supported Node Versions

@@ -464,4 +509,8 @@

## Running Tests
To run the tests, you need to have a `nats-server` executable in your path. Refer to the [server installation guide](https://nats-io.github.io/docs/nats_server/installation.html) in the NATS.io documentation. With that in place, you can run `npm test` to run all tests.
## License
Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.

Sorry, the diff of this file is too big to display

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