diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.h b/native/cpp/CommonCpp/NativeModules/CommRustModule.h --- a/native/cpp/CommonCpp/NativeModules/CommRustModule.h +++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.h @@ -25,6 +25,20 @@ jsi::Array contentOneTimeKeys, jsi::Array notifOneTimeKeys, jsi::String farcasterID) override; + virtual jsi::Value registerReservedPasswordUser( + 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, + jsi::String keyserverMessage, + jsi::String keyserverSignature) override; virtual jsi::Value logInPasswordUser( jsi::Runtime &rt, jsi::String username, @@ -48,6 +62,20 @@ jsi::Array contentOneTimeKeys, jsi::Array notifOneTimeKeys, jsi::String farcasterID) override; + virtual jsi::Value registerReservedWalletUser( + 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 keyserverMessage, + jsi::String keyserverSignature) override; virtual jsi::Value logInWalletUser( jsi::Runtime &rt, jsi::String siweMessage, diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp @@ -87,6 +87,65 @@ }); } +jsi::Value CommRustModule::registerReservedPasswordUser( + 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, + jsi::String keyserverMessage, + jsi::String keyserverSignature) { + auto usernameRust = jsiStringToRustString(username, rt); + auto passwordRust = jsiStringToRustString(password, rt); + auto keyPayloadRust = jsiStringToRustString(keyPayload, rt); + auto keyPayloadSignatureRust = jsiStringToRustString(keyPayloadSignature, rt); + auto contentPrekeyRust = jsiStringToRustString(contentPrekey, rt); + auto contentPrekeySignatureRust = + jsiStringToRustString(contentPrekeySignature, rt); + auto notifPrekeyRust = jsiStringToRustString(notifPrekey, rt); + auto notifPrekeySignatureRust = + jsiStringToRustString(notifPrekeySignature, rt); + auto contentOneTimeKeysRust = jsiStringArrayToRustVec(contentOneTimeKeys, rt); + auto notifOneTimeKeysRust = jsiStringArrayToRustVec(notifOneTimeKeys, rt); + auto keyserverMessageRust = jsiStringToRustString(keyserverMessage, rt); + auto keyserverSignatureRust = jsiStringToRustString(keyserverSignature, rt); + + return createPromiseAsJSIValue( + rt, [=, this](jsi::Runtime &innerRt, std::shared_ptr promise) { + std::string error; + try { + auto currentID = RustPromiseManager::instance.addPromise( + {promise, this->jsInvoker_, innerRt}); + identityRegisterReservedPasswordUser( + usernameRust, + passwordRust, + keyPayloadRust, + keyPayloadSignatureRust, + contentPrekeyRust, + contentPrekeySignatureRust, + notifPrekeyRust, + notifPrekeySignatureRust, + contentOneTimeKeysRust, + notifOneTimeKeysRust, + keyserverMessageRust, + keyserverSignatureRust, + currentID); + } catch (const std::exception &e) { + error = e.what(); + }; + if (!error.empty()) { + this->jsInvoker_->invokeAsync( + [error, promise]() { promise->reject(error); }); + } + }); +} + jsi::Value CommRustModule::logInPasswordUser( jsi::Runtime &rt, jsi::String username, @@ -190,6 +249,65 @@ }); } +jsi::Value CommRustModule::registerReservedWalletUser( + 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 keyserverMessage, + jsi::String keyserverSignature) { + auto siweMessageRust = jsiStringToRustString(siweMessage, rt); + auto siweSignatureRust = jsiStringToRustString(siweSignature, rt); + auto keyPayloadRust = jsiStringToRustString(keyPayload, rt); + auto keyPayloadSignatureRust = jsiStringToRustString(keyPayloadSignature, rt); + auto contentPrekeyRust = jsiStringToRustString(contentPrekey, rt); + auto contentPrekeySignatureRust = + jsiStringToRustString(contentPrekeySignature, rt); + auto notifPrekeyRust = jsiStringToRustString(notifPrekey, rt); + auto notifPrekeySignatureRust = + jsiStringToRustString(notifPrekeySignature, rt); + auto contentOneTimeKeysRust = jsiStringArrayToRustVec(contentOneTimeKeys, rt); + auto notifOneTimeKeysRust = jsiStringArrayToRustVec(notifOneTimeKeys, rt); + auto keyserverMessageRust = jsiStringToRustString(keyserverMessage, rt); + auto keyserverSignatureRust = jsiStringToRustString(keyserverSignature, rt); + + return createPromiseAsJSIValue( + rt, [=, this](jsi::Runtime &innerRt, std::shared_ptr promise) { + std::string error; + try { + auto currentID = RustPromiseManager::instance.addPromise( + {promise, this->jsInvoker_, innerRt}); + identityRegisterReservedWalletUser( + siweMessageRust, + siweSignatureRust, + keyPayloadRust, + keyPayloadSignatureRust, + contentPrekeyRust, + contentPrekeySignatureRust, + notifPrekeyRust, + notifPrekeySignatureRust, + contentOneTimeKeysRust, + notifOneTimeKeysRust, + keyserverMessageRust, + keyserverSignatureRust, + currentID); + } catch (const std::exception &e) { + error = e.what(); + }; + if (!error.empty()) { + this->jsInvoker_->invokeAsync( + [error, promise]() { promise->reject(error); }); + } + }); +} + jsi::Value CommRustModule::logInWalletUser( jsi::Runtime &rt, jsi::String siweMessage, diff --git a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp --- a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp +++ b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp @@ -18,12 +18,18 @@ static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerPasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->registerPasswordUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt), args[5].asString(rt), args[6].asString(rt), args[7].asString(rt), args[8].asObject(rt).asArray(rt), args[9].asObject(rt).asArray(rt), args[10].asString(rt)); } +static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerReservedPasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->registerReservedPasswordUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt), args[5].asString(rt), args[6].asString(rt), args[7].asString(rt), args[8].asObject(rt).asArray(rt), args[9].asObject(rt).asArray(rt), args[10].asString(rt), args[11].asString(rt)); +} static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInPasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->logInPasswordUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt), args[5].asString(rt), args[6].asString(rt), args[7].asString(rt)); } static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerWalletUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->registerWalletUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt), args[5].asString(rt), args[6].asString(rt), args[7].asString(rt), args[8].asObject(rt).asArray(rt), args[9].asObject(rt).asArray(rt), args[10].asString(rt)); } +static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerReservedWalletUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->registerReservedWalletUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt), args[5].asString(rt), args[6].asString(rt), args[7].asString(rt), args[8].asObject(rt).asArray(rt), args[9].asObject(rt).asArray(rt), args[10].asString(rt), args[11].asString(rt)); +} static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInWalletUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->logInWalletUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt), args[5].asString(rt), args[6].asString(rt), args[7].asString(rt)); } @@ -89,8 +95,10 @@ : TurboModule("CommRustTurboModule", jsInvoker) { methodMap_["generateNonce"] = MethodMetadata {0, __hostFunction_CommRustModuleSchemaCxxSpecJSI_generateNonce}; methodMap_["registerPasswordUser"] = MethodMetadata {11, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerPasswordUser}; + methodMap_["registerReservedPasswordUser"] = MethodMetadata {12, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerReservedPasswordUser}; methodMap_["logInPasswordUser"] = MethodMetadata {8, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInPasswordUser}; methodMap_["registerWalletUser"] = MethodMetadata {11, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerWalletUser}; + methodMap_["registerReservedWalletUser"] = MethodMetadata {12, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerReservedWalletUser}; methodMap_["logInWalletUser"] = MethodMetadata {8, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInWalletUser}; methodMap_["updatePassword"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_updatePassword}; methodMap_["deletePasswordUser"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_deletePasswordUser}; diff --git a/native/cpp/CommonCpp/_generated/rustJSI.h b/native/cpp/CommonCpp/_generated/rustJSI.h --- a/native/cpp/CommonCpp/_generated/rustJSI.h +++ b/native/cpp/CommonCpp/_generated/rustJSI.h @@ -22,8 +22,10 @@ public: virtual jsi::Value generateNonce(jsi::Runtime &rt) = 0; virtual jsi::Value registerPasswordUser(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, jsi::String farcasterID) = 0; + virtual jsi::Value registerReservedPasswordUser(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, jsi::String keyserverMessage, jsi::String keyserverSignature) = 0; 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) = 0; virtual jsi::Value registerWalletUser(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 farcasterID) = 0; + virtual jsi::Value registerReservedWalletUser(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 keyserverMessage, jsi::String keyserverSignature) = 0; 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) = 0; virtual jsi::Value updatePassword(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String password) = 0; virtual jsi::Value deletePasswordUser(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String password) = 0; @@ -81,6 +83,14 @@ return bridging::callFromJs( rt, &T::registerPasswordUser, jsInvoker_, instance_, std::move(username), std::move(password), std::move(keyPayload), std::move(keyPayloadSignature), std::move(contentPrekey), std::move(contentPrekeySignature), std::move(notifPrekey), std::move(notifPrekeySignature), std::move(contentOneTimeKeys), std::move(notifOneTimeKeys), std::move(farcasterID)); } + jsi::Value registerReservedPasswordUser(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, jsi::String keyserverMessage, jsi::String keyserverSignature) override { + static_assert( + bridging::getParameterCount(&T::registerReservedPasswordUser) == 13, + "Expected registerReservedPasswordUser(...) to have 13 parameters"); + + return bridging::callFromJs( + rt, &T::registerReservedPasswordUser, jsInvoker_, instance_, std::move(username), std::move(password), std::move(keyPayload), std::move(keyPayloadSignature), std::move(contentPrekey), std::move(contentPrekeySignature), std::move(notifPrekey), std::move(notifPrekeySignature), std::move(contentOneTimeKeys), std::move(notifOneTimeKeys), std::move(keyserverMessage), std::move(keyserverSignature)); + } 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) override { static_assert( bridging::getParameterCount(&T::logInPasswordUser) == 9, @@ -97,6 +107,14 @@ return bridging::callFromJs( rt, &T::registerWalletUser, jsInvoker_, instance_, std::move(siweMessage), std::move(siweSignature), std::move(keyPayload), std::move(keyPayloadSignature), std::move(contentPrekey), std::move(contentPrekeySignature), std::move(notifPrekey), std::move(notifPrekeySignature), std::move(contentOneTimeKeys), std::move(notifOneTimeKeys), std::move(farcasterID)); } + jsi::Value registerReservedWalletUser(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 keyserverMessage, jsi::String keyserverSignature) override { + static_assert( + bridging::getParameterCount(&T::registerReservedWalletUser) == 13, + "Expected registerReservedWalletUser(...) to have 13 parameters"); + + return bridging::callFromJs( + rt, &T::registerReservedWalletUser, jsInvoker_, instance_, std::move(siweMessage), std::move(siweSignature), std::move(keyPayload), std::move(keyPayloadSignature), std::move(contentPrekey), std::move(contentPrekeySignature), std::move(notifPrekey), std::move(notifPrekeySignature), std::move(contentOneTimeKeys), std::move(notifOneTimeKeys), std::move(keyserverMessage), std::move(keyserverSignature)); + } 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) override { static_assert( bridging::getParameterCount(&T::logInWalletUser) == 9, diff --git a/native/schema/CommRustModuleSchema.js b/native/schema/CommRustModuleSchema.js --- a/native/schema/CommRustModuleSchema.js +++ b/native/schema/CommRustModuleSchema.js @@ -20,6 +20,20 @@ notifOneTimeKeys: $ReadOnlyArray, farcasterID: string, ) => Promise; + +registerReservedPasswordUser: ( + username: string, + password: string, + keyPayload: string, + keyPayloadSignature: string, + contentPrekey: string, + contentPrekeySignature: string, + notifPrekey: string, + notifPrekeySignature: string, + contentOneTimeKeys: $ReadOnlyArray, + notifOneTimeKeys: $ReadOnlyArray, + keyserverMessage: string, + keyserverSignature: string, + ) => Promise; +logInPasswordUser: ( username: string, password: string, @@ -43,6 +57,20 @@ notifOneTimeKeys: $ReadOnlyArray, farcasterID: string, ) => Promise; + +registerReservedWalletUser: ( + siweMessage: string, + siweSignature: string, + keyPayload: string, + keyPayloadSignature: string, + contentPrekey: string, + contentPrekeySignature: string, + notifPrekey: string, + notifPrekeySignature: string, + contentOneTimeKeys: $ReadOnlyArray, + notifOneTimeKeys: $ReadOnlyArray, + keyserverMessage: string, + keyserverSignature: string, + ) => Promise; +logInWalletUser: ( siweMessage: string, siweSignature: string,