Package Exports
- @saltyrtc/task-webrtc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@saltyrtc/task-webrtc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SaltyRTC WebRTC Task for JavaScript
This is a SaltyRTC WebRTC task implementation for JavaScript (ES5 / ES2015), written in TypeScript 2.
Warning: This is beta software. Use at your own risk. Testing and review is welcome!
Installing
Via npm
You can install this library via npm:
npm install --save @saltyrtc/task-webrtc @saltyrtc/clientUsage
When creating the task instance, you can specify whether or not a handover to a secure data channel is desired.
let task = new WebRTCTask(true);You can also specify the max DataChannel chunk size:
let task = new WebRTCTask(true, 65536);If you don't specify any values, handover defaults to true and the chunk size defaults to 16384.
The handover can be initiated using the handover method:
let started = task.handover(peerConnection);Note: You should call this method before creating offer/answer!
To send offers, answers and candidates, use the following task methods:
.sendOffer(offer: RTCSessionDescriptionInit): void.sendAnswer(answer: RTCSessionDescriptionInit): void.sendCandidate(candidate: RTCIceCandidateInit): void.sendCandidates(candidates: RTCIceCandidateInit[]): void
You can register and deregister event handlers with the on, once and off methods:
task.on('candidates', (e) => {
for (let candidateInit of e.data) {
pc.addIceCandidate(candidateInit);
}
});The following events are available:
offer(saltyrtc.tasks.webrtc.Offer): An offer message was received.answer(saltyrtc.tasks.webrtc.Answer): An answer message was received.candidates(saltyrtc.tasks.webrtc.Candidates): A candidates message was received.disconnected(number): A previously authenticated peer disconnected from the signaling server.
To know when the handover is finished, please subscribe to the handover event on the client directly.
Testing
To compile the test sources, run:
$ npm run rollup_testsThen simply open tests/testsuite.html in your browser!
Alternatively, run the tests automatically in Firefox and Chrome:
$ npm testSecurity
Responsible Disclosure / Reporting Security Issues
Please report security issues directly to one or both of the following contacts:
- Danilo Bargen
- Email: mail@dbrgn.ch
- Threema: EBEP4UCA
- GPG: EA456E8BAF0109429583EED83578F667F2F3A5FA
- Lennart Grahl
- Email: lennart.grahl@gmail.com
- Threema: MSFVEW6C
- GPG: 3FDB14868A2B36D638F3C495F98FBED10482ABA6
Coding Guidelines
- Write clean ES2015
- Favor
constoverlet
License
MIT, see LICENSE.md.