Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3385744
D12121.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D12121.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.h b/native/cpp/CommonCpp/NativeModules/CommRustModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommRustModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.h
@@ -112,6 +112,11 @@
jsi::String userID,
jsi::String deviceID,
jsi::String accessToken) 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,
diff --git a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
@@ -486,6 +486,33 @@
});
}
+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,
diff --git a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
@@ -45,6 +45,9 @@
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_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));
}
@@ -107,6 +110,7 @@
methodMap_["deletePasswordUser"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_deletePasswordUser};
methodMap_["deleteWalletUser"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_deleteWalletUser};
methodMap_["logOut"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_logOut};
+ 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};
diff --git a/native/cpp/CommonCpp/_generated/rustJSI.h b/native/cpp/CommonCpp/_generated/rustJSI.h
--- a/native/cpp/CommonCpp/_generated/rustJSI.h
+++ b/native/cpp/CommonCpp/_generated/rustJSI.h
@@ -31,6 +31,7 @@
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 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;
@@ -156,6 +157,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::logOut, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken));
}
+ 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,
diff --git a/native/native_rust_library/src/identity/account_actions.rs b/native/native_rust_library/src/identity/account_actions.rs
--- a/native/native_rust_library/src/identity/account_actions.rs
+++ b/native/native_rust_library/src/identity/account_actions.rs
@@ -79,7 +79,24 @@
user_id,
device_id,
};
- let result = log_out_helper(auth_info).await;
+ let result = log_out_helper(auth_info, LogOutType::Legacy).await;
+ handle_void_result_as_callback(result, promise_id);
+ });
+ }
+
+ pub fn log_out_secondary_device(
+ user_id: String,
+ device_id: String,
+ access_token: String,
+ promise_id: u32,
+ ) {
+ RUNTIME.spawn(async move {
+ let auth_info = AuthInfo {
+ access_token,
+ user_id,
+ device_id,
+ };
+ let result = log_out_helper(auth_info, LogOutType::SecondaryDevice).await;
handle_void_result_as_callback(result, promise_id);
});
}
@@ -196,7 +213,15 @@
Ok(())
}
-async fn log_out_helper(auth_info: AuthInfo) -> Result<(), Error> {
+enum LogOutType {
+ Legacy,
+ SecondaryDevice,
+}
+
+async fn log_out_helper(
+ auth_info: AuthInfo,
+ log_out_type: LogOutType,
+) -> Result<(), Error> {
let mut identity_client = get_auth_client(
IDENTITY_SOCKET_ADDR,
auth_info.user_id,
@@ -206,7 +231,13 @@
DEVICE_TYPE.as_str_name().to_lowercase(),
)
.await?;
- identity_client.log_out_user(Empty {}).await?;
+
+ match log_out_type {
+ LogOutType::Legacy => identity_client.log_out_user(Empty {}).await?,
+ LogOutType::SecondaryDevice => {
+ identity_client.log_out_secondary_device(Empty {}).await?
+ }
+ };
Ok(())
}
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -176,6 +176,14 @@
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,
diff --git a/native/schema/CommRustModuleSchema.js b/native/schema/CommRustModuleSchema.js
--- a/native/schema/CommRustModuleSchema.js
+++ b/native/schema/CommRustModuleSchema.js
@@ -107,6 +107,11 @@
deviceID: string,
accessToken: string,
) => Promise<void>;
+ +logOutSecondaryDevice: (
+ userID: string,
+ deviceID: string,
+ accessToken: string,
+ ) => Promise<void>;
+getOutboundKeysForUser: (
authUserID: string,
authDeviceID: string,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 2:07 AM (19 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599014
Default Alt Text
D12121.diff (8 KB)
Attached To
Mode
D12121: [native] Expose LogOutSecondaryDevice RPC via JSI
Attached
Detach File
Event Timeline
Log In to Comment