saltyrtc-client v0.9.1
SaltyRTC JavaScript Client
This is a SaltyRTC v1 implementation for JavaScript (ES5) written in TypeScript 2.0+.
Warning: This is beta software. Use at your own risk. Testing and review is welcome!
The library has been tested with Firefox 45+ and Chromium 49+.
Installing
Via npm
You can install this library via npm:
npm install --save saltyrtc-client msgpack-lite tweetnaclManually
Alternatively, copy one of the following files to your project directly:
- ES2015:
dist/saltyrtc-client.es2015.js - ES5:
dist/saltyrtc-client.es5.js - ES5 minified:
dist/saltyrtc-client.es5.min.js - ES5 minified polyfilled:
dist/saltyrtc-client.es5.min.polyfill.js
Make sure to manually add the following external dependencies to your project:
Usage
First, create a keypair:
let permanentKey = new saltyrtcClient.KeyStore();Then, create a SaltyRTCBuilder instance:
let builder = new saltyrtcClient.SaltyRTCBuilder()
.connectTo(saltyrtcHost, saltyrtcPort)
.withKeyStore(permanentKey);Depending on whether you're the initiator or the responder, initialize the SaltyRTC instance:
let initiator = builder.asInitiator();
let responder = builder.initiatorInfo(permanentKey.publicKeyBytes, initiator.authTokenBytes).asResponder();You can also use trusted keys to connect:
let trustingInitiator = builder.withTrustedPeerKey(responderKey).asInitiator();
let trustingResponder = builder.withTrustedPeerKey(initiatorKey).asResponder();Now you can connect both sides:
initiator.connect()
responder.connect()You can query the current signaling state:
>>> console.log(initiator.state)
server-handshakeAnd you can register callbacks for certain events:
initiator.on('handover', () => console.log('Handover is done'));
responder.on('state-change', (newState) => console.log('New signaling state:', newState));The following events are available:
state-change(saltyrtcClient.SignalingState): The signaling state changed.state-change:<new-state>(void): The signaling state change event, filtered by state.new-responder(responderId): A responder has connected. This event is only dispatched for the initiator.application(data): An application message has arrived.handover(void): The handover to the data channel is done.signaling-connection-lost(responderId): The signaling connection to the specified peer was lost.connection-closed(closeCode): The connection was closed.connection-error(ErrorEvent): A websocket connection error occured.
Development
Install dependencies:
$ npm installTo compile the TypeScript sources to a single JavaScript (ES5 / Minified ES5 / ES2015) file:
$ npm run distThe resulting files will be located in dist/.
Due to a bug (https://github.com/rollup/rollup-plugin-typescript/issues/43),
rollup does not currently output non-fatal errors from TypeScript. To see
those, simply issue npm run validate in your main directory.
$ npm run validateTesting
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.
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago