Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525929
D8657.id29408.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Referenced Files
None
Subscribers
None
D8657.id29408.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
--- a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
+++ b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
@@ -10,6 +10,7 @@
set(NATIVE_HDRS
"CommCoreModule.h"
"CommUtilsModule.h"
+ "CommRustModule.h"
"CommConstants.h"
"NativeModuleUtils.h"
"MessageStoreOperations.h"
@@ -21,6 +22,7 @@
set(NATIVE_SRCS
"CommCoreModule.cpp"
"CommUtilsModule.cpp"
+ "CommRustModule.cpp"
"CommConstants.cpp"
)
diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.h b/native/cpp/CommonCpp/NativeModules/CommRustModule.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include "../_generated/rustJSI.h"
+
+#include <ReactCommon/TurboModuleUtils.h>
+#include <jsi/jsi.h>
+#include <memory>
+
+namespace comm {
+
+namespace jsi = facebook::jsi;
+
+class CommRustModule : public facebook::react::CommRustModuleSchemaCxxSpecJSI {
+ virtual jsi::Value generateNonce(jsi::Runtime &rt) override;
+ virtual jsi::Value registerUser(
+ jsi::Runtime &rt,
+ jsi::String username,
+ jsi::String password,
+ jsi::String keyPayload,
+ jsi::String keyPayloadSignature,
+ jsi::String contentPrekey,
+ jsi::String contentPrekeySignature,
+ jsi::String notifPrekey,
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) override;
+ virtual jsi::Value loginPasswordUser(
+ jsi::Runtime &rt,
+ jsi::String username,
+ jsi::String password,
+ jsi::String keyPayload,
+ jsi::String keyPayloadSignature,
+ jsi::String contentPrekey,
+ jsi::String contentPrekeySignature,
+ jsi::String notifPrekey,
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) override;
+ virtual jsi::Value loginWalletUser(
+ jsi::Runtime &rt,
+ jsi::String siweMessage,
+ jsi::String siweSignature,
+ jsi::String keyPayload,
+ jsi::String keyPayloadSignature,
+ jsi::String contentPrekey,
+ jsi::String contentPrekeySignature,
+ jsi::String notifPrekey,
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys,
+ jsi::String socialProof) override;
+
+public:
+ CommRustModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
+};
+
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
@@ -0,0 +1,176 @@
+#include "CommRustModule.h"
+#include "InternalModules/RustPromiseManager.h"
+#include "JSIRust.h"
+#include "lib.rs.h"
+
+#include <ReactCommon/TurboModuleUtils.h>
+
+namespace comm {
+
+using namespace facebook::react;
+
+CommRustModule::CommRustModule(std::shared_ptr<CallInvoker> jsInvoker)
+ : CommRustModuleSchemaCxxSpecJSI(jsInvoker) {
+}
+
+jsi::Value CommRustModule::generateNonce(jsi::Runtime &rt) {
+ return createPromiseAsJSIValue(
+ rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ std::string error;
+ try {
+ auto currentID = RustPromiseManager::instance.addPromise(
+ promise, this->jsInvoker_, innerRt);
+ identityGenerateNonce(currentID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ };
+ });
+}
+
+jsi::Value CommRustModule::registerUser(
+ jsi::Runtime &rt,
+ jsi::String username,
+ jsi::String password,
+ jsi::String keyPayload,
+ jsi::String keyPayloadSignature,
+ jsi::String contentPrekey,
+ jsi::String contentPrekeySignature,
+ jsi::String notifPrekey,
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) {
+ return createPromiseAsJSIValue(
+ rt,
+ [this,
+ &username,
+ &password,
+ &keyPayload,
+ &keyPayloadSignature,
+ &contentPrekey,
+ &contentPrekeySignature,
+ ¬ifPrekey,
+ ¬ifPrekeySignature,
+ &contentOneTimeKeys,
+ ¬ifOneTimeKeys](
+ jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ std::string error;
+ try {
+ auto currentID = RustPromiseManager::instance.addPromise(
+ promise, this->jsInvoker_, innerRt);
+ identityRegisterUser(
+ jsiStringToRustString(username, innerRt),
+ jsiStringToRustString(password, innerRt),
+ jsiStringToRustString(keyPayload, innerRt),
+ jsiStringToRustString(keyPayloadSignature, innerRt),
+ jsiStringToRustString(contentPrekey, innerRt),
+ jsiStringToRustString(contentPrekeySignature, innerRt),
+ jsiStringToRustString(notifPrekey, innerRt),
+ jsiStringToRustString(notifPrekeySignature, innerRt),
+ jsiStringArrayToRustVec(contentOneTimeKeys, innerRt),
+ jsiStringArrayToRustVec(notifOneTimeKeys, innerRt),
+ currentID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ };
+ });
+}
+
+jsi::Value CommRustModule::loginPasswordUser(
+ jsi::Runtime &rt,
+ jsi::String username,
+ jsi::String password,
+ jsi::String keyPayload,
+ jsi::String keyPayloadSignature,
+ jsi::String contentPrekey,
+ jsi::String contentPrekeySignature,
+ jsi::String notifPrekey,
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) {
+ return createPromiseAsJSIValue(
+ rt,
+ [this,
+ &username,
+ &password,
+ &keyPayload,
+ &keyPayloadSignature,
+ &contentPrekey,
+ &contentPrekeySignature,
+ ¬ifPrekey,
+ ¬ifPrekeySignature,
+ &contentOneTimeKeys,
+ ¬ifOneTimeKeys](
+ jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ std::string error;
+ try {
+ auto currentID = RustPromiseManager::instance.addPromise(
+ promise, this->jsInvoker_, innerRt);
+ identityLoginPasswordUser(
+ jsiStringToRustString(username, innerRt),
+ jsiStringToRustString(password, innerRt),
+ jsiStringToRustString(keyPayload, innerRt),
+ jsiStringToRustString(keyPayloadSignature, innerRt),
+ jsiStringToRustString(contentPrekey, innerRt),
+ jsiStringToRustString(contentPrekeySignature, innerRt),
+ jsiStringToRustString(notifPrekey, innerRt),
+ jsiStringToRustString(notifPrekeySignature, innerRt),
+ jsiStringArrayToRustVec(contentOneTimeKeys, innerRt),
+ jsiStringArrayToRustVec(notifOneTimeKeys, innerRt),
+ currentID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ };
+ });
+}
+
+jsi::Value CommRustModule::loginWalletUser(
+ jsi::Runtime &rt,
+ jsi::String siweMessage,
+ jsi::String siweSignature,
+ jsi::String keyPayload,
+ jsi::String keyPayloadSignature,
+ jsi::String contentPrekey,
+ jsi::String contentPrekeySignature,
+ jsi::String notifPrekey,
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys,
+ jsi::String socialProof) {
+ return createPromiseAsJSIValue(
+ rt,
+ [this,
+ &siweMessage,
+ &siweSignature,
+ &keyPayload,
+ &keyPayloadSignature,
+ &contentPrekey,
+ &contentPrekeySignature,
+ ¬ifPrekey,
+ ¬ifPrekeySignature,
+ &contentOneTimeKeys,
+ ¬ifOneTimeKeys,
+ &socialProof](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ std::string error;
+ try {
+ auto currentID = RustPromiseManager::instance.addPromise(
+ promise, this->jsInvoker_, innerRt);
+ identityLoginWalletUser(
+ jsiStringToRustString(siweMessage, innerRt),
+ jsiStringToRustString(siweSignature, innerRt),
+ jsiStringToRustString(keyPayload, innerRt),
+ jsiStringToRustString(keyPayloadSignature, innerRt),
+ jsiStringToRustString(contentPrekey, innerRt),
+ jsiStringToRustString(contentPrekeySignature, innerRt),
+ jsiStringToRustString(notifPrekey, innerRt),
+ jsiStringToRustString(notifPrekeySignature, innerRt),
+ jsiStringArrayToRustVec(contentOneTimeKeys, innerRt),
+ jsiStringArrayToRustVec(notifOneTimeKeys, innerRt),
+ jsiStringToRustString(socialProof, innerRt),
+ currentID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ };
+ });
+}
+
+} // namespace comm
diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj
--- a/native/ios/Comm.xcodeproj/project.pbxproj
+++ b/native/ios/Comm.xcodeproj/project.pbxproj
@@ -54,6 +54,7 @@
8EF7756B2A7433630046A385 /* ThreadStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF775692A7433630046A385 /* ThreadStore.cpp */; };
8EF7756E2A7513F40046A385 /* MessageStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF7756D2A7513F40046A385 /* MessageStore.cpp */; };
8EF775712A751B780046A385 /* ReportStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF7756F2A751B780046A385 /* ReportStore.cpp */; };
+ 8EF775682A74032C0046A385 /* CommRustModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF775672A74032C0046A385 /* CommRustModule.cpp */; };
B71AFF1F265EDD8600B22352 /* IBMPlexSans-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B71AFF1E265EDD8600B22352 /* IBMPlexSans-Medium.ttf */; };
CB1648AF27CFBE6A00394D9D /* CryptoModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71BF5B7B26BBDA6100EDE27D /* CryptoModule.cpp */; };
CB24361829A39A2500FEC4E1 /* NotificationsCryptoModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB24361729A39A2500FEC4E1 /* NotificationsCryptoModule.cpp */; };
@@ -214,6 +215,8 @@
8EF7756D2A7513F40046A385 /* MessageStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MessageStore.cpp; path = PersistentStorageUtilities/DataStores/MessageStore.cpp; sourceTree = "<group>"; };
8EF7756F2A751B780046A385 /* ReportStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ReportStore.cpp; path = PersistentStorageUtilities/DataStores/ReportStore.cpp; sourceTree = "<group>"; };
8EF775702A751B780046A385 /* ReportStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ReportStore.h; path = PersistentStorageUtilities/DataStores/ReportStore.h; sourceTree = "<group>"; };
+ 8EF775662A74032C0046A385 /* CommRustModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommRustModule.h; sourceTree = "<group>"; };
+ 8EF775672A74032C0046A385 /* CommRustModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommRustModule.cpp; sourceTree = "<group>"; };
913E5A7BDECB327E3DE11053 /* Pods-NotificationService.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.release.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.release.xcconfig"; sourceTree = "<group>"; };
994BEBDD4E4959F69CEA0BC3 /* libPods-Comm.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Comm.a"; sourceTree = BUILT_PRODUCTS_DIR; };
B7055C6B26E477CF00BE0548 /* MessageStoreOperations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageStoreOperations.h; sourceTree = "<group>"; };
@@ -404,6 +407,8 @@
isa = PBXGroup;
children = (
8EA59BD22A6E800100EB4F53 /* NativeModuleUtils.h */,
+ 8EF775672A74032C0046A385 /* CommRustModule.cpp */,
+ 8EF775662A74032C0046A385 /* CommRustModule.h */,
8EE6E4A02A39CCAB00AE6BCD /* DraftStoreOperations.h */,
8EE6E49F2A39CCAB00AE6BCD /* ReportStoreOperations.h */,
CB2688FF2A2DF56000EC7300 /* CommConstants.cpp */,
@@ -486,8 +491,8 @@
71F971B4270726C000DDC5BF /* _generated */ = {
isa = PBXGroup;
children = (
- 8EA59BD72A73DAB000EB4F53 /* rustJSI-generated.cpp */,
- 8EA59BD82A73DAB000EB4F53 /* rustJSI.h */,
+ 8EA59BD72A73DAB000EB4F53 /* rustJSI-generated.cpp */,
+ 8EA59BD82A73DAB000EB4F53 /* rustJSI.h */,
7FE4D9F4291DFE9300667BF6 /* commJSI-generated.cpp */,
7FE4D9F3291DFE9300667BF6 /* commJSI.h */,
7FBB2A7529E94539002C6493 /* utilsJSI-generated.cpp */,
@@ -1038,6 +1043,7 @@
CB7EF180295C674300B17035 /* CommIOSNotificationsBridgeQueue.mm in Sources */,
7F0C6E31291C4468002AA2D9 /* ExpoModulesProvider.swift in Sources */,
75291F0428F9A0D400F4C80E /* DeviceID.cpp in Sources */,
+ 8EF775682A74032C0046A385 /* CommRustModule.cpp in Sources */,
8E43C32C291E5B4A009378F5 /* TerminateApp.mm in Sources */,
8BC9568529FC49B00060AE4A /* JSIRust.cpp in Sources */,
8EA59BD92A73DAB000EB4F53 /* rustJSI-generated.cpp in Sources */,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 6:50 PM (8 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700014
Default Alt Text
D8657.id29408.diff (13 KB)
Attached To
Mode
D8657: [native] add CommRustModule implementation
Attached
Detach File
Event Timeline
Log In to Comment