Gathering detailed insights and metrics for jsonrpc-lite
Gathering detailed insights and metrics for jsonrpc-lite
Gathering detailed insights and metrics for jsonrpc-lite
Gathering detailed insights and metrics for jsonrpc-lite
npm install jsonrpc-lite
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
96 Stars
46 Commits
13 Forks
4 Watching
3 Branches
11 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
JavaScript (56.73%)
TypeScript (43.27%)
Cumulative downloads
Total Downloads
Last day
-22.5%
1,699
Compared to previous day
Last week
-6.5%
13,667
Compared to previous week
Last month
-5.7%
72,311
Compared to previous month
Last year
-22.2%
741,137
Compared to previous year
6
Parse and Serialize JSON-RPC2 messages in node.js or browser.
Inspired by https://github.com/soggie/jsonrpc-serializer
A implementation of JSON-RPC 2.0 specifications
1npm install jsonrpc-lite
1const jsonrpc = require('jsonrpc-lite')
Creates a JSON-RPC 2.0 request object, return JsonRpc object.
id
: {String|Integer}method
: {String}params
: {Object|Array}, optional1const requestObj = jsonrpc.request('123', 'update', {list: [1, 2, 3]}) 2// { 3// jsonrpc: '2.0', 4// id: '123', 5// method: 'update', 6// params: {list: [1, 2, 3]} 7// }
Creates a JSON-RPC 2.0 notification object, return JsonRpc object.
method
: {String}params
: {Object|Array}, optional1const notificationObj = jsonrpc.notification('update', {list: [1, 2, 3]}) 2// { 3// jsonrpc: '2.0', 4// method: 'update', 5// params: {list: [1, 2, 3]} 6// }
Creates a JSON-RPC 2.0 success response object, return JsonRpc object.
id
: {String|Integer}result
: {Mixed}1const successObj = jsonrpc.success('123', 'OK') 2// { 3// jsonrpc: '2.0', 4// id: '123', 5// result: 'OK', 6// }
Creates a JSON-RPC 2.0 error response object, return JsonRpc object.
id
: {String|Integer}error
: {JsonRpcError}1const errorObj = jsonrpc.error('123', new jsonrpc.JsonRpcError('some error', 99)) 2// { 3// jsonrpc: '2.0', 4// id: '123', 5// error: {code: 99, 'message': 'some error'}, 6// }
Takes a JSON-RPC 2.0 payload (string) and tries to parse it into a JSON. If successful, determine what object is it (response, notification, success, error, or invalid), and return it's type and properly formatted object.
message
: {String}return an array, or an object of this format:
single parsed request:
1{ 2 type: 'request', 3 payload: { 4 jsonrpc: '2.0', 5 id: 123, 6 method: 'update', 7 params: {} 8 } 9}
batch parsed result:
1[{ 2 type: 'request', 3 payload: { 4 jsonrpc: '2.0', 5 id: '123', 6 method: 'update', 7 params: [1, 2, 3] 8 } 9}, { 10 type: 'notification', 11 payload: { 12 jsonrpc: '2.0', 13 method: 'update', 14 params: {_id: 'xxx'} 15 } 16}, { 17 type: 'success', 18 payload: { 19 jsonrpc: '2.0', 20 id: '123', 21 result: 'OK' 22 } 23}, { 24 type: 'error', 25 payload: { 26 jsonrpc: '2.0', 27 id: '123', 28 error: [jsonrpc.JsonRpcError object] 29 } 30}, { 31 type: 'invalid', 32 payload: [jsonrpc.JsonRpcError object] 33}]
Takes a JSON-RPC 2.0 payload (Object) and tries to parse it into a JSON. If successful, determine what object is it (response, notification, success, error, or invalid), and return it's type and properly formatted object.
message
: {Object}return an JsonRpcParsed
object with type
and payload
.
Create a JsonRpcError instance.
message
: {String}code
: {Integer}data
: {Mixed} optional1const error = new jsonrpc.JsonRpcError('some error', 999)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
Found 4/17 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More