diff --git a/keyserver/addons/rust-node-addon/src/identity_client/register_user.rs b/keyserver/addons/rust-node-addon/src/identity_client/register_user.rs index e9bf6566d..b6d21ab06 100644 --- a/keyserver/addons/rust-node-addon/src/identity_client/register_user.rs +++ b/keyserver/addons/rust-node-addon/src/identity_client/register_user.rs @@ -1,85 +1,86 @@ use super::*; use tracing::{debug, warn}; #[napi] #[instrument(skip_all)] pub async fn register_user( username: String, password: String, signed_identity_keys_blob: SignedIdentityKeysBlob, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, ) -> Result { debug!("Attempting to register user: {}", username); // Set up the gRPC client that will be used to talk to the Identity service let mut identity_client = get_identity_client().await?; // Start OPAQUE registration and send initial registration request let mut opaque_registration = comm_opaque2::client::Registration::new(); let opaque_registration_request = opaque_registration .start(&password) .map_err(|_| Error::from_status(Status::GenericFailure))?; let device_key_upload = DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: signed_identity_keys_blob.payload, payload_signature: signed_identity_keys_blob.signature, social_proof: None, }), content_upload: Some(Prekey { prekey: content_prekey, prekey_signature: content_prekey_signature, }), notif_upload: Some(Prekey { prekey: notif_prekey, prekey_signature: notif_prekey_signature, }), one_time_content_prekeys: content_one_time_keys, one_time_notif_prekeys: notif_one_time_keys, device_type: DeviceType::Keyserver.into(), }; let registration_start_request = RegistrationStartRequest { opaque_registration_request, username, device_key_upload: Some(device_key_upload), + farcaster_id: None, }; // Finish OPAQUE registration and send final registration request let response = identity_client .register_password_user_start(registration_start_request) .await .map_err(handle_grpc_error)?; debug!("Received registration start response"); let registration_start_response = response.into_inner(); let opaque_registration_upload = opaque_registration .finish( &password, ®istration_start_response.opaque_registration_response, ) .map_err(|_| Error::from_status(Status::GenericFailure))?; let registration_finish_request = RegistrationFinishRequest { session_id: registration_start_response.session_id, opaque_registration_upload, }; let registration_response = identity_client .register_password_user_finish(registration_finish_request) .await .map_err(handle_grpc_error)? .into_inner(); let user_info = UserLoginInfo { user_id: registration_response.user_id, access_token: registration_response.access_token, }; Ok(user_info) } diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs index e571d3070..b3585fd3d 100644 --- a/native/native_rust_library/src/lib.rs +++ b/native/native_rust_library/src/lib.rs @@ -1,1497 +1,1499 @@ use backup::ffi::*; use comm_opaque2::client::{Login, Registration}; use comm_opaque2::grpc::opaque_error_to_grpc_status as handle_error; use exact_user_search::{ find_user_id_for_username, find_user_id_for_wallet_address, }; use ffi::{bool_callback, string_callback, void_callback}; use future_manager::ffi::*; use grpc_clients::identity::protos::auth::{ GetDeviceListRequest, UpdateDeviceListRequest, }; use grpc_clients::identity::protos::authenticated::{ InboundKeyInfo, InboundKeysForUserRequest, KeyserverKeysResponse, OutboundKeyInfo, OutboundKeysForUserRequest, RefreshUserPrekeysRequest, UpdateUserPasswordFinishRequest, UpdateUserPasswordStartRequest, UploadOneTimeKeysRequest, }; use grpc_clients::identity::protos::unauth::{ AuthResponse, DeviceKeyUpload, DeviceType, Empty, IdentityKeyInfo, OpaqueLoginFinishRequest, OpaqueLoginStartRequest, Prekey, RegistrationFinishRequest, RegistrationStartRequest, SecondaryDeviceKeysUploadRequest, WalletAuthRequest, }; use grpc_clients::identity::{get_auth_client, get_unauthenticated_client}; use lazy_static::lazy_static; use serde::Serialize; use std::sync::Arc; use tokio::runtime::{Builder, Runtime}; use tonic::Status; use tracing::instrument; use wallet_registration::register_wallet_user; mod argon2_tools; mod backup; mod constants; mod exact_user_search; mod future_manager; mod wallet_registration; use argon2_tools::compute_backup_key_str; mod generated { // We get the CODE_VERSION from this generated file include!(concat!(env!("OUT_DIR"), "/version.rs")); // We get the IDENTITY_SOCKET_ADDR from this generated file include!(concat!(env!("OUT_DIR"), "/socket_config.rs")); } pub use generated::CODE_VERSION; pub use generated::{BACKUP_SOCKET_ADDR, IDENTITY_SOCKET_ADDR}; #[cfg(not(target_os = "android"))] pub const DEVICE_TYPE: DeviceType = DeviceType::Ios; #[cfg(target_os = "android")] pub const DEVICE_TYPE: DeviceType = DeviceType::Android; lazy_static! { static ref RUNTIME: Arc = Arc::new(Builder::new_multi_thread().enable_all().build().unwrap()); } #[cxx::bridge] mod ffi { extern "Rust" { #[cxx_name = "identityRegisterPasswordUser"] fn register_password_user( username: String, password: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ); #[cxx_name = "identityLogInPasswordUser"] fn log_in_password_user( username: String, password: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, promise_id: u32, ); #[cxx_name = "identityRegisterWalletUser"] fn register_wallet_user( siwe_message: String, siwe_signature: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ); #[cxx_name = "identityLogInWalletUser"] fn log_in_wallet_user( siwe_message: String, siwe_signature: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, promise_id: u32, ); #[cxx_name = "identityUpdateUserPassword"] fn update_user_password( user_id: String, device_id: String, access_token: String, password: String, promise_id: u32, ); #[cxx_name = "identityDeleteUser"] fn delete_user( user_id: String, device_id: String, access_token: String, promise_id: u32, ); #[cxx_name = "identityLogOut"] fn log_out( user_id: String, device_id: String, access_token: String, promise_id: u32, ); #[cxx_name = "identityGetOutboundKeysForUser"] fn get_outbound_keys_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, promise_id: u32, ); #[cxx_name = "identityGetInboundKeysForUser"] fn get_inbound_keys_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, promise_id: u32, ); #[cxx_name = "identityRefreshUserPrekeys"] fn refresh_user_prekeys( auth_user_id: String, auth_device_id: String, auth_access_token: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, promise_id: u32, ); #[cxx_name = "identityGenerateNonce"] fn generate_nonce(promise_id: u32); #[cxx_name = "identityVersionSupported"] fn version_supported(promise_id: u32); #[cxx_name = "identityUploadOneTimeKeys"] fn upload_one_time_keys( auth_user_id: String, auth_device_id: String, auth_access_token: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ); #[cxx_name = "identityGetKeyserverKeys"] fn get_keyserver_keys( user_id: String, device_id: String, access_token: String, keyserver_id: String, promise_id: u32, ); #[cxx_name = "identityGetDeviceListForUser"] fn get_device_list_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, since_timestamp: i64, promise_id: u32, ); #[cxx_name = "identityUpdateDeviceList"] fn update_device_list( auth_user_id: String, auth_device_id: String, auth_access_token: String, update_payload: String, promise_id: u32, ); #[cxx_name = "identityUploadSecondaryDeviceKeysAndLogIn"] fn upload_secondary_device_keys_and_log_in( user_id: String, challenge_response: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ); #[cxx_name = "identityFindUserIDForWalletAddress"] fn find_user_id_for_wallet_address(wallet_address: String, promise_id: u32); #[cxx_name = "identityFindUserIDForUsername"] fn find_user_id_for_username(username: String, promise_id: u32); // Argon2 #[cxx_name = "compute_backup_key"] fn compute_backup_key_str( password: &str, backup_id: &str, ) -> Result<[u8; 32]>; } unsafe extern "C++" { include!("RustCallback.h"); #[namespace = "comm"] #[cxx_name = "stringCallback"] fn string_callback(error: String, promise_id: u32, ret: String); #[namespace = "comm"] #[cxx_name = "voidCallback"] fn void_callback(error: String, promise_id: u32); #[namespace = "comm"] #[cxx_name = "boolCallback"] fn bool_callback(error: String, promise_id: u32, ret: bool); } // AES cryptography #[namespace = "comm"] unsafe extern "C++" { include!("RustAESCrypto.h"); #[allow(unused)] #[cxx_name = "aesGenerateKey"] fn generate_key(buffer: &mut [u8]) -> Result<()>; /// The first two argument aren't mutated but creation of Java ByteBuffer /// requires the underlying bytes to be mutable. #[allow(unused)] #[cxx_name = "aesEncrypt"] fn encrypt( key: &mut [u8], plaintext: &mut [u8], sealed_data: &mut [u8], ) -> Result<()>; /// The first two argument aren't mutated but creation of Java ByteBuffer /// requires the underlying bytes to be mutable. #[allow(unused)] #[cxx_name = "aesDecrypt"] fn decrypt( key: &mut [u8], sealed_data: &mut [u8], plaintext: &mut [u8], ) -> Result<()>; } // Comm Services Auth Metadata Emission #[namespace = "comm"] unsafe extern "C++" { include!("RustCSAMetadataEmitter.h"); #[allow(unused)] #[cxx_name = "sendAuthMetadataToJS"] fn send_auth_metadata_to_js( access_token: String, user_id: String, ) -> Result<()>; } // Backup extern "Rust" { #[cxx_name = "startBackupHandler"] fn start_backup_handler() -> Result<()>; #[cxx_name = "stopBackupHandler"] fn stop_backup_handler() -> Result<()>; #[cxx_name = "triggerBackupFileUpload"] fn trigger_backup_file_upload(); #[cxx_name = "createBackup"] fn create_backup( backup_id: String, backup_secret: String, pickle_key: String, pickled_account: String, promise_id: u32, ); #[cxx_name = "restoreBackup"] fn restore_backup(backup_secret: String, promise_id: u32); #[cxx_name = "restoreBackupData"] fn restore_backup_data( backup_id: String, backup_data_key: String, backup_log_data_key: String, promise_id: u32, ); #[cxx_name = "retrieveBackupKeys"] fn retrieve_backup_keys(backup_secret: String, promise_id: u32); } // Secure store #[namespace = "comm"] unsafe extern "C++" { include!("RustSecureStore.h"); #[allow(unused)] #[cxx_name = "secureStoreSet"] fn secure_store_set(key: &str, value: String) -> Result<()>; #[cxx_name = "secureStoreGet"] fn secure_store_get(key: &str) -> Result; } // C++ Backup creation #[namespace = "comm"] unsafe extern "C++" { include!("RustBackupExecutor.h"); #[cxx_name = "getBackupDirectoryPath"] fn get_backup_directory_path() -> Result; #[cxx_name = "getBackupFilePath"] fn get_backup_file_path( backup_id: &str, is_attachments: bool, ) -> Result; #[cxx_name = "getBackupLogFilePath"] fn get_backup_log_file_path( backup_id: &str, log_id: &str, is_attachments: bool, ) -> Result; #[cxx_name = "getBackupUserKeysFilePath"] fn get_backup_user_keys_file_path(backup_id: &str) -> Result; #[cxx_name = "createMainCompaction"] fn create_main_compaction(backup_id: &str, future_id: usize); #[cxx_name = "restoreFromMainCompaction"] fn restore_from_main_compaction( main_compaction_path: &str, main_compaction_encryption_key: &str, future_id: usize, ); #[cxx_name = "restoreFromBackupLog"] fn restore_from_backup_log(backup_log: Vec, future_id: usize); } // Future handling from C++ extern "Rust" { #[cxx_name = "resolveUnitFuture"] fn resolve_unit_future(future_id: usize); #[cxx_name = "rejectFuture"] fn reject_future(future_id: usize, error: String); } } fn handle_string_result_as_callback( result: Result, promise_id: u32, ) where E: std::fmt::Display, { match result { Err(e) => string_callback(e.to_string(), promise_id, "".to_string()), Ok(r) => string_callback("".to_string(), promise_id, r), } } fn handle_void_result_as_callback(result: Result<(), E>, promise_id: u32) where E: std::fmt::Display, { match result { Err(e) => void_callback(e.to_string(), promise_id), Ok(_) => void_callback("".to_string(), promise_id), } } fn handle_bool_result_as_callback(result: Result, promise_id: u32) where E: std::fmt::Display, { match result { Err(e) => bool_callback(e.to_string(), promise_id, false), Ok(r) => bool_callback("".to_string(), promise_id, r), } } fn generate_nonce(promise_id: u32) { RUNTIME.spawn(async move { let result = fetch_nonce().await; handle_string_result_as_callback(result, promise_id); }); } async fn fetch_nonce() -> Result { let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let nonce = identity_client .generate_nonce(Empty {}) .await? .into_inner() .nonce; Ok(nonce) } fn version_supported(promise_id: u32) { RUNTIME.spawn(async move { let result = version_supported_helper().await; handle_bool_result_as_callback(result, promise_id); }); } async fn version_supported_helper() -> Result { let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client.ping(Empty {}).await; match response { Ok(_) => Ok(true), Err(e) => { if grpc_clients::error::is_version_unsupported(&e) { Ok(false) } else { Err(e.into()) } } } } fn get_keyserver_keys( user_id: String, device_id: String, access_token: String, keyserver_id: String, promise_id: u32, ) { RUNTIME.spawn(async move { let get_keyserver_keys_request = OutboundKeysForUserRequest { user_id: keyserver_id, }; let auth_info = AuthInfo { access_token, user_id, device_id, }; let result = get_keyserver_keys_helper(get_keyserver_keys_request, auth_info).await; handle_string_result_as_callback(result, promise_id); }); } async fn get_keyserver_keys_helper( get_keyserver_keys_request: OutboundKeysForUserRequest, auth_info: AuthInfo, ) -> Result { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .get_keyserver_keys(get_keyserver_keys_request) .await? .into_inner(); let keyserver_keys = OutboundKeyInfoResponse::try_from(response)?; Ok(serde_json::to_string(&keyserver_keys)?) } struct AuthInfo { user_id: String, device_id: String, access_token: String, } #[instrument] fn register_password_user( username: String, password: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ) { RUNTIME.spawn(async move { let password_user_info = PasswordUserInfo { username, password, key_payload, key_payload_signature, content_prekey, content_prekey_signature, notif_prekey, notif_prekey_signature, content_one_time_keys, notif_one_time_keys, }; let result = register_password_user_helper(password_user_info).await; handle_string_result_as_callback(result, promise_id); }); } struct PasswordUserInfo { username: String, password: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, } #[derive(Serialize)] #[serde(rename_all = "camelCase")] struct UserIDAndDeviceAccessToken { #[serde(rename = "userID")] user_id: String, access_token: String, } impl From for UserIDAndDeviceAccessToken { fn from(value: AuthResponse) -> Self { let AuthResponse { user_id, access_token, } = value; Self { user_id, access_token, } } } async fn register_password_user_helper( password_user_info: PasswordUserInfo, ) -> Result { let mut client_registration = Registration::new(); let opaque_registration_request = client_registration .start(&password_user_info.password) .map_err(handle_error)?; let registration_start_request = RegistrationStartRequest { opaque_registration_request, username: password_user_info.username, device_key_upload: Some(DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: password_user_info.key_payload, payload_signature: password_user_info.key_payload_signature, social_proof: None, }), content_upload: Some(Prekey { prekey: password_user_info.content_prekey, prekey_signature: password_user_info.content_prekey_signature, }), notif_upload: Some(Prekey { prekey: password_user_info.notif_prekey, prekey_signature: password_user_info.notif_prekey_signature, }), one_time_content_prekeys: password_user_info.content_one_time_keys, one_time_notif_prekeys: password_user_info.notif_one_time_keys, device_type: DEVICE_TYPE.into(), }), + farcaster_id: None, }; let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .register_password_user_start(registration_start_request) .await?; let registration_start_response = response.into_inner(); let opaque_registration_upload = client_registration .finish( &password_user_info.password, ®istration_start_response.opaque_registration_response, ) .map_err(handle_error)?; let registration_finish_request = RegistrationFinishRequest { session_id: registration_start_response.session_id, opaque_registration_upload, }; let registration_finish_response = identity_client .register_password_user_finish(registration_finish_request) .await? .into_inner(); let user_id_and_access_token = UserIDAndDeviceAccessToken::from(registration_finish_response); Ok(serde_json::to_string(&user_id_and_access_token)?) } #[instrument] fn log_in_password_user( username: String, password: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, promise_id: u32, ) { RUNTIME.spawn(async move { let password_user_info = PasswordUserInfo { username, password, key_payload, key_payload_signature, content_prekey, content_prekey_signature, notif_prekey, notif_prekey_signature, content_one_time_keys: Vec::new(), notif_one_time_keys: Vec::new(), }; let result = log_in_password_user_helper(password_user_info).await; handle_string_result_as_callback(result, promise_id); }); } async fn log_in_password_user_helper( password_user_info: PasswordUserInfo, ) -> Result { let mut client_login = Login::new(); let opaque_login_request = client_login .start(&password_user_info.password) .map_err(handle_error)?; let login_start_request = OpaqueLoginStartRequest { opaque_login_request, username: password_user_info.username, device_key_upload: Some(DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: password_user_info.key_payload, payload_signature: password_user_info.key_payload_signature, social_proof: None, }), content_upload: Some(Prekey { prekey: password_user_info.content_prekey, prekey_signature: password_user_info.content_prekey_signature, }), notif_upload: Some(Prekey { prekey: password_user_info.notif_prekey, prekey_signature: password_user_info.notif_prekey_signature, }), one_time_content_prekeys: password_user_info.content_one_time_keys, one_time_notif_prekeys: password_user_info.notif_one_time_keys, device_type: DEVICE_TYPE.into(), }), force: None, }; let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .log_in_password_user_start(login_start_request) .await?; let login_start_response = response.into_inner(); let opaque_login_upload = client_login .finish(&login_start_response.opaque_login_response) .map_err(handle_error)?; let login_finish_request = OpaqueLoginFinishRequest { session_id: login_start_response.session_id, opaque_login_upload, }; let login_finish_response = identity_client .log_in_password_user_finish(login_finish_request) .await? .into_inner(); let user_id_and_access_token = UserIDAndDeviceAccessToken::from(login_finish_response); Ok(serde_json::to_string(&user_id_and_access_token)?) } struct WalletUserInfo { siwe_message: String, siwe_signature: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, } #[instrument] fn log_in_wallet_user( siwe_message: String, siwe_signature: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, promise_id: u32, ) { RUNTIME.spawn(async move { let wallet_user_info = WalletUserInfo { siwe_message, siwe_signature, key_payload, key_payload_signature, content_prekey, content_prekey_signature, notif_prekey, notif_prekey_signature, content_one_time_keys: Vec::new(), notif_one_time_keys: Vec::new(), }; let result = log_in_wallet_user_helper(wallet_user_info).await; handle_string_result_as_callback(result, promise_id); }); } async fn log_in_wallet_user_helper( wallet_user_info: WalletUserInfo, ) -> Result { let login_request = WalletAuthRequest { siwe_message: wallet_user_info.siwe_message, siwe_signature: wallet_user_info.siwe_signature, device_key_upload: Some(DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: wallet_user_info.key_payload, payload_signature: wallet_user_info.key_payload_signature, social_proof: None, // The SIWE message and signature are the social proof }), content_upload: Some(Prekey { prekey: wallet_user_info.content_prekey, prekey_signature: wallet_user_info.content_prekey_signature, }), notif_upload: Some(Prekey { prekey: wallet_user_info.notif_prekey, prekey_signature: wallet_user_info.notif_prekey_signature, }), one_time_content_prekeys: wallet_user_info.content_one_time_keys, one_time_notif_prekeys: wallet_user_info.notif_one_time_keys, device_type: DEVICE_TYPE.into(), }), + farcaster_id: None, }; let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let login_response = identity_client .log_in_wallet_user(login_request) .await? .into_inner(); let user_id_and_access_token = UserIDAndDeviceAccessToken::from(login_response); Ok(serde_json::to_string(&user_id_and_access_token)?) } struct UpdatePasswordInfo { user_id: String, device_id: String, access_token: String, password: String, } fn update_user_password( user_id: String, device_id: String, access_token: String, password: String, promise_id: u32, ) { RUNTIME.spawn(async move { let update_password_info = UpdatePasswordInfo { access_token, user_id, device_id, password, }; let result = update_user_password_helper(update_password_info).await; handle_void_result_as_callback(result, promise_id); }); } async fn update_user_password_helper( update_password_info: UpdatePasswordInfo, ) -> Result<(), Error> { let mut client_registration = Registration::new(); let opaque_registration_request = client_registration .start(&update_password_info.password) .map_err(handle_error)?; let update_password_start_request = UpdateUserPasswordStartRequest { opaque_registration_request, }; let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, update_password_info.user_id, update_password_info.device_id, update_password_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .update_user_password_start(update_password_start_request) .await?; let update_password_start_response = response.into_inner(); let opaque_registration_upload = client_registration .finish( &update_password_info.password, &update_password_start_response.opaque_registration_response, ) .map_err(handle_error)?; let update_password_finish_request = UpdateUserPasswordFinishRequest { session_id: update_password_start_response.session_id, opaque_registration_upload, }; identity_client .update_user_password_finish(update_password_finish_request) .await?; Ok(()) } fn delete_user( user_id: String, device_id: String, access_token: String, promise_id: u32, ) { RUNTIME.spawn(async move { let auth_info = AuthInfo { access_token, user_id, device_id, }; let result = delete_user_helper(auth_info).await; handle_void_result_as_callback(result, promise_id); }); } async fn delete_user_helper(auth_info: AuthInfo) -> Result<(), Error> { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; identity_client.delete_user(Empty {}).await?; Ok(()) } fn log_out( user_id: String, device_id: String, access_token: String, promise_id: u32, ) { RUNTIME.spawn(async move { let auth_info = AuthInfo { access_token, user_id, device_id, }; let result = log_out_helper(auth_info).await; handle_void_result_as_callback(result, promise_id); }); } async fn log_out_helper(auth_info: AuthInfo) -> Result<(), Error> { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; identity_client.log_out_user(Empty {}).await?; Ok(()) } struct GetOutboundKeysRequestInfo { user_id: String, } struct GetInboundKeysRequestInfo { user_id: String, } // This struct should not be altered without also updating // OutboundKeyInfoResponse in lib/types/identity-service-types.js #[derive(Serialize)] #[serde(rename_all = "camelCase")] struct OutboundKeyInfoResponse { pub payload: String, pub payload_signature: String, pub social_proof: Option, pub content_prekey: String, pub content_prekey_signature: String, pub notif_prekey: String, pub notif_prekey_signature: String, pub one_time_content_prekey: Option, pub one_time_notif_prekey: Option, } // This struct should not be altered without also updating // InboundKeyInfoResponse in lib/types/identity-service-types.js #[derive(Serialize)] #[serde(rename_all = "camelCase")] struct InboundKeyInfoResponse { pub payload: String, pub payload_signature: String, pub social_proof: Option, pub content_prekey: String, pub content_prekey_signature: String, pub notif_prekey: String, pub notif_prekey_signature: String, } impl TryFrom for OutboundKeyInfoResponse { type Error = Error; fn try_from(key_info: OutboundKeyInfo) -> Result { let identity_info = key_info.identity_info.ok_or(Error::MissingResponseData)?; let IdentityKeyInfo { payload, payload_signature, social_proof, } = identity_info; let content_prekey = key_info.content_prekey.ok_or(Error::MissingResponseData)?; let Prekey { prekey: content_prekey_value, prekey_signature: content_prekey_signature, } = content_prekey; let notif_prekey = key_info.notif_prekey.ok_or(Error::MissingResponseData)?; let Prekey { prekey: notif_prekey_value, prekey_signature: notif_prekey_signature, } = notif_prekey; let one_time_content_prekey = key_info.one_time_content_prekey; let one_time_notif_prekey = key_info.one_time_notif_prekey; Ok(Self { payload, payload_signature, social_proof, content_prekey: content_prekey_value, content_prekey_signature, notif_prekey: notif_prekey_value, notif_prekey_signature, one_time_content_prekey, one_time_notif_prekey, }) } } impl TryFrom for OutboundKeyInfoResponse { type Error = Error; fn try_from(response: KeyserverKeysResponse) -> Result { let key_info = response.keyserver_info.ok_or(Error::MissingResponseData)?; Self::try_from(key_info) } } fn get_outbound_keys_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, promise_id: u32, ) { RUNTIME.spawn(async move { let get_outbound_keys_request_info = GetOutboundKeysRequestInfo { user_id }; let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; let result = get_outbound_keys_for_user_helper( get_outbound_keys_request_info, auth_info, ) .await; handle_string_result_as_callback(result, promise_id); }); } async fn get_outbound_keys_for_user_helper( get_outbound_keys_request_info: GetOutboundKeysRequestInfo, auth_info: AuthInfo, ) -> Result { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .get_outbound_keys_for_user(OutboundKeysForUserRequest { user_id: get_outbound_keys_request_info.user_id, }) .await? .into_inner(); let outbound_key_info: Vec = response .devices .into_values() .map(OutboundKeyInfoResponse::try_from) .collect::, _>>()?; Ok(serde_json::to_string(&outbound_key_info)?) } impl TryFrom for InboundKeyInfoResponse { type Error = Error; fn try_from(key_info: InboundKeyInfo) -> Result { let identity_info = key_info.identity_info.ok_or(Error::MissingResponseData)?; let IdentityKeyInfo { payload, payload_signature, social_proof, } = identity_info; let content_prekey = key_info.content_prekey.ok_or(Error::MissingResponseData)?; let Prekey { prekey: content_prekey_value, prekey_signature: content_prekey_signature, } = content_prekey; let notif_prekey = key_info.notif_prekey.ok_or(Error::MissingResponseData)?; let Prekey { prekey: notif_prekey_value, prekey_signature: notif_prekey_signature, } = notif_prekey; Ok(Self { payload, payload_signature, social_proof, content_prekey: content_prekey_value, content_prekey_signature, notif_prekey: notif_prekey_value, notif_prekey_signature, }) } } fn get_inbound_keys_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, promise_id: u32, ) { RUNTIME.spawn(async move { let get_inbound_keys_request_info = GetInboundKeysRequestInfo { user_id }; let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; let result = get_inbound_keys_for_user_helper( get_inbound_keys_request_info, auth_info, ) .await; handle_string_result_as_callback(result, promise_id); }); } async fn get_inbound_keys_for_user_helper( get_inbound_keys_request_info: GetInboundKeysRequestInfo, auth_info: AuthInfo, ) -> Result { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .get_inbound_keys_for_user(InboundKeysForUserRequest { user_id: get_inbound_keys_request_info.user_id, }) .await? .into_inner(); let inbound_key_info: Vec = response .devices .into_values() .map(InboundKeyInfoResponse::try_from) .collect::, _>>()?; Ok(serde_json::to_string(&inbound_key_info)?) } fn refresh_user_prekeys( auth_user_id: String, auth_device_id: String, auth_access_token: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, promise_id: u32, ) { RUNTIME.spawn(async move { let refresh_request = RefreshUserPrekeysRequest { new_content_prekeys: Some(Prekey { prekey: content_prekey, prekey_signature: content_prekey_signature, }), new_notif_prekeys: Some(Prekey { prekey: notif_prekey, prekey_signature: notif_prekey_signature, }), }; let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; let result = refresh_user_prekeys_helper(refresh_request, auth_info).await; handle_void_result_as_callback(result, promise_id); }); } async fn refresh_user_prekeys_helper( refresh_request: RefreshUserPrekeysRequest, auth_info: AuthInfo, ) -> Result<(), Error> { get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await? .refresh_user_prekeys(refresh_request) .await?; Ok(()) } #[instrument] fn upload_one_time_keys( auth_user_id: String, auth_device_id: String, auth_access_token: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ) { RUNTIME.spawn(async move { let upload_request = UploadOneTimeKeysRequest { content_one_time_prekeys: content_one_time_keys, notif_one_time_prekeys: notif_one_time_keys, }; let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; let result = upload_one_time_keys_helper(auth_info, upload_request).await; handle_void_result_as_callback(result, promise_id); }); } async fn upload_one_time_keys_helper( auth_info: AuthInfo, upload_request: UploadOneTimeKeysRequest, ) -> Result<(), Error> { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; identity_client.upload_one_time_keys(upload_request).await?; Ok(()) } fn get_device_list_for_user( auth_user_id: String, auth_device_id: String, auth_access_token: String, user_id: String, since_timestamp: i64, promise_id: u32, ) { RUNTIME.spawn(async move { let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; let since_timestamp = Option::from(since_timestamp).filter(|&t| t > 0); let result = get_device_list_for_user_helper(auth_info, user_id, since_timestamp) .await; handle_string_result_as_callback(result, promise_id); }); } async fn get_device_list_for_user_helper( auth_info: AuthInfo, user_id: String, since_timestamp: Option, ) -> Result { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let response = identity_client .get_device_list_for_user(GetDeviceListRequest { user_id, since_timestamp, }) .await? .into_inner(); let payload = serde_json::to_string(&response.device_list_updates)?; Ok(payload) } fn update_device_list( auth_user_id: String, auth_device_id: String, auth_access_token: String, update_payload: String, promise_id: u32, ) { RUNTIME.spawn(async move { let auth_info = AuthInfo { access_token: auth_access_token, user_id: auth_user_id, device_id: auth_device_id, }; let result = update_device_list_helper(auth_info, update_payload).await; handle_void_result_as_callback(result, promise_id); }); } async fn update_device_list_helper( auth_info: AuthInfo, update_payload: String, ) -> Result<(), Error> { let mut identity_client = get_auth_client( IDENTITY_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let update_request = UpdateDeviceListRequest { new_device_list: update_payload, }; identity_client.update_device_list(update_request).await?; Ok(()) } fn upload_secondary_device_keys_and_log_in( user_id: String, challenge_response: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ) { RUNTIME.spawn(async move { let device_key_upload = DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: key_payload, payload_signature: key_payload_signature, social_proof: None, }), content_upload: Some(Prekey { prekey: content_prekey, prekey_signature: content_prekey_signature, }), notif_upload: Some(Prekey { prekey: notif_prekey, prekey_signature: notif_prekey_signature, }), one_time_content_prekeys: content_one_time_keys, one_time_notif_prekeys: notif_one_time_keys, device_type: DEVICE_TYPE.into(), }; let result = upload_secondary_device_keys_and_log_in_helper( user_id, challenge_response, device_key_upload, ) .await; handle_string_result_as_callback(result, promise_id); }); } async fn upload_secondary_device_keys_and_log_in_helper( user_id: String, challenge_response: String, device_key_upload: DeviceKeyUpload, ) -> Result { let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let request = SecondaryDeviceKeysUploadRequest { user_id, challenge_response, device_key_upload: Some(device_key_upload), }; let response = identity_client .upload_keys_for_registered_device_and_log_in(request) .await? .into_inner(); let user_id_and_access_token = UserIDAndDeviceAccessToken::from(response); Ok(serde_json::to_string(&user_id_and_access_token)?) } #[derive( Debug, derive_more::Display, derive_more::From, derive_more::Error, )] pub enum Error { #[display(fmt = "{}", "_0.message()")] TonicGRPC(Status), #[display(fmt = "{}", "_0")] SerdeJson(serde_json::Error), #[display(fmt = "Missing response data")] MissingResponseData, #[display(fmt = "{}", "_0")] GRPClient(grpc_clients::error::Error), } #[cfg(test)] mod tests { use super::{BACKUP_SOCKET_ADDR, CODE_VERSION, IDENTITY_SOCKET_ADDR}; #[test] fn test_code_version_exists() { assert!(CODE_VERSION > 0); } #[test] fn test_identity_socket_addr_exists() { assert!(IDENTITY_SOCKET_ADDR.len() > 0); assert!(BACKUP_SOCKET_ADDR.len() > 0); } } diff --git a/native/native_rust_library/src/wallet_registration.rs b/native/native_rust_library/src/wallet_registration.rs index 6d9a51e7a..87df879ee 100644 --- a/native/native_rust_library/src/wallet_registration.rs +++ b/native/native_rust_library/src/wallet_registration.rs @@ -1,88 +1,89 @@ use crate::{ handle_string_result_as_callback, Error, UserIDAndDeviceAccessToken, WalletUserInfo, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME, }; use grpc_clients::identity::{ get_unauthenticated_client, protos::unauth::{ DeviceKeyUpload, IdentityKeyInfo, Prekey, WalletAuthRequest, }, }; use tracing::instrument; #[instrument] pub fn register_wallet_user( siwe_message: String, siwe_signature: String, key_payload: String, key_payload_signature: String, content_prekey: String, content_prekey_signature: String, notif_prekey: String, notif_prekey_signature: String, content_one_time_keys: Vec, notif_one_time_keys: Vec, promise_id: u32, ) { RUNTIME.spawn(async move { let wallet_user_info = WalletUserInfo { siwe_message, siwe_signature, key_payload, key_payload_signature, content_prekey, content_prekey_signature, notif_prekey, notif_prekey_signature, content_one_time_keys, notif_one_time_keys, }; let result = register_wallet_user_helper(wallet_user_info).await; handle_string_result_as_callback(result, promise_id); }); } async fn register_wallet_user_helper( wallet_user_info: WalletUserInfo, ) -> Result { let registration_request = WalletAuthRequest { siwe_message: wallet_user_info.siwe_message, siwe_signature: wallet_user_info.siwe_signature, device_key_upload: Some(DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: wallet_user_info.key_payload, payload_signature: wallet_user_info.key_payload_signature, social_proof: None, // The SIWE message and signature are the social proof }), content_upload: Some(Prekey { prekey: wallet_user_info.content_prekey, prekey_signature: wallet_user_info.content_prekey_signature, }), notif_upload: Some(Prekey { prekey: wallet_user_info.notif_prekey, prekey_signature: wallet_user_info.notif_prekey_signature, }), one_time_content_prekeys: wallet_user_info.content_one_time_keys, one_time_notif_prekeys: wallet_user_info.notif_one_time_keys, device_type: DEVICE_TYPE.into(), }), + farcaster_id: None, }; let mut identity_client = get_unauthenticated_client( IDENTITY_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) .await?; let registration_response = identity_client .register_wallet_user(registration_request) .await? .into_inner(); let user_id_and_access_token = UserIDAndDeviceAccessToken { user_id: registration_response.user_id, access_token: registration_response.access_token, }; Ok(serde_json::to_string(&user_id_and_access_token)?) } diff --git a/services/commtest/src/identity/device.rs b/services/commtest/src/identity/device.rs index 8b626dfc0..6c7b8faf2 100644 --- a/services/commtest/src/identity/device.rs +++ b/services/commtest/src/identity/device.rs @@ -1,217 +1,218 @@ use comm_opaque2::client::{Login, Registration}; use grpc_clients::identity::{get_auth_client, get_unauthenticated_client}; use rand::{distributions::Alphanumeric, Rng}; use crate::identity::olm_account_infos::{ ClientPublicKeys, DEFAULT_CLIENT_KEYS, }; use crate::service_addr; use grpc_clients::identity::protos::unauth::{ DeviceKeyUpload, DeviceType, Empty, IdentityKeyInfo, OpaqueLoginFinishRequest, OpaqueLoginStartRequest, Prekey, RegistrationFinishRequest, RegistrationStartRequest, }; pub const PLACEHOLDER_CODE_VERSION: u64 = 0; pub const DEVICE_TYPE: &str = "service"; const PASSWORD: &str = "pass"; pub struct DeviceInfo { pub username: String, pub user_id: String, pub device_id: String, pub access_token: String, } /// Register a new user with a device. /// - Gives random username (returned by function). /// - Device type defaults to keyserver. /// - Device ID taken from `keys` (ed25519), see [`DEFAULT_CLIENT_KEYS`] pub async fn register_user_device( keys: Option<&ClientPublicKeys>, device_type: Option, ) -> DeviceInfo { let username: String = rand::thread_rng() .sample_iter(&Alphanumeric) .take(7) .map(char::from) .collect(); // TODO: Generate dynamic valid olm account info let keys = keys.unwrap_or_else(|| &DEFAULT_CLIENT_KEYS); let example_payload = serde_json::to_string(&keys).expect("Failed to serialize example payload"); // The ed25519 value from the olm payload let device_id = &keys.primary_identity_public_keys.ed25519; let device_type = device_type.unwrap_or(DeviceType::Keyserver); let mut client_registration = Registration::new(); let opaque_registration_request = client_registration.start(PASSWORD).unwrap(); let registration_start_request = RegistrationStartRequest { opaque_registration_request, username: username.to_string(), device_key_upload: Some(DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: example_payload.to_string(), payload_signature: "foo".to_string(), social_proof: None, }), content_upload: Some(Prekey { prekey: "content_prekey".to_string(), prekey_signature: "content_prekey_sig".to_string(), }), notif_upload: Some(Prekey { prekey: "notif_prekey".to_string(), prekey_signature: "notif_prekey_sig".to_string(), }), one_time_content_prekeys: Vec::new(), one_time_notif_prekeys: Vec::new(), device_type: device_type.into(), }), + farcaster_id: None, }; let mut identity_client = get_unauthenticated_client( &service_addr::IDENTITY_GRPC.to_string(), PLACEHOLDER_CODE_VERSION, DEVICE_TYPE.to_string(), ) .await .expect("Couldn't connect to identity service"); let registration_start_response = identity_client .register_password_user_start(registration_start_request) .await .unwrap() .into_inner(); let opaque_registration_upload = client_registration .finish( PASSWORD, ®istration_start_response.opaque_registration_response, ) .unwrap(); let registration_finish_request = RegistrationFinishRequest { session_id: registration_start_response.session_id, opaque_registration_upload, }; let registration_finish_response = identity_client .register_password_user_finish(registration_finish_request) .await .unwrap() .into_inner(); DeviceInfo { username: username.to_string(), device_id: device_id.to_string(), user_id: registration_finish_response.user_id, access_token: registration_finish_response.access_token, } } /// Log in existing user with a device. /// - Tries to log in with given username (it has to be already registered) /// - Device type defaults to keyserver. /// - Device ID taken from `keys` (ed25519), see [`DEFAULT_CLIENT_KEYS`] pub async fn login_user_device( username: &str, keys: Option<&ClientPublicKeys>, device_type: Option, force: bool, ) -> DeviceInfo { // TODO: Generate dynamic valid olm account info let keys = keys.unwrap_or_else(|| &DEFAULT_CLIENT_KEYS); let example_payload = serde_json::to_string(&keys).expect("Failed to serialize example payload"); // The ed25519 value from the olm payload let device_id = &keys.primary_identity_public_keys.ed25519; let device_type = device_type.unwrap_or(DeviceType::Keyserver); let mut client_login = Login::new(); let opaque_login_request = client_login.start(PASSWORD).unwrap(); let login_start_request = OpaqueLoginStartRequest { opaque_login_request, username: username.to_string(), device_key_upload: Some(DeviceKeyUpload { device_key_info: Some(IdentityKeyInfo { payload: example_payload.to_string(), payload_signature: "foo".to_string(), social_proof: None, }), content_upload: Some(Prekey { prekey: "content_prekey".to_string(), prekey_signature: "content_prekey_sig".to_string(), }), notif_upload: Some(Prekey { prekey: "notif_prekey".to_string(), prekey_signature: "notif_prekey_sig".to_string(), }), one_time_content_prekeys: Vec::new(), one_time_notif_prekeys: Vec::new(), device_type: device_type.into(), }), force: Some(force), }; let mut identity_client = get_unauthenticated_client( &service_addr::IDENTITY_GRPC.to_string(), PLACEHOLDER_CODE_VERSION, DEVICE_TYPE.to_string(), ) .await .expect("Couldn't connect to identity service"); let login_start_response = identity_client .log_in_password_user_start(login_start_request) .await .unwrap() .into_inner(); let opaque_login_upload = client_login .finish(&login_start_response.opaque_login_response) .unwrap(); let login_finish_request = OpaqueLoginFinishRequest { session_id: login_start_response.session_id, opaque_login_upload, }; let login_finish_response = identity_client .log_in_password_user_finish(login_finish_request) .await .unwrap() .into_inner(); DeviceInfo { username: username.to_string(), device_id: device_id.to_string(), user_id: login_finish_response.user_id, access_token: login_finish_response.access_token, } } pub async fn logout_user_device(device_info: DeviceInfo) { let DeviceInfo { user_id, device_id, access_token, .. } = device_info; let mut client = get_auth_client( &service_addr::IDENTITY_GRPC.to_string(), user_id, device_id, access_token, PLACEHOLDER_CODE_VERSION, DEVICE_TYPE.to_string(), ) .await .expect("Couldnt connect to auth identity service"); client .log_out_user(Empty {}) .await .expect("Failed to logout user"); } diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs index 03422c63d..374b610e1 100644 --- a/services/identity/src/client_service.rs +++ b/services/identity/src/client_service.rs @@ -1,1048 +1,1055 @@ // 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, }; 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")); } 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", )); } 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 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, })) } } 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 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/constants.rs b/services/identity/src/constants.rs index b7da33a15..521737f6b 100644 --- a/services/identity/src/constants.rs +++ b/services/identity/src/constants.rs @@ -1,235 +1,236 @@ use tokio::time::Duration; // Secrets pub const SECRETS_DIRECTORY: &str = "secrets"; pub const SECRETS_SETUP_FILE: &str = "server_setup.txt"; // DynamoDB // User table information, supporting opaque_ke 2.0 and X3DH information // Users can sign in either through username+password or Eth wallet. // // This structure should be aligned with the messages defined in // shared/protos/identity_unauthenticated.proto // // Structure for a user should be: // { // userID: String, // opaqueRegistrationData: Option, // username: Option, // walletAddress: Option, // devices: HashMap // } // // A device is defined as: // { // deviceType: String, # client or keyserver // keyPayload: String, // keyPayloadSignature: String, // identityPreKey: String, // identityPreKeySignature: String, // identityOneTimeKeys: Vec, // notifPreKey: String, // notifPreKeySignature: String, // notifOneTimeKeys: Vec, // socialProof: Option // } // } // // Additional context: // "devices" uses the signing public identity key of the device as a key for the devices map // "keyPayload" is a JSON encoded string containing identity and notif keys (both signature and verification) // if "deviceType" == "keyserver", then the device will not have any notif key information pub const USERS_TABLE: &str = "identity-users"; pub const USERS_TABLE_PARTITION_KEY: &str = "userID"; pub const USERS_TABLE_REGISTRATION_ATTRIBUTE: &str = "opaqueRegistrationData"; pub const USERS_TABLE_USERNAME_ATTRIBUTE: &str = "username"; pub const USERS_TABLE_DEVICES_MAP_DEVICE_TYPE_ATTRIBUTE_NAME: &str = "deviceType"; pub const USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE: &str = "walletAddress"; pub const USERS_TABLE_SOCIAL_PROOF_ATTRIBUTE_NAME: &str = "socialProof"; pub const USERS_TABLE_DEVICELIST_TIMESTAMP_ATTRIBUTE_NAME: &str = "deviceListTimestamp"; +pub const USERS_TABLE_FARCASTER_ID_ATTRIBUTE_NAME: &str = "farcasterID"; pub const USERS_TABLE_USERNAME_INDEX: &str = "username-index"; pub const USERS_TABLE_WALLET_ADDRESS_INDEX: &str = "walletAddress-index"; pub const ACCESS_TOKEN_TABLE: &str = "identity-tokens"; pub const ACCESS_TOKEN_TABLE_PARTITION_KEY: &str = "userID"; pub const ACCESS_TOKEN_SORT_KEY: &str = "signingPublicKey"; pub const ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE: &str = "created"; pub const ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE: &str = "authType"; pub const ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE: &str = "valid"; pub const ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE: &str = "token"; pub const NONCE_TABLE: &str = "identity-nonces"; pub const NONCE_TABLE_PARTITION_KEY: &str = "nonce"; pub const NONCE_TABLE_CREATED_ATTRIBUTE: &str = "created"; pub const NONCE_TABLE_EXPIRATION_TIME_ATTRIBUTE: &str = "expirationTime"; pub const NONCE_TABLE_EXPIRATION_TIME_UNIX_ATTRIBUTE: &str = "expirationTimeUnix"; pub const WORKFLOWS_IN_PROGRESS_TABLE: &str = "identity-workflows-in-progress"; pub const WORKFLOWS_IN_PROGRESS_PARTITION_KEY: &str = "id"; pub const WORKFLOWS_IN_PROGRESS_WORKFLOW_ATTRIBUTE: &str = "workflow"; pub const WORKFLOWS_IN_PROGRESS_TABLE_EXPIRATION_TIME_UNIX_ATTRIBUTE: &str = "expirationTimeUnix"; // Usernames reserved because they exist in Ashoat's keyserver already pub const RESERVED_USERNAMES_TABLE: &str = "identity-reserved-usernames"; pub const RESERVED_USERNAMES_TABLE_PARTITION_KEY: &str = "username"; pub const RESERVED_USERNAMES_TABLE_USER_ID_ATTRIBUTE: &str = "userID"; pub mod devices_table { /// table name pub const NAME: &str = "identity-devices"; pub const TIMESTAMP_INDEX_NAME: &str = "deviceList-timestamp-index"; /// partition key pub const ATTR_USER_ID: &str = "userID"; /// sort key pub const ATTR_ITEM_ID: &str = "itemID"; // itemID prefixes (one shouldn't be a prefix of the other) pub const DEVICE_ITEM_KEY_PREFIX: &str = "device-"; pub const DEVICE_LIST_KEY_PREFIX: &str = "devicelist-"; // device-specific attrs pub const ATTR_DEVICE_TYPE: &str = "deviceType"; pub const ATTR_DEVICE_KEY_INFO: &str = "deviceKeyInfo"; pub const ATTR_CONTENT_PREKEY: &str = "contentPreKey"; pub const ATTR_NOTIF_PREKEY: &str = "notifPreKey"; // IdentityKeyInfo constants pub const ATTR_KEY_PAYLOAD: &str = "keyPayload"; pub const ATTR_KEY_PAYLOAD_SIGNATURE: &str = "keyPayloadSignature"; // PreKey constants pub const ATTR_PREKEY: &str = "preKey"; pub const ATTR_PREKEY_SIGNATURE: &str = "preKeySignature"; // device-list-specific attrs pub const ATTR_TIMESTAMP: &str = "timestamp"; pub const ATTR_DEVICE_IDS: &str = "deviceIDs"; // migration-specific attrs pub const ATTR_CODE_VERSION: &str = "codeVersion"; pub const ATTR_LOGIN_TIME: &str = "loginTime"; } // One time keys table, which need to exist in their own table to ensure // atomicity of additions and removals pub mod one_time_keys_table { // The `PARTITION_KEY` will contain "notification_${deviceID}" or // "content_${deviceID}" to allow for both key sets to coexist in the same table pub const NAME: &str = "identity-one-time-keys"; pub const PARTITION_KEY: &str = "deviceID"; pub const DEVICE_ID: &str = PARTITION_KEY; pub const SORT_KEY: &str = "oneTimeKey"; pub const ONE_TIME_KEY: &str = SORT_KEY; } // One-time key constants for device info map pub const CONTENT_ONE_TIME_KEY: &str = "contentOneTimeKey"; pub const NOTIF_ONE_TIME_KEY: &str = "notifOneTimeKey"; // Tokio pub const MPSC_CHANNEL_BUFFER_CAPACITY: usize = 1; pub const IDENTITY_SERVICE_SOCKET_ADDR: &str = "[::]:50054"; pub const IDENTITY_SERVICE_WEBSOCKET_ADDR: &str = "[::]:51004"; pub const SOCKET_HEARTBEAT_TIMEOUT: Duration = Duration::from_secs(3); // Token pub const ACCESS_TOKEN_LENGTH: usize = 512; // Temporary config pub const AUTH_TOKEN: &str = "COMM_IDENTITY_SERVICE_AUTH_TOKEN"; pub const KEYSERVER_PUBLIC_KEY: &str = "KEYSERVER_PUBLIC_KEY"; // Nonce pub const NONCE_LENGTH: usize = 17; pub const NONCE_TTL_DURATION: Duration = Duration::from_secs(120); // seconds // Workflows in progress pub const WORKFLOWS_IN_PROGRESS_TTL_DURATION: Duration = Duration::from_secs(120); // Identity pub const DEFAULT_IDENTITY_ENDPOINT: &str = "http://localhost:50054"; // LocalStack pub const LOCALSTACK_ENDPOINT: &str = "LOCALSTACK_ENDPOINT"; // OPAQUE Server Setup pub const OPAQUE_SERVER_SETUP: &str = "OPAQUE_SERVER_SETUP"; // Identity Search pub const OPENSEARCH_ENDPOINT: &str = "OPENSEARCH_ENDPOINT"; pub const DEFAULT_OPENSEARCH_ENDPOINT: &str = "identity-search-domain.us-east-2.opensearch.localhost.localstack.cloud:4566"; pub const IDENTITY_SEARCH_INDEX: &str = "users"; pub const IDENTITY_SEARCH_RESULT_SIZE: u32 = 20; // Tunnelbroker pub const TUNNELBROKER_GRPC_ENDPOINT: &str = "TUNNELBROKER_GRPC_ENDPOINT"; pub const DEFAULT_TUNNELBROKER_ENDPOINT: &str = "http://localhost:50051"; // X3DH key management // Threshold for requesting more one_time keys pub const ONE_TIME_KEY_MINIMUM_THRESHOLD: usize = 5; // Number of keys to be refreshed when below the threshold pub const ONE_TIME_KEY_REFRESH_NUMBER: u32 = 5; // Minimum supported code versions pub const MIN_SUPPORTED_NATIVE_VERSION: u64 = 270; // Request metadata pub mod request_metadata { pub const CODE_VERSION: &str = "code_version"; pub const DEVICE_TYPE: &str = "device_type"; pub const USER_ID: &str = "user_id"; pub const DEVICE_ID: &str = "device_id"; pub const ACCESS_TOKEN: &str = "access_token"; } // CORS pub mod cors { use std::time::Duration; pub const DEFAULT_MAX_AGE: Duration = Duration::from_secs(24 * 60 * 60); pub const DEFAULT_EXPOSED_HEADERS: [&str; 3] = ["grpc-status", "grpc-message", "grpc-status-details-bin"]; pub const DEFAULT_ALLOW_HEADERS: [&str; 9] = [ "x-grpc-web", "content-type", "x-user-agent", "grpc-timeout", super::request_metadata::CODE_VERSION, super::request_metadata::DEVICE_TYPE, super::request_metadata::USER_ID, super::request_metadata::DEVICE_ID, super::request_metadata::ACCESS_TOKEN, ]; pub const ALLOW_ORIGIN_LIST: &str = "ALLOW_ORIGIN_LIST"; } // Regex pub const VALID_USERNAME_REGEX_STRING: &str = r"^[a-zA-Z0-9][a-zA-Z0-9-_]{0,190}$"; diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs index 0fbf855ce..556e4af5d 100644 --- a/services/identity/src/database.rs +++ b/services/identity/src/database.rs @@ -1,1432 +1,1444 @@ 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_PARTITION_KEY, USERS_TABLE_REGISTRATION_ATTRIBUTE, - USERS_TABLE_USERNAME_ATTRIBUTE, USERS_TABLE_USERNAME_INDEX, - USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_INDEX, + 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 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())) } pub async fn get_user_identifier( &self, user_id: &str, ) -> Result { let user_info = 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 }) } 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/shared/protos/identity_unauth.proto b/shared/protos/identity_unauth.proto index 2da538a37..a69250191 100644 --- a/shared/protos/identity_unauth.proto +++ b/shared/protos/identity_unauth.proto @@ -1,272 +1,274 @@ syntax = "proto3"; package identity.unauth; // RPCs from a client (iOS, Android, or web) to identity service service IdentityClientService { // Account actions // Called by user to register with the Identity Service (PAKE only) // Due to limitations of grpc-web, the Opaque challenge+response // needs to be split up over two unary requests // Start/Finish is used here to align with opaque protocol rpc RegisterPasswordUserStart(RegistrationStartRequest) returns ( RegistrationStartResponse) {} rpc RegisterReservedPasswordUserStart(ReservedRegistrationStartRequest) returns (RegistrationStartResponse) {} rpc RegisterPasswordUserFinish(RegistrationFinishRequest) returns ( AuthResponse) {} // Called by user to register device and get an access token rpc LogInPasswordUserStart(OpaqueLoginStartRequest) returns (OpaqueLoginStartResponse) {} rpc LogInPasswordUserFinish(OpaqueLoginFinishRequest) returns (AuthResponse) {} rpc LogInWalletUser(WalletAuthRequest) returns (AuthResponse) {} rpc RegisterWalletUser(WalletAuthRequest) returns (AuthResponse) {} rpc RegisterReservedWalletUser(ReservedWalletRegistrationRequest) returns (AuthResponse) {} rpc UploadKeysForRegisteredDeviceAndLogIn(SecondaryDeviceKeysUploadRequest) returns (AuthResponse) {} // Sign-In with Ethereum actions // Called by clients to get a nonce for a Sign-In with Ethereum message rpc GenerateNonce(Empty) returns (GenerateNonceResponse) {} // Service actions // Called by other services to verify a user's access token rpc VerifyUserAccessToken(VerifyUserAccessTokenRequest) returns (VerifyUserAccessTokenResponse) {} // Ashoat's keyserver actions // Called by Ashoat's keyserver to add usernames to the Identity service's // reserved list rpc AddReservedUsernames(AddReservedUsernamesRequest) returns (Empty) {} // Called by Ashoat's keyserver to remove usernames from the Identity // service's reserved list rpc RemoveReservedUsername(RemoveReservedUsernameRequest) returns (Empty) {} // Miscellaneous actions // Called by users periodically to check if their code version is supported rpc Ping(Empty) returns (Empty) {} // Returns userID for given username or wallet address rpc FindUserID(FindUserIDRequest) returns (FindUserIDResponse) {} } // Helper types message Empty {} message Prekey { string prekey = 1; string prekey_signature = 2; } // Key information needed for starting a X3DH session message IdentityKeyInfo { // JSON payload containing Olm keys // Sessions for users will contain both ContentKeys and NotifKeys // For keyservers, this will only contain ContentKeys string payload = 1; // Payload signed with the signing ed25519 key string payload_signature = 2; // Signed message used for SIWE // This correlates a given wallet with a device's content key optional string social_proof = 3; } // RegisterUser // Ephemeral information provided so others can create initial message // to this device // // Prekeys are generally rotated periodically // One-time Prekeys are "consumed" after first use, so many need to // be provide to avoid exhausting them. enum DeviceType { KEYSERVER = 0; WEB = 1; // iOS doesn't leave a good option for title to camel case renaming IOS = 2; ANDROID = 3; WINDOWS = 4; MAC_OS = 5; } // Bundle of information needed for creating an initial message using X3DH message DeviceKeyUpload { IdentityKeyInfo device_key_info = 1; Prekey content_upload = 2; Prekey notif_upload = 3; repeated string one_time_content_prekeys = 4; repeated string one_time_notif_prekeys = 5; DeviceType device_type = 6; } // Request for registering a new user message RegistrationStartRequest { // Message sent to initiate PAKE registration (step 1) bytes opaque_registration_request = 1; string username = 2; // Information needed to open a new channel to current user's device DeviceKeyUpload device_key_upload = 3; + optional string farcaster_id = 4; } message ReservedRegistrationStartRequest { // Message sent to initiate PAKE registration (step 1) bytes opaque_registration_request = 1; string username = 2; // Information needed to open a new channel to current user's device DeviceKeyUpload device_key_upload = 3; // Message from Ashoat's keyserver attesting that a given user has ownership // of a given username string keyserver_message = 4; // Above message signed with Ashoat's keyserver's signing ed25519 key string keyserver_signature = 5; } // Messages sent from a client to Identity Service message RegistrationFinishRequest { // Identifier to correlate RegisterStart session string session_id = 1; // Final message in PAKE registration bytes opaque_registration_upload = 2; } // Messages sent from Identity Service to client message RegistrationStartResponse { // Identifier used to correlate start request with finish request string session_id = 1; // sent to the user upon reception of the PAKE registration attempt // (step 2) bytes opaque_registration_response = 2; } message AuthResponse { // Unique identifier for user string user_id = 1; string access_token = 2; } // LoginUser message OpaqueLoginStartRequest { string username = 1; // Message sent to initiate PAKE login (step 1) bytes opaque_login_request = 2; // Information specific to a user's device needed to open a new channel of // communication with this user DeviceKeyUpload device_key_upload = 3; // If set to true, the user's existing keyserver will be deleted from the // identity service and replaced with this one. This field has no effect if // the device is not a keyserver optional bool force = 4; } message OpaqueLoginFinishRequest { // Identifier used to correlate start request with finish request string session_id = 1; // Message containing client's reponse to server challenge. // Used to verify that client holds password secret (Step 3) bytes opaque_login_upload = 2; } message OpaqueLoginStartResponse { // Identifier used to correlate start request with finish request string session_id = 1; // Opaque challenge sent from server to client attempting to login (Step 2) bytes opaque_login_response = 2; } message WalletAuthRequest { string siwe_message = 1; string siwe_signature = 2; // Information specific to a user's device needed to open a new channel of // communication with this user DeviceKeyUpload device_key_upload = 3; + optional string farcaster_id = 4; } message ReservedWalletRegistrationRequest { string siwe_message = 1; string siwe_signature = 2; // Information specific to a user's device needed to open a new channel of // communication with this user DeviceKeyUpload device_key_upload = 3; // Message from Ashoat's keyserver attesting that a given user has ownership // of a given wallet address string keyserver_message = 4; // Above message signed with Ashoat's keyserver's signing ed25519 key string keyserver_signature = 5; } // UploadKeysForRegisteredDeviceAndLogIn message SecondaryDeviceKeysUploadRequest { string user_id = 1; string challenge_response = 2; // Information specific to a user's device needed to open a new channel of // communication with this user DeviceKeyUpload device_key_upload = 3; } // GenerateNonce message GenerateNonceResponse{ string nonce = 1; } // VerifyUserAccessToken message VerifyUserAccessTokenRequest { string user_id = 1; // signing ed25519 key for the given user's device string device_id = 2; string access_token = 3; } message VerifyUserAccessTokenResponse { bool token_valid = 1; } // AddReservedUsernames message AddReservedUsernamesRequest { // Message from Ashoat's keyserver containing the username to be added string message = 1; // Above message signed with Ashoat's keyserver's signing ed25519 key string signature = 2; } // RemoveReservedUsername message RemoveReservedUsernameRequest { // Message from Ashoat's keyserver containing the username to be removed string message = 1; // Above message signed with Ashoat's keyserver's signing ed25519 key string signature = 2; } // FindUserID message FindUserIDRequest { oneof identifier { string username = 1; string wallet_address = 2; } } message FindUserIDResponse { // userID if the user is registered with Identity Service, null otherwise optional string user_id = 1; // true if the identifier (username or wallet address) exists in the // reserved usernames list, false otherwise. It doesn't take into account // whether the user is registered with Identity Service (userID != null). bool is_reserved = 2; } diff --git a/web/protobufs/identity-unauth-structs.cjs b/web/protobufs/identity-unauth-structs.cjs index 45fd5700b..bd3b4a5fa 100644 --- a/web/protobufs/identity-unauth-structs.cjs +++ b/web/protobufs/identity-unauth-structs.cjs @@ -1,4952 +1,5048 @@ // source: identity_unauth.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')(); goog.exportSymbol('proto.identity.unauth.AddReservedUsernamesRequest', null, global); goog.exportSymbol('proto.identity.unauth.AuthResponse', null, global); goog.exportSymbol('proto.identity.unauth.DeviceKeyUpload', null, global); goog.exportSymbol('proto.identity.unauth.DeviceType', null, global); goog.exportSymbol('proto.identity.unauth.Empty', null, global); goog.exportSymbol('proto.identity.unauth.FindUserIDRequest', null, global); goog.exportSymbol('proto.identity.unauth.FindUserIDRequest.IdentifierCase', null, global); goog.exportSymbol('proto.identity.unauth.FindUserIDResponse', null, global); goog.exportSymbol('proto.identity.unauth.GenerateNonceResponse', null, global); goog.exportSymbol('proto.identity.unauth.IdentityKeyInfo', null, global); goog.exportSymbol('proto.identity.unauth.OpaqueLoginFinishRequest', null, global); goog.exportSymbol('proto.identity.unauth.OpaqueLoginStartRequest', null, global); goog.exportSymbol('proto.identity.unauth.OpaqueLoginStartResponse', null, global); goog.exportSymbol('proto.identity.unauth.Prekey', null, global); goog.exportSymbol('proto.identity.unauth.RegistrationFinishRequest', null, global); goog.exportSymbol('proto.identity.unauth.RegistrationStartRequest', null, global); goog.exportSymbol('proto.identity.unauth.RegistrationStartResponse', null, global); goog.exportSymbol('proto.identity.unauth.RemoveReservedUsernameRequest', null, global); goog.exportSymbol('proto.identity.unauth.ReservedRegistrationStartRequest', null, global); goog.exportSymbol('proto.identity.unauth.ReservedWalletRegistrationRequest', null, global); goog.exportSymbol('proto.identity.unauth.SecondaryDeviceKeysUploadRequest', null, global); goog.exportSymbol('proto.identity.unauth.VerifyUserAccessTokenRequest', null, global); goog.exportSymbol('proto.identity.unauth.VerifyUserAccessTokenResponse', null, global); goog.exportSymbol('proto.identity.unauth.WalletAuthRequest', 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.unauth.Empty = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.Empty, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.Empty.displayName = 'proto.identity.unauth.Empty'; } /** * 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.unauth.Prekey = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.Prekey, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.Prekey.displayName = 'proto.identity.unauth.Prekey'; } /** * 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.unauth.IdentityKeyInfo = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.IdentityKeyInfo, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.IdentityKeyInfo.displayName = 'proto.identity.unauth.IdentityKeyInfo'; } /** * 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.unauth.DeviceKeyUpload = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, proto.identity.unauth.DeviceKeyUpload.repeatedFields_, null); }; goog.inherits(proto.identity.unauth.DeviceKeyUpload, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.DeviceKeyUpload.displayName = 'proto.identity.unauth.DeviceKeyUpload'; } /** * 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.unauth.RegistrationStartRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.RegistrationStartRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.RegistrationStartRequest.displayName = 'proto.identity.unauth.RegistrationStartRequest'; } /** * 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.unauth.ReservedRegistrationStartRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.ReservedRegistrationStartRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.ReservedRegistrationStartRequest.displayName = 'proto.identity.unauth.ReservedRegistrationStartRequest'; } /** * 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.unauth.RegistrationFinishRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.RegistrationFinishRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.RegistrationFinishRequest.displayName = 'proto.identity.unauth.RegistrationFinishRequest'; } /** * 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.unauth.RegistrationStartResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.RegistrationStartResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.RegistrationStartResponse.displayName = 'proto.identity.unauth.RegistrationStartResponse'; } /** * 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.unauth.AuthResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.AuthResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.AuthResponse.displayName = 'proto.identity.unauth.AuthResponse'; } /** * 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.unauth.OpaqueLoginStartRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.OpaqueLoginStartRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.OpaqueLoginStartRequest.displayName = 'proto.identity.unauth.OpaqueLoginStartRequest'; } /** * 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.unauth.OpaqueLoginFinishRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.OpaqueLoginFinishRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.OpaqueLoginFinishRequest.displayName = 'proto.identity.unauth.OpaqueLoginFinishRequest'; } /** * 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.unauth.OpaqueLoginStartResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.OpaqueLoginStartResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.OpaqueLoginStartResponse.displayName = 'proto.identity.unauth.OpaqueLoginStartResponse'; } /** * 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.unauth.WalletAuthRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.WalletAuthRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.WalletAuthRequest.displayName = 'proto.identity.unauth.WalletAuthRequest'; } /** * 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.unauth.ReservedWalletRegistrationRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.ReservedWalletRegistrationRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.ReservedWalletRegistrationRequest.displayName = 'proto.identity.unauth.ReservedWalletRegistrationRequest'; } /** * 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.unauth.SecondaryDeviceKeysUploadRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.SecondaryDeviceKeysUploadRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.displayName = 'proto.identity.unauth.SecondaryDeviceKeysUploadRequest'; } /** * 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.unauth.GenerateNonceResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.GenerateNonceResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.GenerateNonceResponse.displayName = 'proto.identity.unauth.GenerateNonceResponse'; } /** * 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.unauth.VerifyUserAccessTokenRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.VerifyUserAccessTokenRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.VerifyUserAccessTokenRequest.displayName = 'proto.identity.unauth.VerifyUserAccessTokenRequest'; } /** * 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.unauth.VerifyUserAccessTokenResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.VerifyUserAccessTokenResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.VerifyUserAccessTokenResponse.displayName = 'proto.identity.unauth.VerifyUserAccessTokenResponse'; } /** * 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.unauth.AddReservedUsernamesRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.AddReservedUsernamesRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.AddReservedUsernamesRequest.displayName = 'proto.identity.unauth.AddReservedUsernamesRequest'; } /** * 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.unauth.RemoveReservedUsernameRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.RemoveReservedUsernameRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.RemoveReservedUsernameRequest.displayName = 'proto.identity.unauth.RemoveReservedUsernameRequest'; } /** * 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.unauth.FindUserIDRequest = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, proto.identity.unauth.FindUserIDRequest.oneofGroups_); }; goog.inherits(proto.identity.unauth.FindUserIDRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.FindUserIDRequest.displayName = 'proto.identity.unauth.FindUserIDRequest'; } /** * 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.unauth.FindUserIDResponse = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; goog.inherits(proto.identity.unauth.FindUserIDResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ proto.identity.unauth.FindUserIDResponse.displayName = 'proto.identity.unauth.FindUserIDResponse'; } 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.unauth.Empty.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.Empty.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.unauth.Empty} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.Empty.toObject = function(includeInstance, msg) { var f, obj = { }; 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.unauth.Empty} */ proto.identity.unauth.Empty.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.Empty; return proto.identity.unauth.Empty.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.Empty} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.Empty} */ proto.identity.unauth.Empty.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.Empty.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.Empty.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.unauth.Empty} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.Empty.serializeBinaryToWriter = function(message, writer) { var f = undefined; }; 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.unauth.Prekey.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.Prekey.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.unauth.Prekey} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.Prekey.toObject = function(includeInstance, msg) { var f, obj = { prekey: jspb.Message.getFieldWithDefault(msg, 1, ""), prekeySignature: 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.unauth.Prekey} */ proto.identity.unauth.Prekey.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.Prekey; return proto.identity.unauth.Prekey.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.Prekey} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.Prekey} */ proto.identity.unauth.Prekey.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.setPrekey(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setPrekeySignature(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.Prekey.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.Prekey.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.unauth.Prekey} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.Prekey.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getPrekey(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getPrekeySignature(); if (f.length > 0) { writer.writeString( 2, f ); } }; /** * optional string prekey = 1; * @return {string} */ proto.identity.unauth.Prekey.prototype.getPrekey = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.Prekey} returns this */ proto.identity.unauth.Prekey.prototype.setPrekey = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string prekey_signature = 2; * @return {string} */ proto.identity.unauth.Prekey.prototype.getPrekeySignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.Prekey} returns this */ proto.identity.unauth.Prekey.prototype.setPrekeySignature = function(value) { return jspb.Message.setProto3StringField(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.unauth.IdentityKeyInfo.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.IdentityKeyInfo.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.unauth.IdentityKeyInfo} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.IdentityKeyInfo.toObject = function(includeInstance, msg) { var f, obj = { payload: jspb.Message.getFieldWithDefault(msg, 1, ""), payloadSignature: jspb.Message.getFieldWithDefault(msg, 2, ""), socialProof: jspb.Message.getFieldWithDefault(msg, 3, "") }; 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.unauth.IdentityKeyInfo} */ proto.identity.unauth.IdentityKeyInfo.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.IdentityKeyInfo; return proto.identity.unauth.IdentityKeyInfo.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.IdentityKeyInfo} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.IdentityKeyInfo} */ proto.identity.unauth.IdentityKeyInfo.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.setPayload(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setPayloadSignature(value); break; case 3: 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.unauth.IdentityKeyInfo.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.IdentityKeyInfo.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.unauth.IdentityKeyInfo} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.IdentityKeyInfo.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getPayload(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getPayloadSignature(); if (f.length > 0) { writer.writeString( 2, f ); } f = /** @type {string} */ (jspb.Message.getField(message, 3)); if (f != null) { writer.writeString( 3, f ); } }; /** * optional string payload = 1; * @return {string} */ proto.identity.unauth.IdentityKeyInfo.prototype.getPayload = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.IdentityKeyInfo} returns this */ proto.identity.unauth.IdentityKeyInfo.prototype.setPayload = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string payload_signature = 2; * @return {string} */ proto.identity.unauth.IdentityKeyInfo.prototype.getPayloadSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.IdentityKeyInfo} returns this */ proto.identity.unauth.IdentityKeyInfo.prototype.setPayloadSignature = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional string social_proof = 3; * @return {string} */ proto.identity.unauth.IdentityKeyInfo.prototype.getSocialProof = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.IdentityKeyInfo} returns this */ proto.identity.unauth.IdentityKeyInfo.prototype.setSocialProof = function(value) { return jspb.Message.setField(this, 3, value); }; /** * Clears the field making it undefined. * @return {!proto.identity.unauth.IdentityKeyInfo} returns this */ proto.identity.unauth.IdentityKeyInfo.prototype.clearSocialProof = function() { return jspb.Message.setField(this, 3, undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.IdentityKeyInfo.prototype.hasSocialProof = function() { return jspb.Message.getField(this, 3) != null; }; /** * List of repeated fields within this message type. * @private {!Array} * @const */ proto.identity.unauth.DeviceKeyUpload.repeatedFields_ = [4,5]; 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.unauth.DeviceKeyUpload.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.DeviceKeyUpload.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.unauth.DeviceKeyUpload} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.DeviceKeyUpload.toObject = function(includeInstance, msg) { var f, obj = { deviceKeyInfo: (f = msg.getDeviceKeyInfo()) && proto.identity.unauth.IdentityKeyInfo.toObject(includeInstance, f), contentUpload: (f = msg.getContentUpload()) && proto.identity.unauth.Prekey.toObject(includeInstance, f), notifUpload: (f = msg.getNotifUpload()) && proto.identity.unauth.Prekey.toObject(includeInstance, f), oneTimeContentPrekeysList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f, oneTimeNotifPrekeysList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f, deviceType: jspb.Message.getFieldWithDefault(msg, 6, 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.unauth.DeviceKeyUpload} */ proto.identity.unauth.DeviceKeyUpload.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.DeviceKeyUpload; return proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.DeviceKeyUpload} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = new proto.identity.unauth.IdentityKeyInfo; reader.readMessage(value,proto.identity.unauth.IdentityKeyInfo.deserializeBinaryFromReader); msg.setDeviceKeyInfo(value); break; case 2: var value = new proto.identity.unauth.Prekey; reader.readMessage(value,proto.identity.unauth.Prekey.deserializeBinaryFromReader); msg.setContentUpload(value); break; case 3: var value = new proto.identity.unauth.Prekey; reader.readMessage(value,proto.identity.unauth.Prekey.deserializeBinaryFromReader); msg.setNotifUpload(value); break; case 4: var value = /** @type {string} */ (reader.readString()); msg.addOneTimeContentPrekeys(value); break; case 5: var value = /** @type {string} */ (reader.readString()); msg.addOneTimeNotifPrekeys(value); break; case 6: var value = /** @type {!proto.identity.unauth.DeviceType} */ (reader.readEnum()); msg.setDeviceType(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.DeviceKeyUpload.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.DeviceKeyUpload.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.unauth.DeviceKeyUpload} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getDeviceKeyInfo(); if (f != null) { writer.writeMessage( 1, f, proto.identity.unauth.IdentityKeyInfo.serializeBinaryToWriter ); } f = message.getContentUpload(); if (f != null) { writer.writeMessage( 2, f, proto.identity.unauth.Prekey.serializeBinaryToWriter ); } f = message.getNotifUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.Prekey.serializeBinaryToWriter ); } f = message.getOneTimeContentPrekeysList(); if (f.length > 0) { writer.writeRepeatedString( 4, f ); } f = message.getOneTimeNotifPrekeysList(); if (f.length > 0) { writer.writeRepeatedString( 5, f ); } f = message.getDeviceType(); if (f !== 0.0) { writer.writeEnum( 6, f ); } }; /** * optional IdentityKeyInfo device_key_info = 1; * @return {?proto.identity.unauth.IdentityKeyInfo} */ proto.identity.unauth.DeviceKeyUpload.prototype.getDeviceKeyInfo = function() { return /** @type{?proto.identity.unauth.IdentityKeyInfo} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.IdentityKeyInfo, 1)); }; /** * @param {?proto.identity.unauth.IdentityKeyInfo|undefined} value * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.setDeviceKeyInfo = function(value) { return jspb.Message.setWrapperField(this, 1, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.clearDeviceKeyInfo = function() { return this.setDeviceKeyInfo(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.DeviceKeyUpload.prototype.hasDeviceKeyInfo = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional Prekey content_upload = 2; * @return {?proto.identity.unauth.Prekey} */ proto.identity.unauth.DeviceKeyUpload.prototype.getContentUpload = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.Prekey, 2)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.setContentUpload = function(value) { return jspb.Message.setWrapperField(this, 2, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.clearContentUpload = function() { return this.setContentUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.DeviceKeyUpload.prototype.hasContentUpload = function() { return jspb.Message.getField(this, 2) != null; }; /** * optional Prekey notif_upload = 3; * @return {?proto.identity.unauth.Prekey} */ proto.identity.unauth.DeviceKeyUpload.prototype.getNotifUpload = function() { return /** @type{?proto.identity.unauth.Prekey} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.Prekey, 3)); }; /** * @param {?proto.identity.unauth.Prekey|undefined} value * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.setNotifUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.clearNotifUpload = function() { return this.setNotifUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.DeviceKeyUpload.prototype.hasNotifUpload = function() { return jspb.Message.getField(this, 3) != null; }; /** * repeated string one_time_content_prekeys = 4; * @return {!Array} */ proto.identity.unauth.DeviceKeyUpload.prototype.getOneTimeContentPrekeysList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 4)); }; /** * @param {!Array} value * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.setOneTimeContentPrekeysList = function(value) { return jspb.Message.setField(this, 4, value || []); }; /** * @param {string} value * @param {number=} opt_index * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.addOneTimeContentPrekeys = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 4, value, opt_index); }; /** * Clears the list making it empty but non-null. * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.clearOneTimeContentPrekeysList = function() { return this.setOneTimeContentPrekeysList([]); }; /** * repeated string one_time_notif_prekeys = 5; * @return {!Array} */ proto.identity.unauth.DeviceKeyUpload.prototype.getOneTimeNotifPrekeysList = function() { return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); }; /** * @param {!Array} value * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.setOneTimeNotifPrekeysList = function(value) { return jspb.Message.setField(this, 5, value || []); }; /** * @param {string} value * @param {number=} opt_index * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.addOneTimeNotifPrekeys = function(value, opt_index) { return jspb.Message.addToRepeatedField(this, 5, value, opt_index); }; /** * Clears the list making it empty but non-null. * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.clearOneTimeNotifPrekeysList = function() { return this.setOneTimeNotifPrekeysList([]); }; /** * optional DeviceType device_type = 6; * @return {!proto.identity.unauth.DeviceType} */ proto.identity.unauth.DeviceKeyUpload.prototype.getDeviceType = function() { return /** @type {!proto.identity.unauth.DeviceType} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); }; /** * @param {!proto.identity.unauth.DeviceType} value * @return {!proto.identity.unauth.DeviceKeyUpload} returns this */ proto.identity.unauth.DeviceKeyUpload.prototype.setDeviceType = function(value) { return jspb.Message.setProto3EnumField(this, 6, 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.unauth.RegistrationStartRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.RegistrationStartRequest.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.unauth.RegistrationStartRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RegistrationStartRequest.toObject = function(includeInstance, msg) { var f, obj = { opaqueRegistrationRequest: msg.getOpaqueRegistrationRequest_asB64(), username: jspb.Message.getFieldWithDefault(msg, 2, ""), - deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f) + deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f), + farcasterId: jspb.Message.getFieldWithDefault(msg, 4, "") }; 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.unauth.RegistrationStartRequest} */ proto.identity.unauth.RegistrationStartRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.RegistrationStartRequest; return proto.identity.unauth.RegistrationStartRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.RegistrationStartRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.RegistrationStartRequest} */ proto.identity.unauth.RegistrationStartRequest.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; case 2: var value = /** @type {string} */ (reader.readString()); msg.setUsername(value); break; case 3: var value = new proto.identity.unauth.DeviceKeyUpload; reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); msg.setDeviceKeyUpload(value); break; + case 4: + 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.unauth.RegistrationStartRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.RegistrationStartRequest.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.unauth.RegistrationStartRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RegistrationStartRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getOpaqueRegistrationRequest_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } f = message.getUsername(); if (f.length > 0) { writer.writeString( 2, f ); } f = message.getDeviceKeyUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter ); } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } }; /** * optional bytes opaque_registration_request = 1; * @return {string} */ proto.identity.unauth.RegistrationStartRequest.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.unauth.RegistrationStartRequest.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.unauth.RegistrationStartRequest.prototype.getOpaqueRegistrationRequest_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationRequest())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.RegistrationStartRequest} returns this */ proto.identity.unauth.RegistrationStartRequest.prototype.setOpaqueRegistrationRequest = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** * optional string username = 2; * @return {string} */ proto.identity.unauth.RegistrationStartRequest.prototype.getUsername = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.RegistrationStartRequest} returns this */ proto.identity.unauth.RegistrationStartRequest.prototype.setUsername = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional DeviceKeyUpload device_key_upload = 3; * @return {?proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.RegistrationStartRequest.prototype.getDeviceKeyUpload = function() { return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 3)); }; /** * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value * @return {!proto.identity.unauth.RegistrationStartRequest} returns this */ proto.identity.unauth.RegistrationStartRequest.prototype.setDeviceKeyUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.RegistrationStartRequest} returns this */ proto.identity.unauth.RegistrationStartRequest.prototype.clearDeviceKeyUpload = function() { return this.setDeviceKeyUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.RegistrationStartRequest.prototype.hasDeviceKeyUpload = function() { return jspb.Message.getField(this, 3) != null; }; +/** + * optional string farcaster_id = 4; + * @return {string} + */ +proto.identity.unauth.RegistrationStartRequest.prototype.getFarcasterId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.RegistrationStartRequest} returns this + */ +proto.identity.unauth.RegistrationStartRequest.prototype.setFarcasterId = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.identity.unauth.RegistrationStartRequest} returns this + */ +proto.identity.unauth.RegistrationStartRequest.prototype.clearFarcasterId = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.identity.unauth.RegistrationStartRequest.prototype.hasFarcasterId = function() { + return jspb.Message.getField(this, 4) != 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.unauth.ReservedRegistrationStartRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.ReservedRegistrationStartRequest.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.unauth.ReservedRegistrationStartRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.ReservedRegistrationStartRequest.toObject = function(includeInstance, msg) { var f, obj = { opaqueRegistrationRequest: msg.getOpaqueRegistrationRequest_asB64(), username: jspb.Message.getFieldWithDefault(msg, 2, ""), deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f), keyserverMessage: jspb.Message.getFieldWithDefault(msg, 4, ""), keyserverSignature: 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.unauth.ReservedRegistrationStartRequest} */ proto.identity.unauth.ReservedRegistrationStartRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.ReservedRegistrationStartRequest; return proto.identity.unauth.ReservedRegistrationStartRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.ReservedRegistrationStartRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} */ proto.identity.unauth.ReservedRegistrationStartRequest.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; case 2: var value = /** @type {string} */ (reader.readString()); msg.setUsername(value); break; case 3: var value = new proto.identity.unauth.DeviceKeyUpload; reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); msg.setDeviceKeyUpload(value); break; case 4: var value = /** @type {string} */ (reader.readString()); msg.setKeyserverMessage(value); break; case 5: var value = /** @type {string} */ (reader.readString()); msg.setKeyserverSignature(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.ReservedRegistrationStartRequest.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.unauth.ReservedRegistrationStartRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.ReservedRegistrationStartRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getOpaqueRegistrationRequest_asU8(); if (f.length > 0) { writer.writeBytes( 1, f ); } f = message.getUsername(); if (f.length > 0) { writer.writeString( 2, f ); } f = message.getDeviceKeyUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter ); } f = message.getKeyserverMessage(); if (f.length > 0) { writer.writeString( 4, f ); } f = message.getKeyserverSignature(); if (f.length > 0) { writer.writeString( 5, f ); } }; /** * optional bytes opaque_registration_request = 1; * @return {string} */ proto.identity.unauth.ReservedRegistrationStartRequest.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.unauth.ReservedRegistrationStartRequest.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.unauth.ReservedRegistrationStartRequest.prototype.getOpaqueRegistrationRequest_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationRequest())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} returns this */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.setOpaqueRegistrationRequest = function(value) { return jspb.Message.setProto3BytesField(this, 1, value); }; /** * optional string username = 2; * @return {string} */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.getUsername = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} returns this */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.setUsername = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional DeviceKeyUpload device_key_upload = 3; * @return {?proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.getDeviceKeyUpload = function() { return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 3)); }; /** * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} returns this */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.setDeviceKeyUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} returns this */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.clearDeviceKeyUpload = function() { return this.setDeviceKeyUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.hasDeviceKeyUpload = function() { return jspb.Message.getField(this, 3) != null; }; /** * optional string keyserver_message = 4; * @return {string} */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.getKeyserverMessage = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} returns this */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.setKeyserverMessage = function(value) { return jspb.Message.setProto3StringField(this, 4, value); }; /** * optional string keyserver_signature = 5; * @return {string} */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.getKeyserverSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedRegistrationStartRequest} returns this */ proto.identity.unauth.ReservedRegistrationStartRequest.prototype.setKeyserverSignature = function(value) { return jspb.Message.setProto3StringField(this, 5, 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.unauth.RegistrationFinishRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest} */ proto.identity.unauth.RegistrationFinishRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.RegistrationFinishRequest; return proto.identity.unauth.RegistrationFinishRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.RegistrationFinishRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.RegistrationFinishRequest} */ proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest.prototype.getSessionId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.RegistrationFinishRequest} returns this */ proto.identity.unauth.RegistrationFinishRequest.prototype.setSessionId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_registration_upload = 2; * @return {string} */ proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest.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.unauth.RegistrationFinishRequest.prototype.getOpaqueRegistrationUpload_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationUpload())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.RegistrationFinishRequest} returns this */ proto.identity.unauth.RegistrationFinishRequest.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.unauth.RegistrationStartResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse} */ proto.identity.unauth.RegistrationStartResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.RegistrationStartResponse; return proto.identity.unauth.RegistrationStartResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.RegistrationStartResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.RegistrationStartResponse} */ proto.identity.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse.prototype.getSessionId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.RegistrationStartResponse} returns this */ proto.identity.unauth.RegistrationStartResponse.prototype.setSessionId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_registration_response = 2; * @return {string} */ proto.identity.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse.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.unauth.RegistrationStartResponse.prototype.getOpaqueRegistrationResponse_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueRegistrationResponse())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.RegistrationStartResponse} returns this */ proto.identity.unauth.RegistrationStartResponse.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.unauth.AuthResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.AuthResponse.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.unauth.AuthResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.AuthResponse.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, ""), accessToken: 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.unauth.AuthResponse} */ proto.identity.unauth.AuthResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.AuthResponse; return proto.identity.unauth.AuthResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.AuthResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.AuthResponse} */ proto.identity.unauth.AuthResponse.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 {string} */ (reader.readString()); msg.setAccessToken(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.AuthResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.AuthResponse.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.unauth.AuthResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.AuthResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUserId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getAccessToken(); if (f.length > 0) { writer.writeString( 2, f ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.unauth.AuthResponse.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.AuthResponse} returns this */ proto.identity.unauth.AuthResponse.prototype.setUserId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string access_token = 2; * @return {string} */ proto.identity.unauth.AuthResponse.prototype.getAccessToken = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.AuthResponse} returns this */ proto.identity.unauth.AuthResponse.prototype.setAccessToken = function(value) { return jspb.Message.setProto3StringField(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.unauth.OpaqueLoginStartRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.OpaqueLoginStartRequest.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.unauth.OpaqueLoginStartRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.OpaqueLoginStartRequest.toObject = function(includeInstance, msg) { var f, obj = { username: jspb.Message.getFieldWithDefault(msg, 1, ""), opaqueLoginRequest: msg.getOpaqueLoginRequest_asB64(), deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f), force: jspb.Message.getBooleanFieldWithDefault(msg, 4, false) }; 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.unauth.OpaqueLoginStartRequest} */ proto.identity.unauth.OpaqueLoginStartRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.OpaqueLoginStartRequest; return proto.identity.unauth.OpaqueLoginStartRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.OpaqueLoginStartRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.OpaqueLoginStartRequest} */ proto.identity.unauth.OpaqueLoginStartRequest.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 = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setOpaqueLoginRequest(value); break; case 3: var value = new proto.identity.unauth.DeviceKeyUpload; reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); msg.setDeviceKeyUpload(value); break; case 4: var value = /** @type {boolean} */ (reader.readBool()); msg.setForce(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.OpaqueLoginStartRequest.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.unauth.OpaqueLoginStartRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.OpaqueLoginStartRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUsername(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getOpaqueLoginRequest_asU8(); if (f.length > 0) { writer.writeBytes( 2, f ); } f = message.getDeviceKeyUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter ); } f = /** @type {boolean} */ (jspb.Message.getField(message, 4)); if (f != null) { writer.writeBool( 4, f ); } }; /** * optional string username = 1; * @return {string} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.getUsername = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.OpaqueLoginStartRequest} returns this */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.setUsername = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_login_request = 2; * @return {string} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.getOpaqueLoginRequest = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * optional bytes opaque_login_request = 2; * This is a type-conversion wrapper around `getOpaqueLoginRequest()` * @return {string} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.getOpaqueLoginRequest_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( this.getOpaqueLoginRequest())); }; /** * optional bytes opaque_login_request = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getOpaqueLoginRequest()` * @return {!Uint8Array} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.getOpaqueLoginRequest_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueLoginRequest())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.OpaqueLoginStartRequest} returns this */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.setOpaqueLoginRequest = function(value) { return jspb.Message.setProto3BytesField(this, 2, value); }; /** * optional DeviceKeyUpload device_key_upload = 3; * @return {?proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.getDeviceKeyUpload = function() { return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 3)); }; /** * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value * @return {!proto.identity.unauth.OpaqueLoginStartRequest} returns this */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.setDeviceKeyUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.OpaqueLoginStartRequest} returns this */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.clearDeviceKeyUpload = function() { return this.setDeviceKeyUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.hasDeviceKeyUpload = function() { return jspb.Message.getField(this, 3) != null; }; /** * optional bool force = 4; * @return {boolean} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.getForce = function() { return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, false)); }; /** * @param {boolean} value * @return {!proto.identity.unauth.OpaqueLoginStartRequest} returns this */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.setForce = function(value) { return jspb.Message.setField(this, 4, value); }; /** * Clears the field making it undefined. * @return {!proto.identity.unauth.OpaqueLoginStartRequest} returns this */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.clearForce = function() { return jspb.Message.setField(this, 4, undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.OpaqueLoginStartRequest.prototype.hasForce = function() { return jspb.Message.getField(this, 4) != 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.unauth.OpaqueLoginFinishRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.OpaqueLoginFinishRequest.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.unauth.OpaqueLoginFinishRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.OpaqueLoginFinishRequest.toObject = function(includeInstance, msg) { var f, obj = { sessionId: jspb.Message.getFieldWithDefault(msg, 1, ""), opaqueLoginUpload: msg.getOpaqueLoginUpload_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.unauth.OpaqueLoginFinishRequest} */ proto.identity.unauth.OpaqueLoginFinishRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.OpaqueLoginFinishRequest; return proto.identity.unauth.OpaqueLoginFinishRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.OpaqueLoginFinishRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.OpaqueLoginFinishRequest} */ proto.identity.unauth.OpaqueLoginFinishRequest.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.setOpaqueLoginUpload(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.OpaqueLoginFinishRequest.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.unauth.OpaqueLoginFinishRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.OpaqueLoginFinishRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getSessionId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getOpaqueLoginUpload_asU8(); if (f.length > 0) { writer.writeBytes( 2, f ); } }; /** * optional string session_id = 1; * @return {string} */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.getSessionId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.OpaqueLoginFinishRequest} returns this */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.setSessionId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_login_upload = 2; * @return {string} */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.getOpaqueLoginUpload = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * optional bytes opaque_login_upload = 2; * This is a type-conversion wrapper around `getOpaqueLoginUpload()` * @return {string} */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.getOpaqueLoginUpload_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( this.getOpaqueLoginUpload())); }; /** * optional bytes opaque_login_upload = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getOpaqueLoginUpload()` * @return {!Uint8Array} */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.getOpaqueLoginUpload_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueLoginUpload())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.OpaqueLoginFinishRequest} returns this */ proto.identity.unauth.OpaqueLoginFinishRequest.prototype.setOpaqueLoginUpload = 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.unauth.OpaqueLoginStartResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.OpaqueLoginStartResponse.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.unauth.OpaqueLoginStartResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.OpaqueLoginStartResponse.toObject = function(includeInstance, msg) { var f, obj = { sessionId: jspb.Message.getFieldWithDefault(msg, 1, ""), opaqueLoginResponse: msg.getOpaqueLoginResponse_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.unauth.OpaqueLoginStartResponse} */ proto.identity.unauth.OpaqueLoginStartResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.OpaqueLoginStartResponse; return proto.identity.unauth.OpaqueLoginStartResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.OpaqueLoginStartResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.OpaqueLoginStartResponse} */ proto.identity.unauth.OpaqueLoginStartResponse.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.setOpaqueLoginResponse(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.OpaqueLoginStartResponse.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.unauth.OpaqueLoginStartResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.OpaqueLoginStartResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getSessionId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getOpaqueLoginResponse_asU8(); if (f.length > 0) { writer.writeBytes( 2, f ); } }; /** * optional string session_id = 1; * @return {string} */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.getSessionId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.OpaqueLoginStartResponse} returns this */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.setSessionId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional bytes opaque_login_response = 2; * @return {string} */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.getOpaqueLoginResponse = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * optional bytes opaque_login_response = 2; * This is a type-conversion wrapper around `getOpaqueLoginResponse()` * @return {string} */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.getOpaqueLoginResponse_asB64 = function() { return /** @type {string} */ (jspb.Message.bytesAsB64( this.getOpaqueLoginResponse())); }; /** * optional bytes opaque_login_response = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getOpaqueLoginResponse()` * @return {!Uint8Array} */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.getOpaqueLoginResponse_asU8 = function() { return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( this.getOpaqueLoginResponse())); }; /** * @param {!(string|Uint8Array)} value * @return {!proto.identity.unauth.OpaqueLoginStartResponse} returns this */ proto.identity.unauth.OpaqueLoginStartResponse.prototype.setOpaqueLoginResponse = 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.unauth.WalletAuthRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.WalletAuthRequest.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.unauth.WalletAuthRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.WalletAuthRequest.toObject = function(includeInstance, msg) { var f, obj = { siweMessage: jspb.Message.getFieldWithDefault(msg, 1, ""), siweSignature: jspb.Message.getFieldWithDefault(msg, 2, ""), - deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f) + deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f), + farcasterId: jspb.Message.getFieldWithDefault(msg, 4, "") }; 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.unauth.WalletAuthRequest} */ proto.identity.unauth.WalletAuthRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.WalletAuthRequest; return proto.identity.unauth.WalletAuthRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.WalletAuthRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.WalletAuthRequest} */ proto.identity.unauth.WalletAuthRequest.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.setSiweMessage(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setSiweSignature(value); break; case 3: var value = new proto.identity.unauth.DeviceKeyUpload; reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); msg.setDeviceKeyUpload(value); break; + case 4: + 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.unauth.WalletAuthRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.WalletAuthRequest.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.unauth.WalletAuthRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.WalletAuthRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getSiweMessage(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getSiweSignature(); if (f.length > 0) { writer.writeString( 2, f ); } f = message.getDeviceKeyUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter ); } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } }; /** * optional string siwe_message = 1; * @return {string} */ proto.identity.unauth.WalletAuthRequest.prototype.getSiweMessage = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.WalletAuthRequest} returns this */ proto.identity.unauth.WalletAuthRequest.prototype.setSiweMessage = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string siwe_signature = 2; * @return {string} */ proto.identity.unauth.WalletAuthRequest.prototype.getSiweSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.WalletAuthRequest} returns this */ proto.identity.unauth.WalletAuthRequest.prototype.setSiweSignature = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional DeviceKeyUpload device_key_upload = 3; * @return {?proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.WalletAuthRequest.prototype.getDeviceKeyUpload = function() { return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 3)); }; /** * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value * @return {!proto.identity.unauth.WalletAuthRequest} returns this */ proto.identity.unauth.WalletAuthRequest.prototype.setDeviceKeyUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.WalletAuthRequest} returns this */ proto.identity.unauth.WalletAuthRequest.prototype.clearDeviceKeyUpload = function() { return this.setDeviceKeyUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.WalletAuthRequest.prototype.hasDeviceKeyUpload = function() { return jspb.Message.getField(this, 3) != null; }; +/** + * optional string farcaster_id = 4; + * @return {string} + */ +proto.identity.unauth.WalletAuthRequest.prototype.getFarcasterId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.WalletAuthRequest} returns this + */ +proto.identity.unauth.WalletAuthRequest.prototype.setFarcasterId = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.identity.unauth.WalletAuthRequest} returns this + */ +proto.identity.unauth.WalletAuthRequest.prototype.clearFarcasterId = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.identity.unauth.WalletAuthRequest.prototype.hasFarcasterId = function() { + return jspb.Message.getField(this, 4) != 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.unauth.ReservedWalletRegistrationRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.ReservedWalletRegistrationRequest.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.unauth.ReservedWalletRegistrationRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.ReservedWalletRegistrationRequest.toObject = function(includeInstance, msg) { var f, obj = { siweMessage: jspb.Message.getFieldWithDefault(msg, 1, ""), siweSignature: jspb.Message.getFieldWithDefault(msg, 2, ""), deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.toObject(includeInstance, f), keyserverMessage: jspb.Message.getFieldWithDefault(msg, 4, ""), keyserverSignature: 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.unauth.ReservedWalletRegistrationRequest} */ proto.identity.unauth.ReservedWalletRegistrationRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.ReservedWalletRegistrationRequest; return proto.identity.unauth.ReservedWalletRegistrationRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.ReservedWalletRegistrationRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} */ proto.identity.unauth.ReservedWalletRegistrationRequest.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.setSiweMessage(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setSiweSignature(value); break; case 3: var value = new proto.identity.unauth.DeviceKeyUpload; reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); msg.setDeviceKeyUpload(value); break; case 4: var value = /** @type {string} */ (reader.readString()); msg.setKeyserverMessage(value); break; case 5: var value = /** @type {string} */ (reader.readString()); msg.setKeyserverSignature(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.ReservedWalletRegistrationRequest.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.unauth.ReservedWalletRegistrationRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.ReservedWalletRegistrationRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getSiweMessage(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getSiweSignature(); if (f.length > 0) { writer.writeString( 2, f ); } f = message.getDeviceKeyUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter ); } f = message.getKeyserverMessage(); if (f.length > 0) { writer.writeString( 4, f ); } f = message.getKeyserverSignature(); if (f.length > 0) { writer.writeString( 5, f ); } }; /** * optional string siwe_message = 1; * @return {string} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.getSiweMessage = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} returns this */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.setSiweMessage = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string siwe_signature = 2; * @return {string} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.getSiweSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} returns this */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.setSiweSignature = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional DeviceKeyUpload device_key_upload = 3; * @return {?proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.getDeviceKeyUpload = function() { return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 3)); }; /** * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} returns this */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.setDeviceKeyUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} returns this */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.clearDeviceKeyUpload = function() { return this.setDeviceKeyUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.hasDeviceKeyUpload = function() { return jspb.Message.getField(this, 3) != null; }; /** * optional string keyserver_message = 4; * @return {string} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.getKeyserverMessage = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} returns this */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.setKeyserverMessage = function(value) { return jspb.Message.setProto3StringField(this, 4, value); }; /** * optional string keyserver_signature = 5; * @return {string} */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.getKeyserverSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.ReservedWalletRegistrationRequest} returns this */ proto.identity.unauth.ReservedWalletRegistrationRequest.prototype.setKeyserverSignature = function(value) { return jspb.Message.setProto3StringField(this, 5, 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.unauth.SecondaryDeviceKeysUploadRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.SecondaryDeviceKeysUploadRequest.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.unauth.SecondaryDeviceKeysUploadRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, ""), challengeResponse: jspb.Message.getFieldWithDefault(msg, 2, ""), deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.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.unauth.SecondaryDeviceKeysUploadRequest} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.SecondaryDeviceKeysUploadRequest; return proto.identity.unauth.SecondaryDeviceKeysUploadRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.SecondaryDeviceKeysUploadRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.SecondaryDeviceKeysUploadRequest} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.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 {string} */ (reader.readString()); msg.setChallengeResponse(value); break; case 3: var value = new proto.identity.unauth.DeviceKeyUpload; reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); msg.setDeviceKeyUpload(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.SecondaryDeviceKeysUploadRequest.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.unauth.SecondaryDeviceKeysUploadRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUserId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getChallengeResponse(); if (f.length > 0) { writer.writeString( 2, f ); } f = message.getDeviceKeyUpload(); if (f != null) { writer.writeMessage( 3, f, proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.SecondaryDeviceKeysUploadRequest} returns this */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.setUserId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string challenge_response = 2; * @return {string} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.getChallengeResponse = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.SecondaryDeviceKeysUploadRequest} returns this */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.setChallengeResponse = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional DeviceKeyUpload device_key_upload = 3; * @return {?proto.identity.unauth.DeviceKeyUpload} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.getDeviceKeyUpload = function() { return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 3)); }; /** * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value * @return {!proto.identity.unauth.SecondaryDeviceKeysUploadRequest} returns this */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.setDeviceKeyUpload = function(value) { return jspb.Message.setWrapperField(this, 3, value); }; /** * Clears the message field making it undefined. * @return {!proto.identity.unauth.SecondaryDeviceKeysUploadRequest} returns this */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.clearDeviceKeyUpload = function() { return this.setDeviceKeyUpload(undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.prototype.hasDeviceKeyUpload = 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.unauth.GenerateNonceResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.GenerateNonceResponse.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.unauth.GenerateNonceResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.GenerateNonceResponse.toObject = function(includeInstance, msg) { var f, obj = { nonce: 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.unauth.GenerateNonceResponse} */ proto.identity.unauth.GenerateNonceResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.GenerateNonceResponse; return proto.identity.unauth.GenerateNonceResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.GenerateNonceResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.GenerateNonceResponse} */ proto.identity.unauth.GenerateNonceResponse.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.setNonce(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.GenerateNonceResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.GenerateNonceResponse.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.unauth.GenerateNonceResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.GenerateNonceResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getNonce(); if (f.length > 0) { writer.writeString( 1, f ); } }; /** * optional string nonce = 1; * @return {string} */ proto.identity.unauth.GenerateNonceResponse.prototype.getNonce = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.GenerateNonceResponse} returns this */ proto.identity.unauth.GenerateNonceResponse.prototype.setNonce = 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.unauth.VerifyUserAccessTokenRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.VerifyUserAccessTokenRequest.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.unauth.VerifyUserAccessTokenRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.VerifyUserAccessTokenRequest.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, ""), deviceId: jspb.Message.getFieldWithDefault(msg, 2, ""), accessToken: jspb.Message.getFieldWithDefault(msg, 3, "") }; 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.unauth.VerifyUserAccessTokenRequest} */ proto.identity.unauth.VerifyUserAccessTokenRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.VerifyUserAccessTokenRequest; return proto.identity.unauth.VerifyUserAccessTokenRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.VerifyUserAccessTokenRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.VerifyUserAccessTokenRequest} */ proto.identity.unauth.VerifyUserAccessTokenRequest.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 {string} */ (reader.readString()); msg.setDeviceId(value); break; case 3: var value = /** @type {string} */ (reader.readString()); msg.setAccessToken(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.VerifyUserAccessTokenRequest.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.unauth.VerifyUserAccessTokenRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.VerifyUserAccessTokenRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getUserId(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getDeviceId(); if (f.length > 0) { writer.writeString( 2, f ); } f = message.getAccessToken(); if (f.length > 0) { writer.writeString( 3, f ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.VerifyUserAccessTokenRequest} returns this */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.setUserId = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string device_id = 2; * @return {string} */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.getDeviceId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.VerifyUserAccessTokenRequest} returns this */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.setDeviceId = function(value) { return jspb.Message.setProto3StringField(this, 2, value); }; /** * optional string access_token = 3; * @return {string} */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.getAccessToken = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.VerifyUserAccessTokenRequest} returns this */ proto.identity.unauth.VerifyUserAccessTokenRequest.prototype.setAccessToken = function(value) { return jspb.Message.setProto3StringField(this, 3, 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.unauth.VerifyUserAccessTokenResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.VerifyUserAccessTokenResponse.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.unauth.VerifyUserAccessTokenResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.VerifyUserAccessTokenResponse.toObject = function(includeInstance, msg) { var f, obj = { tokenValid: jspb.Message.getBooleanFieldWithDefault(msg, 1, false) }; 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.unauth.VerifyUserAccessTokenResponse} */ proto.identity.unauth.VerifyUserAccessTokenResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.VerifyUserAccessTokenResponse; return proto.identity.unauth.VerifyUserAccessTokenResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.VerifyUserAccessTokenResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.VerifyUserAccessTokenResponse} */ proto.identity.unauth.VerifyUserAccessTokenResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { case 1: var value = /** @type {boolean} */ (reader.readBool()); msg.setTokenValid(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.VerifyUserAccessTokenResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.VerifyUserAccessTokenResponse.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.unauth.VerifyUserAccessTokenResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.VerifyUserAccessTokenResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getTokenValid(); if (f) { writer.writeBool( 1, f ); } }; /** * optional bool token_valid = 1; * @return {boolean} */ proto.identity.unauth.VerifyUserAccessTokenResponse.prototype.getTokenValid = function() { return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); }; /** * @param {boolean} value * @return {!proto.identity.unauth.VerifyUserAccessTokenResponse} returns this */ proto.identity.unauth.VerifyUserAccessTokenResponse.prototype.setTokenValid = function(value) { return jspb.Message.setProto3BooleanField(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.unauth.AddReservedUsernamesRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.AddReservedUsernamesRequest.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.unauth.AddReservedUsernamesRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.AddReservedUsernamesRequest.toObject = function(includeInstance, msg) { var f, obj = { message: jspb.Message.getFieldWithDefault(msg, 1, ""), signature: 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.unauth.AddReservedUsernamesRequest} */ proto.identity.unauth.AddReservedUsernamesRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.AddReservedUsernamesRequest; return proto.identity.unauth.AddReservedUsernamesRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.AddReservedUsernamesRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.AddReservedUsernamesRequest} */ proto.identity.unauth.AddReservedUsernamesRequest.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.setMessage(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setSignature(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.AddReservedUsernamesRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.AddReservedUsernamesRequest.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.unauth.AddReservedUsernamesRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.AddReservedUsernamesRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getMessage(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getSignature(); if (f.length > 0) { writer.writeString( 2, f ); } }; /** * optional string message = 1; * @return {string} */ proto.identity.unauth.AddReservedUsernamesRequest.prototype.getMessage = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.AddReservedUsernamesRequest} returns this */ proto.identity.unauth.AddReservedUsernamesRequest.prototype.setMessage = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string signature = 2; * @return {string} */ proto.identity.unauth.AddReservedUsernamesRequest.prototype.getSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.AddReservedUsernamesRequest} returns this */ proto.identity.unauth.AddReservedUsernamesRequest.prototype.setSignature = function(value) { return jspb.Message.setProto3StringField(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.unauth.RemoveReservedUsernameRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.RemoveReservedUsernameRequest.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.unauth.RemoveReservedUsernameRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RemoveReservedUsernameRequest.toObject = function(includeInstance, msg) { var f, obj = { message: jspb.Message.getFieldWithDefault(msg, 1, ""), signature: 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.unauth.RemoveReservedUsernameRequest} */ proto.identity.unauth.RemoveReservedUsernameRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.RemoveReservedUsernameRequest; return proto.identity.unauth.RemoveReservedUsernameRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.RemoveReservedUsernameRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.RemoveReservedUsernameRequest} */ proto.identity.unauth.RemoveReservedUsernameRequest.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.setMessage(value); break; case 2: var value = /** @type {string} */ (reader.readString()); msg.setSignature(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.RemoveReservedUsernameRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.RemoveReservedUsernameRequest.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.unauth.RemoveReservedUsernameRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.RemoveReservedUsernameRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = message.getMessage(); if (f.length > 0) { writer.writeString( 1, f ); } f = message.getSignature(); if (f.length > 0) { writer.writeString( 2, f ); } }; /** * optional string message = 1; * @return {string} */ proto.identity.unauth.RemoveReservedUsernameRequest.prototype.getMessage = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.RemoveReservedUsernameRequest} returns this */ proto.identity.unauth.RemoveReservedUsernameRequest.prototype.setMessage = function(value) { return jspb.Message.setProto3StringField(this, 1, value); }; /** * optional string signature = 2; * @return {string} */ proto.identity.unauth.RemoveReservedUsernameRequest.prototype.getSignature = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.RemoveReservedUsernameRequest} returns this */ proto.identity.unauth.RemoveReservedUsernameRequest.prototype.setSignature = 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.unauth.FindUserIDRequest.oneofGroups_ = [[1,2]]; /** * @enum {number} */ proto.identity.unauth.FindUserIDRequest.IdentifierCase = { IDENTIFIER_NOT_SET: 0, USERNAME: 1, WALLET_ADDRESS: 2 }; /** * @return {proto.identity.unauth.FindUserIDRequest.IdentifierCase} */ proto.identity.unauth.FindUserIDRequest.prototype.getIdentifierCase = function() { return /** @type {proto.identity.unauth.FindUserIDRequest.IdentifierCase} */(jspb.Message.computeOneofCase(this, proto.identity.unauth.FindUserIDRequest.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.unauth.FindUserIDRequest.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.FindUserIDRequest.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.unauth.FindUserIDRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.FindUserIDRequest.toObject = function(includeInstance, msg) { var f, obj = { username: jspb.Message.getFieldWithDefault(msg, 1, ""), walletAddress: 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.unauth.FindUserIDRequest} */ proto.identity.unauth.FindUserIDRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.FindUserIDRequest; return proto.identity.unauth.FindUserIDRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.FindUserIDRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.FindUserIDRequest} */ proto.identity.unauth.FindUserIDRequest.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 = /** @type {string} */ (reader.readString()); msg.setWalletAddress(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.FindUserIDRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.FindUserIDRequest.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.unauth.FindUserIDRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.FindUserIDRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = /** @type {string} */ (jspb.Message.getField(message, 1)); if (f != null) { writer.writeString( 1, f ); } f = /** @type {string} */ (jspb.Message.getField(message, 2)); if (f != null) { writer.writeString( 2, f ); } }; /** * optional string username = 1; * @return {string} */ proto.identity.unauth.FindUserIDRequest.prototype.getUsername = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.FindUserIDRequest} returns this */ proto.identity.unauth.FindUserIDRequest.prototype.setUsername = function(value) { return jspb.Message.setOneofField(this, 1, proto.identity.unauth.FindUserIDRequest.oneofGroups_[0], value); }; /** * Clears the field making it undefined. * @return {!proto.identity.unauth.FindUserIDRequest} returns this */ proto.identity.unauth.FindUserIDRequest.prototype.clearUsername = function() { return jspb.Message.setOneofField(this, 1, proto.identity.unauth.FindUserIDRequest.oneofGroups_[0], undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.FindUserIDRequest.prototype.hasUsername = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional string wallet_address = 2; * @return {string} */ proto.identity.unauth.FindUserIDRequest.prototype.getWalletAddress = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.FindUserIDRequest} returns this */ proto.identity.unauth.FindUserIDRequest.prototype.setWalletAddress = function(value) { return jspb.Message.setOneofField(this, 2, proto.identity.unauth.FindUserIDRequest.oneofGroups_[0], value); }; /** * Clears the field making it undefined. * @return {!proto.identity.unauth.FindUserIDRequest} returns this */ proto.identity.unauth.FindUserIDRequest.prototype.clearWalletAddress = function() { return jspb.Message.setOneofField(this, 2, proto.identity.unauth.FindUserIDRequest.oneofGroups_[0], undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.FindUserIDRequest.prototype.hasWalletAddress = 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.unauth.FindUserIDResponse.prototype.toObject = function(opt_includeInstance) { return proto.identity.unauth.FindUserIDResponse.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.unauth.FindUserIDResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.FindUserIDResponse.toObject = function(includeInstance, msg) { var f, obj = { userId: jspb.Message.getFieldWithDefault(msg, 1, ""), isReserved: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) }; 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.unauth.FindUserIDResponse} */ proto.identity.unauth.FindUserIDResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); var msg = new proto.identity.unauth.FindUserIDResponse; return proto.identity.unauth.FindUserIDResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. * @param {!proto.identity.unauth.FindUserIDResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. * @return {!proto.identity.unauth.FindUserIDResponse} */ proto.identity.unauth.FindUserIDResponse.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 {boolean} */ (reader.readBool()); msg.setIsReserved(value); break; default: reader.skipField(); break; } } return msg; }; /** * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ proto.identity.unauth.FindUserIDResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); proto.identity.unauth.FindUserIDResponse.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.unauth.FindUserIDResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ proto.identity.unauth.FindUserIDResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; f = /** @type {string} */ (jspb.Message.getField(message, 1)); if (f != null) { writer.writeString( 1, f ); } f = message.getIsReserved(); if (f) { writer.writeBool( 2, f ); } }; /** * optional string user_id = 1; * @return {string} */ proto.identity.unauth.FindUserIDResponse.prototype.getUserId = function() { return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** * @param {string} value * @return {!proto.identity.unauth.FindUserIDResponse} returns this */ proto.identity.unauth.FindUserIDResponse.prototype.setUserId = function(value) { return jspb.Message.setField(this, 1, value); }; /** * Clears the field making it undefined. * @return {!proto.identity.unauth.FindUserIDResponse} returns this */ proto.identity.unauth.FindUserIDResponse.prototype.clearUserId = function() { return jspb.Message.setField(this, 1, undefined); }; /** * Returns whether this field is set. * @return {boolean} */ proto.identity.unauth.FindUserIDResponse.prototype.hasUserId = function() { return jspb.Message.getField(this, 1) != null; }; /** * optional bool is_reserved = 2; * @return {boolean} */ proto.identity.unauth.FindUserIDResponse.prototype.getIsReserved = function() { return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); }; /** * @param {boolean} value * @return {!proto.identity.unauth.FindUserIDResponse} returns this */ proto.identity.unauth.FindUserIDResponse.prototype.setIsReserved = function(value) { return jspb.Message.setProto3BooleanField(this, 2, value); }; /** * @enum {number} */ proto.identity.unauth.DeviceType = { KEYSERVER: 0, WEB: 1, IOS: 2, ANDROID: 3, WINDOWS: 4, MAC_OS: 5 }; goog.object.extend(exports, proto.identity.unauth); diff --git a/web/protobufs/identity-unauth-structs.cjs.flow b/web/protobufs/identity-unauth-structs.cjs.flow index 5387377a5..a8f27ce74 100644 --- a/web/protobufs/identity-unauth-structs.cjs.flow +++ b/web/protobufs/identity-unauth-structs.cjs.flow @@ -1,544 +1,556 @@ // @flow import { Message, BinaryWriter, BinaryReader, Map as ProtoMap, } from 'google-protobuf'; declare export class Empty extends Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): {}; static toObject(includeInstance: boolean, msg: Empty): {}; static serializeBinaryToWriter(message: Empty, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Empty; static deserializeBinaryFromReader(message: Empty, reader: BinaryReader): Empty; } export type PrekeyObject = { prekey: string, prekeySignature: string, } declare export class Prekey extends Message { getPrekey(): string; setPrekey(value: string): Prekey; getPrekeySignature(): string; setPrekeySignature(value: string): Prekey; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): PrekeyObject; static toObject(includeInstance: boolean, msg: Prekey): PrekeyObject; static serializeBinaryToWriter(message: Prekey, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): Prekey; static deserializeBinaryFromReader(message: Prekey, reader: BinaryReader): Prekey; } export type IdentityKeyInfoObject = { payload: string, payloadSignature: string, socialProof?: string, }; declare export class IdentityKeyInfo extends Message { getPayload(): string; setPayload(value: string): IdentityKeyInfo; getPayloadSignature(): string; setPayloadSignature(value: string): IdentityKeyInfo; getSocialProof(): string; setSocialProof(value: string): IdentityKeyInfo; hasSocialProof(): boolean; clearSocialProof(): IdentityKeyInfo; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): IdentityKeyInfoObject; static toObject(includeInstance: boolean, msg: IdentityKeyInfo): IdentityKeyInfoObject; static serializeBinaryToWriter(message: IdentityKeyInfo, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): IdentityKeyInfo; static deserializeBinaryFromReader(message: IdentityKeyInfo, reader: BinaryReader): IdentityKeyInfo; } declare export class DeviceKeyUpload extends Message { getDeviceKeyInfo(): IdentityKeyInfo | void; setDeviceKeyInfo(value?: IdentityKeyInfo): DeviceKeyUpload; hasDeviceKeyInfo(): boolean; clearDeviceKeyInfo(): DeviceKeyUpload; getContentUpload(): Prekey | void; setContentUpload(value?: Prekey): DeviceKeyUpload; hasContentUpload(): boolean; clearContentUpload(): DeviceKeyUpload; getNotifUpload(): Prekey | void; setNotifUpload(value?: Prekey): DeviceKeyUpload; hasNotifUpload(): boolean; clearNotifUpload(): DeviceKeyUpload; getOneTimeContentPrekeysList(): Array; setOneTimeContentPrekeysList(value: Array): DeviceKeyUpload; clearOneTimeContentPrekeysList(): DeviceKeyUpload; addOneTimeContentPrekeys(value: string, index?: number): DeviceKeyUpload; getOneTimeNotifPrekeysList(): Array; setOneTimeNotifPrekeysList(value: Array): DeviceKeyUpload; clearOneTimeNotifPrekeysList(): DeviceKeyUpload; addOneTimeNotifPrekeys(value: string, index?: number): DeviceKeyUpload; getDeviceType(): DeviceType; setDeviceType(value: DeviceType): DeviceKeyUpload; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): DeviceKeyUploadObject; static toObject(includeInstance: boolean, msg: DeviceKeyUpload): DeviceKeyUploadObject; static serializeBinaryToWriter(message: DeviceKeyUpload, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): DeviceKeyUpload; static deserializeBinaryFromReader(message: DeviceKeyUpload, reader: BinaryReader): DeviceKeyUpload; } export type DeviceKeyUploadObject = { deviceKeyInfo?: IdentityKeyInfoObject, contentUpload?: PrekeyObject, notifUpload?: PrekeyObject, oneTimeContentPrekeysList: Array, oneTimeNotifPrekeysList: Array, deviceType: DeviceType, }; declare export class RegistrationStartRequest extends Message { getOpaqueRegistrationRequest(): Uint8Array | string; getOpaqueRegistrationRequest_asU8(): Uint8Array; getOpaqueRegistrationRequest_asB64(): string; setOpaqueRegistrationRequest(value: Uint8Array | string): RegistrationStartRequest; getUsername(): string; setUsername(value: string): RegistrationStartRequest; getDeviceKeyUpload(): DeviceKeyUpload | void; setDeviceKeyUpload(value?: DeviceKeyUpload): RegistrationStartRequest; hasDeviceKeyUpload(): boolean; clearDeviceKeyUpload(): RegistrationStartRequest; + getFarcasterId(): string; + setFarcasterId(value: string): RegistrationStartRequest; + hasFarcasterId(): boolean; + clearFarcasterId(): RegistrationStartRequest; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RegistrationStartRequestObject; static toObject(includeInstance: boolean, msg: RegistrationStartRequest): RegistrationStartRequestObject; static serializeBinaryToWriter(message: RegistrationStartRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RegistrationStartRequest; static deserializeBinaryFromReader(message: RegistrationStartRequest, reader: BinaryReader): RegistrationStartRequest; } export type RegistrationStartRequestObject = { opaqueRegistrationRequest: Uint8Array | string, username: string, deviceKeyUpload?: DeviceKeyUploadObject, + farcasterId?: string, }; declare export class ReservedRegistrationStartRequest extends Message { getOpaqueRegistrationRequest(): Uint8Array | string; getOpaqueRegistrationRequest_asU8(): Uint8Array; getOpaqueRegistrationRequest_asB64(): string; setOpaqueRegistrationRequest(value: Uint8Array | string): ReservedRegistrationStartRequest; getUsername(): string; setUsername(value: string): ReservedRegistrationStartRequest; getDeviceKeyUpload(): DeviceKeyUpload | void; setDeviceKeyUpload(value?: DeviceKeyUpload): ReservedRegistrationStartRequest; hasDeviceKeyUpload(): boolean; clearDeviceKeyUpload(): ReservedRegistrationStartRequest; getKeyserverMessage(): string; setKeyserverMessage(value: string): ReservedRegistrationStartRequest; getKeyserverSignature(): string; setKeyserverSignature(value: string): ReservedRegistrationStartRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): ReservedRegistrationStartRequestObject; static toObject(includeInstance: boolean, msg: ReservedRegistrationStartRequest): ReservedRegistrationStartRequestObject; static serializeBinaryToWriter(message: ReservedRegistrationStartRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): ReservedRegistrationStartRequest; static deserializeBinaryFromReader(message: ReservedRegistrationStartRequest, reader: BinaryReader): ReservedRegistrationStartRequest; } export type ReservedRegistrationStartRequestObject = { opaqueRegistrationRequest: Uint8Array | string, username: string, deviceKeyUpload?: DeviceKeyUploadObject, keyserverMessage: string, keyserverSignature: string, }; declare export class RegistrationFinishRequest extends Message { getSessionid(): string; setSessionid(value: string): RegistrationFinishRequest; getOpaqueregistrationupload(): Uint8Array | string; getOpaqueregistrationupload_asU8(): Uint8Array; getOpaqueregistrationupload_asB64(): string; setOpaqueregistrationupload(value: Uint8Array | string): RegistrationFinishRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RegistrationFinishRequestObject; static toObject(includeInstance: boolean, msg: RegistrationFinishRequest): RegistrationFinishRequestObject; static serializeBinaryToWriter(message: RegistrationFinishRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RegistrationFinishRequest; static deserializeBinaryFromReader(message: RegistrationFinishRequest, reader: BinaryReader): RegistrationFinishRequest; } export type RegistrationFinishRequestObject = { sessionid: string, opaqueregistrationupload: Uint8Array | string, }; declare export class RegistrationStartResponse extends Message { getSessionId(): string; setSessionId(value: string): RegistrationStartResponse; getOpaqueRegistrationResponse(): Uint8Array | string; getOpaqueRegistrationResponse_asU8(): Uint8Array; getOpaqueRegistrationResponse_asB64(): string; setOpaqueRegistrationResponse(value: Uint8Array | string): RegistrationStartResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RegistrationStartResponseObject; static toObject(includeInstance: boolean, msg: RegistrationStartResponse): RegistrationStartResponseObject; static serializeBinaryToWriter(message: RegistrationStartResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RegistrationStartResponse; static deserializeBinaryFromReader(message: RegistrationStartResponse, reader: BinaryReader): RegistrationStartResponse; } export type RegistrationStartResponseObject = { sessionId: string, opaqueRegistrationResponse: Uint8Array | string, }; declare export class AuthResponse extends Message { getUserId(): string; setUserId(value: string): AuthResponse; getAccessToken(): string; setAccessToken(value: string): AuthResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): AuthResponseObject; static toObject(includeInstance: boolean, msg: AuthResponse): AuthResponseObject; static serializeBinaryToWriter(message: AuthResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): AuthResponse; static deserializeBinaryFromReader(message: AuthResponse, reader: BinaryReader): AuthResponse; } export type AuthResponseObject = { userId: string, accessToken: string, }; declare export class OpaqueLoginStartRequest extends Message { getUsername(): string; setUsername(value: string): OpaqueLoginStartRequest; getOpaqueLoginRequest(): Uint8Array | string; getOpaqueLoginRequest_asU8(): Uint8Array; getOpaqueLoginRequest_asB64(): string; setOpaqueLoginRequest(value: Uint8Array | string): OpaqueLoginStartRequest; getDeviceKeyUpload(): DeviceKeyUpload | void; setDeviceKeyUpload(value?: DeviceKeyUpload): OpaqueLoginStartRequest; hasDeviceKeyUpload(): boolean; clearDeviceKeyUpload(): OpaqueLoginStartRequest; getForce(): boolean; setForce(value: boolean): OpaqueLoginStartRequest; hasForce(): boolean; clearForce(): OpaqueLoginStartRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): OpaqueLoginStartRequestObject; static toObject(includeInstance: boolean, msg: OpaqueLoginStartRequest): OpaqueLoginStartRequestObject; static serializeBinaryToWriter(message: OpaqueLoginStartRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): OpaqueLoginStartRequest; static deserializeBinaryFromReader(message: OpaqueLoginStartRequest, reader: BinaryReader): OpaqueLoginStartRequest; } export type OpaqueLoginStartRequestObject = { username: string, opaqueLoginRequest: Uint8Array | string, deviceKeyUpload?: DeviceKeyUploadObject, force?: boolean, }; declare export class OpaqueLoginFinishRequest extends Message { getSessionId(): string; setSessionId(value: string): OpaqueLoginFinishRequest; getOpaqueLoginUpload(): Uint8Array | string; getOpaqueLoginUpload_asU8(): Uint8Array; getOpaqueLoginUpload_asB64(): string; setOpaqueLoginUpload(value: Uint8Array | string): OpaqueLoginFinishRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): OpaqueLoginFinishRequestObject; static toObject(includeInstance: boolean, msg: OpaqueLoginFinishRequest): OpaqueLoginFinishRequestObject; static serializeBinaryToWriter(message: OpaqueLoginFinishRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): OpaqueLoginFinishRequest; static deserializeBinaryFromReader(message: OpaqueLoginFinishRequest, reader: BinaryReader): OpaqueLoginFinishRequest; } export type OpaqueLoginFinishRequestObject = { sessionId: string, opaqueLoginUpload: Uint8Array | string, }; declare export class OpaqueLoginStartResponse extends Message { getSessionId(): string; setSessionId(value: string): OpaqueLoginStartResponse; getOpaqueLoginResponse(): Uint8Array | string; getOpaqueLoginResponse_asU8(): Uint8Array; getOpaqueLoginResponse_asB64(): string; setOpaqueLoginResponse(value: Uint8Array | string): OpaqueLoginStartResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): OpaqueLoginStartResponseObject; static toObject(includeInstance: boolean, msg: OpaqueLoginStartResponse): OpaqueLoginStartResponseObject; static serializeBinaryToWriter(message: OpaqueLoginStartResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): OpaqueLoginStartResponse; static deserializeBinaryFromReader(message: OpaqueLoginStartResponse, reader: BinaryReader): OpaqueLoginStartResponse; } export type OpaqueLoginStartResponseObject = { sessionId: string, opaqueLoginResponse: Uint8Array | string, }; declare export class WalletAuthRequest extends Message { getSiweMessage(): string; setSiweMessage(value: string): WalletAuthRequest; getSiweSignature(): string; setSiweSignature(value: string): WalletAuthRequest; getDeviceKeyUpload(): DeviceKeyUpload | void; setDeviceKeyUpload(value?: DeviceKeyUpload): WalletAuthRequest; hasDeviceKeyUpload(): boolean; clearDeviceKeyUpload(): WalletAuthRequest; + getFarcasterId(): string; + setFarcasterId(value: string): WalletAuthRequest; + hasFarcasterId(): boolean; + clearFarcasterId(): WalletAuthRequest; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): WalletAuthRequestObject; static toObject(includeInstance: boolean, msg: WalletAuthRequest): WalletAuthRequestObject; static serializeBinaryToWriter(message: WalletAuthRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): WalletAuthRequest; static deserializeBinaryFromReader(message: WalletAuthRequest, reader: BinaryReader): WalletAuthRequest; } export type WalletAuthRequestObject = { siweMessage: string, siweSignature: string, deviceKeyUpload?: DeviceKeyUploadObject, + farcasterId?: string, }; declare export class ReservedWalletRegistrationRequest extends Message { getSiweMessage(): string; setSiweMessage(value: string): ReservedWalletRegistrationRequest; getSiweSignature(): string; setSiweSignature(value: string): ReservedWalletRegistrationRequest; getDeviceKeyUpload(): DeviceKeyUpload | void; setDeviceKeyUpload(value?: DeviceKeyUpload): ReservedWalletRegistrationRequest; hasDeviceKeyUpload(): boolean; clearDeviceKeyUpload(): ReservedWalletRegistrationRequest; getKeyserverMessage(): string; setKeyserverMessage(value: string): ReservedWalletRegistrationRequest; getKeyserverSignature(): string; setKeyserverSignature(value: string): ReservedWalletRegistrationRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): ReservedWalletRegistrationRequestObject; static toObject(includeInstance: boolean, msg: ReservedWalletRegistrationRequest): ReservedWalletRegistrationRequestObject; static serializeBinaryToWriter(message: ReservedWalletRegistrationRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): ReservedWalletRegistrationRequest; static deserializeBinaryFromReader(message: ReservedWalletRegistrationRequest, reader: BinaryReader): ReservedWalletRegistrationRequest; } export type ReservedWalletRegistrationRequestObject = { siweMessage: string, siweSignature: string, deviceKeyUpload?: DeviceKeyUploadObject, keyserverMessage: string, keyserverSignature: string, }; declare export class SecondaryDeviceKeysUploadRequest extends Message { getUserId(): string; setUserId(value: string): SecondaryDeviceKeysUploadRequest; getChallengeResponse(): string; setChallengeResponse(value: string): SecondaryDeviceKeysUploadRequest; getDeviceKeyUpload(): DeviceKeyUpload | void; setDeviceKeyUpload(value?: DeviceKeyUpload): SecondaryDeviceKeysUploadRequest; hasDeviceKeyUpload(): boolean; clearDeviceKeyUpload(): SecondaryDeviceKeysUploadRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SecondaryDeviceKeysUploadRequestObject; static toObject(includeInstance: boolean, msg: SecondaryDeviceKeysUploadRequest): SecondaryDeviceKeysUploadRequestObject; static serializeBinaryToWriter(message: SecondaryDeviceKeysUploadRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): SecondaryDeviceKeysUploadRequest; static deserializeBinaryFromReader(message: SecondaryDeviceKeysUploadRequest, reader: BinaryReader): SecondaryDeviceKeysUploadRequest; } export type SecondaryDeviceKeysUploadRequestObject = { userId: string, deviceKeyUpload?: DeviceKeyUploadObject, } declare export class GenerateNonceResponse extends Message { getNonce(): string; setNonce(value: string): GenerateNonceResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GenerateNonceResponseObject; static toObject(includeInstance: boolean, msg: GenerateNonceResponse): GenerateNonceResponseObject; static serializeBinaryToWriter(message: GenerateNonceResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): GenerateNonceResponse; static deserializeBinaryFromReader(message: GenerateNonceResponse, reader: BinaryReader): GenerateNonceResponse; } export type GenerateNonceResponseObject = { nonce: string, }; declare export class VerifyUserAccessTokenRequest extends Message { getUserId(): string; setUserId(value: string): VerifyUserAccessTokenRequest; getDeviceId(): string; setDeviceId(value: string): VerifyUserAccessTokenRequest; getAccessToken(): string; setAccessToken(value: string): VerifyUserAccessTokenRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): VerifyUserAccessTokenRequestObject; static toObject(includeInstance: boolean, msg: VerifyUserAccessTokenRequest): VerifyUserAccessTokenRequestObject; static serializeBinaryToWriter(message: VerifyUserAccessTokenRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): VerifyUserAccessTokenRequest; static deserializeBinaryFromReader(message: VerifyUserAccessTokenRequest, reader: BinaryReader): VerifyUserAccessTokenRequest; } export type VerifyUserAccessTokenRequestObject = { userId: string, deviceId: string, accessToken: string, }; declare export class VerifyUserAccessTokenResponse extends Message { getTokenValid(): boolean; setTokenValid(value: boolean): VerifyUserAccessTokenResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): VerifyUserAccessTokenResponseObject; static toObject(includeInstance: boolean, msg: VerifyUserAccessTokenResponse): VerifyUserAccessTokenResponseObject; static serializeBinaryToWriter(message: VerifyUserAccessTokenResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): VerifyUserAccessTokenResponse; static deserializeBinaryFromReader(message: VerifyUserAccessTokenResponse, reader: BinaryReader): VerifyUserAccessTokenResponse; } export type VerifyUserAccessTokenResponseObject = { tokenValid: boolean, }; declare export class AddReservedUsernamesRequest extends Message { getMessage(): string; setMessage(value: string): AddReservedUsernamesRequest; getSignature(): string; setSignature(value: string): AddReservedUsernamesRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): AddReservedUsernamesRequestObject; static toObject(includeInstance: boolean, msg: AddReservedUsernamesRequest): AddReservedUsernamesRequestObject; static serializeBinaryToWriter(message: AddReservedUsernamesRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): AddReservedUsernamesRequest; static deserializeBinaryFromReader(message: AddReservedUsernamesRequest, reader: BinaryReader): AddReservedUsernamesRequest; } export type AddReservedUsernamesRequestObject = { message: string, signature: string, }; declare export class RemoveReservedUsernameRequest extends Message { getMessage(): string; setMessage(value: string): RemoveReservedUsernameRequest; getSignature(): string; setSignature(value: string): RemoveReservedUsernameRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): RemoveReservedUsernameRequestObject; static toObject(includeInstance: boolean, msg: RemoveReservedUsernameRequest): RemoveReservedUsernameRequestObject; static serializeBinaryToWriter(message: RemoveReservedUsernameRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): RemoveReservedUsernameRequest; static deserializeBinaryFromReader(message: RemoveReservedUsernameRequest, reader: BinaryReader): RemoveReservedUsernameRequest; } export type RemoveReservedUsernameRequestObject = { message: string, signature: string, }; export type IdentifierCase = 0 | 1 | 2; declare export class FindUserIDRequest extends Message { getUsername(): string; setUsername(value: string): FindUserIDRequest; getWalletAddress(): string; setWalletAddress(value: string): FindUserIDRequest; getIdentifierCase(): IdentifierCase; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): FindUserIDRequestObject; static toObject(includeInstance: boolean, msg: FindUserIDRequest): FindUserIDRequestObject; static serializeBinaryToWriter(message: FindUserIDRequest, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): FindUserIDRequest; static deserializeBinaryFromReader(message: FindUserIDRequest, reader: BinaryReader): FindUserIDRequest; } export type FindUserIDRequestObject = { username: string, walletAddress: string, } declare export class FindUserIDResponse extends Message { getUserId(): string; setUserId(value: string): FindUserIDResponse; hasUserId(): boolean; clearUserId(): FindUserIDResponse; getIsReserved(): boolean; setIsReserved(value: boolean): FindUserIDResponse; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): FindUserIDResponseObject; static toObject(includeInstance: boolean, msg: FindUserIDResponse): FindUserIDResponseObject; static serializeBinaryToWriter(message: FindUserIDResponse, writer: BinaryWriter): void; static deserializeBinary(bytes: Uint8Array): FindUserIDResponse; static deserializeBinaryFromReader(message: FindUserIDResponse, reader: BinaryReader): FindUserIDResponse; } export type FindUserIDResponseObject = { userId?: string, isReserved: boolean, } export type DeviceType = 0 | 1 | 2 | 3 | 4 | 5;