diff options
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/index.d.ts | 2 | ||||
-rw-r--r-- | javascript/olm_post.js | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/javascript/index.d.ts b/javascript/index.d.ts index d11ce23..e558fec 100644 --- a/javascript/index.d.ts +++ b/javascript/index.d.ts @@ -27,6 +27,8 @@ declare class Account { max_number_of_one_time_keys(): number; generate_one_time_keys(number_of_keys: number); remove_one_time_keys(session: Session); + generate_fallback_key(); + fallback_key(): string; pickle(key: string): string; unpickle(key: string, pickle: string); } diff --git a/javascript/olm_post.js b/javascript/olm_post.js index 439041a..82dd803 100644 --- a/javascript/olm_post.js +++ b/javascript/olm_post.js @@ -141,11 +141,32 @@ Account.prototype['generate_one_time_keys'] = restore_stack(function( }); Account.prototype['remove_one_time_keys'] = restore_stack(function(session) { - account_method(Module['_olm_remove_one_time_keys'])( + account_method(Module['_olm_remove_one_time_keys'])( this.ptr, session.ptr ); }); +Account.prototype['generate_fallback_key'] = restore_stack(function() { + var random_length = account_method( + Module['_olm_account_generate_fallback_key_random_length'] + )(this.ptr); + var random = random_stack(random_length); + account_method(Module['_olm_account_generate_fallback_key'])( + this.ptr, random, random_length + ); +}); + +Account.prototype['fallback_key'] = restore_stack(function() { + var keys_length = account_method( + Module['_olm_account_fallback_key_length'] + )(this.ptr); + var keys = stack(keys_length + NULL_BYTE_PADDING_LENGTH); + account_method(Module['_olm_account_fallback_key'])( + this.ptr, keys, keys_length + ); + return UTF8ToString(keys, keys_length); +}); + Account.prototype['pickle'] = restore_stack(function(key) { var key_array = array_from_string(key); var pickle_length = account_method( |