Socket
Socket
Sign inDemoInstall

json-rpc-engine

Package Overview
Dependencies
Maintainers
5
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rpc-engine - npm Package Compare versions

Comparing version 5.3.0 to 5.4.0

8

CHANGELOG.md

@@ -10,2 +10,8 @@ # Changelog

## [5.4.0] - 2020-11-07
### Changed
- Make the TypeScript types not terrible ([#66](https://github.com/MetaMask/json-rpc-engine/pull/66), [#67](https://github.com/MetaMask/json-rpc-engine/pull/67))
## [5.3.0] - 2020-07-30

@@ -29,3 +35,3 @@

They have been replaced with Promises and native `async`/`await`, which means that some operations are _no longer_ eagerly executed.
This change may affect consumers that depend on the eager execution of middleware _during_ middleware execution, _outside of_ middleware functions and request handlers.
This change may affect consumers that depend on the eager execution of middleware _during_ request processing, _outside of_ middleware functions and request handlers.
- In general, it is a bad practice to work with state that depends on middleware execution, while the middleware are executing.

2

package.json
{
"name": "json-rpc-engine",
"version": "5.3.0",
"version": "5.4.0",
"description": "a tool for processing JSON RPC",

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

@@ -1,21 +0,26 @@

import { IEthereumRpcError } from 'eth-rpc-errors/@types'
/** A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0". */
export type JsonRpcVersion = "2.0";
/**
* A String specifying the version of the JSON-RPC protocol.
* MUST be exactly "2.0".
*/
export type JsonRpcVersion = '2.0';
/** Method names that begin with the word rpc followed by a period character
* (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions
* and MUST NOT be used for anything else. */
* and MUST NOT be used for anything else.
*/
export type JsonRpcReservedMethod = string;
/** An identifier established by the Client that MUST contain a String, Number,
* or NULL value if included. If it is not included it is assumed to be a
* notification. The value SHOULD normally not be Null and Numbers SHOULD
* NOT contain fractional parts [2] */
/**
* An identifier established by the Client that MUST contain a String, Number,
* or NULL value if included. If it is not included it is assumed to be a
* notification. The value SHOULD normally not be Null and Numbers SHOULD
* NOT contain fractional parts.
*/
export type JsonRpcId = number | string | void;
interface JsonRpcError<T> extends IEthereumRpcError<T> {}
export interface JsonRpcError<T> extends IEthereumRpcError<T> {}
interface JsonRpcRequest<T> {
export interface JsonRpcRequest<T> {
jsonrpc: JsonRpcVersion;

@@ -27,38 +32,88 @@ method: string;

interface JsonRpcNotification<T> extends JsonRpcResponse<T> {
export interface JsonRpcNotification<T> {
jsonrpc: JsonRpcVersion;
method: string,
params?: T;
}
interface JsonRpcResponse<T> {
result?: any;
error?: JsonRpcError<any>;
jsonrpc: JsonRpcVersion;
id: JsonRpcId;
interface JsonRpcResponseBase {
jsonrpc: JsonRpcVersion,
id: JsonRpcId,
}
interface JsonRpcSuccess<T> extends JsonRpcResponse<T> {
result: any;
export interface JsonRpcSuccess<T> extends JsonRpcResponseBase {
result: T;
}
interface JsonRpcFailure<T> extends JsonRpcResponse<T> {
error: JsonRpcError<T>;
export interface JsonRpcFailure<T> extends JsonRpcResponseBase {
error: JsonRpcError<T>;
}
type JsonRpcEngineEndCallback = (error?: JsonRpcError<any>) => void;
type JsonRpcEngineNextCallback = (returnFlightCallback?: (done: () => void) => void) => void;
export type JsonRpcResponse<T> = JsonRpcSuccess<T> | JsonRpcFailure<T>
interface JsonRpcMiddleware {
export type JsonRpcEngineEndCallback = (error?: JsonRpcError<unknown>) => void;
type ReturnHandlerCallback = (done: (error?: Error) => void) => void
export type JsonRpcEngineNextCallback = (
returnHandlerCallback?: ReturnHandlerCallback,
) => void;
export type AsyncJsonRpcEngineNextCallback = (
returnHandlerCallback?: ReturnHandlerCallback,
) => Promise<void>;
export interface JsonRpcMiddleware {
(
req: JsonRpcRequest<any>,
res: JsonRpcResponse<any>,
req: JsonRpcRequest<unknown>,
res: JsonRpcResponse<unknown>,
next: JsonRpcEngineNextCallback,
end: JsonRpcEngineEndCallback,
) : void;
): void;
}
interface JsonRpcEngine {
export interface AsyncJsonrpcMiddleware {
(
req: JsonRpcRequest<unknown>,
res: JsonRpcResponse<unknown>,
next: AsyncJsonRpcEngineNextCallback,
): Promise<void>;
}
export interface JsonRpcEngine {
push: (middleware: JsonRpcMiddleware) => void;
handle: (req: JsonRpcRequest<any>, callback: (error: JsonRpcError<any>, res: JsonRpcResponse<any>) => void) => void;
handle: (
req: JsonRpcRequest<unknown>,
callback: (
error: JsonRpcError<unknown>,
res: JsonRpcResponse<unknown>,
) => void,
) => void;
}
export interface asMiddleware {
(engine: JsonRpcEngine): JsonRpcMiddleware;
}
export interface createAsyncMiddleware {
(asyncMiddleware: AsyncJsonrpcMiddleware): JsonRpcMiddleware;
}
type Serializable = boolean | number | string | Record<string, unknown> | unknown[] | null | undefined;
type ScaffoldMiddlewareHandler<T> = T extends Function ? JsonRpcMiddleware : Serializable;
export interface createScaffoldMiddleware<T> {
(handlers: {[methodName: string]: ScaffoldMiddlewareHandler<T>}): JsonRpcMiddleware;
}
export interface createIdRemapMiddleware {
(): JsonRpcMiddleware;
}
export interface mergeMiddleware {
(middlewares: JsonRpcMiddleware[]): JsonRpcMiddleware;
}
export interface getUniqueId {
(): number;
}

@@ -10,3 +10,3 @@ 'use strict'

module.exports = class RpcEngine extends SafeEventEmitter {
module.exports = class JsonRpcEngine extends SafeEventEmitter {
constructor () {

@@ -137,3 +137,3 @@ super()

for (const middleware of this._middleware) {
isComplete = await RpcEngine._runMiddleware(
isComplete = await JsonRpcEngine._runMiddleware(
req, res, middleware, returnHandlers,

@@ -140,0 +140,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