Skip to content

Commit fcf2fda

Browse files
committed
[Auth] TOTP support for macOS
1 parent 4e62da1 commit fcf2fda

25 files changed

+132
-90
lines changed

FirebaseAuth/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 12.1.0
2+
- [added] Added TOTP support for macOS.
3+
14
# 12.0.0
25
- [removed] **Breaking Change**: Removed the following Dynamic Links related
36
APIs:

FirebaseAuth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Firebase Auth for iOS
1+
# Firebase Auth for iOS and macOS
22

33
Firebase Auth enables apps to easily support multiple authentication options
44
for their end users.

FirebaseAuth/Sources/ObjC/FIRMultiFactorConstants.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
#import <TargetConditionals.h>
18-
#if TARGET_OS_IOS
18+
#if TARGET_OS_IOS || TARGET_OS_OSX
1919

2020
#import <Foundation/Foundation.h>
2121

FirebaseAuth/Sources/Public/FirebaseAuth/FIRMultiFactor.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,27 +22,26 @@ NS_ASSUME_NONNULL_BEGIN
2222

2323
/** @typedef FIRMultiFactorSessionCallback
2424
@brief The callback that triggered when a developer calls `getSessionWithCompletion`.
25-
This type is available on iOS only.
25+
This type is available on iOS and macOS.
2626
@param session The multi factor session returned, if any.
2727
@param error The error which occurred, if any.
2828
*/
2929
typedef void (^FIRMultiFactorSessionCallback)(FIRMultiFactorSession *_Nullable session,
3030
NSError *_Nullable error)
31-
NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead.")
32-
API_UNAVAILABLE(macos, tvos, watchos);
31+
NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead.") API_UNAVAILABLE(tvos, watchos);
3332

3433
/**
3534
@brief The string identifier for using phone as a second factor.
36-
This constant is available on iOS only.
35+
This constant is available on iOS and macOS.
3736
*/
3837
extern NSString *const _Nonnull FIRPhoneMultiFactorID NS_SWIFT_NAME(PhoneMultiFactorID)
39-
API_UNAVAILABLE(macos, tvos, watchos);
38+
API_UNAVAILABLE(tvos, watchos);
4039

4140
/**
4241
@brief The string identifier for using TOTP as a second factor.
43-
This constant is available on iOS only.
42+
This constant is available on iOS and macOS.
4443
*/
4544
extern NSString *const _Nonnull FIRTOTPMultiFactorID NS_SWIFT_NAME(TOTPMultiFactorID)
46-
API_UNAVAILABLE(macos, tvos, watchos);
45+
API_UNAVAILABLE(tvos, watchos);
4746

4847
NS_ASSUME_NONNULL_END

FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ final class AuthBackend: AuthBackendProtocol {
9999
}
100100

101101
private static func generateMFAError(response: AuthRPCResponse, auth: Auth) -> Error? {
102-
#if !os(iOS)
102+
#if !os(iOS) || !os(macOS)
103103
return nil
104104
#else
105105
if let mfaResponse = response as? AuthMFAResponse,
@@ -124,7 +124,7 @@ final class AuthBackend: AuthBackendProtocol {
124124
} else {
125125
return nil
126126
}
127-
#endif // !os(iOS)
127+
#endif // !os(iOS) || !os(macOS)
128128
}
129129

130130
// Check whether or not the successful response is actually the special case phone

FirebaseAuth/Sources/Swift/MultiFactor/MultiFactor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
import Foundation
1616

17-
#if os(iOS)
17+
#if os(iOS) || os(macOS)
1818

1919
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
2020
extension MultiFactor: NSSecureCoding {}
2121

2222
/// The interface defining the multi factor related properties and operations pertaining to a
2323
/// user.
2424
///
25-
/// This class is available on iOS only.
25+
/// This class is available on iOS and macOS.
2626
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
2727
@objc(FIRMultiFactor) open class MultiFactor: NSObject {
2828
@objc open var enrolledFactors: [MultiFactorInfo]

FirebaseAuth/Sources/Swift/MultiFactor/MultiFactorAssertion.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
import Foundation
1616

17-
#if os(iOS)
17+
#if os(iOS) || os(macOS)
1818

1919
/// The base class for asserting ownership of a second factor. This is equivalent to the
2020
/// AuthCredential class.
2121
///
22-
/// This class is available on iOS only.
22+
/// This class is available on iOS and macOS.
2323
@objc(FIRMultiFactorAssertion) open class MultiFactorAssertion: NSObject {
2424
/// The second factor identifier for this opaque object asserting a second factor.
2525
@objc open var factorID: String

FirebaseAuth/Sources/Swift/MultiFactor/MultiFactorInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import Foundation
1616

1717
// TODO(Swift 6 Breaking): Make checked Sendable.
1818

19-
#if os(iOS)
19+
#if os(iOS) || os(macOS)
2020
extension MultiFactorInfo: NSSecureCoding {}
2121

2222
/// Safe public structure used to represent a second factor entity from a client perspective.
2323
///
24-
/// This class is available on iOS only.
24+
/// This class is available on iOS and macOS.
2525
@objc(FIRMultiFactorInfo) open class MultiFactorInfo: NSObject, @unchecked Sendable {
2626
/// The multi-factor enrollment ID.
2727
@objc(UID) public let uid: String

FirebaseAuth/Sources/Swift/MultiFactor/MultiFactorResolver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
import Foundation
1616

17-
#if os(iOS)
17+
#if os(iOS) || os(macOS)
1818

1919
/// The subclass of base class `MultiFactorAssertion`, used to assert ownership of a phone
2020
/// second factor.
2121
///
22-
/// This class is available on iOS only.
22+
/// This class is available on iOS and macOS.
2323
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
2424
@objc(FIRMultiFactorResolver)
2525
open class MultiFactorResolver: NSObject {

FirebaseAuth/Sources/Swift/MultiFactor/MultiFactorSession.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616

17-
#if os(iOS)
17+
#if os(iOS) || os(macOS)
1818

1919
/// Opaque object that identifies the current session to enroll a second factor or to
2020
/// complete sign in when previously enrolled.
@@ -23,7 +23,7 @@ import Foundation
2323
/// or to complete sign in when previously enrolled. It contains additional context on the
2424
/// existing user, notably the confirmation that the user passed the first factor challenge.
2525
///
26-
/// This class is available on iOS only.
26+
/// This class is available on iOS and macOS.
2727
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
2828
@objc(FIRMultiFactorSession) open class MultiFactorSession: NSObject {
2929
/// The ID token for an enroll flow. This has to be retrieved after recent authentication.

0 commit comments

Comments
 (0)