Skip to content

Commit

Permalink
fix(auth): expose KeychainLocalStorage with default init params (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev authored Sep 2, 2024
1 parent f093294 commit c1095c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 2 additions & 6 deletions Sources/Auth/Storage/AuthLocalStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ public protocol AuthLocalStorage: Sendable {

extension AuthClient.Configuration {
#if !os(Linux) && !os(Windows)
public static let defaultLocalStorage: any AuthLocalStorage = KeychainLocalStorage(
service: "supabase.gotrue.swift",
accessGroup: nil
)
public static let defaultLocalStorage: any AuthLocalStorage = KeychainLocalStorage()
#elseif os(Windows)
public static let defaultLocalStorage: any AuthLocalStorage =
WinCredLocalStorage(service: "supabase.gotrue.swift")
public static let defaultLocalStorage: any AuthLocalStorage = WinCredLocalStorage()
#endif
}
3 changes: 2 additions & 1 deletion Sources/Auth/Storage/KeychainLocalStorage.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#if !os(Windows) && !os(Linux)
import Foundation

/// ``AuthLocalStorage`` implementation using Keychain. This is the default local storage used by the library.
public struct KeychainLocalStorage: AuthLocalStorage {
private let keychain: Keychain

public init(service: String, accessGroup: String?) {
public init(service: String = "supabase.gotrue.swift", accessGroup: String? = nil) {
keychain = Keychain(service: service, accessGroup: accessGroup)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Auth/Storage/WinCredLocalStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
private let credentialType: DWORD
private let credentialPersistence: DWORD

public init(service: String) {
public init(service: String = "supabase.gotrue.swift") {
self.service = service
credentialType = DWORD(CRED_TYPE_GENERIC)
credentialPersistence = DWORD(CRED_PERSIST_LOCAL_MACHINE)
Expand Down

0 comments on commit c1095c9

Please sign in to comment.