{"id":41653029,"url":"https://github.com/leonardoraele/json-rpc-dual-engine","last_synced_at":"2026-01-24T16:17:40.242Z","repository":{"id":57285136,"uuid":"332313097","full_name":"leonardoraele/json-rpc-dual-engine","owner":"leonardoraele","description":"A Javascript JSON-RPC-2.0 transport protocol agnostic client and server engine.","archived":false,"fork":false,"pushed_at":"2025-09-08T17:59:13.000Z","size":606,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T15:19:16.783Z","etag":null,"topics":["client","http","https","json","json-rpc","json-rpc-client","json-rpc-engine","json-rpc-server","json-rpc2","rpc","server","server-engines","socket","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonardoraele.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-23T21:38:34.000Z","updated_at":"2025-09-08T17:59:17.000Z","dependencies_parsed_at":"2022-09-19T23:21:48.966Z","dependency_job_id":null,"html_url":"https://github.com/leonardoraele/json-rpc-dual-engine","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/leonardoraele/json-rpc-dual-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardoraele%2Fjson-rpc-dual-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardoraele%2Fjson-rpc-dual-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardoraele%2Fjson-rpc-dual-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardoraele%2Fjson-rpc-dual-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonardoraele","download_url":"https://codeload.github.com/leonardoraele/json-rpc-dual-engine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardoraele%2Fjson-rpc-dual-engine/sbom","scorecard":{"id":584964,"data":{"date":"2025-08-11","repo":{"name":"github.com/leonardoraele/json-rpc-dual-engine","commit":"e90e92ce9022d48eed31fc04ebf91dfb690a1c98"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Maintained","score":5,"reason":"6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardoraele/json-rpc-dual-engine/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardoraele/json-rpc-dual-engine/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardoraele/json-rpc-dual-engine/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardoraele/json-rpc-dual-engine/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardoraele/json-rpc-dual-engine/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardoraele/json-rpc-dual-engine/test.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   3 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/publish.yml:32","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T20:12:21.337Z","repository_id":57285136,"created_at":"2025-08-20T20:12:21.337Z","updated_at":"2025-08-20T20:12:21.337Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28731223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","http","https","json","json-rpc","json-rpc-client","json-rpc-engine","json-rpc-server","json-rpc2","rpc","server","server-engines","socket","websocket"],"created_at":"2026-01-24T16:17:39.640Z","updated_at":"2026-01-24T16:17:40.236Z","avatar_url":"https://github.com/leonardoraele.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-rpc-dual-engine\n![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/leonardoraele/json-rpc-dual-engine/Test/master)\n![NPM](https://img.shields.io/npm/l/json-rpc-dual-engine)\n![node-current](https://img.shields.io/node/v/json-rpc-dual-engine)\n![npm](https://img.shields.io/npm/v/json-rpc-dual-engine)\n![GitHub last commit](https://img.shields.io/github/last-commit/leonardoraele/json-rpc-dual-engine)\n![npm](https://img.shields.io/npm/dw/json-rpc-dual-engine)\n\nA transport agnostic implementation of the [JSON-RPC-2.0 spec].\n\nThis package includes a client and a server.\nYou can import either separately without increasing the size of your final build, if you don't need both.\n\n[JSON-RPC-2.0 spec]: https://www.jsonrpc.org/specification\n\n## Install\n\n```bash\nnpm install json-rpc-dual-engine\n```\n\n## Usage\n\n### Server\nCreate the server with an object that implements the methods to be exposed to the client:\n\n```js\nimport { JsonRpcServer } from 'json-rpc-dual-engine/server';\n\nconst api = {\n\tmultiply(a, b) {\n\t\treturn a * b;\n\t},\n\tping() {\n\t\treturn 'pong';\n\t},\n};\n\nconst server = new JsonRpcServer({ api });\n```\n\nRegister a `transport` callback to receive the json-rpc responses generated by the server:\n\n```js\n// `transport` will be called whenever the server generates a response.\n// It's your job is to send it to the client somehow.\nserver.transport = response =\u003e console.log(response);\n```\n\nThen use the `accept` method to deliver incoming remote method calls to the server.\nThe server validates the json-rpc message call, calls the appropriate registered method,\nand generate the appropriate json-rpc response based on the return of the registered handler.\n\n```js\n// It's your job to receive the request from the client somehow.\nconst request = '{\"jsonrpc\":\"2.0\",\"method\":\"multiply\",\"params\":[7,11],\"id\":\"1\"}';\n\nserver.accept(request);\n// Output: '{\"jsonrpc\":\"2.0\",\"result\":77,\"id\":\"1\"}'\n```\n\n### Client\nCreate the client:\n\n```js\nimport { JsonRpcClient } from 'json-rpc-dual-engine/client';\n\nconst client = new JsonRpcClient();\n```\n\nRegister a `transport` callack to send requests made by the client to the server.\n\n```js\n// It's your job to send the requests to the server somehow.\nclient.transport = request =\u003e console.log(request);\n\nclient.sendRequest('multiply', [7, 11]);\n// Output: '{\"jsonrpc\":\"2.0\",\"method\":\"multiply\",\"params\":[7,11],\"id\":\"1\"}'\n\nclient.sendNotification('ping'); // no return\n// Output: '{\"jsonrpc\":\"2.0\",\"method\":\"ping\"}'\n\n// Or use the proxy object:\nclient.remote.multiply(7, 11);\nclient.remote.ping();\n```\n\nUse the `accept` method to deliver incoming server responses to the client to resolve request promises.\n\n```js\n// Using setTimeout to simulate a future incoming message from the server\nsetTimeout(100, () =\u003e {\n\tconst response = '{\"jsonrpc\":\"2.0\",\"result\":77,\"id\":\"2\"}'; // Gets a response from the server somehow\n\tclient.accept(response);\n});\n\nconst result = await client.request('multiply', [7, 11]);\n\nconsole.log(result); // Output: 77\n```\n\nOr using the proxy object:\n\n```js\nconst remote = client.remote;\n\nconst result = await remote.multiply(7, 11);\n\nconsole.log(result); // Output: 77\n```\n\n### Server and Client\n\nThe `JsonRpcDualEngine` class includes both a client and a server in it.\nIt's useful in cases where you need bidirectional communication.\nThe `accept()` method of the dual engine accepts both requests and responses.\n\n```js\nimport { JsonRpcDualEngine } from 'json-rpc-dual-engine';\n\nconst engine1 = new JsonRpcDualEngine({\n\tapi: {\n\t\tgetId() { return '1'; }\n\t}\n});\n\nconst engine2 = new JsonRpcDualEngine({\n\tapi: {\n\t\tgetId() { return '2'; }\n\t}\n});\n\nengine1.onmessage = message =\u003e engine2.accept(message);\nengine2.onmessage = message =\u003e engine1.accept(message);\n\nconsole.log(await engine1.sendRequest('getId')); // Output: '2'\nconsole.log(await engine2.sendRequest('getId')); // Output: '1'\n```\n\n### WebSocket Example\n\nOn the server side:\n\n```js\nimport { JsonRpcServer } from 'json-rpc-dual-engine/server';\nimport { WebSocketServer } from 'ws';\n\nconst wss = new WebSocketServer({ port: 8080 });\nconst engine = JsonRpcServer({\n\tapi: {\n\t\tmultiply(a, b) {\n\t\t\treturn a * b;\n\t\t}\n\t}\n});\n\nwss.on('connection', ws =\u003e {\n\tws.on('message', request =\u003e engine.accept(request)); // Messages from the client are handled by the engine\n\tengine.transport = response =\u003e ws.send(response); // Responses are sent to the client via websocket\n});\n```\n\nOn the client side:\n\n```js\nimport { JsonRpcClient } from 'json-rpc-dual-engine/client';\nimport WebSocket from 'ws';\n\nconst websocket = new WebSocket('ws://remote.example');\nconst engine = new JsonRpcClient();\n\nengine.transport = request =\u003e websocket.send(request); // Requests are sent to the server via websocket\nwebsocket.on('message', response =\u003e engine.accept(response)); // Responses from the server are handled by the engine\n\n// Waits for connection before sending a message\nawait new Promise((resolve, reject) =\u003e {\n\twebsocket.onopen = resolve;\n\twebsocket.onerror = reject;\n});\n\n// Sends a json-rpc request through webscoket to the remote server and waits for the response\nconst result = await engine.remote.multiply(7, 11);\n\nconsole.log(result); // Output: 77\n```\n\n\u003c!-- ### Streams\n\nYou can use the `JsonRpcStream` to work with Node.js streams.\nIt creates a `Duplex` streams that sends incoming data to the engine\nand outputs messages (client requests or server responses) generated by engine.\nIt works with both client and server engines.\n\n```js\nconst { JsonRpcClient, JsonRpcServer } = require('json-rpc-dual-engine');\nconst JsonRpcStream = require('json-rpc-dual-engine/stream');\n\nconst server = JsonRpcStream(JsonRpcServer());\nconst client = JsonRpcStream(JsonRpcClient());\n\n// Streams use the dual engine, which can act as both client and server\nserver.engine.register('multiply', (a, b) =\u003e a * b);\n\n// Pipes requests from the client to the server, and responses from the server back to the client\nclient.pipe(server).pipe(client);\n\nconst result = await client.engine.request('multiply', [7, 11]);\n\nconsole.log(result); // Output: 77\n``` --\u003e\n\n## Development Environment\n\n#### Install Deps\n\n\tnpm install\n\n#### Test\n\n\tnpm test\n\n#### Coverage\n\n\tnpm run coverage\n\n## LICENSE\n\n[MIT](./LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardoraele%2Fjson-rpc-dual-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonardoraele%2Fjson-rpc-dual-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardoraele%2Fjson-rpc-dual-engine/lists"}