Skip to content

Commit 58307e7

Browse files
committed
more progress
1 parent f4e93b3 commit 58307e7

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

FirebaseAuth/Sources/Swift/Auth/Auth.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ extension Auth: AuthInterop {
16251625
// MARK: Internal methods
16261626

16271627
init(app: FirebaseApp,
1628-
keychainStorageProvider: AuthKeychainStorage = AuthKeychainStorageReal(),
1628+
keychainStorageProvider: AuthKeychainStorage = AuthKeychainStorageReal.shared,
16291629
backend: AuthBackend = .init(rpcIssuer: AuthBackendRPCIssuer()),
16301630
authDispatcher: AuthDispatcher = .init()) {
16311631
self.app = app

FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ class AuthComponent: NSObject, Library, ComponentLifecycleMaintainer {
7878
// This doesn't stop any request already issued, see b/27704535
7979

8080
if let keychainServiceName = Auth.deleteKeychainServiceNameForAppName(app.name) {
81-
let keychain = AuthKeychainServices(service: keychainServiceName)
81+
let keychain = AuthKeychainServices(
82+
service: keychainServiceName,
83+
storage: AuthKeychainStorageReal.shared
84+
)
8285
let userKey = "\(app.name)_firebase_user"
8386
try? keychain.removeData(forKey: userKey)
8487
}

FirebaseAuth/Sources/Swift/Storage/AuthKeychainServices.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ final class AuthKeychainServices: Sendable {
3131

3232
// MARK: - Internal methods for shared keychain operations
3333

34-
required init(service: String = "Unset service",
35-
storage: AuthKeychainStorage = AuthKeychainStorageReal()) {
34+
required init(service: String = "Unset service", storage: AuthKeychainStorage) {
3635
self.service = service
3736
keychainStorage = storage
3837
}
@@ -105,10 +104,6 @@ final class AuthKeychainServices: Sendable {
105104
/// This dictionary is to avoid unnecessary keychain operations against legacy items.
106105
private let legacyEntryDeletedForKey = FIRAllocatedUnfairLock<Set<String>>(initialState: [])
107106

108-
static func storage(identifier: String) -> Self {
109-
return Self(service: identifier)
110-
}
111-
112107
func data(forKey key: String) throws -> Data? {
113108
if let data = try getItemLegacy(query: genericPasswordQuery(key: key)) {
114109
return data

FirebaseAuth/Sources/Swift/Storage/AuthKeychainStorageReal.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
import Foundation
1616

1717
/// The utility class to update the real keychain
18-
1918
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
2019
final class AuthKeychainStorageReal: AuthKeychainStorage {
20+
static let shared: AuthKeychainStorageReal = .init()
21+
22+
private init() {}
23+
2124
func get(query: [String: Any], result: inout AnyObject?) -> OSStatus {
2225
return SecItemCopyMatching(query as CFDictionary, &result)
2326
}

FirebaseAuth/Tests/Unit/AuthKeychainServicesTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class AuthKeychainServicesTests: XCTestCase {
3636
#if (os(macOS) && !FIREBASE_AUTH_TESTING_USE_MACOS_KEYCHAIN) || SWIFT_PACKAGE
3737
let storage: AuthKeychainStorage = FakeAuthKeychainStorage()
3838
#else
39-
let storage: AuthKeychainStorage = AuthKeychainStorageReal()
39+
let storage: AuthKeychainStorage = AuthKeychainStorageReal.shared
4040
#endif // (os(macOS) && !FIREBASE_AUTH_TESTING_USE_MACOS_KEYCHAIN) || SWIFT_PACKAGE
4141

4242
override func setUp() {

FirebaseAuth/Tests/Unit/AuthTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AuthTests: RPCBaseTests {
4343
#if (os(macOS) && !FIREBASE_AUTH_TESTING_USE_MACOS_KEYCHAIN) || SWIFT_PACKAGE
4444
let keychainStorageProvider = FakeAuthKeychainStorage()
4545
#else
46-
let keychainStorageProvider = AuthKeychainStorageReal()
46+
let keychainStorageProvider = AuthKeychainStorageReal.shared
4747
#endif // (os(macOS) && !FIREBASE_AUTH_TESTING_USE_MACOS_KEYCHAIN) || SWIFT_PACKAGE
4848

4949
// Stub the implementation to save the token refresh task for later execution.

FirebaseAuth/Tests/Unit/UserTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class UserTests: RPCBaseTests {
4545
#if (os(macOS) && !FIREBASE_AUTH_TESTING_USE_MACOS_KEYCHAIN) || SWIFT_PACKAGE
4646
let keychainStorageProvider = FakeAuthKeychainStorage()
4747
#else
48-
let keychainStorageProvider = AuthKeychainStorageReal()
48+
let keychainStorageProvider = AuthKeychainStorageReal.shared
4949
#endif // (os(macOS) && !FIREBASE_AUTH_TESTING_USE_MACOS_KEYCHAIN) || SWIFT_PACKAGE
5050
auth = Auth(
5151
app: FirebaseApp.app(name: "test-UserTests")!,

0 commit comments

Comments
 (0)