Page MenuHomePhabricator

No OneTemporary

diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
index aacf8d62f..63aa5183a 100644
--- a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
@@ -1,1077 +1,1089 @@
#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();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::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,
jsi::String initialDeviceList) {
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 farcasterIDRust = jsiStringToRustString(farcasterID, rt);
auto initialDeviceListRust = jsiStringToRustString(initialDeviceList, 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});
identityRegisterPasswordUser(
usernameRust,
passwordRust,
keyPayloadRust,
keyPayloadSignatureRust,
contentPrekeyRust,
contentPrekeySignatureRust,
notifPrekeyRust,
notifPrekeySignatureRust,
contentOneTimeKeysRust,
notifOneTimeKeysRust,
farcasterIDRust,
initialDeviceListRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
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,
jsi::String initialDeviceList) {
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);
auto initialDeviceListRust = jsiStringToRustString(initialDeviceList, 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});
identityRegisterReservedPasswordUser(
usernameRust,
passwordRust,
keyPayloadRust,
keyPayloadSignatureRust,
contentPrekeyRust,
contentPrekeySignatureRust,
notifPrekeyRust,
notifPrekeySignatureRust,
contentOneTimeKeysRust,
notifOneTimeKeysRust,
keyserverMessageRust,
keyserverSignatureRust,
initialDeviceListRust,
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,
jsi::String password,
jsi::String keyPayload,
jsi::String keyPayloadSignature,
jsi::String contentPrekey,
jsi::String contentPrekeySignature,
jsi::String notifPrekey,
- jsi::String notifPrekeySignature) {
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) {
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);
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});
identityLogInPasswordUser(
usernameRust,
passwordRust,
keyPayloadRust,
keyPayloadSignatureRust,
contentPrekeyRust,
contentPrekeySignatureRust,
notifPrekeyRust,
notifPrekeySignatureRust,
+ contentOneTimeKeysRust,
+ notifOneTimeKeysRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::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) {
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 farcasterIDRust = jsiStringToRustString(farcasterID, rt);
auto initialDeviceListRust = jsiStringToRustString(initialDeviceList, 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});
identityRegisterWalletUser(
siweMessageRust,
siweSignatureRust,
keyPayloadRust,
keyPayloadSignatureRust,
contentPrekeyRust,
contentPrekeySignatureRust,
notifPrekeyRust,
notifPrekeySignatureRust,
contentOneTimeKeysRust,
notifOneTimeKeysRust,
farcasterIDRust,
initialDeviceListRust,
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,
jsi::String siweSignature,
jsi::String keyPayload,
jsi::String keyPayloadSignature,
jsi::String contentPrekey,
jsi::String contentPrekeySignature,
jsi::String notifPrekey,
- jsi::String notifPrekeySignature) {
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) {
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);
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});
identityLogInWalletUser(
siweMessageRust,
siweSignatureRust,
keyPayloadRust,
keyPayloadSignatureRust,
contentPrekeyRust,
contentPrekeySignatureRust,
notifPrekeyRust,
notifPrekeySignatureRust,
+ contentOneTimeKeysRust,
+ notifOneTimeKeysRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
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,
jsi::String deviceID,
jsi::String accessToken,
jsi::String oldPassword,
jsi::String newPassword) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, rt);
auto oldPasswordRust = jsiStringToRustString(oldPassword, rt);
auto newPasswordRust = jsiStringToRustString(newPassword, 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});
identityUpdateUserPassword(
userIDRust,
deviceIDRust,
accessTokenRust,
oldPasswordRust,
newPasswordRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::deletePasswordUser(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken,
jsi::String password) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, rt);
auto passwordRust = jsiStringToRustString(password, 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});
identityDeletePasswordUser(
userIDRust,
deviceIDRust,
accessTokenRust,
passwordRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::deleteWalletUser(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, 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});
identityDeleteWalletUser(
userIDRust, deviceIDRust, accessTokenRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::logOut(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, 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});
identityLogOut(userIDRust, deviceIDRust, accessTokenRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::logOutPrimaryDevice(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken,
jsi::String signedDeviceList) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, rt);
auto deviceListRust = jsiStringToRustString(signedDeviceList, 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});
identityLogOutPrimaryDevice(
userIDRust,
deviceIDRust,
accessTokenRust,
deviceListRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::logOutSecondaryDevice(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, 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});
identityLogOutSecondaryDevice(
userIDRust, deviceIDRust, accessTokenRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::getOutboundKeysForUser(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String userID) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto userIDRust = jsiStringToRustString(userID, 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});
identityGetOutboundKeysForUser(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
userIDRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::getInboundKeysForUser(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String userID) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto userIDRust = jsiStringToRustString(userID, 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});
identityGetInboundKeysForUser(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
userIDRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::versionSupported(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});
identityVersionSupported(currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::uploadOneTimeKeys(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::Array contentOneTimePreKeys,
jsi::Array notifOneTimePreKeys) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto contentOneTimePreKeysRust =
jsiStringArrayToRustVec(contentOneTimePreKeys, rt);
auto notifOneTimePreKeysRust =
jsiStringArrayToRustVec(notifOneTimePreKeys, 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});
identityUploadOneTimeKeys(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
contentOneTimePreKeysRust,
notifOneTimePreKeysRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::getKeyserverKeys(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String keyserverID) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto keyserverIDRust = jsiStringToRustString(keyserverID, 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});
identityGetKeyserverKeys(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
keyserverIDRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::getDeviceListForUser(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String userID,
std::optional<double> sinceTimestamp) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto userIDRust = jsiStringToRustString(userID, rt);
auto timestampI64 = static_cast<int64_t>(sinceTimestamp.value_or(0));
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});
identityGetDeviceListForUser(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
userIDRust,
timestampI64,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::getDeviceListsForUsers(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::Array userIDs) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto userIDsRust = jsiStringArrayToRustVec(userIDs, 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});
identityGetDeviceListsForUsers(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
userIDsRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::updateDeviceList(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String updatePayload) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto updatePayloadRust = jsiStringToRustString(updatePayload, 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});
identityUpdateDeviceList(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
updatePayloadRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::syncPlatformDetails(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, 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});
identitySyncPlatformDetails(
authUserIDRust, authDeviceIDRust, authAccessTokenRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::uploadSecondaryDeviceKeysAndLogIn(
jsi::Runtime &rt,
jsi::String userID,
jsi::String nonce,
jsi::String nonceSignature,
jsi::String keyPayload,
jsi::String keyPayloadSignature,
jsi::String contentPrekey,
jsi::String contentPrekeySignature,
jsi::String notifPrekey,
jsi::String notifPrekeySignature,
jsi::Array contentOneTimeKeys,
jsi::Array notifOneTimeKeys) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto nonceRust = jsiStringToRustString(nonce, rt);
auto nonceSignatureRust = jsiStringToRustString(nonceSignature, 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);
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});
identityUploadSecondaryDeviceKeysAndLogIn(
userIDRust,
nonceRust,
nonceSignatureRust,
keyPayloadRust,
keyPayloadSignatureRust,
contentPrekeyRust,
contentPrekeySignatureRust,
notifPrekeyRust,
notifPrekeySignatureRust,
contentOneTimeKeysRust,
notifOneTimeKeysRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::logInExistingDevice(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String nonce,
jsi::String nonceSignature) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto nonceRust = jsiStringToRustString(nonce, rt);
auto nonceSignatureRust = jsiStringToRustString(nonceSignature, 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});
identityLogInExistingDevice(
userIDRust,
deviceIDRust,
nonceRust,
nonceSignatureRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::findUserIDForWalletAddress(
jsi::Runtime &rt,
jsi::String walletAddress) {
auto walletAddressRust = jsiStringToRustString(walletAddress, 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});
identityFindUserIDForWalletAddress(walletAddressRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value
CommRustModule::findUserIDForUsername(jsi::Runtime &rt, jsi::String username) {
auto usernameRust = jsiStringToRustString(username, 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});
identityFindUserIDForUsername(usernameRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value
CommRustModule::getFarcasterUsers(jsi::Runtime &rt, jsi::Array farcasterIDs) {
auto farcasterIDsRust = jsiStringArrayToRustVec(farcasterIDs, 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});
identityGetFarcasterUsers(farcasterIDsRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::linkFarcasterAccount(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken,
jsi::String farcasterID) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, rt);
auto farcasterIDRust = jsiStringToRustString(farcasterID, 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});
identityLinkFarcasterAccount(
userIDRust,
deviceIDRust,
accessTokenRust,
farcasterIDRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::unlinkFarcasterAccount(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) {
auto userIDRust = jsiStringToRustString(userID, rt);
auto deviceIDRust = jsiStringToRustString(deviceID, rt);
auto accessTokenRust = jsiStringToRustString(accessToken, 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});
identityUnlinkFarcasterAccount(
userIDRust, deviceIDRust, accessTokenRust, currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
jsi::Value CommRustModule::findUserIdentities(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::Array userIDs) {
auto authUserIDRust = jsiStringToRustString(authUserID, rt);
auto authDeviceIDRust = jsiStringToRustString(authDeviceID, rt);
auto authAccessTokenRust = jsiStringToRustString(authAccessToken, rt);
auto userIDsRust = jsiStringArrayToRustVec(userIDs, 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});
identityFindUserIdentities(
authUserIDRust,
authDeviceIDRust,
authAccessTokenRust,
userIDsRust,
currentID);
} catch (const std::exception &e) {
error = e.what();
};
if (!error.empty()) {
this->jsInvoker_->invokeAsync(
[error, promise]() { promise->reject(error); });
}
});
}
} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.h b/native/cpp/CommonCpp/NativeModules/CommRustModule.h
index 3bc6e20ea..9380d3ad8 100644
--- a/native/cpp/CommonCpp/NativeModules/CommRustModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.h
@@ -1,224 +1,228 @@
#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 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,
jsi::String initialDeviceList) 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,
jsi::String initialDeviceList) 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) override;
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) override;
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) 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) override;
+ jsi::String notifPrekeySignature,
+ jsi::Array contentOneTimeKeys,
+ jsi::Array notifOneTimeKeys) 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,
jsi::String deviceID,
jsi::String accessToken,
jsi::String oldPassword,
jsi::String newPassword) override;
virtual jsi::Value deletePasswordUser(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken,
jsi::String password) override;
virtual jsi::Value deleteWalletUser(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) override;
virtual jsi::Value logOut(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) override;
virtual jsi::Value logOutPrimaryDevice(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken,
jsi::String signedDeviceList) override;
virtual jsi::Value logOutSecondaryDevice(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) override;
virtual jsi::Value getOutboundKeysForUser(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String userID) override;
virtual jsi::Value getInboundKeysForUser(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String userID) override;
virtual jsi::Value versionSupported(jsi::Runtime &rt) override;
virtual jsi::Value uploadOneTimeKeys(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::Array contentOneTimePreKeys,
jsi::Array notifOneTimePreKeys) override;
virtual jsi::Value getKeyserverKeys(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String keyserverID) override;
virtual jsi::Value getDeviceListForUser(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String userID,
std::optional<double> sinceTimestamp) override;
virtual jsi::Value getDeviceListsForUsers(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::Array userIDs) override;
virtual jsi::Value updateDeviceList(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::String updatePayload) override;
virtual jsi::Value syncPlatformDetails(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken) override;
virtual jsi::Value uploadSecondaryDeviceKeysAndLogIn(
jsi::Runtime &rt,
jsi::String userID,
jsi::String nonce,
jsi::String nonceSignature,
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 logInExistingDevice(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String nonce,
jsi::String nonceSignature) override;
virtual jsi::Value findUserIDForWalletAddress(
jsi::Runtime &rt,
jsi::String walletAddress) override;
virtual jsi::Value
findUserIDForUsername(jsi::Runtime &rt, jsi::String username) override;
virtual jsi::Value
getFarcasterUsers(jsi::Runtime &rt, jsi::Array farcasterIDs) override;
virtual jsi::Value linkFarcasterAccount(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken,
jsi::String farcasterID) override;
virtual jsi::Value unlinkFarcasterAccount(
jsi::Runtime &rt,
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) override;
virtual jsi::Value findUserIdentities(
jsi::Runtime &rt,
jsi::String authUserID,
jsi::String authDeviceID,
jsi::String authAccessToken,
jsi::Array userIDs) override;
public:
CommRustModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
index c91966313..c509d7af8 100644
--- a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
@@ -1,142 +1,142 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleH.js
*/
#include "rustJSI.h"
namespace facebook {
namespace react {
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_generateNonce(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->generateNonce(rt);
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerPasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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), args[11].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerReservedPasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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), args[12].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInPasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
- return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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));
+ return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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), args[8].asObject(rt).asArray(rt), args[9].asObject(rt).asArray(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerWalletUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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), 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<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));
+ 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), args[8].asObject(rt).asArray(rt), args[9].asObject(rt).asArray(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));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_deletePasswordUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->deletePasswordUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_deleteWalletUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->deleteWalletUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOut(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->logOut(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOutPrimaryDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->logOutPrimaryDevice(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOutSecondaryDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->logOutSecondaryDevice(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getOutboundKeysForUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getInboundKeysForUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getInboundKeysForUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_versionSupported(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->versionSupported(rt);
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_uploadOneTimeKeys(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->uploadOneTimeKeys(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asObject(rt).asArray(rt), args[4].asObject(rt).asArray(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getKeyserverKeys(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getKeyserverKeys(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getDeviceListForUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getDeviceListForUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt), args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asNumber()));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getDeviceListsForUsers(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getDeviceListsForUsers(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asObject(rt).asArray(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_updateDeviceList(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->updateDeviceList(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_syncPlatformDetails(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->syncPlatformDetails(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_uploadSecondaryDeviceKeysAndLogIn(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->uploadSecondaryDeviceKeysAndLogIn(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].asString(rt), args[9].asObject(rt).asArray(rt), args[10].asObject(rt).asArray(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInExistingDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->logInExistingDevice(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_findUserIDForWalletAddress(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->findUserIDForWalletAddress(rt, args[0].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_findUserIDForUsername(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->findUserIDForUsername(rt, args[0].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getFarcasterUsers(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getFarcasterUsers(rt, args[0].asObject(rt).asArray(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_linkFarcasterAccount(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->linkFarcasterAccount(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_unlinkFarcasterAccount(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->unlinkFarcasterAccount(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_findUserIdentities(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->findUserIdentities(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt), args[3].asObject(rt).asArray(rt));
}
CommRustModuleSchemaCxxSpecJSI::CommRustModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommRustTurboModule", jsInvoker) {
methodMap_["generateNonce"] = MethodMetadata {0, __hostFunction_CommRustModuleSchemaCxxSpecJSI_generateNonce};
methodMap_["registerPasswordUser"] = MethodMetadata {12, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerPasswordUser};
methodMap_["registerReservedPasswordUser"] = MethodMetadata {13, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerReservedPasswordUser};
- methodMap_["logInPasswordUser"] = MethodMetadata {8, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInPasswordUser};
+ methodMap_["logInPasswordUser"] = MethodMetadata {10, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInPasswordUser};
methodMap_["registerWalletUser"] = MethodMetadata {12, __hostFunction_CommRustModuleSchemaCxxSpecJSI_registerWalletUser};
- methodMap_["logInWalletUser"] = MethodMetadata {8, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInWalletUser};
+ methodMap_["logInWalletUser"] = MethodMetadata {10, __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};
methodMap_["logOut"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOut};
methodMap_["logOutPrimaryDevice"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOutPrimaryDevice};
methodMap_["logOutSecondaryDevice"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOutSecondaryDevice};
methodMap_["getOutboundKeysForUser"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUser};
methodMap_["getInboundKeysForUser"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getInboundKeysForUser};
methodMap_["versionSupported"] = MethodMetadata {0, __hostFunction_CommRustModuleSchemaCxxSpecJSI_versionSupported};
methodMap_["uploadOneTimeKeys"] = MethodMetadata {5, __hostFunction_CommRustModuleSchemaCxxSpecJSI_uploadOneTimeKeys};
methodMap_["getKeyserverKeys"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getKeyserverKeys};
methodMap_["getDeviceListForUser"] = MethodMetadata {5, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getDeviceListForUser};
methodMap_["getDeviceListsForUsers"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getDeviceListsForUsers};
methodMap_["updateDeviceList"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_updateDeviceList};
methodMap_["syncPlatformDetails"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_syncPlatformDetails};
methodMap_["uploadSecondaryDeviceKeysAndLogIn"] = MethodMetadata {11, __hostFunction_CommRustModuleSchemaCxxSpecJSI_uploadSecondaryDeviceKeysAndLogIn};
methodMap_["logInExistingDevice"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logInExistingDevice};
methodMap_["findUserIDForWalletAddress"] = MethodMetadata {1, __hostFunction_CommRustModuleSchemaCxxSpecJSI_findUserIDForWalletAddress};
methodMap_["findUserIDForUsername"] = MethodMetadata {1, __hostFunction_CommRustModuleSchemaCxxSpecJSI_findUserIDForUsername};
methodMap_["getFarcasterUsers"] = MethodMetadata {1, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getFarcasterUsers};
methodMap_["linkFarcasterAccount"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_linkFarcasterAccount};
methodMap_["unlinkFarcasterAccount"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_unlinkFarcasterAccount};
methodMap_["findUserIdentities"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_findUserIdentities};
}
} // namespace react
} // namespace facebook
diff --git a/native/cpp/CommonCpp/_generated/rustJSI.h b/native/cpp/CommonCpp/_generated/rustJSI.h
index d3b89e252..117220842 100644
--- a/native/cpp/CommonCpp/_generated/rustJSI.h
+++ b/native/cpp/CommonCpp/_generated/rustJSI.h
@@ -1,323 +1,323 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleH.js
*/
#pragma once
#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>
namespace facebook {
namespace react {
class JSI_EXPORT CommRustModuleSchemaCxxSpecJSI : public TurboModule {
protected:
CommRustModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
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, jsi::String initialDeviceList) = 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, jsi::String initialDeviceList) = 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 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) = 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 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) = 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;
virtual jsi::Value logOut(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) = 0;
virtual jsi::Value logOutPrimaryDevice(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String signedDeviceList) = 0;
virtual jsi::Value logOutSecondaryDevice(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) = 0;
virtual jsi::Value getOutboundKeysForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID) = 0;
virtual jsi::Value getInboundKeysForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID) = 0;
virtual jsi::Value versionSupported(jsi::Runtime &rt) = 0;
virtual jsi::Value uploadOneTimeKeys(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::Array contentOneTimePreKeys, jsi::Array notifOneTimePreKeys) = 0;
virtual jsi::Value getKeyserverKeys(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String keyserverID) = 0;
virtual jsi::Value getDeviceListForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID, std::optional<double> sinceTimestamp) = 0;
virtual jsi::Value getDeviceListsForUsers(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::Array userIDs) = 0;
virtual jsi::Value updateDeviceList(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String updatePayload) = 0;
virtual jsi::Value syncPlatformDetails(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken) = 0;
virtual jsi::Value uploadSecondaryDeviceKeysAndLogIn(jsi::Runtime &rt, jsi::String userID, jsi::String nonce, jsi::String nonceSignature, jsi::String keyPayload, jsi::String keyPayloadSignature, jsi::String contentPrekey, jsi::String contentPrekeySignature, jsi::String notifPrekey, jsi::String notifPrekeySignature, jsi::Array contentOneTimeKeys, jsi::Array notifOneTimeKeys) = 0;
virtual jsi::Value logInExistingDevice(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String nonce, jsi::String nonceSignature) = 0;
virtual jsi::Value findUserIDForWalletAddress(jsi::Runtime &rt, jsi::String walletAddress) = 0;
virtual jsi::Value findUserIDForUsername(jsi::Runtime &rt, jsi::String username) = 0;
virtual jsi::Value getFarcasterUsers(jsi::Runtime &rt, jsi::Array farcasterIDs) = 0;
virtual jsi::Value linkFarcasterAccount(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String farcasterID) = 0;
virtual jsi::Value unlinkFarcasterAccount(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) = 0;
virtual jsi::Value findUserIdentities(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::Array userIDs) = 0;
};
template <typename T>
class JSI_EXPORT CommRustModuleSchemaCxxSpec : public TurboModule {
public:
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
return delegate_.get(rt, propName);
}
protected:
CommRustModuleSchemaCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommRustTurboModule", jsInvoker),
delegate_(static_cast<T*>(this), jsInvoker) {}
private:
class Delegate : public CommRustModuleSchemaCxxSpecJSI {
public:
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
CommRustModuleSchemaCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {}
jsi::Value generateNonce(jsi::Runtime &rt) override {
static_assert(
bridging::getParameterCount(&T::generateNonce) == 1,
"Expected generateNonce(...) to have 1 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::generateNonce, jsInvoker_, instance_);
}
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, jsi::String initialDeviceList) override {
static_assert(
bridging::getParameterCount(&T::registerPasswordUser) == 13,
"Expected registerPasswordUser(...) to have 13 parameters");
return bridging::callFromJs<jsi::Value>(
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), std::move(initialDeviceList));
}
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, jsi::String initialDeviceList) override {
static_assert(
bridging::getParameterCount(&T::registerReservedPasswordUser) == 14,
"Expected registerReservedPasswordUser(...) to have 14 parameters");
return bridging::callFromJs<jsi::Value>(
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), std::move(initialDeviceList));
}
- 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 {
+ 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 {
static_assert(
- bridging::getParameterCount(&T::logInPasswordUser) == 9,
- "Expected logInPasswordUser(...) to have 9 parameters");
+ bridging::getParameterCount(&T::logInPasswordUser) == 11,
+ "Expected logInPasswordUser(...) to have 11 parameters");
return bridging::callFromJs<jsi::Value>(
- rt, &T::logInPasswordUser, 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));
+ rt, &T::logInPasswordUser, 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));
}
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) override {
static_assert(
bridging::getParameterCount(&T::registerWalletUser) == 13,
"Expected registerWalletUser(...) to have 13 parameters");
return bridging::callFromJs<jsi::Value>(
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), std::move(initialDeviceList));
}
- 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 {
+ 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) override {
static_assert(
- bridging::getParameterCount(&T::logInWalletUser) == 9,
- "Expected logInWalletUser(...) to have 9 parameters");
+ bridging::getParameterCount(&T::logInWalletUser) == 11,
+ "Expected logInWalletUser(...) to have 11 parameters");
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));
+ 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), std::move(contentOneTimeKeys), std::move(notifOneTimeKeys));
}
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,
"Expected updatePassword(...) to have 6 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::updatePassword, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken), std::move(oldPassword), std::move(newPassword));
}
jsi::Value deletePasswordUser(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String password) override {
static_assert(
bridging::getParameterCount(&T::deletePasswordUser) == 5,
"Expected deletePasswordUser(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::deletePasswordUser, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken), std::move(password));
}
jsi::Value deleteWalletUser(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) override {
static_assert(
bridging::getParameterCount(&T::deleteWalletUser) == 4,
"Expected deleteWalletUser(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::deleteWalletUser, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken));
}
jsi::Value logOut(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) override {
static_assert(
bridging::getParameterCount(&T::logOut) == 4,
"Expected logOut(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::logOut, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken));
}
jsi::Value logOutPrimaryDevice(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String signedDeviceList) override {
static_assert(
bridging::getParameterCount(&T::logOutPrimaryDevice) == 5,
"Expected logOutPrimaryDevice(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::logOutPrimaryDevice, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken), std::move(signedDeviceList));
}
jsi::Value logOutSecondaryDevice(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) override {
static_assert(
bridging::getParameterCount(&T::logOutSecondaryDevice) == 4,
"Expected logOutSecondaryDevice(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::logOutSecondaryDevice, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken));
}
jsi::Value getOutboundKeysForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID) override {
static_assert(
bridging::getParameterCount(&T::getOutboundKeysForUser) == 5,
"Expected getOutboundKeysForUser(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::getOutboundKeysForUser, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userID));
}
jsi::Value getInboundKeysForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID) override {
static_assert(
bridging::getParameterCount(&T::getInboundKeysForUser) == 5,
"Expected getInboundKeysForUser(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::getInboundKeysForUser, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userID));
}
jsi::Value versionSupported(jsi::Runtime &rt) override {
static_assert(
bridging::getParameterCount(&T::versionSupported) == 1,
"Expected versionSupported(...) to have 1 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::versionSupported, jsInvoker_, instance_);
}
jsi::Value uploadOneTimeKeys(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::Array contentOneTimePreKeys, jsi::Array notifOneTimePreKeys) override {
static_assert(
bridging::getParameterCount(&T::uploadOneTimeKeys) == 6,
"Expected uploadOneTimeKeys(...) to have 6 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::uploadOneTimeKeys, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(contentOneTimePreKeys), std::move(notifOneTimePreKeys));
}
jsi::Value getKeyserverKeys(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String keyserverID) override {
static_assert(
bridging::getParameterCount(&T::getKeyserverKeys) == 5,
"Expected getKeyserverKeys(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::getKeyserverKeys, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(keyserverID));
}
jsi::Value getDeviceListForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID, std::optional<double> sinceTimestamp) override {
static_assert(
bridging::getParameterCount(&T::getDeviceListForUser) == 6,
"Expected getDeviceListForUser(...) to have 6 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::getDeviceListForUser, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userID), std::move(sinceTimestamp));
}
jsi::Value getDeviceListsForUsers(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::Array userIDs) override {
static_assert(
bridging::getParameterCount(&T::getDeviceListsForUsers) == 5,
"Expected getDeviceListsForUsers(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::getDeviceListsForUsers, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userIDs));
}
jsi::Value updateDeviceList(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String updatePayload) override {
static_assert(
bridging::getParameterCount(&T::updateDeviceList) == 5,
"Expected updateDeviceList(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::updateDeviceList, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(updatePayload));
}
jsi::Value syncPlatformDetails(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken) override {
static_assert(
bridging::getParameterCount(&T::syncPlatformDetails) == 4,
"Expected syncPlatformDetails(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::syncPlatformDetails, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken));
}
jsi::Value uploadSecondaryDeviceKeysAndLogIn(jsi::Runtime &rt, jsi::String userID, jsi::String nonce, jsi::String nonceSignature, 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 {
static_assert(
bridging::getParameterCount(&T::uploadSecondaryDeviceKeysAndLogIn) == 12,
"Expected uploadSecondaryDeviceKeysAndLogIn(...) to have 12 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::uploadSecondaryDeviceKeysAndLogIn, jsInvoker_, instance_, std::move(userID), std::move(nonce), std::move(nonceSignature), std::move(keyPayload), std::move(keyPayloadSignature), std::move(contentPrekey), std::move(contentPrekeySignature), std::move(notifPrekey), std::move(notifPrekeySignature), std::move(contentOneTimeKeys), std::move(notifOneTimeKeys));
}
jsi::Value logInExistingDevice(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String nonce, jsi::String nonceSignature) override {
static_assert(
bridging::getParameterCount(&T::logInExistingDevice) == 5,
"Expected logInExistingDevice(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::logInExistingDevice, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(nonce), std::move(nonceSignature));
}
jsi::Value findUserIDForWalletAddress(jsi::Runtime &rt, jsi::String walletAddress) override {
static_assert(
bridging::getParameterCount(&T::findUserIDForWalletAddress) == 2,
"Expected findUserIDForWalletAddress(...) to have 2 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::findUserIDForWalletAddress, jsInvoker_, instance_, std::move(walletAddress));
}
jsi::Value findUserIDForUsername(jsi::Runtime &rt, jsi::String username) override {
static_assert(
bridging::getParameterCount(&T::findUserIDForUsername) == 2,
"Expected findUserIDForUsername(...) to have 2 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::findUserIDForUsername, jsInvoker_, instance_, std::move(username));
}
jsi::Value getFarcasterUsers(jsi::Runtime &rt, jsi::Array farcasterIDs) override {
static_assert(
bridging::getParameterCount(&T::getFarcasterUsers) == 2,
"Expected getFarcasterUsers(...) to have 2 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::getFarcasterUsers, jsInvoker_, instance_, std::move(farcasterIDs));
}
jsi::Value linkFarcasterAccount(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String farcasterID) override {
static_assert(
bridging::getParameterCount(&T::linkFarcasterAccount) == 5,
"Expected linkFarcasterAccount(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::linkFarcasterAccount, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken), std::move(farcasterID));
}
jsi::Value unlinkFarcasterAccount(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) override {
static_assert(
bridging::getParameterCount(&T::unlinkFarcasterAccount) == 4,
"Expected unlinkFarcasterAccount(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::unlinkFarcasterAccount, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken));
}
jsi::Value findUserIdentities(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::Array userIDs) override {
static_assert(
bridging::getParameterCount(&T::findUserIdentities) == 5,
"Expected findUserIdentities(...) to have 5 parameters");
return bridging::callFromJs<jsi::Value>(
rt, &T::findUserIdentities, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userIDs));
}
private:
T *instance_;
};
Delegate delegate_;
};
} // namespace react
} // namespace facebook
diff --git a/native/identity-service/identity-service-context-provider.react.js b/native/identity-service/identity-service-context-provider.react.js
index 6d580cb8e..69af6f589 100644
--- a/native/identity-service/identity-service-context-provider.react.js
+++ b/native/identity-service/identity-service-context-provider.react.js
@@ -1,746 +1,758 @@
// @flow
import * as React from 'react';
import { getOneTimeKeyValues } from 'lib/shared/crypto-utils.js';
import { createAndSignSingletonDeviceList } from 'lib/shared/device-list-utils.js';
import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import {
type IdentityKeysBlob,
identityKeysBlobValidator,
type OneTimeKeysResultValues,
} from 'lib/types/crypto-types.js';
import {
type DeviceOlmInboundKeys,
deviceOlmInboundKeysValidator,
type DeviceOlmOutboundKeys,
deviceOlmOutboundKeysValidator,
farcasterUsersValidator,
identityAuthResultValidator,
type IdentityServiceClient,
ONE_TIME_KEYS_NUMBER,
type SignedDeviceList,
signedDeviceListHistoryValidator,
type SignedNonce,
type UserAuthMetadata,
userDeviceOlmInboundKeysValidator,
type UserDevicesOlmInboundKeys,
type UserDevicesOlmOutboundKeys,
type UsersSignedDeviceLists,
userIdentitiesResponseValidator,
type UsersDevicesPlatformDetails,
peersDeviceListsValidator,
} from 'lib/types/identity-service-types.js';
import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
import { assertWithValidator } from 'lib/utils/validation-utils.js';
import { getCommServicesAuthMetadataEmitter } from '../event-emitters/csa-auth-metadata-emitter.js';
import { commCoreModule, commRustModule } from '../native-modules.js';
import { useSelector } from '../redux/redux-utils.js';
type Props = {
+children: React.Node,
};
function IdentityServiceContextProvider(props: Props): React.Node {
const { children } = props;
const userIDPromiseRef = React.useRef<?Promise<?string>>();
if (!userIDPromiseRef.current) {
userIDPromiseRef.current = (async () => {
const { userID } = await commCoreModule.getCommServicesAuthMetadata();
return userID;
})();
}
React.useEffect(() => {
const metadataEmitter = getCommServicesAuthMetadataEmitter();
const subscription = metadataEmitter.addListener(
'commServicesAuthMetadata',
(authMetadata: UserAuthMetadata) => {
userIDPromiseRef.current = Promise.resolve(authMetadata.userID);
},
);
return () => subscription.remove();
}, []);
const accessToken = useSelector(state => state.commServicesAccessToken);
const getAuthMetadata = React.useCallback<
() => Promise<{
+deviceID: string,
+userID: string,
+accessToken: string,
}>,
>(async () => {
const deviceID = await getContentSigningKey();
const userID = await userIDPromiseRef.current;
if (!deviceID || !userID || !accessToken) {
throw new Error('Identity service client is not initialized');
}
return { deviceID, userID, accessToken };
}, [accessToken]);
const processAuthResult = async (authResult: string, deviceID: string) => {
const { userID, accessToken: token, username } = JSON.parse(authResult);
const identityAuthResult = {
accessToken: token,
userID,
username,
};
const validatedResult = assertWithValidator(
identityAuthResult,
identityAuthResultValidator,
);
await commCoreModule.setCommServicesAuthMetadata(
validatedResult.userID,
deviceID,
validatedResult.accessToken,
);
return validatedResult;
};
const client = React.useMemo<IdentityServiceClient>(
() => ({
deleteWalletUser: async () => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.deleteWalletUser(userID, deviceID, token);
},
deletePasswordUser: async (password: string) => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.deletePasswordUser(
userID,
deviceID,
token,
password,
);
},
logOut: async () => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.logOut(userID, deviceID, token);
},
logOutPrimaryDevice: async () => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
const signedDeviceList =
await createAndSignSingletonDeviceList(deviceID);
return commRustModule.logOutPrimaryDevice(
userID,
deviceID,
token,
JSON.stringify(signedDeviceList),
);
},
logOutSecondaryDevice: async () => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.logOutSecondaryDevice(userID, deviceID, token);
},
getKeyserverKeys: async (
keyserverID: string,
): Promise<DeviceOlmOutboundKeys> => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
const result = await commRustModule.getKeyserverKeys(
userID,
deviceID,
token,
keyserverID,
);
const resultObject = JSON.parse(result);
const payload = resultObject?.payload;
const keyserverKeys = {
identityKeysBlob: payload ? JSON.parse(payload) : null,
contentInitializationInfo: {
prekey: resultObject?.contentPrekey,
prekeySignature: resultObject?.contentPrekeySignature,
oneTimeKey: resultObject?.oneTimeContentPrekey,
},
notifInitializationInfo: {
prekey: resultObject?.notifPrekey,
prekeySignature: resultObject?.notifPrekeySignature,
oneTimeKey: resultObject?.oneTimeNotifPrekey,
},
payloadSignature: resultObject?.payloadSignature,
};
return assertWithValidator(
keyserverKeys,
deviceOlmOutboundKeysValidator,
);
},
getOutboundKeysForUser: async (
targetUserID: string,
): Promise<UserDevicesOlmOutboundKeys[]> => {
const {
deviceID: authDeviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
const result = await commRustModule.getOutboundKeysForUser(
userID,
authDeviceID,
token,
targetUserID,
);
const resultArray = JSON.parse(result);
return resultArray
.map(outboundKeysInfo => {
try {
const payload = outboundKeysInfo?.payload;
const identityKeysBlob: IdentityKeysBlob = assertWithValidator(
payload ? JSON.parse(payload) : null,
identityKeysBlobValidator,
);
const deviceID =
identityKeysBlob.primaryIdentityPublicKeys.ed25519;
const deviceKeys = {
identityKeysBlob,
contentInitializationInfo: {
prekey: outboundKeysInfo?.contentPrekey,
prekeySignature: outboundKeysInfo?.contentPrekeySignature,
oneTimeKey: outboundKeysInfo?.oneTimeContentPrekey,
},
notifInitializationInfo: {
prekey: outboundKeysInfo?.notifPrekey,
prekeySignature: outboundKeysInfo?.notifPrekeySignature,
oneTimeKey: outboundKeysInfo?.oneTimeNotifPrekey,
},
payloadSignature: outboundKeysInfo?.payloadSignature,
};
try {
const validatedKeys = assertWithValidator(
deviceKeys,
deviceOlmOutboundKeysValidator,
);
return {
deviceID,
keys: validatedKeys,
};
} catch (e) {
console.log(e);
return {
deviceID,
keys: null,
};
}
} catch (e) {
console.log(e);
return null;
}
})
.filter(Boolean);
},
getInboundKeysForUser: async (
targetUserID: string,
): Promise<UserDevicesOlmInboundKeys> => {
const {
deviceID: authDeviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
const result = await commRustModule.getInboundKeysForUser(
userID,
authDeviceID,
token,
targetUserID,
);
const resultArray = JSON.parse(result);
const devicesKeys: {
[deviceID: string]: ?DeviceOlmInboundKeys,
} = {};
resultArray.forEach(inboundKeysInfo => {
try {
const payload = inboundKeysInfo?.payload;
const identityKeysBlob: IdentityKeysBlob = assertWithValidator(
payload ? JSON.parse(payload) : null,
identityKeysBlobValidator,
);
const deviceID = identityKeysBlob.primaryIdentityPublicKeys.ed25519;
const deviceKeys = {
identityKeysBlob,
signedPrekeys: {
contentPrekey: inboundKeysInfo?.contentPrekey,
contentPrekeySignature: inboundKeysInfo?.contentPrekeySignature,
notifPrekey: inboundKeysInfo?.notifPrekey,
notifPrekeySignature: inboundKeysInfo?.notifPrekeySignature,
},
payloadSignature: inboundKeysInfo?.payloadSignature,
};
try {
devicesKeys[deviceID] = assertWithValidator(
deviceKeys,
deviceOlmInboundKeysValidator,
);
} catch (e) {
console.log(e);
devicesKeys[deviceID] = null;
}
} catch (e) {
console.log(e);
}
});
const device = resultArray?.[0];
const inboundUserKeys = {
keys: devicesKeys,
username: device?.username,
walletAddress: device?.walletAddress,
};
return assertWithValidator(
inboundUserKeys,
userDeviceOlmInboundKeysValidator,
);
},
uploadOneTimeKeys: async (oneTimeKeys: OneTimeKeysResultValues) => {
const {
deviceID: authDeviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
await commRustModule.uploadOneTimeKeys(
userID,
authDeviceID,
token,
oneTimeKeys.contentOneTimeKeys,
oneTimeKeys.notificationsOneTimeKeys,
);
},
registerPasswordUser: async (
username: string,
password: string,
fid: ?string,
) => {
await commCoreModule.initializeCryptoAccount();
const [
{ blobPayload, signature, primaryIdentityPublicKeys },
{ contentOneTimeKeys, notificationsOneTimeKeys },
prekeys,
] = await Promise.all([
commCoreModule.getUserPublicKey(),
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
const initialDeviceList = await createAndSignSingletonDeviceList(
primaryIdentityPublicKeys.ed25519,
);
const registrationResult = await commRustModule.registerPasswordUser(
username,
password,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
fid ?? '',
JSON.stringify(initialDeviceList),
);
return await processAuthResult(
registrationResult,
primaryIdentityPublicKeys.ed25519,
);
},
registerReservedPasswordUser: async (
username: string,
password: string,
keyserverMessage: string,
keyserverSignature: string,
) => {
await commCoreModule.initializeCryptoAccount();
const [
{ blobPayload, signature, primaryIdentityPublicKeys },
{ contentOneTimeKeys, notificationsOneTimeKeys },
prekeys,
] = await Promise.all([
commCoreModule.getUserPublicKey(),
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
const initialDeviceList = await createAndSignSingletonDeviceList(
primaryIdentityPublicKeys.ed25519,
);
const registrationResult =
await commRustModule.registerReservedPasswordUser(
username,
password,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
keyserverMessage,
keyserverSignature,
JSON.stringify(initialDeviceList),
);
return await processAuthResult(
registrationResult,
primaryIdentityPublicKeys.ed25519,
);
},
logInPasswordUser: async (username: string, password: string) => {
await commCoreModule.initializeCryptoAccount();
- const [{ blobPayload, signature, primaryIdentityPublicKeys }, prekeys] =
- await Promise.all([
- commCoreModule.getUserPublicKey(),
- commCoreModule.validateAndGetPrekeys(),
- ]);
+ const [
+ { blobPayload, signature, primaryIdentityPublicKeys },
+ { contentOneTimeKeys, notificationsOneTimeKeys },
+ prekeys,
+ ] = await Promise.all([
+ commCoreModule.getUserPublicKey(),
+ commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
+ commCoreModule.validateAndGetPrekeys(),
+ ]);
const loginResult = await commRustModule.logInPasswordUser(
username,
password,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
+ getOneTimeKeyValues(contentOneTimeKeys),
+ getOneTimeKeyValues(notificationsOneTimeKeys),
);
return await processAuthResult(
loginResult,
primaryIdentityPublicKeys.ed25519,
);
},
registerWalletUser: async (
walletAddress: string,
siweMessage: string,
siweSignature: string,
fid: ?string,
) => {
await commCoreModule.initializeCryptoAccount();
const [
{ blobPayload, signature, primaryIdentityPublicKeys },
{ contentOneTimeKeys, notificationsOneTimeKeys },
prekeys,
] = await Promise.all([
commCoreModule.getUserPublicKey(),
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
const initialDeviceList = await createAndSignSingletonDeviceList(
primaryIdentityPublicKeys.ed25519,
);
const registrationResult = await commRustModule.registerWalletUser(
siweMessage,
siweSignature,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
fid ?? '',
JSON.stringify(initialDeviceList),
);
return await processAuthResult(
registrationResult,
primaryIdentityPublicKeys.ed25519,
);
},
logInWalletUser: async (
walletAddress: string,
siweMessage: string,
siweSignature: string,
) => {
await commCoreModule.initializeCryptoAccount();
- const [{ blobPayload, signature, primaryIdentityPublicKeys }, prekeys] =
- await Promise.all([
- commCoreModule.getUserPublicKey(),
- commCoreModule.validateAndGetPrekeys(),
- ]);
+ const [
+ { blobPayload, signature, primaryIdentityPublicKeys },
+ { contentOneTimeKeys, notificationsOneTimeKeys },
+ prekeys,
+ ] = await Promise.all([
+ commCoreModule.getUserPublicKey(),
+ commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
+ commCoreModule.validateAndGetPrekeys(),
+ ]);
const loginResult = await commRustModule.logInWalletUser(
siweMessage,
siweSignature,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
+ getOneTimeKeyValues(contentOneTimeKeys),
+ getOneTimeKeyValues(notificationsOneTimeKeys),
);
return await processAuthResult(
loginResult,
primaryIdentityPublicKeys.ed25519,
);
},
restoreUser: async (
userID: string,
deviceList: SignedDeviceList,
siweMessage?: string,
siweSignature?: string,
) => {
await commCoreModule.initializeCryptoAccount();
const [
{ blobPayload, signature, primaryIdentityPublicKeys },
{ contentOneTimeKeys, notificationsOneTimeKeys },
prekeys,
] = await Promise.all([
commCoreModule.getUserPublicKey(),
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
const restoreResult = await commRustModule.restoreUser(
userID,
siweMessage,
siweSignature,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
JSON.stringify(deviceList),
);
return await processAuthResult(
restoreResult,
primaryIdentityPublicKeys.ed25519,
);
},
uploadKeysForRegisteredDeviceAndLogIn: async (
userID: string,
nonceChallengeResponse: SignedNonce,
) => {
await commCoreModule.initializeCryptoAccount();
const [
{ blobPayload, signature, primaryIdentityPublicKeys },
{ contentOneTimeKeys, notificationsOneTimeKeys },
prekeys,
] = await Promise.all([
commCoreModule.getUserPublicKey(),
commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER),
commCoreModule.validateAndGetPrekeys(),
]);
const { nonce, nonceSignature } = nonceChallengeResponse;
const registrationResult =
await commRustModule.uploadSecondaryDeviceKeysAndLogIn(
userID,
nonce,
nonceSignature,
blobPayload,
signature,
prekeys.contentPrekey,
prekeys.contentPrekeySignature,
prekeys.notifPrekey,
prekeys.notifPrekeySignature,
getOneTimeKeyValues(contentOneTimeKeys),
getOneTimeKeyValues(notificationsOneTimeKeys),
);
return await processAuthResult(
registrationResult,
primaryIdentityPublicKeys.ed25519,
);
},
generateNonce: commRustModule.generateNonce,
getDeviceListHistoryForUser: async (
userID: string,
sinceTimestamp?: number,
) => {
const {
deviceID: authDeviceID,
userID: authUserID,
accessToken: token,
} = await getAuthMetadata();
const result = await commRustModule.getDeviceListForUser(
authUserID,
authDeviceID,
token,
userID,
sinceTimestamp,
);
const rawPayloads: string[] = JSON.parse(result);
const deviceLists: SignedDeviceList[] = rawPayloads.map(payload =>
JSON.parse(payload),
);
return assertWithValidator(
deviceLists,
signedDeviceListHistoryValidator,
);
},
getDeviceListsForUsers: async (userIDs: $ReadOnlyArray<string>) => {
const {
deviceID: authDeviceID,
userID: authUserID,
accessToken: token,
} = await getAuthMetadata();
const result = await commRustModule.getDeviceListsForUsers(
authUserID,
authDeviceID,
token,
userIDs,
);
const rawPayloads: {
+usersDeviceLists: { +[userID: string]: string },
+usersDevicesPlatformDetails: UsersDevicesPlatformDetails,
} = JSON.parse(result);
let usersDeviceLists: UsersSignedDeviceLists = {};
for (const userID in rawPayloads.usersDeviceLists) {
usersDeviceLists = {
...usersDeviceLists,
[userID]: JSON.parse(rawPayloads.usersDeviceLists[userID]),
};
}
const peersDeviceLists = {
usersSignedDeviceLists: usersDeviceLists,
usersDevicesPlatformDetails: rawPayloads.usersDevicesPlatformDetails,
};
return assertWithValidator(peersDeviceLists, peersDeviceListsValidator);
},
updateDeviceList: async (newDeviceList: SignedDeviceList) => {
const {
deviceID: authDeviceID,
userID,
accessToken: authAccessToken,
} = await getAuthMetadata();
const payload = JSON.stringify(newDeviceList);
await commRustModule.updateDeviceList(
userID,
authDeviceID,
authAccessToken,
payload,
);
},
syncPlatformDetails: async () => {
const {
deviceID: authDeviceID,
userID,
accessToken: authAccessToken,
} = await getAuthMetadata();
await commRustModule.syncPlatformDetails(
userID,
authDeviceID,
authAccessToken,
);
},
getFarcasterUsers: async (farcasterIDs: $ReadOnlyArray<string>) => {
const farcasterUsersJSONString =
await commRustModule.getFarcasterUsers(farcasterIDs);
const farcasterUsers = JSON.parse(farcasterUsersJSONString);
return assertWithValidator(farcasterUsers, farcasterUsersValidator);
},
linkFarcasterAccount: async (farcasterID: string) => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.linkFarcasterAccount(
userID,
deviceID,
token,
farcasterID,
);
},
unlinkFarcasterAccount: async () => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.unlinkFarcasterAccount(userID, deviceID, token);
},
findUserIdentities: async (userIDs: $ReadOnlyArray<string>) => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
const result = await commRustModule.findUserIdentities(
userID,
deviceID,
token,
userIDs,
);
return assertWithValidator(
JSON.parse(result),
userIdentitiesResponseValidator,
);
},
versionSupported: () => {
return commRustModule.versionSupported();
},
changePassword: async (oldPassword: string, newPassword: string) => {
const {
deviceID,
userID,
accessToken: token,
} = await getAuthMetadata();
return commRustModule.updatePassword(
userID,
deviceID,
token,
oldPassword,
newPassword,
);
},
}),
[getAuthMetadata],
);
const value = React.useMemo(
() => ({
identityClient: client,
getAuthMetadata,
}),
[client, getAuthMetadata],
);
return (
<IdentityClientContext.Provider value={value}>
{children}
</IdentityClientContext.Provider>
);
}
export default IdentityServiceContextProvider;
diff --git a/native/native_rust_library/src/identity/login.rs b/native/native_rust_library/src/identity/login.rs
index 48afe7374..8d9ac900e 100644
--- a/native/native_rust_library/src/identity/login.rs
+++ b/native/native_rust_library/src/identity/login.rs
@@ -1,336 +1,340 @@
use comm_opaque2::client::Login;
use grpc_clients::identity::{
get_unauthenticated_client,
protos::unauth::{
DeviceKeyUpload, ExistingDeviceLoginRequest, IdentityKeyInfo,
OpaqueLoginFinishRequest, OpaqueLoginStartRequest, Prekey,
RestoreUserRequest, SecondaryDeviceKeysUploadRequest, WalletAuthRequest,
},
};
use tracing::instrument;
use super::{
IdentityAuthResult, LogInPasswordUserInfo, LogInWalletUserInfo,
RestoreUserInfo, PLATFORM_METADATA,
};
use crate::utils::jsi_callbacks::handle_string_result_as_callback;
use crate::{Error, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
#[allow(clippy::too_many_arguments)]
pub mod ffi {
use crate::identity::{
DeviceKeys, LogInPasswordUserInfo, LogInWalletUserInfo,
};
use super::*;
#[instrument]
pub fn log_in_password_user(
username: String,
password: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
promise_id: u32,
) {
RUNTIME.spawn(async move {
let password_user_info = LogInPasswordUserInfo {
username,
password,
device_keys: DeviceKeys {
key_payload,
key_payload_signature,
content_prekey,
content_prekey_signature,
notif_prekey,
notif_prekey_signature,
- content_one_time_keys: Vec::new(),
- notif_one_time_keys: Vec::new(),
+ content_one_time_keys,
+ notif_one_time_keys,
},
};
let result = log_in_password_user_helper(password_user_info).await;
handle_string_result_as_callback(result, promise_id);
});
}
#[instrument]
pub fn log_in_wallet_user(
siwe_message: String,
siwe_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
promise_id: u32,
) {
RUNTIME.spawn(async move {
let wallet_user_info = LogInWalletUserInfo {
siwe_message,
siwe_signature,
device_keys: DeviceKeys {
key_payload,
key_payload_signature,
content_prekey,
content_prekey_signature,
notif_prekey,
notif_prekey_signature,
- content_one_time_keys: Vec::new(),
- notif_one_time_keys: Vec::new(),
+ content_one_time_keys,
+ notif_one_time_keys,
},
};
let result = log_in_wallet_user_helper(wallet_user_info).await;
handle_string_result_as_callback(result, promise_id);
});
}
// Primary device restore
#[instrument]
pub fn restore_user(
user_id: String,
siwe_message: String,
siwe_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
device_list: String,
promise_id: u32,
) {
RUNTIME.spawn(async move {
let siwe_message = Some(siwe_message).filter(|it| !it.is_empty());
let siwe_signature = Some(siwe_signature).filter(|it| !it.is_empty());
let restored_user_info = RestoreUserInfo {
user_id,
siwe_message,
siwe_signature,
device_list,
device_keys: DeviceKeys {
key_payload,
key_payload_signature,
content_prekey,
content_prekey_signature,
notif_prekey,
notif_prekey_signature,
content_one_time_keys,
notif_one_time_keys,
},
};
let result = restore_user_helper(restored_user_info).await;
handle_string_result_as_callback(result, promise_id);
});
}
// QR code device log in
pub fn upload_secondary_device_keys_and_log_in(
user_id: String,
nonce: String,
nonce_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
promise_id: u32,
) {
RUNTIME.spawn(async move {
let device_key_upload = DeviceKeyUpload {
device_key_info: Some(IdentityKeyInfo {
payload: key_payload,
payload_signature: key_payload_signature,
}),
content_upload: Some(Prekey {
prekey: content_prekey,
prekey_signature: content_prekey_signature,
}),
notif_upload: Some(Prekey {
prekey: notif_prekey,
prekey_signature: notif_prekey_signature,
}),
one_time_content_prekeys: content_one_time_keys,
one_time_notif_prekeys: notif_one_time_keys,
device_type: DEVICE_TYPE.into(),
};
let result = upload_secondary_device_keys_and_log_in_helper(
user_id,
nonce,
nonce_signature,
device_key_upload,
)
.await;
handle_string_result_as_callback(result, promise_id);
});
}
pub fn log_in_existing_device(
user_id: String,
device_id: String,
nonce: String,
nonce_signature: String,
promise_id: u32,
) {
RUNTIME.spawn(async move {
let result = log_in_existing_device_helper(
user_id,
device_id,
nonce,
nonce_signature,
)
.await;
handle_string_result_as_callback(result, promise_id);
});
}
}
async fn log_in_password_user_helper(
password_user_info: LogInPasswordUserInfo,
) -> Result<String, Error> {
let mut client_login = Login::new();
let opaque_login_request = client_login
.start(&password_user_info.password)
.map_err(crate::handle_error)?;
let login_start_request = OpaqueLoginStartRequest {
opaque_login_request,
username: password_user_info.username,
device_key_upload: Some(password_user_info.device_keys.into()),
force: None,
};
let mut identity_client =
get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
.await?;
let response = identity_client
.log_in_password_user_start(login_start_request)
.await?;
let login_start_response = response.into_inner();
let opaque_login_upload = client_login
.finish(&login_start_response.opaque_login_response)
.map_err(crate::handle_error)?;
let login_finish_request = OpaqueLoginFinishRequest {
session_id: login_start_response.session_id,
opaque_login_upload,
};
let login_finish_response = identity_client
.log_in_password_user_finish(login_finish_request)
.await?
.into_inner();
let auth_result = IdentityAuthResult::from(login_finish_response);
Ok(serde_json::to_string(&auth_result)?)
}
async fn log_in_wallet_user_helper(
wallet_user_info: LogInWalletUserInfo,
) -> Result<String, Error> {
let login_request = WalletAuthRequest {
siwe_message: wallet_user_info.siwe_message,
siwe_signature: wallet_user_info.siwe_signature,
device_key_upload: Some(wallet_user_info.device_keys.into()),
farcaster_id: None,
initial_device_list: "".to_string(),
};
let mut identity_client =
get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
.await?;
let login_response = identity_client
.log_in_wallet_user(login_request)
.await?
.into_inner();
let auth_result = IdentityAuthResult::from(login_response);
Ok(serde_json::to_string(&auth_result)?)
}
async fn restore_user_helper(
wallet_user_info: RestoreUserInfo,
) -> Result<String, Error> {
let restore_request = RestoreUserRequest {
user_id: wallet_user_info.user_id,
siwe_message: wallet_user_info.siwe_message,
siwe_signature: wallet_user_info.siwe_signature,
device_list: wallet_user_info.device_list,
device_key_upload: Some(wallet_user_info.device_keys.into()),
};
let mut identity_client =
get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
.await?;
let auth_response = identity_client
.restore_user(restore_request)
.await?
.into_inner();
let auth_result = IdentityAuthResult::from(auth_response);
Ok(serde_json::to_string(&auth_result)?)
}
async fn upload_secondary_device_keys_and_log_in_helper(
user_id: String,
nonce: String,
nonce_signature: String,
device_key_upload: DeviceKeyUpload,
) -> Result<String, Error> {
let mut identity_client =
get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
.await?;
let request = SecondaryDeviceKeysUploadRequest {
user_id,
nonce,
nonce_signature,
device_key_upload: Some(device_key_upload),
};
let response = identity_client
.upload_keys_for_registered_device_and_log_in(request)
.await?
.into_inner();
let auth_result = IdentityAuthResult::from(response);
Ok(serde_json::to_string(&auth_result)?)
}
async fn log_in_existing_device_helper(
user_id: String,
device_id: String,
nonce: String,
nonce_signature: String,
) -> Result<String, Error> {
let mut identity_client =
get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
.await?;
let request = ExistingDeviceLoginRequest {
user_id,
device_id,
nonce,
nonce_signature,
};
let response = identity_client
.log_in_existing_device(request)
.await?
.into_inner();
let auth_result = IdentityAuthResult::from(response);
Ok(serde_json::to_string(&auth_result)?)
}
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
index 7abd445d2..8696ee290 100644
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -1,553 +1,557 @@
use comm_opaque2::grpc::opaque_error_to_grpc_status as handle_error;
use grpc_clients::identity::protos::unauth::DeviceType;
use lazy_static::lazy_static;
use std::sync::Arc;
use tokio::runtime::{Builder, Runtime};
use tonic::Status;
mod argon2_tools;
mod backup;
mod constants;
mod identity;
mod utils;
use crate::argon2_tools::compute_backup_key_str;
use crate::utils::jsi_callbacks::{
handle_string_result_as_callback, handle_void_result_as_callback,
};
mod generated {
// We get the CODE_VERSION from this generated file
include!(concat!(env!("OUT_DIR"), "/version.rs"));
// We get the IDENTITY_SOCKET_ADDR from this generated file
include!(concat!(env!("OUT_DIR"), "/socket_config.rs"));
}
pub use generated::CODE_VERSION;
pub use generated::{BACKUP_SOCKET_ADDR, IDENTITY_SOCKET_ADDR};
#[cfg(not(target_os = "android"))]
pub const DEVICE_TYPE: DeviceType = DeviceType::Ios;
#[cfg(target_os = "android")]
pub const DEVICE_TYPE: DeviceType = DeviceType::Android;
lazy_static! {
static ref RUNTIME: Arc<Runtime> =
Arc::new(Builder::new_multi_thread().enable_all().build().unwrap());
}
// ffi uses
use backup::ffi::*;
use identity::ffi::*;
use utils::future_manager::ffi::*;
#[allow(clippy::too_many_arguments)]
#[cxx::bridge]
mod ffi {
// Identity Service APIs
extern "Rust" {
#[cxx_name = "identityRegisterPasswordUser"]
fn register_password_user(
username: String,
password: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
farcaster_id: String,
initial_device_list: String,
promise_id: u32,
);
#[cxx_name = "identityRegisterReservedPasswordUser"]
fn register_reserved_password_user(
username: String,
password: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
keyserver_message: String,
keyserver_signature: String,
initial_device_list: String,
promise_id: u32,
);
#[cxx_name = "identityLogInPasswordUser"]
fn log_in_password_user(
username: String,
password: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
promise_id: u32,
);
#[cxx_name = "identityRegisterWalletUser"]
fn register_wallet_user(
siwe_message: String,
siwe_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
farcaster_id: String,
initial_device_list: String,
promise_id: u32,
);
#[cxx_name = "identityLogInWalletUser"]
fn log_in_wallet_user(
siwe_message: String,
siwe_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
promise_id: u32,
);
#[cxx_name = "identityRestoreUser"]
fn restore_user(
user_id: String,
siwe_message: String,
siwe_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
device_list: String,
promise_id: u32,
);
#[cxx_name = "identityUpdateUserPassword"]
fn update_user_password(
user_id: String,
device_id: String,
access_token: String,
old_password: String,
new_password: String,
promise_id: u32,
);
#[cxx_name = "identityDeleteWalletUser"]
fn delete_wallet_user(
user_id: String,
device_id: String,
access_token: String,
promise_id: u32,
);
#[cxx_name = "identityDeletePasswordUser"]
fn delete_password_user(
user_id: String,
device_id: String,
access_token: String,
password: String,
promise_id: u32,
);
#[cxx_name = "identityLogOut"]
fn log_out(
user_id: String,
device_id: String,
access_token: String,
promise_id: u32,
);
#[cxx_name = "identityLogOutPrimaryDevice"]
fn log_out_primary_device(
user_id: String,
device_id: String,
access_token: String,
signed_device_list: String,
promise_id: u32,
);
#[cxx_name = "identityLogOutSecondaryDevice"]
fn log_out_secondary_device(
user_id: String,
device_id: String,
access_token: String,
promise_id: u32,
);
#[cxx_name = "identityGetOutboundKeysForUser"]
fn get_outbound_keys_for_user(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
user_id: String,
promise_id: u32,
);
#[cxx_name = "identityGetInboundKeysForUser"]
fn get_inbound_keys_for_user(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
user_id: String,
promise_id: u32,
);
#[cxx_name = "identityRefreshUserPrekeys"]
fn refresh_user_prekeys(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
promise_id: u32,
);
#[cxx_name = "identityGenerateNonce"]
fn generate_nonce(promise_id: u32);
#[cxx_name = "identityVersionSupported"]
fn version_supported(promise_id: u32);
#[cxx_name = "identityUploadOneTimeKeys"]
fn upload_one_time_keys(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
promise_id: u32,
);
#[cxx_name = "identityGetKeyserverKeys"]
fn get_keyserver_keys(
user_id: String,
device_id: String,
access_token: String,
keyserver_id: String,
promise_id: u32,
);
#[cxx_name = "identityGetDeviceListForUser"]
fn get_device_list_for_user(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
user_id: String,
since_timestamp: i64,
promise_id: u32,
);
#[cxx_name = "identityGetDeviceListsForUsers"]
fn get_device_lists_for_users(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
user_ids: Vec<String>,
promise_id: u32,
);
#[cxx_name = "identityUpdateDeviceList"]
fn update_device_list(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
update_payload: String,
promise_id: u32,
);
#[cxx_name = "identitySyncPlatformDetails"]
fn sync_platform_details(
auth_user_id: String,
auth_device_id: String,
auth_access_token: String,
promise_id: u32,
);
#[cxx_name = "identityUploadSecondaryDeviceKeysAndLogIn"]
fn upload_secondary_device_keys_and_log_in(
user_id: String,
nonce: String,
nonce_signature: String,
key_payload: String,
key_payload_signature: String,
content_prekey: String,
content_prekey_signature: String,
notif_prekey: String,
notif_prekey_signature: String,
content_one_time_keys: Vec<String>,
notif_one_time_keys: Vec<String>,
promise_id: u32,
);
#[cxx_name = "identityLogInExistingDevice"]
fn log_in_existing_device(
user_id: String,
device_id: String,
nonce: String,
nonce_signature: String,
promise_id: u32,
);
#[cxx_name = "identityFindUserIDForWalletAddress"]
fn find_user_id_for_wallet_address(wallet_address: String, promise_id: u32);
#[cxx_name = "identityFindUserIDForUsername"]
fn find_user_id_for_username(username: String, promise_id: u32);
// Farcaster
#[cxx_name = "identityGetFarcasterUsers"]
fn get_farcaster_users(farcaster_ids: Vec<String>, promise_id: u32);
#[cxx_name = "identityLinkFarcasterAccount"]
fn link_farcaster_account(
user_id: String,
device_id: String,
access_token: String,
farcaster_id: String,
promise_id: u32,
);
#[cxx_name = "identityUnlinkFarcasterAccount"]
fn unlink_farcaster_account(
user_id: String,
device_id: String,
access_token: String,
promise_id: u32,
);
#[cxx_name = "identityFindUserIdentities"]
fn find_user_identities(
user_id: String,
device_id: String,
access_token: String,
user_ids: Vec<String>,
promise_id: u32,
);
// Argon2
#[cxx_name = "compute_backup_key"]
fn compute_backup_key_str(
password: &str,
backup_id: &str,
) -> Result<[u8; 32]>;
}
unsafe extern "C++" {
include!("RustCallback.h");
#[namespace = "comm"]
#[cxx_name = "stringCallback"]
fn string_callback(error: String, promise_id: u32, ret: String);
#[namespace = "comm"]
#[cxx_name = "voidCallback"]
fn void_callback(error: String, promise_id: u32);
#[namespace = "comm"]
#[cxx_name = "boolCallback"]
fn bool_callback(error: String, promise_id: u32, ret: bool);
}
// AES cryptography
#[namespace = "comm"]
unsafe extern "C++" {
include!("RustAESCrypto.h");
#[allow(unused)]
#[cxx_name = "aesGenerateKey"]
fn generate_key(buffer: &mut [u8]) -> Result<()>;
/// The first two argument aren't mutated but creation of Java ByteBuffer
/// requires the underlying bytes to be mutable.
#[allow(unused)]
#[cxx_name = "aesEncrypt"]
fn encrypt(
key: &mut [u8],
plaintext: &mut [u8],
sealed_data: &mut [u8],
) -> Result<()>;
/// The first two argument aren't mutated but creation of Java ByteBuffer
/// requires the underlying bytes to be mutable.
#[allow(unused)]
#[cxx_name = "aesDecrypt"]
fn decrypt(
key: &mut [u8],
sealed_data: &mut [u8],
plaintext: &mut [u8],
) -> Result<()>;
}
// Comm Services Auth Metadata Emission
#[namespace = "comm"]
unsafe extern "C++" {
include!("RustCSAMetadataEmitter.h");
#[allow(unused)]
#[cxx_name = "sendAuthMetadataToJS"]
fn send_auth_metadata_to_js(
access_token: String,
user_id: String,
) -> Result<()>;
}
// Backup
extern "Rust" {
#[cxx_name = "startBackupHandler"]
fn start_backup_handler() -> Result<()>;
#[cxx_name = "stopBackupHandler"]
fn stop_backup_handler() -> Result<()>;
#[cxx_name = "triggerBackupFileUpload"]
fn trigger_backup_file_upload();
#[cxx_name = "createBackup"]
fn create_backup(
backup_id: String,
backup_secret: String,
pickle_key: String,
pickled_account: String,
siwe_backup_msg: String,
promise_id: u32,
);
#[cxx_name = "restoreBackup"]
fn restore_backup(
backup_secret: String,
backup_id: String,
max_version: String,
promise_id: u32,
);
#[cxx_name = "restoreBackupData"]
fn restore_backup_data(
backup_id: String,
backup_data_key: String,
backup_log_data_key: String,
max_version: String,
promise_id: u32,
);
#[cxx_name = "retrieveBackupKeys"]
fn retrieve_backup_keys(backup_secret: String, promise_id: u32);
#[cxx_name = "retrieveLatestSIWEBackupData"]
fn retrieve_latest_siwe_backup_data(promise_id: u32);
}
// Secure store
#[namespace = "comm"]
unsafe extern "C++" {
include!("RustSecureStore.h");
#[allow(unused)]
#[cxx_name = "secureStoreSet"]
fn secure_store_set(key: &str, value: String) -> Result<()>;
#[cxx_name = "secureStoreGet"]
fn secure_store_get(key: &str) -> Result<String>;
}
// C++ Backup creation
#[namespace = "comm"]
unsafe extern "C++" {
include!("RustBackupExecutor.h");
#[cxx_name = "getBackupDirectoryPath"]
fn get_backup_directory_path() -> Result<String>;
#[cxx_name = "getBackupFilePath"]
fn get_backup_file_path(
backup_id: &str,
is_attachments: bool,
) -> Result<String>;
#[cxx_name = "getBackupLogFilePath"]
fn get_backup_log_file_path(
backup_id: &str,
log_id: &str,
is_attachments: bool,
) -> Result<String>;
#[cxx_name = "getBackupUserKeysFilePath"]
fn get_backup_user_keys_file_path(backup_id: &str) -> Result<String>;
#[cxx_name = "getSIWEBackupMessagePath"]
fn get_siwe_backup_message_path(backup_id: &str) -> Result<String>;
#[cxx_name = "createMainCompaction"]
fn create_main_compaction(backup_id: &str, future_id: usize);
#[cxx_name = "restoreFromMainCompaction"]
fn restore_from_main_compaction(
main_compaction_path: &str,
main_compaction_encryption_key: &str,
max_version: &str,
future_id: usize,
);
#[cxx_name = "restoreFromBackupLog"]
fn restore_from_backup_log(backup_log: Vec<u8>, future_id: usize);
}
// Future handling from C++
extern "Rust" {
#[cxx_name = "resolveUnitFuture"]
fn resolve_unit_future(future_id: usize);
#[cxx_name = "rejectFuture"]
fn reject_future(future_id: usize, error: String);
}
}
#[derive(
Debug, derive_more::Display, derive_more::From, derive_more::Error,
)]
pub enum Error {
#[display(fmt = "{}", "_0.message()")]
TonicGRPC(Status),
#[display(fmt = "{}", "_0")]
SerdeJson(serde_json::Error),
#[display(fmt = "Missing response data")]
MissingResponseData,
#[display(fmt = "{}", "_0")]
GRPClient(grpc_clients::error::Error),
}
#[cfg(test)]
#[allow(clippy::assertions_on_constants)]
mod tests {
use super::{BACKUP_SOCKET_ADDR, CODE_VERSION, IDENTITY_SOCKET_ADDR};
#[test]
fn test_code_version_exists() {
assert!(CODE_VERSION > 0);
}
#[test]
fn test_identity_socket_addr_exists() {
assert!(!IDENTITY_SOCKET_ADDR.is_empty());
assert!(!BACKUP_SOCKET_ADDR.is_empty());
}
}
diff --git a/native/schema/CommRustModuleSchema.js b/native/schema/CommRustModuleSchema.js
index 024836238..238189434 100644
--- a/native/schema/CommRustModuleSchema.js
+++ b/native/schema/CommRustModuleSchema.js
@@ -1,214 +1,218 @@
// @flow
'use strict';
import { TurboModuleRegistry } from 'react-native';
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport.js';
export interface Spec extends TurboModule {
+generateNonce: () => Promise<string>;
+registerPasswordUser: (
username: string,
password: string,
keyPayload: string,
keyPayloadSignature: string,
contentPrekey: string,
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
contentOneTimeKeys: $ReadOnlyArray<string>,
notifOneTimeKeys: $ReadOnlyArray<string>,
farcasterID: string,
initialDeviceList: string,
) => Promise<string>;
+registerReservedPasswordUser: (
username: string,
password: string,
keyPayload: string,
keyPayloadSignature: string,
contentPrekey: string,
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
contentOneTimeKeys: $ReadOnlyArray<string>,
notifOneTimeKeys: $ReadOnlyArray<string>,
keyserverMessage: string,
keyserverSignature: string,
initialDeviceList: string,
) => Promise<string>;
+logInPasswordUser: (
username: string,
password: string,
keyPayload: string,
keyPayloadSignature: string,
contentPrekey: string,
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
+ contentOneTimeKeys: $ReadOnlyArray<string>,
+ notifOneTimeKeys: $ReadOnlyArray<string>,
) => Promise<string>;
+registerWalletUser: (
siweMessage: string,
siweSignature: string,
keyPayload: string,
keyPayloadSignature: string,
contentPrekey: string,
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
contentOneTimeKeys: $ReadOnlyArray<string>,
notifOneTimeKeys: $ReadOnlyArray<string>,
farcasterID: string,
initialDeviceList: string,
) => Promise<string>;
+logInWalletUser: (
siweMessage: string,
siweSignature: string,
keyPayload: string,
keyPayloadSignature: string,
contentPrekey: string,
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
+ contentOneTimeKeys: $ReadOnlyArray<string>,
+ notifOneTimeKeys: $ReadOnlyArray<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,
accessToken: string,
oldPassword: string,
newPassword: string,
) => Promise<void>;
+deletePasswordUser: (
userID: string,
deviceID: string,
accessToken: string,
password: string,
) => Promise<void>;
+deleteWalletUser: (
userID: string,
deviceID: string,
accessToken: string,
) => Promise<void>;
+logOut: (
userID: string,
deviceID: string,
accessToken: string,
) => Promise<void>;
+logOutPrimaryDevice: (
userID: string,
deviceID: string,
accessToken: string,
signedDeviceList: string,
) => Promise<void>;
+logOutSecondaryDevice: (
userID: string,
deviceID: string,
accessToken: string,
) => Promise<void>;
+getOutboundKeysForUser: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
userID: string,
) => Promise<string>;
+getInboundKeysForUser: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
userID: string,
) => Promise<string>;
+versionSupported: () => Promise<boolean>;
+uploadOneTimeKeys: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
contentOneTimePreKeys: $ReadOnlyArray<string>,
notifOneTimePreKeys: $ReadOnlyArray<string>,
) => Promise<void>;
+getKeyserverKeys: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
keyserverID: string,
) => Promise<string>;
+getDeviceListForUser: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
userID: string,
sinceTimestamp: ?number,
) => Promise<string>;
+getDeviceListsForUsers: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
userIDs: $ReadOnlyArray<string>,
) => Promise<string>;
+updateDeviceList: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
updatePayload: string,
) => Promise<void>;
+syncPlatformDetails: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
) => Promise<void>;
+uploadSecondaryDeviceKeysAndLogIn: (
userID: string,
nonce: string,
nonceSignature: string,
keyPayload: string,
keyPayloadSignature: string,
contentPrekey: string,
contentPrekeySignature: string,
notifPrekey: string,
notifPrekeySignature: string,
contentOneTimeKeys: $ReadOnlyArray<string>,
notifOneTimeKeys: $ReadOnlyArray<string>,
) => Promise<string>;
+logInExistingDevice: (
userID: string,
deviceID: string,
nonce: string,
nonceSignature: string,
) => Promise<string>;
+findUserIDForWalletAddress: (walletAddress: string) => Promise<string>;
+findUserIDForUsername: (username: string) => Promise<string>;
+getFarcasterUsers: (farcasterIDs: $ReadOnlyArray<string>) => Promise<string>;
+linkFarcasterAccount: (
userID: string,
deviceID: string,
accessToken: string,
farcasterID: string,
) => Promise<void>;
+unlinkFarcasterAccount: (
userID: string,
deviceID: string,
accessToken: string,
) => Promise<void>;
+findUserIdentities: (
authUserID: string,
authDeviceID: string,
authAccessToken: string,
userIDs: $ReadOnlyArray<string>,
) => Promise<string>;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(
'CommRustTurboModule',
): Spec);

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 23, 8:49 AM (21 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690665
Default Alt Text
(149 KB)

Event Timeline