Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change default accessibility value #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions Sources/GoodPersistence/KeychainValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public class KeychainValue<T: Codable & Equatable> {
public init(
_ key: String,
defaultValue: T,
accessibility: KeychainAccess.Accessibility? = nil,
accessibility: KeychainAccess.Accessibility = .afterFirstUnlock,
synchronizable: Bool = false,
authenticationPolicy: KeychainAccess.AuthenticationPolicy? = nil
) {
Expand Down Expand Up @@ -170,7 +170,7 @@ public class KeychainValue<T: Codable & Equatable> {

private let key: String
private let defaultValue: T
private let accessibility: KeychainAccess.Accessibility?
private let accessibility: KeychainAccess.Accessibility
private let synchronizable: Bool
private let authenticationPolicy: KeychainAccess.AuthenticationPolicy?

Expand Down Expand Up @@ -321,19 +321,14 @@ public class KeychainValue<T: Codable & Equatable> {
///
/// - Returns: A configured `KeychainAccess.Keychain` instance based on the provided parameters.
private func setupKeychain() -> KeychainAccess.Keychain {
if let accessibility, let authenticationPolicy {
return Keychain.default
.accessibility(accessibility, authenticationPolicy: authenticationPolicy)
} else if let accessibility {
if let authenticationPolicy {
return Keychain.default
.synchronizable(synchronizable)
.accessibility(accessibility)
} else if let authenticationPolicy {
return Keychain.default
.accessibility(Keychain.default.accessibility, authenticationPolicy: authenticationPolicy)
.accessibility(accessibility, authenticationPolicy: authenticationPolicy)
} else {
return Keychain.default
.synchronizable(synchronizable)
.accessibility(accessibility)
}
}

Expand Down