json-rpc-middleware-stream
Advanced tools
Comparing version 4.2.3 to 5.0.1
@@ -0,6 +1,6 @@ | ||
import type { JsonRpcEngine } from '@metamask/json-rpc-engine'; | ||
import { Duplex } from 'readable-stream'; | ||
import { JsonRpcEngine } from 'json-rpc-engine'; | ||
interface EngineStreamOptions { | ||
declare type EngineStreamOptions = { | ||
engine: JsonRpcEngine; | ||
} | ||
}; | ||
/** | ||
@@ -7,0 +7,0 @@ * Takes a JsonRpcEngine and returns a Duplex stream wrapping it. |
@@ -12,3 +12,3 @@ "use strict"; | ||
function createEngineStream(opts) { | ||
if (!opts || !opts.engine) { | ||
if (!(opts === null || opts === void 0 ? void 0 : opts.engine)) { | ||
throw new Error('Missing engine parameter!'); | ||
@@ -30,9 +30,9 @@ } | ||
* @param _encoding - The stream encoding, not used. | ||
* @param cb - The stream write callback. | ||
* @param streamWriteCallback - The stream write callback. | ||
*/ | ||
function write(req, _encoding, cb) { | ||
function write(req, _encoding, streamWriteCallback) { | ||
engine.handle(req, (_err, res) => { | ||
stream.push(res); | ||
}); | ||
cb(); | ||
streamWriteCallback(); | ||
} | ||
@@ -39,0 +39,0 @@ } |
@@ -0,7 +1,8 @@ | ||
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; | ||
import SafeEventEmitter from '@metamask/safe-event-emitter'; | ||
import type { JsonRpcParams } from '@metamask/utils'; | ||
import { Duplex } from 'readable-stream'; | ||
import { JsonRpcMiddleware } from 'json-rpc-engine'; | ||
interface Options { | ||
declare type Options = { | ||
retryOnMessage?: string; | ||
} | ||
}; | ||
/** | ||
@@ -18,5 +19,5 @@ * Creates a JsonRpcEngine middleware with an associated Duplex stream and | ||
events: SafeEventEmitter; | ||
middleware: JsonRpcMiddleware<unknown, unknown>; | ||
middleware: JsonRpcMiddleware<JsonRpcParams, JsonRpcParams>; | ||
stream: Duplex; | ||
}; | ||
export {}; |
@@ -46,6 +46,6 @@ "use strict"; | ||
* @param _encoding - The stream encoding, not used. | ||
* @param cb - The stream write callback. | ||
* @param streamWriteCallback - The stream write callback. | ||
*/ | ||
function processMessage(res, _encoding, cb) { | ||
let err = null; | ||
function processMessage(res, _encoding, streamWriteCallback) { | ||
let errorObj = null; | ||
try { | ||
@@ -61,6 +61,6 @@ const isNotification = !res.id; | ||
catch (_err) { | ||
err = _err; | ||
errorObj = _err; | ||
} | ||
// continue processing stream | ||
cb(err); | ||
streamWriteCallback(errorObj); | ||
} | ||
@@ -73,8 +73,9 @@ /** | ||
function processResponse(res) { | ||
const context = idMap[res.id]; | ||
const responseId = res.id; | ||
const context = idMap[responseId]; | ||
if (!context) { | ||
console.warn(`StreamMiddleware - Unknown response id "${res.id}"`); | ||
console.warn(`StreamMiddleware - Unknown response id "${responseId}"`); | ||
return; | ||
} | ||
delete idMap[res.id]; | ||
delete idMap[responseId]; | ||
// copy whole res onto original res | ||
@@ -81,0 +82,0 @@ Object.assign(context.res, res); |
{ | ||
"name": "json-rpc-middleware-stream", | ||
"version": "4.2.3", | ||
"version": "5.0.1", | ||
"description": "A small toolset for streaming JSON-RPC data and matching requests and responses.", | ||
@@ -17,6 +17,7 @@ "repository": { | ||
"build:clean": "rimraf dist && yarn build", | ||
"lint": "yarn lint:eslint && yarn lint:misc --check", | ||
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:dependencies", | ||
"lint:dependencies": "depcheck", | ||
"lint:eslint": "eslint . --cache --ext js,ts", | ||
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", | ||
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", | ||
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", | ||
"prepublishOnly": "yarn build:clean && yarn lint && yarn test", | ||
@@ -28,5 +29,6 @@ "setup": "yarn install && yarn allow-scripts", | ||
"dependencies": { | ||
"@metamask/json-rpc-engine": "^7.1.1", | ||
"@metamask/safe-event-emitter": "^3.0.0", | ||
"json-rpc-engine": "^6.1.0", | ||
"readable-stream": "^2.3.3" | ||
"@metamask/utils": "^8.1.0", | ||
"readable-stream": "^3.6.2" | ||
}, | ||
@@ -37,23 +39,24 @@ "devDependencies": { | ||
"@metamask/auto-changelog": "^3.0.0", | ||
"@metamask/eslint-config": "^9.0.0", | ||
"@metamask/eslint-config-jest": "^9.0.0", | ||
"@metamask/eslint-config-nodejs": "^9.0.0", | ||
"@metamask/eslint-config-typescript": "^9.0.1", | ||
"@metamask/eslint-config": "^12.0.0", | ||
"@metamask/eslint-config-jest": "^12.0.0", | ||
"@metamask/eslint-config-nodejs": "^12.0.0", | ||
"@metamask/eslint-config-typescript": "^12.0.0", | ||
"@types/jest": "^26.0.13", | ||
"@types/node": "^17.0.23", | ||
"@types/readable-stream": "^2.3.9", | ||
"@typescript-eslint/eslint-plugin": "^4.21.0", | ||
"@typescript-eslint/parser": "^4.21.0", | ||
"eslint": "^7.23.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.3.4", | ||
"eslint-plugin-jsdoc": "^36.1.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"@typescript-eslint/eslint-plugin": "^5.30.7", | ||
"@typescript-eslint/parser": "^5.30.7", | ||
"depcheck": "^1.4.5", | ||
"eslint": "^8.44.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^27.1.5", | ||
"eslint-plugin-jsdoc": "^39.3.3", | ||
"eslint-plugin-n": "^15.7.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"extension-port-stream": "^2.0.1", | ||
"jest": "^27.5.1", | ||
"jest-it-up": "^2.0.2", | ||
"json-rpc-engine": "^6.1.0", | ||
"prettier": "^2.2.1", | ||
"prettier": "^2.7.1", | ||
"prettier-plugin-packagejson": "^2.2.17", | ||
@@ -63,7 +66,8 @@ "rimraf": "^3.0.2", | ||
"ts-node": "^10.7.0", | ||
"typescript": "^4.2.4", | ||
"typescript": "~4.8.4", | ||
"webextension-polyfill-ts": "^0.26.0" | ||
}, | ||
"packageManager": "yarn@3.6.3", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": "^16.20 || ^18.16 || >=20" | ||
}, | ||
@@ -70,0 +74,0 @@ "publishConfig": { |
# json-rpc-middleware-stream | ||
A small toolset for streaming JSON RPC data and matching requests and responses. Made to be used with [`json-rpc-engine`](https://npmjs.com/package/json-rpc-engine). | ||
A small toolset for streaming JSON RPC data and matching requests and responses. Made to be used with [`@metamask/json-rpc-engine`](https://npmjs.com/package/@metamask/json-rpc-engine). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200
20521
4
31
12
+ Added@metamask/utils@^8.1.0
+ Added@ethereumjs/common@3.2.0(transitive)
+ Added@ethereumjs/rlp@4.0.1(transitive)
+ Added@ethereumjs/tx@4.2.0(transitive)
+ Added@ethereumjs/util@8.1.0(transitive)
+ Added@metamask/json-rpc-engine@7.3.3(transitive)
+ Added@metamask/rpc-errors@6.4.0(transitive)
+ Added@metamask/superstruct@3.1.0(transitive)
+ Added@metamask/utils@8.5.09.2.1(transitive)
+ Added@noble/curves@1.4.2(transitive)
+ Added@noble/hashes@1.4.01.5.0(transitive)
+ Added@scure/base@1.1.9(transitive)
+ Added@scure/bip32@1.4.0(transitive)
+ Added@scure/bip39@1.3.0(transitive)
+ Added@types/debug@4.1.12(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedethereum-cryptography@2.2.1(transitive)
+ Addedmicro-ftch@0.3.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpony-cause@2.1.11(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addeduuid@9.0.1(transitive)
- Removedjson-rpc-engine@^6.1.0
- Removed@metamask/safe-event-emitter@2.0.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedeth-rpc-errors@4.0.3(transitive)
- Removedisarray@1.0.0(transitive)
- Removedjson-rpc-engine@6.1.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
Updatedreadable-stream@^3.6.2