{"id":14978192,"url":"https://github.com/michaelfranzl/socket.io-bridge","last_synced_at":"2026-01-28T05:20:55.956Z","repository":{"id":29357690,"uuid":"120946751","full_name":"michaelfranzl/socket.io-bridge","owner":"michaelfranzl","description":"Isomorphic library for real-time, bidirectional, event-based communication between two Socket.IO clients","archived":false,"fork":false,"pushed_at":"2023-03-04T08:46:39.000Z","size":731,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T10:34:13.744Z","etag":null,"topics":["client-client","events","socket-io","socketio"],"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/michaelfranzl.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-09T19:29:53.000Z","updated_at":"2022-09-24T06:19:05.000Z","dependencies_parsed_at":"2024-08-29T13:08:01.471Z","dependency_job_id":"b6ed0d86-94b0-4d05-95c3-69790437ae63","html_url":"https://github.com/michaelfranzl/socket.io-bridge","commit_stats":{"total_commits":55,"total_committers":3,"mean_commits":"18.333333333333332","dds":0.4,"last_synced_commit":"d33809727b2aa96a371cfc07c4e52f0b2f7fefdb"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/michaelfranzl/socket.io-bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfranzl%2Fsocket.io-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfranzl%2Fsocket.io-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfranzl%2Fsocket.io-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfranzl%2Fsocket.io-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelfranzl","download_url":"https://codeload.github.com/michaelfranzl/socket.io-bridge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelfranzl%2Fsocket.io-bridge/sbom","scorecard":{"id":641153,"data":{"date":"2025-08-11","repo":{"name":"github.com/michaelfranzl/socket.io-bridge","commit":"d33809727b2aa96a371cfc07c4e52f0b2f7fefdb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"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":"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":"Code-Review","score":0,"reason":"Found 0/13 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/githubpublish.yml:1","Warn: no topLevel permission defined: .github/workflows/npmpublish.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":"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":"Pinned-Dependencies","score":5,"reason":"dependency not pinned by hash detected -- score normalized to 5","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/githubpublish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/githubpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/githubpublish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/githubpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/githubpublish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/githubpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/githubpublish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/githubpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/npmpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/npmpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/npmpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/npmpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/michaelfranzl/socket.io-bridge/test.yml/master?enable=pin","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:  10 out of  10 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":"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 17 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"}},{"name":"Vulnerabilities","score":0,"reason":"27 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-j4f2-536g-r55m","Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-6vfc-qv3f-vr6c","Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj","Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-6fx8-h7jm-663j","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj","Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq","Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9","Warn: Project is vulnerable to: GHSA-mxhp-79qh-mcx6","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"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-21T10:48:10.088Z","repository_id":29357690,"created_at":"2025-08-21T10:48:10.088Z","updated_at":"2025-08-21T10:48:10.088Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28840088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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-client","events","socket-io","socketio"],"created_at":"2024-09-24T13:57:01.659Z","updated_at":"2026-01-28T05:20:55.930Z","avatar_url":"https://github.com/michaelfranzl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# socket.io-bridge\n\nReal-time, bidirectional, event-based communication between two [Socket.IO](https://github.com/socketio) clients.\n\nThere are no dependencies on message queue or pub/sub servers. The Node.js server creates client-client 'bridges' (private namespaces used by two clients) using just Socket.IO.\n\n![Test](https://github.com/michaelfranzl/socket.io-bridge/workflows/Test/badge.svg)\n\n## Features\n\n* Client library works with Node.js and browsers\n* Works through firewalls and with NAT (because clients connect to the server)\n* Addressing using self-assigned string IDs (locally unique, communicated via some other channel)\n* Real-time peer connection and disconnection notification\n* Private namespaces ('bridges') have random names\n* The server is transparent to event names; clients can emit any signal (using `.emit` and `.on`) without the need to change the server\n* Promise and/or callback-based peer connection notification\n* Connection multiplexing over just one TCP connection (this is a Socket.IO feature)\n\n## Example\n\nSee a working demo at [packages/client/demo](packages/client/demo).\n\nWithout socket.io-bridge, with only plain Socket.IO, to route an event from one client to another client, one has to do:\n\nClient 1:\n\n```javascript\nsocket.emit('event');\n```\n\nServer:\n\n```javascript\nclient1.on('event', () =\u003e client2.emit('event'));\n```\n\nClient 2:\n\n```javascript\nsocket.on('event', () =\u003e console.log('event'));\n```\n\nDisadvantages in this approach:\n\n* Three separate implementations are tighly coupled (server, client1, client2)\n* client1 does not know if client2 is currently connected to the server\n* client1 does not know when client2 disconnects\n* client1 does not know *who* client2 is\n\nThese issues can be solved using the present library, and are illustrated below.\n\nOn the backend (assuming a server at `http://localhost:3000`), adding the client-client briging behavior to an already existing Socket.IO server just requires one additional line:\n\n```javascript\nimport http from 'http';\nimport SocketIoServer from 'socket.io';\nimport makeBridgeServer from 'socket.io-bridge-server';\n\nconst server = http.createServer().listen(3000);\nconst socketIoServer = SocketIoServer(server);\nconst namespace = socketIoServer.of('/bridge');\n\nmakeBridgeServer({ namespace }); // \u003c-- that's it\n```\n\nOn client \"Alice\" (running in a browser or in Node.js):\n\n```javascript\nimport SocketIoClient from 'socket.io-client';\n\n// setup\nconst socket = SocketIoClient('http://localhost:3000/bridge');\nconst bridgeClient = new SocketIoBridgeClient({ socket });\n\n// usage\nbridgeClient\n  .make({ id: 'Alice', peerId: 'Bob' }) // We are \"Alice\", and we want to talk to \"Bob\".\n  .then((peer) =\u003e { // Bob is now connected. `peer` is a regular Socket.IO client socket.\n    // Application-specific implementation.\n    peer.emit('hello');\n    peer.on('concatenate two words', (txt1, txt2) =\u003e callback(`${txt1} ${txt2}!`));\n  });\n```\n\nOn client \"Bob\" (running in a browser or in Node.js):\n\n```javascript\nimport SocketIoClient from 'socket.io-client';\n\n// setup\nconst socket = SocketIoClient('http://localhost:3000/bridge');\nconst bridgeClient = new SocketIoBridgeClient({ socket });\n\n// usage\nbridgeClient.make({\n  // We are \"Bob\". We don't want to talk to anybody specific, but others may want to talk to us.\n  id: 'Bob',\n  onconnection: (peer) =\u003e {\n    console.log('someone connected to us');\n    socket.on('hello', () =\u003e { console.log('someone said hello') });\n\n    socket.emit('concatenate two words', 'Hello', 'world', (answer) =\u003e {\n      console.log(answer); // This prints \"Hello world!\" if the peer implements this event.\n    });\n  },\n});\n```\n\nAdvantages of this approach:\n\n* Only the client implementations are coupled, the server is decoupled.\n* There are no event listeners on all the used sockets except those set by the clients themselves.\n* Socket.IO callbacks work (i.e. functions as payload).\n* If one client disconnects, the other socket will be disconnected too.\n* Only one client needs to provide the argument `peerId`, the other peer does not. The peer who is\n    not providing `peerId` expects that other peers connect to it (it is loosely equivalent to a\n    'server').\n* The order in which the clients connect to the server does not matter.\n* Two mechanisms are provided for when a peer connects, which can be used interchangeably: a\n    Promise, and a callback function `onconnection`. Note that a Promise can resolve only once. For\n    multiple connections to one peer, you can only use the callback on this peer.\n* For one connection to the server, an arbitrary number of client-client connections can be\n    established (by calling `make` repeatedly).\n* Because Socket.IO connections are multiplexed over just one TCP connection, even multiple connections between two endpoints established in such a way are multiplexed too.\n\n\n## Connection establishment protocol\n\nThis custom protocol is implemented by the packages `socket.io-bridge-server` and `socket.io-bridge-client`. The user does not need to know about it, it's working behind the scenes and ends when the `onconnection` callback is called, or when the connection promise resolves.\n\nIn the example below, client \"c1\" wants to connect to client \"c2\".\n\nOne namespace on the server (under the path `/bridge`) is used to negotiate the creation of new private sub-namespaces (in the example below called `nname`)\n\n```\nCLIENT c1                     SERVER                      CLIENT c2\n                            nsp:/bridge\n---------connection-----------\u003e  |\n-----------login--------------\u003e  |\n \u003c--------logged_in------------- |\n-----request_bridge(c2)-------\u003e  |\n                                 |\n                                 |  \u003c--------connection-------------\n                                 |  \u003c----------login----------------\n                                 | ----------logged_in------------\u003e\n\u003c--- connect_to_bridge(nname)--- | -----connect_to_bridge(nname)--\u003e\n\n```\n\nBoth clients will receive the `connect_to_bridge` event at the same time (disregarding network delays) and will connect to the new namespace, the name of which is known only to the clients:\n\n\n```\n\nCLIENT c1                     SERVER                      CLIENT c2\n                         nsp:/bridge/nname\n---------connection-----------\u003e  |\n-----------start--------------\u003e  |\n                                 |\n                                 |  \u003c--------connection------------\n                                 |  \u003c----------start---------------\n \u003c--------peer_connected-------- | ---------peer_connected-------\u003e\n```\n\nAt this point, the server removes all event listeners from the sockets, and the clients perform an echo test to test connectivity without the active participation of the server:\n\n```\nCLIENT c1                     SERVER                      CLIENT c2\n                         nsp:/bridge/nname\n                                 |\n--------------echo------------\u003e  | --------------echo------------\u003e\n \u003c--------------echo------------ |  \u003c-------------echo------------\n                                 |\n \u003c-------------echo------------- |  \u003c--------------echo-----------\n--------------echo------------\u003e  | --------------echo-------------\u003e\n```\n\nAfter this succeeds, the clients remove the `echo` event listener from the sockets, which now are a 'transparent pipe' to the other peer, and pass them to the user code using a resolving promise and the `onconnection` callback.\n\n\n# Development and testing\n\nThe [test file](packages/client/tests/test.js) is also a documentation on various use cases.\n\nRun the tests:\n\n```sh\nnpm test\n```\n\nTo use the debugger during testing, run:\n\n```sh\nnpm test -- --inspect\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelfranzl%2Fsocket.io-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelfranzl%2Fsocket.io-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelfranzl%2Fsocket.io-bridge/lists"}