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
0 commit comments