Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update iOS passkey create flow to prevent 25308 error (#520)
Leendert de Borst00c230a92ed4
diff --git a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swiftindex 9e8a0d1b0..79900e0eb 100644--- a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift+++ b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift@@ -186,35 +186,14 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {prfInputs = extractPrfInputs(from: extensionInput)}- // Initialize vault store- let vaultStore = VaultStore()-- // Check vault state- guard sanityChecks(vaultStore: vaultStore) else {- return- }-- // Unlock vault- do {- try vaultStore.unlockVault()- } catch {- print("PasskeyRegistration: Failed to unlock vault: \(error)")- extensionContext.cancelRequest(withError: NSError(- domain: ASExtensionErrorDomain,- code: ASExtensionError.failed.rawValue,- userInfo: [NSLocalizedDescriptionKey: "Failed to unlock vault"]- ))- return- }-- // Show passkey registration UI- showPasskeyRegistrationView(+ // Store parameters for use in viewWillAppear+ // Vault unlock and UI display will happen in viewWillAppear+ self.passkeyRegistrationParams = PasskeyRegistrationParams(rpId: rpId,userName: userName,userDisplayName: userDisplayName,userId: userId,clientDataHash: clientDataHash,- vaultStore: vaultStore,enablePrf: prfEnabled,prfInputs: prfInputs)@@ -431,7 +410,7 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {try vaultStore.commitTransaction()// Step 5: Upload vault changes to server- viewModel.setLoading(true, message: NSLocalizedString("vault_syncing", comment: "Uploading vault..."))+ viewModel.setLoading(true, message: NSLocalizedString("creating_passkey", comment: "Uploading vault..."))do {try await vaultStore.mutateVault(using: webApiService)} catch {diff --git a/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift b/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swiftindex fd6ef5dad..cbd42b554 100644--- a/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift+++ b/apps/mobile-app/ios/Autofill/CredentialProviderViewController.swift@@ -36,6 +36,9 @@ public class CredentialProviderViewController: ASCredentialProviderViewControlleprivate var initialRpId: String?private var clientDataHash: Data?+ // Passkey registration properties+ internal var passkeyRegistrationParams: PasskeyRegistrationParams?+// Quick return mode (complete request without showing UI)internal var isQuickReturnMode = falseinternal var quickReturnPasswordRequest: ASPasswordCredentialRequest?@@ -92,11 +95,6 @@ public class CredentialProviderViewController: ASCredentialProviderViewControllereturn}- // Don't set up credential view if we're in passkey registration mode- if isPasskeyRegistrationMode {- return- }-// Check if there is a stored vault. If not, it means the user has not logged in yet and we// should redirect to the main app login screen automatically.let vaultStore = VaultStore()@@ -120,6 +118,30 @@ public class CredentialProviderViewController: ASCredentialProviderViewControllereturn}+ // Handle passkey registration mode after vault is unlocked+ if isPasskeyRegistrationMode {+ guard let params = passkeyRegistrationParams else {+ extensionContext.cancelRequest(withError: NSError(+ domain: ASExtensionErrorDomain,+ code: ASExtensionError.failed.rawValue,+ userInfo: [NSLocalizedDescriptionKey: "Missing passkey registration parameters"]+ ))+ return+ }++ // Show passkey registration UI+ showPasskeyRegistrationView(+ rpId: params.rpId,+ userName: params.userName,+ userDisplayName: params.userDisplayName,+ userId: params.userId,+ clientDataHash: params.clientDataHash,+ vaultStore: vaultStore,+ enablePrf: params.enablePrf,+ prfInputs: params.prfInputs+ )+ return+ }// Only set up the view if we haven't alreadyif currentHostingController == nil {@@ -244,8 +266,6 @@ public class CredentialProviderViewController: ASCredentialProviderViewControlleoverride public func prepareInterfaceToProvideCredential(for request: ASCredentialRequest) {// Check if this is a password/credential requestif let passwordRequest = request as? ASPasswordCredentialRequest {- // We don't unlock vault here - that requires user interaction context- // which will happen in viewWillAppearself.isQuickReturnMode = trueself.quickReturnPasswordRequest = passwordRequestreturn@@ -253,9 +273,6 @@ public class CredentialProviderViewController: ASCredentialProviderViewControlle// Check if this is a passkey requestif let passkeyRequest = request as? ASPasskeyCredentialRequest {- // Store request and set quick return mode flag- // We don't unlock vault here - that requires user interaction context- // which will happen in viewWillAppearself.isQuickReturnMode = trueself.quickReturnPasskeyRequest = passkeyRequestreturndiff --git a/apps/mobile-app/ios/Autofill/Structs/PasskeyRegistrationParams.swift b/apps/mobile-app/ios/Autofill/Structs/PasskeyRegistrationParams.swiftnew file mode 100644index 000000000..202165358--- /dev/null+++ b/apps/mobile-app/ios/Autofill/Structs/PasskeyRegistrationParams.swift@@ -0,0 +1,20 @@+import Foundation+import VaultStoreKit++/// Parameters for passkey registration+public struct PasskeyRegistrationParams {+ /// The relying party identifier (domain)+ public let rpId: String+ /// The user name+ public let userName: String?+ /// The user display name+ public let userDisplayName: String?+ /// The user ID+ public let userId: Data?+ /// The client data hash+ public let clientDataHash: Data+ /// Whether PRF is enabled+ public let enablePrf: Bool+ /// The PRF inputs+ public let prfInputs: PrfInputs?+}\ No newline at end of filediff --git a/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyFormView.swift b/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyFormView.swiftindex cf0a26588..df591af8b 100644--- a/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyFormView.swift+++ b/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyFormView.swift@@ -117,14 +117,14 @@ struct PasskeyFormView: View {LoadingOverlayView(message: viewModel.loadingMessage)}}- .navigationTitle(isReplaceMode- ? String(localized: "replace_passkey_title", bundle: locBundle)- : String(localized: "create_passkey_title", bundle: locBundle)).navigationBarTitleDisplayMode(.inline)- .onAppear {- // Auto-focus the title field- DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {- isTitleFocused = true+ .toolbar {+ ToolbarItem(placement: .principal) {+ Text(isReplaceMode+ ? String(localized: "replace_passkey_title", bundle: locBundle)+ : String(localized: "create_passkey_title", bundle: locBundle))+ .font(.headline)+ .foregroundStyle(colorScheme == .dark ? ColorConstants.Dark.text : ColorConstants.Light.text)}}}diff --git a/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyRegistrationView.swift b/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyRegistrationView.swiftindex 091efbc3d..b836e325c 100644--- a/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyRegistrationView.swift+++ b/apps/mobile-app/ios/VaultUI/Registration/Passkeys/PasskeyRegistrationView.swift@@ -45,8 +45,16 @@ public struct PasskeyRegistrationView: View {LoadingOverlayView(message: viewModel.loadingMessage)}}- .navigationBarHidden(viewModel.existingPasskeys.isEmpty).navigationBarTitleDisplayMode(.inline)+ .toolbar {+ ToolbarItem(placement: .principal) {+ if !viewModel.existingPasskeys.isEmpty {+ Text(String(localized: "create_passkey_title", bundle: locBundle))+ .font(.headline)+ .foregroundStyle(colorScheme == .dark ? ColorConstants.Dark.text : ColorConstants.Light.text)+ }+ }+ }.navigationDestination(for: PasskeyNavigationDestination.self) { destination indestinationView(for: destination)}@@ -191,12 +199,6 @@ public struct PasskeyRegistrationView: View {.padding(.horizontal).padding(.bottom, 20)}- .onAppear {- // Auto-focus when appearing- DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {- isTitleFocused = true- }- }}// MARK: - Navigation Destination