| 1763 | } |
| 1764 | |
| 1765 | jsi::Value CommCoreModule::encryptNotification( |
| 1766 | jsi::Runtime &rt, |
| 1767 | jsi::String payload, |
| 1768 | jsi::String deviceID) { |
| 1769 | auto payloadCpp{payload.utf8(rt)}; |
| 1770 | auto deviceIDCpp{deviceID.utf8(rt)}; |
| 1771 | |
| 1772 | return createPromiseAsJSIValue( |
| 1773 | rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) { |
| 1774 | taskType job = [=, &innerRt]() { |
| 1775 | std::string error; |
| 1776 | crypto::EncryptedData result; |
| 1777 | try { |
| 1778 | result = |
| 1779 | NotificationsCryptoModule::encrypt(deviceIDCpp, payloadCpp); |
| 1780 | } catch (const std::exception &e) { |
| 1781 | error = e.what(); |
| 1782 | } |
| 1783 | |
| 1784 | this->jsInvoker_->invokeAsync([=, &innerRt]() { |
| 1785 | if (error.size()) { |
| 1786 | promise->reject(error); |
| 1787 | return; |
| 1788 | } |
| 1789 | auto encryptedDataJSI = parseEncryptedData(innerRt, result); |
| 1790 | promise->resolve(std::move(encryptedDataJSI)); |
| 1791 | }); |
| 1792 | }; |
| 1793 | this->cryptoThread->scheduleTask(job); |
| 1794 | }); |
| 1795 | } |
| 1796 | |
| 1797 | jsi::Value CommCoreModule::encryptAndPersist( |
| 1798 | jsi::Runtime &rt, |
nothing calls this directly
no test coverage detected