Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Make passkey a single prop instead of list (#1404)
Leendert de Borst6b0c482b704b
diff --git a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swiftindex ad1ba861c..f1797f996 100644--- a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift+++ b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift@@ -544,9 +544,9 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {*/internal func handlePasskeySelection(credential: AutofillCredential, clientDataHash: Data, rpId: String) {do {- // Get the first matching passkey for the RP ID- guard let passkeys = credential.passkeys,- let passkey = passkeys.first(where: { $0.rpId.lowercased() == rpId.lowercased() }) else {+ // Get the passkey and verify it matches the RP ID+ guard let passkey = credential.passkey,+ passkey.rpId.lowercased() == rpId.lowercased() else {extensionContext.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain,code: ASExtensionError.credentialIdentityNotFound.rawValuediff --git a/apps/mobile-app/ios/VaultModels/AutofillCredential.swift b/apps/mobile-app/ios/VaultModels/AutofillCredential.swiftindex 51860289b..ef78257a2 100644--- a/apps/mobile-app/ios/VaultModels/AutofillCredential.swift+++ b/apps/mobile-app/ios/VaultModels/AutofillCredential.swift@@ -12,7 +12,7 @@ public struct AutofillCredential: Codable, Hashable, Equatable {public let email: String?public let password: String?public let notes: String?- public let passkeys: [Passkey]?+ public let passkey: Passkey?public let createdAt: Datepublic let updatedAt: Date@@ -25,7 +25,7 @@ public struct AutofillCredential: Codable, Hashable, Equatable {email: String?,password: String?,notes: String?,- passkeys: [Passkey]?,+ passkey: Passkey?,createdAt: Date,updatedAt: Date) {@@ -37,7 +37,7 @@ public struct AutofillCredential: Codable, Hashable, Equatable {self.email = emailself.password = passwordself.notes = notes- self.passkeys = passkeys+ self.passkey = passkeyself.createdAt = createdAtself.updatedAt = updatedAt}@@ -45,8 +45,8 @@ public struct AutofillCredential: Codable, Hashable, Equatable {/// Initialize from an Item model./// - Parameters:/// - item: The Item to convert from- /// - passkeys: Optional passkeys associated with this item- public init(from item: Item, passkeys: [Passkey]? = nil) {+ /// - passkey: Optional passkey associated with this item+ public init(from item: Item, passkey: Passkey? = nil) {self.id = item.idself.serviceName = item.nameself.serviceUrl = item.url@@ -55,7 +55,7 @@ public struct AutofillCredential: Codable, Hashable, Equatable {self.email = item.emailself.password = item.passwordself.notes = item.getFieldValue(FieldKey.notesContent)- self.passkeys = passkeys+ self.passkey = passkeyself.createdAt = item.createdAtself.updatedAt = item.updatedAt}@@ -88,9 +88,8 @@ public struct AutofillCredential: Codable, Hashable, Equatable {return !password.isEmpty}- /// Returns true if this credential has passkeys.- public var hasPasskeys: Bool {- guard let passkeys = passkeys else { return false }- return !passkeys.isEmpty+ /// Returns true if this credential has a passkey.+ public var hasPasskey: Bool {+ return passkey != nil}}diff --git a/apps/mobile-app/ios/VaultStoreKit/CredentialIdentityStore.swift b/apps/mobile-app/ios/VaultStoreKit/CredentialIdentityStore.swiftindex 45d14a2af..35d34c977 100644--- a/apps/mobile-app/ios/VaultStoreKit/CredentialIdentityStore.swift+++ b/apps/mobile-app/ios/VaultStoreKit/CredentialIdentityStore.swift@@ -79,8 +79,8 @@ public class CredentialIdentityStore {/// Create password credential identities from credentialsprivate func createPasswordIdentities(from credentials: [AutofillCredential]) -> [ASPasswordCredentialIdentity] {return credentials.compactMap { credential in- guard !credential.hasPasskeys else {- // Skip if this record has passkeys as they will be saved in createPasskeyIdentities+ guard !credential.hasPasskey else {+ // Skip if this record has a passkey as they will be saved in createPasskeyIdentitiesreturn nil}@@ -112,30 +112,27 @@ public class CredentialIdentityStore {/// Create passkey credential identities from credentialsprivate func createPasskeyIdentities(from credentials: [AutofillCredential]) -> [ASPasskeyCredentialIdentity] {- return credentials.flatMap { credential -> [ASPasskeyCredentialIdentity] in- guard let passkeys = credential.passkeys else {- return []+ return credentials.compactMap { credential -> ASPasskeyCredentialIdentity? in+ guard let passkey = credential.passkey, !passkey.isDeleted else {+ return nil}- return passkeys.filter { !($0.isDeleted) }- .compactMap { passkey in- // Get the userName for display in iOS AutoFill UI- // Passkeys may store userName, otherwise use the credential's identifier- let userName = passkey.userName ?? credential.identifier-- // Convert passkey.Id to bytes for credentialID- let credentialId = try? PasskeyHelper.guidToBytes(passkey.id.uuidString)-- // For passkeys, we use the rpId from the passkey itself, not the service URL- // This is because passkeys are tied to the RP ID, which may differ from the service URL- return ASPasskeyCredentialIdentity(- relyingPartyIdentifier: passkey.rpId,- userName: userName,- credentialID: credentialId ?? Data(), // WebAuthn credential ID (16-byte GUID)- userHandle: passkey.userHandle ?? Data(),- recordIdentifier: passkey.id.uuidString- )- }+ // Get the userName for display in iOS AutoFill UI+ // Passkeys may store userName, otherwise use the credential's identifier+ let userName = passkey.userName ?? credential.identifier++ // Convert passkey.Id to bytes for credentialID+ let credentialId = try? PasskeyHelper.guidToBytes(passkey.id.uuidString)++ // For passkeys, we use the rpId from the passkey itself, not the service URL+ // This is because passkeys are tied to the RP ID, which may differ from the service URL+ return ASPasskeyCredentialIdentity(+ relyingPartyIdentifier: passkey.rpId,+ userName: userName,+ credentialID: credentialId ?? Data(), // WebAuthn credential ID (16-byte GUID)+ userHandle: passkey.userHandle ?? Data(),+ recordIdentifier: passkey.id.uuidString+ )}}}diff --git a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Query.swift b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Query.swiftindex 841626a46..b6ddc494b 100644--- a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Query.swift+++ b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Query.swift@@ -287,19 +287,20 @@ extension VaultStore {/// Convert an Item to an AutofillCredential for iOS Autofill.private func convertItemToAutofillCredential(_ item: Item) -> AutofillCredential? {- // Load passkeys for this item+ // Load passkey for this item (gets first non-deleted passkey)let passkeys = try? getPasskeys(forItemId: item.id)+ let passkey = passkeys?.first- return AutofillCredential(from: item, passkeys: passkeys)+ return AutofillCredential(from: item, passkey: passkey)}/// Get all items that have passkeys for passkey autofill.public func getAllAutofillCredentialsWithPasskeys() throws -> [AutofillCredential] {var credentials = try getAllAutofillCredentials()- // Filter to only include credentials that actually have passkeys+ // Filter to only include credentials that actually have a passkeycredentials = credentials.filter { credential in- return credential.hasPasskeys+ return credential.hasPasskey}return credentialsdiff --git a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swiftindex f798d4451..469b38c98 100644--- a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift+++ b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift@@ -166,7 +166,7 @@ public func truncateText(_ text: String?, limit: Int) -> String {email: "[email protected]",password: "securepassword123",notes: "Sample notes",- passkeys: nil,+ passkey: nil,createdAt: Date(),updatedAt: Date()),diff --git a/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift b/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swiftindex b551adb7a..597b5b351 100644--- a/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift+++ b/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift@@ -285,7 +285,7 @@ extension AutofillCredential {email: "[email protected]",password: "password123",notes: "Sample credential",- passkeys: nil,+ passkey: nil,createdAt: Date(),updatedAt: Date())@@ -306,7 +306,7 @@ public class PreviewCredentialProviderViewModel: CredentialProviderViewModel {email: "[email protected]",password: "password456",notes: "Another sample credential",- passkeys: nil,+ passkey: nil,createdAt: Date(),updatedAt: Date())diff --git a/apps/mobile-app/ios/VaultUI/Selection/PasskeyProviderView.swift b/apps/mobile-app/ios/VaultUI/Selection/PasskeyProviderView.swiftindex 52099001a..dc841d3ab 100644--- a/apps/mobile-app/ios/VaultUI/Selection/PasskeyProviderView.swift+++ b/apps/mobile-app/ios/VaultUI/Selection/PasskeyProviderView.swift@@ -159,8 +159,8 @@ private struct PasskeyCredentialCard: View {.foregroundColor(colors.textMuted)}- // Show passkey count- if credential.hasPasskeys {+ // Show passkey indicator+ if credential.hasPasskey {Text(String(localized: "passkey", bundle: locBundle)).font(.caption).foregroundColor(colors.primary)@@ -260,9 +260,9 @@ public class PasskeyProviderViewModel: ObservableObject {credential.notes?.lowercased() ?? ""]- // Add passkey rpIds to searchable fields- if let passkeys = credential.passkeys {- searchableFields.append(contentsOf: passkeys.map { $0.rpId.lowercased() })+ // Add passkey rpId to searchable fields+ if let passkey = credential.passkey {+ searchableFields.append(passkey.rpId.lowercased())}// All search words must be found (each in at least one field)@@ -344,7 +344,7 @@ public class PasskeyProviderViewModel: ObservableObject {email: "[email protected]",password: "password123",notes: nil,- passkeys: [mockPasskey1],+ passkey: mockPasskey1,createdAt: Date(),updatedAt: Date()),@@ -357,7 +357,7 @@ public class PasskeyProviderViewModel: ObservableObject {email: "[email protected]",password: "password456",notes: nil,- passkeys: [mockPasskey2],+ passkey: mockPasskey2,createdAt: Date(),updatedAt: Date())@@ -403,7 +403,7 @@ public class PasskeyProviderViewModel: ObservableObject {email: "[email protected]",password: nil,notes: nil,- passkeys: [mockPasskey],+ passkey: mockPasskey,createdAt: Date(),updatedAt: Date())