Skip to content

Commit 70d4fee

Browse files
[local_auth] Rename iOS classes (#6108)
When we renamed `local_auth_ios` to `local_auth_darwin` I forgot that we needed to rename all of the classes. Not doing so would make it a breaking change for us to switch endorsement, since anyone who depends directly on `local_auth_ios` (anyone setting custom strings, most commonly) would then have both copies. It's an immediate runtime failure on launch since it tries to register the same plugin class twice, but even if we fixed just that it would be picking an implementation of each class and random and we could have strange runtime behavior as they diverge over time. This renames the plugin class to use the newer `FLA` prefix, and renames all of the internal classes already using `FLA` to `FLAD` to make them distinct. (This is slightly ugly, but we're only stuck with it until we convert this plugin to Swift.)
1 parent 2424147 commit 70d4fee

File tree

11 files changed

+259
-253
lines changed

11 files changed

+259
-253
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.2.1
2+
3+
* Renames the Objective-C plugin classes to avoid runtime conflicts with
4+
`local_auth_ios` in apps that have transitive dependencies on both.
5+
16
## 1.2.0
27

38
* Renames the package previously published as [`local_auth_ios`](https://pub.dev/packages/local_auth_ios)

packages/local_auth/local_auth_darwin/darwin/Classes/FLTLocalAuthPlugin.h renamed to packages/local_auth/local_auth_darwin/darwin/Classes/FLALocalAuthPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
#import "messages.g.h"
88

9-
@interface FLTLocalAuthPlugin : NSObject <FlutterPlugin, FLALocalAuthApi>
9+
@interface FLALocalAuthPlugin : NSObject <FlutterPlugin, FLADLocalAuthApi>
1010
@end

packages/local_auth/local_auth_darwin/darwin/Classes/FLTLocalAuthPlugin.m renamed to packages/local_auth/local_auth_darwin/darwin/Classes/FLALocalAuthPlugin.m

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
#import "FLTLocalAuthPlugin.h"
5-
#import "FLTLocalAuthPlugin_Test.h"
4+
#import "FLALocalAuthPlugin.h"
5+
#import "FLALocalAuthPlugin_Test.h"
66

77
#import <LocalAuthentication/LocalAuthentication.h>
88

9-
typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError *_Nullable);
9+
typedef void (^FLADAuthCompletion)(FLADAuthResultDetails *_Nullable, FlutterError *_Nullable);
1010

1111
/**
1212
* A default context factory that wraps standard LAContext allocation.
1313
*/
14-
@interface FLADefaultAuthContextFactory : NSObject <FLAAuthContextFactory>
14+
@interface FLADefaultAuthContextFactory : NSObject <FLADAuthContextFactory>
1515
@end
1616

