Skip to content

Commit

Permalink
SDK-1561 Fix issue with Biometrics registration (#216)
Browse files Browse the repository at this point in the history
* kSecAttrAccessible and kSecAttrAccessControl are mutually exclusive. Prefer kSecAttrAccessControl if both are requested

* Lint
  • Loading branch information
jhaven-stytch authored Apr 3, 2024
1 parent a5f550a commit 0f2c133
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Sources/StytchCore/Extensions/Dictionary+Stytch.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import CoreFoundation
import Foundation

extension Dictionary where Key == CFString, Value == Any {
func merging(_ other: Self) -> CFDictionary {
merging(other) { $1 } as CFDictionary
}

func accessibilityAwareMerging(_ other: Self) -> CFDictionary {
var combined = merging(other) { $1 } as [CFString: Any]
if combined[kSecAttrAccessible] != nil, combined[kSecAttrAccessControl] != nil {
// we can't have both, so prefer kSecAttrAccessControl
combined.removeValue(forKey: kSecAttrAccessible)
}
return combined as CFDictionary
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension KeychainClient {
}

func insertQuery(value: Value) -> CFDictionary {
baseQuery.merging(updateQuerySegment(for: value))
baseQuery.accessibilityAwareMerging(updateQuerySegment(for: value))
}

func updateQuerySegment(for value: Value) -> [CFString: Any] {
Expand Down

0 comments on commit 0f2c133

Please sign in to comment.