diff options
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/axolotl_pre.js | 1 | ||||
-rwxr-xr-x | javascript/build.py | 6 | ||||
-rw-r--r-- | javascript/demo.html | 10 | ||||
-rw-r--r-- | javascript/olm_post.js (renamed from javascript/axolotl_post.js) | 66 | ||||
-rw-r--r-- | javascript/olm_pre.js | 1 |
5 files changed, 42 insertions, 42 deletions
diff --git a/javascript/axolotl_pre.js b/javascript/axolotl_pre.js deleted file mode 100644 index 69df923..0000000 --- a/javascript/axolotl_pre.js +++ /dev/null @@ -1 +0,0 @@ -Axolotl = function() { diff --git a/javascript/build.py b/javascript/build.py index 08436fd..68b7e45 100755 --- a/javascript/build.py +++ b/javascript/build.py @@ -28,8 +28,8 @@ if not os.path.exists("build"): os.mkdir("build") functions = set() -RE_FUNCTION=re.compile("(axolotl_[^( ]*)\\(") -with open("include/axolotl/axolotl.hh") as header: +RE_FUNCTION=re.compile("(olm_[^( ]*)\\(") +with open("include/olm/olm.hh") as header: for line in header: match = RE_FUNCTION.search(line) if match: @@ -60,7 +60,7 @@ compile_args += ("--pre-js", pre_js) compile_args += ("--post-js", post_js) compile_args += ("-s", "EXPORTED_FUNCTIONS=@" + exported_functions) -library = "build/axolotl.js" +library = "build/olm.js" def run(args): print args diff --git a/javascript/demo.html b/javascript/demo.html index ce4bfed..cace119 100644 --- a/javascript/demo.html +++ b/javascript/demo.html @@ -1,6 +1,6 @@ <html> <head> -<script src="../build/axolotl.js"></script> +<script src="../build/olm.js"></script> <script> document.addEventListener("DOMContentLoaded", function (event) { @@ -19,10 +19,10 @@ document.addEventListener("DOMContentLoaded", function (event) { return {start:start, done:done}; } - var alice = new Axolotl.Account(); - var bob = new Axolotl.Account(); - var a_session = new Axolotl.Session(); - var b_session = new Axolotl.Session(); + var alice = new Olm.Account(); + var bob = new Olm.Account(); + var a_session = new Olm.Session(); + var b_session = new Olm.Session(); var message_1; var tasks = []; diff --git a/javascript/axolotl_post.js b/javascript/olm_post.js index 570c66f..6ebd198 100644 --- a/javascript/axolotl_post.js +++ b/javascript/olm_post.js @@ -2,7 +2,7 @@ var runtime = Module['Runtime']; var malloc = Module['_malloc']; var free = Module['_free']; var Pointer_stringify = Module['Pointer_stringify']; -var AXOLOTL_ERROR = Module['_axolotl_error'](); +var OLM_ERROR = Module['_olm_error'](); function stack(size_or_array) { return Module['allocate'](size_or_array, 'i8', Module['ALLOC_STACK']); @@ -31,19 +31,19 @@ function restore_stack(wrapped) { } function Account() { - var size = Module['_axolotl_account_size'](); + var size = Module['_olm_account_size'](); this.buf = malloc(size); - this.ptr = Module['_axolotl_account'](this.buf); + this.ptr = Module['_olm_account'](this.buf); } function account_method(wrapped) { return function() { var result = wrapped.apply(this, arguments); - if (result === AXOLOTL_ERROR) { + if (result === OLM_ERROR) { var message = Pointer_stringify( - Module['_axolotl_account_last_error'](arguments[0]) + Module['_olm_account_last_error'](arguments[0]) ); - throw new Error("AXOLOTL." + message); + throw new Error("OLM." + message); } return result; } @@ -55,20 +55,20 @@ Account.prototype['free'] = function() { Account.prototype['create'] = restore_stack(function() { var random_length = account_method( - Module['_axolotl_create_account_random_length'] + Module['_olm_create_account_random_length'] )(this.ptr); var random = random_stack(random_length); - account_method(Module['_axolotl_create_account'])( + account_method(Module['_olm_create_account'])( this.ptr, random, random_length ); }); Account.prototype['identity_keys'] = restore_stack(function() { var keys_length = account_method( - Module['_axolotl_account_identity_keys_length'] + Module['_olm_account_identity_keys_length'] )(this.ptr); var keys = stack(keys_length); - account_method(Module['_axolotl_account_identity_keys'])( + account_method(Module['_olm_account_identity_keys'])( this.ptr, keys, keys_length ); return Pointer_stringify(keys, keys_length); @@ -76,10 +76,10 @@ Account.prototype['identity_keys'] = restore_stack(function() { Account.prototype['one_time_keys'] = restore_stack(function() { var keys_length = account_method( - Module['_axolotl_account_one_time_keys_length'] + Module['_olm_account_one_time_keys_length'] )(this.ptr); var keys = stack(keys_length); - account_method(Module['_axolotl_account_one_time_keys'])( + account_method(Module['_olm_account_one_time_keys'])( this.ptr, keys, keys_length ); return Pointer_stringify(keys, keys_length); @@ -88,11 +88,11 @@ Account.prototype['one_time_keys'] = restore_stack(function() { Account.prototype['pickle'] = restore_stack(function(key) { var key_array = array_from_string(key); var pickle_length = account_method( - Module['_axolotl_pickle_account_length'] + Module['_olm_pickle_account_length'] )(this.ptr); var key_buffer = stack(key_array); var pickle_buffer = stack(pickle_length); - account_method(Module['_axolotl_pickle_account'])( + account_method(Module['_olm_pickle_account'])( this.ptr, key_buffer, key_array.length, pickle_buffer, pickle_length ); return Pointer_stringify(pickle_buffer, pickle_length); @@ -103,26 +103,26 @@ Account.prototype['unpickle'] = restore_stack(function(key, pickle) { var key_buffer = stack(key_array); var pickle_array = array_from_string(pickle); var pickle_buffer = stack(pickle_length); - account_method(Module['_axolotl_unpickle_account'])( + account_method(Module['_olm_unpickle_account'])( this.ptr, key_buffer, key_array.length, pickle_buffer, pickle_array.length ); }); function Session() { - var size = Module['_axolotl_session_size'](); + var size = Module['_olm_session_size'](); this.buf = malloc(size); - this.ptr = Module['_axolotl_session'](this.buf); + this.ptr = Module['_olm_session'](this.buf); } function session_method(wrapped) { return function() { var result = wrapped.apply(this, arguments); - if (result === AXOLOTL_ERROR) { + if (result === OLM_ERROR) { var message = Pointer_stringify( - Module['_axolotl_session_last_error'](arguments[0]) + Module['_olm_session_last_error'](arguments[0]) ); - throw new Error("AXOLOTL." + message); + throw new Error("OLM." + message); } return result; } @@ -135,11 +135,11 @@ Session.prototype['free'] = function() { Session.prototype['pickle'] = restore_stack(function(key) { var key_array = array_from_string(key); var pickle_length = session_method( - Module['_axolotl_pickle_session_length'] + Module['_olm_pickle_session_length'] )(this.ptr); var key_buffer = stack(key_array); var pickle_buffer = stack(pickle_length); - session_method(Module['_axolotl_pickle_session'])( + session_method(Module['_olm_pickle_session'])( this.ptr, key_buffer, key_array.length, pickle_buffer, pickle_length ); return Pointer_stringify(pickle_buffer, pickle_length); @@ -150,7 +150,7 @@ Session.prototype['unpickle'] = restore_stack(function(key, pickle) { var key_buffer = stack(key_array); var pickle_array = array_from_string(pickle); var pickle_buffer = stack(pickle_array); - session_method(Module['_axolotl_unpickle_session'])( + session_method(Module['_olm_unpickle_session'])( this.ptr, key_buffer, key_array.length, pickle_buffer, pickle_array.length ); @@ -160,14 +160,14 @@ Session.prototype['create_outbound'] = restore_stack(function( account, their_identity_key, their_one_time_key_id, their_one_time_key ) { var random_length = session_method( - Module['_axolotl_create_outbound_session_random_length'] + Module['_olm_create_outbound_session_random_length'] )(this.ptr); var random = random_stack(random_length); var identity_key_array = array_from_string(their_identity_key); var one_time_key_array = array_from_string(their_one_time_key); var identity_key_buffer = stack(identity_key_array); var one_time_key_buffer = stack(one_time_key_array); - session_method(Module['_axolotl_create_outbound_session'])( + session_method(Module['_olm_create_outbound_session'])( this.ptr, account.ptr, identity_key_buffer, identity_key_array.length, their_one_time_key_id, @@ -181,7 +181,7 @@ Session.prototype['create_inbound'] = restore_stack(function( ) { var message_array = array_from_string(one_time_key_message); var message_buffer = stack(message_array); - session_method(Module['_axolotl_create_inbound_session'])( + session_method(Module['_olm_create_inbound_session'])( this.ptr, account.ptr, message_buffer, message_array.length ); }); @@ -191,7 +191,7 @@ Session.prototype['matches_inbound'] = restore_stack(function( ) { var message_array = array_from_string(one_time_key_message); var message_buffer = stack(message_array); - return session_method(Module['_axolotl_matches_inbound_session'])( + return session_method(Module['_olm_matches_inbound_session'])( this.ptr, account.ptr, message_buffer, message_array.length ) ? true : false; }); @@ -200,19 +200,19 @@ Session.prototype['encrypt'] = restore_stack(function( plaintext ) { var random_length = session_method( - Module['_axolotl_encrypt_random_length'] + Module['_olm_encrypt_random_length'] )(this.ptr); var message_type = session_method( - Module['_axolotl_encrypt_message_type'] + Module['_olm_encrypt_message_type'] )(this.ptr); var plaintext_array = array_from_string(plaintext); var message_length = session_method( - Module['_axolotl_encrypt_message_length'] + Module['_olm_encrypt_message_length'] )(this.ptr, plaintext_array.length); var random = random_stack(random_length); var plaintext_buffer = stack(plaintext_array); var message_buffer = stack(message_length); - session_method(Module['_axolotl_encrypt'])( + session_method(Module['_olm_encrypt'])( this.ptr, plaintext_buffer, plaintext_array.length, random, random_length, @@ -230,13 +230,13 @@ Session.prototype['decrypt'] = restore_stack(function( var message_array = array_from_string(message); var message_buffer = stack(message_array); var max_plaintext_length = session_method( - Module['_axolotl_decrypt_max_plaintext_length'] + Module['_olm_decrypt_max_plaintext_length'] )(this.ptr, message_type, message_buffer, message_array.length); // caculating the length destroys the input buffer. // So we copy the array to a new buffer var message_buffer = stack(message_array); var plaintext_buffer = stack(max_plaintext_length); - var plaintext_length = session_method(Module["_axolotl_decrypt"])( + var plaintext_length = session_method(Module["_olm_decrypt"])( this.ptr, message_type, message_buffer, message.length, plaintext_buffer, max_plaintext_length diff --git a/javascript/olm_pre.js b/javascript/olm_pre.js new file mode 100644 index 0000000..c7b0d5e --- /dev/null +++ b/javascript/olm_pre.js @@ -0,0 +1 @@ +Olm = function() { |