{"id":15782329,"url":"https://github.com/mirpo/mimic-ws","last_synced_at":"2025-09-19T04:31:54.238Z","repository":{"id":42882077,"uuid":"256002881","full_name":"mirpo/mimic-ws","owner":"mirpo","description":"Mimic-ws is drop-in replacement for ws, power by uWebSocket.js","archived":false,"fork":false,"pushed_at":"2023-03-04T12:29:41.000Z","size":429,"stargazers_count":10,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-08T10:59:41.080Z","etag":null,"topics":["javascript","mqtt","nodejs","protocol","pubsub","realtime","webscoket","websocket-client","websocket-server"],"latest_commit_sha":null,"homepage":"https://github.com/mirpo/mimic-ws","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/mirpo.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":"2020-04-15T18:26:18.000Z","updated_at":"2024-07-17T15:53:24.000Z","dependencies_parsed_at":"2024-10-26T00:38:51.503Z","dependency_job_id":"64aab47a-1d70-4d3d-8ebf-1a56d223ec32","html_url":"https://github.com/mirpo/mimic-ws","commit_stats":{"total_commits":22,"total_committers":3,"mean_commits":7.333333333333333,"dds":0.4545454545454546,"last_synced_commit":"a53b8828189dc1ee52d8534126947fd811fe9442"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/mirpo/mimic-ws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirpo%2Fmimic-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirpo%2Fmimic-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirpo%2Fmimic-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirpo%2Fmimic-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirpo","download_url":"https://codeload.github.com/mirpo/mimic-ws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirpo%2Fmimic-ws/sbom","scorecard":{"id":649334,"data":{"date":"2025-08-11","repo":{"name":"github.com/mirpo/mimic-ws","commit":"a53b8828189dc1ee52d8534126947fd811fe9442"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"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/18 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":"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":"Pinned-Dependencies","score":6,"reason":"dependency not pinned by hash detected -- score normalized to 6","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/mirpo/mimic-ws/nodejs.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party 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":["Warn: no topLevel permission defined: .github/workflows/nodejs.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":"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 12 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":"16 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","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-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","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-21T13:02:03.083Z","repository_id":42882077,"created_at":"2025-08-21T13:02:03.083Z","updated_at":"2025-08-21T13:02:03.083Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275881571,"owners_count":25545398,"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","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"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":["javascript","mqtt","nodejs","protocol","pubsub","realtime","webscoket","websocket-client","websocket-server"],"created_at":"2024-10-04T19:05:35.090Z","updated_at":"2025-09-19T04:31:53.936Z","avatar_url":"https://github.com/mirpo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mimic-ws\n\n[![Npm version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coverage Status][coveralls-image]][coveralls-url]\n\nMimic-ws is drop-in replacement for [ws](https://github.com/websockets/ws), powered by [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js)\n\n**Note**: This module does not work in the browser. \n\n## Installing\n`npm install mimic-ws`\n\n#### Been a drop-in replacement, `mimic-ws` has some limits and difference:\n- For SSL initialization you don't need separate HTTP server, just define `certificate` and `key` parameters, check [examples](#usage-examples).\n- `clientTracking` is always true, and `wss.clients` is a `Map`, key is unique id, each `ws` has the same unique attribute `id`. No need to code own logic.\n- Added `backpressure` event, so you can check that websocket is slow.\n- Added `drain` event, so you can check that websocket buffer is free.\n- Added `publish`/`subscribe` functions with MQTT topics support, check [examples](#usage-examples)\n- `WebSocket` handlers like `onclose`/`onerror` are removed. Use events.\n- Use `idleTimeout` for dropping connections.\n- Use `maxBackpressure` for dropping slow consumers.\n- `verifyClient` parameters are bit different.\n\n## Usage examples\n\n### Simple server\n\n```js\nconst WebSocket = require('mimic-ws')\n\nconst wss = new WebSocket.Server({\n    port: 8080\n})\n\nwss.on('connection', (ws) =\u003e {\n    ws.on('message', (message) =\u003e {\n        console.log('received: %s', message)\n    })\n\n    ws.send('something')\n})\n```\n\n### SSL server\n\n```js\nconst WebSocket = require('mimic-ws')\n\nconst wss = new WebSocket.Server({\n    port: 8080,\n    sslCert: './test/fixtures/cert.pem',\n    sslKey: './test/fixtures/key.pem',\n})\n\nwss.on('connection', (ws) =\u003e {\n    ws.on('message', (message) =\u003e {\n        console.log('received: %s', message)\n    })\n\n    ws.send('something')\n})\n```\n\n### Server broadcast old school\n\nA client WebSocket broadcasting to all connected WebSocket clients, including itself.\n\n```js\nconst WebSocket = require('mimic-ws')\n\nconst wss = new WebSocket.Server({\n    port: 8080\n})\n\nwss.on('connection', (ws) =\u003e {\n    ws.on('message', (data) =\u003e {\n        wss.clients.forEach((client) =\u003e {\n            client.send(data)\n        })\n    })\n})\n```\nA client WebSocket broadcasting to every other connected WebSocket clients, excluding itself.\n\n```js\nconst WebSocket = require('mimic-ws')\n\nconst wss = new WebSocket.Server({\n    port: 8080\n})\n\nwss.on('connection', (ws) =\u003e {\n    ws.on('message', (data) =\u003e {\n        wss.clients.forEach((client, id) =\u003e {\n            if (ws !== client) { // or if (id.localeCompare(ws.id))\n                client.send(data)\n            }\n        })\n    })\n})\n```\n\n### Server broadcast pub/sub using MQTT topics\n\n\n```js\nconst WebSocket = require('mimic-ws')\n\nconst wss = new WebSocket.Server({\n    port: 8080\n})\n\nwss.on('connection', (ws) =\u003e {\n    ws.subscribe('/house/#')\n\n    ws.publish('/house/room1')\n    ws.publish('/house/room2')\n})\n```\n\n### Simple app using pub/sub JSON protocol\n```js\nconst WebSocket = require('mimic-ws')\n\nconst wss = new WebSocket.Server({\n    port: 8080\n})\n\nconst handle = (ws, msg) =\u003e {\n    if (msg \u0026\u0026 msg.action) {\n        switch (msg.action) {\n            case 'publish':\n                ws.publish(msg.topic, JSON.stringify(msg.data))\n                break\n\n            case 'subscribe':\n                console.log(msg)\n                ws.subscribe(msg.topic)\n                break\n\n            case 'unsubscribe':\n                ws.unsubscribe(msg.topic)\n                break\n\n            default:\n                console.error(`Unknown action: ${msg.action}`)\n        }\n    }\n}\n\nwss.on('connection', (ws) =\u003e {\n    ws.on('message', (message) =\u003e {\n        const msg = JSON.parse(message)\n        handle(ws, msg)\n    })\n})\n\nconst publisher = new WebSocket(`ws://localhost:${wss.address().port}`)\npublisher.on('open', () =\u003e {\n    setInterval(() =\u003e {\n        const msg = {\n            action: 'publish',\n            topic: '/house/room1',\n            data: {\n                title: 'temperature in room1',\n                value: Math.floor(Math.random() * 30),\n                timestamp: Date.now()\n            }\n        }\n        publisher.send(JSON.stringify(msg))\n\n        const msg2 = {\n            action: 'publish',\n            topic: '/house/room2',\n            data: {\n                title: 'temperature in room2',\n                value: Math.floor(Math.random() * 30),\n                timestamp: Date.now()\n            }\n        }\n        publisher.send(JSON.stringify(msg2))\n    }, 1000)\n})\n\nconst subscriber = new WebSocket(`ws://localhost:${wss.address().port}`)\nsubscriber.on('open', () =\u003e {\n    const msg = {\n        action: 'subscribe',\n        topic: '/house/#'\n    }\n    subscriber.send(JSON.stringify(msg))\n})\n\nsubscriber.on('message', (message) =\u003e {\n    console.log(`got message: ${message}`)\n})\n```\n\n\n#### Other examples\nCheck test cases.\n\n#### Changelog\nWe're using the GitHub releases for changelog entries.\n\n#### TODO\n1. More tests\n2. Typescript declaration\n3. Benchmarks\n\n### Enable debug\n``export DEBUG=mimic-ws*``\n\n#### License\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/mimic-ws.svg?logo=npm\n[npm-url]: https://www.npmjs.com/package/mimic-ws\n\n[ci-image]: https://github.com/mirpo/mimic-ws/workflows/Build/badge.svg\n[ci-url]: https://github.com/mirpo/mimic-ws/actions\n\n[coveralls-image]: https://coveralls.io/repos/github/mirpo/mimic-ws/badge.svg?branch=master\n[coveralls-url]: https://coveralls.io/github/mirpo/mimic-ws\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirpo%2Fmimic-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirpo%2Fmimic-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirpo%2Fmimic-ws/lists"}