firepeer
Secure p2p signalling and authentication for simple-peer using firebase realtime database.
Setup firebase
-
Create a firebase project and setup the javascript client SDK.
-
Add these security rules in the firebase console to secure the signalling data.
Signaling data is exchanged in
/peers/$uid/$id/$otherUid/$otherId
. Security rules ensure that only the intended users can access signalling data and the signals are valid.Shortcut:
https://console.firebase.google.com/project/<YOUR_PROJECT_ID>/database/rules
-
Enable your prefered sign-in method in the firebase console. Firepeer requires authentication so at the very least you have to select anonymous authentication.
Shortcut:
https://console.firebase.google.com/project/<YOUR_PROJECT_ID>/authentication/providers
Install
npm install --save firepeer
Usage
//alice side firebase; const alice = firebase; console // peer id of alice //authenticate with the sign-in method you enabled in the consoleawait firebasesignInWith* console // uid of alice // connectconst connection = await alice; // send a mesage to bobconnection
// bob side firebase; const bob = app: firebase; console // id //authenticateawait firebasesignInWith* console // peer id of bob // wait for connection and receive messagebob
Connections are just instances of simple-peer already connected!