| 875 | } |
| 876 | |
| 877 | jsi::Value |
| 878 | CommCoreModule::getOneTimeKeys(jsi::Runtime &rt, double oneTimeKeysAmount) { |
| 879 | return createPromiseAsJSIValue( |
| 880 | rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) { |
| 881 | taskType job = [=, &innerRt]() { |
| 882 | std::string error; |
| 883 | std::vector<std::string> contentResult; |
| 884 | std::vector<std::string> notifResult; |
| 885 | if (this->contentCryptoModule == nullptr || |
| 886 | !NotificationsCryptoModule::isNotificationsAccountInitialized()) { |
| 887 | this->jsInvoker_->invokeAsync([=, &innerRt]() { |
| 888 | promise->reject("user has not been initialized"); |
| 889 | }); |
| 890 | return; |
| 891 | } |
| 892 | try { |
| 893 | contentResult = |
| 894 | this->contentCryptoModule->getOneTimeKeysForPublishing( |
| 895 | oneTimeKeysAmount); |
| 896 | std::pair<std::shared_ptr<crypto::CryptoModule>, std::string> |
| 897 | notifsCryptoModuleWithPicklingKey = |
| 898 | NotificationsCryptoModule::fetchNotificationsAccount() |
| 899 | .value(); |
| 900 | notifResult = notifsCryptoModuleWithPicklingKey.first |
| 901 | ->getOneTimeKeysForPublishing(oneTimeKeysAmount); |
| 902 | this->persistCryptoModules(true, notifsCryptoModuleWithPicklingKey); |
| 903 | } catch (const std::exception &e) { |
| 904 | error = e.what(); |
| 905 | } |
| 906 | this->jsInvoker_->invokeAsync([=, &innerRt]() { |
| 907 | if (error.size()) { |
| 908 | promise->reject(error); |
| 909 | return; |
| 910 | } |
| 911 | promise->resolve( |
| 912 | parseOneTimeKeysResult(innerRt, contentResult, notifResult)); |
| 913 | }); |
| 914 | }; |
| 915 | this->cryptoThread->scheduleTask(job); |
| 916 | }); |
| 917 | } |
| 918 | |
| 919 | jsi::Value CommCoreModule::validateAndUploadPrekeys( |
| 920 | jsi::Runtime &rt, |
nothing calls this directly
no test coverage detected