Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
@messagebird/webrtc
Advanced tools
yarn && yarn build -w
to watch for file changesyarn build-types
to generate TS typings.The SDK is distributed on npm. To install the SDK and start using it in your client simply run
npm install @messagebird/webrtc
# Or if you use yarn
yarn add @messagebird/webrtc
To enable your application to make and receive calls over WebRTC, you have to instantiate a new Device. To connect to the WebRTC server and authenticate with your MessageBird account you need to generate a JWT and pass it to the client Here is an example app that generates a JWT
import { Device } from '@messagebird/webrtc'; // TODO < name
const device = new Device({
username: 'test',
});
// Open a connection to the MessageBird WebRTC API
device
.setup({ jwt: 'TEST' })
.then(() => {
// Ready to start and receive WebRTC connections.
})
.catch(error => {
// Error making a connection. The error object contains details of the failure.
});
Make sure you’ve instantiated the Device
and opened the connection by calling the .setup()
method. After successfully instantiating a new device you can start new RTC connections by calling the connect()
method.
device
.connect({
// Any additional data can be passed as arguments to the `connect` function
conference: 'Test conference',
to: '+31612345678',
})
.then(connection => {
// resolves with an `RTCConnection` object (docs)
})
.catch(error => {
// Failed to start a session, error object contains details.
});
You can handle incoming RTC connections by listening for the the on('incoming')
event. (untested)
device.on('incoming', connection => {
connection.accept(); // Accept the incoming connection and start a call
connection.reject(); // Reject the incoming connection.
});
This project comes with an example embedded in the examples
directory. To run the example:
yarn && yarn build -w
open examples/index.html
DEFAULT_JWT
in examples/index.js
for easier debuggingCheck out the TS Typings: https://gitlab.messagebird.io/frontend/javascript-webrtc-sdk/tree/master/types
constructor(options)
Creates a new instance of the Device. Accepts an options object with the following properties:
setup(options)
Connect the Device to start making outbound calls or listen for incoming sessions
connect(options)
Start a new outgoing RTC session. Accepts an options object with the following properties:
connection
when the call is connected. Rejects if starting the connection failed.destroy()
Disconnects all ongoing connections and terminates the connection to the server. After calling destroy
, you are required to call setup
again before you can start accepting new incoming connections
on('ready', handler)
When the device is ready to start receiving and making calls. Can be called multiple times in case the client disconnects and automatically reconnects.
on('offline', handler)
When the device disconnects for a certain reason. (docs on data object with reason)
on('incoming', handler)
Fired when an incoming RTC session is received. Callback contains an connection
object.
device.on('incoming', incomingConnection => {
// Accept the incoming call
incomingConnection.accept();
});
on('connected', handler)
Fired when a connection
is opened, the handler function receives a Connection
object as an argument
on('confirmed', handler)
Fired when an outgoingConnection
is confirmed by the other party (todo: how does this behave with ringing state?)
on('disconnected', handler)
Fired when a connection
disconnects.
The connection
object describes an ongoing RTC session. You will never instantiate an connection
yourself, the SDK will take care of that for you.
disconnect()
Disconnects the device from the connection
IncomingConnection
extends everything from Connection
, but has some additional methods
acccept()
Accept an incomingConnection to start a call.
FAQs
Documentation can be found at https://developers.messagebird.com/docs/webrtc
We found that @messagebird/webrtc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 38 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.