olm/javascript
Damir Jelić 071029c201 javascript: Switch from deprecated Pointer_stringify() to UTF8toString().
The Pointer_stringify() function is deprecated and has a couple of
issues because it tries to guess the encoding of the buffer. In some
cases it can ignore the length parameter which could end up in
inconsistencies.

Switch to UTF8toString() that takes a length parameter and respects,
that way we don't need to allocate an additional byte for a NULL byte.
2019-04-08 15:18:28 -04:00
..
demo Return the message index when decrypting group messages. 2016-10-20 09:58:55 +01:00
test Add signing class to the pk module 2019-01-29 20:47:41 +00:00
.gitignore also ignore the non-wasm JS file 2018-10-16 16:11:22 -04:00
externs.js Another day, another interface 2018-09-25 17:13:29 +01:00
olm_inbound_group_session.js javascript: Switch from deprecated Pointer_stringify() to UTF8toString(). 2019-04-08 15:18:28 -04:00
olm_outbound_group_session.js javascript: Switch from deprecated Pointer_stringify() to UTF8toString(). 2019-04-08 15:18:28 -04:00
olm_pk.js javascript: Switch from deprecated Pointer_stringify() to UTF8toString(). 2019-04-08 15:18:28 -04:00
olm_post.js javascript: Switch from deprecated Pointer_stringify() to UTF8toString(). 2019-04-08 15:18:28 -04:00
olm_pre.js javascript: Switch from deprecated Pointer_stringify() to UTF8toString(). 2019-04-08 15:18:28 -04:00
olm_prefix.js Another day, another interface 2018-09-25 17:13:29 +01:00
olm_sas.js javascript: Switch from deprecated Pointer_stringify() to UTF8toString(). 2019-04-08 15:18:28 -04:00
olm_suffix.js Dual-build wasm and asm.js olm 2018-10-04 20:09:54 +01:00
package.json prepare release 3.0.0 2018-10-23 12:58:10 -04:00
README.md Javascript bindings for group sessions 2016-05-25 17:48:01 +01:00

Olm

Example:

var alice = new Olm.Account();
var bob = new Olm.Account();
alice.create();
bob.create();
bob.generate_one_time_keys(1);

var bobs_id_keys = JSON.parse(bob.identity_keys());
var bobs_id_key = bobs_id_keys.curve25519;
var bobs_ot_keys = JSON.parse(bob.one_time_keys());
for (key in bobs_ot_keys.curve25519) {
    var bobs_ot_key = bobs_ot_keys.curve25519[key];
}

alice_session = new Olm.Session();
alice_session.create_outbound(alice, bobs_id_key, bobs_ot_key);
alice_message = a_session.encrypt("Hello");

bob_session.create_inbound(bob, bob_message);
var plaintext = bob_session.decrypt(message_1.type, bob_message);
bob.remove_one_time_keys(bob_session);

Group chat:

var outbound_session = new Olm.OutboundGroupSession();
outbound_session.create();

// exchange these over a secure channel
var session_id = group_session.session_id();
var session_key = group_session.session_key();
var message_index = group_session.message_index();

var inbound_session = new Olm.InboundGroupSession();
inbound_session.create(message_index, session_key);

var ciphertext = outbound_session.encrypt("Hello");
var plaintext = inbound_session.decrypt(ciphertext);