Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Improve passkey replace flow UI and navigation structure (#520)
Leendert de Borst646416c0690f
diff --git a/apps/mobile-app/android/app/build.gradle b/apps/mobile-app/android/app/build.gradleindex 13d1fb2d6..fe79766f5 100644--- a/apps/mobile-app/android/app/build.gradle+++ b/apps/mobile-app/android/app/build.gradle@@ -190,6 +190,10 @@ dependencies {// Add Material Design components for UIimplementation("com.google.android.material:material:1.11.0")+ // Add Fragment and ViewModel dependencies for fragment-based UI+ implementation("androidx.fragment:fragment-ktx:1.6.2")+ implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")+// Add vector drawable support for SVGimplementation("com.caverock:androidsvg-aar:1.4")diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.ktnew file mode 100644index 000000000..69b4eca22--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.kt@@ -0,0 +1,743 @@+package net.aliasvault.app.credentialprovider++import android.app.Activity+import android.content.Intent+import android.os.Bundle+import android.util.Log+import android.view.LayoutInflater+import android.view.View+import android.view.ViewGroup+import android.widget.TextView+import androidx.credentials.CreatePublicKeyCredentialResponse+import androidx.credentials.provider.PendingIntentHandler+import androidx.fragment.app.Fragment+import androidx.fragment.app.activityViewModels+import androidx.lifecycle.lifecycleScope+import com.google.android.material.button.MaterialButton+import com.google.android.material.textfield.TextInputEditText+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.delay+import kotlinx.coroutines.launch+import kotlinx.coroutines.withContext+import net.aliasvault.app.R+import net.aliasvault.app.components.LoadingIndicator+import net.aliasvault.app.vaultstore.PasskeyWithCredentialInfo+import net.aliasvault.app.vaultstore.VaultStore+import net.aliasvault.app.vaultstore.createCredentialWithPasskey+import net.aliasvault.app.vaultstore.models.Passkey+import net.aliasvault.app.vaultstore.passkey.PasskeyAuthenticator+import net.aliasvault.app.vaultstore.passkey.PasskeyHelper+import net.aliasvault.app.vaultstore.replacePasskey+import net.aliasvault.app.webapi.WebApiService+import org.json.JSONObject+import java.util.Date+import java.util.UUID++/**+ * Fragment for passkey creation/replacement form+ */+class PasskeyFormFragment : Fragment() {++ companion object {+ private const val TAG = "PasskeyFormFragment"+ private const val ARG_IS_REPLACE = "is_replace"+ private const val ARG_PASSKEY_ID = "passkey_id"++ fun newInstance(isReplace: Boolean, passkeyId: String?): PasskeyFormFragment {+ return PasskeyFormFragment().apply {+ arguments = Bundle().apply {+ putBoolean(ARG_IS_REPLACE, isReplace)+ passkeyId?.let { putString(ARG_PASSKEY_ID, it) }+ }+ }+ }+ }++ private val viewModel: PasskeyRegistrationViewModel by activityViewModels()+ private lateinit var vaultStore: VaultStore+ private lateinit var webApiService: WebApiService++ private var isReplace: Boolean = false+ private var passkeyToReplace: PasskeyWithCredentialInfo? = null++ // UI elements+ private lateinit var headerSubtitle: TextView+ private lateinit var infoExplanationText: TextView+ private lateinit var displayNameInput: TextInputEditText+ private lateinit var websiteText: TextView+ private lateinit var usernameContainer: View+ private lateinit var usernameText: TextView+ private lateinit var errorText: TextView+ private lateinit var saveButton: MaterialButton+ private lateinit var cancelButton: MaterialButton+ private lateinit var scrollView: View+ private lateinit var loadingOverlay: View+ private lateinit var loadingIndicator: LoadingIndicator++ override fun onCreate(savedInstanceState: Bundle?) {+ super.onCreate(savedInstanceState)+ isReplace = arguments?.getBoolean(ARG_IS_REPLACE) ?: false+ val passkeyId = arguments?.getString(ARG_PASSKEY_ID)+ passkeyToReplace = passkeyId?.let {+ viewModel.getPasskeyById(UUID.fromString(it))+ }++ // Initialize services+ vaultStore = VaultStore.getExistingInstance()+ ?: throw Exception("VaultStore not initialized")+ webApiService = WebApiService(requireContext())+ }++ override fun onCreateView(+ inflater: LayoutInflater,+ container: ViewGroup?,+ savedInstanceState: Bundle?,+ ): View? {+ return inflater.inflate(R.layout.fragment_passkey_form, container, false)+ }++ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {+ super.onViewCreated(view, savedInstanceState)++ // Initialize UI elements+ val headerTitle = view.findViewById<TextView>(R.id.headerTitle)+ headerSubtitle = view.findViewById(R.id.headerSubtitle)+ infoExplanationText = view.findViewById(R.id.infoExplanationText)+ displayNameInput = view.findViewById(R.id.displayNameInput)+ websiteText = view.findViewById(R.id.websiteText)+ usernameContainer = view.findViewById(R.id.usernameContainer)+ usernameText = view.findViewById(R.id.usernameText)+ errorText = view.findViewById(R.id.errorText)+ saveButton = view.findViewById(R.id.saveButton)+ cancelButton = view.findViewById(R.id.cancelButton)+ scrollView = view.findViewById(R.id.scrollView)+ loadingOverlay = view.findViewById(R.id.loadingOverlay)+ loadingIndicator = view.findViewById(R.id.loadingIndicator)++ // Update UI based on mode+ if (isReplace && passkeyToReplace != null) {+ headerTitle.text = getString(R.string.replace_passkey_title)+ headerSubtitle.visibility = View.GONE+ infoExplanationText.text = getString(R.string.passkey_replace_explanation)+ displayNameInput.setText(passkeyToReplace?.passkey?.displayName)+ saveButton.text = getString(R.string.passkey_replace_button)+ } else {+ headerTitle.text = getString(R.string.create_passkey_title)+ headerSubtitle.visibility = View.GONE+ infoExplanationText.text = getString(R.string.passkey_create_explanation)+ displayNameInput.setText(viewModel.rpId)+ saveButton.text = getString(R.string.passkey_create_button)+ }++ // Set website+ websiteText.text = viewModel.rpId++ // Set username if available+ if (!viewModel.userName.isNullOrEmpty()) {+ usernameContainer.visibility = View.VISIBLE+ usernameText.text = viewModel.userName+ } else {+ usernameContainer.visibility = View.GONE+ }++ // Set up button listeners+ saveButton.setOnClickListener {+ onSaveClicked()+ }++ cancelButton.setOnClickListener {+ if (viewModel.existingPasskeys.isNotEmpty()) {+ // Go back to selection view+ parentFragmentManager.popBackStack()+ } else {+ requireActivity().setResult(Activity.RESULT_CANCELED)+ requireActivity().finish()+ }+ }+ }++ private fun onSaveClicked() {+ // Validate display name+ val displayName = displayNameInput.text.toString().trim()+ if (displayName.isEmpty()) {+ errorText.text = getString(R.string.passkey_error_empty_name)+ errorText.visibility = View.VISIBLE+ return+ }++ // Hide error and start creation+ errorText.visibility = View.GONE++ // Start passkey creation in coroutine+ lifecycleScope.launch {+ if (isReplace && passkeyToReplace != null) {+ replacePasskeyFlow(displayName, passkeyToReplace!!)+ } else {+ createPasskeyFlow(displayName)+ }+ }+ }++ private fun showLoading(message: String) {+ loadingIndicator.setMessage(message)+ loadingIndicator.startAnimation()+ loadingOverlay.visibility = View.VISIBLE+ scrollView.alpha = 0.3f+ scrollView.isEnabled = false+ }++ private fun hideLoading() {+ loadingIndicator.stopAnimation()+ loadingOverlay.visibility = View.GONE+ scrollView.alpha = 1.0f+ scrollView.isEnabled = true+ }++ private fun showError(message: String) {+ hideLoading()+ errorText.text = message+ errorText.visibility = View.VISIBLE+ }++ /**+ * Create a new passkey flow+ */+ private suspend fun createPasskeyFlow(displayName: String) = withContext(Dispatchers.IO) {+ try {+ // Step 1: Sync vault before creating passkey to ensure we have latest data+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_checking_connection))+ }++ try {+ vaultStore.syncVault(webApiService)+ } catch (e: Exception) {+ // Server connectivity check failed - show appropriate error dialog+ withContext(Dispatchers.Main) {+ showSyncErrorAlert(e)+ }+ return@withContext+ }++ // Step 2: Create passkey credentials+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_creating))+ }++ Log.d(TAG, "Creating passkey for RP: ${viewModel.rpId}, user: ${viewModel.userName}")++ // Extract favicon (optional)+ var logo: ByteArray? = null+ try {+ logo = webApiService.extractFavicon("https://${viewModel.rpId}")+ } catch (e: Exception) {+ Log.w(TAG, "Favicon extraction failed", e)+ // Continue without logo+ }++ // Generate passkey credentials+ val passkeyId = UUID.randomUUID()+ val credentialId = PasskeyHelper.guidToBytes(passkeyId.toString())++ // Use clientDataHash from the request+ val requestClientDataHash = viewModel.clientDataHash+ if (requestClientDataHash == null) {+ throw Exception("Client data hash not available")+ }++ // Parse request to get challenge (for building response clientDataJSON later)+ val requestObj = JSONObject(viewModel.requestJson)+ val challenge = requestObj.optString("challenge", "")++ // Use origin from the request+ val requestOrigin = viewModel.origin+ if (requestOrigin == null) {+ throw Exception("Origin not available")+ }+ Log.d(TAG, "Using origin from request: $requestOrigin")++ // Extract PRF inputs if present+ val prfInputs = extractPrfInputs(requestObj)+ val enablePrf = prfInputs != null++ // Create the passkey using PasskeyAuthenticator+ val passkeyResult = PasskeyAuthenticator.createPasskey(+ credentialId = credentialId,+ clientDataHash = requestClientDataHash,+ rpId = viewModel.rpId,+ userId = viewModel.userId,+ userName = viewModel.userName,+ userDisplayName = viewModel.userDisplayName,+ uvPerformed = true,+ enablePrf = enablePrf,+ prfInputs = prfInputs,+ )++ // Create Passkey model object+ val now = Date()+ val passkey = Passkey(+ id = passkeyId,+ parentCredentialId = UUID.randomUUID(), // Will be set by createCredentialWithPasskey+ rpId = viewModel.rpId,+ userHandle = viewModel.userId,+ userName = viewModel.userName,+ publicKey = passkeyResult.publicKey,+ privateKey = passkeyResult.privateKey,+ prfKey = passkeyResult.prfSecret,+ displayName = displayName,+ createdAt = now,+ updatedAt = now,+ isDeleted = false,+ )++ // Step 3: Store in database+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_saving))+ }++ Log.d(TAG, "Saving passkey to vault...")+ vaultStore.createCredentialWithPasskey(+ rpId = viewModel.rpId,+ userName = viewModel.userName,+ displayName = displayName,+ passkey = passkey,+ logo = logo,+ )+ Log.d(TAG, "Passkey saved successfully")++ // Step 4: Upload vault changes to server+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_syncing))+ }++ try {+ vaultStore.mutateVault(webApiService)+ } catch (e: Exception) {+ Log.w(TAG, "Vault mutation failed, but passkey was created locally", e)+ // Show error dialog but continue - passkey is still saved locally+ withContext(Dispatchers.Main) {+ showSyncErrorAlert(e)+ delay(2000)+ }+ }++ // Build response+ val credentialIdB64 = base64urlEncode(credentialId)+ val attestationObjectB64 = base64urlEncode(passkeyResult.attestationObject)++ // Rebuild clientDataJSON for the response (needed for the credential response)+ val clientDataJson =+ """{"type":"webauthn.create","challenge":"$challenge","origin":"$requestOrigin","crossOrigin":false}"""+ val clientDataJsonB64 = base64urlEncode(clientDataJson.toByteArray(Charsets.UTF_8))++ val responseJson = JSONObject().apply {+ put("id", credentialIdB64)+ put("rawId", credentialIdB64)+ put("type", "public-key")+ put("authenticatorAttachment", "platform")+ put(+ "response",+ JSONObject().apply {+ put("clientDataJSON", clientDataJsonB64)+ put("attestationObject", attestationObjectB64)+ put("authenticatorData", base64urlEncode(passkeyResult.authenticatorData))+ put(+ "transports",+ org.json.JSONArray().apply {+ put("internal")+ },+ )+ put("publicKey", base64urlEncode(passkeyResult.publicKeyDER))+ put("publicKeyAlgorithm", -7) // ES256, required for Chrome CredManHelper. Firefox doesn't need this.+ },+ )++ // Add PRF extension results if present+ val prfResults = if (enablePrf) passkeyResult.prfResults else null+ if (prfResults != null) {+ put(+ "clientExtensionResults",+ JSONObject().apply {+ put(+ "prf",+ JSONObject().apply {+ put("enabled", true)+ put(+ "results",+ JSONObject().apply {+ put("first", base64urlEncode(prfResults.first))+ prfResults.second?.let {+ put("second", base64urlEncode(it))+ }+ },+ )+ },+ )+ },+ )+ } else {+ put("clientExtensionResults", JSONObject())+ }+ }++ Log.d(TAG, "Response JSON: ${responseJson.toString(2)}")++ val response = CreatePublicKeyCredentialResponse(responseJson.toString())++ withContext(Dispatchers.Main) {+ hideLoading()+ val resultIntent = Intent()+ try {+ Log.d(TAG, "Setting credential response...")+ PendingIntentHandler.setCreateCredentialResponse(resultIntent, response)+ Log.d(TAG, "Credential response set successfully")++ requireActivity().setResult(Activity.RESULT_OK, resultIntent)+ Log.d(TAG, "Result set to RESULT_OK, finishing activity")+ requireActivity().finish()+ } catch (e: Exception) {+ Log.e(TAG, "Error setting credential response", e)+ showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")+ }+ }+ } catch (e: Exception) {+ Log.e(TAG, "Error creating passkey", e)+ withContext(Dispatchers.Main) {+ showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")+ }+ }+ }++ /**+ * Replace an existing passkey flow+ */+ private suspend fun replacePasskeyFlow(displayName: String, passkeyToReplace: PasskeyWithCredentialInfo) = withContext(Dispatchers.IO) {+ try {+ // Step 1: Sync vault before replacing passkey to ensure we have latest data+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_checking_connection))+ }++ try {+ vaultStore.syncVault(webApiService)+ } catch (e: Exception) {+ // Server connectivity check failed - show appropriate error dialog+ withContext(Dispatchers.Main) {+ showSyncErrorAlert(e)+ }+ return@withContext+ }++ // Step 2: Replace passkey+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_replacing))+ }++ Log.d(TAG, "Replacing passkey ${passkeyToReplace.passkey.id} for RP: ${viewModel.rpId}")++ // Extract favicon (optional)+ var logo: ByteArray? = null+ try {+ logo = webApiService.extractFavicon("https://${viewModel.rpId}")+ } catch (e: Exception) {+ Log.w(TAG, "Favicon extraction failed", e)+ // Continue without logo+ }++ // Generate new passkey credentials+ val newPasskeyId = UUID.randomUUID()+ val credentialId = PasskeyHelper.guidToBytes(newPasskeyId.toString())++ // Use clientDataHash from the request+ val requestClientDataHash = viewModel.clientDataHash+ if (requestClientDataHash == null) {+ throw Exception("Client data hash not available")+ }++ // Parse request to get challenge+ val requestObj = JSONObject(viewModel.requestJson)+ val challenge = requestObj.optString("challenge", "")++ // Use origin from the request+ val requestOrigin = viewModel.origin+ if (requestOrigin == null) {+ throw Exception("Origin not available")+ }++ // Extract PRF inputs if present+ val prfInputs = extractPrfInputs(requestObj)+ val enablePrf = prfInputs != null++ // Create the new passkey using PasskeyAuthenticator+ val passkeyResult = PasskeyAuthenticator.createPasskey(+ credentialId = credentialId,+ clientDataHash = requestClientDataHash,+ rpId = viewModel.rpId,+ userId = viewModel.userId,+ userName = viewModel.userName,+ userDisplayName = viewModel.userDisplayName,+ uvPerformed = true,+ enablePrf = enablePrf,+ prfInputs = prfInputs,+ )++ // Create new Passkey model object+ val now = Date()+ val newPasskey = Passkey(+ id = newPasskeyId,+ parentCredentialId = passkeyToReplace.passkey.parentCredentialId,+ rpId = viewModel.rpId,+ userHandle = viewModel.userId,+ userName = viewModel.userName,+ publicKey = passkeyResult.publicKey,+ privateKey = passkeyResult.privateKey,+ prfKey = passkeyResult.prfSecret,+ displayName = displayName,+ createdAt = now,+ updatedAt = now,+ isDeleted = false,+ )++ // Step 3: Replace in database+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_saving))+ }++ val db = vaultStore.database ?: throw Exception("Vault not unlocked")+ db.beginTransaction()+ try {+ vaultStore.replacePasskey(+ oldPasskeyId = passkeyToReplace.passkey.id,+ newPasskey = newPasskey,+ displayName = displayName,+ logo = logo,+ db = db,+ )++ // Commit transaction and persist to encrypted vault file+ vaultStore.commitTransaction()++ Log.d(TAG, "Passkey replaced successfully")+ } catch (e: Exception) {+ db.endTransaction()+ throw e+ }++ // Step 4: Upload vault changes to server+ withContext(Dispatchers.Main) {+ showLoading(getString(R.string.passkey_syncing))+ }++ try {+ vaultStore.mutateVault(webApiService)+ } catch (e: Exception) {+ Log.w(TAG, "Vault mutation failed, but passkey was replaced locally", e)+ // Show error dialog but continue - passkey is still saved locally+ withContext(Dispatchers.Main) {+ showSyncErrorAlert(e)+ delay(2000)+ }+ }++ // Build response (same as create flow)+ val credentialIdB64 = base64urlEncode(credentialId)+ val attestationObjectB64 = base64urlEncode(passkeyResult.attestationObject)++ val clientDataJson =+ """{"type":"webauthn.create","challenge":"$challenge","origin":"$requestOrigin","crossOrigin":false}"""+ val clientDataJsonB64 = base64urlEncode(clientDataJson.toByteArray(Charsets.UTF_8))++ val responseJson = JSONObject().apply {+ put("id", credentialIdB64)+ put("rawId", credentialIdB64)+ put("type", "public-key")+ put("authenticatorAttachment", "platform")+ put(+ "response",+ JSONObject().apply {+ put("clientDataJSON", clientDataJsonB64)+ put("attestationObject", attestationObjectB64)+ put("authenticatorData", base64urlEncode(passkeyResult.authenticatorData))+ put(+ "transports",+ org.json.JSONArray().apply {+ put("internal")+ },+ )+ put("publicKey", base64urlEncode(passkeyResult.publicKeyDER))+ put("publicKeyAlgorithm", -7)+ },+ )++ // Add PRF extension results if present+ val prfResults = if (enablePrf) passkeyResult.prfResults else null+ if (prfResults != null) {+ put(+ "clientExtensionResults",+ JSONObject().apply {+ put(+ "prf",+ JSONObject().apply {+ put("enabled", true)+ put(+ "results",+ JSONObject().apply {+ put("first", base64urlEncode(prfResults.first))+ prfResults.second?.let {+ put("second", base64urlEncode(it))+ }+ },+ )+ },+ )+ },+ )+ } else {+ put("clientExtensionResults", JSONObject())+ }+ }++ Log.d(TAG, "Response JSON: ${responseJson.toString(2)}")++ val response = CreatePublicKeyCredentialResponse(responseJson.toString())++ withContext(Dispatchers.Main) {+ hideLoading()+ val resultIntent = Intent()+ try {+ Log.d(TAG, "Setting credential response...")+ PendingIntentHandler.setCreateCredentialResponse(resultIntent, response)+ Log.d(TAG, "Credential response set successfully")++ requireActivity().setResult(Activity.RESULT_OK, resultIntent)+ Log.d(TAG, "Result set to RESULT_OK, finishing activity")+ requireActivity().finish()+ } catch (e: Exception) {+ Log.e(TAG, "Error setting credential response", e)+ showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")+ }+ }+ } catch (e: Exception) {+ Log.e(TAG, "Error replacing passkey", e)+ withContext(Dispatchers.Main) {+ showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")+ }+ }+ }++ /**+ * Extract PRF extension inputs from request+ */+ private fun extractPrfInputs(requestObj: JSONObject): PasskeyAuthenticator.PrfInputs? {+ try {+ val extensions = requestObj.optJSONObject("extensions") ?: return null+ val prf = extensions.optJSONObject("prf") ?: return null+ val eval = prf.optJSONObject("eval") ?: return null++ val firstB64 = eval.optString("first")+ if (firstB64.isEmpty()) return null+ val secondB64 = eval.optString("second")++ val first = base64urlDecode(firstB64)+ val second = if (secondB64.isNotEmpty()) base64urlDecode(secondB64) else null++ Log.d(TAG, "PRF extension requested")+ return PasskeyAuthenticator.PrfInputs(first, second)+ } catch (e: Exception) {+ Log.w(TAG, "Error extracting PRF inputs", e)+ return null+ }+ }++ /**+ * Encode bytes to base64url string+ */+ private fun base64urlEncode(data: ByteArray): String {+ return android.util.Base64.encodeToString(+ data,+ android.util.Base64.URL_SAFE or android.util.Base64.NO_WRAP or android.util.Base64.NO_PADDING,+ )+ }++ /**+ * Decode base64url string to bytes+ */+ private fun base64urlDecode(base64url: String): ByteArray {+ var base64 = base64url+ .replace('-', '+')+ .replace('_', '/')++ // Add padding if needed+ val remainder = base64.length % 4+ if (remainder > 0) {+ base64 += "=".repeat(4 - remainder)+ }++ return android.util.Base64.decode(base64, android.util.Base64.NO_WRAP)+ }++ /**+ * Show sync error alert dialog with appropriate message based on error type.+ * This method mirrors the iOS implementation in CredentialProviderViewController.swift:366+ */+ private fun showSyncErrorAlert(error: Throwable) {+ var title = getString(R.string.connection_error_title)+ var message = getString(R.string.connection_error_message)++ // Check if it's a VaultSyncError and customize message accordingly+ if (error is net.aliasvault.app.vaultstore.VaultSyncError) {+ when (error) {+ is net.aliasvault.app.vaultstore.VaultSyncError.SessionExpired,+ is net.aliasvault.app.vaultstore.VaultSyncError.AuthenticationFailed,+ -> {+ title = getString(R.string.session_expired_title)+ message = getString(R.string.session_expired_message)+ }++ is net.aliasvault.app.vaultstore.VaultSyncError.PasswordChanged -> {+ title = getString(R.string.password_changed_title)+ message = getString(R.string.password_changed_message)+ }++ is net.aliasvault.app.vaultstore.VaultSyncError.ClientVersionNotSupported -> {+ title = getString(R.string.version_not_supported_title)+ message = getString(R.string.version_not_supported_message)+ }++ is net.aliasvault.app.vaultstore.VaultSyncError.ServerVersionNotSupported -> {+ title = getString(R.string.server_version_not_supported_title)+ message = getString(R.string.server_version_not_supported_message)+ }++ is net.aliasvault.app.vaultstore.VaultSyncError.ServerUnavailable -> {+ title = getString(R.string.server_unavailable_title)+ message = getString(R.string.server_unavailable_message)+ }++ is net.aliasvault.app.vaultstore.VaultSyncError.NetworkError,+ is net.aliasvault.app.vaultstore.VaultSyncError.Timeout,+ -> {+ title = getString(R.string.network_error_title)+ message = getString(R.string.network_error_message)+ }++ else -> {+ // Use default connectivity error message for other errors+ }+ }+ }++ hideLoading()++ // Create and show alert dialog+ val alert = android.app.AlertDialog.Builder(requireContext())+ .setTitle(title)+ .setMessage(message)+ .setPositiveButton(android.R.string.ok) { dialog, _ ->+ dialog.dismiss()+ }+ .create()++ alert.show()+ }+}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.ktindex e248e0710..0165623f8 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt@@ -1,44 +1,20 @@package net.aliasvault.app.credentialprovider-import android.app.Activity-import android.content.Intentimport android.os.Bundleimport android.util.Log-import android.view.LayoutInflater-import android.view.View-import android.widget.LinearLayout-import android.widget.TextView+import androidx.activity.viewModelsimport androidx.credentials.CreatePublicKeyCredentialRequest-import androidx.credentials.CreatePublicKeyCredentialResponseimport androidx.credentials.provider.PendingIntentHandler-import androidx.credentials.provider.ProviderCreateCredentialRequest-import com.google.android.material.button.MaterialButton-import com.google.android.material.textfield.TextInputEditText-import kotlinx.coroutines.CoroutineScope-import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.delay-import kotlinx.coroutines.launch-import kotlinx.coroutines.withContext+import androidx.fragment.app.FragmentActivityimport net.aliasvault.app.R-import net.aliasvault.app.components.LoadingIndicator-import net.aliasvault.app.vaultstore.PasskeyWithCredentialInfoimport net.aliasvault.app.vaultstore.VaultStore-import net.aliasvault.app.vaultstore.createCredentialWithPasskeyimport net.aliasvault.app.vaultstore.getPasskeysWithCredentialInfo-import net.aliasvault.app.vaultstore.models.Passkey-import net.aliasvault.app.vaultstore.passkey.PasskeyAuthenticator-import net.aliasvault.app.vaultstore.passkey.PasskeyHelper-import net.aliasvault.app.vaultstore.replacePasskey-import net.aliasvault.app.webapi.WebApiService-import org.json.JSONArrayimport org.json.JSONObject-import java.util.Date-import java.util.UUID/*** PasskeyRegistrationActivity*- * Handles passkey registration (credential creation) with a full UI.+ * Handles passkey registration (credential creation) with a full UI using fragments.* Shows a form where the user can edit the display name, then creates and saves the passkey.* Displays loading states and error messages similar to iOS PasskeyRegistrationView.*@@ -46,46 +22,14 @@ import java.util.UUID* 1. Selection mode: When existing passkeys are found, shows options to create new or replace existing* 2. Form mode: Direct passkey creation form (either new or replacing a selected passkey)*/-class PasskeyRegistrationActivity : Activity() {+class PasskeyRegistrationActivity : FragmentActivity() {companion object {private const val TAG = "PasskeyRegistration"}+ private val viewModel: PasskeyRegistrationViewModel by viewModels()private lateinit var vaultStore: VaultStore- private lateinit var webApiService: WebApiService-- // UI elements - Form mode- private var headerSubtitle: TextView? = null- private var displayNameInput: TextInputEditText? = null- private var websiteText: TextView? = null- private var usernameContainer: View? = null- private var usernameText: TextView? = null- private var errorText: TextView? = null- private var saveButton: MaterialButton? = null- private var cancelButton: MaterialButton? = null- private var scrollView: View? = null- private var loadingOverlay: View? = null- private var loadingIndicator: LoadingIndicator? = null-- // UI elements - Selection mode- private var createNewButton: MaterialButton? = null- private var existingPasskeysContainer: LinearLayout? = null-- // Request data- private var providerRequest: ProviderCreateCredentialRequest? = null- private var requestJson: String = ""- private var clientDataHash: ByteArray? = null- private var origin: String? = null- private var rpId: String = ""- private var userName: String? = null- private var userDisplayName: String? = null- private var userId: ByteArray? = null-- // State- private var existingPasskeys: List<PasskeyWithCredentialInfo> = emptyList()- private var selectedPasskeyToReplace: PasskeyWithCredentialInfo? = null- private var isReplaceMode: Boolean = falseoverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)@@ -93,15 +37,14 @@ class PasskeyRegistrationActivity : Activity() {Log.d(TAG, "PasskeyRegistrationActivity onCreate called")try {- // Initialize VaultStore and WebApiService+ // Initialize VaultStorevaultStore = VaultStore.getExistingInstance()?: throw Exception("VaultStore not initialized")- webApiService = WebApiService(this)- Log.d(TAG, "VaultStore and WebApiService initialized")+ Log.d(TAG, "VaultStore initialized")// Retrieve provider request- providerRequest = PendingIntentHandler.retrieveProviderCreateCredentialRequest(intent)+ val providerRequest = PendingIntentHandler.retrieveProviderCreateCredentialRequest(intent)if (providerRequest == null) {Log.e(TAG, "No provider request found in intent")finish()@@ -111,7 +54,7 @@ class PasskeyRegistrationActivity : Activity() {Log.d(TAG, "Provider request retrieved successfully")// Extract parameters from providerRequest.callingRequest- val createRequest = providerRequest!!.callingRequest+ val createRequest = providerRequest.callingRequestif (createRequest !is CreatePublicKeyCredentialRequest) {Log.e(TAG, "Request is not a CreatePublicKeyCredentialRequest")finish()@@ -119,37 +62,37 @@ class PasskeyRegistrationActivity : Activity() {}// Get requestJson, clientDataHash, and origin from the request- requestJson = createRequest.requestJson- clientDataHash = createRequest.clientDataHash- origin = createRequest.origin+ viewModel.requestJson = createRequest.requestJson+ viewModel.clientDataHash = createRequest.clientDataHash+ viewModel.origin = createRequest.origin- Log.d(TAG, "Request JSON: $requestJson")- Log.d(TAG, "Origin: $origin")- Log.d(TAG, "ClientDataHash length: ${clientDataHash?.size}")+ Log.d(TAG, "Request JSON: ${viewModel.requestJson}")+ Log.d(TAG, "Origin: ${viewModel.origin}")+ Log.d(TAG, "ClientDataHash length: ${viewModel.clientDataHash?.size}")// Parse request JSON to extract RP ID and user info- val requestObj = JSONObject(requestJson)+ val requestObj = JSONObject(viewModel.requestJson)// Extract RP infoval rpObj = requestObj.optJSONObject("rp")- rpId = rpObj?.optString("id") ?: ""+ viewModel.rpId = rpObj?.optString("id") ?: ""// Extract user infoval userObj = requestObj.optJSONObject("user")- userName = userObj?.optString("name")?.takeIf { it.isNotEmpty() }- userDisplayName = userObj?.optString("displayName")?.takeIf { it.isNotEmpty() }+ viewModel.userName = userObj?.optString("name")?.takeIf { it.isNotEmpty() }+ viewModel.userDisplayName = userObj?.optString("displayName")?.takeIf { it.isNotEmpty() }val userIdB64 = userObj?.optString("id")- Log.d(TAG, "Parameters: rpId=$rpId, userName=$userName, userDisplayName=$userDisplayName")+ Log.d(TAG, "Parameters: rpId=${viewModel.rpId}, userName=${viewModel.userName}, userDisplayName=${viewModel.userDisplayName}")- if (rpId.isEmpty() || requestJson.isEmpty()) {+ if (viewModel.rpId.isEmpty() || viewModel.requestJson.isEmpty()) {Log.e(TAG, "Missing required parameters")finish()return}// Decode user ID from base64url- userId = if (!userIdB64.isNullOrEmpty()) {+ viewModel.userId = if (!userIdB64.isNullOrEmpty()) {try {base64urlDecode(userIdB64)} catch (e: Exception) {@@ -163,612 +106,53 @@ class PasskeyRegistrationActivity : Activity() {// Check for existing passkeysval db = vaultStore.databaseif (db != null) {- existingPasskeys = vaultStore.getPasskeysWithCredentialInfo(- rpId = rpId,- userName = userName,- userId = userId,+ viewModel.existingPasskeys = vaultStore.getPasskeysWithCredentialInfo(+ rpId = viewModel.rpId,+ userName = viewModel.userName,+ userId = viewModel.userId,db = db,)- Log.d(TAG, "Found ${existingPasskeys.size} existing passkeys for rpId=$rpId")- }-- // Decide which layout to show- if (existingPasskeys.isEmpty()) {- // No existing passkeys - show form directly- showFormView(isReplace = false, passkeyToReplace = null)- } else {- // Existing passkeys found - show selection view- showSelectionView()- }- } catch (e: Exception) {- Log.e(TAG, "Error in onCreate", e)- finish()- }- }-- /**- * Show selection view when there are existing passkeys- */- private fun showSelectionView() {- setContentView(R.layout.activity_passkey_selection)-- // Initialize selection view elements- val headerSubtitle: TextView = findViewById(R.id.headerSubtitle)- createNewButton = findViewById(R.id.createNewButton)- existingPasskeysContainer = findViewById(R.id.existingPasskeysContainer)- cancelButton = findViewById(R.id.cancelButton)- scrollView = findViewById(R.id.scrollView)- loadingOverlay = findViewById(R.id.loadingOverlay)- loadingIndicator = findViewById(R.id.loadingIndicator)-- // Set subtitle- headerSubtitle.text = "Create a new passkey for $rpId"-- // Set up create new button- createNewButton?.setOnClickListener {- showFormView(isReplace = false, passkeyToReplace = null)- }-- // Populate existing passkeys list- val inflater = LayoutInflater.from(this)- existingPasskeys.forEach { passkeyInfo ->- val itemView = inflater.inflate(R.layout.item_existing_passkey, existingPasskeysContainer, false)-- val displayNameView = itemView.findViewById<TextView>(R.id.passkeyDisplayName)- val subtitleView = itemView.findViewById<TextView>(R.id.passkeySubtitle)-- displayNameView.text = passkeyInfo.passkey.displayName- val subtitle = buildString {- passkeyInfo.username?.let { append(it) }- if (passkeyInfo.username != null && passkeyInfo.serviceName != null) {- append(" • ")- }- passkeyInfo.serviceName?.let { append(it) }- }- subtitleView.text = subtitle.ifEmpty { rpId }-- itemView.setOnClickListener {- showFormView(isReplace = true, passkeyToReplace = passkeyInfo)- }-- existingPasskeysContainer?.addView(itemView)- }-- // Set up cancel button- cancelButton?.setOnClickListener {- setResult(RESULT_CANCELED)- finish()- }- }-- /**- * Show form view for creating or replacing a passkey- */- private fun showFormView(isReplace: Boolean, passkeyToReplace: PasskeyWithCredentialInfo?) {- setContentView(R.layout.activity_passkey_registration)-- this.isReplaceMode = isReplace- this.selectedPasskeyToReplace = passkeyToReplace-- // Initialize form view elements- headerSubtitle = findViewById(R.id.headerSubtitle)- displayNameInput = findViewById(R.id.displayNameInput)- websiteText = findViewById(R.id.websiteText)- usernameContainer = findViewById(R.id.usernameContainer)- usernameText = findViewById(R.id.usernameText)- errorText = findViewById(R.id.errorText)- saveButton = findViewById(R.id.saveButton)- cancelButton = findViewById(R.id.cancelButton)- scrollView = findViewById(R.id.scrollView)- loadingOverlay = findViewById(R.id.loadingOverlay)- loadingIndicator = findViewById(R.id.loadingIndicator)-- // Update UI based on mode- if (isReplace && passkeyToReplace != null) {- headerSubtitle?.text = "Replace passkey for $rpId"- displayNameInput?.setText(passkeyToReplace.passkey.displayName)- saveButton?.text = getString(R.string.passkey_replace_button)- } else {- headerSubtitle?.text = "Create a new passkey for $rpId"- displayNameInput?.setText(rpId)- saveButton?.text = getString(R.string.passkey_create_button)- }-- // Set website- websiteText?.text = rpId-- // Set username if available- if (!userName.isNullOrEmpty()) {- usernameContainer?.visibility = View.VISIBLE- usernameText?.text = userName- } else {- usernameContainer?.visibility = View.GONE- }-- // Set up button listeners- saveButton?.setOnClickListener {- onSaveClicked()- }-- cancelButton?.setOnClickListener {- if (existingPasskeys.isNotEmpty()) {- // Go back to selection view- showSelectionView()- } else {- setResult(RESULT_CANCELED)- finish()- }- }- }-- private fun onSaveClicked() {- // Validate display name- val displayName = displayNameInput?.text.toString().trim()- if (displayName.isEmpty()) {- errorText?.text = getString(R.string.passkey_error_empty_name)- errorText?.visibility = View.VISIBLE- return- }-- // Hide error and start creation- errorText?.visibility = View.GONE-- // Start passkey creation in coroutine- CoroutineScope(Dispatchers.Main).launch {- if (isReplaceMode && selectedPasskeyToReplace != null) {- replacePasskeyFlow(displayName, selectedPasskeyToReplace!!)- } else {- createPasskeyFlow(displayName)- }- }- }-- private fun showLoading(message: String) {- loadingIndicator?.setMessage(message)- loadingIndicator?.startAnimation()- loadingOverlay?.visibility = View.VISIBLE- scrollView?.alpha = 0.3f- scrollView?.isEnabled = false- }-- private fun hideLoading() {- loadingIndicator?.stopAnimation()- loadingOverlay?.visibility = View.GONE- scrollView?.alpha = 1.0f- scrollView?.isEnabled = true- }-- private fun showError(message: String) {- hideLoading()- errorText?.text = message- errorText?.visibility = View.VISIBLE- }-- /**- * Create a new passkey flow- */- private suspend fun createPasskeyFlow(displayName: String) = withContext(Dispatchers.IO) {- try {- withContext(Dispatchers.Main) {- showLoading(getString(R.string.passkey_creating))- }-- Log.d(TAG, "Creating passkey for RP: $rpId, user: $userName")-- // Extract favicon (optional)- var logo: ByteArray? = null- try {- logo = webApiService.extractFavicon("https://$rpId")- } catch (e: Exception) {- Log.w(TAG, "Favicon extraction failed", e)- // Continue without logo- }-- // Generate passkey credentials- val passkeyId = UUID.randomUUID()- val credentialId = PasskeyHelper.guidToBytes(passkeyId.toString())-- // Use clientDataHash from the request- val requestClientDataHash = [email protected]- if (requestClientDataHash == null) {- throw Exception("Client data hash not available")+ Log.d(TAG, "Found ${viewModel.existingPasskeys.size} existing passkeys for rpId=${viewModel.rpId}")}- // Parse request to get challenge (for building response clientDataJSON later)- val requestObj = JSONObject(requestJson)- val challenge = requestObj.optString("challenge", "")-- // Use origin from the request- val requestOrigin = [email protected]- if (requestOrigin == null) {- throw Exception("Origin not available")- }- Log.d(TAG, "Using origin from request: $requestOrigin")-- // Extract PRF inputs if present- val prfInputs = extractPrfInputs(requestObj)- val enablePrf = prfInputs != null-- // Create the passkey using PasskeyAuthenticator- val passkeyResult = PasskeyAuthenticator.createPasskey(- credentialId = credentialId,- clientDataHash = requestClientDataHash,- rpId = rpId,- userId = userId,- userName = userName,- userDisplayName = userDisplayName,- uvPerformed = true,- enablePrf = enablePrf,- prfInputs = prfInputs,- )-- // Create Passkey model object- val now = Date()- val passkey = Passkey(- id = passkeyId,- parentCredentialId = UUID.randomUUID(), // Will be set by createCredentialWithPasskey- rpId = rpId,- userHandle = userId,- userName = userName,- publicKey = passkeyResult.publicKey,- privateKey = passkeyResult.privateKey,- prfKey = passkeyResult.prfSecret,- displayName = displayName,- createdAt = now,- updatedAt = now,- isDeleted = false,- )+ // Set content view with fragment container+ setContentView(R.layout.activity_passkey_registration_container)- // Store in database- withContext(Dispatchers.Main) {- showLoading(getString(R.string.passkey_saving))- }-- Log.d(TAG, "Saving passkey to vault...")- vaultStore.createCredentialWithPasskey(- rpId = rpId,- userName = userName,- displayName = displayName,- passkey = passkey,- logo = logo,- )- Log.d(TAG, "Passkey saved successfully")-- // Upload vault changes to server- withContext(Dispatchers.Main) {- showLoading(getString(R.string.passkey_syncing))- }-- try {- vaultStore.mutateVault(webApiService)- } catch (e: Exception) {- Log.w(TAG, "Vault mutation failed, but passkey was created locally", e)- // Continue - passkey is still saved locally- withContext(Dispatchers.Main) {- showError("Saved locally, but sync failed: ${e.message}")- delay(2000)- }- }-- // Build response- val credentialIdB64 = base64urlEncode(credentialId)- val attestationObjectB64 = base64urlEncode(passkeyResult.attestationObject)-- // Rebuild clientDataJSON for the response (needed for the credential response)- val clientDataJson =- """{"type":"webauthn.create","challenge":"$challenge","origin":"$requestOrigin","crossOrigin":false}"""- val clientDataJsonB64 = base64urlEncode(clientDataJson.toByteArray(Charsets.UTF_8))-- val responseJson = JSONObject().apply {- put("id", credentialIdB64)- put("rawId", credentialIdB64)- put("type", "public-key")- put("authenticatorAttachment", "platform")- put(- "response",- JSONObject().apply {- put("clientDataJSON", clientDataJsonB64)- put("attestationObject", attestationObjectB64)- put("authenticatorData", base64urlEncode(passkeyResult.authenticatorData))- put(- "transports",- org.json.JSONArray().apply {- put("internal")- },- )- put("publicKey", base64urlEncode(passkeyResult.publicKeyDER))- put("publicKeyAlgorithm", -7) // ES256, required for Chrome CredManHelper. Firefox doesn't need this.- },- )-- // Add PRF extension results if present- val prfResults = if (enablePrf) passkeyResult.prfResults else null- if (prfResults != null) {- put(- "clientExtensionResults",- JSONObject().apply {- put(- "prf",- JSONObject().apply {- put("enabled", true)- put(- "results",- JSONObject().apply {- put("first", base64urlEncode(prfResults.first))- prfResults.second?.let {- put("second", base64urlEncode(it))- }- },- )- },- )- },- )+ // Only initialize fragments if this is a fresh onCreate (not a configuration change)+ if (savedInstanceState == null) {+ // Decide which fragment to show+ if (viewModel.existingPasskeys.isEmpty()) {+ // No existing passkeys - show form directly+ showFormFragment(isReplace = false, passkeyId = null)} else {- put("clientExtensionResults", JSONObject())- }- }-- Log.d(TAG, "Response JSON: ${responseJson.toString(2)}")-- val response = CreatePublicKeyCredentialResponse(responseJson.toString())-- withContext(Dispatchers.Main) {- hideLoading()- val resultIntent = Intent()- try {- Log.d(TAG, "Setting credential response...")- PendingIntentHandler.setCreateCredentialResponse(resultIntent, response)- Log.d(TAG, "Credential response set successfully")-- setResult(RESULT_OK, resultIntent)- Log.d(TAG, "Result set to RESULT_OK, finishing activity")- finish()- } catch (e: Exception) {- Log.e(TAG, "Error setting credential response", e)- showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")+ // Existing passkeys found - show selection view+ showSelectionFragment()}}} catch (e: Exception) {- Log.e(TAG, "Error creating passkey", e)- withContext(Dispatchers.Main) {- showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")- }- }- }-- /**- * Replace an existing passkey flow- */- private suspend fun replacePasskeyFlow(displayName: String, passkeyToReplace: PasskeyWithCredentialInfo) = withContext(Dispatchers.IO) {- try {- withContext(Dispatchers.Main) {- showLoading(getString(R.string.passkey_replacing))- }-- Log.d(TAG, "Replacing passkey ${passkeyToReplace.passkey.id} for RP: $rpId")-- // Extract favicon (optional)- var logo: ByteArray? = null- try {- logo = webApiService.extractFavicon("https://$rpId")- } catch (e: Exception) {- Log.w(TAG, "Favicon extraction failed", e)- // Continue without logo- }-- // Generate new passkey credentials- val newPasskeyId = UUID.randomUUID()- val credentialId = PasskeyHelper.guidToBytes(newPasskeyId.toString())-- // Use clientDataHash from the request- val requestClientDataHash = [email protected]- if (requestClientDataHash == null) {- throw Exception("Client data hash not available")- }-- // Parse request to get challenge- val requestObj = JSONObject(requestJson)- val challenge = requestObj.optString("challenge", "")-- // Use origin from the request- val requestOrigin = [email protected]- if (requestOrigin == null) {- throw Exception("Origin not available")- }-- // Extract PRF inputs if present- val prfInputs = extractPrfInputs(requestObj)- val enablePrf = prfInputs != null-- // Create the new passkey using PasskeyAuthenticator- val passkeyResult = PasskeyAuthenticator.createPasskey(- credentialId = credentialId,- clientDataHash = requestClientDataHash,- rpId = rpId,- userId = userId,- userName = userName,- userDisplayName = userDisplayName,- uvPerformed = true,- enablePrf = enablePrf,- prfInputs = prfInputs,- )-- // Create new Passkey model object- val now = Date()- val newPasskey = Passkey(- id = newPasskeyId,- parentCredentialId = passkeyToReplace.passkey.parentCredentialId,- rpId = rpId,- userHandle = userId,- userName = userName,- publicKey = passkeyResult.publicKey,- privateKey = passkeyResult.privateKey,- prfKey = passkeyResult.prfSecret,- displayName = displayName,- createdAt = now,- updatedAt = now,- isDeleted = false,- )-- // Replace in database- withContext(Dispatchers.Main) {- showLoading(getString(R.string.passkey_saving))- }-- val db = vaultStore.database ?: throw Exception("Vault not unlocked")- db.beginTransaction()- try {- vaultStore.replacePasskey(- oldPasskeyId = passkeyToReplace.passkey.id,- newPasskey = newPasskey,- displayName = displayName,- logo = logo,- db = db,- )-- // Commit transaction and persist to encrypted vault file- vaultStore.commitTransaction()-- Log.d(TAG, "Passkey replaced successfully")- } catch (e: Exception) {- db.endTransaction()- throw e- }-- // Upload vault changes to server- withContext(Dispatchers.Main) {- showLoading(getString(R.string.passkey_syncing))- }-- try {- vaultStore.mutateVault(webApiService)- } catch (e: Exception) {- Log.w(TAG, "Vault mutation failed, but passkey was replaced locally", e)- withContext(Dispatchers.Main) {- showError("Saved locally, but sync failed: ${e.message}")- delay(2000)- }- }-- // Build response (same as create flow)- val credentialIdB64 = base64urlEncode(credentialId)- val attestationObjectB64 = base64urlEncode(passkeyResult.attestationObject)-- val clientDataJson =- """{"type":"webauthn.create","challenge":"$challenge","origin":"$requestOrigin","crossOrigin":false}"""- val clientDataJsonB64 = base64urlEncode(clientDataJson.toByteArray(Charsets.UTF_8))-- val responseJson = JSONObject().apply {- put("id", credentialIdB64)- put("rawId", credentialIdB64)- put("type", "public-key")- put("authenticatorAttachment", "platform")- put(- "response",- JSONObject().apply {- put("clientDataJSON", clientDataJsonB64)- put("attestationObject", attestationObjectB64)- put("authenticatorData", base64urlEncode(passkeyResult.authenticatorData))- put(- "transports",- org.json.JSONArray().apply {- put("internal")- },- )- put("publicKey", base64urlEncode(passkeyResult.publicKeyDER))- put("publicKeyAlgorithm", -7)- },- )-- // Add PRF extension results if present- val prfResults = if (enablePrf) passkeyResult.prfResults else null- if (prfResults != null) {- put(- "clientExtensionResults",- JSONObject().apply {- put(- "prf",- JSONObject().apply {- put("enabled", true)- put(- "results",- JSONObject().apply {- put("first", base64urlEncode(prfResults.first))- prfResults.second?.let {- put("second", base64urlEncode(it))- }- },- )- },- )- },- )- } else {- put("clientExtensionResults", JSONObject())- }- }-- Log.d(TAG, "Response JSON: ${responseJson.toString(2)}")-- val response = CreatePublicKeyCredentialResponse(responseJson.toString())-- withContext(Dispatchers.Main) {- hideLoading()- val resultIntent = Intent()- try {- Log.d(TAG, "Setting credential response...")- PendingIntentHandler.setCreateCredentialResponse(resultIntent, response)- Log.d(TAG, "Credential response set successfully")-- setResult(RESULT_OK, resultIntent)- Log.d(TAG, "Result set to RESULT_OK, finishing activity")- finish()- } catch (e: Exception) {- Log.e(TAG, "Error setting credential response", e)- showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")- }- }- } catch (e: Exception) {- Log.e(TAG, "Error replacing passkey", e)- withContext(Dispatchers.Main) {- showError(getString(R.string.passkey_creation_failed) + ": ${e.message}")- }+ Log.e(TAG, "Error in onCreate", e)+ finish()}}/**- * Extract PRF extension inputs from request+ * Show selection fragment when there are existing passkeys*/- private fun extractPrfInputs(requestObj: JSONObject): PasskeyAuthenticator.PrfInputs? {- try {- val extensions = requestObj.optJSONObject("extensions") ?: return null- val prf = extensions.optJSONObject("prf") ?: return null- val eval = prf.optJSONObject("eval") ?: return null-- val firstB64 = eval.optString("first")- if (firstB64.isEmpty()) return null- val secondB64 = eval.optString("second")-- val first = base64urlDecode(firstB64)- val second = if (secondB64.isNotEmpty()) base64urlDecode(secondB64) else null-- Log.d(TAG, "PRF extension requested")- return PasskeyAuthenticator.PrfInputs(first, second)- } catch (e: Exception) {- Log.w(TAG, "Error extracting PRF inputs", e)- return null- }+ private fun showSelectionFragment() {+ val fragment = PasskeySelectionFragment()+ supportFragmentManager.beginTransaction()+ .replace(R.id.fragmentContainer, fragment)+ .commit()}/**- * Encode bytes to base64url string+ * Show form fragment for creating or replacing a passkey*/- private fun base64urlEncode(data: ByteArray): String {- return android.util.Base64.encodeToString(- data,- android.util.Base64.URL_SAFE or android.util.Base64.NO_WRAP or android.util.Base64.NO_PADDING,- )+ private fun showFormFragment(isReplace: Boolean, passkeyId: String?) {+ val fragment = PasskeyFormFragment.newInstance(isReplace, passkeyId)+ supportFragmentManager.beginTransaction()+ .replace(R.id.fragmentContainer, fragment)+ .commit()}/**diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationViewModel.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationViewModel.ktnew file mode 100644index 000000000..81d19a048--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationViewModel.kt@@ -0,0 +1,38 @@+package net.aliasvault.app.credentialprovider++import androidx.lifecycle.ViewModel+import net.aliasvault.app.vaultstore.PasskeyWithCredentialInfo+import java.util.UUID++/**+ * ViewModel to share passkey registration state between fragments+ */+class PasskeyRegistrationViewModel : ViewModel() {+ // Request data+ var requestJson: String = ""+ var clientDataHash: ByteArray? = null+ var origin: String? = null+ var rpId: String = ""+ var userName: String? = null+ var userDisplayName: String? = null+ var userId: ByteArray? = null++ // State+ var existingPasskeys: List<PasskeyWithCredentialInfo> = emptyList()+ var selectedPasskeyToReplace: PasskeyWithCredentialInfo? = null+ var isReplaceMode: Boolean = false++ fun onCreateNewSelected() {+ isReplaceMode = false+ selectedPasskeyToReplace = null+ }++ fun onReplaceSelected(passkeyInfo: PasskeyWithCredentialInfo) {+ isReplaceMode = true+ selectedPasskeyToReplace = passkeyInfo+ }++ fun getPasskeyById(id: UUID): PasskeyWithCredentialInfo? {+ return existingPasskeys.firstOrNull { it.passkey.id == id }+ }+}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeySelectionFragment.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeySelectionFragment.ktnew file mode 100644index 000000000..09217bec5--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeySelectionFragment.kt@@ -0,0 +1,95 @@+package net.aliasvault.app.credentialprovider++import android.os.Bundle+import android.view.LayoutInflater+import android.view.View+import android.view.ViewGroup+import android.widget.LinearLayout+import android.widget.TextView+import androidx.fragment.app.Fragment+import androidx.fragment.app.activityViewModels+import com.google.android.material.button.MaterialButton+import net.aliasvault.app.R++/**+ * Fragment that shows the passkey selection screen+ * Displays options to create new or replace existing passkeys+ */+class PasskeySelectionFragment : Fragment() {++ private val viewModel: PasskeyRegistrationViewModel by activityViewModels()++ override fun onCreateView(+ inflater: LayoutInflater,+ container: ViewGroup?,+ savedInstanceState: Bundle?,+ ): View? {+ return inflater.inflate(R.layout.fragment_passkey_selection, container, false)+ }++ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {+ super.onViewCreated(view, savedInstanceState)++ val headerTitle = view.findViewById<TextView>(R.id.headerTitle)+ val headerSubtitle = view.findViewById<TextView>(R.id.headerSubtitle)+ val createNewButton = view.findViewById<MaterialButton>(R.id.createNewButton)+ val existingPasskeysContainer = view.findViewById<LinearLayout>(R.id.existingPasskeysContainer)+ val cancelButton = view.findViewById<MaterialButton>(R.id.cancelButton)++ // Set title and subtitle+ headerTitle.text = getString(R.string.create_passkey_title)+ headerSubtitle.text = getString(R.string.create_passkey_subtitle)++ // Set up create new button+ createNewButton.setOnClickListener {+ viewModel.onCreateNewSelected()+ navigateToForm(isReplace = false, passkeyId = null)+ }++ // Populate existing passkeys list+ val inflater = LayoutInflater.from(requireContext())+ viewModel.existingPasskeys.forEach { passkeyInfo ->+ val itemView = inflater.inflate(R.layout.item_existing_passkey, existingPasskeysContainer, false)++ val displayNameView = itemView.findViewById<TextView>(R.id.passkeyDisplayName)+ val subtitleView = itemView.findViewById<TextView>(R.id.passkeySubtitle)++ displayNameView.text = passkeyInfo.passkey.displayName+ val subtitle = buildString {+ passkeyInfo.username?.let { append(it) }+ if (passkeyInfo.username != null && passkeyInfo.serviceName != null) {+ append(" • ")+ }+ passkeyInfo.serviceName?.let { append(it) }+ }+ subtitleView.text = subtitle.ifEmpty { viewModel.rpId }++ itemView.setOnClickListener {+ viewModel.onReplaceSelected(passkeyInfo)+ navigateToForm(isReplace = true, passkeyId = passkeyInfo.passkey.id.toString())+ }++ existingPasskeysContainer.addView(itemView)+ }++ // Set up cancel button+ cancelButton.setOnClickListener {+ requireActivity().setResult(android.app.Activity.RESULT_CANCELED)+ requireActivity().finish()+ }+ }++ private fun navigateToForm(isReplace: Boolean, passkeyId: String?) {+ val fragment = PasskeyFormFragment.newInstance(isReplace, passkeyId)+ parentFragmentManager.beginTransaction()+ .setCustomAnimations(+ R.anim.slide_in_right,+ R.anim.slide_out_left,+ R.anim.slide_in_left,+ R.anim.slide_out_right,+ )+ .replace(R.id.fragmentContainer, fragment)+ .addToBackStack(null)+ .commit()+ }+}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.ktindex ec0c98835..9406c6999 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.kt@@ -1143,6 +1143,27 @@ class VaultStore(}}+ /**+ * Sync the vault with the server.+ * Returns true if a new vault was downloaded, false if vault is already up to date.+ * NOTE: This is a convenience method that combines isNewVaultVersionAvailable and downloadVault+ * For better UX control, use isNewVaultVersionAvailable() and downloadVault() separately+ */+ suspend fun syncVault(webApiService: net.aliasvault.app.webapi.WebApiService): Boolean {+ // Check if new version is available+ val versionCheck = isNewVaultVersionAvailable(webApiService)+ val isNewVersionAvailable = versionCheck["isNewVersionAvailable"] as? Boolean ?: false+ val newRevision = versionCheck["newRevision"] as? Int++ if (isNewVersionAvailable && newRevision != null) {+ // Download the new vault+ downloadVault(webApiService, newRevision)+ return true+ }++ return false+ }+/*** Fetch and validate server status.*/@@ -1156,16 +1177,22 @@ class VaultStore(requiresAuth = true,)} catch (e: Exception) {- throw Exception("Network error: ${e.message}", e)+ // Network error - convert to VaultSyncError+ throw VaultSyncError.NetworkError(e)}// Check response status+ // Note: WebApiService already handles 401 with automatic token refresh and retry+ // If we still get a 401 here, it means the refresh failed and we should logoutif (statusResponse.statusCode != 200) {if (statusResponse.statusCode == 401) {- throw Exception("Session expired")+ // Authentication failed even after token refresh attempt+ Log.e(TAG, "Authentication failed (401) - token refresh also failed")+ throw VaultSyncError.SessionExpired()}+ // Other error (5xx, network, etc.) - go offlinesetOfflineMode(true)- throw Exception("Server unavailable: ${statusResponse.statusCode}")+ throw VaultSyncError.ServerUnavailable(statusResponse.statusCode)}val status = try {@@ -1178,11 +1205,12 @@ class VaultStore()} catch (e: Exception) {Log.e(TAG, "Failed to decode status response", e)- throw Exception("Failed to decode status response: ${e.message}")+ Log.e(TAG, "Response body: '${statusResponse.body}'")+ throw VaultSyncError.ParseError("Failed to decode status response: ${e.message}")}if (!status.clientVersionSupported) {- throw Exception("Client version not supported")+ throw VaultSyncError.ClientVersionNotSupported()}validateSrpSalt(status.srpSalt)@@ -1202,10 +1230,10 @@ class VaultStore(val json = org.json.JSONObject(keyDerivationParams)val salt = json.optString("salt", "")if (srpSalt.isNotEmpty() && srpSalt != salt) {- throw Exception("Password changed")+ throw VaultSyncError.PasswordChanged()}} catch (e: Exception) {- if (e.message == "Password changed") throw e+ if (e is VaultSyncError.PasswordChanged) throw e// Ignore parsing errors}}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncError.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncError.ktnew file mode 100644index 000000000..5c7538349--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncError.kt@@ -0,0 +1,62 @@+package net.aliasvault.app.vaultstore++/**+ * Error codes for vault sync operations+ * These error codes are language-independent and can be properly handled by the client+ *+ * This is a Kotlin port of the iOS Swift implementation:+ * - Reference: apps/mobile-app/ios/VaultStoreKit/Enums/VaultSyncError.swift+ *+ * IMPORTANT: Keep all implementations synchronized. Changes to the public interface must be+ * reflected in all ports. Error types and codes should remain consistent.+ */+sealed class VaultSyncError(message: String, cause: Throwable? = null) : Exception(message, cause) {+ // Authentication errors+ class AuthenticationFailed(message: String = "Authentication failed") : VaultSyncError(message)+ class SessionExpired(message: String = "Session expired") : VaultSyncError(message)+ class PasswordChanged(message: String = "Password has changed") : VaultSyncError(message)++ // Network/connectivity errors+ class ServerUnavailable(val statusCode: Int, message: String = "Server unavailable (status: $statusCode)") :+ VaultSyncError(message)+ class NetworkError(val underlyingError: Throwable) :+ VaultSyncError("Network error: ${underlyingError.message}", underlyingError)+ class Timeout(message: String = "Request timeout") : VaultSyncError(message)++ // Version/compatibility errors+ class ClientVersionNotSupported(message: String = "Client version not supported") : VaultSyncError(message)+ class ServerVersionNotSupported(message: String = "Server version not supported") : VaultSyncError(message)+ class VaultVersionIncompatible(message: String = "Vault version incompatible") : VaultSyncError(message)++ // Vault status errors+ class VaultMergeRequired(message: String = "Vault merge required") : VaultSyncError(message)+ class VaultOutdated(message: String = "Vault outdated") : VaultSyncError(message)++ // Decryption errors+ class VaultDecryptFailed(message: String = "Failed to decrypt vault") : VaultSyncError(message)++ // Generic errors+ class UnknownError(message: String) : VaultSyncError("Unknown error: $message")+ class ParseError(message: String) : VaultSyncError("Parse error: $message")++ /**+ * Get the error code string for React Native bridge+ */+ val code: String+ get() = when (this) {+ is AuthenticationFailed -> "VAULT_SYNC_AUTH_FAILED"+ is SessionExpired -> "VAULT_SYNC_SESSION_EXPIRED"+ is PasswordChanged -> "VAULT_SYNC_PASSWORD_CHANGED"+ is ServerUnavailable -> "VAULT_SYNC_SERVER_UNAVAILABLE"+ is NetworkError -> "VAULT_SYNC_NETWORK_ERROR"+ is Timeout -> "VAULT_SYNC_TIMEOUT"+ is ClientVersionNotSupported -> "VAULT_SYNC_CLIENT_VERSION_NOT_SUPPORTED"+ is ServerVersionNotSupported -> "VAULT_SYNC_SERVER_VERSION_NOT_SUPPORTED"+ is VaultVersionIncompatible -> "VAULT_SYNC_VAULT_VERSION_INCOMPATIBLE"+ is VaultMergeRequired -> "VAULT_SYNC_MERGE_REQUIRED"+ is VaultOutdated -> "VAULT_SYNC_OUTDATED"+ is VaultDecryptFailed -> "VAULT_SYNC_DECRYPT_FAILED"+ is UnknownError -> "VAULT_SYNC_UNKNOWN_ERROR"+ is ParseError -> "VAULT_SYNC_PARSE_ERROR"+ }+}diff --git a/apps/mobile-app/android/app/src/main/res/anim/slide_in_left.xml b/apps/mobile-app/android/app/src/main/res/anim/slide_in_left.xmlnew file mode 100644index 000000000..451f65293--- /dev/null+++ b/apps/mobile-app/android/app/src/main/res/anim/slide_in_left.xml@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="utf-8"?>+<set xmlns:android="http://schemas.android.com/apk/res/android">+ <translate+ android:duration="300"+ android:fromXDelta="-100%"+ android:toXDelta="0%" />+ <alpha+ android:duration="300"+ android:fromAlpha="0.0"+ android:toAlpha="1.0" />+</set>diff --git a/apps/mobile-app/android/app/src/main/res/anim/slide_in_right.xml b/apps/mobile-app/android/app/src/main/res/anim/slide_in_right.xmlnew file mode 100644index 000000000..782b3db24--- /dev/null+++ b/apps/mobile-app/android/app/src/main/res/anim/slide_in_right.xml@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="utf-8"?>+<set xmlns:android="http://schemas.android.com/apk/res/android">+ <translate+ android:duration="300"+ android:fromXDelta="100%"+ android:toXDelta="0%" />+ <alpha+ android:duration="300"+ android:fromAlpha="0.0"+ android:toAlpha="1.0" />+</set>diff --git a/apps/mobile-app/android/app/src/main/res/anim/slide_out_left.xml b/apps/mobile-app/android/app/src/main/res/anim/slide_out_left.xmlnew file mode 100644index 000000000..a70e2dd46--- /dev/null+++ b/apps/mobile-app/android/app/src/main/res/anim/slide_out_left.xml@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="utf-8"?>+<set xmlns:android="http://schemas.android.com/apk/res/android">+ <translate+ android:duration="300"+ android:fromXDelta="0%"+ android:toXDelta="-100%" />+ <alpha+ android:duration="300"+ android:fromAlpha="1.0"+ android:toAlpha="0.0" />+</set>diff --git a/apps/mobile-app/android/app/src/main/res/anim/slide_out_right.xml b/apps/mobile-app/android/app/src/main/res/anim/slide_out_right.xmlnew file mode 100644index 000000000..0553877e7--- /dev/null+++ b/apps/mobile-app/android/app/src/main/res/anim/slide_out_right.xml@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="utf-8"?>+<set xmlns:android="http://schemas.android.com/apk/res/android">+ <translate+ android:duration="300"+ android:fromXDelta="0%"+ android:toXDelta="100%" />+ <alpha+ android:duration="300"+ android:fromAlpha="1.0"+ android:toAlpha="0.0" />+</set>diff --git a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration_container.xml b/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration_container.xmlnew file mode 100644index 000000000..d0783194a--- /dev/null+++ b/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration_container.xml@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="utf-8"?>+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"+ android:id="@+id/fragmentContainer"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:background="@color/av_background"+ android:fitsSystemWindows="true" />diff --git a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xml b/apps/mobile-app/android/app/src/main/res/layout/fragment_passkey_form.xmlsimilarity index 98%rename from apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xmlrename to apps/mobile-app/android/app/src/main/res/layout/fragment_passkey_form.xmlindex 7a77670e7..03460a67d 100644--- a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xml+++ b/apps/mobile-app/android/app/src/main/res/layout/fragment_passkey_form.xml@@ -72,6 +72,7 @@android:contentDescription="@string/passkey_info_icon" /><TextView+ android:id="@+id/infoExplanationText"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"@@ -224,7 +225,7 @@android:id="@+id/loadingOverlay"android:layout_width="match_parent"android:layout_height="match_parent"- android:background="#B3000000"+ android:background="@color/av_loading_overlay"android:visibility="gone"android:clickable="true"android:focusable="true">diff --git a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_selection.xml b/apps/mobile-app/android/app/src/main/res/layout/fragment_passkey_selection.xmlsimilarity index 90%rename from apps/mobile-app/android/app/src/main/res/layout/activity_passkey_selection.xmlrename to apps/mobile-app/android/app/src/main/res/layout/fragment_passkey_selection.xmlindex 50f8355c4..98309e8ab 100644--- a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_selection.xml+++ b/apps/mobile-app/android/app/src/main/res/layout/fragment_passkey_selection.xml@@ -81,14 +81,20 @@android:paddingStart="4dp"android:paddingEnd="4dp" />- <!-- Existing passkeys list container -->+ <!-- Scrollable existing passkeys list (max 2.5 items visible) --><LinearLayoutandroid:id="@+id/existingPasskeysContainer"android:layout_width="match_parent"android:layout_height="wrap_content"- android:orientation="vertical"- android:layout_marginBottom="24dp">- <!-- Passkey items will be added programmatically -->+ android:orientation="vertical">++ <LinearLayout+ android:id="@+id/existingPasskeysContainer"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:orientation="vertical">+ <!-- Passkey items will be added programmatically -->+ </LinearLayout></LinearLayout><Viewdiff --git a/apps/mobile-app/android/app/src/main/res/layout/item_existing_passkey.xml b/apps/mobile-app/android/app/src/main/res/layout/item_existing_passkey.xmlindex a3b97de11..56d348253 100644--- a/apps/mobile-app/android/app/src/main/res/layout/item_existing_passkey.xml+++ b/apps/mobile-app/android/app/src/main/res/layout/item_existing_passkey.xml@@ -8,6 +8,7 @@android:clickable="true"android:focusable="true"android:padding="16dp"+ android:layout_marginBottom="8dp"android:gravity="center_vertical"><!-- Icon -->diff --git a/apps/mobile-app/android/app/src/main/res/values-night/colors.xml b/apps/mobile-app/android/app/src/main/res/values-night/colors.xmlindex 820791460..959b96de1 100644--- a/apps/mobile-app/android/app/src/main/res/values-night/colors.xml+++ b/apps/mobile-app/android/app/src/main/res/values-night/colors.xml@@ -11,4 +11,7 @@<color name="av_tertiary">#eabf69</color><color name="av_icon">#9BA1A6</color><color name="av_error">#ef4444</color>++ <!-- Loading overlay background (dark mode: black with 80% opacity) -->+ <color name="av_loading_overlay">#CC000000</color></resources>diff --git a/apps/mobile-app/android/app/src/main/res/values/colors.xml b/apps/mobile-app/android/app/src/main/res/values/colors.xmlindex e66a4c272..af3daf2bd 100644--- a/apps/mobile-app/android/app/src/main/res/values/colors.xml+++ b/apps/mobile-app/android/app/src/main/res/values/colors.xml@@ -29,4 +29,7 @@<color name="av_tertiary">#eabf69</color><color name="av_icon">#687076</color><color name="av_error">#D32F2F</color>++ <!-- Loading overlay background (light mode: white with 80% opacity) -->+ <color name="av_loading_overlay">#CCFFFFFF</color></resources>diff --git a/apps/mobile-app/android/app/src/main/res/values/strings.xml b/apps/mobile-app/android/app/src/main/res/values/strings.xmlindex 31d5e6763..fa9f1c77a 100644--- a/apps/mobile-app/android/app/src/main/res/values/strings.xml+++ b/apps/mobile-app/android/app/src/main/res/values/strings.xml@@ -20,6 +20,9 @@<!-- Passkey registration --><string name="passkey_registration_title">Create Passkey</string>+ <string name="create_passkey_title">Create New Passkey</string>+ <string name="create_passkey_subtitle">Register a new passkey for this website. It will be securely stored in your vault and automatically synced across your devices with AliasVault.</string>+ <string name="replace_passkey_title">Replace Passkey</string><string name="passkey_display_name_label">Passkey Name</string><string name="passkey_display_name_hint">Enter a name for this passkey</string><string name="passkey_website_label">Website</string>@@ -34,11 +37,27 @@<string name="passkey_creation_failed">Failed to create passkey</string><string name="passkey_retry_button">Retry</string><string name="passkey_info_icon">Info icon</string>- <string name="passkey_create_explanation">Create a passkey to securely sign in without passwords</string>+ <string name="passkey_create_explanation">This creates a new passkey and stores it in your vault. It will be automatically synced across all your devices that use AliasVault.</string><string name="passkey_create_new_button">Create New Passkey</string>- <string name="passkey_select_to_replace">Select passkey to replace</string>- <string name="passkey_replace_title">Replace Passkey</string>+ <string name="passkey_select_to_replace">Or, replace an existing passkey:</string><string name="passkey_replace_button">Replace Passkey</string>- <string name="passkey_replace_explanation">Replacing this passkey will delete the old one and create a new one</string>+ <string name="passkey_replace_explanation">This will replace the existing passkey with a new one. Please be aware that your old passkey will be overwritten and no longer accessible. If you wish to create a separate passkey instead, go back to the previous screen.</string><string name="passkey_replacing">Replacing passkey…</string>+ <string name="passkey_checking_connection">Checking connection…</string>++ <!-- Vault sync error messages -->+ <string name="connection_error_title">Connection Error</string>+ <string name="connection_error_message">No connection to the server can be made. Please check your internet connection and try creating the passkey again.</string>+ <string name="session_expired_title">Session Expired</string>+ <string name="session_expired_message">Your session has expired. Please sign in again.</string>+ <string name="password_changed_title">Password Changed</string>+ <string name="password_changed_message">Your password has been changed. Please sign in again.</string>+ <string name="version_not_supported_title">Update Required</string>+ <string name="version_not_supported_message">Your app version is no longer supported. Please update to the latest version.</string>+ <string name="server_unavailable_title">Server Unavailable</string>+ <string name="server_unavailable_message">The server is currently unavailable. Please try again later.</string>+ <string name="network_error_title">Network Error</string>+ <string name="network_error_message">A network error occurred. Please check your connection and try again.</string>+ <string name="server_version_not_supported_title">Server Update Required</string>+ <string name="server_version_not_supported_message">The server version is outdated. Please contact your administrator to update the server.</string></resources>\ No newline at end of file