MCPcopy Create free account
hub / github.com/CommE2E/comm / encrypt

Method encrypt

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:1733–1763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1731}
1732
1733jsi::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
1765jsi::Value CommCoreModule::encryptNotification(
1766 jsi::Runtime &rt,

Callers

nothing calls this directly

Calls 6

persistCryptoModulesMethod · 0.95
parseEncryptedDataFunction · 0.85
rejectMethod · 0.80
resolveMethod · 0.80
scheduleTaskMethod · 0.80
encryptMethod · 0.65

Tested by

no test coverage detected