Gathering detailed insights and metrics for y-webrtc
Gathering detailed insights and metrics for y-webrtc
Gathering detailed insights and metrics for y-webrtc
Gathering detailed insights and metrics for y-webrtc
@remirror/extension-yjs
Realtime collaboration with yjs
@layer5/y-webrtc
Yjs WebRTC provider for layer5 projects.
webrtc-adapter
A shim to insulate apps from WebRTC spec changes and browser prefix differences
amazon-kinesis-video-streams-webrtc
Amazon Kinesis Video Streams WebRTC SDK for JavaScript.
npm install y-webrtc
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
482 Stars
138 Commits
118 Forks
16 Watching
3 Branches
17 Contributors
Updated on 27 Nov 2024
JavaScript (96.93%)
Dockerfile (2.61%)
HTML (0.45%)
Cumulative downloads
Total Downloads
Last day
14.3%
17,042
Compared to previous day
Last week
-1.8%
74,409
Compared to previous week
Last month
7.1%
336,397
Compared to previous month
Last year
347.9%
2,910,039
Compared to previous year
4
1
11
1
Propagates document updates peer-to-peer to all users using WebRTC.
1npm i y-webrtc
1import * as Y from 'yjs' 2import { WebrtcProvider } from 'y-webrtc' 3 4const ydoc = new Y.Doc() 5// clients connected to the same room-name share document updates 6const provider = new WebrtcProvider('your-room-name', ydoc, { password: 'optional-room-password' }) 7const yarray = ydoc.get('array', Y.Array)
The peers find each other by connecting to a signaling server. This package implements a small signaling server in ./bin/server.js
.
1# start signaling server 2PORT=4444 node ./bin/server.js
Peers using the same signaling server will find each other. You can specify several custom signaling servers like so:
1const provider = new WebrtcProvider('your-room-name', ydoc, { signaling: ['wss://y-webrtc-ckynwnzncc.now.sh', 'ws://localhost:4444'] })
There is also an interesting article about setting up a scalable "serverless" signaling server by Ronny Roeller: https://medium.com/collaborne-engineering/serverless-yjs-72d0a84326a2
y-webrtc is restricted by the number of peers that the web browser can create. By default, every client is connected to every other client up until the maximum number of conns is reached. The clients will still sync if every client is connected at least indirectly to every other client. Theoretically, y-webrtc allows an unlimited number of users, but at some point it can't be guaranteed anymore that the clients sync any longer**. Because we don't want to be greedy,
y-webrtc has a restriction to connect to a maximum of 20 + math.floor(random.rand() * 15)
peers. The value has a random factor in order to prevent clients to form clusters, that can't connect to other clients. The value can be adjusted using the maxConn
option. I.e.
1const provider = new WebrtcProvider('your-room-name', ydoc, { maxConns: 70 + math.floor(random.rand() * 70) })
** A gifted mind could use this as an exercise and calculate the probability of clusters forming depending on the number of peers in the network. The default value was used to connect at least 100 clients at a conference meeting on a bad network connection.
Just listen to the "peers" event from the provider to listen for more incoming WebRTC connections and use the simple-peer API to share streams. More help on this would be welcome. By default, browser windows share data using BroadcastChannel without WebRTC. In order to connect all peers and browser windows with each other, set maxConns = Number.POSITIVE_INFINITY
and filterBcConns = false
.
1new WebrtcProvider(roomName, ydoc[, opts])
The following default values of opts
can be overwritten:
1{ 2 // Specify signaling servers. The client will connect to every signaling server concurrently to find other peers as fast as possible. 3 signaling: ['wss://signaling.yjs.dev', 'wss://y-webrtc-signaling-eu.herokuapp.com', 'wss://y-webrtc-signaling-us.herokuapp.com'], 4 // If password is a string, it will be used to encrypt all communication over the signaling servers. 5 // No sensitive information (WebRTC connection info, shared data) will be shared over the signaling servers. 6 // The main objective is to prevent man-in-the-middle attacks and to allow you to securely use public / untrusted signaling instances. 7 password: null, 8 // Specify an existing Awareness instance - see https://github.com/yjs/y-protocols 9 awareness: new awarenessProtocol.Awareness(doc), 10 // Maximal number of WebRTC connections. 11 // A random factor is recommended, because it reduces the chance that n clients form a cluster. 12 maxConns: 20 + math.floor(random.rand() * 15), 13 // Whether to disable WebRTC connections to other tabs in the same browser. 14 // Tabs within the same browser share document updates using BroadcastChannels. 15 // WebRTC connections within the same browser are therefore only necessary if you want to share video information too. 16 filterBcConns: true, 17 // simple-peer options. See https://github.com/feross/simple-peer#peer--new-peeropts for available options. 18 // y-webrtc uses simple-peer internally as a library to create WebRTC connections. 19 peerOpts: {} 20}
y-webrtc
uses the lib0/logging.js
logging library. By default this library disables logging. You can enable it by specifying the log
environment / localStorage variable:
1// enable logging for all modules 2localStorage.log = 'true' 3// enable logging only for y-webrtc 4localStorage.log = 'y-webrtc' 5// by specifying a regex variables 6localStorage.log = '^y.*'
1# enable y-webrtc logging in nodejs 2LOG='y-webrtc' node index.js
Yjs is licensed under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 8/20 approved changesets -- score normalized to 4
Reason
6 existing vulnerabilities detected
Details
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More