Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
json-rpiecy
Advanced tools
Rpiecy is a lightweighted lib for managing JSON-RPC objects and comunication.
The easiest way of installing is using npm:
$ npm i json-rpiecy -s
Or using yarn:
$ yarn add json-rpiecy
Using node require:
const rpiecy = require('json-rpiecy');
Using es6 imports:
import * as rpiecy from 'json-rpiecy';
Accepts a set of arguments, and returns a rpiecy.Request instance.
Signatures:
rpiecy.createRequest(method, params?, id?)
string
object | array
string | number | null
rpiecy.createRequest(object)
object
string
object | array
string | number | null
Accepts a set of arguments, and returns a rpiecy.Response instance.
Signatures:
rpiecy.createResponse(id, result?, error?)
string | number
string
rpiecy.Error
rpiecy.createResponse(object)
object
Parses a json string into a Request a Notification a Response or an Error.
Signature:
rpiecy.parse(str)
Listens for requests on specified server/input, check this for more info.
By default it uses stdio for listening and outputing
Signature:
rpiecy.listen(callback)
Listens for method to be passed
Signature:
rpiecy.listenFor(method, callback): void
Outputs a rpc entity via defined output channel
Signature:
rpiecy.output(rpcEnt): void
Outputs an rpc Request via defined output channel, and awaits the response, it returns a Promise<RpcResponse>
Signature:
rpiecy.sendAndAwait(req): Promise<rpiecy.Response>
Namespace containing a set of utility methods for rpc validation.
Check if string or object is valid rpc
Signature:
rpiecy.validate.isRpc(value: string | object): boolean
A rpc call is represented by a Request object.
Signature:
rpiecy.Request(method, params?, id?)
string
object | array
string | number | null
rpiecy.Request(object)
object
string
object | array
string | number | null
Methods:
.response(result: object): Response<result>
- creates a Response object for this request.error(message: string, code: number, data?:any): Response<error>
- creates an Response with error for this request.error(error?: object): Response<error>
- overload for accepting an object as first argument.matches(method: string): boolean
- Check if request matches method.sendAndAwait(): Promise<Response>
- Sends a request to set output channel, and awaits the responseA Notification is a Request object without an "id" member. A Request object that is a Notification signifies the Client's lack of interest in the corresponding Response object, and as such no Response object needs to be returned to the client. The Server MUST NOT reply to a Notification, including those that are within a batch request.
When a rpc call is made, the Server MUST reply with a Response, except for in the case of Notifications.
Signature:
rpiecy.Response(id, result?, error?)
string | number
string
rpiecy.Error
rpiecy.Response(object)
object
object | array
object | array
string | number | null
When a rpc call encounters an error, the Response Object MUST contain the error member with a value that is a RpcError:
Signature:
rpiecy.RpcError(message, code, data?)
string
number
object | array
rpiecy.RpcError(object)
object
string
number
object | array
Static Constants:
Error.INTERNAL_ERROR
= -32603Error.INVALID_PARAMS
= -32602Error.METHOD_NOT_FOUND
= -32601Error.INVALID_REQUEST
= -32600Error.PARSE_ERROR
= -32700Error.TIMED_OUT
= -32001const rpiecy = require('rpiecy');
const request = rpiecy.createRequest({ method: 'method', params: {}, id: 'id' });
request.print();
request.output();
const response = rpiecy.createResponse('id', { /* result */ });
response.print();
response.output();
rpiecy.sendAndAwait(request)
.then(response => {
console.log(`Response for ${request.id}: `, response);
})
rpiecy.listen((request) => {
console.log(`Received request ${request.id}: `, request);
request.response({ data: SOME_DATA }).output();
});
const method = rpiecy.createMethod('test-method', {});
rpiecy.listenFor(method, (request) => {
console.log(`Received request ${request.id}: `, request);
request.response({ data: SOME_DATA }).output();
});
FAQs
rpiecy is a lightweighted lib for managing JSON-RPC calls
We found that json-rpiecy 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.