diff options
author | Mark Haines <mjark@negativecurvature.net> | 2016-10-21 09:57:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-21 09:57:42 +0100 |
commit | 5a98012c0d3951d2d08e9922ee682fbdecc68f0c (patch) | |
tree | f4510135c054c28f2366119136c97ae024556497 /javascript | |
parent | 65b334531754d9decf485975ffd2f9591bc80e84 (diff) | |
parent | 9a8d2d15d97dc17d8f33b7d45b0fefc1267b57c4 (diff) |
Merge pull request #31 from matrix-org/markjh/groupmessageindex
Return the message index when decrypting group messages.
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/demo/group_demo.js | 4 | ||||
-rw-r--r-- | javascript/olm_inbound_group_session.js | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/javascript/demo/group_demo.js b/javascript/demo/group_demo.js index 1b8f7ab..42a3d84 100644 --- a/javascript/demo/group_demo.js +++ b/javascript/demo/group_demo.js @@ -403,8 +403,8 @@ DemoUser.prototype.decryptGroup = function(jsonpacket, callback) { throw new Error("Unknown session id " + session_id); } - var plaintext = session.decrypt(packet.body); - done(plaintext); + var result = session.decrypt(packet.body); + done(result.plaintext); }, callback); }; diff --git a/javascript/olm_inbound_group_session.js b/javascript/olm_inbound_group_session.js index 6058233..1b7fcfe 100644 --- a/javascript/olm_inbound_group_session.js +++ b/javascript/olm_inbound_group_session.js @@ -73,10 +73,12 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function( // So we copy the array to a new buffer var message_buffer = stack(message_array); var plaintext_buffer = stack(max_plaintext_length + NULL_BYTE_PADDING_LENGTH); + var message_index = stack(4); var plaintext_length = inbound_group_session_method(Module["_olm_group_decrypt"])( this.ptr, message_buffer, message_array.length, - plaintext_buffer, max_plaintext_length + plaintext_buffer, max_plaintext_length, + message_index ); // Pointer_stringify requires a null-terminated argument (the optional @@ -86,7 +88,10 @@ InboundGroupSession.prototype['decrypt'] = restore_stack(function( 0, "i8" ); - return Pointer_stringify(plaintext_buffer); + return { + "plaintext": Pointer_stringify(plaintext_buffer), + "message_index": Module['getValue'](message_index, "i32") + } }); InboundGroupSession.prototype['session_id'] = restore_stack(function() { |