Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update iOS passkey replace flow (#1685)
Leendert de Borst10be2d3450ce
diff --git a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swiftindex 144f1c925..18735368f 100644--- a/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift+++ b/apps/mobile-app/ios/Autofill/CredentialProviderViewController+Passkey.swift@@ -225,7 +225,7 @@ extension CredentialProviderViewController: PasskeyProviderDelegate {// Query for existing passkeys with this rpId and userNamevar existingPasskeys: [PasskeyWithCredentialInfo] = []do {- let results = try vaultStore.getPasskeysWithCredentialInfo(forRpId: rpId, userName: userName, userId: userId)+ let results = try vaultStore.getPasskeysWithCredentialInfo(forRpId: rpId, userId: userId)existingPasskeys = results.map { result inPasskeyWithCredentialInfo(id: result.passkey.id,diff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swiftindex 367f5abb7..267f6ba6f 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swift@@ -20,22 +20,40 @@ public struct PasskeyQueries {FROM Passkeys p"""+ /// Base SELECT for passkeys joined with Items to check parent item deletion status.+ public static let baseSelectWithItemCheck = """+ SELECT+ p.Id,+ p.ItemId,+ p.RpId,+ p.UserHandle,+ p.PublicKey,+ p.PrivateKey,+ p.PrfKey,+ p.DisplayName,+ p.CreatedAt,+ p.UpdatedAt,+ p.IsDeleted+ FROM Passkeys p+ INNER JOIN Items i ON p.ItemId = i.Id AND i.IsDeleted = 0 AND i.DeletedAt IS NULL+ """+/// Get a passkey by its ID (credential ID).public static let getById = """- \(baseSelect)+ \(baseSelectWithItemCheck)WHERE p.Id = ? AND p.IsDeleted = 0"""/// Get all passkeys for an item.public static let getByItemId = """- \(baseSelect)+ \(baseSelectWithItemCheck)WHERE p.ItemId = ? AND p.IsDeleted = 0ORDER BY p.CreatedAt DESC"""/// Get all passkeys for a relying party (rpId).public static let getByRpId = """- \(baseSelect)+ \(baseSelectWithItemCheck)WHERE p.RpId = ? AND p.IsDeleted = 0ORDER BY p.CreatedAt DESC"""@@ -60,7 +78,7 @@ public struct PasskeyQueries {FROM Passkeys pINNER JOIN Items i ON p.ItemId = i.IdLEFT JOIN FieldValues fv ON fv.ItemId = i.Id AND fv.FieldKey = 'login.username' AND fv.IsDeleted = 0- WHERE p.RpId = ? AND p.IsDeleted = 0 AND i.IsDeleted = 0+ WHERE p.RpId = ? AND p.IsDeleted = 0 AND i.IsDeleted = 0 AND i.DeletedAt IS NULLORDER BY p.CreatedAt DESC"""diff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swiftindex 9554c8832..03888d856 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swift@@ -227,7 +227,6 @@ public class PasskeyRepository: BaseRepository {try updateItemLogoInternal(itemId: newPasskey.parentItemId.uuidString.uppercased(),logo: logo,- displayName: displayName,rpId: newPasskey.rpId,now: now)@@ -364,28 +363,33 @@ public class PasskeyRepository: BaseRepository {}}- /// Update item logo when replacing a passkey.+ /// Update item logo.+ /// Note: This only updates the logo, NOT the item name./// - Parameters:/// - itemId: The item ID/// - logo: The new logo data- /// - displayName: The new display name/// - rpId: The relying party ID for logo source- public func updateItemLogo(itemId: String, logo: Data, displayName: String, rpId: String) throws {+ public func updateItemLogo(itemId: String, logo: Data, rpId: String) throws {try withTransaction {let now = self.now()- try updateItemLogoInternal(itemId: itemId, logo: logo, displayName: displayName, rpId: rpId, now: now)+ try updateItemLogoInternal(itemId: itemId, logo: logo, rpId: rpId, now: now)}}/// Internal helper to update item logo without creating a transaction./// Used within larger transactions to avoid nested transaction issues.+ /// Note: This only updates the logo, never the item name./// - Parameters:/// - itemId: The item ID/// - logo: The new logo data- /// - displayName: The new display name/// - rpId: The relying party ID for logo source (used when creating new logo)/// - now: The current timestamp- private func updateItemLogoInternal(itemId: String, logo: Data, displayName: String, rpId: String, now: String) throws {+ private func updateItemLogoInternal(+ itemId: String,+ logo: Data,+ rpId: String,+ now: String+ ) throws {// Get current logo ID from itemlet itemResults = try client.executeQuery("SELECT LogoId FROM Items WHERE Id = ?",@@ -412,12 +416,6 @@ public class PasskeyRepository: BaseRepository {params: [newLogoId, now, itemId])}-- // Update item name- try client.executeUpdate(- "UPDATE Items SET Name = ?, UpdatedAt = ? WHERE Id = ?",- params: [displayName, now, itemId]- )}/// Add a passkey to an existing Item (merge passkey into existing credential).@@ -441,7 +439,6 @@ public class PasskeyRepository: BaseRepository {try updateItemLogoInternal(itemId: itemIdString,logo: logo,- displayName: passkey.displayName,rpId: passkey.rpId,now: now)diff --git a/apps/mobile-app/utils/db/repositories/PasskeyRepository.ts b/apps/mobile-app/utils/db/repositories/PasskeyRepository.tsindex 69267fc97..ef91397d3 100644--- a/apps/mobile-app/utils/db/repositories/PasskeyRepository.ts+++ b/apps/mobile-app/utils/db/repositories/PasskeyRepository.ts@@ -35,7 +35,7 @@ const PasskeyQueries = {i.Name as ItemName,fv.Value as UsernameFROM Passkeys p- LEFT JOIN Items i ON p.ItemId = i.Id+ INNER JOIN Items i ON p.ItemId = i.Id AND i.IsDeleted = 0 AND i.DeletedAt IS NULLLEFT JOIN FieldValues fv ON fv.ItemId = i.Id AND fv.FieldKey = 'login.username' AND fv.IsDeleted = 0WHERE p.RpId = ? AND p.IsDeleted = 0ORDER BY p.CreatedAt DESC`,@@ -61,7 +61,7 @@ const PasskeyQueries = {i.Name as ItemName,fv.Value as UsernameFROM Passkeys p- LEFT JOIN Items i ON p.ItemId = i.Id+ INNER JOIN Items i ON p.ItemId = i.Id AND i.IsDeleted = 0 AND i.DeletedAt IS NULLLEFT JOIN FieldValues fv ON fv.ItemId = i.Id AND fv.FieldKey = 'login.username' AND fv.IsDeleted = 0WHERE p.Id = ? AND p.IsDeleted = 0`,@@ -86,7 +86,7 @@ const PasskeyQueries = {i.Name as ItemName,fv.Value as UsernameFROM Passkeys p- LEFT JOIN Items i ON p.ItemId = i.Id+ INNER JOIN Items i ON p.ItemId = i.Id AND i.IsDeleted = 0 AND i.DeletedAt IS NULLLEFT JOIN FieldValues fv ON fv.ItemId = i.Id AND fv.FieldKey = 'login.username' AND fv.IsDeleted = 0WHERE p.ItemId = ? AND p.IsDeleted = 0ORDER BY p.CreatedAt DESC`,