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 @@ -60,13 +60,12 @@ jsi::String userID, jsi::String deviceID, jsi::String accessToken) override; - virtual jsi::Value getOutboundKeysForUserDevice( + virtual jsi::Value getOutboundKeysForUser( jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, - jsi::String userID, - jsi::String deviceID) override; + jsi::String userID) override; virtual jsi::Value versionSupported(jsi::Runtime &rt) override; public: 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 @@ -223,25 +223,23 @@ }); } -jsi::Value CommRustModule::getOutboundKeysForUserDevice( +jsi::Value CommRustModule::getOutboundKeysForUser( jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, - jsi::String userID, - jsi::String deviceID) { + jsi::String userID) { return createPromiseAsJSIValue( rt, [&, this](jsi::Runtime &innerRt, std::shared_ptr promise) { std::string error; try { auto currentID = RustPromiseManager::instance.addPromise( promise, this->jsInvoker_, innerRt); - identityGetOutboundKeysForUserDevice( + identityGetOutboundKeysForUser( jsiStringToRustString(authUserID, innerRt), jsiStringToRustString(authDeviceID, innerRt), jsiStringToRustString(authAccessToken, innerRt), jsiStringToRustString(userID, innerRt), - jsiStringToRustString(deviceID, innerRt), currentID); } catch (const std::exception &e) { error = e.what(); diff --git a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp --- a/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp +++ b/native/cpp/CommonCpp/_generated/rustJSI-generated.cpp @@ -30,8 +30,8 @@ static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_deleteUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->deleteUser(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt)); } -static jsi::Value __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUserDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getOutboundKeysForUserDevice(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_getOutboundKeysForUser(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getOutboundKeysForUser(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(&turboModule)->versionSupported(rt); @@ -45,7 +45,7 @@ methodMap_["loginWalletUser"] = MethodMetadata {11, __hostFunction_CommRustModuleSchemaCxxSpecJSI_loginWalletUser}; methodMap_["updatePassword"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_updatePassword}; methodMap_["deleteUser"] = MethodMetadata {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_deleteUser}; - methodMap_["getOutboundKeysForUserDevice"] = MethodMetadata {5, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUserDevice}; + methodMap_["getOutboundKeysForUser"] = MethodMetadata {4, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUser}; 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 @@ -26,7 +26,7 @@ virtual jsi::Value loginWalletUser(jsi::Runtime &rt, jsi::String siweMessage, jsi::String siweSignature, jsi::String keyPayload, jsi::String keyPayloadSignature, jsi::String contentPrekey, jsi::String contentPrekeySignature, jsi::String notifPrekey, jsi::String notifPrekeySignature, jsi::Array contentOneTimeKeys, jsi::Array notifOneTimeKeys, jsi::String socialProof) = 0; virtual jsi::Value updatePassword(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken, jsi::String password) = 0; virtual jsi::Value deleteUser(jsi::Runtime &rt, jsi::String userID, jsi::String deviceID, jsi::String accessToken) = 0; - virtual jsi::Value getOutboundKeysForUserDevice(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID, jsi::String deviceID) = 0; + virtual jsi::Value getOutboundKeysForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID) = 0; virtual jsi::Value versionSupported(jsi::Runtime &rt) = 0; }; @@ -97,13 +97,13 @@ return bridging::callFromJs( rt, &T::deleteUser, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken)); } - jsi::Value getOutboundKeysForUserDevice(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID, jsi::String deviceID) override { + jsi::Value getOutboundKeysForUser(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID) override { static_assert( - bridging::getParameterCount(&T::getOutboundKeysForUserDevice) == 6, - "Expected getOutboundKeysForUserDevice(...) to have 6 parameters"); + bridging::getParameterCount(&T::getOutboundKeysForUser) == 5, + "Expected getOutboundKeysForUser(...) to have 5 parameters"); return bridging::callFromJs( - rt, &T::getOutboundKeysForUserDevice, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userID), std::move(deviceID)); + rt, &T::getOutboundKeysForUser, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userID)); } jsi::Value versionSupported(jsi::Runtime &rt) override { static_assert( 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 @@ -115,13 +115,12 @@ promise_id: u32, ); - #[cxx_name = "identityGetOutboundKeysForUserDevice"] - fn get_outbound_keys_for_user_device( + #[cxx_name = "identityGetOutboundKeysForUser"] + fn get_outbound_keys_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, - device_id: String, promise_id: u32, ); @@ -776,7 +775,6 @@ struct GetOutboundKeysRequestInfo { user_id: String, - device_id: String, } // This struct should not be altered without also updating @@ -841,23 +839,21 @@ } } -fn get_outbound_keys_for_user_device( +fn get_outbound_keys_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, - device_id: String, promise_id: u32, ) { RUNTIME.spawn(async move { - let get_outbound_keys_request_info = - GetOutboundKeysRequestInfo { user_id, device_id }; + let get_outbound_keys_request_info = GetOutboundKeysRequestInfo { user_id }; let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; - let result = get_outbound_keys_for_user_device_helper( + let result = get_outbound_keys_for_user_helper( get_outbound_keys_request_info, auth_info, ) @@ -866,7 +862,7 @@ }); } -async fn get_outbound_keys_for_user_device_helper( +async fn get_outbound_keys_for_user_helper( get_outbound_keys_request_info: GetOutboundKeysRequestInfo, auth_info: AuthInfo, ) -> Result { @@ -879,19 +875,18 @@ DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; - let mut response = identity_client + let response = identity_client .get_outbound_keys_for_user(OutboundKeysForUserRequest { user_id: get_outbound_keys_request_info.user_id, }) .await? .into_inner(); - let outbound_key_info = OutboundKeyInfoResponse::try_from( - response - .devices - .remove(&get_outbound_keys_request_info.device_id) - .ok_or(Error::MissingResponseData)?, - )?; + let outbound_key_info: Vec = response + .devices + .into_values() + .map(OutboundKeyInfoResponse::try_from) + .collect::, _>>()?; Ok(serde_json::to_string(&outbound_key_info)?) } diff --git a/native/schema/CommRustModuleSchema.js b/native/schema/CommRustModuleSchema.js --- a/native/schema/CommRustModuleSchema.js +++ b/native/schema/CommRustModuleSchema.js @@ -55,12 +55,11 @@ deviceID: string, accessToken: string, ) => Promise; - +getOutboundKeysForUserDevice: ( + +getOutboundKeysForUser: ( authUserID: string, authDeviceID: string, authAccessToken: string, userID: string, - deviceID: string, ) => Promise; +versionSupported: () => Promise; }