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

@adt/json-rpc

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adt/json-rpc - npm Package Compare versions

Comparing version 0.0.1-SNAPSHOT.19 to 0.0.1-SNAPSHOT.20

94

dist/JsonRpc.cjs.js

@@ -16,14 +16,2 @@ 'use strict';

/**
* TODO: Implementation
* Parses Json to JsonRpc object
* @param {String} str
* @return JsonRpcElement
*/
JsonRpcElement.parse = function (str) {
// TODO:
};
JsonRpcElement.prototype = Object.freeze(Object.create(null, /** @lends JsonRpcElement.prototype */{

@@ -409,3 +397,3 @@ jsonrpc: { value: "2.0" },

/**
* Serialize request to object to string
* Serialize request object to string
* @return {String}

@@ -505,2 +493,82 @@ */

//import JsonRpcElement from "./JsonRpcElement";
/**
* Parses Json to JsonRpc object
* @param {String} str String to parse
* @param {Boolean} [weak=false] Don't check for existence of "jsonrpc" property in object
* @return JsonRpcElement
*/
var parse = function parse(str, weak) {
var u = "undefined";
var obj = void 0;
try {
obj = JSON.parse(str);
} catch (e) {
throw new Error("String " + str + " is not a valid JSON");
}
if (weak === true && "jsonrpc" in obj === false) {
// TODO: Dedicated exception
throw new Error("Missing 'jsonrpc' property in unserialized. You can omit this check by using the `weak` param");
}
var _obj = obj,
id = _obj.id,
method = _obj.method,
result = _obj.result,
error = _obj.error,
params = _obj.params;
if ((typeof id === "undefined" ? "undefined" : _typeof(id)) !== u) {
// Request or response
if ((typeof method === "undefined" ? "undefined" : _typeof(method)) !== u) {
if ((typeof params === "undefined" ? "undefined" : _typeof(params)) === u) {
throw new Error("Missing 'method' property in unserialized object");
}
return JsonRpcRequest({
id: id, method: method, params: params
});
} else if ((typeof result === "undefined" ? "undefined" : _typeof(result)) !== u) {
return JsonRpcResponseResult({
id: id, result: result
});
} else if ((typeof error === "undefined" ? "undefined" : _typeof(error)) !== u) {
var code = error.code,
message = error.message,
data = error.data;
return JsonRpcResponseError({
id: id,
error: JsonRpcError({
code: code, message: message, data: data
})
});
} else {
// TODO: Dedicated Exception
throw new Error("Unserialized object is not a valid JSON-RPC element");
}
} else {
// Event
return JsonRpcEvent({
method: method, params: params
});
}
};
JsonRpcElement.parse = parse;
JsonRpcElement.fromJson = parse;
exports.JsonRpcElement = JsonRpcElement;

@@ -507,0 +575,0 @@ exports.JsonRpcError = JsonRpcError;

@@ -12,14 +12,2 @@ /**

/**
* TODO: Implementation
* Parses Json to JsonRpc object
* @param {String} str
* @return JsonRpcElement
*/
JsonRpcElement.parse = function (str) {
// TODO:
};
JsonRpcElement.prototype = Object.freeze(Object.create(null, /** @lends JsonRpcElement.prototype */{

@@ -405,3 +393,3 @@ jsonrpc: { value: "2.0" },

/**
* Serialize request to object to string
* Serialize request object to string
* @return {String}

@@ -501,2 +489,82 @@ */

//import JsonRpcElement from "./JsonRpcElement";
/**
* Parses Json to JsonRpc object
* @param {String} str String to parse
* @param {Boolean} [weak=false] Don't check for existence of "jsonrpc" property in object
* @return JsonRpcElement
*/
var parse = function parse(str, weak) {
var u = "undefined";
var obj = void 0;
try {
obj = JSON.parse(str);
} catch (e) {
throw new Error("String " + str + " is not a valid JSON");
}
if (weak === true && "jsonrpc" in obj === false) {
// TODO: Dedicated exception
throw new Error("Missing 'jsonrpc' property in unserialized. You can omit this check by using the `weak` param");
}
var _obj = obj,
id = _obj.id,
method = _obj.method,
result = _obj.result,
error = _obj.error,
params = _obj.params;
if ((typeof id === "undefined" ? "undefined" : _typeof(id)) !== u) {
// Request or response
if ((typeof method === "undefined" ? "undefined" : _typeof(method)) !== u) {
if ((typeof params === "undefined" ? "undefined" : _typeof(params)) === u) {
throw new Error("Missing 'method' property in unserialized object");
}
return JsonRpcRequest({
id: id, method: method, params: params
});
} else if ((typeof result === "undefined" ? "undefined" : _typeof(result)) !== u) {
return JsonRpcResponseResult({
id: id, result: result
});
} else if ((typeof error === "undefined" ? "undefined" : _typeof(error)) !== u) {
var code = error.code,
message = error.message,
data = error.data;
return JsonRpcResponseError({
id: id,
error: JsonRpcError({
code: code, message: message, data: data
})
});
} else {
// TODO: Dedicated Exception
throw new Error("Unserialized object is not a valid JSON-RPC element");
}
} else {
// Event
return JsonRpcEvent({
method: method, params: params
});
}
};
JsonRpcElement.parse = parse;
JsonRpcElement.fromJson = parse;
export { JsonRpcElement, JsonRpcError, JsonRpcEvent, JsonRpcRequest, JsonRpcResponse, JsonRpcResponseError, JsonRpcResponseResult };

@@ -24,14 +24,2 @@ (function (global, factory) {

/**
* TODO: Implementation
* Parses Json to JsonRpc object
* @param {String} str
* @return JsonRpcElement
*/
JsonRpcElement.parse = function (str) {
// TODO:
};
JsonRpcElement.prototype = Object.freeze(Object.create(null, /** @lends JsonRpcElement.prototype */{

@@ -417,3 +405,3 @@ jsonrpc: { value: "2.0" },

/**
* Serialize request to object to string
* Serialize request object to string
* @return {String}

@@ -513,2 +501,82 @@ */

//import JsonRpcElement from "./JsonRpcElement";
/**
* Parses Json to JsonRpc object
* @param {String} str String to parse
* @param {Boolean} [weak=false] Don't check for existence of "jsonrpc" property in object
* @return JsonRpcElement
*/
var parse = function parse(str, weak) {
var u = "undefined";
var obj = void 0;
try {
obj = JSON.parse(str);
} catch (e) {
throw new Error("String " + str + " is not a valid JSON");
}
if (weak === true && "jsonrpc" in obj === false) {
// TODO: Dedicated exception
throw new Error("Missing 'jsonrpc' property in unserialized. You can omit this check by using the `weak` param");
}
var _obj = obj,
id = _obj.id,
method = _obj.method,
result = _obj.result,
error = _obj.error,
params = _obj.params;
if ((typeof id === "undefined" ? "undefined" : _typeof(id)) !== u) {
// Request or response
if ((typeof method === "undefined" ? "undefined" : _typeof(method)) !== u) {
if ((typeof params === "undefined" ? "undefined" : _typeof(params)) === u) {
throw new Error("Missing 'method' property in unserialized object");
}
return JsonRpcRequest({
id: id, method: method, params: params
});
} else if ((typeof result === "undefined" ? "undefined" : _typeof(result)) !== u) {
return JsonRpcResponseResult({
id: id, result: result
});
} else if ((typeof error === "undefined" ? "undefined" : _typeof(error)) !== u) {
var code = error.code,
message = error.message,
data = error.data;
return JsonRpcResponseError({
id: id,
error: JsonRpcError({
code: code, message: message, data: data
})
});
} else {
// TODO: Dedicated Exception
throw new Error("Unserialized object is not a valid JSON-RPC element");
}
} else {
// Event
return JsonRpcEvent({
method: method, params: params
});
}
};
JsonRpcElement.parse = parse;
JsonRpcElement.fromJson = parse;
exports.JsonRpcElement = JsonRpcElement;

@@ -515,0 +583,0 @@ exports.JsonRpcError = JsonRpcError;

2

package.json
{
"name": "@adt/json-rpc",
"version": "0.0.1-SNAPSHOT.19",
"version": "0.0.1-SNAPSHOT.20",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "dist/JsonRpc.cjs.js",

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