add JavaScript function for getting unpublished fallback key

This commit is contained in:
Hubert Chathi 2021-11-19 17:48:25 -05:00
parent 4127a84b3d
commit c5eff859cb
2 changed files with 29 additions and 0 deletions

View file

@ -29,6 +29,7 @@ declare class Account {
remove_one_time_keys(session: Session); remove_one_time_keys(session: Session);
generate_fallback_key(); generate_fallback_key();
fallback_key(): string; fallback_key(): string;
unpublished_fallback_key(): string;
pickle(key: string | Uint8Array): string; pickle(key: string | Uint8Array): string;
unpickle(key: string | Uint8Array, pickle: string); unpickle(key: string | Uint8Array, pickle: string);
} }

View file

@ -172,6 +172,34 @@ Account.prototype['fallback_key'] = restore_stack(function() {
return UTF8ToString(keys, keys_length); return UTF8ToString(keys, keys_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['unpublished_fallback_key'] = restore_stack(function() {
var keys_length = account_method(
Module['_olm_account_unpublished_fallback_key_length']
)(this.ptr);
var keys = stack(keys_length + NULL_BYTE_PADDING_LENGTH);
account_method(Module['_olm_account_unpublished_fallback_key'])(
this.ptr, keys, keys_length
);
return UTF8ToString(keys, keys_length);
});
Account.prototype['forget_previous_fallback'] = restore_stack(function() {
account_method(Module['_olm_account_forget_previous_fallback_key'])(
this.ptr
);
});
Account.prototype['pickle'] = restore_stack(function(key) { Account.prototype['pickle'] = restore_stack(function(key) {
var key_array = array_from_string(key); var key_array = array_from_string(key);
var pickle_length = account_method( var pickle_length = account_method(