Page MenuHomePhabricator

D13231.diff
No OneTemporary

D13231.diff

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
@@ -75,6 +75,20 @@
jsi::String contentPrekeySignature,
jsi::String notifPrekey,
jsi::String notifPrekeySignature) override;
+ virtual jsi::Value restoreUser(
+ jsi::Runtime &rt,
+ jsi::String userID,
+ std::optional<jsi::String> siweMessage,
+ std::optional<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 deviceList) override;
virtual jsi::Value updatePassword(
jsi::Runtime &rt,
jsi::String userID,
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
@@ -305,6 +305,71 @@
});
}
+jsi::Value CommRustModule::restoreUser(
+ jsi::Runtime &rt,
+ jsi::String userID,
+ std::optional<jsi::String> siweMessage,
+ std::optional<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 deviceList) {
+ rust::String siweMessageRust = "";
+ if (siweMessage.has_value()) {
+ siweMessageRust = jsiStringToRustString(siweMessage.value(), rt);
+ }
+ rust::String siweSignatureRust = "";
+ if (siweSignature.has_value()) {
+ siweSignatureRust = jsiStringToRustString(siweSignature.value(), rt);
+ }
+ auto userIDRust = jsiStringToRustString(userID, 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 deviceListRust = jsiStringToRustString(deviceList, 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});
+ identityRestoreUser(
+ userIDRust,
+ siweMessageRust,
+ siweSignatureRust,
+ keyPayloadRust,
+ keyPayloadSignatureRust,
+ contentPrekeyRust,
+ contentPrekeySignatureRust,
+ notifPrekeyRust,
+ notifPrekeySignatureRust,
+ contentOneTimeKeysRust,
+ notifOneTimeKeysRust,
+ deviceListRust,
+ currentID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ };
+ if (!error.empty()) {
+ this->jsInvoker_->invokeAsync(
+ [error, promise]() { promise->reject(error); });
+ }
+ });
+}
+
jsi::Value CommRustModule::updatePassword(
jsi::Runtime &rt,
jsi::String userID,
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
@@ -30,6 +30,9 @@
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInWalletUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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));
}
+static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_restoreUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->restoreUser(rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(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].asString(rt), args[9].asObject(rt).asArray(rt), args[10].asObject(rt).asArray(rt), args[11].asString(rt));
+}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_updatePassword(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->updatePassword(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].asString(rt));
}
@@ -108,6 +111,7 @@
methodMap_["logInPasswordUser"] = MethodMetadata {8, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInPasswordUser};
methodMap_["registerWalletUser"] = MethodMetadata {12, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerWalletUser};
methodMap_["logInWalletUser"] = MethodMetadata {8, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInWalletUser};
+ methodMap_["restoreUser"] = MethodMetadata {12, __hostFunction_CommRustModuleSchemaCxxSpecJSI_restoreUser};
methodMap_["updatePassword"] = MethodMetadata {5, __hostFunction_CommRustModuleSchemaCxxSpecJSI_updatePassword};
methodMap_["deletePasswordUser"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_deletePasswordUser};
methodMap_["deleteWalletUser"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_deleteWalletUser};
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
@@ -26,6 +26,7 @@
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, jsi::String initialDeviceList) = 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 restoreUser(jsi::Runtime &rt, jsi::String userID, std::optional<jsi::String> siweMessage, std::optional<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 deviceList) = 0;
virtual jsi::Value updatePassword(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String oldPassword, jsi::String newPassword) = 0;
virtual jsi::Value deletePasswordUser(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String password) = 0;
virtual jsi::Value deleteWalletUser(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) = 0;
@@ -118,6 +119,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::logInWalletUser, 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));
}
+ jsi::Value restoreUser(jsi::Runtime &rt, jsi::String userID, std::optional<jsi::String> siweMessage, std::optional<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 deviceList) override {
+ static_assert(
+ bridging::getParameterCount(&T::restoreUser) == 13,
+ "Expected restoreUser(...) to have 13 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::restoreUser, jsInvoker_, instance_, std::move(userID), 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(deviceList));
+ }
jsi::Value updatePassword(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String oldPassword, jsi::String newPassword) override {
static_assert(
bridging::getParameterCount(&T::updatePassword) == 6,
diff --git a/native/schema/CommRustModuleSchema.js b/native/schema/CommRustModuleSchema.js
--- a/native/schema/CommRustModuleSchema.js
+++ b/native/schema/CommRustModuleSchema.js
@@ -70,6 +70,20 @@
notifPrekey: string,
notifPrekeySignature: string,
) => Promise<string>;
+ +restoreUser: (
+ userID: string,
+ siweMessage: ?string,
+ siweSignature: ?string,
+ keyPayload: string,
+ keyPayloadSignature: string,
+ contentPrekey: string,
+ contentPrekeySignature: string,
+ notifPrekey: string,
+ notifPrekeySignature: string,
+ contentOneTimeKeys: $ReadOnlyArray<string>,
+ notifOneTimeKeys: $ReadOnlyArray<string>,
+ deviceList: string,
+ ) => Promise<string>;
+updatePassword: (
userID: string,
deviceID: string,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 1:01 AM (20 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2598884
Default Alt Text
D13231.diff (10 KB)

Event Timeline