
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
jsonrpcserver
Advanced tools
JSON-RPC Server (http://www.jsonrpc.org/specification) with endpoints implementation
Simple-to-use JSON-RPC Server with endpoints implementation (JSON-RPC Specification).
$ npm install jsonrpcserver --save
You can instantiate HTTP-server (default usage):
var logger = require('mylogger'),
API = require('myapi'),
JsonRpcServer = require('jsonrpcserver');
var rpcServerInstance = new JsonRpcServer(logger); //logger is an optional one
...
rpcServerInstance.register('/my/new/endpoint', {
"context": new API(),
"map": {
"testMethod": {
"handler": "test",
"params": [
{
"type": "string",
"required": true
}
]
},
"yetAnotherMethod": {
"handler": function(options, cb) {
(typeof cb == 'function') && cb(null, options);
},
"params": {
"first": {
"type": "number",
"required": true
},
"second": {
"type": "any",
"required": false,
"default": "Foo"
}
}
}
}
});
...
rpcServerInstance.init({
handler: 80,
timeout: 10
});
Or you can use jsonrpcserver as proxy:
var logger = require('mylogger'),
API = require('myapi'),
JsonRpcServer = require('jsonrpcserver');
var rpcServerInstance = new JsonRpcServer(logger); //logger is an optional one
...
rpcServerInstance.register('/my/new/endpoint', {
"context": new API(),
"map": {
"testMethod": {
"handler": "test",
"params": [
{
"type": "string",
"required": true
}
]
},
"yetAnotherMethod": {
"handler": function(options, cb) {
(typeof cb == 'function') && cb(null, options);
},
"params": {
"first": {
"type": "number",
"required": true
},
"second": {
"type": "any",
"required": false,
"default": "Foo"
}
}
}
}
});
...
// proxy my request
var request = {
method: "yetAnotherMethod",
params: {
first: 1,
second: "Bar"
},
id: 1
};
rpcServerInstance.proxy('/my/new/endpoint', request, function(response) {
console.log(response);
// {
// httpCode: 200,
// headers: {
// 'Content-Type': 'application/json-rpc'
// },
// payload: {
// jsonrpc: '2.0',
// result: { ok: 1 },
// id: 1
// }
// }
});
constructor (logger)
- create the serverlogger
- an optional parameter, it means reference to the logger instance; console will use by defaultregister (endpoint, map)
- register endpointYou can use register
method (as well as unload
) at any time in code, definition order (before or after init
) doesn't matter.
endpoint
- - endpoint URI, that will handle your requestsmap
- - API schema map, such as (type 'any'
could use for non-strict type validation):
/**
* @param map = {
* context: <object>,
* map: {
* methodName1: {
* handler: <functionName|callable>,
* //-- with named params ---
* params: {
* param1: {
* type: "string|number|boolean|object|array|any",
* required: true|false,
* default: <defaultValue>
* },
* ...
* }
* //-- or with array-like params --
* params: [
* {
* type: "string|number|boolean|object|array|any",
* required: true|false,
* default: <defaultValue>
* },
* ...
* ]
* },
* ...
* }
* }
*/
unload (endpoint)
- unload the endpointendpoint
- - endpoint URI that would be unloadedproxy (endpoint, payload, callback)
- emulate the requestendpoint
- - endpoint URI that would be unloadedpayload
- - request object according to JSON-RPC 2.0 Specification
callback
- - callback that handles the responseinit (configuration)
- instantiate the serverconfiguration
- - an optional parameter, that describe server configuration (look below, with defaults):
{
"handler": 80, // it may be port, unix-socket path or instance of HTTP/HTTPS server, by default 80 port
"https": false, // boolean flag sets true if we want set up the HTTPS server
"key": null, // the SSL-key path (for HTTPS only)
"cert": null, // the SSL-cert path (for HTTPS only)
"timeout": 60 // the request timeout in sec, by default 60
}
Not-implemented features:
MIT
FAQs
JSON-RPC Server (http://www.jsonrpc.org/specification) with endpoints implementation
The npm package jsonrpcserver receives a total of 0 weekly downloads. As such, jsonrpcserver popularity was classified as not popular.
We found that jsonrpcserver 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.