aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_inbound_group_session.js
diff options
context:
space:
mode:
authorRichard van der Hoff <github@rvanderhoff.org.uk>2017-01-10 15:39:42 +0000
committerGitHub <noreply@github.com>2017-01-10 15:39:42 +0000
commit860740a91ee0efcf3c594ece23ef0a38ddda394e (patch)
tree32bc83b640221ff5c983b92fb3a90c6d73d7c85d /javascript/olm_inbound_group_session.js
parent14c30da0e2bdff675c8af97e3c6ee49fba82af8d (diff)
parentc04b770cd3c96aa3a55ff3b6d817ba5b6f6f6922 (diff)
Merge pull request #42 from matrix-org/rav/megolm_export
Export and import of megolm session data
Diffstat (limited to 'javascript/olm_inbound_group_session.js')
-rw-r--r--javascript/olm_inbound_group_session.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/javascript/olm_inbound_group_session.js b/javascript/olm_inbound_group_session.js
index 2e4727f..6bc745d 100644
--- a/javascript/olm_inbound_group_session.js
+++ b/javascript/olm_inbound_group_session.js
@@ -61,6 +61,15 @@ InboundGroupSession.prototype['create'] = restore_stack(function(session_key) {
);
});
+InboundGroupSession.prototype['import_session'] = restore_stack(function(session_key) {
+ var key_array = array_from_string(session_key);
+ var key_buffer = stack(key_array);
+
+ inbound_group_session_method(Module['_olm_import_inbound_group_session'])(
+ this.ptr, key_buffer, key_array.length
+ );
+});
+
InboundGroupSession.prototype['decrypt'] = restore_stack(function(
message
) {
@@ -123,4 +132,21 @@ InboundGroupSession.prototype['session_id'] = restore_stack(function() {
return Pointer_stringify(session_id);
});
+InboundGroupSession.prototype['first_known_index'] = restore_stack(function() {
+ return inbound_group_session_method(
+ Module['_olm_inbound_group_session_first_known_index']
+ )(this.ptr);
+});
+
+InboundGroupSession.prototype['export_session'] = restore_stack(function(message_index) {
+ var key_length = inbound_group_session_method(
+ Module['_olm_export_inbound_group_session_length']
+ )(this.ptr);
+ var key = stack(key_length + NULL_BYTE_PADDING_LENGTH);
+ outbound_group_session_method(Module['_olm_export_inbound_group_session'])(
+ this.ptr, key, key_length, message_index
+ );
+ return Pointer_stringify(key);
+});
+
olm_exports['InboundGroupSession'] = InboundGroupSession;