[native] update one time keys logic
Summary:
A lot of changes here... will annotate all of them inline. Here are the big things:
- consolidated getPrimaryOneTimeKeys and getNotificationsOneTimeKeys into a single API, getOneTimeKeys
- make sure we only generate one-time keys if we don't have enough unpublished one-time keys
- rename CryptoModule::getOneTimeKeys to CryptoModule::getOneTimeKeysForPublishing so that it's clear to the caller that the returned keys should be published immediately
Test Plan:
test patch
- Modified getOneTimeKeysForPublishing to generate one unpublished one-time key
- called `commCoreModule.getOneTimeKeys(10) twice from JS
- confirmed that the one unpublished key appeared in otks but not otks2 (all the keys in otks get marked as published so they are no longer accessible on the second call)
- confirmed that otks2 was a brand new set of 10 keys
- (not in patch) called commCoreModule.getOneTimeKeys(101) and got an error: {"message": "error generateKeys => invalid amount of one-time keys published. Expected 101, got 100"}. this is expected since the account can only hold 100 one-time keys.
Reviewers: ashoat, kamil, marcin
Reviewed By: ashoat, kamil, marcin
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D10977