| 1731 | } |
| 1732 | |
| 1733 | jsi::Value CommCoreModule::encrypt( |
| 1734 | jsi::Runtime &rt, |
| 1735 | jsi::String message, |
| 1736 | jsi::String deviceID) { |
| 1737 | auto messageCpp{message.utf8(rt)}; |
| 1738 | auto deviceIDCpp{deviceID.utf8(rt)}; |
| 1739 | return createPromiseAsJSIValue( |
| 1740 | rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) { |
| 1741 | taskType job = [=, &innerRt]() { |
| 1742 | std::string error; |
| 1743 | crypto::EncryptedData encryptedMessage; |
| 1744 | try { |
| 1745 | encryptedMessage = |
| 1746 | contentCryptoModule->encrypt(deviceIDCpp, messageCpp); |
| 1747 | this->persistCryptoModules(true, std::nullopt); |
| 1748 | } catch (const std::exception &e) { |
| 1749 | error = e.what(); |
| 1750 | } |
| 1751 | this->jsInvoker_->invokeAsync([=, &innerRt]() { |
| 1752 | if (error.size()) { |
| 1753 | promise->reject(error); |
| 1754 | return; |
| 1755 | } |
| 1756 | auto encryptedDataJSI = |
| 1757 | parseEncryptedData(innerRt, encryptedMessage); |
| 1758 | promise->resolve(std::move(encryptedDataJSI)); |
| 1759 | }); |
| 1760 | }; |
| 1761 | this->cryptoThread->scheduleTask(job); |
| 1762 | }); |
| 1763 | } |
| 1764 | |
| 1765 | jsi::Value CommCoreModule::encryptNotification( |
| 1766 | jsi::Runtime &rt, |
nothing calls this directly
no test coverage detected