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

Method getUserPublicKey

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:687–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685}
686
687jsi::Value CommCoreModule::getUserPublicKey(jsi::Runtime &rt) {
688 return createPromiseAsJSIValue(
689 rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
690 taskType job = [=, &innerRt]() {
691 std::string error;
692 std::string primaryKeysResult;
693 std::string notificationsKeysResult;
694 if (this->contentCryptoModule == nullptr ||
695 !NotificationsCryptoModule::isNotificationsAccountInitialized()) {
696 error = "user has not been initialized";
697 } else {
698 primaryKeysResult = this->contentCryptoModule->getIdentityKeys();
699 notificationsKeysResult =
700 NotificationsCryptoModule::getIdentityKeys();
701 }
702
703 std::string notificationsCurve25519Cpp, notificationsEd25519Cpp,
704 blobPayloadCpp, signatureCpp, primaryCurve25519Cpp,
705 primaryEd25519Cpp;
706
707 if (!error.size()) {
708 folly::dynamic parsedPrimary;
709 try {
710 parsedPrimary = folly::parseJson(primaryKeysResult);
711 } catch (const folly::json::parse_error &e) {
712 error =
713 "parsing identity keys failed with: " + std::string(e.what());
714 }
715 if (!error.size()) {
716 primaryCurve25519Cpp = parsedPrimary["curve25519"].asString();
717 primaryEd25519Cpp = parsedPrimary["ed25519"].asString();
718
719 folly::dynamic parsedNotifications;
720 try {
721 parsedNotifications = folly::parseJson(notificationsKeysResult);
722 } catch (const folly::json::parse_error &e) {
723 error = "parsing notifications keys failed with: " +
724 std::string(e.what());
725 }
726 if (!error.size()) {
727 notificationsCurve25519Cpp =
728 parsedNotifications["curve25519"].asString();
729 notificationsEd25519Cpp =
730 parsedNotifications["ed25519"].asString();
731
732 folly::dynamic blobPayloadJSON = folly::dynamic::object(
733 "primaryIdentityPublicKeys",
734 folly::dynamic::object("ed25519", primaryEd25519Cpp)(
735 "curve25519", primaryCurve25519Cpp))(
736 "notificationIdentityPublicKeys",
737 folly::dynamic::object("ed25519", notificationsEd25519Cpp)(
738 "curve25519", notificationsCurve25519Cpp));
739
740 blobPayloadCpp = folly::toJson(blobPayloadJSON);
741 signatureCpp =
742 this->contentCryptoModule->signMessage(blobPayloadCpp);
743 }
744 }

Callers

nothing calls this directly

Calls 5

rejectMethod · 0.80
resolveMethod · 0.80
scheduleTaskMethod · 0.80
getIdentityKeysMethod · 0.45
signMessageMethod · 0.45

Tested by

no test coverage detected