{"id":14037349,"url":"https://github.com/natzcam/firepeer","last_synced_at":"2025-04-04T22:30:33.210Z","repository":{"id":33183290,"uuid":"154121766","full_name":"natzcam/firepeer","owner":"natzcam","description":"secure p2p signalling and authentication for simple-peer using firebase realtime database","archived":false,"fork":false,"pushed_at":"2023-01-03T15:17:26.000Z","size":1050,"stargazers_count":35,"open_issues_count":18,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T20:14:30.848Z","etag":null,"topics":["browser","firebase","firebase-realtime-database","node","p2p","peer","signalling","simplepeer","webrtc"],"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/natzcam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-22T09:58:54.000Z","updated_at":"2024-09-10T21:41:17.000Z","dependencies_parsed_at":"2023-01-14T23:48:53.742Z","dependency_job_id":null,"html_url":"https://github.com/natzcam/firepeer","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natzcam%2Ffirepeer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natzcam%2Ffirepeer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natzcam%2Ffirepeer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natzcam%2Ffirepeer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natzcam","download_url":"https://codeload.github.com/natzcam/firepeer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247260235,"owners_count":20909959,"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":["browser","firebase","firebase-realtime-database","node","p2p","peer","signalling","simplepeer","webrtc"],"created_at":"2024-08-12T03:02:44.416Z","updated_at":"2025-04-04T22:30:32.708Z","avatar_url":"https://github.com/natzcam.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# firepeer\n\nSecure p2p signalling and authentication for [simple-peer](https://github.com/feross/simple-peer) using [firebase realtime database](https://firebase.google.com/docs/database/).\n\n[![Version](https://img.shields.io/npm/v/firepeer.svg)](https://npmjs.org/package/firepeer)\n[![Downloads/week](https://img.shields.io/npm/dw/firepeer.svg)](https://npmjs.org/package/firepeer)\n[![License](https://img.shields.io/npm/l/firepeer.svg)](https://github.com/natzcam/firepeer/blob/master/package.json)\n\n## Setup firebase\n\n1. [Create a firebase project and setup the javascript client SDK](https://firebase.google.com/docs/database/web/start).\n\n2. Add these security rules in the firebase console to secure the signalling data.\n\n    ```json\n    {\n      \"rules\": {\n        \"peers\": {\n          \"$uid\": {\n            \"$id\": {\n              \".read\": \"auth != null \u0026\u0026 auth.uid == $uid\",\n              \".write\": \"auth != null \u0026\u0026 auth.uid == $uid\",\n              \"$otherUid\": {\n                \"$otherId\": {\n                  \".read\": \"auth != null \u0026\u0026 auth.uid == $otherUid\",\n                  \".write\": \"auth != null \u0026\u0026 auth.uid == $otherUid\",\n                  \"sdp\": {\n                    \".validate\": \"newData.isString() \u0026\u0026 newData.val().length \u003c 4000\"\n                  },\n                  \"type\": {\n                    \".validate\": \"newData.val() == 'offer' || newData.val() == 'answer' || newData.val() == 'error'\"\n                  },\n                  \"$other\": { \".validate\": false }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n    ```\n\n    Signaling data is exchanged in `/peers/$uid/$id/$otherUid/$otherId`. Security rules ensure that only intended users can access signalling data and signals are valid.\n\n    \u003e Shortcut: `https://console.firebase.google.com/project/\u003cYOUR_PROJECT_ID\u003e/database/rules`\n\n\n3. Enable your prefered sign-in method in the firebase console. Firepeer requires authentication, so at the very least, you have to select [anonymous authentication](https://firebase.google.com/docs/auth/web/anonymous-auth).\n\n    \u003e Shortcut: `https://console.firebase.google.com/project/\u003cYOUR_PROJECT_ID\u003e/authentication/providers`\n\n### Install\n```js\nnpm install --save firepeer\n```\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/firepeer@\u003cFIREPEER_VERSION\u003e/lib/firepeer.min.js\"\u003e\u003c/script\u003e\n```\n\n### Usage\n\n```javascript\n//alice side\n\nfirebase.initializeApp({\n  //values from firebase console\n});\n\nconst alice = new FirePeer(firebase);\n\nconsole.log(alice.id) // peer id of alice\n\n//authenticate with the sign-in method you enabled in the console\nawait firebase.auth().signInWith*()\n\nconsole.log(alice.uid) // uid of alice\n\n// connect\nconst connection = await alice.connect(BOB_UID, BOB_ID);\n\n// send a mesage to bob\nconnection.send('hello')\n```\n\n```javascript\n// bob side\n\nfirebase.initializeApp({\n  //values from firebase console\n});\n\nconst bob = new FirePeer({\n  app: firebase.app()\n});\n\nconsole.log(bob.id) // id\n\n//authenticate\nawait firebase.auth().signInWith*()\n\nconsole.log(bob.uid) // peer id of bob\n\n// wait for connection and receive message\nbob.on('connection', (connection)=\u003e{\n    connection.on('data', (data)=\u003e{\n        console.log(data) //hello\n    })\n})\n```\n\nConnections are just instances of [simple-peer](https://github.com/feross/simple-peer#api) already connected!\n\n## Reference\n\n[https://natzcam.github.io/firepeer](https://natzcam.github.io/firepeer)\n\n## Demo\n\n[https://firepeer-demo.firebaseapp.com](https://firepeer-demo.firebaseapp.com)\n\nSource:\n[https://github.com/natzcam/firepeer-demo](https://github.com/natzcam/firepeer-demo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatzcam%2Ffirepeer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatzcam%2Ffirepeer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatzcam%2Ffirepeer/lists"}