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

jayson

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jayson - npm Package Compare versions

Comparing version 3.5.2 to 3.6.1

3

lib/client/index.js

@@ -119,3 +119,4 @@ 'use strict';

generator: this.options.generator,
version: this.options.version
version: this.options.version,
notificationIdNull: this.options.notificationIdNull
});

@@ -122,0 +123,0 @@ } catch(err) {

@@ -12,2 +12,3 @@ 'use strict';

* @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)
* @param {Number} [options.notificationIdNull=false] When version is 2 and this option is true, the id of a notification request will be set to null instead of being omitted
* @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID

@@ -25,2 +26,8 @@ * @throws {TypeError} If any of the parameters are invalid

// check valid version provided
const version = typeof options.version === 'number' ? options.version : 2;
if (version !== 1 && version !== 2) {
throw new TypeError(version + ' must be 1 or 2');
}
const request = {

@@ -30,4 +37,3 @@ method: method

// assume that we are doing a 2.0 request unless specified differently
if(typeof options.version === 'undefined' || options.version !== 1) {
if(version === 2) {
request.jsonrpc = '2.0';

@@ -37,3 +43,2 @@ }

if(params) {
// params given, but invalid?

@@ -43,5 +48,3 @@ if(typeof params !== 'object' && !Array.isArray(params)) {

}
request.params = params;
}

@@ -53,2 +56,7 @@

request.id = generator(request, options);
} else if (version === 2 && id === null) {
// we have a version 2 notification
if (options.notificationIdNull) {
request.id = null; // id will not be set at all unless option provided
}
} else {

@@ -55,0 +63,0 @@ request.id = id;

{
"name": "jayson",
"version": "3.5.2",
"version": "3.6.1",
"description": "JSON-RPC 1.0/2.0 compliant server and client",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -119,4 +119,6 @@ # Jayson

## Changelog (only notable milestones)
## Changelog (only notable milestones/changes)
- *3.6.1*
- JSON-RPC 2.0 notifications no longer have id property unless overridden
- *3.3.3*

@@ -194,8 +196,9 @@ - Promise support for browser client

| Option | Default | Type | Description |
|------------- |------------------------------------ |------------ |---------------------------------------------------------- |
| `reviver` | `undefined` | `Function` | `JSON.parse` reviver |
| `replacer` | `undefined` | `Function` | `JSON.stringify` replacer |
| `generator` | [RFC4122][rfc_4122_spec] generator | `Function` | Generates a `String` for request ID. |
| `version` | 2 | `Number` | JSON-RPC version to support (1 or 2) |
| Option | Default | Type | Description |
|----------------------|------------------------------------|------------|------------------------------------------------------------------------------------------|
| `reviver` | `undefined` | `Function` | `JSON.parse` reviver |
| `replacer` | `undefined` | `Function` | `JSON.stringify` replacer |
| `generator` | [RFC4122][rfc_4122_spec] generator | `Function` | Generates a `String` for request ID. |
| `version` | 2 | `Number` | JSON-RPC version to support (1 or 2) |
| `notificationIdNull` | `false` | `Boolean` | *Since 3.6.1*. When true "id" property of a request will be set to null when version 2. |

@@ -368,3 +371,5 @@ [rfc_4122_spec]: http://www.ietf.org/rfc/rfc4122.txt

* See the [Official JSON-RPC 2.0 Specification][jsonrpc-spec] for additional information on how Jayson handles notifications that are erroneous.
* *Since 3.6.1* When making a JSON-RPC 2.0 notification request the "id" property will be omitted in the request object. In previous versions it was set to `null` against the recommendation of the official specification. This behaviour can be overridden with the `notificationIdNull` option.
#### Batches

@@ -371,0 +376,0 @@

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