diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs index a10cd3b98..59315f2fc 100644 --- a/services/identity/src/client_service.rs +++ b/services/identity/src/client_service.rs @@ -1,1100 +1,1101 @@ // Standard library imports use std::str::FromStr; // External crate imports use comm_lib::aws::DynamoDBError; use comm_lib::shared::reserved_users::RESERVED_USERNAME_SET; use comm_opaque2::grpc::protocol_error_to_grpc_status; use rand::rngs::OsRng; use serde::{Deserialize, Serialize}; use siwe::eip55; use tonic::Response; use tracing::{debug, error, info, warn}; // Workspace crate imports use crate::config::CONFIG; use crate::constants::request_metadata; use crate::database::{ DBDeviceTypeInt, DatabaseClient, DeviceType, KeyPayload, }; use crate::error::{DeviceListError, Error as DBError}; use crate::grpc_services::protos::unauth::{ find_user_id_request, AddReservedUsernamesRequest, AuthResponse, Empty, FindUserIdRequest, FindUserIdResponse, GenerateNonceResponse, OpaqueLoginFinishRequest, OpaqueLoginStartRequest, OpaqueLoginStartResponse, RegistrationFinishRequest, RegistrationStartRequest, RegistrationStartResponse, RemoveReservedUsernameRequest, ReservedRegistrationStartRequest, ReservedWalletRegistrationRequest, SecondaryDeviceKeysUploadRequest, VerifyUserAccessTokenRequest, VerifyUserAccessTokenResponse, WalletAuthRequest, GetFarcasterUsersRequest, GetFarcasterUsersResponse }; use crate::grpc_services::shared::get_value; use crate::grpc_utils::{ ChallengeResponse, DeviceKeyUploadActions, NonceChallenge, }; use crate::nonce::generate_nonce_data; use crate::reserved_users::{ validate_account_ownership_message_and_get_user_id, validate_add_reserved_usernames_message, validate_remove_reserved_username_message, }; use crate::siwe::{ is_valid_ethereum_address, parse_and_verify_siwe_message, SocialProof, }; use crate::token::{AccessTokenData, AuthType}; pub use crate::grpc_services::protos::unauth::identity_client_service_server::{ IdentityClientService, IdentityClientServiceServer, }; use crate::regex::is_valid_username; #[derive(Clone, Serialize, Deserialize)] pub enum WorkflowInProgress { Registration(Box), Login(Box), Update(UpdateState), } #[derive(Clone, Serialize, Deserialize)] pub struct UserRegistrationInfo { pub username: String, pub flattened_device_key_upload: FlattenedDeviceKeyUpload, pub user_id: Option, pub farcaster_id: Option, } #[derive(Clone, Serialize, Deserialize)] pub struct UserLoginInfo { pub user_id: String, pub flattened_device_key_upload: FlattenedDeviceKeyUpload, pub opaque_server_login: comm_opaque2::server::Login, pub device_to_remove: Option, } #[derive(Clone, Serialize, Deserialize)] pub struct UpdateState { pub user_id: String, } #[derive(Clone, Serialize, Deserialize)] pub struct FlattenedDeviceKeyUpload { pub device_id_key: String, pub key_payload: String, pub key_payload_signature: String, pub content_prekey: String, pub content_prekey_signature: String, pub content_one_time_keys: Vec, pub notif_prekey: String, pub notif_prekey_signature: String, pub notif_one_time_keys: Vec, pub device_type: DeviceType, } #[derive(derive_more::Constructor)] pub struct ClientService { client: DatabaseClient, } #[tonic::async_trait] impl IdentityClientService for ClientService { async fn register_password_user_start( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); debug!("Received registration request for: {}", message.username); if !is_valid_username(&message.username) || is_valid_ethereum_address(&message.username) { return Err(tonic::Status::invalid_argument("invalid username")); } self.check_username_taken(&message.username).await?; let username_in_reserved_usernames_table = self .client .username_in_reserved_usernames_table(&message.username) .await .map_err(handle_db_error)?; if username_in_reserved_usernames_table { return Err(tonic::Status::already_exists("username already exists")); } if RESERVED_USERNAME_SET.contains(&message.username) { return Err(tonic::Status::invalid_argument("username reserved")); } if let Some(fid) = &message.farcaster_id { self.check_farcaster_id_taken(fid).await?; } let registration_state = construct_user_registration_info( &message, None, message.username.clone(), message.farcaster_id.clone(), )?; let server_registration = comm_opaque2::server::Registration::new(); let server_message = server_registration .start( &CONFIG.server_setup, &message.opaque_registration_request, message.username.as_bytes(), ) .map_err(protocol_error_to_grpc_status)?; let session_id = self .client .insert_workflow(WorkflowInProgress::Registration(Box::new( registration_state, ))) .await .map_err(handle_db_error)?; let response = RegistrationStartResponse { session_id, opaque_registration_response: server_message, }; Ok(Response::new(response)) } async fn register_reserved_password_user_start( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); self.check_username_taken(&message.username).await?; if RESERVED_USERNAME_SET.contains(&message.username) { return Err(tonic::Status::invalid_argument("username reserved")); } let username_in_reserved_usernames_table = self .client .username_in_reserved_usernames_table(&message.username) .await .map_err(handle_db_error)?; if !username_in_reserved_usernames_table { return Err(tonic::Status::permission_denied("username not reserved")); } let user_id = validate_account_ownership_message_and_get_user_id( &message.username, &message.keyserver_message, &message.keyserver_signature, )?; let registration_state = construct_user_registration_info( &message, Some(user_id), message.username.clone(), None, )?; let server_registration = comm_opaque2::server::Registration::new(); let server_message = server_registration .start( &CONFIG.server_setup, &message.opaque_registration_request, message.username.as_bytes(), ) .map_err(protocol_error_to_grpc_status)?; let session_id = self .client .insert_workflow(WorkflowInProgress::Registration(Box::new( registration_state, ))) .await .map_err(handle_db_error)?; let response = RegistrationStartResponse { session_id, opaque_registration_response: server_message, }; Ok(Response::new(response)) } async fn register_password_user_finish( &self, request: tonic::Request, ) -> Result, tonic::Status> { let code_version = get_code_version(&request); let message = request.into_inner(); if let Some(WorkflowInProgress::Registration(state)) = self .client .get_workflow(message.session_id) .await .map_err(handle_db_error)? { let server_registration = comm_opaque2::server::Registration::new(); let password_file = server_registration .finish(&message.opaque_registration_upload) .map_err(protocol_error_to_grpc_status)?; let login_time = chrono::Utc::now(); let device_id = state.flattened_device_key_upload.device_id_key.clone(); let user_id = self .client .add_password_user_to_users_table( *state, password_file, code_version, login_time, ) .await .map_err(handle_db_error)?; // Create access token let token = AccessTokenData::with_created_time( user_id.clone(), device_id, login_time, crate::token::AuthType::Password, &mut OsRng, ); let access_token = token.access_token.clone(); self .client .put_access_token_data(token) .await .map_err(handle_db_error)?; let response = AuthResponse { user_id, access_token, }; Ok(Response::new(response)) } else { Err(tonic::Status::not_found("session not found")) } } async fn log_in_password_user_start( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); debug!("Attempting to log in user: {:?}", &message.username); let user_id_and_password_file = self .client .get_user_id_and_password_file_from_username(&message.username) .await .map_err(handle_db_error)?; let (user_id, password_file_bytes) = if let Some(data) = user_id_and_password_file { data } else { // It's possible that the user attempting login is already registered // on Ashoat's keyserver. If they are, we should send back a gRPC status // code instructing them to get a signed message from Ashoat's keyserver // in order to claim their username and register with the Identity // service. let username_in_reserved_usernames_table = self .client .username_in_reserved_usernames_table(&message.username) .await .map_err(handle_db_error)?; if username_in_reserved_usernames_table { return Err(tonic::Status::failed_precondition( "need keyserver message to claim username", )); } return Err(tonic::Status::not_found("user not found")); }; let flattened_device_key_upload = construct_flattened_device_key_upload(&message)?; let maybe_device_to_remove = self .get_keyserver_device_to_remove( &user_id, &flattened_device_key_upload.device_id_key, message.force.unwrap_or(false), &flattened_device_key_upload.device_type, ) .await?; let mut server_login = comm_opaque2::server::Login::new(); let server_response = server_login .start( &CONFIG.server_setup, &password_file_bytes, &message.opaque_login_request, message.username.as_bytes(), ) .map_err(protocol_error_to_grpc_status)?; let login_state = construct_user_login_info( user_id, server_login, flattened_device_key_upload, maybe_device_to_remove, )?; let session_id = self .client .insert_workflow(WorkflowInProgress::Login(Box::new(login_state))) .await .map_err(handle_db_error)?; let response = Response::new(OpaqueLoginStartResponse { session_id, opaque_login_response: server_response, }); Ok(response) } async fn log_in_password_user_finish( &self, request: tonic::Request, ) -> Result, tonic::Status> { let code_version = get_code_version(&request); let message = request.into_inner(); if let Some(WorkflowInProgress::Login(state)) = self .client .get_workflow(message.session_id) .await .map_err(handle_db_error)? { let mut server_login = state.opaque_server_login.clone(); server_login .finish(&message.opaque_login_upload) .map_err(protocol_error_to_grpc_status)?; if let Some(device_to_remove) = state.device_to_remove { self .client .remove_device(state.user_id.clone(), device_to_remove) .await .map_err(handle_db_error)?; } let login_time = chrono::Utc::now(); self .client .add_user_device( state.user_id.clone(), state.flattened_device_key_upload.clone(), code_version, login_time, ) .await .map_err(handle_db_error)?; // Create access token let token = AccessTokenData::with_created_time( state.user_id.clone(), state.flattened_device_key_upload.device_id_key, login_time, crate::token::AuthType::Password, &mut OsRng, ); let access_token = token.access_token.clone(); self .client .put_access_token_data(token) .await .map_err(handle_db_error)?; let response = AuthResponse { user_id: state.user_id, access_token, }; Ok(Response::new(response)) } else { Err(tonic::Status::not_found("session not found")) } } async fn log_in_wallet_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let code_version = get_code_version(&request); let message = request.into_inner(); let parsed_message = parse_and_verify_siwe_message( &message.siwe_message, &message.siwe_signature, )?; self.verify_and_remove_nonce(&parsed_message.nonce).await?; let wallet_address = eip55(&parsed_message.address); let flattened_device_key_upload = construct_flattened_device_key_upload(&message)?; let login_time = chrono::Utc::now(); let Some(user_id) = self .client .get_user_id_from_user_info(wallet_address.clone(), &AuthType::Wallet) .await .map_err(handle_db_error)? else { // It's possible that the user attempting login is already registered // on Ashoat's keyserver. If they are, we should send back a gRPC status // code instructing them to get a signed message from Ashoat's keyserver // in order to claim their wallet address and register with the Identity // service. let username_in_reserved_usernames_table = self .client .username_in_reserved_usernames_table(&wallet_address) .await .map_err(handle_db_error)?; if username_in_reserved_usernames_table { return Err(tonic::Status::failed_precondition( "need keyserver message to claim username", )); } return Err(tonic::Status::not_found("user not found")); }; self .client .add_user_device( user_id.clone(), flattened_device_key_upload.clone(), code_version, chrono::Utc::now(), ) .await .map_err(handle_db_error)?; // Create access token let token = AccessTokenData::with_created_time( user_id.clone(), flattened_device_key_upload.device_id_key, login_time, crate::token::AuthType::Wallet, &mut OsRng, ); let access_token = token.access_token.clone(); self .client .put_access_token_data(token) .await .map_err(handle_db_error)?; let response = AuthResponse { user_id, access_token, }; Ok(Response::new(response)) } async fn register_wallet_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let code_version = get_code_version(&request); let message = request.into_inner(); let parsed_message = parse_and_verify_siwe_message( &message.siwe_message, &message.siwe_signature, )?; match self .client .get_nonce_from_nonces_table(&parsed_message.nonce) .await .map_err(handle_db_error)? { None => return Err(tonic::Status::invalid_argument("invalid nonce")), Some(nonce) if nonce.is_expired() => { // we don't need to remove the nonce from the table here // because the DynamoDB TTL will take care of it return Err(tonic::Status::aborted("nonce expired")); } Some(_) => self .client .remove_nonce_from_nonces_table(&parsed_message.nonce) .await .map_err(handle_db_error)?, }; let wallet_address = eip55(&parsed_message.address); self.check_wallet_address_taken(&wallet_address).await?; let username_in_reserved_usernames_table = self .client .username_in_reserved_usernames_table(&wallet_address) .await .map_err(handle_db_error)?; if username_in_reserved_usernames_table { return Err(tonic::Status::already_exists( "wallet address already exists", )); } if let Some(fid) = &message.farcaster_id { self.check_farcaster_id_taken(fid).await?; } let flattened_device_key_upload = construct_flattened_device_key_upload(&message)?; let login_time = chrono::Utc::now(); let social_proof = SocialProof::new(message.siwe_message, message.siwe_signature); let serialized_social_proof = serde_json::to_string(&social_proof) .map_err(|_| tonic::Status::invalid_argument("invalid_social_proof"))?; let user_id = self .client .add_wallet_user_to_users_table( flattened_device_key_upload.clone(), wallet_address, serialized_social_proof, None, code_version, login_time, message.farcaster_id, ) .await .map_err(handle_db_error)?; // Create access token let token = AccessTokenData::with_created_time( user_id.clone(), flattened_device_key_upload.device_id_key, login_time, crate::token::AuthType::Wallet, &mut OsRng, ); let access_token = token.access_token.clone(); self .client .put_access_token_data(token) .await .map_err(handle_db_error)?; let response = AuthResponse { user_id, access_token, }; Ok(Response::new(response)) } async fn register_reserved_wallet_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let code_version = get_code_version(&request); let message = request.into_inner(); let parsed_message = parse_and_verify_siwe_message( &message.siwe_message, &message.siwe_signature, )?; self.verify_and_remove_nonce(&parsed_message.nonce).await?; let wallet_address = eip55(&parsed_message.address); self.check_wallet_address_taken(&wallet_address).await?; let wallet_address_in_reserved_usernames_table = self .client .username_in_reserved_usernames_table(&wallet_address) .await .map_err(handle_db_error)?; if !wallet_address_in_reserved_usernames_table { return Err(tonic::Status::permission_denied( "wallet address not reserved", )); } let user_id = validate_account_ownership_message_and_get_user_id( &wallet_address, &message.keyserver_message, &message.keyserver_signature, )?; let flattened_device_key_upload = construct_flattened_device_key_upload(&message)?; let social_proof = SocialProof::new(message.siwe_message, message.siwe_signature); let serialized_social_proof = serde_json::to_string(&social_proof) .map_err(|_| tonic::Status::invalid_argument("invalid_social_proof"))?; let login_time = chrono::Utc::now(); self .client .add_wallet_user_to_users_table( flattened_device_key_upload.clone(), wallet_address, serialized_social_proof, Some(user_id.clone()), code_version, login_time, None, ) .await .map_err(handle_db_error)?; let token = AccessTokenData::with_created_time( user_id.clone(), flattened_device_key_upload.device_id_key, login_time, crate::token::AuthType::Wallet, &mut OsRng, ); let access_token = token.access_token.clone(); self .client .put_access_token_data(token) .await .map_err(handle_db_error)?; let response = AuthResponse { user_id, access_token, }; Ok(Response::new(response)) } async fn upload_keys_for_registered_device_and_log_in( &self, request: tonic::Request, ) -> Result, tonic::Status> { let code_version = get_code_version(&request); let message = request.into_inner(); let challenge_response = ChallengeResponse::try_from(&message)?; let flattened_device_key_upload = construct_flattened_device_key_upload(&message)?; let user_id = message.user_id; let device_id = flattened_device_key_upload.device_id_key.clone(); let NonceChallenge { nonce } = challenge_response.verify_and_get_message(&device_id)?; self.verify_and_remove_nonce(&nonce).await?; + let user_identifier = self + .client + .get_user_identifier(&user_id) + .await + .map_err(handle_db_error)? + .ok_or_else(|| tonic::Status::not_found("user not found"))?; + let Some(device_list) = self .client .get_current_device_list(&user_id) .await .map_err(handle_db_error)? else { warn!("User {} does not have valid device list. Secondary device auth impossible.", user_id); return Err(tonic::Status::aborted("device list error")); }; if !device_list.device_ids.contains(&device_id) { return Err(tonic::Status::permission_denied( "device not in device list", )); } let login_time = chrono::Utc::now(); - - let user_identifier = self - .client - .get_user_identifier(&user_id) - .await - .map_err(handle_db_error)?; let token = AccessTokenData::with_created_time( user_id.clone(), device_id, login_time, user_identifier.into(), &mut OsRng, ); let access_token = token.access_token.clone(); self .client .put_access_token_data(token) .await .map_err(handle_db_error)?; self .client .put_device_data( &user_id, flattened_device_key_upload, code_version, login_time, ) .await .map_err(handle_db_error)?; let response = AuthResponse { user_id, access_token, }; Ok(Response::new(response)) } async fn generate_nonce( &self, _request: tonic::Request, ) -> Result, tonic::Status> { let nonce_data = generate_nonce_data(&mut OsRng); match self .client .add_nonce_to_nonces_table(nonce_data.clone()) .await { Ok(_) => Ok(Response::new(GenerateNonceResponse { nonce: nonce_data.nonce, })), Err(e) => Err(handle_db_error(e)), } } async fn verify_user_access_token( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); debug!("Verifying device: {}", &message.device_id); let token_valid = self .client .verify_access_token( message.user_id, message.device_id.clone(), message.access_token, ) .await .map_err(handle_db_error)?; let response = Response::new(VerifyUserAccessTokenResponse { token_valid }); debug!( "device {} was verified: {}", &message.device_id, token_valid ); Ok(response) } async fn add_reserved_usernames( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); let user_details = validate_add_reserved_usernames_message( &message.message, &message.signature, )?; let filtered_user_details = self .client .filter_out_taken_usernames(user_details) .await .map_err(handle_db_error)?; self .client .add_usernames_to_reserved_usernames_table(filtered_user_details) .await .map_err(handle_db_error)?; let response = Response::new(Empty {}); Ok(response) } async fn remove_reserved_username( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); let username = validate_remove_reserved_username_message( &message.message, &message.signature, )?; self .client .delete_username_from_reserved_usernames_table(username) .await .map_err(handle_db_error)?; let response = Response::new(Empty {}); Ok(response) } async fn ping( &self, _request: tonic::Request, ) -> Result, tonic::Status> { let response = Response::new(Empty {}); Ok(response) } async fn find_user_id( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); use find_user_id_request::Identifier; let (user_ident, auth_type) = match message.identifier { None => { return Err(tonic::Status::invalid_argument("no identifier provided")) } Some(Identifier::Username(username)) => (username, AuthType::Password), Some(Identifier::WalletAddress(address)) => (address, AuthType::Wallet), }; let (is_reserved_result, user_id_result) = tokio::join!( self .client .username_in_reserved_usernames_table(&user_ident), self .client .get_user_id_from_user_info(user_ident.clone(), &auth_type), ); let is_reserved = is_reserved_result.map_err(handle_db_error)?; let user_id = user_id_result.map_err(handle_db_error)?; Ok(Response::new(FindUserIdResponse { user_id, is_reserved, })) } async fn get_farcaster_users( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); let farcaster_users = self .client .get_farcaster_users(message.farcaster_ids) .await .map_err(handle_db_error)? .into_iter() .map(|d| d.0) .collect(); Ok(Response::new(GetFarcasterUsersResponse { farcaster_users })) } } impl ClientService { async fn check_username_taken( &self, username: &str, ) -> Result<(), tonic::Status> { let username_taken = self .client .username_taken(username.to_string()) .await .map_err(handle_db_error)?; if username_taken { return Err(tonic::Status::already_exists("username already exists")); } Ok(()) } async fn check_wallet_address_taken( &self, wallet_address: &str, ) -> Result<(), tonic::Status> { let wallet_address_taken = self .client .wallet_address_taken(wallet_address.to_string()) .await .map_err(handle_db_error)?; if wallet_address_taken { return Err(tonic::Status::already_exists( "wallet address already exists", )); } Ok(()) } async fn check_farcaster_id_taken( &self, farcaster_id: &str, ) -> Result<(), tonic::Status> { let fid_already_registered = !self .client .get_farcaster_users(vec![farcaster_id.to_string()]) .await .map_err(handle_db_error)? .is_empty(); if fid_already_registered { return Err(tonic::Status::already_exists( "farcaster ID already associated with different user", )); } Ok(()) } async fn verify_and_remove_nonce( &self, nonce: &str, ) -> Result<(), tonic::Status> { match self .client .get_nonce_from_nonces_table(nonce) .await .map_err(handle_db_error)? { None => return Err(tonic::Status::invalid_argument("invalid nonce")), Some(nonce) if nonce.is_expired() => { // we don't need to remove the nonce from the table here // because the DynamoDB TTL will take care of it return Err(tonic::Status::aborted("nonce expired")); } Some(nonce_data) => self .client .remove_nonce_from_nonces_table(&nonce_data.nonce) .await .map_err(handle_db_error)?, }; Ok(()) } async fn get_keyserver_device_to_remove( &self, user_id: &str, new_keyserver_device_id: &str, force: bool, device_type: &DeviceType, ) -> Result, tonic::Status> { if device_type != &DeviceType::Keyserver { return Ok(None); } let maybe_keyserver_device_id = self .client .get_keyserver_device_id_for_user(user_id) .await .map_err(handle_db_error)?; let Some(existing_keyserver_device_id) = maybe_keyserver_device_id else { return Ok(None); }; if new_keyserver_device_id == existing_keyserver_device_id { return Ok(None); } if force { info!( "keyserver {} will be removed from the device list", existing_keyserver_device_id ); Ok(Some(existing_keyserver_device_id)) } else { Err(tonic::Status::already_exists( "user already has a keyserver", )) } } } pub fn handle_db_error(db_error: DBError) -> tonic::Status { match db_error { DBError::AwsSdk(DynamoDBError::InternalServerError(_)) | DBError::AwsSdk(DynamoDBError::ProvisionedThroughputExceededException( _, )) | DBError::AwsSdk(DynamoDBError::RequestLimitExceeded(_)) => { tonic::Status::unavailable("please retry") } DBError::DeviceList(DeviceListError::InvalidDeviceListUpdate) => { tonic::Status::invalid_argument("invalid device list update") } e => { error!("Encountered an unexpected error: {}", e); tonic::Status::failed_precondition("unexpected error") } } } fn construct_user_registration_info( message: &impl DeviceKeyUploadActions, user_id: Option, username: String, farcaster_id: Option, ) -> Result { Ok(UserRegistrationInfo { username, flattened_device_key_upload: construct_flattened_device_key_upload( message, )?, user_id, farcaster_id, }) } fn construct_user_login_info( user_id: String, opaque_server_login: comm_opaque2::server::Login, flattened_device_key_upload: FlattenedDeviceKeyUpload, device_to_remove: Option, ) -> Result { Ok(UserLoginInfo { user_id, flattened_device_key_upload, opaque_server_login, device_to_remove, }) } fn construct_flattened_device_key_upload( message: &impl DeviceKeyUploadActions, ) -> Result { let key_info = KeyPayload::from_str(&message.payload()?) .map_err(|_| tonic::Status::invalid_argument("malformed payload"))?; let flattened_device_key_upload = FlattenedDeviceKeyUpload { device_id_key: key_info.primary_identity_public_keys.ed25519, key_payload: message.payload()?, key_payload_signature: message.payload_signature()?, content_prekey: message.content_prekey()?, content_prekey_signature: message.content_prekey_signature()?, content_one_time_keys: message.one_time_content_prekeys()?, notif_prekey: message.notif_prekey()?, notif_prekey_signature: message.notif_prekey_signature()?, notif_one_time_keys: message.one_time_notif_prekeys()?, device_type: DeviceType::try_from(DBDeviceTypeInt(message.device_type()?)) .map_err(handle_db_error)?, }; Ok(flattened_device_key_upload) } fn get_code_version(req: &tonic::Request) -> u64 { get_value(req, request_metadata::CODE_VERSION) .and_then(|version| version.parse().ok()) .unwrap_or_else(|| { warn!( "Could not retrieve code version from request: {:?}. Defaulting to 0", req ); Default::default() }) } diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs index a844f4a81..7efd8ba2c 100644 --- a/services/identity/src/database.rs +++ b/services/identity/src/database.rs @@ -1,1445 +1,1447 @@ use comm_lib::aws::ddb::{ operation::{ delete_item::DeleteItemOutput, get_item::GetItemOutput, put_item::PutItemOutput, query::QueryOutput, }, primitives::Blob, types::{AttributeValue, PutRequest, ReturnConsumedCapacity, WriteRequest}, }; use comm_lib::aws::{AwsConfig, DynamoDBClient}; use comm_lib::database::{ AttributeExtractor, AttributeMap, DBItemAttributeError, DBItemError, TryFromAttribute, }; use constant_time_eq::constant_time_eq; use std::collections::{HashMap, HashSet}; use std::str::FromStr; use std::sync::Arc; use crate::{ constants::USERS_TABLE_SOCIAL_PROOF_ATTRIBUTE_NAME, ddb_utils::EthereumIdentity, reserved_users::UserDetail, }; use crate::{ ddb_utils::{ create_one_time_key_partition_key, into_one_time_put_requests, Identifier, OlmAccountType, }, grpc_services::protos, }; use crate::{ error::{consume_error, Error}, grpc_utils::DeviceKeysInfo, }; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use tracing::{debug, error, info, warn}; use crate::client_service::{FlattenedDeviceKeyUpload, UserRegistrationInfo}; use crate::config::CONFIG; use crate::constants::{ ACCESS_TOKEN_SORT_KEY, ACCESS_TOKEN_TABLE, ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE, ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE, ACCESS_TOKEN_TABLE_PARTITION_KEY, ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE, ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE, NONCE_TABLE, NONCE_TABLE_CREATED_ATTRIBUTE, NONCE_TABLE_EXPIRATION_TIME_ATTRIBUTE, NONCE_TABLE_EXPIRATION_TIME_UNIX_ATTRIBUTE, NONCE_TABLE_PARTITION_KEY, RESERVED_USERNAMES_TABLE, RESERVED_USERNAMES_TABLE_PARTITION_KEY, RESERVED_USERNAMES_TABLE_USER_ID_ATTRIBUTE, USERS_TABLE, USERS_TABLE_DEVICES_MAP_DEVICE_TYPE_ATTRIBUTE_NAME, USERS_TABLE_FARCASTER_ID_ATTRIBUTE_NAME, USERS_TABLE_PARTITION_KEY, USERS_TABLE_REGISTRATION_ATTRIBUTE, USERS_TABLE_USERNAME_ATTRIBUTE, USERS_TABLE_USERNAME_INDEX, USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_INDEX, }; use crate::id::generate_uuid; use crate::nonce::NonceData; use crate::token::{AccessTokenData, AuthType}; pub use grpc_clients::identity::DeviceType; mod device_list; mod farcaster; mod workflows; pub use device_list::{DeviceListRow, DeviceListUpdate, DeviceRow}; use self::device_list::Prekey; #[derive(Serialize, Deserialize)] pub struct OlmKeys { pub curve25519: String, pub ed25519: String, } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct KeyPayload { pub notification_identity_public_keys: OlmKeys, pub primary_identity_public_keys: OlmKeys, } impl FromStr for KeyPayload { type Err = serde_json::Error; // The payload is held in the database as an escaped JSON payload. // Escaped double quotes need to be trimmed before attempting to serialize fn from_str(payload: &str) -> Result { serde_json::from_str(&payload.replace(r#"\""#, r#"""#)) } } pub struct DBDeviceTypeInt(pub i32); impl TryFrom for DeviceType { type Error = crate::error::Error; fn try_from(value: DBDeviceTypeInt) -> Result { let device_result = DeviceType::try_from(value.0); device_result.map_err(|_| { Error::Attribute(DBItemError { attribute_name: USERS_TABLE_DEVICES_MAP_DEVICE_TYPE_ATTRIBUTE_NAME .to_string(), attribute_value: Some(AttributeValue::N(value.0.to_string())).into(), attribute_error: DBItemAttributeError::InvalidValue, }) }) } } pub struct OutboundKeys { pub key_payload: String, pub key_payload_signature: String, pub social_proof: Option, pub content_prekey: Prekey, pub notif_prekey: Prekey, pub content_one_time_key: Option, pub notif_one_time_key: Option, } impl From for protos::auth::OutboundKeyInfo { fn from(db_keys: OutboundKeys) -> Self { use protos::unauth::IdentityKeyInfo; Self { identity_info: Some(IdentityKeyInfo { payload: db_keys.key_payload, payload_signature: db_keys.key_payload_signature, social_proof: db_keys.social_proof, }), content_prekey: Some(db_keys.content_prekey.into()), notif_prekey: Some(db_keys.notif_prekey.into()), one_time_content_prekey: db_keys.content_one_time_key, one_time_notif_prekey: db_keys.notif_one_time_key, } } } #[derive(Clone)] pub struct DatabaseClient { client: Arc, } impl DatabaseClient { pub fn new(aws_config: &AwsConfig) -> Self { let client = match &CONFIG.localstack_endpoint { Some(endpoint) => { info!( "Configuring DynamoDB client to use LocalStack endpoint: {}", endpoint ); let ddb_config_builder = comm_lib::aws::ddb::config::Builder::from(aws_config) .endpoint_url(endpoint); DynamoDBClient::from_conf(ddb_config_builder.build()) } None => DynamoDBClient::new(aws_config), }; DatabaseClient { client: Arc::new(client), } } pub async fn add_password_user_to_users_table( &self, registration_state: UserRegistrationInfo, password_file: Vec, code_version: u64, access_token_creation_time: DateTime, ) -> Result { let device_key_upload = registration_state.flattened_device_key_upload; let user_id = self .add_user_to_users_table( device_key_upload.clone(), Some((registration_state.username, Blob::new(password_file))), None, registration_state.user_id, registration_state.farcaster_id, ) .await?; self .add_device( &user_id, device_key_upload, code_version, access_token_creation_time, ) .await?; Ok(user_id) } pub async fn add_wallet_user_to_users_table( &self, flattened_device_key_upload: FlattenedDeviceKeyUpload, wallet_address: String, social_proof: String, user_id: Option, code_version: u64, access_token_creation_time: DateTime, farcaster_id: Option, ) -> Result { let wallet_identity = EthereumIdentity { wallet_address, social_proof, }; let user_id = self .add_user_to_users_table( flattened_device_key_upload.clone(), None, Some(wallet_identity), user_id, farcaster_id, ) .await?; self .add_device( &user_id, flattened_device_key_upload, code_version, access_token_creation_time, ) .await?; Ok(user_id) } async fn add_user_to_users_table( &self, flattened_device_key_upload: FlattenedDeviceKeyUpload, username_and_password_file: Option<(String, Blob)>, wallet_identity: Option, user_id: Option, farcaster_id: Option, ) -> Result { let user_id = user_id.unwrap_or_else(generate_uuid); let mut user = HashMap::from([( USERS_TABLE_PARTITION_KEY.to_string(), AttributeValue::S(user_id.clone()), )]); if let Some((username, password_file)) = username_and_password_file { user.insert( USERS_TABLE_USERNAME_ATTRIBUTE.to_string(), AttributeValue::S(username), ); user.insert( USERS_TABLE_REGISTRATION_ATTRIBUTE.to_string(), AttributeValue::B(password_file), ); } if let Some(eth_identity) = wallet_identity { user.insert( USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE.to_string(), AttributeValue::S(eth_identity.wallet_address), ); user.insert( USERS_TABLE_SOCIAL_PROOF_ATTRIBUTE_NAME.to_string(), AttributeValue::S(eth_identity.social_proof), ); } if let Some(fid) = farcaster_id { user.insert( USERS_TABLE_FARCASTER_ID_ATTRIBUTE_NAME.to_string(), AttributeValue::S(fid), ); } self .client .put_item() .table_name(USERS_TABLE) .set_item(Some(user)) // make sure we don't accidentaly overwrite existing row .condition_expression("attribute_not_exists(#pk)") .expression_attribute_names("#pk", USERS_TABLE_PARTITION_KEY) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; self .append_one_time_prekeys( flattened_device_key_upload.device_id_key, flattened_device_key_upload.content_one_time_keys, flattened_device_key_upload.notif_one_time_keys, ) .await?; Ok(user_id) } pub async fn add_user_device( &self, user_id: String, flattened_device_key_upload: FlattenedDeviceKeyUpload, code_version: u64, access_token_creation_time: DateTime, ) -> Result<(), Error> { let content_one_time_keys = flattened_device_key_upload.content_one_time_keys.clone(); let notif_one_time_keys = flattened_device_key_upload.notif_one_time_keys.clone(); // add device to the device list if not exists let device_id = flattened_device_key_upload.device_id_key.clone(); let device_exists = self .device_exists(user_id.clone(), device_id.clone()) .await?; if device_exists { self .update_device_login_time( user_id.clone(), device_id, access_token_creation_time, ) .await?; return Ok(()); } // add device to the new device list self .add_device( user_id, flattened_device_key_upload, code_version, access_token_creation_time, ) .await?; self .append_one_time_prekeys( device_id, content_one_time_keys, notif_one_time_keys, ) .await?; Ok(()) } pub async fn get_keyserver_keys_for_user( &self, user_id: &str, ) -> Result, Error> { use crate::grpc_services::protos::unauth::DeviceType as GrpcDeviceType; // DynamoDB doesn't have a way to "pop" a value from a list, so we must // first read in user info, then update one_time_keys with value we // gave to requester let mut user_info = self .get_item_from_users_table(user_id) .await? .item .ok_or(Error::MissingItem)?; let user_id: String = user_info.take_attr(USERS_TABLE_PARTITION_KEY)?; let social_proof: Option = user_info.take_attr(USERS_TABLE_SOCIAL_PROOF_ATTRIBUTE_NAME)?; let user_devices = self.get_current_devices(user_id).await?; let maybe_keyserver_device = user_devices .into_iter() .find(|device| device.device_type == GrpcDeviceType::Keyserver); let Some(keyserver) = maybe_keyserver_device else { return Ok(None); }; debug!( "Found keyserver in devices table (ID={})", &keyserver.device_id ); let notif_one_time_key: Option = self .get_one_time_key(&keyserver.device_id, OlmAccountType::Notification) .await?; let content_one_time_key: Option = self .get_one_time_key(&keyserver.device_id, OlmAccountType::Content) .await?; debug!( "Able to get notif one-time key for keyserver {}: {}", &keyserver.device_id, notif_one_time_key.is_some() ); debug!( "Able to get content one-time key for keyserver {}: {}", &keyserver.device_id, content_one_time_key.is_some() ); let outbound_payload = OutboundKeys { key_payload: keyserver.device_key_info.key_payload, key_payload_signature: keyserver.device_key_info.key_payload_signature, social_proof, content_prekey: keyserver.content_prekey, notif_prekey: keyserver.notif_prekey, content_one_time_key, notif_one_time_key, }; Ok(Some(outbound_payload)) } pub async fn get_keyserver_device_id_for_user( &self, user_id: &str, ) -> Result, Error> { use crate::grpc_services::protos::unauth::DeviceType as GrpcDeviceType; let user_devices = self.get_current_devices(user_id).await?; let maybe_keyserver_device_id = user_devices .into_iter() .find(|device| device.device_type == GrpcDeviceType::Keyserver) .map(|device| device.device_id); Ok(maybe_keyserver_device_id) } /// Will "mint" a single one-time key by attempting to successfully delete a /// key pub async fn get_one_time_key( &self, device_id: &str, account_type: OlmAccountType, ) -> Result, Error> { use crate::constants::one_time_keys_table as otk_table; use crate::constants::ONE_TIME_KEY_MINIMUM_THRESHOLD; let query_result = self.get_one_time_keys(device_id, account_type).await?; let items = query_result.items(); fn spawn_refresh_keys_task(device_id: &str) { // Clone the string slice to move into the async block let device_id = device_id.to_string(); tokio::spawn(async move { debug!("Attempting to request more keys for device: {}", &device_id); let result = crate::tunnelbroker::send_refresh_keys_request(&device_id).await; consume_error(result); }); } // If no one-time keys exist, or if there aren't enough, request more. // Additionally, if no one-time keys exist, return early. let item_vec = if let Some(items_list) = items { if items_list.len() < ONE_TIME_KEY_MINIMUM_THRESHOLD { spawn_refresh_keys_task(device_id); } items_list } else { debug!("Unable to find {:?} one-time key", account_type); spawn_refresh_keys_task(device_id); return Ok(None); }; let mut result = None; // Attempt to delete the one-time keys individually, a successful delete // mints the one-time key to the requester for item in item_vec { let pk: String = item.get_attr(otk_table::PARTITION_KEY)?; let otk: String = item.get_attr(otk_table::SORT_KEY)?; let composite_key = HashMap::from([ (otk_table::PARTITION_KEY.to_string(), AttributeValue::S(pk)), ( otk_table::SORT_KEY.to_string(), AttributeValue::S(otk.clone()), ), ]); debug!("Attempting to delete a {:?} one time key", account_type); match self .client .delete_item() .set_key(Some(composite_key)) .table_name(otk_table::NAME) .send() .await { Ok(_) => { result = Some(otk); break; } // This err should only happen if a delete occurred between the read // above and this delete Err(e) => { debug!("Unable to delete key: {:?}", e); continue; } } } // Return deleted key Ok(result) } pub async fn get_one_time_keys( &self, device_id: &str, account_type: OlmAccountType, ) -> Result { use crate::constants::one_time_keys_table::*; // Add related prefix to partition key to grab the correct result set let partition_key = create_one_time_key_partition_key(device_id, account_type); self .client .query() .table_name(NAME) .key_condition_expression(format!("{} = :pk", PARTITION_KEY)) .expression_attribute_values(":pk", AttributeValue::S(partition_key)) .return_consumed_capacity(ReturnConsumedCapacity::Total) .send() .await .map_err(|e| Error::AwsSdk(e.into())) .map(|response| { let capacity_units = response .consumed_capacity() .and_then(|it| it.capacity_units()); debug!("OTK read consumed capacity: {:?}", capacity_units); response }) } pub async fn append_one_time_prekeys( &self, device_id: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, ) -> Result<(), Error> { use crate::constants::one_time_keys_table; let mut otk_requests = into_one_time_put_requests( &device_id, content_one_time_keys, OlmAccountType::Content, ); let notif_otk_requests: Vec = into_one_time_put_requests( &device_id, notif_one_time_keys, OlmAccountType::Notification, ); otk_requests.extend(notif_otk_requests); // BatchWriteItem has a hard limit of 25 writes per call for requests in otk_requests.chunks(25) { self .client .batch_write_item() .request_items(one_time_keys_table::NAME, requests.to_vec()) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; } Ok(()) } pub async fn update_user_password( &self, user_id: String, password_file: Vec, ) -> Result<(), Error> { let update_expression = format!("SET {} = :p", USERS_TABLE_REGISTRATION_ATTRIBUTE); let expression_attribute_values = HashMap::from([( ":p".to_string(), AttributeValue::B(Blob::new(password_file)), )]); self .client .update_item() .table_name(USERS_TABLE) .key(USERS_TABLE_PARTITION_KEY, AttributeValue::S(user_id)) .update_expression(update_expression) .set_expression_attribute_values(Some(expression_attribute_values)) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; Ok(()) } pub async fn delete_user( &self, user_id: String, ) -> Result { debug!(user_id, "Attempting to delete user's devices"); self.delete_devices_table_rows_for_user(&user_id).await?; debug!(user_id, "Attempting to delete user"); match self .client .delete_item() .table_name(USERS_TABLE) .key( USERS_TABLE_PARTITION_KEY, AttributeValue::S(user_id.clone()), ) .send() .await { Ok(out) => { info!("User has been deleted {}", user_id); Ok(out) } Err(e) => { error!("DynamoDB client failed to delete user {}", user_id); Err(Error::AwsSdk(e.into())) } } } pub async fn get_access_token_data( &self, user_id: String, signing_public_key: String, ) -> Result, Error> { let primary_key = create_composite_primary_key( ( ACCESS_TOKEN_TABLE_PARTITION_KEY.to_string(), user_id.clone(), ), ( ACCESS_TOKEN_SORT_KEY.to_string(), signing_public_key.clone(), ), ); let get_item_result = self .client .get_item() .table_name(ACCESS_TOKEN_TABLE) .set_key(Some(primary_key)) .consistent_read(true) .send() .await; match get_item_result { Ok(GetItemOutput { item: Some(mut item), .. }) => { let created = DateTime::::try_from_attr( ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE, item.remove(ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE), )?; let auth_type = parse_auth_type_attribute( item.remove(ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE), )?; let valid = parse_valid_attribute( item.remove(ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE), )?; let access_token = parse_token_attribute( item.remove(ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE), )?; Ok(Some(AccessTokenData { user_id, signing_public_key, access_token, created, auth_type, valid, })) } Ok(_) => { info!( "No item found for user {} and signing public key {} in token table", user_id, signing_public_key ); Ok(None) } Err(e) => { error!( "DynamoDB client failed to get token for user {} with signing public key {}: {}", user_id, signing_public_key, e ); Err(Error::AwsSdk(e.into())) } } } pub async fn verify_access_token( &self, user_id: String, signing_public_key: String, access_token_to_verify: String, ) -> Result { let is_valid = self .get_access_token_data(user_id, signing_public_key) .await? .map(|access_token_data| { constant_time_eq( access_token_data.access_token.as_bytes(), access_token_to_verify.as_bytes(), ) && access_token_data.is_valid() }) .unwrap_or(false); Ok(is_valid) } pub async fn put_access_token_data( &self, access_token_data: AccessTokenData, ) -> Result { let item = HashMap::from([ ( ACCESS_TOKEN_TABLE_PARTITION_KEY.to_string(), AttributeValue::S(access_token_data.user_id), ), ( ACCESS_TOKEN_SORT_KEY.to_string(), AttributeValue::S(access_token_data.signing_public_key), ), ( ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE.to_string(), AttributeValue::S(access_token_data.access_token), ), ( ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE.to_string(), AttributeValue::S(access_token_data.created.to_rfc3339()), ), ( ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE.to_string(), AttributeValue::S(match access_token_data.auth_type { AuthType::Password => "password".to_string(), AuthType::Wallet => "wallet".to_string(), }), ), ( ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE.to_string(), AttributeValue::Bool(access_token_data.valid), ), ]); self .client .put_item() .table_name(ACCESS_TOKEN_TABLE) .set_item(Some(item)) .send() .await .map_err(|e| Error::AwsSdk(e.into())) } pub async fn delete_access_token_data( &self, user_id: String, device_id_key: String, ) -> Result<(), Error> { self .client .delete_item() .table_name(ACCESS_TOKEN_TABLE) .key( ACCESS_TOKEN_TABLE_PARTITION_KEY.to_string(), AttributeValue::S(user_id), ) .key( ACCESS_TOKEN_SORT_KEY.to_string(), AttributeValue::S(device_id_key), ) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; Ok(()) } pub async fn wallet_address_taken( &self, wallet_address: String, ) -> Result { let result = self .get_user_id_from_user_info(wallet_address, &AuthType::Wallet) .await?; Ok(result.is_some()) } pub async fn username_taken(&self, username: String) -> Result { let result = self .get_user_id_from_user_info(username, &AuthType::Password) .await?; Ok(result.is_some()) } pub async fn filter_out_taken_usernames( &self, user_details: Vec, ) -> Result, Error> { let db_usernames = self.get_all_usernames().await?; let db_usernames_set: HashSet = db_usernames.into_iter().collect(); let available_user_details: Vec = user_details .into_iter() .filter(|user_detail| !db_usernames_set.contains(&user_detail.username)) .collect(); Ok(available_user_details) } async fn get_user_from_user_info( &self, user_info: String, auth_type: &AuthType, ) -> Result>, Error> { let (index, attribute_name) = match auth_type { AuthType::Password => { (USERS_TABLE_USERNAME_INDEX, USERS_TABLE_USERNAME_ATTRIBUTE) } AuthType::Wallet => ( USERS_TABLE_WALLET_ADDRESS_INDEX, USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, ), }; match self .client .query() .table_name(USERS_TABLE) .index_name(index) .key_condition_expression(format!("{} = :u", attribute_name)) .expression_attribute_values(":u", AttributeValue::S(user_info.clone())) .send() .await { Ok(QueryOutput { items: Some(items), .. }) => { let num_items = items.len(); if num_items == 0 { return Ok(None); } if num_items > 1 { warn!( "{} user IDs associated with {} {}: {:?}", num_items, attribute_name, user_info, items ); } let first_item = items[0].clone(); let user_id = first_item .get(USERS_TABLE_PARTITION_KEY) .ok_or(DBItemError { attribute_name: USERS_TABLE_PARTITION_KEY.to_string(), attribute_value: None.into(), attribute_error: DBItemAttributeError::Missing, })? .as_s() .map_err(|_| DBItemError { attribute_name: USERS_TABLE_PARTITION_KEY.to_string(), attribute_value: first_item .get(USERS_TABLE_PARTITION_KEY) .cloned() .into(), attribute_error: DBItemAttributeError::IncorrectType, })?; let result = self.get_item_from_users_table(user_id).await?; Ok(result.item) } Ok(_) => { info!( "No item found for {} {} in users table", attribute_name, user_info ); Ok(None) } Err(e) => { error!( "DynamoDB client failed to get user from {} {}: {}", attribute_name, user_info, e ); Err(Error::AwsSdk(e.into())) } } } pub async fn get_keys_for_user( &self, user_id: &str, get_one_time_keys: bool, ) -> Result, Error> { let mut devices_response = self.get_keys_for_user_devices(user_id).await?; if devices_response.is_empty() { debug!("No devices found for user {}", user_id); return Ok(None); } if get_one_time_keys { for (device_id_key, device_keys) in devices_response.iter_mut() { device_keys.notif_one_time_key = self .get_one_time_key(device_id_key, OlmAccountType::Notification) .await?; device_keys.content_one_time_key = self .get_one_time_key(device_id_key, OlmAccountType::Content) .await?; } } Ok(Some(devices_response)) } pub async fn get_user_id_from_user_info( &self, user_info: String, auth_type: &AuthType, ) -> Result, Error> { match self .get_user_from_user_info(user_info.clone(), auth_type) .await { Ok(Some(mut user)) => user .take_attr(USERS_TABLE_PARTITION_KEY) .map(Some) .map_err(Error::Attribute), Ok(_) => Ok(None), Err(e) => Err(e), } } pub async fn get_user_id_and_password_file_from_username( &self, username: &str, ) -> Result)>, Error> { match self .get_user_from_user_info(username.to_string(), &AuthType::Password) .await { Ok(Some(mut user)) => { let user_id = user.take_attr(USERS_TABLE_PARTITION_KEY)?; let password_file = parse_registration_data_attribute( user.remove(USERS_TABLE_REGISTRATION_ATTRIBUTE), )?; Ok(Some((user_id, password_file))) } Ok(_) => { info!( "No item found for user {} in PAKE registration table", username ); Ok(None) } Err(e) => { error!( "DynamoDB client failed to get registration data for user {}: {}", username, e ); Err(e) } } } pub async fn get_item_from_users_table( &self, user_id: &str, ) -> Result { let primary_key = create_simple_primary_key(( USERS_TABLE_PARTITION_KEY.to_string(), user_id.to_string(), )); self .client .get_item() .table_name(USERS_TABLE) .set_key(Some(primary_key)) .consistent_read(true) .send() .await .map_err(|e| Error::AwsSdk(e.into())) } + /// Retrieves username for password users or wallet address for wallet users + /// Returns `None` if user not found pub async fn get_user_identifier( &self, user_id: &str, - ) -> Result { - let user_info = self + ) -> Result, Error> { + self .get_item_from_users_table(user_id) .await? .item - .ok_or(Error::MissingItem)?; - - Identifier::try_from(user_info).map_err(|e| { - error!(user_id, "Database item is missing an identifier"); - e - }) + .map(Identifier::try_from) + .transpose() + .map_err(|e| { + error!(user_id, "Database item is missing an identifier"); + e + }) } async fn get_all_usernames(&self) -> Result, Error> { let scan_output = self .client .scan() .table_name(USERS_TABLE) .projection_expression(USERS_TABLE_USERNAME_ATTRIBUTE) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; let mut result = Vec::new(); if let Some(attributes) = scan_output.items { for mut attribute in attributes { if let Ok(username) = attribute.take_attr(USERS_TABLE_USERNAME_ATTRIBUTE) { result.push(username); } } } Ok(result) } pub async fn get_all_user_details(&self) -> Result, Error> { let scan_output = self .client .scan() .table_name(USERS_TABLE) .projection_expression(format!( "{USERS_TABLE_USERNAME_ATTRIBUTE}, {USERS_TABLE_PARTITION_KEY}" )) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; let mut result = Vec::new(); if let Some(attributes) = scan_output.items { for mut attribute in attributes { if let (Ok(username), Ok(user_id)) = ( attribute.take_attr(USERS_TABLE_USERNAME_ATTRIBUTE), attribute.take_attr(USERS_TABLE_PARTITION_KEY), ) { result.push(UserDetail { username, user_id }); } } } Ok(result) } pub async fn get_all_reserved_user_details( &self, ) -> Result, Error> { let scan_output = self .client .scan() .table_name(RESERVED_USERNAMES_TABLE) .projection_expression(format!( "{RESERVED_USERNAMES_TABLE_PARTITION_KEY},\ {RESERVED_USERNAMES_TABLE_USER_ID_ATTRIBUTE}" )) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; let mut result = Vec::new(); if let Some(attributes) = scan_output.items { for mut attribute in attributes { if let (Ok(username), Ok(user_id)) = ( attribute.take_attr(USERS_TABLE_USERNAME_ATTRIBUTE), attribute.take_attr(RESERVED_USERNAMES_TABLE_USER_ID_ATTRIBUTE), ) { result.push(UserDetail { username, user_id }); } } } Ok(result) } pub async fn add_nonce_to_nonces_table( &self, nonce_data: NonceData, ) -> Result { let item = HashMap::from([ ( NONCE_TABLE_PARTITION_KEY.to_string(), AttributeValue::S(nonce_data.nonce), ), ( NONCE_TABLE_CREATED_ATTRIBUTE.to_string(), AttributeValue::S(nonce_data.created.to_rfc3339()), ), ( NONCE_TABLE_EXPIRATION_TIME_ATTRIBUTE.to_string(), AttributeValue::S(nonce_data.expiration_time.to_rfc3339()), ), ( NONCE_TABLE_EXPIRATION_TIME_UNIX_ATTRIBUTE.to_string(), AttributeValue::N(nonce_data.expiration_time.timestamp().to_string()), ), ]); self .client .put_item() .table_name(NONCE_TABLE) .set_item(Some(item)) .send() .await .map_err(|e| Error::AwsSdk(e.into())) } pub async fn get_nonce_from_nonces_table( &self, nonce_value: impl Into, ) -> Result, Error> { let get_response = self .client .get_item() .table_name(NONCE_TABLE) .key( NONCE_TABLE_PARTITION_KEY, AttributeValue::S(nonce_value.into()), ) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; let Some(mut item) = get_response.item else { return Ok(None); }; let nonce = item.take_attr(NONCE_TABLE_PARTITION_KEY)?; let created = DateTime::::try_from_attr( NONCE_TABLE_CREATED_ATTRIBUTE, item.remove(NONCE_TABLE_CREATED_ATTRIBUTE), )?; let expiration_time = DateTime::::try_from_attr( NONCE_TABLE_EXPIRATION_TIME_ATTRIBUTE, item.remove(NONCE_TABLE_EXPIRATION_TIME_ATTRIBUTE), )?; Ok(Some(NonceData { nonce, created, expiration_time, })) } pub async fn remove_nonce_from_nonces_table( &self, nonce: impl Into, ) -> Result<(), Error> { self .client .delete_item() .table_name(NONCE_TABLE) .key(NONCE_TABLE_PARTITION_KEY, AttributeValue::S(nonce.into())) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; Ok(()) } pub async fn add_usernames_to_reserved_usernames_table( &self, user_details: Vec, ) -> Result<(), Error> { // A single call to BatchWriteItem can consist of up to 25 operations for user_chunk in user_details.chunks(25) { let write_requests = user_chunk .iter() .map(|user_detail| { let put_request = PutRequest::builder() .item( RESERVED_USERNAMES_TABLE_PARTITION_KEY, AttributeValue::S(user_detail.username.to_string()), ) .item( RESERVED_USERNAMES_TABLE_USER_ID_ATTRIBUTE, AttributeValue::S(user_detail.user_id.to_string()), ) .build(); WriteRequest::builder().put_request(put_request).build() }) .collect(); self .client .batch_write_item() .request_items(RESERVED_USERNAMES_TABLE, write_requests) .send() .await .map_err(|e| Error::AwsSdk(e.into()))?; } info!("Batch write item to reserved usernames table succeeded"); Ok(()) } pub async fn delete_username_from_reserved_usernames_table( &self, username: String, ) -> Result { debug!( "Attempting to delete username {} from reserved usernames table", username ); match self .client .delete_item() .table_name(RESERVED_USERNAMES_TABLE) .key( RESERVED_USERNAMES_TABLE_PARTITION_KEY, AttributeValue::S(username.clone()), ) .send() .await { Ok(out) => { info!( "Username {} has been deleted from reserved usernames table", username ); Ok(out) } Err(e) => { error!("DynamoDB client failed to delete username {} from reserved usernames table", username); Err(Error::AwsSdk(e.into())) } } } pub async fn username_in_reserved_usernames_table( &self, username: &str, ) -> Result { match self .client .get_item() .table_name(RESERVED_USERNAMES_TABLE) .key( RESERVED_USERNAMES_TABLE_PARTITION_KEY.to_string(), AttributeValue::S(username.to_string()), ) .consistent_read(true) .send() .await { Ok(GetItemOutput { item: Some(_), .. }) => Ok(true), Ok(_) => Ok(false), Err(e) => Err(Error::AwsSdk(e.into())), } } } type AttributeName = String; type Devices = HashMap; fn create_simple_primary_key( partition_key: (AttributeName, String), ) -> HashMap { HashMap::from([(partition_key.0, AttributeValue::S(partition_key.1))]) } fn create_composite_primary_key( partition_key: (AttributeName, String), sort_key: (AttributeName, String), ) -> HashMap { let mut primary_key = create_simple_primary_key(partition_key); primary_key.insert(sort_key.0, AttributeValue::S(sort_key.1)); primary_key } fn parse_auth_type_attribute( attribute: Option, ) -> Result { if let Some(AttributeValue::S(auth_type)) = &attribute { match auth_type.as_str() { "password" => Ok(AuthType::Password), "wallet" => Ok(AuthType::Wallet), _ => Err(DBItemError::new( ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::IncorrectType, )), } } else { Err(DBItemError::new( ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::Missing, )) } } fn parse_valid_attribute( attribute: Option, ) -> Result { match attribute { Some(AttributeValue::Bool(valid)) => Ok(valid), Some(_) => Err(DBItemError::new( ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::IncorrectType, )), None => Err(DBItemError::new( ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::Missing, )), } } fn parse_token_attribute( attribute: Option, ) -> Result { match attribute { Some(AttributeValue::S(token)) => Ok(token), Some(_) => Err(DBItemError::new( ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::IncorrectType, )), None => Err(DBItemError::new( ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::Missing, )), } } fn parse_registration_data_attribute( attribute: Option, ) -> Result, DBItemError> { match attribute { Some(AttributeValue::B(server_registration_bytes)) => { Ok(server_registration_bytes.into_inner()) } Some(_) => Err(DBItemError::new( USERS_TABLE_REGISTRATION_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::IncorrectType, )), None => Err(DBItemError::new( USERS_TABLE_REGISTRATION_ATTRIBUTE.to_string(), attribute.into(), DBItemAttributeError::Missing, )), } } #[deprecated(note = "Use `comm_lib` counterpart instead")] #[allow(dead_code)] fn parse_map_attribute( attribute_name: &str, attribute_value: Option, ) -> Result { match attribute_value { Some(AttributeValue::M(map)) => Ok(map), Some(_) => { error!( attribute = attribute_name, value = ?attribute_value, error_type = "IncorrectType", "Unexpected attribute type when parsing map attribute" ); Err(DBItemError::new( attribute_name.to_string(), attribute_value.into(), DBItemAttributeError::IncorrectType, )) } None => { error!( attribute = attribute_name, error_type = "Missing", "Attribute is missing" ); Err(DBItemError::new( attribute_name.to_string(), attribute_value.into(), DBItemAttributeError::Missing, )) } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_create_simple_primary_key() { let partition_key_name = "userID".to_string(); let partition_key_value = "12345".to_string(); let partition_key = (partition_key_name.clone(), partition_key_value.clone()); let mut primary_key = create_simple_primary_key(partition_key); assert_eq!(primary_key.len(), 1); let attribute = primary_key.remove(&partition_key_name); assert!(attribute.is_some()); assert_eq!(attribute, Some(AttributeValue::S(partition_key_value))); } #[test] fn test_create_composite_primary_key() { let partition_key_name = "userID".to_string(); let partition_key_value = "12345".to_string(); let partition_key = (partition_key_name.clone(), partition_key_value.clone()); let sort_key_name = "deviceID".to_string(); let sort_key_value = "54321".to_string(); let sort_key = (sort_key_name.clone(), sort_key_value.clone()); let mut primary_key = create_composite_primary_key(partition_key, sort_key); assert_eq!(primary_key.len(), 2); let partition_key_attribute = primary_key.remove(&partition_key_name); assert!(partition_key_attribute.is_some()); assert_eq!( partition_key_attribute, Some(AttributeValue::S(partition_key_value)) ); let sort_key_attribute = primary_key.remove(&sort_key_name); assert!(sort_key_attribute.is_some()); assert_eq!(sort_key_attribute, Some(AttributeValue::S(sort_key_value))) } #[test] fn validate_keys() { // Taken from test user let example_payload = r#"{\"notificationIdentityPublicKeys\":{\"curve25519\":\"DYmV8VdkjwG/VtC8C53morogNJhpTPT/4jzW0/cxzQo\",\"ed25519\":\"D0BV2Y7Qm36VUtjwyQTJJWYAycN7aMSJmhEsRJpW2mk\"},\"primaryIdentityPublicKeys\":{\"curve25519\":\"Y4ZIqzpE1nv83kKGfvFP6rifya0itRg2hifqYtsISnk\",\"ed25519\":\"cSlL+VLLJDgtKSPlIwoCZg0h0EmHlQoJC08uV/O+jvg\"}}"#; let serialized_payload = KeyPayload::from_str(example_payload).unwrap(); assert_eq!( serialized_payload .notification_identity_public_keys .curve25519, "DYmV8VdkjwG/VtC8C53morogNJhpTPT/4jzW0/cxzQo" ); } #[test] fn test_int_to_device_type() { let valid_result = DeviceType::try_from(3); assert!(valid_result.is_ok()); assert_eq!(valid_result.unwrap(), DeviceType::Android); let invalid_result = DeviceType::try_from(6); assert!(invalid_result.is_err()); } } diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs index 0ec1859dd..1999032d3 100644 --- a/services/identity/src/grpc_services/authenticated.rs +++ b/services/identity/src/grpc_services/authenticated.rs @@ -1,591 +1,617 @@ use std::collections::HashMap; use crate::config::CONFIG; use crate::database::{DeviceListRow, DeviceListUpdate}; use crate::{ client_service::{handle_db_error, UpdateState, WorkflowInProgress}, constants::request_metadata, database::DatabaseClient, ddb_utils::DateTimeExt, grpc_services::shared::get_value, }; use chrono::{DateTime, Utc}; use comm_opaque2::grpc::protocol_error_to_grpc_status; use tonic::{Request, Response, Status}; use tracing::{debug, error, warn}; use super::protos::auth::{ identity, identity_client_service_server::IdentityClientService, GetDeviceListRequest, GetDeviceListResponse, Identity, InboundKeyInfo, InboundKeysForUserRequest, InboundKeysForUserResponse, KeyserverKeysResponse, LinkFarcasterAccountRequest, OutboundKeyInfo, OutboundKeysForUserRequest, OutboundKeysForUserResponse, RefreshUserPrekeysRequest, UpdateDeviceListRequest, UpdateUserPasswordFinishRequest, UpdateUserPasswordStartRequest, UpdateUserPasswordStartResponse, UploadOneTimeKeysRequest, }; +use super::protos::auth::{UserIdentityRequest, UserIdentityResponse}; use super::protos::unauth::Empty; #[derive(derive_more::Constructor)] pub struct AuthenticatedService { db_client: DatabaseClient, } fn get_auth_info(req: &Request<()>) -> Option<(String, String, String)> { debug!("Retrieving auth info for request: {:?}", req); let user_id = get_value(req, request_metadata::USER_ID)?; let device_id = get_value(req, request_metadata::DEVICE_ID)?; let access_token = get_value(req, request_metadata::ACCESS_TOKEN)?; Some((user_id, device_id, access_token)) } pub fn auth_interceptor( req: Request<()>, db_client: &DatabaseClient, ) -> Result, Status> { debug!("Intercepting request to check auth info: {:?}", req); let (user_id, device_id, access_token) = get_auth_info(&req) .ok_or_else(|| Status::unauthenticated("Missing credentials"))?; let handle = tokio::runtime::Handle::current(); let new_db_client = db_client.clone(); // This function cannot be `async`, yet must call the async db call // Force tokio to resolve future in current thread without an explicit .await let valid_token = tokio::task::block_in_place(move || { handle .block_on(new_db_client.verify_access_token( user_id, device_id, access_token, )) .map_err(handle_db_error) })?; if !valid_token { return Err(Status::aborted("Bad Credentials")); } Ok(req) } pub fn get_user_and_device_id( request: &Request, ) -> Result<(String, String), Status> { let user_id = get_value(request, request_metadata::USER_ID) .ok_or_else(|| Status::unauthenticated("Missing user_id field"))?; let device_id = get_value(request, request_metadata::DEVICE_ID) .ok_or_else(|| Status::unauthenticated("Missing device_id field"))?; Ok((user_id, device_id)) } #[tonic::async_trait] impl IdentityClientService for AuthenticatedService { async fn refresh_user_prekeys( &self, request: Request, ) -> Result, Status> { let (user_id, device_id) = get_user_and_device_id(&request)?; let message = request.into_inner(); debug!("Refreshing prekeys for user: {}", user_id); let content_keys = message .new_content_prekeys .ok_or_else(|| Status::invalid_argument("Missing content keys"))?; let notif_keys = message .new_notif_prekeys .ok_or_else(|| Status::invalid_argument("Missing notification keys"))?; self .db_client .update_device_prekeys( user_id, device_id, content_keys.into(), notif_keys.into(), ) .await .map_err(handle_db_error)?; let response = Response::new(Empty {}); Ok(response) } async fn get_outbound_keys_for_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); let user_id = &message.user_id; let devices_map = self .db_client .get_keys_for_user(user_id, true) .await .map_err(handle_db_error)? .ok_or_else(|| tonic::Status::not_found("user not found"))?; let transformed_devices = devices_map .into_iter() .map(|(key, device_info)| (key, OutboundKeyInfo::from(device_info))) .collect::>(); Ok(tonic::Response::new(OutboundKeysForUserResponse { devices: transformed_devices, })) } async fn get_inbound_keys_for_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { use identity::IdentityInfo; let message = request.into_inner(); let user_id = &message.user_id; let devices_map = self .db_client .get_keys_for_user(user_id, false) .await .map_err(handle_db_error)? .ok_or_else(|| tonic::Status::not_found("user not found"))?; let transformed_devices = devices_map .into_iter() .map(|(key, device_info)| (key, InboundKeyInfo::from(device_info))) .collect::>(); let identifier = self .db_client .get_user_identifier(user_id) .await - .map_err(handle_db_error)?; + .map_err(handle_db_error)? + .ok_or_else(|| tonic::Status::not_found("user not found"))?; let identity_info = IdentityInfo::try_from(identifier)?; Ok(tonic::Response::new(InboundKeysForUserResponse { devices: transformed_devices, identity: Some(Identity { identity_info: Some(identity_info), }), })) } async fn get_keyserver_keys( &self, request: Request, ) -> Result, Status> { use identity::IdentityInfo; let message = request.into_inner(); let keyserver_info = self .db_client .get_keyserver_keys_for_user(&message.user_id) .await .map_err(handle_db_error)? .map(OutboundKeyInfo::from); let identifier = self .db_client .get_user_identifier(&message.user_id) .await - .map_err(handle_db_error)?; + .map_err(handle_db_error)? + .ok_or_else(|| tonic::Status::not_found("user not found"))?; let identity_info = IdentityInfo::try_from(identifier)?; let identity = Some(Identity { identity_info: Some(identity_info), }); let response = Response::new(KeyserverKeysResponse { keyserver_info, identity, }); return Ok(response); } async fn upload_one_time_keys( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, device_id) = get_user_and_device_id(&request)?; let message = request.into_inner(); debug!("Attempting to update one time keys for user: {}", user_id); self .db_client .append_one_time_prekeys( device_id, message.content_one_time_prekeys, message.notif_one_time_prekeys, ) .await .map_err(handle_db_error)?; Ok(tonic::Response::new(Empty {})) } async fn update_user_password_start( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, _) = get_user_and_device_id(&request)?; let message = request.into_inner(); let server_registration = comm_opaque2::server::Registration::new(); let server_message = server_registration .start( &CONFIG.server_setup, &message.opaque_registration_request, user_id.as_bytes(), ) .map_err(protocol_error_to_grpc_status)?; let update_state = UpdateState { user_id }; let session_id = self .db_client .insert_workflow(WorkflowInProgress::Update(update_state)) .await .map_err(handle_db_error)?; let response = UpdateUserPasswordStartResponse { session_id, opaque_registration_response: server_message, }; Ok(Response::new(response)) } async fn update_user_password_finish( &self, request: tonic::Request, ) -> Result, tonic::Status> { let message = request.into_inner(); let Some(WorkflowInProgress::Update(state)) = self .db_client .get_workflow(message.session_id) .await .map_err(handle_db_error)? else { return Err(tonic::Status::not_found("session not found")); }; let server_registration = comm_opaque2::server::Registration::new(); let password_file = server_registration .finish(&message.opaque_registration_upload) .map_err(protocol_error_to_grpc_status)?; self .db_client .update_user_password(state.user_id, password_file) .await .map_err(handle_db_error)?; let response = Empty {}; Ok(Response::new(response)) } async fn log_out_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, device_id) = get_user_and_device_id(&request)?; self .db_client .remove_device(&user_id, &device_id) .await .map_err(handle_db_error)?; self .db_client .delete_access_token_data(user_id, device_id) .await .map_err(handle_db_error)?; let response = Empty {}; Ok(Response::new(response)) } async fn delete_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, _) = get_user_and_device_id(&request)?; self .db_client .delete_user(user_id) .await .map_err(handle_db_error)?; let response = Empty {}; Ok(Response::new(response)) } async fn get_device_list_for_user( &self, request: tonic::Request, ) -> Result, tonic::Status> { let GetDeviceListRequest { user_id, since_timestamp, } = request.into_inner(); let since = since_timestamp .map(|timestamp| { DateTime::::from_utc_timestamp_millis(timestamp) .ok_or_else(|| tonic::Status::invalid_argument("Invalid timestamp")) }) .transpose()?; let mut db_result = self .db_client .get_device_list_history(user_id, since) .await .map_err(handle_db_error)?; // these should be sorted already, but just in case db_result.sort_by_key(|list| list.timestamp); let device_list_updates: Vec = db_result .into_iter() .map(RawDeviceList::from) .map(SignedDeviceList::try_from_raw) .collect::, _>>()?; let stringified_updates = device_list_updates .iter() .map(serde_json::to_string) .collect::, _>>() .map_err(|err| { error!("Failed to serialize device list updates: {}", err); tonic::Status::failed_precondition("unexpected error") })?; Ok(Response::new(GetDeviceListResponse { device_list_updates: stringified_updates, })) } async fn update_device_list( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, _device_id) = get_user_and_device_id(&request)?; // TODO: when we stop doing "primary device rotation" (migration procedure) // we should verify if this RPC is called by primary device only let new_list = SignedDeviceList::try_from(request.into_inner())?; let update = DeviceListUpdate::try_from(new_list)?; self .db_client .apply_devicelist_update(&user_id, update) .await .map_err(handle_db_error)?; Ok(Response::new(Empty {})) } async fn link_farcaster_account( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, _) = get_user_and_device_id(&request)?; let message = request.into_inner(); let mut get_farcaster_users_response = self .db_client .get_farcaster_users(vec![message.farcaster_id.clone()]) .await .map_err(handle_db_error)?; if get_farcaster_users_response.len() > 1 { error!("multiple users associated with the same Farcaster ID"); return Err(Status::failed_precondition("cannot link Farcaster ID")); } if let Some(u) = get_farcaster_users_response.pop() { if u.0.user_id == user_id { return Ok(Response::new(Empty {})); } else { return Err(Status::already_exists( "farcaster ID already associated with different user", )); } } self .db_client .add_farcaster_id(user_id, message.farcaster_id) .await .map_err(handle_db_error)?; let response = Empty {}; Ok(Response::new(response)) } async fn unlink_farcaster_account( &self, request: tonic::Request, ) -> Result, tonic::Status> { let (user_id, _) = get_user_and_device_id(&request)?; self .db_client .remove_farcaster_id(user_id) .await .map_err(handle_db_error)?; let response = Empty {}; Ok(Response::new(response)) } + + async fn find_user_identity( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + use identity::IdentityInfo; + + let message = request.into_inner(); + let identifier = self + .db_client + .get_user_identifier(&message.user_id) + .await + .map_err(handle_db_error)? + .ok_or_else(|| tonic::Status::not_found("user not found"))?; + + let identity_info = IdentityInfo::try_from(identifier)?; + let identity = Some(Identity { + identity_info: Some(identity_info), + }); + + let response = Response::new(UserIdentityResponse { identity }); + return Ok(response); + } } // raw device list that can be serialized to JSON (and then signed in the future) #[derive(serde::Serialize, serde::Deserialize)] struct RawDeviceList { devices: Vec, timestamp: i64, } impl From for RawDeviceList { fn from(row: DeviceListRow) -> Self { Self { devices: row.device_ids, timestamp: row.timestamp.timestamp_millis(), } } } #[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] struct SignedDeviceList { /// JSON-stringified [`RawDeviceList`] raw_device_list: String, } impl SignedDeviceList { /// Serialize (and sign in the future) a [`RawDeviceList`] fn try_from_raw(raw: RawDeviceList) -> Result { let stringified_list = serde_json::to_string(&raw).map_err(|err| { error!("Failed to serialize raw device list: {}", err); tonic::Status::failed_precondition("unexpected error") })?; Ok(Self { raw_device_list: stringified_list, }) } fn as_raw(&self) -> Result { // The device list payload is sent as an escaped JSON payload. // Escaped double quotes need to be trimmed before attempting to deserialize serde_json::from_str(&self.raw_device_list.replace(r#"\""#, r#"""#)) .map_err(|err| { warn!("Failed to deserialize raw device list: {}", err); tonic::Status::invalid_argument("invalid device list payload") }) } } impl TryFrom for SignedDeviceList { type Error = tonic::Status; fn try_from(request: UpdateDeviceListRequest) -> Result { serde_json::from_str(&request.new_device_list).map_err(|err| { warn!("Failed to deserialize device list update: {}", err); tonic::Status::invalid_argument("invalid device list payload") }) } } impl TryFrom for DeviceListUpdate { type Error = tonic::Status; fn try_from(signed_list: SignedDeviceList) -> Result { let RawDeviceList { devices, timestamp: raw_timestamp, } = signed_list.as_raw()?; let timestamp = DateTime::::from_utc_timestamp_millis(raw_timestamp) .ok_or_else(|| { error!("Failed to parse RawDeviceList timestamp!"); tonic::Status::invalid_argument("invalid timestamp") })?; Ok(DeviceListUpdate::new(devices, timestamp)) } } #[cfg(test)] mod tests { use super::*; #[test] fn serialize_device_list_updates() { let raw_updates = vec![ RawDeviceList { devices: vec!["device1".into()], timestamp: 111111111, }, RawDeviceList { devices: vec!["device1".into(), "device2".into()], timestamp: 222222222, }, ]; let expected_raw_list1 = r#"{"devices":["device1"],"timestamp":111111111}"#; let expected_raw_list2 = r#"{"devices":["device1","device2"],"timestamp":222222222}"#; let signed_updates = raw_updates .into_iter() .map(SignedDeviceList::try_from_raw) .collect::, _>>() .expect("signing device list updates failed"); assert_eq!(signed_updates[0].raw_device_list, expected_raw_list1); assert_eq!(signed_updates[1].raw_device_list, expected_raw_list2); let stringified_updates = signed_updates .iter() .map(serde_json::to_string) .collect::, _>>() .expect("serialize signed device lists failed"); let expected_stringified_list1 = r#"{"rawDeviceList":"{\"devices\":[\"device1\"],\"timestamp\":111111111}"}"#; let expected_stringified_list2 = r#"{"rawDeviceList":"{\"devices\":[\"device1\",\"device2\"],\"timestamp\":222222222}"}"#; assert_eq!(stringified_updates[0], expected_stringified_list1); assert_eq!(stringified_updates[1], expected_stringified_list2); } #[test] fn deserialize_device_list_update() { let raw_payload = r#"{"rawDeviceList":"{\"devices\":[\"device1\",\"device2\"],\"timestamp\":123456789}"}"#; let request = UpdateDeviceListRequest { new_device_list: raw_payload.to_string(), }; let signed_list = SignedDeviceList::try_from(request) .expect("Failed to parse SignedDeviceList"); let update = DeviceListUpdate::try_from(signed_list) .expect("Failed to parse DeviceListUpdate from signed list"); let expected_timestamp = DateTime::::from_utc_timestamp_millis(123456789).unwrap(); assert_eq!(update.timestamp, expected_timestamp); assert_eq!( update.devices, vec!["device1".to_string(), "device2".to_string()] ); } } diff --git a/shared/protos/identity_auth.proto b/shared/protos/identity_auth.proto index 67c13ebac..a94e57c66 100644 --- a/shared/protos/identity_auth.proto +++ b/shared/protos/identity_auth.proto @@ -1,209 +1,222 @@ syntax = "proto3"; import "identity_unauth.proto"; package identity.auth; // RPCs from a client (iOS, Android, or web) to identity service // // This service will assert authenticity of a device by verifying the access // token through an interceptor, thus avoiding the need to explicitly pass // the credentials on every request service IdentityClientService { // X3DH actions // Replenish one-time preKeys rpc UploadOneTimeKeys(UploadOneTimeKeysRequest) returns (identity.unauth.Empty) {} // Rotate a device's prekey and prekey signature // Rotated for deniability of older messages rpc RefreshUserPrekeys(RefreshUserPrekeysRequest) returns (identity.unauth.Empty) {} // Called by clients to get all device keys associated with a user in order // to open a new channel of communication on any of their devices. // Specially, this will return the following per device: // - Identity keys (both Content and Notif Keys) // - Prekey (including prekey signature) // - One-time Prekey rpc GetOutboundKeysForUser(OutboundKeysForUserRequest) returns (OutboundKeysForUserResponse) {} // Called by receivers of a communication request. The reponse will return // identity keys (both content and notif keys) and related prekeys per device, // but will not contain one-time keys. Additionally, the response will contain // the other user's username. rpc GetInboundKeysForUser(InboundKeysForUserRequest) returns (InboundKeysForUserResponse) {} // Called by user to update password and receive new access token rpc UpdateUserPasswordStart(UpdateUserPasswordStartRequest) returns (UpdateUserPasswordStartResponse) {} rpc UpdateUserPasswordFinish(UpdateUserPasswordFinishRequest) returns (identity.unauth.Empty) {} // Called by user to log out (clears device's keys and access token) rpc LogOutUser(identity.unauth.Empty) returns (identity.unauth.Empty) {} // Called by a user to delete their own account rpc DeleteUser(identity.unauth.Empty) returns (identity.unauth.Empty) {} // Called by clients to get required keys for opening a connection // to a user's keyserver rpc GetKeyserverKeys(OutboundKeysForUserRequest) returns (KeyserverKeysResponse) {} // Returns device list history rpc GetDeviceListForUser(GetDeviceListRequest) returns (GetDeviceListResponse) {} rpc UpdateDeviceList(UpdateDeviceListRequest) returns (identity.unauth.Empty) {} // Farcaster actions // Called by an existing user to link their Farcaster account rpc LinkFarcasterAccount(LinkFarcasterAccountRequest) returns (identity.unauth.Empty) {} // Called by an existing user to unlink their Farcaster account rpc UnlinkFarcasterAccount(identity.unauth.Empty) returns (identity.unauth.Empty) {} + + rpc FindUserIdentity(UserIdentityRequest) returns (UserIdentityResponse) {} } // Helper types message EthereumIdentity { string wallet_address = 1; string social_proof = 2; } message Identity { oneof identity_info { string username = 1; EthereumIdentity eth_identity = 2; } } // UploadOneTimeKeys // As OPKs get exhausted, they need to be refreshed message UploadOneTimeKeysRequest { repeated string content_one_time_prekeys = 1; repeated string notif_one_time_prekeys = 2; } // RefreshUserPreKeys message RefreshUserPrekeysRequest { identity.unauth.Prekey new_content_prekeys = 1; identity.unauth.Prekey new_notif_prekeys = 2; } // Information needed when establishing communication to someone else's device message OutboundKeyInfo { identity.unauth.IdentityKeyInfo identity_info = 1; identity.unauth.Prekey content_prekey = 2; identity.unauth.Prekey notif_prekey = 3; optional string one_time_content_prekey = 4; optional string one_time_notif_prekey = 5; } message KeyserverKeysResponse { optional OutboundKeyInfo keyserver_info = 1; Identity identity = 2; } // GetOutboundKeysForUser message OutboundKeysForUserResponse { // Map is keyed on devices' public ed25519 key used for signing map devices = 1; } // Information needed by a device to establish communcation when responding // to a request. // The device receiving a request only needs the content key and prekey. message OutboundKeysForUserRequest { string user_id = 1; } // GetInboundKeysForUser message InboundKeyInfo { identity.unauth.IdentityKeyInfo identity_info = 1; identity.unauth.Prekey content_prekey = 2; identity.unauth.Prekey notif_prekey = 3; } message InboundKeysForUserResponse { // Map is keyed on devices' public ed25519 key used for signing map devices = 1; Identity identity = 2; } message InboundKeysForUserRequest { string user_id = 1; } // UpdateUserPassword // Request for updating a user, similar to registration but need a // access token to validate user before updating password message UpdateUserPasswordStartRequest { // Message sent to initiate PAKE registration (step 1) bytes opaque_registration_request = 1; } // Do a user registration, but overwrite the existing credentials // after validation of user message UpdateUserPasswordFinishRequest { // Identifier used to correlate start and finish request string session_id = 1; // Opaque client registration upload (step 3) bytes opaque_registration_upload = 2; } message UpdateUserPasswordStartResponse { // Identifier used to correlate start request with finish request string session_id = 1; bytes opaque_registration_response = 2; } // GetDeviceListForUser message GetDeviceListRequest { // User whose device lists we want to retrieve string user_id = 1; // UTC timestamp in milliseconds // If none, whole device list history will be retrieved optional int64 since_timestamp = 2; } message GetDeviceListResponse { // A list of stringified JSON objects of the following format: // { // "rawDeviceList": JSON.stringify({ // "devices": [, ...] // "timestamp": , // }) // } repeated string device_list_updates = 1; } // UpdateDeviceListForUser message UpdateDeviceListRequest { // A stringified JSON object of the following format: // { // "rawDeviceList": JSON.stringify({ // "devices": [, ...] // "timestamp": , // }) // } string new_device_list = 1; } // LinkFarcasterAccount message LinkFarcasterAccountRequest { string farcaster_id = 1; } + +// FindUserIdentity + +message UserIdentityRequest { + // user ID for which we want to get the identity + string user_id = 1; +} + +message UserIdentityResponse { + Identity identity = 1; +} diff --git a/web/protobufs/identity-auth-client.cjs b/web/protobufs/identity-auth-client.cjs index 5fa2d0154..f92ba7584 100644 --- a/web/protobufs/identity-auth-client.cjs +++ b/web/protobufs/identity-auth-client.cjs @@ -1,874 +1,936 @@ /** * @fileoverview gRPC-Web generated client stub for identity.auth * @enhanceable * @public * @generated */ // Code generated by protoc-gen-grpc-web. DO NOT EDIT. // versions: // protoc-gen-grpc-web v1.4.2 // protoc v3.21.12 // source: identity_auth.proto /* eslint-disable */ // @ts-nocheck const grpc = {}; grpc.web = require('grpc-web'); var identity_unauth_pb = require('./identity-unauth-structs.cjs') const proto = {}; proto.identity = {}; proto.identity.auth = require('./identity-auth-structs.cjs'); /** * @param {string} hostname * @param {?Object} credentials * @param {?grpc.web.ClientOptions} options * @constructor * @struct * @final */ proto.identity.auth.IdentityClientServiceClient = function(hostname, credentials, options) { if (!options) options = {}; options.format = 'text'; /** * @private @const {!grpc.web.GrpcWebClientBase} The client */ this.client_ = new grpc.web.GrpcWebClientBase(options); /** * @private @const {string} The hostname */ this.hostname_ = hostname.replace(/\/+$/, ''); }; /** * @param {string} hostname * @param {?Object} credentials * @param {?grpc.web.ClientOptions} options * @constructor * @struct * @final */ proto.identity.auth.IdentityClientServicePromiseClient = function(hostname, credentials, options) { if (!options) options = {}; options.format = 'text'; /** * @private @const {!grpc.web.GrpcWebClientBase} The client */ this.client_ = new grpc.web.GrpcWebClientBase(options); /** * @private @const {string} The hostname */ this.hostname_ = hostname.replace(/\/+$/, ''); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.UploadOneTimeKeysRequest, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_UploadOneTimeKeys = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/UploadOneTimeKeys', grpc.web.MethodType.UNARY, proto.identity.auth.UploadOneTimeKeysRequest, identity_unauth_pb.Empty, /** * @param {!proto.identity.auth.UploadOneTimeKeysRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.auth.UploadOneTimeKeysRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.uploadOneTimeKeys = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/UploadOneTimeKeys', request, metadata || {}, methodDescriptor_IdentityClientService_UploadOneTimeKeys, callback); }; /** * @param {!proto.identity.auth.UploadOneTimeKeysRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.uploadOneTimeKeys = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/UploadOneTimeKeys', request, metadata || {}, methodDescriptor_IdentityClientService_UploadOneTimeKeys); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.RefreshUserPrekeysRequest, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_RefreshUserPrekeys = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/RefreshUserPrekeys', grpc.web.MethodType.UNARY, proto.identity.auth.RefreshUserPrekeysRequest, identity_unauth_pb.Empty, /** * @param {!proto.identity.auth.RefreshUserPrekeysRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.auth.RefreshUserPrekeysRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.refreshUserPrekeys = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/RefreshUserPrekeys', request, metadata || {}, methodDescriptor_IdentityClientService_RefreshUserPrekeys, callback); }; /** * @param {!proto.identity.auth.RefreshUserPrekeysRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.refreshUserPrekeys = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/RefreshUserPrekeys', request, metadata || {}, methodDescriptor_IdentityClientService_RefreshUserPrekeys); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.OutboundKeysForUserRequest, * !proto.identity.auth.OutboundKeysForUserResponse>} */ const methodDescriptor_IdentityClientService_GetOutboundKeysForUser = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/GetOutboundKeysForUser', grpc.web.MethodType.UNARY, proto.identity.auth.OutboundKeysForUserRequest, proto.identity.auth.OutboundKeysForUserResponse, /** * @param {!proto.identity.auth.OutboundKeysForUserRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, proto.identity.auth.OutboundKeysForUserResponse.deserializeBinary ); /** * @param {!proto.identity.auth.OutboundKeysForUserRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.auth.OutboundKeysForUserResponse)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.getOutboundKeysForUser = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/GetOutboundKeysForUser', request, metadata || {}, methodDescriptor_IdentityClientService_GetOutboundKeysForUser, callback); }; /** * @param {!proto.identity.auth.OutboundKeysForUserRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.getOutboundKeysForUser = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/GetOutboundKeysForUser', request, metadata || {}, methodDescriptor_IdentityClientService_GetOutboundKeysForUser); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.InboundKeysForUserRequest, * !proto.identity.auth.InboundKeysForUserResponse>} */ const methodDescriptor_IdentityClientService_GetInboundKeysForUser = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/GetInboundKeysForUser', grpc.web.MethodType.UNARY, proto.identity.auth.InboundKeysForUserRequest, proto.identity.auth.InboundKeysForUserResponse, /** * @param {!proto.identity.auth.InboundKeysForUserRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, proto.identity.auth.InboundKeysForUserResponse.deserializeBinary ); /** * @param {!proto.identity.auth.InboundKeysForUserRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.auth.InboundKeysForUserResponse)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.getInboundKeysForUser = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/GetInboundKeysForUser', request, metadata || {}, methodDescriptor_IdentityClientService_GetInboundKeysForUser, callback); }; /** * @param {!proto.identity.auth.InboundKeysForUserRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.getInboundKeysForUser = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/GetInboundKeysForUser', request, metadata || {}, methodDescriptor_IdentityClientService_GetInboundKeysForUser); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.UpdateUserPasswordStartRequest, * !proto.identity.auth.UpdateUserPasswordStartResponse>} */ const methodDescriptor_IdentityClientService_UpdateUserPasswordStart = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/UpdateUserPasswordStart', grpc.web.MethodType.UNARY, proto.identity.auth.UpdateUserPasswordStartRequest, proto.identity.auth.UpdateUserPasswordStartResponse, /** * @param {!proto.identity.auth.UpdateUserPasswordStartRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, proto.identity.auth.UpdateUserPasswordStartResponse.deserializeBinary ); /** * @param {!proto.identity.auth.UpdateUserPasswordStartRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.auth.UpdateUserPasswordStartResponse)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.updateUserPasswordStart = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/UpdateUserPasswordStart', request, metadata || {}, methodDescriptor_IdentityClientService_UpdateUserPasswordStart, callback); }; /** * @param {!proto.identity.auth.UpdateUserPasswordStartRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.updateUserPasswordStart = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/UpdateUserPasswordStart', request, metadata || {}, methodDescriptor_IdentityClientService_UpdateUserPasswordStart); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.UpdateUserPasswordFinishRequest, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_UpdateUserPasswordFinish = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/UpdateUserPasswordFinish', grpc.web.MethodType.UNARY, proto.identity.auth.UpdateUserPasswordFinishRequest, identity_unauth_pb.Empty, /** * @param {!proto.identity.auth.UpdateUserPasswordFinishRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.auth.UpdateUserPasswordFinishRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.updateUserPasswordFinish = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/UpdateUserPasswordFinish', request, metadata || {}, methodDescriptor_IdentityClientService_UpdateUserPasswordFinish, callback); }; /** * @param {!proto.identity.auth.UpdateUserPasswordFinishRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.updateUserPasswordFinish = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/UpdateUserPasswordFinish', request, metadata || {}, methodDescriptor_IdentityClientService_UpdateUserPasswordFinish); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.unauth.Empty, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_LogOutUser = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/LogOutUser', grpc.web.MethodType.UNARY, identity_unauth_pb.Empty, identity_unauth_pb.Empty, /** * @param {!proto.identity.unauth.Empty} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.unauth.Empty} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.logOutUser = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/LogOutUser', request, metadata || {}, methodDescriptor_IdentityClientService_LogOutUser, callback); }; /** * @param {!proto.identity.unauth.Empty} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.logOutUser = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/LogOutUser', request, metadata || {}, methodDescriptor_IdentityClientService_LogOutUser); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.unauth.Empty, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_DeleteUser = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/DeleteUser', grpc.web.MethodType.UNARY, identity_unauth_pb.Empty, identity_unauth_pb.Empty, /** * @param {!proto.identity.unauth.Empty} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.unauth.Empty} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.deleteUser = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/DeleteUser', request, metadata || {}, methodDescriptor_IdentityClientService_DeleteUser, callback); }; /** * @param {!proto.identity.unauth.Empty} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.deleteUser = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/DeleteUser', request, metadata || {}, methodDescriptor_IdentityClientService_DeleteUser); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.OutboundKeysForUserRequest, * !proto.identity.auth.KeyserverKeysResponse>} */ const methodDescriptor_IdentityClientService_GetKeyserverKeys = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/GetKeyserverKeys', grpc.web.MethodType.UNARY, proto.identity.auth.OutboundKeysForUserRequest, proto.identity.auth.KeyserverKeysResponse, /** * @param {!proto.identity.auth.OutboundKeysForUserRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, proto.identity.auth.KeyserverKeysResponse.deserializeBinary ); /** * @param {!proto.identity.auth.OutboundKeysForUserRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.auth.KeyserverKeysResponse)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.getKeyserverKeys = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/GetKeyserverKeys', request, metadata || {}, methodDescriptor_IdentityClientService_GetKeyserverKeys, callback); }; /** * @param {!proto.identity.auth.OutboundKeysForUserRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.getKeyserverKeys = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/GetKeyserverKeys', request, metadata || {}, methodDescriptor_IdentityClientService_GetKeyserverKeys); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.GetDeviceListRequest, * !proto.identity.auth.GetDeviceListResponse>} */ const methodDescriptor_IdentityClientService_GetDeviceListForUser = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/GetDeviceListForUser', grpc.web.MethodType.UNARY, proto.identity.auth.GetDeviceListRequest, proto.identity.auth.GetDeviceListResponse, /** * @param {!proto.identity.auth.GetDeviceListRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, proto.identity.auth.GetDeviceListResponse.deserializeBinary ); /** * @param {!proto.identity.auth.GetDeviceListRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.auth.GetDeviceListResponse)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.getDeviceListForUser = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/GetDeviceListForUser', request, metadata || {}, methodDescriptor_IdentityClientService_GetDeviceListForUser, callback); }; /** * @param {!proto.identity.auth.GetDeviceListRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.getDeviceListForUser = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/GetDeviceListForUser', request, metadata || {}, methodDescriptor_IdentityClientService_GetDeviceListForUser); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.UpdateDeviceListRequest, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_UpdateDeviceList = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/UpdateDeviceList', grpc.web.MethodType.UNARY, proto.identity.auth.UpdateDeviceListRequest, identity_unauth_pb.Empty, /** * @param {!proto.identity.auth.UpdateDeviceListRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.auth.UpdateDeviceListRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.updateDeviceList = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/UpdateDeviceList', request, metadata || {}, methodDescriptor_IdentityClientService_UpdateDeviceList, callback); }; /** * @param {!proto.identity.auth.UpdateDeviceListRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.updateDeviceList = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/UpdateDeviceList', request, metadata || {}, methodDescriptor_IdentityClientService_UpdateDeviceList); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.auth.LinkFarcasterAccountRequest, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_LinkFarcasterAccount = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/LinkFarcasterAccount', grpc.web.MethodType.UNARY, proto.identity.auth.LinkFarcasterAccountRequest, identity_unauth_pb.Empty, /** * @param {!proto.identity.auth.LinkFarcasterAccountRequest} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.auth.LinkFarcasterAccountRequest} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.linkFarcasterAccount = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/LinkFarcasterAccount', request, metadata || {}, methodDescriptor_IdentityClientService_LinkFarcasterAccount, callback); }; /** * @param {!proto.identity.auth.LinkFarcasterAccountRequest} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.linkFarcasterAccount = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/LinkFarcasterAccount', request, metadata || {}, methodDescriptor_IdentityClientService_LinkFarcasterAccount); }; /** * @const * @type {!grpc.web.MethodDescriptor< * !proto.identity.unauth.Empty, * !proto.identity.unauth.Empty>} */ const methodDescriptor_IdentityClientService_UnlinkFarcasterAccount = new grpc.web.MethodDescriptor( '/identity.auth.IdentityClientService/UnlinkFarcasterAccount', grpc.web.MethodType.UNARY, identity_unauth_pb.Empty, identity_unauth_pb.Empty, /** * @param {!proto.identity.unauth.Empty} request * @return {!Uint8Array} */ function(request) { return request.serializeBinary(); }, identity_unauth_pb.Empty.deserializeBinary ); /** * @param {!proto.identity.unauth.Empty} request The * request proto * @param {?Object} metadata User defined * call metadata * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)} * callback The callback function(error, response) * @return {!grpc.web.ClientReadableStream|undefined} * The XHR Node Readable Stream */ proto.identity.auth.IdentityClientServiceClient.prototype.unlinkFarcasterAccount = function(request, metadata, callback) { return this.client_.rpcCall(this.hostname_ + '/identity.auth.IdentityClientService/UnlinkFarcasterAccount', request, metadata || {}, methodDescriptor_IdentityClientService_UnlinkFarcasterAccount, callback); }; /** * @param {!proto.identity.unauth.Empty} request The * request proto * @param {?Object=} metadata User defined * call metadata * @return {!Promise} * Promise that resolves to the response */ proto.identity.auth.IdentityClientServicePromiseClient.prototype.unlinkFarcasterAccount = function(request, metadata) { return this.client_.unaryCall(this.hostname_ + '/identity.auth.IdentityClientService/UnlinkFarcasterAccount', request, metadata || {}, methodDescriptor_IdentityClientService_UnlinkFarcasterAccount); }; +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.identity.auth.UserIdentityRequest, + * !proto.identity.auth.UserIdentityResponse>} + */ +const methodDescriptor_IdentityClientService_FindUserIdentity = new grpc.web.MethodDescriptor( + '/identity.auth.IdentityClientService/FindUserIdentity', + grpc.web.MethodType.UNARY, + proto.identity.auth.UserIdentityRequest, + proto.identity.auth.UserIdentityResponse, + /** + * @param {!proto.identity.auth.UserIdentityRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.identity.auth.UserIdentityResponse.deserializeBinary +); + + +/** + * @param {!proto.identity.auth.UserIdentityRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.identity.auth.UserIdentityResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.identity.auth.IdentityClientServiceClient.prototype.findUserIdentity = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/identity.auth.IdentityClientService/FindUserIdentity', + request, + metadata || {}, + methodDescriptor_IdentityClientService_FindUserIdentity, + callback); +}; + + +/** + * @param {!proto.identity.auth.UserIdentityRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.identity.auth.IdentityClientServicePromiseClient.prototype.findUserIdentity = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/identity.auth.IdentityClientService/FindUserIdentity', + request, + metadata || {}, + methodDescriptor_IdentityClientService_FindUserIdentity); +}; + + module.exports = proto.identity.auth; + diff --git a/web/protobufs/identity-auth-client.cjs.flow b/web/protobufs/identity-auth-client.cjs.flow index 017787da8..bb045dd08 100644 --- a/web/protobufs/identity-auth-client.cjs.flow +++ b/web/protobufs/identity-auth-client.cjs.flow @@ -1,175 +1,187 @@ // @flow import * as grpcWeb from 'grpc-web'; import * as identityAuthStructs from './identity-auth-structs.cjs'; import * as identityStructs from './identity-unauth-structs.cjs'; declare export class IdentityClientServiceClient { constructor (hostname: string, credentials?: null | { +[index: string]: string; }, options?: null | { +[index: string]: any; }): void; uploadOneTimeKeys( request: identityAuthStructs.UploadOneTimeKeysRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; refreshUserPrekeys( request: identityAuthStructs.RefreshUserPrekeysRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; getOutboundKeysForUser( request: identityAuthStructs.OutboundKeysForUserRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityAuthStructs.OutboundKeysForUserResponse) => void ): grpcWeb.ClientReadableStream; getInboundKeysForUser( request: identityAuthStructs.InboundKeysForUserRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityAuthStructs.InboundKeysForUserResponse) => void ): grpcWeb.ClientReadableStream; updateUserPasswordStart( request: identityAuthStructs.UpdateUserPasswordStartRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityAuthStructs.UpdateUserPasswordStartResponse) => void ): grpcWeb.ClientReadableStream; updateUserPasswordFinish( request: identityAuthStructs.UpdateUserPasswordFinishRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; logOutUser( request: identityStructs.Empty, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; deleteUser( request: identityStructs.Empty, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; getKeyserverKeys( request: identityAuthStructs.OutboundKeysForUserRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityAuthStructs.KeyserverKeysResponse) => void ): grpcWeb.ClientReadableStream; getDeviceListForUser( request: identityAuthStructs.GetDeviceListRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityAuthStructs.GetDeviceListResponse) => void ): grpcWeb.ClientReadableStream; updateDeviceList( request: identityAuthStructs.UpdateDeviceListRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; linkFarcasterAccount( request: identityAuthStructs.LinkFarcasterAccountRequest, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; unlinkFarcasterAccount( request: identityStructs.Empty, metadata: grpcWeb.Metadata | void, callback: (err: grpcWeb.RpcError, response: identityStructs.Empty) => void ): grpcWeb.ClientReadableStream; + + findUserIdentity( + request: identityAuthStructs.UserIdentityRequest, + metadata: grpcWeb.Metadata | void, + callback: (err: grpcWeb.RpcError, + response: identityAuthStructs.UserIdentityResponse) => void + ): grpcWeb.ClientReadableStream; } declare export class IdentityClientServicePromiseClient { constructor (hostname: string, credentials?: null | { +[index: string]: string; }, options?: null | { +[index: string]: any; }): void; uploadOneTimeKeys( request: identityAuthStructs.UploadOneTimeKeysRequest, metadata?: grpcWeb.Metadata ): Promise; refreshUserPrekeys( request: identityAuthStructs.RefreshUserPrekeysRequest, metadata?: grpcWeb.Metadata ): Promise; getOutboundKeysForUser( request: identityAuthStructs.OutboundKeysForUserRequest, metadata?: grpcWeb.Metadata ): Promise; getInboundKeysForUser( request: identityAuthStructs.InboundKeysForUserRequest, metadata?: grpcWeb.Metadata ): Promise; updateUserPasswordStart( request: identityAuthStructs.UpdateUserPasswordStartRequest, metadata?: grpcWeb.Metadata ): Promise; updateUserPasswordFinish( request: identityAuthStructs.UpdateUserPasswordFinishRequest, metadata?: grpcWeb.Metadata ): Promise; logOutUser( request: identityStructs.Empty, metadata?: grpcWeb.Metadata ): Promise; deleteUser( request: identityStructs.Empty, metadata?: grpcWeb.Metadata ): Promise; getKeyserverKeys( request: identityAuthStructs.OutboundKeysForUserRequest, metadata?: grpcWeb.Metadata ): Promise; getDeviceListForUser( request: identityAuthStructs.GetDeviceListRequest, metadata?: grpcWeb.Metadata ): Promise; updateDeviceList( request: identityAuthStructs.UpdateDeviceListRequest, metadata?: grpcWeb.Metadata ): Promise; linkFarcasterAccount( request: identityAuthStructs.LinkFarcasterAccountRequest, metadata?: grpcWeb.Metadata ): Promise; unlinkFarcasterAccount( request: identityStructs.Empty, metadata?: grpcWeb.Metadata ): Promise; + + findUserIdentity( + request: identityAuthStructs.UserIdentityRequest, + metadata?: grpcWeb.Metadata + ): Promise; } diff --git a/web/protobufs/identity-auth-structs.cjs b/web/protobufs/identity-auth-structs.cjs index 608116278..ddaf34315 100644 --- a/web/protobufs/identity-auth-structs.cjs +++ b/web/protobufs/identity-auth-structs.cjs @@ -1,3715 +1,4040 @@ // source: identity_auth.proto /** * @fileoverview * @enhanceable * @suppress {missingRequire} reports error on implicit type usages. * @suppress {messageConventions} JS Compiler reports an error if a variable or * field starts with 'MSG_' and isn't a translatable message. * @public * @generated */ // GENERATED CODE -- DO NOT EDIT! /* eslint-disable */ // @ts-nocheck var jspb = require('google-protobuf'); var goog = jspb; var global = (typeof globalThis !== 'undefined' && globalThis) || (typeof window !== 'undefined' && window) || (typeof global !== 'undefined' && global) || (typeof self !== 'undefined' && self) || (function () { return this; }).call(null) || Function('return this')(); var identity_unauth_pb = require('./identity-unauth-structs.cjs'); goog.object.extend(proto, identity_unauth_pb); goog.exportSymbol('proto.identity.auth.EthereumIdentity', null, global); goog.exportSymbol('proto.identity.auth.GetDeviceListRequest', null, global); goog.exportSymbol('proto.identity.auth.GetDeviceListResponse', null, global); goog.exportSymbol('proto.identity.auth.Identity', null, global); goog.exportSymbol('proto.identity.auth.Identity.IdentityInfoCase', null, global); goog.exportSymbol('proto.identity.auth.InboundKeyInfo', null, global); goog.exportSymbol('proto.identity.auth.InboundKeysForUserRequest', null, global); goog.exportSymbol('proto.identity.auth.InboundKeysForUserResponse', null, global); goog.exportSymbol('proto.identity.auth.KeyserverKeysResponse', null, global); goog.exportSymbol('proto.identity.auth.LinkFarcasterAccountRequest', null, global); goog.exportSymbol('proto.identity.auth.OutboundKeyInfo', null, global); goog.exportSymbol('proto.identity.auth.OutboundKeysForUserRequest', null, global); goog.exportSymbol('proto.identity.auth.OutboundKeysForUserResponse', null, global); goog.exportSymbol('proto.identity.auth.RefreshUserPrekeysRequest', null, global); goog.exportSymbol('proto.identity.auth.UpdateDeviceListRequest', null, global); goog.exportSymbol('proto.identity.auth.UpdateUserPasswordFinishRequest', null, global); goog.exportSymbol('proto.identity.auth.UpdateUserPasswordStartRequest', null, global); goog.exportSymbol('proto.identity.auth.UpdateUserPasswordStartResponse', null, global); goog.exportSymbol('proto.identity.auth.UploadOneTimeKeysRequest', null, global); +goog.exportSymbol('proto.identity.auth.UserIdentityRequest', null, global); +goog.exportSymbol('proto.identity.auth.UserIdentityResponse', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.EthereumIdentity = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.EthereumIdentity, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.EthereumIdentity.displayName = 'proto.identity.auth.EthereumIdentity'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.Identity = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, proto.identity.auth.Identity.oneofGroups_); }; goog.inherits(proto.identity.auth.Identity, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.Identity.displayName = 'proto.identity.auth.Identity'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.UploadOneTimeKeysRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, proto.identity.auth.UploadOneTimeKeysRequest.repeatedFields_, null); }; goog.inherits(proto.identity.auth.UploadOneTimeKeysRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.UploadOneTimeKeysRequest.displayName = 'proto.identity.auth.UploadOneTimeKeysRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.RefreshUserPrekeysRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.RefreshUserPrekeysRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.RefreshUserPrekeysRequest.displayName = 'proto.identity.auth.RefreshUserPrekeysRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.OutboundKeyInfo = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.OutboundKeyInfo, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.OutboundKeyInfo.displayName = 'proto.identity.auth.OutboundKeyInfo'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.KeyserverKeysResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.KeyserverKeysResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.KeyserverKeysResponse.displayName = 'proto.identity.auth.KeyserverKeysResponse'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.OutboundKeysForUserResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.OutboundKeysForUserResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.OutboundKeysForUserResponse.displayName = 'proto.identity.auth.OutboundKeysForUserResponse'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.OutboundKeysForUserRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.OutboundKeysForUserRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.OutboundKeysForUserRequest.displayName = 'proto.identity.auth.OutboundKeysForUserRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.InboundKeyInfo = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.InboundKeyInfo, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.InboundKeyInfo.displayName = 'proto.identity.auth.InboundKeyInfo'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.InboundKeysForUserResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.InboundKeysForUserResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.InboundKeysForUserResponse.displayName = 'proto.identity.auth.InboundKeysForUserResponse'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.InboundKeysForUserRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.InboundKeysForUserRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.InboundKeysForUserRequest.displayName = 'proto.identity.auth.InboundKeysForUserRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.UpdateUserPasswordStartRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.UpdateUserPasswordStartRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.UpdateUserPasswordStartRequest.displayName = 'proto.identity.auth.UpdateUserPasswordStartRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.UpdateUserPasswordFinishRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.UpdateUserPasswordFinishRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.UpdateUserPasswordFinishRequest.displayName = 'proto.identity.auth.UpdateUserPasswordFinishRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.UpdateUserPasswordStartResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.UpdateUserPasswordStartResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.UpdateUserPasswordStartResponse.displayName = 'proto.identity.auth.UpdateUserPasswordStartResponse'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.GetDeviceListRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.GetDeviceListRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.GetDeviceListRequest.displayName = 'proto.identity.auth.GetDeviceListRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.GetDeviceListResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, proto.identity.auth.GetDeviceListResponse.repeatedFields_, null); }; goog.inherits(proto.identity.auth.GetDeviceListResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.GetDeviceListResponse.displayName = 'proto.identity.auth.GetDeviceListResponse'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.UpdateDeviceListRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.UpdateDeviceListRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.UpdateDeviceListRequest.displayName = 'proto.identity.auth.UpdateDeviceListRequest'; } /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a * server response, or constructed directly in Javascript. The array is used * in place and becomes part of the constructed object. It is not cloned. * If no data is provided, the constructed object will be empty, but still * valid. * @extends {jspb.Message} * @constructor */ proto.identity.auth.LinkFarcasterAccountRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.auth.LinkFarcasterAccountRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.auth.LinkFarcasterAccountRequest.displayName = 'proto.identity.auth.LinkFarcasterAccountRequest'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.identity.auth.UserIdentityRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.identity.auth.UserIdentityRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.identity.auth.UserIdentityRequest.displayName = 'proto.identity.auth.UserIdentityRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.identity.auth.UserIdentityResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.identity.auth.UserIdentityResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.identity.auth.UserIdentityResponse.displayName = 'proto.identity.auth.UserIdentityResponse'; +} if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.EthereumIdentity.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.EthereumIdentity.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.EthereumIdentity} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.EthereumIdentity.toObject = function(includeInstance, msg) { var f, obj = { walletAddress: jspb.Message.getFieldWithDefault(msg, 1, ""), socialProof: jspb.Message.getFieldWithDefault(msg, 2, "") }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.EthereumIdentity} */ proto.identity.auth.EthereumIdentity.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.EthereumIdentity; return proto.identity.auth.EthereumIdentity.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.EthereumIdentity} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.EthereumIdentity} */ proto.identity.auth.EthereumIdentity.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setWalletAddress(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setSocialProof(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.EthereumIdentity.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.EthereumIdentity.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.EthereumIdentity} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.EthereumIdentity.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getWalletAddress(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getSocialProof(); if (f.length > 0) { writer.writeString( 2, f ); } }; /** * optional string wallet_address = 1; * @return {string} */ proto.identity.auth.EthereumIdentity.prototype.getWalletAddress = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.EthereumIdentity} returns this */ proto.identity.auth.EthereumIdentity.prototype.setWalletAddress = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string social_proof = 2; * @return {string} */ proto.identity.auth.EthereumIdentity.prototype.getSocialProof = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.auth.EthereumIdentity} returns this */ proto.identity.auth.EthereumIdentity.prototype.setSocialProof = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * Oneof group definitions for this message. Each group defines the field * numbers belonging to that group. When of these fields' value is set, all * other fields in the group are cleared. During deserialization, if multiple * fields are encountered for a group, only the last value seen will be kept. * @private {!Array>} * @const */ proto.identity.auth.Identity.oneofGroups_ = [[1,2]]; /** * @enum {number} */ proto.identity.auth.Identity.IdentityInfoCase = { IDENTITY_INFO_NOT_SET: 0, USERNAME: 1, ETH_IDENTITY: 2 }; /** * @return {proto.identity.auth.Identity.IdentityInfoCase} */ proto.identity.auth.Identity.prototype.getIdentityInfoCase = function() { return /** @type {proto.identity.auth.Identity.IdentityInfoCase} */(jspb.Message.computeOneofCase(this, proto.identity.auth.Identity.oneofGroups_[0])); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.Identity.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.Identity.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.Identity} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.Identity.toObject = function(includeInstance, msg) { var f, obj = { username: jspb.Message.getFieldWithDefault(msg, 1, ""), ethIdentity: (f = msg.getEthIdentity()) && proto.identity.auth.EthereumIdentity.toObject(includeInstance, f) }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.Identity} */ proto.identity.auth.Identity.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.Identity; return proto.identity.auth.Identity.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.Identity} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.Identity} */ proto.identity.auth.Identity.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setUsername(value); break; case 2: var value = new proto.identity.auth.EthereumIdentity; reader.readMessage(value,proto.identity.auth.EthereumIdentity.deserializeBinaryFromReader); msg.setEthIdentity(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.Identity.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.Identity.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.Identity} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.Identity.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = /** @type {string} */ (jspb.Message.getField(message, 1)); if (f != null) { writer.writeString( 1, f ); } f = message.getEthIdentity(); if (f != null) { writer.writeMessage( 2, f, proto.identity.auth.EthereumIdentity.serializeBinaryToWriter ); } }; /** * optional string username = 1; * @return {string} */ proto.identity.auth.Identity.prototype.getUsername = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.Identity} returns this */ proto.identity.auth.Identity.prototype.setUsername = function(value) { return jspb.Message.setOneofField(this, 1, proto.identity.auth.Identity.oneofGroups_[0], value); }; /** * Clears the field making it undefined. * @return {!proto.identity.auth.Identity} returns this */ proto.identity.auth.Identity.prototype.clearUsername = function() { return jspb.Message.setOneofField(this, 1, proto.identity.auth.Identity.oneofGroups_[0], undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.Identity.prototype.hasUsername = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional EthereumIdentity eth_identity = 2; * @return {?proto.identity.auth.EthereumIdentity} */ proto.identity.auth.Identity.prototype.getEthIdentity = function() { return /** @type{?proto.identity.auth.EthereumIdentity} */ ( jspb.Message.getWrapperField(this, proto.identity.auth.EthereumIdentity, 2)); }; /** * @param {?proto.identity.auth.EthereumIdentity|undefined} value * @return {!proto.identity.auth.Identity} returns this */ proto.identity.auth.Identity.prototype.setEthIdentity = function(value) { return jspb.Message.setOneofWrapperField(this, 2, proto.identity.auth.Identity.oneofGroups_[0], value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.Identity} returns this */ proto.identity.auth.Identity.prototype.clearEthIdentity = function() { return this.setEthIdentity(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.Identity.prototype.hasEthIdentity = function() { return jspb.Message.getField(this, 2) != null; }; /** * List of repeated fields within this message type. * @private {!Array} * @const */ proto.identity.auth.UploadOneTimeKeysRequest.repeatedFields_ = [1,2]; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.UploadOneTimeKeysRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.UploadOneTimeKeysRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UploadOneTimeKeysRequest.toObject = function(includeInstance, msg) { var f, obj = { contentOneTimePrekeysList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f, notifOneTimePrekeysList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.UploadOneTimeKeysRequest} */ proto.identity.auth.UploadOneTimeKeysRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.UploadOneTimeKeysRequest; return proto.identity.auth.UploadOneTimeKeysRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.UploadOneTimeKeysRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.UploadOneTimeKeysRequest} */ proto.identity.auth.UploadOneTimeKeysRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.addContentOneTimePrekeys(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.addNotifOneTimePrekeys(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.UploadOneTimeKeysRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.UploadOneTimeKeysRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UploadOneTimeKeysRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getContentOneTimePrekeysList(); if (f.length > 0) { writer.writeRepeatedString( 1, f ); } f = message.getNotifOneTimePrekeysList(); if (f.length > 0) { writer.writeRepeatedString( 2, f ); } }; /** * repeated string content_one_time_prekeys = 1; * @return {!Array} */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.getContentOneTimePrekeysList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** * @param {!Array} value * @return {!proto.identity.auth.UploadOneTimeKeysRequest} returns this */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.setContentOneTimePrekeysList = function(value) { return jspb.Message.setField(this, 1, value || []); }; /** * @param {string} value * @param {number=} opt_index * @return {!proto.identity.auth.UploadOneTimeKeysRequest} returns this */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.addContentOneTimePrekeys = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** * Clears the list making it empty but non-null. * @return {!proto.identity.auth.UploadOneTimeKeysRequest} returns this */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.clearContentOneTimePrekeysList = function() { return this.setContentOneTimePrekeysList([]); }; /** * repeated string notif_one_time_prekeys = 2; * @return {!Array} */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.getNotifOneTimePrekeysList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); }; /** * @param {!Array} value * @return {!proto.identity.auth.UploadOneTimeKeysRequest} returns this */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.setNotifOneTimePrekeysList = function(value) { return jspb.Message.setField(this, 2, value || []); }; /** * @param {string} value * @param {number=} opt_index * @return {!proto.identity.auth.UploadOneTimeKeysRequest} returns this */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.addNotifOneTimePrekeys = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 2, value, opt_index); }; /** * Clears the list making it empty but non-null. * @return {!proto.identity.auth.UploadOneTimeKeysRequest} returns this */ proto.identity.auth.UploadOneTimeKeysRequest.prototype.clearNotifOneTimePrekeysList = function() { return this.setNotifOneTimePrekeysList([]); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.RefreshUserPrekeysRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.RefreshUserPrekeysRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.RefreshUserPrekeysRequest.toObject = function(includeInstance, msg) { var f, obj = { newContentPrekeys: (f = msg.getNewContentPrekeys()) && identity_unauth_pb.Prekey.toObject(includeInstance, f), newNotifPrekeys: (f = msg.getNewNotifPrekeys()) && identity_unauth_pb.Prekey.toObject(includeInstance, f) }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.RefreshUserPrekeysRequest} */ proto.identity.auth.RefreshUserPrekeysRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.RefreshUserPrekeysRequest; return proto.identity.auth.RefreshUserPrekeysRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.RefreshUserPrekeysRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.RefreshUserPrekeysRequest} */ proto.identity.auth.RefreshUserPrekeysRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = new identity_unauth_pb.Prekey; reader.readMessage(value,identity_unauth_pb.Prekey.deserializeBinaryFromReader); msg.setNewContentPrekeys(value); break; case 2: var value = new identity_unauth_pb.Prekey; reader.readMessage(value,identity_unauth_pb.Prekey.deserializeBinaryFromReader); msg.setNewNotifPrekeys(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.RefreshUserPrekeysRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.RefreshUserPrekeysRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.RefreshUserPrekeysRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getNewContentPrekeys(); if (f != null) { writer.writeMessage( 1, f, identity_unauth_pb.Prekey.serializeBinaryToWriter ); } f = message.getNewNotifPrekeys(); if (f != null) { writer.writeMessage( 2, f, identity_unauth_pb.Prekey.serializeBinaryToWriter ); } }; /** * optional identity.unauth.Prekey new_content_prekeys = 1; * @return {?proto.identity.unauth.Prekey} */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.getNewContentPrekeys = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.Prekey, 1)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.auth.RefreshUserPrekeysRequest} returns this */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.setNewContentPrekeys = function(value) { return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.RefreshUserPrekeysRequest} returns this */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.clearNewContentPrekeys = function() { return this.setNewContentPrekeys(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.hasNewContentPrekeys = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional identity.unauth.Prekey new_notif_prekeys = 2; * @return {?proto.identity.unauth.Prekey} */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.getNewNotifPrekeys = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.Prekey, 2)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.auth.RefreshUserPrekeysRequest} returns this */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.setNewNotifPrekeys = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.RefreshUserPrekeysRequest} returns this */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.clearNewNotifPrekeys = function() { return this.setNewNotifPrekeys(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.RefreshUserPrekeysRequest.prototype.hasNewNotifPrekeys = function() { return jspb.Message.getField(this, 2) != null; }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.OutboundKeyInfo.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.OutboundKeyInfo.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.OutboundKeyInfo} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.OutboundKeyInfo.toObject = function(includeInstance, msg) { var f, obj = { identityInfo: (f = msg.getIdentityInfo()) && identity_unauth_pb.IdentityKeyInfo.toObject(includeInstance, f), contentPrekey: (f = msg.getContentPrekey()) && identity_unauth_pb.Prekey.toObject(includeInstance, f), notifPrekey: (f = msg.getNotifPrekey()) && identity_unauth_pb.Prekey.toObject(includeInstance, f), oneTimeContentPrekey: jspb.Message.getFieldWithDefault(msg, 4, ""), oneTimeNotifPrekey: jspb.Message.getFieldWithDefault(msg, 5, "") }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.OutboundKeyInfo} */ proto.identity.auth.OutboundKeyInfo.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.OutboundKeyInfo; return proto.identity.auth.OutboundKeyInfo.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.OutboundKeyInfo} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.OutboundKeyInfo} */ proto.identity.auth.OutboundKeyInfo.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = new identity_unauth_pb.IdentityKeyInfo; reader.readMessage(value,identity_unauth_pb.IdentityKeyInfo.deserializeBinaryFromReader); msg.setIdentityInfo(value); break; case 2: var value = new identity_unauth_pb.Prekey; reader.readMessage(value,identity_unauth_pb.Prekey.deserializeBinaryFromReader); msg.setContentPrekey(value); break; case 3: var value = new identity_unauth_pb.Prekey; reader.readMessage(value,identity_unauth_pb.Prekey.deserializeBinaryFromReader); msg.setNotifPrekey(value); break; case 4: var value = /** @type {string} */ (reader.readString()); msg.setOneTimeContentPrekey(value); break; case 5: var value = /** @type {string} */ (reader.readString()); msg.setOneTimeNotifPrekey(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.OutboundKeyInfo.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.OutboundKeyInfo.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.OutboundKeyInfo} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.OutboundKeyInfo.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getIdentityInfo(); if (f != null) { writer.writeMessage( 1, f, identity_unauth_pb.IdentityKeyInfo.serializeBinaryToWriter ); } f = message.getContentPrekey(); if (f != null) { writer.writeMessage( 2, f, identity_unauth_pb.Prekey.serializeBinaryToWriter ); } f = message.getNotifPrekey(); if (f != null) { writer.writeMessage( 3, f, identity_unauth_pb.Prekey.serializeBinaryToWriter ); } f = /** @type {string} */ (jspb.Message.getField(message, 4)); if (f != null) { writer.writeString( 4, f ); } f = /** @type {string} */ (jspb.Message.getField(message, 5)); if (f != null) { writer.writeString( 5, f ); } }; /** * optional identity.unauth.IdentityKeyInfo identity_info = 1; * @return {?proto.identity.unauth.IdentityKeyInfo} */ proto.identity.auth.OutboundKeyInfo.prototype.getIdentityInfo = function() { return /** @type{?proto.identity.unauth.IdentityKeyInfo} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.IdentityKeyInfo, 1)); }; /** * @param {?proto.identity.unauth.IdentityKeyInfo|undefined} value * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.setIdentityInfo = function(value) { return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.clearIdentityInfo = function() { return this.setIdentityInfo(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.OutboundKeyInfo.prototype.hasIdentityInfo = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional identity.unauth.Prekey content_prekey = 2; * @return {?proto.identity.unauth.Prekey} */ proto.identity.auth.OutboundKeyInfo.prototype.getContentPrekey = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.Prekey, 2)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.setContentPrekey = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.clearContentPrekey = function() { return this.setContentPrekey(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.OutboundKeyInfo.prototype.hasContentPrekey = function() { return jspb.Message.getField(this, 2) != null; }; /** * optional identity.unauth.Prekey notif_prekey = 3; * @return {?proto.identity.unauth.Prekey} */ proto.identity.auth.OutboundKeyInfo.prototype.getNotifPrekey = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.Prekey, 3)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.setNotifPrekey = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.clearNotifPrekey = function() { return this.setNotifPrekey(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.OutboundKeyInfo.prototype.hasNotifPrekey = function() { return jspb.Message.getField(this, 3) != null; }; /** * optional string one_time_content_prekey = 4; * @return {string} */ proto.identity.auth.OutboundKeyInfo.prototype.getOneTimeContentPrekey = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** * @param {string} value * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.setOneTimeContentPrekey = function(value) { return jspb.Message.setField(this, 4, value); }; /** * Clears the field making it undefined. * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.clearOneTimeContentPrekey = function() { return jspb.Message.setField(this, 4, undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.OutboundKeyInfo.prototype.hasOneTimeContentPrekey = function() { return jspb.Message.getField(this, 4) != null; }; /** * optional string one_time_notif_prekey = 5; * @return {string} */ proto.identity.auth.OutboundKeyInfo.prototype.getOneTimeNotifPrekey = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); }; /** * @param {string} value * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.setOneTimeNotifPrekey = function(value) { return jspb.Message.setField(this, 5, value); }; /** * Clears the field making it undefined. * @return {!proto.identity.auth.OutboundKeyInfo} returns this */ proto.identity.auth.OutboundKeyInfo.prototype.clearOneTimeNotifPrekey = function() { return jspb.Message.setField(this, 5, undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.OutboundKeyInfo.prototype.hasOneTimeNotifPrekey = function() { return jspb.Message.getField(this, 5) != null; }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.KeyserverKeysResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.KeyserverKeysResponse.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.KeyserverKeysResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.KeyserverKeysResponse.toObject = function(includeInstance, msg) { var f, obj = { keyserverInfo: (f = msg.getKeyserverInfo()) && proto.identity.auth.OutboundKeyInfo.toObject(includeInstance, f), identity: (f = msg.getIdentity()) && proto.identity.auth.Identity.toObject(includeInstance, f) }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.KeyserverKeysResponse} */ proto.identity.auth.KeyserverKeysResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.KeyserverKeysResponse; return proto.identity.auth.KeyserverKeysResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.KeyserverKeysResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.KeyserverKeysResponse} */ proto.identity.auth.KeyserverKeysResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = new proto.identity.auth.OutboundKeyInfo; reader.readMessage(value,proto.identity.auth.OutboundKeyInfo.deserializeBinaryFromReader); msg.setKeyserverInfo(value); break; case 2: var value = new proto.identity.auth.Identity; reader.readMessage(value,proto.identity.auth.Identity.deserializeBinaryFromReader); msg.setIdentity(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.KeyserverKeysResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.KeyserverKeysResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.KeyserverKeysResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.KeyserverKeysResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getKeyserverInfo(); if (f != null) { writer.writeMessage( 1, f, proto.identity.auth.OutboundKeyInfo.serializeBinaryToWriter ); } f = message.getIdentity(); if (f != null) { writer.writeMessage( 2, f, proto.identity.auth.Identity.serializeBinaryToWriter ); } }; /** * optional OutboundKeyInfo keyserver_info = 1; * @return {?proto.identity.auth.OutboundKeyInfo} */ proto.identity.auth.KeyserverKeysResponse.prototype.getKeyserverInfo = function() { return /** @type{?proto.identity.auth.OutboundKeyInfo} */ ( jspb.Message.getWrapperField(this, proto.identity.auth.OutboundKeyInfo, 1)); }; /** * @param {?proto.identity.auth.OutboundKeyInfo|undefined} value * @return {!proto.identity.auth.KeyserverKeysResponse} returns this */ proto.identity.auth.KeyserverKeysResponse.prototype.setKeyserverInfo = function(value) { return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.KeyserverKeysResponse} returns this */ proto.identity.auth.KeyserverKeysResponse.prototype.clearKeyserverInfo = function() { return this.setKeyserverInfo(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.KeyserverKeysResponse.prototype.hasKeyserverInfo = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional Identity identity = 2; * @return {?proto.identity.auth.Identity} */ proto.identity.auth.KeyserverKeysResponse.prototype.getIdentity = function() { return /** @type{?proto.identity.auth.Identity} */ ( jspb.Message.getWrapperField(this, proto.identity.auth.Identity, 2)); }; /** * @param {?proto.identity.auth.Identity|undefined} value * @return {!proto.identity.auth.KeyserverKeysResponse} returns this */ proto.identity.auth.KeyserverKeysResponse.prototype.setIdentity = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.KeyserverKeysResponse} returns this */ proto.identity.auth.KeyserverKeysResponse.prototype.clearIdentity = function() { return this.setIdentity(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.KeyserverKeysResponse.prototype.hasIdentity = function() { return jspb.Message.getField(this, 2) != null; }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.OutboundKeysForUserResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.OutboundKeysForUserResponse.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.OutboundKeysForUserResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.OutboundKeysForUserResponse.toObject = function(includeInstance, msg) { var f, obj = { devicesMap: (f = msg.getDevicesMap()) ? f.toObject(includeInstance, proto.identity.auth.OutboundKeyInfo.toObject) : [] }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.OutboundKeysForUserResponse} */ proto.identity.auth.OutboundKeysForUserResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.OutboundKeysForUserResponse; return proto.identity.auth.OutboundKeysForUserResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.OutboundKeysForUserResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.OutboundKeysForUserResponse} */ proto.identity.auth.OutboundKeysForUserResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = msg.getDevicesMap(); reader.readMessage(value, function(message, reader) { jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.identity.auth.OutboundKeyInfo.deserializeBinaryFromReader, "", new proto.identity.auth.OutboundKeyInfo()); }); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.OutboundKeysForUserResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.OutboundKeysForUserResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.OutboundKeysForUserResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.OutboundKeysForUserResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getDevicesMap(true); if (f && f.getLength() > 0) { f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.identity.auth.OutboundKeyInfo.serializeBinaryToWriter); } }; /** * map devices = 1; * @param {boolean=} opt_noLazyCreate Do not create the map if * empty, instead returning `undefined` * @return {!jspb.Map} */ proto.identity.auth.OutboundKeysForUserResponse.prototype.getDevicesMap = function(opt_noLazyCreate) { return /** @type {!jspb.Map} */ ( jspb.Message.getMapField(this, 1, opt_noLazyCreate, proto.identity.auth.OutboundKeyInfo)); }; /** * Clears values from the map. The map will be non-null. * @return {!proto.identity.auth.OutboundKeysForUserResponse} returns this */ proto.identity.auth.OutboundKeysForUserResponse.prototype.clearDevicesMap = function() { this.getDevicesMap().clear(); return this; }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.OutboundKeysForUserRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.OutboundKeysForUserRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.OutboundKeysForUserRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.OutboundKeysForUserRequest.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, "") }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.OutboundKeysForUserRequest} */ proto.identity.auth.OutboundKeysForUserRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.OutboundKeysForUserRequest; return proto.identity.auth.OutboundKeysForUserRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.OutboundKeysForUserRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.OutboundKeysForUserRequest} */ proto.identity.auth.OutboundKeysForUserRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setUserId(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.OutboundKeysForUserRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.OutboundKeysForUserRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.OutboundKeysForUserRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.OutboundKeysForUserRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUserId(); if (f.length > 0) { writer.writeString( 1, f ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.auth.OutboundKeysForUserRequest.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.OutboundKeysForUserRequest} returns this */ proto.identity.auth.OutboundKeysForUserRequest.prototype.setUserId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.InboundKeyInfo.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.InboundKeyInfo.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.InboundKeyInfo} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.InboundKeyInfo.toObject = function(includeInstance, msg) { var f, obj = { identityInfo: (f = msg.getIdentityInfo()) && identity_unauth_pb.IdentityKeyInfo.toObject(includeInstance, f), contentPrekey: (f = msg.getContentPrekey()) && identity_unauth_pb.Prekey.toObject(includeInstance, f), notifPrekey: (f = msg.getNotifPrekey()) && identity_unauth_pb.Prekey.toObject(includeInstance, f) }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.InboundKeyInfo} */ proto.identity.auth.InboundKeyInfo.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.InboundKeyInfo; return proto.identity.auth.InboundKeyInfo.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.InboundKeyInfo} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.InboundKeyInfo} */ proto.identity.auth.InboundKeyInfo.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = new identity_unauth_pb.IdentityKeyInfo; reader.readMessage(value,identity_unauth_pb.IdentityKeyInfo.deserializeBinaryFromReader); msg.setIdentityInfo(value); break; case 2: var value = new identity_unauth_pb.Prekey; reader.readMessage(value,identity_unauth_pb.Prekey.deserializeBinaryFromReader); msg.setContentPrekey(value); break; case 3: var value = new identity_unauth_pb.Prekey; reader.readMessage(value,identity_unauth_pb.Prekey.deserializeBinaryFromReader); msg.setNotifPrekey(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.InboundKeyInfo.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.InboundKeyInfo.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.InboundKeyInfo} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.InboundKeyInfo.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getIdentityInfo(); if (f != null) { writer.writeMessage( 1, f, identity_unauth_pb.IdentityKeyInfo.serializeBinaryToWriter ); } f = message.getContentPrekey(); if (f != null) { writer.writeMessage( 2, f, identity_unauth_pb.Prekey.serializeBinaryToWriter ); } f = message.getNotifPrekey(); if (f != null) { writer.writeMessage( 3, f, identity_unauth_pb.Prekey.serializeBinaryToWriter ); } }; /** * optional identity.unauth.IdentityKeyInfo identity_info = 1; * @return {?proto.identity.unauth.IdentityKeyInfo} */ proto.identity.auth.InboundKeyInfo.prototype.getIdentityInfo = function() { return /** @type{?proto.identity.unauth.IdentityKeyInfo} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.IdentityKeyInfo, 1)); }; /** * @param {?proto.identity.unauth.IdentityKeyInfo|undefined} value * @return {!proto.identity.auth.InboundKeyInfo} returns this */ proto.identity.auth.InboundKeyInfo.prototype.setIdentityInfo = function(value) { return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.InboundKeyInfo} returns this */ proto.identity.auth.InboundKeyInfo.prototype.clearIdentityInfo = function() { return this.setIdentityInfo(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.InboundKeyInfo.prototype.hasIdentityInfo = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional identity.unauth.Prekey content_prekey = 2; * @return {?proto.identity.unauth.Prekey} */ proto.identity.auth.InboundKeyInfo.prototype.getContentPrekey = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.Prekey, 2)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.auth.InboundKeyInfo} returns this */ proto.identity.auth.InboundKeyInfo.prototype.setContentPrekey = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.InboundKeyInfo} returns this */ proto.identity.auth.InboundKeyInfo.prototype.clearContentPrekey = function() { return this.setContentPrekey(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.InboundKeyInfo.prototype.hasContentPrekey = function() { return jspb.Message.getField(this, 2) != null; }; /** * optional identity.unauth.Prekey notif_prekey = 3; * @return {?proto.identity.unauth.Prekey} */ proto.identity.auth.InboundKeyInfo.prototype.getNotifPrekey = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, identity_unauth_pb.Prekey, 3)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.auth.InboundKeyInfo} returns this */ proto.identity.auth.InboundKeyInfo.prototype.setNotifPrekey = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.InboundKeyInfo} returns this */ proto.identity.auth.InboundKeyInfo.prototype.clearNotifPrekey = function() { return this.setNotifPrekey(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.InboundKeyInfo.prototype.hasNotifPrekey = function() { return jspb.Message.getField(this, 3) != null; }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.InboundKeysForUserResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.InboundKeysForUserResponse.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.InboundKeysForUserResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.InboundKeysForUserResponse.toObject = function(includeInstance, msg) { var f, obj = { devicesMap: (f = msg.getDevicesMap()) ? f.toObject(includeInstance, proto.identity.auth.InboundKeyInfo.toObject) : [], identity: (f = msg.getIdentity()) && proto.identity.auth.Identity.toObject(includeInstance, f) }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.InboundKeysForUserResponse} */ proto.identity.auth.InboundKeysForUserResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.InboundKeysForUserResponse; return proto.identity.auth.InboundKeysForUserResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.InboundKeysForUserResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.InboundKeysForUserResponse} */ proto.identity.auth.InboundKeysForUserResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = msg.getDevicesMap(); reader.readMessage(value, function(message, reader) { jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.identity.auth.InboundKeyInfo.deserializeBinaryFromReader, "", new proto.identity.auth.InboundKeyInfo()); }); break; case 2: var value = new proto.identity.auth.Identity; reader.readMessage(value,proto.identity.auth.Identity.deserializeBinaryFromReader); msg.setIdentity(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.InboundKeysForUserResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.InboundKeysForUserResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.InboundKeysForUserResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.InboundKeysForUserResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getDevicesMap(true); if (f && f.getLength() > 0) { f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.identity.auth.InboundKeyInfo.serializeBinaryToWriter); } f = message.getIdentity(); if (f != null) { writer.writeMessage( 2, f, proto.identity.auth.Identity.serializeBinaryToWriter ); } }; /** * map devices = 1; * @param {boolean=} opt_noLazyCreate Do not create the map if * empty, instead returning `undefined` * @return {!jspb.Map} */ proto.identity.auth.InboundKeysForUserResponse.prototype.getDevicesMap = function(opt_noLazyCreate) { return /** @type {!jspb.Map} */ ( jspb.Message.getMapField(this, 1, opt_noLazyCreate, proto.identity.auth.InboundKeyInfo)); }; /** * Clears values from the map. The map will be non-null. * @return {!proto.identity.auth.InboundKeysForUserResponse} returns this */ proto.identity.auth.InboundKeysForUserResponse.prototype.clearDevicesMap = function() { this.getDevicesMap().clear(); return this; }; /** * optional Identity identity = 2; * @return {?proto.identity.auth.Identity} */ proto.identity.auth.InboundKeysForUserResponse.prototype.getIdentity = function() { return /** @type{?proto.identity.auth.Identity} */ ( jspb.Message.getWrapperField(this, proto.identity.auth.Identity, 2)); }; /** * @param {?proto.identity.auth.Identity|undefined} value * @return {!proto.identity.auth.InboundKeysForUserResponse} returns this */ proto.identity.auth.InboundKeysForUserResponse.prototype.setIdentity = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.auth.InboundKeysForUserResponse} returns this */ proto.identity.auth.InboundKeysForUserResponse.prototype.clearIdentity = function() { return this.setIdentity(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.InboundKeysForUserResponse.prototype.hasIdentity = function() { return jspb.Message.getField(this, 2) != null; }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.InboundKeysForUserRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.InboundKeysForUserRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.InboundKeysForUserRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.InboundKeysForUserRequest.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, "") }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.InboundKeysForUserRequest} */ proto.identity.auth.InboundKeysForUserRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.InboundKeysForUserRequest; return proto.identity.auth.InboundKeysForUserRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.InboundKeysForUserRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.InboundKeysForUserRequest} */ proto.identity.auth.InboundKeysForUserRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setUserId(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.InboundKeysForUserRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.InboundKeysForUserRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.InboundKeysForUserRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.InboundKeysForUserRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUserId(); if (f.length > 0) { writer.writeString( 1, f ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.auth.InboundKeysForUserRequest.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.InboundKeysForUserRequest} returns this */ proto.identity.auth.InboundKeysForUserRequest.prototype.setUserId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.UpdateUserPasswordStartRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.UpdateUserPasswordStartRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.UpdateUserPasswordStartRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateUserPasswordStartRequest.toObject = function(includeInstance, msg) { var f, obj = { opaqueRegistrationRequest: msg.getOpaqueRegistrationRequest_asB64() }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.UpdateUserPasswordStartRequest} */ proto.identity.auth.UpdateUserPasswordStartRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.UpdateUserPasswordStartRequest; return proto.identity.auth.UpdateUserPasswordStartRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.UpdateUserPasswordStartRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.UpdateUserPasswordStartRequest} */ proto.identity.auth.UpdateUserPasswordStartRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setOpaqueRegistrationRequest(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.UpdateUserPasswordStartRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.UpdateUserPasswordStartRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.UpdateUserPasswordStartRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateUserPasswordStartRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getOpaqueRegistrationRequest_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } }; /** * optional bytes opaque_registration_request = 1; * @return {string} */ proto.identity.auth.UpdateUserPasswordStartRequest.prototype.getOpaqueRegistrationRequest = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * optional bytes opaque_registration_request = 1; * This is a type-conversion wrapper around `getOpaqueRegistrationRequest()` * @return {string} */ proto.identity.auth.UpdateUserPasswordStartRequest.prototype.getOpaqueRegistrationRequest_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( this.getOpaqueRegistrationRequest())); }; /** * optional bytes opaque_registration_request = 1; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getOpaqueRegistrationRequest()` * @return {!Uint8Array} */ proto.identity.auth.UpdateUserPasswordStartRequest.prototype.getOpaqueRegistrationRequest_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationRequest())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.auth.UpdateUserPasswordStartRequest} returns this */ proto.identity.auth.UpdateUserPasswordStartRequest.prototype.setOpaqueRegistrationRequest = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.UpdateUserPasswordFinishRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.UpdateUserPasswordFinishRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateUserPasswordFinishRequest.toObject = function(includeInstance, msg) { var f, obj = { sessionId: jspb.Message.getFieldWithDefault(msg, 1, ""), opaqueRegistrationUpload: msg.getOpaqueRegistrationUpload_asB64() }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.UpdateUserPasswordFinishRequest} */ proto.identity.auth.UpdateUserPasswordFinishRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.UpdateUserPasswordFinishRequest; return proto.identity.auth.UpdateUserPasswordFinishRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.UpdateUserPasswordFinishRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.UpdateUserPasswordFinishRequest} */ proto.identity.auth.UpdateUserPasswordFinishRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setSessionId(value); break; case 2: var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setOpaqueRegistrationUpload(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.UpdateUserPasswordFinishRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.UpdateUserPasswordFinishRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateUserPasswordFinishRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getSessionId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getOpaqueRegistrationUpload_asU8(); if (f.length > 0) { writer.writeBytes( 2, f ); } }; /** * optional string session_id = 1; * @return {string} */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.getSessionId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.UpdateUserPasswordFinishRequest} returns this */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.setSessionId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_registration_upload = 2; * @return {string} */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.getOpaqueRegistrationUpload = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * optional bytes opaque_registration_upload = 2; * This is a type-conversion wrapper around `getOpaqueRegistrationUpload()` * @return {string} */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.getOpaqueRegistrationUpload_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( this.getOpaqueRegistrationUpload())); }; /** * optional bytes opaque_registration_upload = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getOpaqueRegistrationUpload()` * @return {!Uint8Array} */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.getOpaqueRegistrationUpload_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationUpload())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.auth.UpdateUserPasswordFinishRequest} returns this */ proto.identity.auth.UpdateUserPasswordFinishRequest.prototype.setOpaqueRegistrationUpload = function(value) { return jspb.Message.setProto3BytesField(this, 2, value); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.UpdateUserPasswordStartResponse.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.UpdateUserPasswordStartResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateUserPasswordStartResponse.toObject = function(includeInstance, msg) { var f, obj = { sessionId: jspb.Message.getFieldWithDefault(msg, 1, ""), opaqueRegistrationResponse: msg.getOpaqueRegistrationResponse_asB64() }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.UpdateUserPasswordStartResponse} */ proto.identity.auth.UpdateUserPasswordStartResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.UpdateUserPasswordStartResponse; return proto.identity.auth.UpdateUserPasswordStartResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.UpdateUserPasswordStartResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.UpdateUserPasswordStartResponse} */ proto.identity.auth.UpdateUserPasswordStartResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setSessionId(value); break; case 2: var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setOpaqueRegistrationResponse(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.UpdateUserPasswordStartResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.UpdateUserPasswordStartResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateUserPasswordStartResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getSessionId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getOpaqueRegistrationResponse_asU8(); if (f.length > 0) { writer.writeBytes( 2, f ); } }; /** * optional string session_id = 1; * @return {string} */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.getSessionId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.UpdateUserPasswordStartResponse} returns this */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.setSessionId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_registration_response = 2; * @return {string} */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.getOpaqueRegistrationResponse = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * optional bytes opaque_registration_response = 2; * This is a type-conversion wrapper around `getOpaqueRegistrationResponse()` * @return {string} */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.getOpaqueRegistrationResponse_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( this.getOpaqueRegistrationResponse())); }; /** * optional bytes opaque_registration_response = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getOpaqueRegistrationResponse()` * @return {!Uint8Array} */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.getOpaqueRegistrationResponse_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationResponse())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.auth.UpdateUserPasswordStartResponse} returns this */ proto.identity.auth.UpdateUserPasswordStartResponse.prototype.setOpaqueRegistrationResponse = function(value) { return jspb.Message.setProto3BytesField(this, 2, value); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.GetDeviceListRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.GetDeviceListRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.GetDeviceListRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.GetDeviceListRequest.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, ""), sinceTimestamp: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.GetDeviceListRequest} */ proto.identity.auth.GetDeviceListRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.GetDeviceListRequest; return proto.identity.auth.GetDeviceListRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.GetDeviceListRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.GetDeviceListRequest} */ proto.identity.auth.GetDeviceListRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setUserId(value); break; case 2: var value = /** @type {number} */ (reader.readInt64()); msg.setSinceTimestamp(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.GetDeviceListRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.GetDeviceListRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.GetDeviceListRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.GetDeviceListRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUserId(); if (f.length > 0) { writer.writeString( 1, f ); } f = /** @type {number} */ (jspb.Message.getField(message, 2)); if (f != null) { writer.writeInt64( 2, f ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.auth.GetDeviceListRequest.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.GetDeviceListRequest} returns this */ proto.identity.auth.GetDeviceListRequest.prototype.setUserId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional int64 since_timestamp = 2; * @return {number} */ proto.identity.auth.GetDeviceListRequest.prototype.getSinceTimestamp = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** * @param {number} value * @return {!proto.identity.auth.GetDeviceListRequest} returns this */ proto.identity.auth.GetDeviceListRequest.prototype.setSinceTimestamp = function(value) { return jspb.Message.setField(this, 2, value); }; /** * Clears the field making it undefined. * @return {!proto.identity.auth.GetDeviceListRequest} returns this */ proto.identity.auth.GetDeviceListRequest.prototype.clearSinceTimestamp = function() { return jspb.Message.setField(this, 2, undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.auth.GetDeviceListRequest.prototype.hasSinceTimestamp = function() { return jspb.Message.getField(this, 2) != null; }; /** * List of repeated fields within this message type. * @private {!Array} * @const */ proto.identity.auth.GetDeviceListResponse.repeatedFields_ = [1]; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.GetDeviceListResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.GetDeviceListResponse.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.GetDeviceListResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.GetDeviceListResponse.toObject = function(includeInstance, msg) { var f, obj = { deviceListUpdatesList: (f = jspb.Message.getRepeatedField(msg, 1)) == null ? undefined : f }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.GetDeviceListResponse} */ proto.identity.auth.GetDeviceListResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.GetDeviceListResponse; return proto.identity.auth.GetDeviceListResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.GetDeviceListResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.GetDeviceListResponse} */ proto.identity.auth.GetDeviceListResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.addDeviceListUpdates(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.GetDeviceListResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.GetDeviceListResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.GetDeviceListResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.GetDeviceListResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getDeviceListUpdatesList(); if (f.length > 0) { writer.writeRepeatedString( 1, f ); } }; /** * repeated string device_list_updates = 1; * @return {!Array} */ proto.identity.auth.GetDeviceListResponse.prototype.getDeviceListUpdatesList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 1)); }; /** * @param {!Array} value * @return {!proto.identity.auth.GetDeviceListResponse} returns this */ proto.identity.auth.GetDeviceListResponse.prototype.setDeviceListUpdatesList = function(value) { return jspb.Message.setField(this, 1, value || []); }; /** * @param {string} value * @param {number=} opt_index * @return {!proto.identity.auth.GetDeviceListResponse} returns this */ proto.identity.auth.GetDeviceListResponse.prototype.addDeviceListUpdates = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 1, value, opt_index); }; /** * Clears the list making it empty but non-null. * @return {!proto.identity.auth.GetDeviceListResponse} returns this */ proto.identity.auth.GetDeviceListResponse.prototype.clearDeviceListUpdatesList = function() { return this.setDeviceListUpdatesList([]); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.UpdateDeviceListRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.UpdateDeviceListRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.UpdateDeviceListRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateDeviceListRequest.toObject = function(includeInstance, msg) { var f, obj = { newDeviceList: jspb.Message.getFieldWithDefault(msg, 1, "") }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.UpdateDeviceListRequest} */ proto.identity.auth.UpdateDeviceListRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.UpdateDeviceListRequest; return proto.identity.auth.UpdateDeviceListRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.UpdateDeviceListRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.UpdateDeviceListRequest} */ proto.identity.auth.UpdateDeviceListRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setNewDeviceList(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.UpdateDeviceListRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.UpdateDeviceListRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.UpdateDeviceListRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.UpdateDeviceListRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getNewDeviceList(); if (f.length > 0) { writer.writeString( 1, f ); } }; /** * optional string new_device_list = 1; * @return {string} */ proto.identity.auth.UpdateDeviceListRequest.prototype.getNewDeviceList = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.UpdateDeviceListRequest} returns this */ proto.identity.auth.UpdateDeviceListRequest.prototype.setNewDeviceList = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. * Field names that are reserved in JavaScript and will be renamed to pb_name. * Optional fields that are not set will be set to undefined. * To access a reserved field use, foo.pb_, eg, foo.pb_default. * For the list of reserved names please see: * net/proto2/compiler/js/internal/generator.cc#kKeyword. * @param {boolean=} opt_includeInstance Deprecated. whether to include the * JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @return {!Object} */ proto.identity.auth.LinkFarcasterAccountRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.auth.LinkFarcasterAccountRequest.toObject(opt_includeInstance, this); }; /** * Static version of the {@see toObject} method. * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration * @param {!proto.identity.auth.LinkFarcasterAccountRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.LinkFarcasterAccountRequest.toObject = function(includeInstance, msg) { var f, obj = { farcasterId: jspb.Message.getFieldWithDefault(msg, 1, "") }; if (includeInstance) { obj.$jspbMessageInstance = msg; } return obj; }; } /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. * @return {!proto.identity.auth.LinkFarcasterAccountRequest} */ proto.identity.auth.LinkFarcasterAccountRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.auth.LinkFarcasterAccountRequest; return proto.identity.auth.LinkFarcasterAccountRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.auth.LinkFarcasterAccountRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.auth.LinkFarcasterAccountRequest} */ proto.identity.auth.LinkFarcasterAccountRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {string} */ (reader.readString()); msg.setFarcasterId(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.auth.LinkFarcasterAccountRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.auth.LinkFarcasterAccountRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. * @param {!proto.identity.auth.LinkFarcasterAccountRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.auth.LinkFarcasterAccountRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getFarcasterId(); if (f.length > 0) { writer.writeString( 1, f ); } }; /** * optional string farcaster_id = 1; * @return {string} */ proto.identity.auth.LinkFarcasterAccountRequest.prototype.getFarcasterId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.auth.LinkFarcasterAccountRequest} returns this */ proto.identity.auth.LinkFarcasterAccountRequest.prototype.setFarcasterId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.identity.auth.UserIdentityRequest.prototype.toObject = function(opt_includeInstance) { + return proto.identity.auth.UserIdentityRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.identity.auth.UserIdentityRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.auth.UserIdentityRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.identity.auth.UserIdentityRequest} + */ +proto.identity.auth.UserIdentityRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.identity.auth.UserIdentityRequest; + return proto.identity.auth.UserIdentityRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.identity.auth.UserIdentityRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.identity.auth.UserIdentityRequest} + */ +proto.identity.auth.UserIdentityRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUserId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.identity.auth.UserIdentityRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.identity.auth.UserIdentityRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.identity.auth.UserIdentityRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.auth.UserIdentityRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.identity.auth.UserIdentityRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.auth.UserIdentityRequest} returns this + */ +proto.identity.auth.UserIdentityRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.identity.auth.UserIdentityResponse.prototype.toObject = function(opt_includeInstance) { + return proto.identity.auth.UserIdentityResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.identity.auth.UserIdentityResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.auth.UserIdentityResponse.toObject = function(includeInstance, msg) { + var f, obj = { + identity: (f = msg.getIdentity()) && proto.identity.auth.Identity.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.identity.auth.UserIdentityResponse} + */ +proto.identity.auth.UserIdentityResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.identity.auth.UserIdentityResponse; + return proto.identity.auth.UserIdentityResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.identity.auth.UserIdentityResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.identity.auth.UserIdentityResponse} + */ +proto.identity.auth.UserIdentityResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.identity.auth.Identity; + reader.readMessage(value,proto.identity.auth.Identity.deserializeBinaryFromReader); + msg.setIdentity(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.identity.auth.UserIdentityResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.identity.auth.UserIdentityResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.identity.auth.UserIdentityResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.auth.UserIdentityResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getIdentity(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.identity.auth.Identity.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Identity identity = 1; + * @return {?proto.identity.auth.Identity} + */ +proto.identity.auth.UserIdentityResponse.prototype.getIdentity = function() { + return /** @type{?proto.identity.auth.Identity} */ ( + jspb.Message.getWrapperField(this, proto.identity.auth.Identity, 1)); +}; + + +/** + * @param {?proto.identity.auth.Identity|undefined} value + * @return {!proto.identity.auth.UserIdentityResponse} returns this +*/ +proto.identity.auth.UserIdentityResponse.prototype.setIdentity = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.identity.auth.UserIdentityResponse} returns this + */ +proto.identity.auth.UserIdentityResponse.prototype.clearIdentity = function() { + return this.setIdentity(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.identity.auth.UserIdentityResponse.prototype.hasIdentity = function() { + return jspb.Message.getField(this, 1) != null; +}; + + goog.object.extend(exports, proto.identity.auth); diff --git a/web/protobufs/identity-auth-structs.cjs.flow b/web/protobufs/identity-auth-structs.cjs.flow index ba8f68465..4f5f46960 100644 --- a/web/protobufs/identity-auth-structs.cjs.flow +++ b/web/protobufs/identity-auth-structs.cjs.flow @@ -1,406 +1,440 @@ // @flow import { Message, BinaryWriter, BinaryReader, Map as ProtoMap, } from 'google-protobuf'; import * as identityStructs from './identity-unauth-structs.cjs'; declare export class EthereumIdentity extends Message { getWalletAddress(): string; setWalletAddress(value: string): EthereumIdentity; getSocialProof(): string; setSocialProof(value: string): EthereumIdentity; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): EthereumIdentityObject; static toObject(includeInstance: boolean, msg: EthereumIdentity): EthereumIdentityObject; static serializeBinaryToWriter(message: EthereumIdentity, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): EthereumIdentity; static deserializeBinaryFromReader(message: EthereumIdentity, reader: BinaryReader): EthereumIdentity; } export type EthereumIdentityObject = { walletAddress: string, socialProof: string, } export type IdentityInfoCase = 0 | 1 | 2; declare export class Identity extends Message { getUsername(): string; setUsername(value: string): Identity; getEthIdentity(): EthereumIdentity | void; setEthIdentity(value?: EthereumIdentity): Identity; hasEthIdentity(): boolean; clearEthIdentity(): Identity; getIdentityInfoCase(): IdentityInfoCase; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): IdentityObject; static toObject(includeInstance: boolean, msg: Identity): IdentityObject; static serializeBinaryToWriter(message: Identity, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Identity; static deserializeBinaryFromReader(message: Identity, reader: BinaryReader): Identity; } export type IdentityObject = { username: string, ethIdentity: ?EthereumIdentityObject, } declare export class UploadOneTimeKeysRequest extends Message { getContentOneTimePrekeysList(): Array; setContentOneTimePrekeysList(value: Array): UploadOneTimeKeysRequest; clearContentOneTimePrekeysList(): UploadOneTimeKeysRequest; addContentOneTimePrekeys(value: string, index?: number): UploadOneTimeKeysRequest; getNotifOneTimePrekeysList(): Array; setNotifOneTimePrekeysList(value: Array): UploadOneTimeKeysRequest; clearNotifOneTimePrekeysList(): UploadOneTimeKeysRequest; addNotifOneTimePrekeys(value: string, index?: number): UploadOneTimeKeysRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UploadOneTimeKeysRequestObject; static toObject(includeInstance: boolean, msg: UploadOneTimeKeysRequest): UploadOneTimeKeysRequestObject; static serializeBinaryToWriter(message: UploadOneTimeKeysRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UploadOneTimeKeysRequest; static deserializeBinaryFromReader(message: UploadOneTimeKeysRequest, reader: BinaryReader): UploadOneTimeKeysRequest; } export type UploadOneTimeKeysRequestObject = { contentOneTimePrekeysList: Array, notifOneTimePrekeysList: Array, }; declare export class RefreshUserPrekeysRequest extends Message { getNewContentPrekeys(): identityStructs.Prekey | void; setNewContentPrekeys(value?: identityStructs.Prekey): RefreshUserPrekeysRequest; hasNewContentPrekeys(): boolean; clearNewContentPrekeys(): RefreshUserPrekeysRequest; getNewNotifPrekeys(): identityStructs.Prekey | void; setNewNotifPrekeys(value?: identityStructs.Prekey): RefreshUserPrekeysRequest; hasNewNotifPrekeys(): boolean; clearNewNotifPrekeys(): RefreshUserPrekeysRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RefreshUserPrekeysRequestObject; static toObject(includeInstance: boolean, msg: RefreshUserPrekeysRequest): RefreshUserPrekeysRequestObject; static serializeBinaryToWriter(message: RefreshUserPrekeysRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RefreshUserPrekeysRequest; static deserializeBinaryFromReader(message: RefreshUserPrekeysRequest, reader: BinaryReader): RefreshUserPrekeysRequest; } export type RefreshUserPrekeysRequestObject = { newContentPrekeys?: identityStructs.PrekeyObject, newNotifPrekeys?: identityStructs.PrekeyObject, } declare export class OutboundKeyInfo extends Message { getIdentityInfo(): identityStructs.IdentityKeyInfo | void; setIdentityInfo(value?: identityStructs.IdentityKeyInfo): OutboundKeyInfo; hasIdentityInfo(): boolean; clearIdentityInfo(): OutboundKeyInfo; getContentPrekey(): identityStructs.Prekey | void; setContentPrekey(value?: identityStructs.Prekey): OutboundKeyInfo; hasContentPrekey(): boolean; clearContentPrekey(): OutboundKeyInfo; getNotifPrekey(): identityStructs.Prekey | void; setNotifPrekey(value?: identityStructs.Prekey): OutboundKeyInfo; hasNotifPrekey(): boolean; clearNotifPrekey(): OutboundKeyInfo; getOneTimeContentPrekey(): string; setOneTimeContentPrekey(value: string): OutboundKeyInfo; hasOneTimeContentPrekey(): boolean; clearOneTimeContentPrekey(): OutboundKeyInfo; getOneTimeNotifPrekey(): string; setOneTimeNotifPrekey(value: string): OutboundKeyInfo; hasOneTimeNotifPrekey(): boolean; clearOneTimeNotifPrekey(): OutboundKeyInfo; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): OutboundKeyInfoObject; static toObject(includeInstance: boolean, msg: OutboundKeyInfo): OutboundKeyInfoObject; static serializeBinaryToWriter(message: OutboundKeyInfo, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): OutboundKeyInfo; static deserializeBinaryFromReader(message: OutboundKeyInfo, reader: BinaryReader): OutboundKeyInfo; } export type OutboundKeyInfoObject = { identityInfo?: identityStructs.IdentityKeyInfoObject, contentPrekey?: identityStructs.PrekeyObject, notifPrekey?: identityStructs.PrekeyObject, oneTimeContentPrekey?: string, oneTimeNotifPrekey?: string, }; declare export class KeyserverKeysResponse extends Message { getKeyserverInfo(): OutboundKeyInfo | void; setKeyserverInfo(value?: OutboundKeyInfo): KeyserverKeysResponse; hasKeyserverInfo(): boolean; clearKeyserverInfo(): KeyserverKeysResponse; getIdentity(): Identity | void; setIdentity(value?: Identity): KeyserverKeysResponse; hasIdentity(): boolean; clearIdentity(): KeyserverKeysResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): KeyserverKeysResponseObject; static toObject(includeInstance: boolean, msg: KeyserverKeysResponse): KeyserverKeysResponseObject; static serializeBinaryToWriter(message: KeyserverKeysResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): KeyserverKeysResponse; static deserializeBinaryFromReader(message: KeyserverKeysResponse, reader: BinaryReader): KeyserverKeysResponse; } export type KeyserverKeysResponseObject = { keyserverInfo?: OutboundKeyInfoObject, identity: ?IdentityObject, }; declare export class OutboundKeysForUserResponse extends Message { getDevicesMap(): ProtoMap; clearDevicesMap(): OutboundKeysForUserResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): OutboundKeysForUserResponseObject; static toObject(includeInstance: boolean, msg: OutboundKeysForUserResponse): OutboundKeysForUserResponseObject; static serializeBinaryToWriter(message: OutboundKeysForUserResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): OutboundKeysForUserResponse; static deserializeBinaryFromReader(message: OutboundKeysForUserResponse, reader: BinaryReader): OutboundKeysForUserResponse; } export type OutboundKeysForUserResponseObject = { devicesMap: Array<[string, OutboundKeyInfoObject]>, }; declare export class OutboundKeysForUserRequest extends Message { getUserId(): string; setUserId(value: string): OutboundKeysForUserRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): OutboundKeysForUserRequestObject; static toObject(includeInstance: boolean, msg: OutboundKeysForUserRequest): OutboundKeysForUserRequestObject; static serializeBinaryToWriter(message: OutboundKeysForUserRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): OutboundKeysForUserRequest; static deserializeBinaryFromReader(message: OutboundKeysForUserRequest, reader: BinaryReader): OutboundKeysForUserRequest; } export type OutboundKeysForUserRequestObject = { userId: string, }; declare export class InboundKeyInfo extends Message { getIdentityInfo(): identityStructs.IdentityKeyInfo | void; setIdentityInfo(value?: identityStructs.IdentityKeyInfo): InboundKeyInfo; hasIdentityInfo(): boolean; clearIdentityInfo(): InboundKeyInfo; getContentPrekey(): identityStructs.Prekey | void; setContentPrekey(value?: identityStructs.Prekey): InboundKeyInfo; hasContentPrekey(): boolean; clearContentPrekey(): InboundKeyInfo; getNotifPrekey(): identityStructs.Prekey | void; setNotifPrekey(value?: identityStructs.Prekey): InboundKeyInfo; hasNotifPrekey(): boolean; clearNotifPrekey(): InboundKeyInfo; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): InboundKeyInfoObject; static toObject(includeInstance: boolean, msg: InboundKeyInfo): InboundKeyInfoObject; static serializeBinaryToWriter(message: InboundKeyInfo, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): InboundKeyInfo; static deserializeBinaryFromReader(message: InboundKeyInfo, reader: BinaryReader): InboundKeyInfo; } export type InboundKeyInfoObject = { identityInfo?: identityStructs.IdentityKeyInfoObject, contentPrekey?: identityStructs.PrekeyObject, notifPrekey?: identityStructs.PrekeyObject, }; declare export class InboundKeysForUserResponse extends Message { getDevicesMap(): ProtoMap; clearDevicesMap(): InboundKeysForUserResponse; getIdentity(): Identity | void; setIdentity(value?: Identity): InboundKeysForUserResponse; hasIdentity(): boolean; clearIdentity(): InboundKeysForUserResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): InboundKeysForUserResponseObject; static toObject(includeInstance: boolean, msg: InboundKeysForUserResponse): InboundKeysForUserResponseObject; static serializeBinaryToWriter(message: InboundKeysForUserResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): InboundKeysForUserResponse; static deserializeBinaryFromReader(message: InboundKeysForUserResponse, reader: BinaryReader): InboundKeysForUserResponse; } export type InboundKeysForUserResponseObject = { devicesMap: Array<[string, InboundKeyInfoObject]>, identity: ?IdentityObject, } declare export class InboundKeysForUserRequest extends Message { getUserId(): string; setUserId(value: string): InboundKeysForUserRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): InboundKeysForUserRequestObject; static toObject(includeInstance: boolean, msg: InboundKeysForUserRequest): InboundKeysForUserRequestObject; static serializeBinaryToWriter(message: InboundKeysForUserRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): InboundKeysForUserRequest; static deserializeBinaryFromReader(message: InboundKeysForUserRequest, reader: BinaryReader): InboundKeysForUserRequest; } export type InboundKeysForUserRequestObject = { userId: string, }; declare export class UpdateUserPasswordStartRequest extends Message { getOpaqueRegistrationRequest(): Uint8Array | string; getOpaqueRegistrationRequest_asU8(): Uint8Array; getOpaqueRegistrationRequest_asB64(): string; setOpaqueRegistrationRequest(value: Uint8Array | string): UpdateUserPasswordStartRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateUserPasswordStartRequestObject; static toObject(includeInstance: boolean, msg: UpdateUserPasswordStartRequest): UpdateUserPasswordStartRequestObject; static serializeBinaryToWriter(message: UpdateUserPasswordStartRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateUserPasswordStartRequest; static deserializeBinaryFromReader(message: UpdateUserPasswordStartRequest, reader: BinaryReader): UpdateUserPasswordStartRequest; } export type UpdateUserPasswordStartRequestObject = { opaqueRegistrationRequest: Uint8Array | string, }; declare export class UpdateUserPasswordFinishRequest extends Message { getSessionId(): string; setSessionId(value: string): UpdateUserPasswordFinishRequest; getOpaqueRegistrationUpload(): Uint8Array | string; getOpaqueRegistrationUpload_asU8(): Uint8Array; getOpaqueRegistrationUpload_asB64(): string; setOpaqueRegistrationUpload(value: Uint8Array | string): UpdateUserPasswordFinishRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateUserPasswordFinishRequestObject; static toObject(includeInstance: boolean, msg: UpdateUserPasswordFinishRequest): UpdateUserPasswordFinishRequestObject; static serializeBinaryToWriter(message: UpdateUserPasswordFinishRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateUserPasswordFinishRequest; static deserializeBinaryFromReader(message: UpdateUserPasswordFinishRequest, reader: BinaryReader): UpdateUserPasswordFinishRequest; } export type UpdateUserPasswordFinishRequestObject = { sessionId: string, opaqueRegistrationUpload: Uint8Array | string, }; declare export class UpdateUserPasswordStartResponse extends Message { getSessionId(): string; setSessionId(value: string): UpdateUserPasswordStartResponse; getOpaqueRegistrationResponse(): Uint8Array | string; getOpaqueRegistrationResponse_asU8(): Uint8Array; getOpaqueRegistrationResponse_asB64(): string; setOpaqueRegistrationResponse(value: Uint8Array | string): UpdateUserPasswordStartResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateUserPasswordStartResponseObject; static toObject(includeInstance: boolean, msg: UpdateUserPasswordStartResponse): UpdateUserPasswordStartResponseObject; static serializeBinaryToWriter(message: UpdateUserPasswordStartResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateUserPasswordStartResponse; static deserializeBinaryFromReader(message: UpdateUserPasswordStartResponse, reader: BinaryReader): UpdateUserPasswordStartResponse; } export type UpdateUserPasswordStartResponseObject = { sessionId: string, opaqueRegistrationResponse: Uint8Array | string, }; export type SinceTimestampCase = 0 | 2; declare export class GetDeviceListRequest extends Message { getUserId(): string; setUserId(value: string): GetDeviceListRequest; getSinceTimestamp(): number; setSinceTimestamp(value: number): GetDeviceListRequest; hasSinceTimestamp(): boolean; clearSinceTimestamp(): GetDeviceListRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetDeviceListRequestObject; static toObject(includeInstance: boolean, msg: GetDeviceListRequest): GetDeviceListRequestObject; static serializeBinaryToWriter(message: GetDeviceListRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GetDeviceListRequest; static deserializeBinaryFromReader(message: GetDeviceListRequest, reader: BinaryReader): GetDeviceListRequest; } export type GetDeviceListRequestObject = { userId: string, sinceTimestamp?: number, } declare export class GetDeviceListResponse extends Message { getDeviceListUpdatesList(): Array; setDeviceListUpdatesList(value: Array): GetDeviceListResponse; clearDeviceListUpdatesList(): GetDeviceListResponse; addDeviceListUpdates(value: string, index?: number): GetDeviceListResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetDeviceListResponseObject; static toObject(includeInstance: boolean, msg: GetDeviceListResponse): GetDeviceListResponseObject; static serializeBinaryToWriter(message: GetDeviceListResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GetDeviceListResponse; static deserializeBinaryFromReader(message: GetDeviceListResponse, reader: BinaryReader): GetDeviceListResponse; } export type GetDeviceListResponseObject = { deviceListUpdatesList: Array, } declare export class UpdateDeviceListRequest extends Message { getNewDeviceList(): string; setNewDeviceList(value: string): UpdateDeviceListRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): UpdateDeviceListRequestObject; static toObject(includeInstance: boolean, msg: UpdateDeviceListRequest): UpdateDeviceListRequestObject; static serializeBinaryToWriter(message: UpdateDeviceListRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): UpdateDeviceListRequest; static deserializeBinaryFromReader(message: UpdateDeviceListRequest, reader: BinaryReader): UpdateDeviceListRequest; } export type UpdateDeviceListRequestObject = { newDeviceList: string, } declare export class LinkFarcasterAccountRequest extends Message { getFarcasterId(): string; setFarcasterId(value: string): LinkFarcasterAccountRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): LinkFarcasterAccountRequestObject; static toObject(includeInstance: boolean, msg: LinkFarcasterAccountRequest): LinkFarcasterAccountRequestObject; static serializeBinaryToWriter(message: LinkFarcasterAccountRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): LinkFarcasterAccountRequest; static deserializeBinaryFromReader(message: LinkFarcasterAccountRequest, reader: BinaryReader): LinkFarcasterAccountRequest; } export type LinkFarcasterAccountRequestObject = { farcasterId: string, } + +declare export class UserIdentityRequest extends Message { + getUserId(): string; + setUserId(value: string): UserIdentityRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserIdentityRequestObject; + static toObject(includeInstance: boolean, msg: UserIdentityRequest): UserIdentityRequestObject; + static serializeBinaryToWriter(message: UserIdentityRequest, writer: BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserIdentityRequest; + static deserializeBinaryFromReader(message: UserIdentityRequest, reader: BinaryReader): UserIdentityRequest; +} + +export type UserIdentityRequestObject = { + userId: string, +} + +declare export class UserIdentityResponse extends Message { + getIdentity(): Identity | void; + setIdentity(value?: Identity): UserIdentityResponse; + hasIdentity(): boolean; + clearIdentity(): UserIdentityResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UserIdentityResponseObject; + static toObject(includeInstance: boolean, msg: UserIdentityResponse): UserIdentityResponseObject; + static serializeBinaryToWriter(message: UserIdentityResponse, writer: BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UserIdentityResponse; + static deserializeBinaryFromReader(message: UserIdentityResponse, reader: BinaryReader): UserIdentityResponse; +} + +export type UserIdentityResponseObject = { + identity: ?IdentityObject, +}