1717
@implementation FLADefaultAuthContextFactory
@@ -26,18 +26,18 @@ - (LAContext *)createAuthContext {
2626
* A data container for sticky auth state.
2727
*/
2828
@interface FLAStickyAuthState : NSObject
29-
@property(nonatomic, strong, nonnull) FLAAuthOptions *options;
30-
@property(nonatomic, strong, nonnull) FLAAuthStrings *strings;
31-
@property(nonatomic, copy, nonnull) FLAAuthCompletion resultHandler;
32-
- (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options
33-
strings:(nonnull FLAAuthStrings *)strings
34-
resultHandler:(nonnull FLAAuthCompletion)resultHandler;
29+
@property(nonatomic, strong, nonnull) FLADAuthOptions *options;
30+
@property(nonatomic, strong, nonnull) FLADAuthStrings *strings;
31+
@property(nonatomic, copy, nonnull) FLADAuthCompletion resultHandler;
32+
- (instancetype)initWithOptions:(nonnull FLADAuthOptions *)options
33+
strings:(nonnull FLADAuthStrings *)strings
34+
resultHandler:(nonnull FLADAuthCompletion)resultHandler;
3535
@end
3636

3737
@implementation FLAStickyAuthState
38-
- (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options
39-
strings:(nonnull FLAAuthStrings *)strings
40-
resultHandler:(nonnull FLAAuthCompletion)resultHandler {
38+
- (instancetype)initWithOptions:(nonnull FLADAuthOptions *)options
39+
strings:(nonnull FLADAuthStrings *)strings
40+
resultHandler:(nonnull FLADAuthCompletion)resultHandler {
4141
self = [super init];
4242
if (self) {
4343
_options = options;
@@ -50,36 +50,36 @@ - (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options
5050

5151
#pragma mark -
5252

53-
@interface FLTLocalAuthPlugin ()
53+
@interface FLALocalAuthPlugin ()
5454
@property(nonatomic, strong, nullable) FLAStickyAuthState *lastCallState;
55-
@property(nonatomic, strong) NSObject<FLAAuthContextFactory> *authContextFactory;
55+
@property(nonatomic, strong) NSObject<FLADAuthContextFactory> *authContextFactory;
5656
@end
5757

58-
@implementation FLTLocalAuthPlugin
58+
@implementation FLALocalAuthPlugin
5959

6060
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
61-
FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init];
61+
FLALocalAuthPlugin *instance = [[FLALocalAuthPlugin alloc] init];
6262
[registrar addApplicationDelegate:instance];
63-
SetUpFLALocalAuthApi([registrar messenger], instance);
63+
SetUpFLADLocalAuthApi([registrar messenger], instance);
6464
}
6565

6666
- (instancetype)init {
6767
return [self initWithContextFactory:[[FLADefaultAuthContextFactory alloc] init]];
6868
}
6969

70-
- (instancetype)initWithContextFactory:(NSObject<FLAAuthContextFactory> *)factory {
70+
- (instancetype)initWithContextFactory:(NSObject<FLADAuthContextFactory> *)factory {
7171
self = [super init];
7272
if (self) {
7373
_authContextFactory = factory;
7474
}
7575
return self;
7676
}
7777

78-
#pragma mark FLALocalAuthApi
78+
#pragma mark FLADLocalAuthApi
7979

80-
- (void)authenticateWithOptions:(nonnull FLAAuthOptions *)options
81-
strings:(nonnull FLAAuthStrings *)strings
82-
completion:(nonnull void (^)(FLAAuthResultDetails *_Nullable,
80+
- (void)authenticateWithOptions:(nonnull FLADAuthOptions *)options
81+
strings:(nonnull FLADAuthStrings *)strings
82+
completion:(nonnull void (^)(FLADAuthResultDetails *_Nullable,
8383
FlutterError *_Nullable))completion {
8484
LAContext *context = [self.authContextFactory createAuthContext];
8585
NSError *authError = nil;
@@ -126,18 +126,19 @@ - (nullable NSNumber *)deviceCanSupportBiometricsWithError:
126126
return @NO;
127127
}
128128

129-
- (nullable NSArray<FLAAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
129+
- (nullable NSArray<FLADAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
130130
(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
131131
LAContext *context = [self.authContextFactory createAuthContext];
132132
NSError *authError = nil;
133-
NSMutableArray<FLAAuthBiometricWrapper *> *biometrics = [[NSMutableArray alloc] init];
133+
NSMutableArray<FLADAuthBiometricWrapper *> *biometrics = [[NSMutableArray alloc] init];
134134
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
135135
error:&authError]) {
136136
if (authError == nil) {
137137
if (context.biometryType == LABiometryTypeFaceID) {
138-
[biometrics addObject:[FLAAuthBiometricWrapper makeWithValue:FLAAuthBiometricFace]];
138+
[biometrics addObject:[FLADAuthBiometricWrapper makeWithValue:FLADAuthBiometricFace]];
139139
} else if (context.biometryType == LABiometryTypeTouchID) {
140-
[biometrics addObject:[FLAAuthBiometricWrapper makeWithValue:FLAAuthBiometricFingerprint]];
140+
[biometrics
141+
addObject:[FLADAuthBiometricWrapper makeWithValue:FLADAuthBiometricFingerprint]];
141142
}
142143
}
143144
}
@@ -155,7 +156,7 @@ - (nullable NSNumber *)isDeviceSupportedWithError:
155156
- (void)showAlertWithMessage:(NSString *)message
156157
dismissButtonTitle:(NSString *)dismissButtonTitle
157158
openSettingsButtonTitle:(NSString *)openSettingsButtonTitle
158-
completion:(FLAAuthCompletion)completion {
159+
completion:(FLADAuthCompletion)completion {
159160
UIAlertController *alert =
160161
[UIAlertController alertControllerWithTitle:@""
161162
message:message
@@ -189,9 +190,9 @@ - (void)showAlertWithMessage:(NSString *)message
189190

190191
- (void)handleAuthReplyWithSuccess:(BOOL)success
191192
error:(NSError *)error
192-
options:(FLAAuthOptions *)options
193-
strings:(FLAAuthStrings *)strings
194-
completion:(nonnull FLAAuthCompletion)completion {
193+
options:(FLADAuthOptions *)options
194+
strings:(FLADAuthStrings *)strings
195+
completion:(nonnull FLADAuthCompletion)completion {
195196
NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread.");
196197
if (success) {
197198
[self handleSucceeded:YES withCompletion:completion];
@@ -219,19 +220,19 @@ - (void)handleAuthReplyWithSuccess:(BOOL)success
219220
}
220221
}
221222

222-
- (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull FLAAuthCompletion)completion {
223-
completion(
224-
[FLAAuthResultDetails makeWithResult:(succeeded ? FLAAuthResultSuccess : FLAAuthResultFailure)
225-
errorMessage:nil
226-
errorDetails:nil],
227-
nil);
223+
- (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull FLADAuthCompletion)completion {
224+
completion([FLADAuthResultDetails
225+
makeWithResult:(succeeded ? FLADAuthResultSuccess : FLADAuthResultFailure)
226+
errorMessage:nil
227+
errorDetails:nil],
228+
nil);
228229
}
229230

230231
- (void)handleError:(NSError *)authError
231-
withOptions:(FLAAuthOptions *)options
232-
strings:(FLAAuthStrings *)strings
233-
completion:(nonnull FLAAuthCompletion)completion {
234-
FLAAuthResult result = FLAAuthResultErrorNotAvailable;
232+
withOptions:(FLADAuthOptions *)options
233+
strings:(FLADAuthStrings *)strings
234+
completion:(nonnull FLADAuthCompletion)completion {
235+
FLADAuthResult result = FLADAuthResultErrorNotAvailable;
235236
switch (authError.code) {
236237
case LAErrorPasscodeNotSet:
237238
case LAErrorBiometryNotEnrolled:
@@ -242,8 +243,8 @@ - (void)handleError:(NSError *)authError
242243
completion:completion];
243244
return;
244245
}
245-
result = authError.code == LAErrorPasscodeNotSet ? FLAAuthResultErrorPasscodeNotSet
246-
: FLAAuthResultErrorNotEnrolled;
246+
result = authError.code == LAErrorPasscodeNotSet ? FLADAuthResultErrorPasscodeNotSet
247+
: FLADAuthResultErrorNotEnrolled;
247248
break;
248249
case LAErrorBiometryLockout:
249250
[self showAlertWithMessage:strings.lockOut
@@ -252,9 +253,9 @@ - (void)handleError:(NSError *)authError
252253
completion:completion];
253254
return;
254255
}
255-
completion([FLAAuthResultDetails makeWithResult:result
256-
errorMessage:authError.localizedDescription
257-
errorDetails:authError.domain],
256+
completion([FLADAuthResultDetails makeWithResult:result
257+
errorMessage:authError.localizedDescription
258+
errorDetails:authError.domain],
258259
nil);
259260
}
260261

packages/local_auth/local_auth_darwin/darwin/Classes/FLTLocalAuthPlugin_Test.h renamed to packages/local_auth/local_auth_darwin/darwin/Classes/FLALocalAuthPlugin_Test.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
/**
99
* Protocol for a source of LAContext instances. Used to allow context injection in unit tests.
1010
*/
11-
@protocol FLAAuthContextFactory <NSObject>
11+
@protocol FLADAuthContextFactory <NSObject>
1212
- (LAContext *)createAuthContext;
1313
@end
1414

15-
@interface FLTLocalAuthPlugin ()
15+
@interface FLALocalAuthPlugin ()
1616
/**
1717
* Returns an instance that uses the given factory to create LAContexts.
1818
*/
19-
- (instancetype)initWithContextFactory:(NSObject<FLAAuthContextFactory> *)factory
19+
- (instancetype)initWithContextFactory:(NSObject<FLADAuthContextFactory> *)factory
2020
NS_DESIGNATED_INITIALIZER;
2121
@end

packages/local_auth/local_auth_darwin/darwin/Classes/messages.g.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,46 @@
1414
NS_ASSUME_NONNULL_BEGIN
1515

1616
/// Possible outcomes of an authentication attempt.
17-
typedef NS_ENUM(NSUInteger, FLAAuthResult) {
17+
typedef NS_ENUM(NSUInteger, FLADAuthResult) {
1818
/// The user authenticated successfully.
19-
FLAAuthResultSuccess = 0,
19+
FLADAuthResultSuccess = 0,
2020
/// The user failed to successfully authenticate.
21-
FLAAuthResultFailure = 1,
21+
FLADAuthResultFailure = 1,
2222
/// The authentication system was not available.
23-
FLAAuthResultErrorNotAvailable = 2,
23+
FLADAuthResultErrorNotAvailable = 2,
2424
/// No biometrics are enrolled.
25-
FLAAuthResultErrorNotEnrolled = 3,
25+
FLADAuthResultErrorNotEnrolled = 3,
2626
/// No passcode is set.
27-
FLAAuthResultErrorPasscodeNotSet = 4,
27+
FLADAuthResultErrorPasscodeNotSet = 4,
2828
};
2929

30-
/// Wrapper for FLAAuthResult to allow for nullability.
31-
@interface FLAAuthResultBox : NSObject
32-
@property(nonatomic, assign) FLAAuthResult value;
33-
- (instancetype)initWithValue:(FLAAuthResult)value;
30+
/// Wrapper for FLADAuthResult to allow for nullability.
31+
@interface FLADAuthResultBox : NSObject
32+
@property(nonatomic, assign) FLADAuthResult value;
33+
- (instancetype)initWithValue:(FLADAuthResult)value;
3434
@end
3535

3636
/// Pigeon equivalent of the subset of BiometricType used by iOS.
37-
typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
38-
FLAAuthBiometricFace = 0,
39-
FLAAuthBiometricFingerprint = 1,
37+
typedef NS_ENUM(NSUInteger, FLADAuthBiometric) {
38+
FLADAuthBiometricFace = 0,
39+
FLADAuthBiometricFingerprint = 1,
4040
};
4141

42-
/// Wrapper for FLAAuthBiometric to allow for nullability.
43-
@interface FLAAuthBiometricBox : NSObject
44-
@property(nonatomic, assign) FLAAuthBiometric value;
45-
- (instancetype)initWithValue:(FLAAuthBiometric)value;
42+
/// Wrapper for FLADAuthBiometric to allow for nullability.
43+
@interface FLADAuthBiometricBox : NSObject
44+
@property(nonatomic, assign) FLADAuthBiometric value;
45+
- (instancetype)initWithValue:(FLADAuthBiometric)value;
4646
@end
4747

48-
@class FLAAuthStrings;
49-
@class FLAAuthOptions;
50-
@class FLAAuthResultDetails;
51-
@class FLAAuthBiometricWrapper;
48+
@class FLADAuthStrings;
49+
@class FLADAuthOptions;
50+
@class FLADAuthResultDetails;
51+
@class FLADAuthBiometricWrapper;
5252

5353
/// Pigeon version of IOSAuthMessages, plus the authorization reason.
5454
///
5555
/// See auth_messages_ios.dart for details.
56-
@interface FLAAuthStrings : NSObject
56+
@interface FLADAuthStrings : NSObject
5757
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
5858
- (instancetype)init NS_UNAVAILABLE;
5959
+ (instancetype)makeWithReason:(NSString *)reason
@@ -70,7 +70,7 @@ typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
7070
@property(nonatomic, copy, nullable) NSString *localizedFallbackTitle;
7171
@end
7272

73-
@interface FLAAuthOptions : NSObject
73+
@interface FLADAuthOptions : NSObject
7474
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
7575
- (instancetype)init NS_UNAVAILABLE;
7676
+ (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly
@@ -81,31 +81,31 @@ typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
8181
@property(nonatomic, assign) BOOL useErrorDialogs;
8282
@end
8383

84-
@interface FLAAuthResultDetails : NSObject
84+
@interface FLADAuthResultDetails : NSObject
8585
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
8686
- (instancetype)init NS_UNAVAILABLE;
87-
+ (instancetype)makeWithResult:(FLAAuthResult)result
87+
+ (instancetype)makeWithResult:(FLADAuthResult)result
8888
errorMessage:(nullable NSString *)errorMessage
8989
errorDetails:(nullable NSString *)errorDetails;
9090
/// The result of authenticating.
91-
@property(nonatomic, assign) FLAAuthResult result;
91+
@property(nonatomic, assign) FLADAuthResult result;
9292
/// A system-provided error message, if any.
9393
@property(nonatomic, copy, nullable) NSString *errorMessage;
9494
/// System-provided error details, if any.
9595
@property(nonatomic, copy, nullable) NSString *errorDetails;
9696
@end
9797

98-
@interface FLAAuthBiometricWrapper : NSObject
98+
@interface FLADAuthBiometricWrapper : NSObject
9999
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
100100
- (instancetype)init NS_UNAVAILABLE;
101-
+ (instancetype)makeWithValue:(FLAAuthBiometric)value;
102-
@property(nonatomic, assign) FLAAuthBiometric value;
101+
+ (instancetype)makeWithValue:(FLADAuthBiometric)value;
102+
@property(nonatomic, assign) FLADAuthBiometric value;
103103
@end
104104

105-
/// The codec used by FLALocalAuthApi.
106-
NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void);
105+
/// The codec used by FLADLocalAuthApi.
106+
NSObject<FlutterMessageCodec> *FLADLocalAuthApiGetCodec(void);
107107

108-
@protocol FLALocalAuthApi
108+
@protocol FLADLocalAuthApi
109109
/// Returns true if this device supports authentication.
110110
///
111111
/// @return `nil` only when `error != nil`.
@@ -119,17 +119,17 @@ NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void);
119119
/// without additional setup.
120120
///
121121
/// @return `nil` only when `error != nil`.
122-
- (nullable NSArray<FLAAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
122+
- (nullable NSArray<FLADAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
123123
(FlutterError *_Nullable *_Nonnull)error;
124124
/// Attempts to authenticate the user with the provided [options], and using
125125
/// [strings] for any UI.
126-
- (void)authenticateWithOptions:(FLAAuthOptions *)options
127-
strings:(FLAAuthStrings *)strings
128-
completion:(void (^)(FLAAuthResultDetails *_Nullable,
126+
- (void)authenticateWithOptions:(FLADAuthOptions *)options
127+
strings:(FLADAuthStrings *)strings
128+
completion:(void (^)(FLADAuthResultDetails *_Nullable,
129129
FlutterError *_Nullable))completion;
130130
@end
131131

132-
extern void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
133-
NSObject<FLALocalAuthApi> *_Nullable api);
132+
extern void SetUpFLADLocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
133+
NSObject<FLADLocalAuthApi> *_Nullable api);
134134

135135
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)