fix: address AutoFill extension code review findings
- Remove dead provideCredentialWithoutUserInteraction override and unlockSilently() helper (nothing registers credential identities, so it could never run, and it was a footgun for future inline QuickType work). - Surface non-cancellation biometric unlock failures into errorMessage instead of swallowing them, matching UnlockViewModel.unlockWithBiometrics(). - Forward VaultSession.objectWillChange into ExtensionViewModel via Combine so the lock/unlock UI transition no longer depends on an accidental isUnlocking side effect, matching VaultViewModel's pattern. - Show the "Open MyPass" deep-link escape hatch whenever unlock fails (errorMessage set), not only when there's no bookmark yet, per the extension constraints spec. - Add INFOPLIST_KEY_NSFaceIDUsageDescription to the MyPass and AutoFill targets' Debug/Release build configs. Also folds in pre-existing alphabetical reordering of two PBXBuildFile/PBXFileReference entries in project.pbxproj from an earlier task, since this same file is already being touched here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf
This commit is contained in:
@@ -22,32 +22,6 @@ final class CredentialProviderViewController: ASCredentialProviderViewController
|
||||
showUI(serviceIdentifiers: ids)
|
||||
}
|
||||
|
||||
// Called for inline QuickType suggestion (no UI shown).
|
||||
override func provideCredentialWithoutUserInteraction(for credentialIdentity: ASPasswordCredentialIdentity) {
|
||||
Task {
|
||||
do {
|
||||
try await unlockSilently()
|
||||
let all = session.allEntries()
|
||||
if let entry = all.first(where: { $0.id.uuidString == credentialIdentity.recordIdentifier }) {
|
||||
let credential = ASPasswordCredential(user: entry.username, password: entry.password.reveal())
|
||||
self.extensionContext.completeRequest(withSelectedCredential: credential, completionHandler: nil)
|
||||
} else {
|
||||
self.extensionContext.cancelRequest(withError: ASExtensionError(.credentialIdentityNotFound))
|
||||
}
|
||||
} catch {
|
||||
self.extensionContext.cancelRequest(withError: ASExtensionError(.userInteractionRequired))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func unlockSilently() async throws {
|
||||
guard session.isLocked else { return }
|
||||
let password = try keychainStore.load(for: "masterPassword")
|
||||
let url = try bookmarkService.resolveURL()
|
||||
defer { bookmarkService.stopAccess(url: url) }
|
||||
try session.unlock(url: url, password: password)
|
||||
}
|
||||
|
||||
private func showUI(serviceIdentifiers: [String]) {
|
||||
let rootView = ExtensionRootView(
|
||||
session: session,
|
||||
|
||||
@@ -73,7 +73,7 @@ struct ExtensionRootView: View {
|
||||
Text(msg).foregroundStyle(.red).font(.caption).multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
if !vm.hasVault {
|
||||
if !vm.hasVault || vm.errorMessage != nil {
|
||||
Link(destination: URL(string: "mypass://unlock")!) {
|
||||
Label("Open MyPass to set up vault", systemImage: "arrow.up.right")
|
||||
.font(.caption)
|
||||
@@ -98,6 +98,7 @@ final class ExtensionViewModel: ObservableObject {
|
||||
private let biometricService: BiometricAuthService
|
||||
private let onSelect: (Entry) -> Void
|
||||
private let onCancel: () -> Void
|
||||
private var sessionCancellable: AnyCancellable?
|
||||
|
||||
init(
|
||||
session: VaultSession,
|
||||
@@ -115,6 +116,9 @@ final class ExtensionViewModel: ObservableObject {
|
||||
self.biometricService = biometricService
|
||||
self.onSelect = onSelect
|
||||
self.onCancel = onCancel
|
||||
sessionCancellable = session.objectWillChange.sink { [weak self] in
|
||||
self?.objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
var isLocked: Bool { session.isLocked }
|
||||
@@ -139,7 +143,7 @@ final class ExtensionViewModel: ObservableObject {
|
||||
try await biometricService.authenticate(reason: "Unlock MyPass")
|
||||
try performUnlockFromKeychain()
|
||||
} catch {
|
||||
// Silently fail -- user can type password
|
||||
errorMessage = error.localizedDescription
|
||||
}
|
||||
isUnlocking = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user