{"id":29068900,"url":"https://github.com/aspectron/iris-rpc","last_synced_at":"2025-06-27T11:09:35.712Z","repository":{"id":16678065,"uuid":"19433963","full_name":"aspectron/iris-rpc","owner":"aspectron","description":"JSON RPC over TLS","archived":false,"fork":false,"pushed_at":"2017-07-27T14:41:25.000Z","size":67,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-13T15:54:23.243Z","etag":null,"topics":[],"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/aspectron.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":"2014-05-04T19:19:02.000Z","updated_at":"2017-03-10T02:38:58.000Z","dependencies_parsed_at":"2022-08-25T19:01:52.635Z","dependency_job_id":null,"html_url":"https://github.com/aspectron/iris-rpc","commit_stats":null,"previous_names":["aspectron/zetta-rpc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aspectron/iris-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Firis-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Firis-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Firis-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Firis-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aspectron","download_url":"https://codeload.github.com/aspectron/iris-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Firis-rpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262244913,"owners_count":23281029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-06-27T11:09:35.316Z","updated_at":"2025-06-27T11:09:35.675Z","avatar_url":"https://github.com/aspectron.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IRIS Framework - JSON RPC over TLS\n\n[![dependencies Status](https://david-dm.org/aspectron/iris-rpc.svg)](https://david-dm.org/aspectron/iris-rpc#info=dependencies)\n[![license:mit](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)\n\nIRIS-RPC is a part of [IRIS Framework](https://github.com/aspectron/iris-app).\n\n#### Security Features:\n\n- Uses TLS (SSL) for data transport\n- HMAC based authentication against user-supplied secret\n- Optional message signing against MITM attacks\n- Optional second layer message encryption (aes-256-cbc by default, if enabled)\n\nAuthentication is based on user supplied secret keys, so this is as secure as your host.\n\n\n## Usage\n\n`npm install iris-rpc`\n\n\n### Messaging\n\nIRIS RPC library allows sending of JSON objects between client and server. If these JSON objects contain an opcode (`op` field), they will be emitted to the registered event listeners as well as on the RPC objects themselves (Client, Server and Multiplexer).  If `op` field is missing, `rpc.digest(function(msg) { ... })` must be used to capture transmission of incoming JSON objects.\n\n### Client\n\n```javascript\nvar irisRPC = require('iris-rpc');\n\nvar rpc = new irisRPC.Client({\t\t// or zrpc.Client() for connection to a single server\n    address: \"host:port\",\t\t\t\t\n    auth: \"user-supplied-secret-key\",   // must match opposite side\n    certificates: ...,\t\t\t\t\t// standard node certificates containing 'key', 'cert', 'ca' data, typically core.certificates\n    uuid: \"...\",  \t\t\t\t\t\t// uuid of the node, typically core.uuid\n    designation: 'user-application-id',\t// named identifier that is available during connection on the opposite side\n    ping: true,\t\t\t\t\t\t\t// optional: enable automatic server ping (see Client::setPingDataObject())\n    pingFreq : 3 * 1000,\t\t\t\t// optional: ping frequency (default 3 seconds)\n    pingDataObject : ...,\t\t\t\t// this object will be transmitted during ping\n    cipher: true,\t\t\t\t\t\t// optional: 'true' or name of cipher algorithm for 2nd layer encryption \n    \t\t\t\t\t\t\t\t\t// (default 'aes-256-cbc' if true)\n    signatures: true\t\t\t\t\t// optional: enable message signing\n});\n\n\n// receive messages\nrpc.on('user-message', function(msg, rpc) { ... })\t\n\n// receive messages with external event emitter\nrpc.registerListener(eventEmitter);\t\t// register event emitter that will receive messages\neventEmitter.on('user-message', function(msg, rpc) { ... })\t\n\n// send messages or JSON objects\nrpc.dispatch({ op : 'user-message ', ... })\t\n\n// receive each message as JSON\nrpc.digest(function(msg, rpc) { ... })\n\n```\n\n### Server\n\n```javascript\nvar irisRPC = require('iris-rpc');\n\nvar rpc = new irisRPC.Server({\n\tport : 12345, \t\t\t\t\t\t// listening port\n\tauth : \"user-supplied-secret-key\",\n    certificates: ...,\t\t\t\t\t// standard node certificates containing 'key', 'cert', 'ca' data\n}, function(err) {\n\tconsole.log('iris-rpc server is listening for new connections');\n});\n\n// client connection event: cid is a unique remote end-point identifier (built from designation+node)\nrpc.on('connect', function(address, cid, stream) { ... })\n\n// client disconnection event\nrpc.on('disconnect', function(cid, stream) { ... })\n\n// receive messages\nrpc.on('user-message', function(msg, cid, stream) { ... })\n\n// send messages\nrpc.dispatch(cid, { op : 'user-message' })\n\n// receive JSON objects (without 'op' field)\nrpc.digest(function(msg, cid, stream) { ... })\n```\n\n### Multiplexer\n\nMultiplexer allows creation of a single RPC interface that can combine multiple Client and/or Server RPC instances while providing a common interface for message dispatch and reception.\n\nWhen configuring multiplexer, arguments are supplied as follows:\n* RPC parameters (passed on to underlying Client and Server instances)\n* List of connectsions\n* Verbose title of the RPC link\n\nIf list of connections contains `port` key, Multiplexer will create an underlying Server instance, for `address` key, it will create underlying Client instance.\n\n```javascript\n\nvar connectionList = {\n    client1 : {\n        address : \"\u003cip\u003e:\u003cport\u003e\",\n        auth : \"\u003cauth-string-matching-opposite-side\u003e\"\n    },\n    client2 : {\n        address : \"\u003cip\u003e:\u003cport\u003e\",\n        auth : \"\u003cauth-string-matching-opposite-side\u003e\"\n    },\n    server1 : {\n        address : \u003cport\u003e,\n        auth : \"\u003cauth-string-matching-opposite-side\u003e\"\n    },\n    server2 : {\n        address : \u003cport\u003e,\n        auth : \"\u003cauth-string-matching-opposite-side\u003e\"\n    },\n    ...\n}\n\nself.rpc = new irisRPC.Multiplexer({\n    uuid : core.uuid,\n    certificates: core.certificates,\n    designation: '\u003crpc-link-identification\u003e',\n}, connectionList, \"RPC TITLE\");\n\n```\n\n### Router\n\nRouter interface is designed for large-scale systems that require a lot of\nsimultaneous connections.  Linux systems are by default configured to allow between 128 \nand 1024 simultaneous TCP connections.  This number can be increased, but ultimately\nyou may need to scale horizontally using additional servers.\n\nRouter acts as a message relay between Server and Client.\n\nExample:\n```javascript\nvar router = zrpc.Router({\n\tport : 6699,                       // Server instance configuration\n\tauth : \"172d7c54d7354f7a1f9d161c6033b6281e7096acc4dcb198763a4555f264259d\",\n\tcertificates : core.certificates,\n\tclient : {                         // Client instance configuration\n\t\taddress : \"127.0.0.1:4488\",\n        auth : \"172d7c54d7354f7a1f9d161c6033b6281e7096acc4dcb198763a4555f264259d\",\n\t\tuuid : self.uuid\n\t}\n})\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspectron%2Firis-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspectron%2Firis-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspectron%2Firis-rpc/lists"}