Page MenuHomePhabricator

D10049.diff
No OneTemporary

D10049.diff

diff --git a/keyserver/addons/rust-node-addon/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js
--- a/keyserver/addons/rust-node-addon/rust-binding-types.js
+++ b/keyserver/addons/rust-node-addon/rust-binding-types.js
@@ -58,8 +58,10 @@
notifOneTimePreKeys: $ReadOnlyArray<string>,
) => Promise<boolean>,
+getInboundKeysForUserDevice: (
- identifierType: string,
- identifierValue: string,
+ authUserId: string,
+ authDeviceId: string,
+ authAccessToken: string,
+ userId: string,
deviceId: string,
) => Promise<InboundKeyInfoResponse>,
};
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/get_inbound_keys_for_user.rs b/keyserver/addons/rust-node-addon/src/identity_client/get_inbound_keys_for_user.rs
--- a/keyserver/addons/rust-node-addon/src/identity_client/get_inbound_keys_for_user.rs
+++ b/keyserver/addons/rust-node-addon/src/identity_client/get_inbound_keys_for_user.rs
@@ -1,26 +1,25 @@
-use grpc_clients::identity::protos::client::{
- inbound_keys_for_user_request::Identifier, InboundKeysForUserRequest,
-};
+use grpc_clients::identity::protos::authenticated::InboundKeysForUserRequest;
use super::*;
#[napi]
#[instrument(skip_all)]
pub async fn get_inbound_keys_for_user_device(
- identifier_type: String,
- identifier_value: String,
+ auth_user_id: String,
+ auth_device_id: String,
+ auth_access_token: String,
+ user_id: String,
device_id: String,
) -> Result<InboundKeyInfoResponse> {
// Set up the gRPC client that will be used to talk to the Identity service
- let mut identity_client = get_identity_client().await?;
+ let mut identity_client = get_authenticated_identity_client(
+ auth_user_id,
+ auth_device_id,
+ auth_access_token,
+ )
+ .await?;
- let identifier = match identifier_type.as_str() {
- "walletAddress" => Some(Identifier::WalletAddress(identifier_value)),
- "username" => Some(Identifier::Username(identifier_value)),
- _ => return Err(Error::from_status(Status::GenericFailure)),
- };
-
- let inbound_keys_for_user_request = InboundKeysForUserRequest { identifier };
+ let inbound_keys_for_user_request = InboundKeysForUserRequest { user_id };
let mut response = identity_client
.get_inbound_keys_for_user(inbound_keys_for_user_request)
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
@@ -62,8 +62,10 @@
jsi::String accessToken) override;
virtual jsi::Value getOutboundKeysForUserDevice(
jsi::Runtime &rt,
- jsi::String identifierType,
- jsi::String identifierValue,
+ jsi::String authUserID,
+ jsi::String authDeviceID,
+ jsi::String authAccessToken,
+ jsi::String userID,
jsi::String deviceID) override;
virtual jsi::Value versionSupported(jsi::Runtime &rt) override;
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
@@ -225,20 +225,22 @@
jsi::Value CommRustModule::getOutboundKeysForUserDevice(
jsi::Runtime &rt,
- jsi::String identifierType,
- jsi::String identifierValue,
+ jsi::String authUserID,
+ jsi::String authDeviceID,
+ jsi::String authAccessToken,
+ jsi::String userID,
jsi::String deviceID) {
return createPromiseAsJSIValue(
- rt,
- [this, &identifierType, &identifierValue, &deviceID](
- jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ rt, [&, this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
std::string error;
try {
auto currentID = RustPromiseManager::instance.addPromise(
promise, this->jsInvoker_, innerRt);
identityGetOutboundKeysForUserDevice(
- jsiStringToRustString(identifierType, innerRt),
- jsiStringToRustString(identifierValue, innerRt),
+ jsiStringToRustString(authUserID, innerRt),
+ jsiStringToRustString(authDeviceID, innerRt),
+ jsiStringToRustString(authAccessToken, innerRt),
+ jsiStringToRustString(userID, innerRt),
jsiStringToRustString(deviceID, innerRt),
currentID);
} catch (const std::exception &e) {
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
@@ -31,7 +31,7 @@
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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<CommRustModuleSchemaCxxSpecJSI *>(&turboModule)->getOutboundKeysForUserDevice(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
+ return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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_versionSupported(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommRustModuleSchemaCxxSpecJSI *>(&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 {3, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUserDevice};
+ methodMap_["getOutboundKeysForUserDevice"] = MethodMetadata {5, __hostFunction_CommRustModuleSchemaCxxSpecJSI_getOutboundKeysForUserDevice};
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 identifierType, jsi::String identifierValue, jsi::String deviceID) = 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 versionSupported(jsi::Runtime &rt) = 0;
};
@@ -97,13 +97,13 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::deleteUser, jsInvoker_, instance_, std::move(userID), std::move(deviceID), std::move(accessToken));
}
- jsi::Value getOutboundKeysForUserDevice(jsi::Runtime &rt, jsi::String identifierType, jsi::String identifierValue, jsi::String deviceID) override {
+ jsi::Value getOutboundKeysForUserDevice(jsi::Runtime &rt, jsi::String authUserID, jsi::String authDeviceID, jsi::String authAccessToken, jsi::String userID, jsi::String deviceID) override {
static_assert(
- bridging::getParameterCount(&T::getOutboundKeysForUserDevice) == 4,
- "Expected getOutboundKeysForUserDevice(...) to have 4 parameters");
+ bridging::getParameterCount(&T::getOutboundKeysForUserDevice) == 6,
+ "Expected getOutboundKeysForUserDevice(...) to have 6 parameters");
return bridging::callFromJs<jsi::Value>(
- rt, &T::getOutboundKeysForUserDevice, jsInvoker_, instance_, std::move(identifierType), std::move(identifierValue), std::move(deviceID));
+ rt, &T::getOutboundKeysForUserDevice, jsInvoker_, instance_, std::move(authUserID), std::move(authDeviceID), std::move(authAccessToken), std::move(userID), std::move(deviceID));
}
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
@@ -2,12 +2,12 @@
use comm_opaque2::client::{Login, Registration};
use comm_opaque2::grpc::opaque_error_to_grpc_status as handle_error;
use grpc_clients::identity::protos::authenticated::{
- UpdateUserPasswordFinishRequest, UpdateUserPasswordStartRequest,
+ OutboundKeysForUserRequest, UpdateUserPasswordFinishRequest,
+ UpdateUserPasswordStartRequest,
};
use grpc_clients::identity::protos::client::{
- outbound_keys_for_user_request::Identifier, DeviceKeyUpload, DeviceType,
- Empty, IdentityKeyInfo, OpaqueLoginFinishRequest, OpaqueLoginStartRequest,
- OutboundKeyInfo, OutboundKeysForUserRequest, PreKey,
+ DeviceKeyUpload, DeviceType, Empty, IdentityKeyInfo,
+ OpaqueLoginFinishRequest, OpaqueLoginStartRequest, OutboundKeyInfo, PreKey,
RegistrationFinishRequest, RegistrationStartRequest, WalletLoginRequest,
};
use grpc_clients::identity::{
@@ -114,8 +114,10 @@
#[cxx_name = "identityGetOutboundKeysForUserDevice"]
fn get_outbound_keys_for_user_device(
- identifier_type: String,
- identifier_value: String,
+ auth_user_id: String,
+ auth_device_id: String,
+ auth_access_token: String,
+ user_id: String,
device_id: String,
promise_id: u32,
);
@@ -750,8 +752,7 @@
}
struct GetOutboundKeysRequestInfo {
- identifier_type: String,
- identifier_value: String,
+ user_id: String,
device_id: String,
}
@@ -818,50 +819,47 @@
}
fn get_outbound_keys_for_user_device(
- identifier_type: String,
- identifier_value: String,
+ 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 {
- identifier_type,
- identifier_value,
- device_id,
+ let get_outbound_keys_request_info =
+ GetOutboundKeysRequestInfo { user_id, device_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(get_outbound_keys_request_info)
- .await;
+ let result = get_outbound_keys_for_user_device_helper(
+ get_outbound_keys_request_info,
+ auth_info,
+ )
+ .await;
handle_string_result_as_callback(result, promise_id);
});
}
async fn get_outbound_keys_for_user_device_helper(
get_outbound_keys_request_info: GetOutboundKeysRequestInfo,
+ auth_info: AuthInfo,
) -> Result<String, Error> {
- let identifier = match get_outbound_keys_request_info.identifier_type.as_str()
- {
- "walletAddress" => Some(Identifier::WalletAddress(
- get_outbound_keys_request_info.identifier_value,
- )),
- "username" => Some(Identifier::Username(
- get_outbound_keys_request_info.identifier_value,
- )),
- _ => {
- return Err(Error::TonicGRPC(tonic::Status::invalid_argument(
- "invalid identifier",
- )))
- }
- };
-
- let mut identity_client = get_unauthenticated_client(
+ let mut identity_client = get_auth_client(
"http://127.0.0.1:50054",
+ auth_info.user_id,
+ auth_info.device_id,
+ auth_info.access_token,
CODE_VERSION,
DEVICE_TYPE.as_str_name().to_lowercase(),
)
.await?;
let mut response = identity_client
- .get_outbound_keys_for_user(OutboundKeysForUserRequest { identifier })
+ .get_outbound_keys_for_user(OutboundKeysForUserRequest {
+ user_id: get_outbound_keys_request_info.user_id,
+ })
.await?
.into_inner();
diff --git a/native/schema/CommRustModuleSchema.js b/native/schema/CommRustModuleSchema.js
--- a/native/schema/CommRustModuleSchema.js
+++ b/native/schema/CommRustModuleSchema.js
@@ -56,8 +56,10 @@
accessToken: string,
) => Promise<void>;
+getOutboundKeysForUserDevice: (
- identifierType: string,
- identifierValue: string,
+ authUserID: string,
+ authDeviceID: string,
+ authAccessToken: string,
+ userID: string,
deviceID: string,
) => Promise<string>;
+versionSupported: () => Promise<boolean>;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 2:08 PM (19 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571102
Default Alt Text
D10049.diff (13 KB)

Event Timeline