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 @@ -33,13 +33,11 @@ sessionInitializationInfo: SignedIdentityKeysBlob, ) => Promise, +loginUserWallet: ( - userId: string, - signingPublicKey: string, siweMessage: string, siweSignature: string, - sessionInitializationInfo: SignedIdentityKeysBlob, - socialProof: string, - ) => Promise, + signedIdentityKeysBlob: SignedIdentityKeysBlob, + socialProof: ?string, + ) => Promise, +deleteUser: (userId: string) => Promise, +updateUser: (userId: string, password: string) => Promise, +compareUsers: ( diff --git a/keyserver/addons/rust-node-addon/src/identity_client/login_user.rs b/keyserver/addons/rust-node-addon/src/identity_client/login_user.rs --- a/keyserver/addons/rust-node-addon/src/identity_client/login_user.rs +++ b/keyserver/addons/rust-node-addon/src/identity_client/login_user.rs @@ -3,19 +3,18 @@ #[napi] #[instrument(skip_all)] async fn login_user_wallet( - user_id: String, - signing_public_key: String, siwe_message: String, siwe_signature: String, - mut session_initialization_info: HashMap, - social_proof: String, -) -> Result { + signed_identity_keys_blob: SignedIdentityKeysBlob, + social_proof: Option, +) -> Result { + // Set up the gRPC client that will be used to talk to the Identity service let channel = get_identity_service_channel().await?; let token: MetadataValue<_> = IDENTITY_SERVICE_CONFIG .identity_auth_token .parse() .map_err(|_| Error::from_status(Status::GenericFailure))?; - let mut identity_client = IdentityKeyserverServiceClient::with_interceptor( + let mut identity_client = IdentityClientServiceClient::with_interceptor( channel, |mut req: Request<()>| { req.metadata_mut().insert("authorization", token.clone()); @@ -23,43 +22,37 @@ }, ); - // Create a LoginRequest channel and use ReceiverStream to turn the - // MPSC receiver into a Stream for outbound messages - let (tx, rx) = mpsc::channel(1); - let stream = ReceiverStream::new(rx); - let request = Request::new(stream); - - let mut response_stream = identity_client - .login_user(request) + // Create wallet login request and send it to the Identity service + let device_key_upload = DeviceKeyUpload { + device_key_info: Some(IdentityKeyInfo { + payload: signed_identity_keys_blob.payload, + payload_signature: signed_identity_keys_blob.signature, + social_proof: social_proof, + }), + identity_upload: Some(identity_client::PreKey { + pre_key: String::new(), + pre_key_signature: String::new(), + }), + notif_upload: Some(identity_client::PreKey { + pre_key: String::new(), + pre_key_signature: String::new(), + }), + onetime_identity_prekeys: Vec::new(), + onetime_notif_prekeys: Vec::new(), + }; + let login_request = Request::new(WalletLoginRequest { + siwe_message, + siwe_signature, + device_key_upload: Some(device_key_upload), + }); + + identity_client + .login_wallet_user(login_request) .await .map_err(|_| Error::from_status(Status::GenericFailure))? .into_inner(); - // Start wallet login on client and send initial login request to Identity - // service - session_initialization_info.insert("socialProof".to_string(), social_proof); - let login_request = LoginRequest { - data: Some(WalletLoginRequest(WalletLoginRequestStruct { - user_id, - signing_public_key, - siwe_message, - siwe_signature, - session_initialization_info: Some(SessionInitializationInfo { - info: session_initialization_info, - }), - })), - }; - if let Err(e) = tx.send(login_request).await { - error!("Response was dropped: {}", e); - return Err(Error::from_status(Status::GenericFailure)); - } - - // Return access token - let message = response_stream.message().await.map_err(|e| { - error!("Received an error from inbound message stream: {}", e); - Error::from_status(Status::GenericFailure) - })?; - get_wallet_access_token(message) + Ok(true) } #[napi] @@ -197,16 +190,3 @@ Err(handle_unexpected_response(message)) } } - -fn get_wallet_access_token( - message: Option, -) -> Result { - if let Some(LoginResponse { - data: Some(WalletLoginResponse(WalletLoginResponseStruct { access_token })), - }) = message - { - Ok(access_token) - } else { - Err(handle_unexpected_response(message)) - } -} diff --git a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs --- a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs +++ b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs @@ -14,9 +14,7 @@ use identity::identity_keyserver_service_client::IdentityKeyserverServiceClient; use identity::{ login_request::Data::PakeLoginRequest, - login_request::Data::WalletLoginRequest, login_response::Data::PakeLoginResponse as LoginPakeLoginResponse, - login_response::Data::WalletLoginResponse, pake_login_request::Data::PakeCredentialFinalization as LoginPakeCredentialFinalization, pake_login_request::Data::PakeCredentialRequestAndUserId, pake_login_response::Data::AccessToken, @@ -25,13 +23,11 @@ PakeCredentialRequestAndUserId as PakeCredentialRequestAndUserIdStruct, PakeLoginRequest as PakeLoginRequestStruct, PakeLoginResponse as PakeLoginResponseStruct, SessionInitializationInfo, - WalletLoginRequest as WalletLoginRequestStruct, - WalletLoginResponse as WalletLoginResponseStruct, }; use identity_client::identity_client_service_client::IdentityClientServiceClient; use identity_client::{ DeviceKeyUpload, IdentityKeyInfo, RegistrationFinishRequest, - RegistrationStartRequest, + RegistrationStartRequest, WalletLoginRequest, }; use lazy_static::lazy_static; use napi::bindgen_prelude::*; diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -592,15 +592,11 @@ } // 9. Try to double-write SIWE account info to the Identity service. - const userIDCopy = userID; if (identityKeys && signedIdentityKeysBlob) { - const identityKeysCopy = identityKeys; handleAsyncPromise( (async () => { const rustAPI = await getRustAPI(); await rustAPI.loginUserWallet( - userIDCopy, - identityKeysCopy.primaryIdentityPublicKeys.ed25519, siweMessage.toMessage(), signature, signedIdentityKeysBlob, diff --git a/shared/protos/identity_client.proto b/shared/protos/identity_client.proto --- a/shared/protos/identity_client.proto +++ b/shared/protos/identity_client.proto @@ -193,7 +193,6 @@ } message WalletLoginRequest { - // ed25519 key for the given user's device string siweMessage = 1; string siweSignature = 2; // Information specific to a user's device needed to open a new channel of