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+.
You can install this library via
npm install --save @saltyrtc/client msgpack-lite tweetnacl
Alternatively, copy one of the following files to your project directly:
Make sure to manually add the following external dependencies to your project:
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:
You can query the current signaling state:
>>> console.log(initiator.state) server-handshake
And 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.
$ npm install
$ npm run dist
The resulting files will be located in
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 validate
To compile the test sources, run:
$ npm run rollup_tests
Then simply open
tests/testsuite.html in your browser!
Alternatively, run the tests automatically in Firefox and Chrome:
$ npm test
Please report security issues directly to one or both of the following contacts:
Generated using TypeDoc