{"id":45277894,"url":"https://github.com/jershell/simple-jsonrpc-js","last_synced_at":"2026-02-21T02:01:35.210Z","repository":{"id":49376473,"uuid":"63328365","full_name":"jershell/simple-jsonrpc-js","owner":"jershell","description":"Simple jsonrpc javascript library. Generate and parse json rpc messages","archived":false,"fork":false,"pushed_at":"2021-03-03T14:00:25.000Z","size":142,"stargazers_count":66,"open_issues_count":2,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-02-05T20:08:57.610Z","etag":null,"topics":["jsonrpc","jsonrpc-js","websockets","webworker"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jershell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-14T10:46:57.000Z","updated_at":"2025-10-29T03:08:27.000Z","dependencies_parsed_at":"2022-08-25T04:21:29.216Z","dependency_job_id":null,"html_url":"https://github.com/jershell/simple-jsonrpc-js","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/jershell/simple-jsonrpc-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fsimple-jsonrpc-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fsimple-jsonrpc-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fsimple-jsonrpc-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fsimple-jsonrpc-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jershell","download_url":"https://codeload.github.com/jershell/simple-jsonrpc-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jershell%2Fsimple-jsonrpc-js/sbom","scorecard":{"id":516209,"data":{"date":"2025-08-11","repo":{"name":"github.com/jershell/simple-jsonrpc-js","commit":"baeadcfc31309d920fbb191293ca0f0722f31fbd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"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":"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":"Code-Review","score":1,"reason":"Found 3/27 approved changesets -- score normalized to 1","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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"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:0","Info: FSF or OSI recognized license: MIT License: LICENSE: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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T01:53:28.131Z","repository_id":49376473,"created_at":"2025-08-20T01:53:28.131Z","updated_at":"2025-08-20T01:53:28.131Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29671513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["jsonrpc","jsonrpc-js","websockets","webworker"],"created_at":"2026-02-21T02:01:34.632Z","updated_at":"2026-02-21T02:01:35.200Z","avatar_url":"https://github.com/jershell.png","language":"JavaScript","readme":"# simple-jsonrpc-js\n\n- Client and server.\n- Support websocket and http.\n- Full support for JSON-RPC 2.0 (including auto-incrementing request IDs)\n\nOriginally created by [jershell / QuickResto](https://github.com/jershell). ([original Github repo](https://github.com/jershell/simple-jsonrpc-js))\n\nSome updates written by [Privex Inc.](https://github.com/Privex) ([Privex's simple-jsonrpc fork repo](https://github.com/jershell/simple-jsonrpc-js))\n\n## Browser Quickstart\n\nFor usage in browsers, you can quickly add it to your web application from [Privex's](https://www.privex.io) CDN - which hosts both the latest\nGit version (master) of the library, along with official tagged release versions for safe production use.\n\n```html\n\u003cscript src=\"https://cdn.privex.io/lib/simple-jsonrpc/master/simple-jsonrpc-js.min.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n    // Create a Simple-JsonRPC object which can call HTTP JSON-RPC queries against the remote server https://rpc.example.com\n    var jrpc = simple_jsonrpc.connect_xhr('https://rpc.example.com');\n\n    // Equivelent to: {\"jsonrpc\":\"2.0\",\"method\":\"get_account\",\"id\":1,\"params\":[\"johndoe\"]}\n    jrpc.call('get_account', ['johndoe']).then(function(res) {\n        console.log(\"User ID:\", res.id);\n        console.log(\"User Email:\", res.email);\n        console.log(\"User Name:\", res.full_name);\n    });\n    // Equivelent to: {\"jsonrpc\":\"2.0\",\"method\":\"find_posts\",\"id\":2,\"params\":{\"tag\":\"python\",\"author\":\"jane.doe\"}}\n    jrpc.call('find_posts', {tag: 'python', author: 'jane.doe'}).then(function(posts) {\n        for (var p of posts) {\n            console.log(\"Post title:\", p.title)\n            console.log(\"Post tags:\", p.tags)\n            console.log(\"Post content:\", p.content)\n        }\n    });\n    // Equivelent to: {\"jsonrpc\":\"2.0\",\"method\":\"status\",\"id\":3}\n    jrpc.call('status').then(function(status) {\n        console.log(status);\n    });\n\n\u003c/script\u003e\n```\n\nFor safe production usage, you should use a versioned release of the library, with asset integrity attributes like so:\n\n```html\n\u003cscript src=\"https://cdn.privex.io/lib/simple-jsonrpc/1.0.0/simple-jsonrpc-js.min.js\" \n        integrity=\"sha384-AlmC3wzXXhOcKeP42iv0VOyrxth6bLTmu4l4YgK9oii9MArKWpLFBfrFN91OxnEO\" \n        crossorigin=\"anonymous\"\u003e\n\u003c/script\u003e\n```\n\nPrivex's CDN regularly publishes integrity hashes for the JS and CSS files they host, along with script/link tags with the integrity\nattributes pre-configured for easy copy pasting: [https://cdn.privex.io/integrity.txt](https://cdn.privex.io/integrity.txt) (CTRL-F for `simple-jsonrpc`)\n\n## Installing\n\nYou can install this package either with\n\n### Bower - for HTML web clients\n\n```sh\nbower install simple-jsonrpc-js\n```\n\n### NPM or Yarn - for NodeJS applications\n\n```sh\n# Installing simple-jsonrpc-js with Yarn (https://yarnpkg.com/)\nyarn install simple-jsonrpc-js\n# If you don't have / don't want to use Yarn, you can install using NPM normally\nnpm install simple-jsonrpc-js\n```\n\n## Building production JS\n\n```sh\n# Install the 'gulp' tool globally\nnpm install -g gulp-cli\n\ngit clone https://github.com/jershell/simple-jsonrpc-js.git\ncd simple-jsonrpc-js\n# Install NodeJS dependencies\nyarn install   # or npm install\n# Compile simple-jsonrpc-js.js into dist/simple-jsonrpc-js.min.js\nyarn build     # or npm build   ||  or just 'gulp compress'\n```\n\n## Usage\n\n(over WebSocket) on server:\n\n```js\n\nfunction add(x, y){\n    return x + y;\n}\n\n//over ws\nvar WebSocketServer = new require('ws');\nvar JsonRPC = require('simple-jsonrpc-js');\n\nvar webSocketServer = new WebSocketServer.Server({\n    host: '0.0.0.0',\n    port: 8090\n}).on('connection', function(ws) {\n    var jrpc = new JsonRPC();\n    ws.jrpc = jrpc;\n\n    ws.jrpc.toStream = function(message){\n        ws.send(message);\n    };\n\n    ws.on('message', function(message) {\n        jrpc.messageHandler(message);\n    });\n\n    jrpc.on('add', ['x', 'y'], add);\n\n    jrpc.on('mul', ['x', 'y'], function(x, y){\n        return x*y;\n    });\n\n    var item_id = 120;\n\n    jrpc.on('create', ['item', 'rewrite'], function(item, rewrite){\n        item_id ++;\n        item.id = item_id;\n        return item;\n    });\n\n    jrpc.call('view.setTitle', [\"JSONRPC over ws\"]);\n\n});\n\n```\n\nAnd on client:\n\n```js\n        //configure\n        var jrpc = new simple_jsonrpc();\n        var socket = new WebSocket(\"ws://localhost:8090\");\n\n        //wait of call\n        jrpc.on('view.setTitle', function(title){\n            document.getElementsByClassName('title')[0].innerHTML = title;\n        });\n\n        socket.onmessage = function(event) {\n            jrpc.messageHandler(event.data);\n        };\n\n        jrpc.toStream = function(_msg){\n            socket.send(_msg);\n        };\n\n        socket.onerror = function(error) {\n            console.error(\"Error: \" + error.message);\n        };\n\n        socket.onclose = function(event) {\n            if (event.wasClean) {\n                console.info('Connection close was clean');\n            } else {\n                console.error('Connection suddenly close');\n            }\n            console.info('close code : ' + event.code + ' reason: ' + event.reason);\n        };\n\n        //usage\n        //after connect\n        socket.onopen = function(){\n\n            //calls\n            jrpc.call('add', [2, 3]).then(function (result) {\n                document.getElementsByClassName('paragraph')[0].innerHTML += 'add(2, 3) result: ' + result + '\u003cbr\u003e';\n            });\n\n            jrpc.call('mul', {y: 3, x: 2}).then(function (result) {\n                document.getElementsByClassName('paragraph')[0].innerHTML += 'mul(2, 3) result: ' + result + '\u003cbr\u003e';\n            });\n\n            jrpc.batch([\n                {call:{method: \"add\", params: [5,2]}},\n                {call:{method: \"mul\", params: [100, 200]}},\n                {call:{method: \"create\", params: {item: {foo: \"bar\"}, rewrite: true}}}\n            ]);\n        };\n```\n\nMore examples in directory\n\n## API\n\n```call(methodName, params)``` - Remote method invocation. Returned `promise` object.  \n\n```notification(methodName, params)``` - Remote method invocation without response object  \n\n```batch(calls)``` - batch invocation. Returned `promise` object.  \n\n```on(methodName, paramsName, handler)``` - Registration local method for incommig invocation\n\n```off(methodName)``` - disable method for incommig invocation\n\n```customException(code, message, data)``` - return exception with implementation-defined server-errors    \n\n***configuration:***  \n\n```messageHandler(rawMessage)``` -  All incoming messages must be passed as a parameter.  Returned `promise` object.\n\n```toStream```  - The property, a function pointer. It is necessary to determine before use. Will be called for send a message to the remote host  \n\n```undefinedResult``` - allow to set default result of locally called function if it returns undefined\n\nusage example:\n```js\n    jrpc.undefinedResult = null; // or false, or whatever\n    jrpc.on('find', function(key) {\n        if (db.exists(key))\n\t    return db.get(key);\n\t// If there is nothing found then just return nothing\n    });\n```\n## Dependecies\n\n- NodeJS \u003c= 8.11.4 (if using within a NodeJS app, or compiling) || Latest browser (if using client side)\n- (Optional) [promise-polyfill](https://github.com/taylorhakes/promise-polyfill) for OLD versions of NodeJS and certain older browsers\n\n## Specification\n\n[http://www.jsonrpc.org/specification](http://www.jsonrpc.org/specification)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjershell%2Fsimple-jsonrpc-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjershell%2Fsimple-jsonrpc-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjershell%2Fsimple-jsonrpc-js/lists"}