[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.)
This commit is contained in:
stuartmorgan
2024-02-12 15:46:18 -08:00
committed by GitHub
parent 2424147b0a
commit 70d4feeb1a
11 changed files with 259 additions and 253 deletions

View File

@ -1,3 +1,8 @@
## 1.2.1
* Renames the Objective-C plugin classes to avoid runtime conflicts with
`local_auth_ios` in apps that have transitive dependencies on both.
## 1.2.0 ## 1.2.0
* Renames the package previously published as [`local_auth_ios`](https://pub.dev/packages/local_auth_ios) * Renames the package previously published as [`local_auth_ios`](https://pub.dev/packages/local_auth_ios)

View File

@ -6,5 +6,5 @@
#import "messages.g.h" #import "messages.g.h"
@interface FLTLocalAuthPlugin : NSObject <FlutterPlugin, FLALocalAuthApi> @interface FLALocalAuthPlugin : NSObject <FlutterPlugin, FLADLocalAuthApi>
@end @end

View File

@ -1,17 +1,17 @@
// Copyright 2013 The Flutter Authors. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "FLTLocalAuthPlugin.h" #import "FLALocalAuthPlugin.h"
#import "FLTLocalAuthPlugin_Test.h" #import "FLALocalAuthPlugin_Test.h"
#import <LocalAuthentication/LocalAuthentication.h> #import <LocalAuthentication/LocalAuthentication.h>
typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError *_Nullable); typedef void (^FLADAuthCompletion)(FLADAuthResultDetails *_Nullable, FlutterError *_Nullable);
/** /**
* A default context factory that wraps standard LAContext allocation. * A default context factory that wraps standard LAContext allocation.
*/ */
@interface FLADefaultAuthContextFactory : NSObject <FLAAuthContextFactory> @interface FLADefaultAuthContextFactory : NSObject <FLADAuthContextFactory>
@end @end
@implementation FLADefaultAuthContextFactory @implementation FLADefaultAuthContextFactory
@ -26,18 +26,18 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
* A data container for sticky auth state. * A data container for sticky auth state.
*/ */
@interface FLAStickyAuthState : NSObject @interface FLAStickyAuthState : NSObject
@property(nonatomic, strong, nonnull) FLAAuthOptions *options; @property(nonatomic, strong, nonnull) FLADAuthOptions *options;
@property(nonatomic, strong, nonnull) FLAAuthStrings *strings; @property(nonatomic, strong, nonnull) FLADAuthStrings *strings;
@property(nonatomic, copy, nonnull) FLAAuthCompletion resultHandler; @property(nonatomic, copy, nonnull) FLADAuthCompletion resultHandler;
- (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options - (instancetype)initWithOptions:(nonnull FLADAuthOptions *)options
strings:(nonnull FLAAuthStrings *)strings strings:(nonnull FLADAuthStrings *)strings
resultHandler:(nonnull FLAAuthCompletion)resultHandler; resultHandler:(nonnull FLADAuthCompletion)resultHandler;
@end @end
@implementation FLAStickyAuthState @implementation FLAStickyAuthState
- (instancetype)initWithOptions:(nonnull FLAAuthOptions *)options - (instancetype)initWithOptions:(nonnull FLADAuthOptions *)options
strings:(nonnull FLAAuthStrings *)strings strings:(nonnull FLADAuthStrings *)strings
resultHandler:(nonnull FLAAuthCompletion)resultHandler { resultHandler:(nonnull FLADAuthCompletion)resultHandler {
self = [super init]; self = [super init];
if (self) { if (self) {
_options = options; _options = options;
@ -50,24 +50,24 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
#pragma mark - #pragma mark -
@interface FLTLocalAuthPlugin () @interface FLALocalAuthPlugin ()
@property(nonatomic, strong, nullable) FLAStickyAuthState *lastCallState; @property(nonatomic, strong, nullable) FLAStickyAuthState *lastCallState;
@property(nonatomic, strong) NSObject<FLAAuthContextFactory> *authContextFactory; @property(nonatomic, strong) NSObject<FLADAuthContextFactory> *authContextFactory;
@end @end
@implementation FLTLocalAuthPlugin @implementation FLALocalAuthPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar { + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init]; FLALocalAuthPlugin *instance = [[FLALocalAuthPlugin alloc] init];
[registrar addApplicationDelegate:instance]; [registrar addApplicationDelegate:instance];
SetUpFLALocalAuthApi([registrar messenger], instance); SetUpFLADLocalAuthApi([registrar messenger], instance);
} }
- (instancetype)init { - (instancetype)init {
return [self initWithContextFactory:[[FLADefaultAuthContextFactory alloc] init]]; return [self initWithContextFactory:[[FLADefaultAuthContextFactory alloc] init]];
} }
- (instancetype)initWithContextFactory:(NSObject<FLAAuthContextFactory> *)factory { - (instancetype)initWithContextFactory:(NSObject<FLADAuthContextFactory> *)factory {
self = [super init]; self = [super init];
if (self) { if (self) {
_authContextFactory = factory; _authContextFactory = factory;
@ -75,11 +75,11 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
return self; return self;
} }
#pragma mark FLALocalAuthApi #pragma mark FLADLocalAuthApi
- (void)authenticateWithOptions:(nonnull FLAAuthOptions *)options - (void)authenticateWithOptions:(nonnull FLADAuthOptions *)options
strings:(nonnull FLAAuthStrings *)strings strings:(nonnull FLADAuthStrings *)strings
completion:(nonnull void (^)(FLAAuthResultDetails *_Nullable, completion:(nonnull void (^)(FLADAuthResultDetails *_Nullable,
FlutterError *_Nullable))completion { FlutterError *_Nullable))completion {
LAContext *context = [self.authContextFactory createAuthContext]; LAContext *context = [self.authContextFactory createAuthContext];
NSError *authError = nil; NSError *authError = nil;
@ -126,18 +126,19 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
return @NO; return @NO;
} }
- (nullable NSArray<FLAAuthBiometricWrapper *> *)getEnrolledBiometricsWithError: - (nullable NSArray<FLADAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
(FlutterError *_Nullable __autoreleasing *_Nonnull)error { (FlutterError *_Nullable __autoreleasing *_Nonnull)error {
LAContext *context = [self.authContextFactory createAuthContext]; LAContext *context = [self.authContextFactory createAuthContext];
NSError *authError = nil; NSError *authError = nil;
NSMutableArray<FLAAuthBiometricWrapper *> *biometrics = [[NSMutableArray alloc] init]; NSMutableArray<FLADAuthBiometricWrapper *> *biometrics = [[NSMutableArray alloc] init];
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
error:&authError]) { error:&authError]) {
if (authError == nil) { if (authError == nil) {
if (context.biometryType == LABiometryTypeFaceID) { if (context.biometryType == LABiometryTypeFaceID) {
[biometrics addObject:[FLAAuthBiometricWrapper makeWithValue:FLAAuthBiometricFace]]; [biometrics addObject:[FLADAuthBiometricWrapper makeWithValue:FLADAuthBiometricFace]];
} else if (context.biometryType == LABiometryTypeTouchID) { } else if (context.biometryType == LABiometryTypeTouchID) {
[biometrics addObject:[FLAAuthBiometricWrapper makeWithValue:FLAAuthBiometricFingerprint]]; [biometrics
addObject:[FLADAuthBiometricWrapper makeWithValue:FLADAuthBiometricFingerprint]];
} }
} }
} }
@ -155,7 +156,7 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
- (void)showAlertWithMessage:(NSString *)message - (void)showAlertWithMessage:(NSString *)message
dismissButtonTitle:(NSString *)dismissButtonTitle dismissButtonTitle:(NSString *)dismissButtonTitle
openSettingsButtonTitle:(NSString *)openSettingsButtonTitle openSettingsButtonTitle:(NSString *)openSettingsButtonTitle
completion:(FLAAuthCompletion)completion { completion:(FLADAuthCompletion)completion {
UIAlertController *alert = UIAlertController *alert =
[UIAlertController alertControllerWithTitle:@"" [UIAlertController alertControllerWithTitle:@""
message:message message:message
@ -189,9 +190,9 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
- (void)handleAuthReplyWithSuccess:(BOOL)success - (void)handleAuthReplyWithSuccess:(BOOL)success
error:(NSError *)error error:(NSError *)error
options:(FLAAuthOptions *)options options:(FLADAuthOptions *)options
strings:(FLAAuthStrings *)strings strings:(FLADAuthStrings *)strings
completion:(nonnull FLAAuthCompletion)completion { completion:(nonnull FLADAuthCompletion)completion {
NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread."); NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread.");
if (success) { if (success) {
[self handleSucceeded:YES withCompletion:completion]; [self handleSucceeded:YES withCompletion:completion];
@ -219,19 +220,19 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
} }
} }
- (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull FLAAuthCompletion)completion { - (void)handleSucceeded:(BOOL)succeeded withCompletion:(nonnull FLADAuthCompletion)completion {
completion( completion([FLADAuthResultDetails
[FLAAuthResultDetails makeWithResult:(succeeded ? FLAAuthResultSuccess : FLAAuthResultFailure) makeWithResult:(succeeded ? FLADAuthResultSuccess : FLADAuthResultFailure)
errorMessage:nil errorMessage:nil
errorDetails:nil], errorDetails:nil],
nil); nil);
} }
- (void)handleError:(NSError *)authError - (void)handleError:(NSError *)authError
withOptions:(FLAAuthOptions *)options withOptions:(FLADAuthOptions *)options
strings:(FLAAuthStrings *)strings strings:(FLADAuthStrings *)strings
completion:(nonnull FLAAuthCompletion)completion { completion:(nonnull FLADAuthCompletion)completion {
FLAAuthResult result = FLAAuthResultErrorNotAvailable; FLADAuthResult result = FLADAuthResultErrorNotAvailable;
switch (authError.code) { switch (authError.code) {
case LAErrorPasscodeNotSet: case LAErrorPasscodeNotSet:
case LAErrorBiometryNotEnrolled: case LAErrorBiometryNotEnrolled:
@ -242,8 +243,8 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
completion:completion]; completion:completion];
return; return;
} }
result = authError.code == LAErrorPasscodeNotSet ? FLAAuthResultErrorPasscodeNotSet result = authError.code == LAErrorPasscodeNotSet ? FLADAuthResultErrorPasscodeNotSet
: FLAAuthResultErrorNotEnrolled; : FLADAuthResultErrorNotEnrolled;
break; break;
case LAErrorBiometryLockout: case LAErrorBiometryLockout:
[self showAlertWithMessage:strings.lockOut [self showAlertWithMessage:strings.lockOut
@ -252,9 +253,9 @@ typedef void (^FLAAuthCompletion)(FLAAuthResultDetails *_Nullable, FlutterError
completion:completion]; completion:completion];
return; return;
} }
completion([FLAAuthResultDetails makeWithResult:result completion([FLADAuthResultDetails makeWithResult:result
errorMessage:authError.localizedDescription errorMessage:authError.localizedDescription
errorDetails:authError.domain], errorDetails:authError.domain],
nil); nil);
} }

View File

@ -8,14 +8,14 @@
/** /**
* Protocol for a source of LAContext instances. Used to allow context injection in unit tests. * Protocol for a source of LAContext instances. Used to allow context injection in unit tests.
*/ */
@protocol FLAAuthContextFactory <NSObject> @protocol FLADAuthContextFactory <NSObject>
- (LAContext *)createAuthContext; - (LAContext *)createAuthContext;
@end @end
@interface FLTLocalAuthPlugin () @interface FLALocalAuthPlugin ()
/** /**
* Returns an instance that uses the given factory to create LAContexts. * Returns an instance that uses the given factory to create LAContexts.
*/ */
- (instancetype)initWithContextFactory:(NSObject<FLAAuthContextFactory> *)factory - (instancetype)initWithContextFactory:(NSObject<FLADAuthContextFactory> *)factory
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
@end @end

View File

@ -14,46 +14,46 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// Possible outcomes of an authentication attempt. /// Possible outcomes of an authentication attempt.
typedef NS_ENUM(NSUInteger, FLAAuthResult) { typedef NS_ENUM(NSUInteger, FLADAuthResult) {
/// The user authenticated successfully. /// The user authenticated successfully.
FLAAuthResultSuccess = 0, FLADAuthResultSuccess = 0,
/// The user failed to successfully authenticate. /// The user failed to successfully authenticate.
FLAAuthResultFailure = 1, FLADAuthResultFailure = 1,
/// The authentication system was not available. /// The authentication system was not available.
FLAAuthResultErrorNotAvailable = 2, FLADAuthResultErrorNotAvailable = 2,
/// No biometrics are enrolled. /// No biometrics are enrolled.
FLAAuthResultErrorNotEnrolled = 3, FLADAuthResultErrorNotEnrolled = 3,
/// No passcode is set. /// No passcode is set.
FLAAuthResultErrorPasscodeNotSet = 4, FLADAuthResultErrorPasscodeNotSet = 4,
}; };
/// Wrapper for FLAAuthResult to allow for nullability. /// Wrapper for FLADAuthResult to allow for nullability.
@interface FLAAuthResultBox : NSObject @interface FLADAuthResultBox : NSObject
@property(nonatomic, assign) FLAAuthResult value; @property(nonatomic, assign) FLADAuthResult value;
- (instancetype)initWithValue:(FLAAuthResult)value; - (instancetype)initWithValue:(FLADAuthResult)value;
@end @end
/// Pigeon equivalent of the subset of BiometricType used by iOS. /// Pigeon equivalent of the subset of BiometricType used by iOS.
typedef NS_ENUM(NSUInteger, FLAAuthBiometric) { typedef NS_ENUM(NSUInteger, FLADAuthBiometric) {
FLAAuthBiometricFace = 0, FLADAuthBiometricFace = 0,
FLAAuthBiometricFingerprint = 1, FLADAuthBiometricFingerprint = 1,
}; };
/// Wrapper for FLAAuthBiometric to allow for nullability. /// Wrapper for FLADAuthBiometric to allow for nullability.
@interface FLAAuthBiometricBox : NSObject @interface FLADAuthBiometricBox : NSObject
@property(nonatomic, assign) FLAAuthBiometric value; @property(nonatomic, assign) FLADAuthBiometric value;
- (instancetype)initWithValue:(FLAAuthBiometric)value; - (instancetype)initWithValue:(FLADAuthBiometric)value;
@end @end
@class FLAAuthStrings; @class FLADAuthStrings;
@class FLAAuthOptions; @class FLADAuthOptions;
@class FLAAuthResultDetails; @class FLADAuthResultDetails;
@class FLAAuthBiometricWrapper; @class FLADAuthBiometricWrapper;
/// Pigeon version of IOSAuthMessages, plus the authorization reason. /// Pigeon version of IOSAuthMessages, plus the authorization reason.
/// ///
/// See auth_messages_ios.dart for details. /// See auth_messages_ios.dart for details.
@interface FLAAuthStrings : NSObject @interface FLADAuthStrings : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method. /// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithReason:(NSString *)reason + (instancetype)makeWithReason:(NSString *)reason
@ -70,7 +70,7 @@ typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
@property(nonatomic, copy, nullable) NSString *localizedFallbackTitle; @property(nonatomic, copy, nullable) NSString *localizedFallbackTitle;
@end @end
@interface FLAAuthOptions : NSObject @interface FLADAuthOptions : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method. /// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly + (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly
@ -81,31 +81,31 @@ typedef NS_ENUM(NSUInteger, FLAAuthBiometric) {
@property(nonatomic, assign) BOOL useErrorDialogs; @property(nonatomic, assign) BOOL useErrorDialogs;
@end @end
@interface FLAAuthResultDetails : NSObject @interface FLADAuthResultDetails : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method. /// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithResult:(FLAAuthResult)result + (instancetype)makeWithResult:(FLADAuthResult)result
errorMessage:(nullable NSString *)errorMessage errorMessage:(nullable NSString *)errorMessage
errorDetails:(nullable NSString *)errorDetails; errorDetails:(nullable NSString *)errorDetails;
/// The result of authenticating. /// The result of authenticating.
@property(nonatomic, assign) FLAAuthResult result; @property(nonatomic, assign) FLADAuthResult result;
/// A system-provided error message, if any. /// A system-provided error message, if any.
@property(nonatomic, copy, nullable) NSString *errorMessage; @property(nonatomic, copy, nullable) NSString *errorMessage;
/// System-provided error details, if any. /// System-provided error details, if any.
@property(nonatomic, copy, nullable) NSString *errorDetails; @property(nonatomic, copy, nullable) NSString *errorDetails;
@end @end
@interface FLAAuthBiometricWrapper : NSObject @interface FLADAuthBiometricWrapper : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method. /// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithValue:(FLAAuthBiometric)value; + (instancetype)makeWithValue:(FLADAuthBiometric)value;
@property(nonatomic, assign) FLAAuthBiometric value; @property(nonatomic, assign) FLADAuthBiometric value;
@end @end
/// The codec used by FLALocalAuthApi. /// The codec used by FLADLocalAuthApi.
NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void); NSObject<FlutterMessageCodec> *FLADLocalAuthApiGetCodec(void);
@protocol FLALocalAuthApi @protocol FLADLocalAuthApi
/// Returns true if this device supports authentication. /// Returns true if this device supports authentication.
/// ///
/// @return `nil` only when `error != nil`. /// @return `nil` only when `error != nil`.
@ -119,17 +119,17 @@ NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void);
/// without additional setup. /// without additional setup.
/// ///
/// @return `nil` only when `error != nil`. /// @return `nil` only when `error != nil`.
- (nullable NSArray<FLAAuthBiometricWrapper *> *)getEnrolledBiometricsWithError: - (nullable NSArray<FLADAuthBiometricWrapper *> *)getEnrolledBiometricsWithError:
(FlutterError *_Nullable *_Nonnull)error; (FlutterError *_Nullable *_Nonnull)error;
/// Attempts to authenticate the user with the provided [options], and using /// Attempts to authenticate the user with the provided [options], and using
/// [strings] for any UI. /// [strings] for any UI.
- (void)authenticateWithOptions:(FLAAuthOptions *)options - (void)authenticateWithOptions:(FLADAuthOptions *)options
strings:(FLAAuthStrings *)strings strings:(FLADAuthStrings *)strings
completion:(void (^)(FLAAuthResultDetails *_Nullable, completion:(void (^)(FLADAuthResultDetails *_Nullable,
FlutterError *_Nullable))completion; FlutterError *_Nullable))completion;
@end @end
extern void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger, extern void SetUpFLADLocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLALocalAuthApi> *_Nullable api); NSObject<FLADLocalAuthApi> *_Nullable api);
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -31,8 +31,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
/// Possible outcomes of an authentication attempt. /// Possible outcomes of an authentication attempt.
@implementation FLAAuthResultBox @implementation FLADAuthResultBox
- (instancetype)initWithValue:(FLAAuthResult)value { - (instancetype)initWithValue:(FLADAuthResult)value {
self = [super init]; self = [super init];
if (self) { if (self) {
_value = value; _value = value;
@ -42,8 +42,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
@end @end
/// Pigeon equivalent of the subset of BiometricType used by iOS. /// Pigeon equivalent of the subset of BiometricType used by iOS.
@implementation FLAAuthBiometricBox @implementation FLADAuthBiometricBox
- (instancetype)initWithValue:(FLAAuthBiometric)value { - (instancetype)initWithValue:(FLADAuthBiometric)value {
self = [super init]; self = [super init];
if (self) { if (self) {
_value = value; _value = value;
@ -52,38 +52,38 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
@end @end
@interface FLAAuthStrings () @interface FLADAuthStrings ()
+ (FLAAuthStrings *)fromList:(NSArray *)list; + (FLADAuthStrings *)fromList:(NSArray *)list;
+ (nullable FLAAuthStrings *)nullableFromList:(NSArray *)list; + (nullable FLADAuthStrings *)nullableFromList:(NSArray *)list;
- (NSArray *)toList; - (NSArray *)toList;
@end @end
@interface FLAAuthOptions () @interface FLADAuthOptions ()
+ (FLAAuthOptions *)fromList:(NSArray *)list; + (FLADAuthOptions *)fromList:(NSArray *)list;
+ (nullable FLAAuthOptions *)nullableFromList:(NSArray *)list; + (nullable FLADAuthOptions *)nullableFromList:(NSArray *)list;
- (NSArray *)toList; - (NSArray *)toList;
@end @end
@interface FLAAuthResultDetails () @interface FLADAuthResultDetails ()
+ (FLAAuthResultDetails *)fromList:(NSArray *)list; + (FLADAuthResultDetails *)fromList:(NSArray *)list;
+ (nullable FLAAuthResultDetails *)nullableFromList:(NSArray *)list; + (nullable FLADAuthResultDetails *)nullableFromList:(NSArray *)list;
- (NSArray *)toList; - (NSArray *)toList;
@end @end
@interface FLAAuthBiometricWrapper () @interface FLADAuthBiometricWrapper ()
+ (FLAAuthBiometricWrapper *)fromList:(NSArray *)list; + (FLADAuthBiometricWrapper *)fromList:(NSArray *)list;
+ (nullable FLAAuthBiometricWrapper *)nullableFromList:(NSArray *)list; + (nullable FLADAuthBiometricWrapper *)nullableFromList:(NSArray *)list;
- (NSArray *)toList; - (NSArray *)toList;
@end @end
@implementation FLAAuthStrings @implementation FLADAuthStrings
+ (instancetype)makeWithReason:(NSString *)reason + (instancetype)makeWithReason:(NSString *)reason
lockOut:(NSString *)lockOut lockOut:(NSString *)lockOut
goToSettingsButton:(NSString *)goToSettingsButton goToSettingsButton:(NSString *)goToSettingsButton
goToSettingsDescription:(NSString *)goToSettingsDescription goToSettingsDescription:(NSString *)goToSettingsDescription
cancelButton:(NSString *)cancelButton cancelButton:(NSString *)cancelButton
localizedFallbackTitle:(nullable NSString *)localizedFallbackTitle { localizedFallbackTitle:(nullable NSString *)localizedFallbackTitle {
FLAAuthStrings *pigeonResult = [[FLAAuthStrings alloc] init]; FLADAuthStrings *pigeonResult = [[FLADAuthStrings alloc] init];
pigeonResult.reason = reason; pigeonResult.reason = reason;
pigeonResult.lockOut = lockOut; pigeonResult.lockOut = lockOut;
pigeonResult.goToSettingsButton = goToSettingsButton; pigeonResult.goToSettingsButton = goToSettingsButton;
@ -92,8 +92,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
pigeonResult.localizedFallbackTitle = localizedFallbackTitle; pigeonResult.localizedFallbackTitle = localizedFallbackTitle;
return pigeonResult; return pigeonResult;
} }
+ (FLAAuthStrings *)fromList:(NSArray *)list { + (FLADAuthStrings *)fromList:(NSArray *)list {
FLAAuthStrings *pigeonResult = [[FLAAuthStrings alloc] init]; FLADAuthStrings *pigeonResult = [[FLADAuthStrings alloc] init];
pigeonResult.reason = GetNullableObjectAtIndex(list, 0); pigeonResult.reason = GetNullableObjectAtIndex(list, 0);
pigeonResult.lockOut = GetNullableObjectAtIndex(list, 1); pigeonResult.lockOut = GetNullableObjectAtIndex(list, 1);
pigeonResult.goToSettingsButton = GetNullableObjectAtIndex(list, 2); pigeonResult.goToSettingsButton = GetNullableObjectAtIndex(list, 2);
@ -102,8 +102,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
pigeonResult.localizedFallbackTitle = GetNullableObjectAtIndex(list, 5); pigeonResult.localizedFallbackTitle = GetNullableObjectAtIndex(list, 5);
return pigeonResult; return pigeonResult;
} }
+ (nullable FLAAuthStrings *)nullableFromList:(NSArray *)list { + (nullable FLADAuthStrings *)nullableFromList:(NSArray *)list {
return (list) ? [FLAAuthStrings fromList:list] : nil; return (list) ? [FLADAuthStrings fromList:list] : nil;
} }
- (NSArray *)toList { - (NSArray *)toList {
return @[ return @[
@ -117,25 +117,25 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
@end @end
@implementation FLAAuthOptions @implementation FLADAuthOptions
+ (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly + (instancetype)makeWithBiometricOnly:(BOOL)biometricOnly
sticky:(BOOL)sticky sticky:(BOOL)sticky
useErrorDialogs:(BOOL)useErrorDialogs { useErrorDialogs:(BOOL)useErrorDialogs {
FLAAuthOptions *pigeonResult = [[FLAAuthOptions alloc] init]; FLADAuthOptions *pigeonResult = [[FLADAuthOptions alloc] init];
pigeonResult.biometricOnly = biometricOnly; pigeonResult.biometricOnly = biometricOnly;
pigeonResult.sticky = sticky; pigeonResult.sticky = sticky;
pigeonResult.useErrorDialogs = useErrorDialogs; pigeonResult.useErrorDialogs = useErrorDialogs;
return pigeonResult; return pigeonResult;
} }
+ (FLAAuthOptions *)fromList:(NSArray *)list { + (FLADAuthOptions *)fromList:(NSArray *)list {
FLAAuthOptions *pigeonResult = [[FLAAuthOptions alloc] init]; FLADAuthOptions *pigeonResult = [[FLADAuthOptions alloc] init];
pigeonResult.biometricOnly = [GetNullableObjectAtIndex(list, 0) boolValue]; pigeonResult.biometricOnly = [GetNullableObjectAtIndex(list, 0) boolValue];
pigeonResult.sticky = [GetNullableObjectAtIndex(list, 1) boolValue]; pigeonResult.sticky = [GetNullableObjectAtIndex(list, 1) boolValue];
pigeonResult.useErrorDialogs = [GetNullableObjectAtIndex(list, 2) boolValue]; pigeonResult.useErrorDialogs = [GetNullableObjectAtIndex(list, 2) boolValue];
return pigeonResult; return pigeonResult;
} }
+ (nullable FLAAuthOptions *)nullableFromList:(NSArray *)list { + (nullable FLADAuthOptions *)nullableFromList:(NSArray *)list {
return (list) ? [FLAAuthOptions fromList:list] : nil; return (list) ? [FLADAuthOptions fromList:list] : nil;
} }
- (NSArray *)toList { - (NSArray *)toList {
return @[ return @[
@ -146,25 +146,25 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
@end @end
@implementation FLAAuthResultDetails @implementation FLADAuthResultDetails
+ (instancetype)makeWithResult:(FLAAuthResult)result + (instancetype)makeWithResult:(FLADAuthResult)result
errorMessage:(nullable NSString *)errorMessage errorMessage:(nullable NSString *)errorMessage
errorDetails:(nullable NSString *)errorDetails { errorDetails:(nullable NSString *)errorDetails {
FLAAuthResultDetails *pigeonResult = [[FLAAuthResultDetails alloc] init]; FLADAuthResultDetails *pigeonResult = [[FLADAuthResultDetails alloc] init];
pigeonResult.result = result; pigeonResult.result = result;
pigeonResult.errorMessage = errorMessage; pigeonResult.errorMessage = errorMessage;
pigeonResult.errorDetails = errorDetails; pigeonResult.errorDetails = errorDetails;
return pigeonResult; return pigeonResult;
} }
+ (FLAAuthResultDetails *)fromList:(NSArray *)list { + (FLADAuthResultDetails *)fromList:(NSArray *)list {
FLAAuthResultDetails *pigeonResult = [[FLAAuthResultDetails alloc] init]; FLADAuthResultDetails *pigeonResult = [[FLADAuthResultDetails alloc] init];
pigeonResult.result = [GetNullableObjectAtIndex(list, 0) integerValue]; pigeonResult.result = [GetNullableObjectAtIndex(list, 0) integerValue];
pigeonResult.errorMessage = GetNullableObjectAtIndex(list, 1); pigeonResult.errorMessage = GetNullableObjectAtIndex(list, 1);
pigeonResult.errorDetails = GetNullableObjectAtIndex(list, 2); pigeonResult.errorDetails = GetNullableObjectAtIndex(list, 2);
return pigeonResult; return pigeonResult;
} }
+ (nullable FLAAuthResultDetails *)nullableFromList:(NSArray *)list { + (nullable FLADAuthResultDetails *)nullableFromList:(NSArray *)list {
return (list) ? [FLAAuthResultDetails fromList:list] : nil; return (list) ? [FLADAuthResultDetails fromList:list] : nil;
} }
- (NSArray *)toList { - (NSArray *)toList {
return @[ return @[
@ -175,19 +175,19 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
@end @end
@implementation FLAAuthBiometricWrapper @implementation FLADAuthBiometricWrapper
+ (instancetype)makeWithValue:(FLAAuthBiometric)value { + (instancetype)makeWithValue:(FLADAuthBiometric)value {
FLAAuthBiometricWrapper *pigeonResult = [[FLAAuthBiometricWrapper alloc] init]; FLADAuthBiometricWrapper *pigeonResult = [[FLADAuthBiometricWrapper alloc] init];
pigeonResult.value = value; pigeonResult.value = value;
return pigeonResult; return pigeonResult;
} }
+ (FLAAuthBiometricWrapper *)fromList:(NSArray *)list { + (FLADAuthBiometricWrapper *)fromList:(NSArray *)list {
FLAAuthBiometricWrapper *pigeonResult = [[FLAAuthBiometricWrapper alloc] init]; FLADAuthBiometricWrapper *pigeonResult = [[FLADAuthBiometricWrapper alloc] init];
pigeonResult.value = [GetNullableObjectAtIndex(list, 0) integerValue]; pigeonResult.value = [GetNullableObjectAtIndex(list, 0) integerValue];
return pigeonResult; return pigeonResult;
} }
+ (nullable FLAAuthBiometricWrapper *)nullableFromList:(NSArray *)list { + (nullable FLADAuthBiometricWrapper *)nullableFromList:(NSArray *)list {
return (list) ? [FLAAuthBiometricWrapper fromList:list] : nil; return (list) ? [FLADAuthBiometricWrapper fromList:list] : nil;
} }
- (NSArray *)toList { - (NSArray *)toList {
return @[ return @[
@ -196,39 +196,39 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
@end @end
@interface FLALocalAuthApiCodecReader : FlutterStandardReader @interface FLADLocalAuthApiCodecReader : FlutterStandardReader
@end @end
@implementation FLALocalAuthApiCodecReader @implementation FLADLocalAuthApiCodecReader
- (nullable id)readValueOfType:(UInt8)type { - (nullable id)readValueOfType:(UInt8)type {
switch (type) { switch (type) {
case 128: case 128:
return [FLAAuthBiometricWrapper fromList:[self readValue]]; return [FLADAuthBiometricWrapper fromList:[self readValue]];
case 129: case 129:
return [FLAAuthOptions fromList:[self readValue]]; return [FLADAuthOptions fromList:[self readValue]];
case 130: case 130:
return [FLAAuthResultDetails fromList:[self readValue]]; return [FLADAuthResultDetails fromList:[self readValue]];
case 131: case 131:
return [FLAAuthStrings fromList:[self readValue]]; return [FLADAuthStrings fromList:[self readValue]];
default: default:
return [super readValueOfType:type]; return [super readValueOfType:type];
} }
} }
@end @end
@interface FLALocalAuthApiCodecWriter : FlutterStandardWriter @interface FLADLocalAuthApiCodecWriter : FlutterStandardWriter
@end @end
@implementation FLALocalAuthApiCodecWriter @implementation FLADLocalAuthApiCodecWriter
- (void)writeValue:(id)value { - (void)writeValue:(id)value {
if ([value isKindOfClass:[FLAAuthBiometricWrapper class]]) { if ([value isKindOfClass:[FLADAuthBiometricWrapper class]]) {
[self writeByte:128]; [self writeByte:128];
[self writeValue:[value toList]]; [self writeValue:[value toList]];
} else if ([value isKindOfClass:[FLAAuthOptions class]]) { } else if ([value isKindOfClass:[FLADAuthOptions class]]) {
[self writeByte:129]; [self writeByte:129];
[self writeValue:[value toList]]; [self writeValue:[value toList]];
} else if ([value isKindOfClass:[FLAAuthResultDetails class]]) { } else if ([value isKindOfClass:[FLADAuthResultDetails class]]) {
[self writeByte:130]; [self writeByte:130];
[self writeValue:[value toList]]; [self writeValue:[value toList]];
} else if ([value isKindOfClass:[FLAAuthStrings class]]) { } else if ([value isKindOfClass:[FLADAuthStrings class]]) {
[self writeByte:131]; [self writeByte:131];
[self writeValue:[value toList]]; [self writeValue:[value toList]];
} else { } else {
@ -237,40 +237,40 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
} }
@end @end
@interface FLALocalAuthApiCodecReaderWriter : FlutterStandardReaderWriter @interface FLADLocalAuthApiCodecReaderWriter : FlutterStandardReaderWriter
@end @end
@implementation FLALocalAuthApiCodecReaderWriter @implementation FLADLocalAuthApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[FLALocalAuthApiCodecWriter alloc] initWithData:data]; return [[FLADLocalAuthApiCodecWriter alloc] initWithData:data];
} }
- (FlutterStandardReader *)readerWithData:(NSData *)data { - (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[FLALocalAuthApiCodecReader alloc] initWithData:data]; return [[FLADLocalAuthApiCodecReader alloc] initWithData:data];
} }
@end @end
NSObject<FlutterMessageCodec> *FLALocalAuthApiGetCodec(void) { NSObject<FlutterMessageCodec> *FLADLocalAuthApiGetCodec(void) {
static FlutterStandardMessageCodec *sSharedObject = nil; static FlutterStandardMessageCodec *sSharedObject = nil;
static dispatch_once_t sPred = 0; static dispatch_once_t sPred = 0;
dispatch_once(&sPred, ^{ dispatch_once(&sPred, ^{
FLALocalAuthApiCodecReaderWriter *readerWriter = FLADLocalAuthApiCodecReaderWriter *readerWriter =
[[FLALocalAuthApiCodecReaderWriter alloc] init]; [[FLADLocalAuthApiCodecReaderWriter alloc] init];
sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
}); });
return sSharedObject; return sSharedObject;
} }
void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger, void SetUpFLADLocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLALocalAuthApi> *api) { NSObject<FLADLocalAuthApi> *api) {
/// Returns true if this device supports authentication. /// Returns true if this device supports authentication.
{ {
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.isDeviceSupported" initWithName:@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.isDeviceSupported"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLALocalAuthApiGetCodec()]; codec:FLADLocalAuthApiGetCodec()];
if (api) { if (api) {
NSCAssert( NSCAssert(
[api respondsToSelector:@selector(isDeviceSupportedWithError:)], [api respondsToSelector:@selector(isDeviceSupportedWithError:)],
@"FLALocalAuthApi api (%@) doesn't respond to @selector(isDeviceSupportedWithError:)", @"FLADLocalAuthApi api (%@) doesn't respond to @selector(isDeviceSupportedWithError:)",
api); api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
FlutterError *error; FlutterError *error;
@ -288,10 +288,10 @@ void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
initWithName: initWithName:
@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.deviceCanSupportBiometrics" @"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.deviceCanSupportBiometrics"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLALocalAuthApiGetCodec()]; codec:FLADLocalAuthApiGetCodec()];
if (api) { if (api) {
NSCAssert([api respondsToSelector:@selector(deviceCanSupportBiometricsWithError:)], NSCAssert([api respondsToSelector:@selector(deviceCanSupportBiometricsWithError:)],
@"FLALocalAuthApi api (%@) doesn't respond to " @"FLADLocalAuthApi api (%@) doesn't respond to "
@"@selector(deviceCanSupportBiometricsWithError:)", @"@selector(deviceCanSupportBiometricsWithError:)",
api); api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
@ -309,15 +309,15 @@ void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.getEnrolledBiometrics" initWithName:@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.getEnrolledBiometrics"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLALocalAuthApiGetCodec()]; codec:FLADLocalAuthApiGetCodec()];
if (api) { if (api) {
NSCAssert( NSCAssert([api respondsToSelector:@selector(getEnrolledBiometricsWithError:)],
[api respondsToSelector:@selector(getEnrolledBiometricsWithError:)], @"FLADLocalAuthApi api (%@) doesn't respond to "
@"FLALocalAuthApi api (%@) doesn't respond to @selector(getEnrolledBiometricsWithError:)", @"@selector(getEnrolledBiometricsWithError:)",
api); api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
FlutterError *error; FlutterError *error;
NSArray<FLAAuthBiometricWrapper *> *output = [api getEnrolledBiometricsWithError:&error]; NSArray<FLADAuthBiometricWrapper *> *output = [api getEnrolledBiometricsWithError:&error];
callback(wrapResult(output, error)); callback(wrapResult(output, error));
}]; }];
} else { } else {
@ -330,19 +330,19 @@ void SetUpFLALocalAuthApi(id<FlutterBinaryMessenger> binaryMessenger,
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.authenticate" initWithName:@"dev.flutter.pigeon.local_auth_darwin.LocalAuthApi.authenticate"
binaryMessenger:binaryMessenger binaryMessenger:binaryMessenger
codec:FLALocalAuthApiGetCodec()]; codec:FLADLocalAuthApiGetCodec()];
if (api) { if (api) {
NSCAssert([api respondsToSelector:@selector(authenticateWithOptions:strings:completion:)], NSCAssert([api respondsToSelector:@selector(authenticateWithOptions:strings:completion:)],
@"FLALocalAuthApi api (%@) doesn't respond to " @"FLADLocalAuthApi api (%@) doesn't respond to "
@"@selector(authenticateWithOptions:strings:completion:)", @"@selector(authenticateWithOptions:strings:completion:)",
api); api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message; NSArray *args = message;
FLAAuthOptions *arg_options = GetNullableObjectAtIndex(args, 0); FLADAuthOptions *arg_options = GetNullableObjectAtIndex(args, 0);
FLAAuthStrings *arg_strings = GetNullableObjectAtIndex(args, 1); FLADAuthStrings *arg_strings = GetNullableObjectAtIndex(args, 1);
[api authenticateWithOptions:arg_options [api authenticateWithOptions:arg_options
strings:arg_strings strings:arg_strings
completion:^(FLAAuthResultDetails *_Nullable output, completion:^(FLADAuthResultDetails *_Nullable output,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
callback(wrapResult(output, error)); callback(wrapResult(output, error));
}]; }];

View File

@ -14,7 +14,7 @@ static const NSTimeInterval kTimeout = 30.0;
/** /**
* A context factory that returns preset contexts. * A context factory that returns preset contexts.
*/ */
@interface StubAuthContextFactory : NSObject <FLAAuthContextFactory> @interface StubAuthContextFactory : NSObject <FLADAuthContextFactory>
@property(copy, nonatomic) NSMutableArray *contexts; @property(copy, nonatomic) NSMutableArray *contexts;
- (instancetype)initWithContexts:(NSArray *)contexts; - (instancetype)initWithContexts:(NSArray *)contexts;
@end @end
@ -40,10 +40,10 @@ static const NSTimeInterval kTimeout = 30.0;
#pragma mark - #pragma mark -
@interface FLTLocalAuthPluginTests : XCTestCase @interface FLALocalAuthPluginTests : XCTestCase
@end @end
@implementation FLTLocalAuthPluginTests @implementation FLALocalAuthPluginTests
- (void)setUp { - (void)setUp {
self.continueAfterFailure = NO; self.continueAfterFailure = NO;
@ -51,12 +51,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testSuccessfullAuthWithBiometrics { - (void)testSuccessfullAuthWithBiometrics {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
// evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not
@ -73,14 +73,14 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:YES [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:YES
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
XCTAssertTrue([NSThread isMainThread]); XCTAssertTrue([NSThread isMainThread]);
XCTAssertEqual(resultDetails.result, FLAAuthResultSuccess); XCTAssertEqual(resultDetails.result, FLADAuthResultSuccess);
XCTAssertNil(error); XCTAssertNil(error);
[expectation fulfill]; [expectation fulfill];
}]; }];
@ -89,12 +89,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testSuccessfullAuthWithoutBiometrics { - (void)testSuccessfullAuthWithoutBiometrics {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
// evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not
@ -111,14 +111,14 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:NO
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
XCTAssertTrue([NSThread isMainThread]); XCTAssertTrue([NSThread isMainThread]);
XCTAssertEqual(resultDetails.result, FLAAuthResultSuccess); XCTAssertEqual(resultDetails.result, FLADAuthResultSuccess);
XCTAssertNil(error); XCTAssertNil(error);
[expectation fulfill]; [expectation fulfill];
}]; }];
@ -127,12 +127,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testFailedAuthWithBiometrics { - (void)testFailedAuthWithBiometrics {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
// evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not
@ -149,18 +149,18 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:YES [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:YES
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
XCTAssertTrue([NSThread isMainThread]); XCTAssertTrue([NSThread isMainThread]);
// TODO(stuartmorgan): Fix this; this was the pre-Pigeon-migration // TODO(stuartmorgan): Fix this; this was the pre-Pigeon-migration
// behavior, so is preserved as part of the migration, but a failed // behavior, so is preserved as part of the migration, but a failed
// authentication should return failure, not an error that results in a // authentication should return failure, not an error that results in a
// PlatformException. // PlatformException.
XCTAssertEqual(resultDetails.result, FLAAuthResultErrorNotAvailable); XCTAssertEqual(resultDetails.result, FLADAuthResultErrorNotAvailable);
XCTAssertNil(error); XCTAssertNil(error);
[expectation fulfill]; [expectation fulfill];
}]; }];
@ -169,12 +169,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testFailedWithUnknownErrorCode { - (void)testFailedWithUnknownErrorCode {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
// evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not
@ -191,14 +191,14 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:NO
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
XCTAssertTrue([NSThread isMainThread]); XCTAssertTrue([NSThread isMainThread]);
XCTAssertEqual(resultDetails.result, FLAAuthResultErrorNotAvailable); XCTAssertEqual(resultDetails.result, FLADAuthResultErrorNotAvailable);
XCTAssertNil(error); XCTAssertNil(error);
[expectation fulfill]; [expectation fulfill];
}]; }];
@ -207,12 +207,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testSystemCancelledWithoutStickyAuth { - (void)testSystemCancelledWithoutStickyAuth {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
// evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not
@ -229,14 +229,14 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:NO
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
XCTAssertTrue([NSThread isMainThread]); XCTAssertTrue([NSThread isMainThread]);
XCTAssertEqual(resultDetails.result, FLAAuthResultFailure); XCTAssertEqual(resultDetails.result, FLADAuthResultFailure);
XCTAssertNil(error); XCTAssertNil(error);
[expectation fulfill]; [expectation fulfill];
}]; }];
@ -245,12 +245,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testFailedAuthWithoutBiometrics { - (void)testFailedAuthWithoutBiometrics {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
// evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not
@ -267,18 +267,18 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:NO
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
XCTAssertTrue([NSThread isMainThread]); XCTAssertTrue([NSThread isMainThread]);
// TODO(stuartmorgan): Fix this; this was the pre-Pigeon-migration // TODO(stuartmorgan): Fix this; this was the pre-Pigeon-migration
// behavior, so is preserved as part of the migration, but a failed // behavior, so is preserved as part of the migration, but a failed
// authentication should return failure, not an error that results in a // authentication should return failure, not an error that results in a
// PlatformException. // PlatformException.
XCTAssertEqual(resultDetails.result, FLAAuthResultErrorNotAvailable); XCTAssertEqual(resultDetails.result, FLADAuthResultErrorNotAvailable);
XCTAssertNil(error); XCTAssertNil(error);
[expectation fulfill]; [expectation fulfill];
}]; }];
@ -287,12 +287,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testLocalizedFallbackTitle { - (void)testLocalizedFallbackTitle {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
strings.localizedFallbackTitle = @"a title"; strings.localizedFallbackTitle = @"a title";
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
@ -310,11 +310,11 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:NO
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
OCMVerify([mockAuthContext OCMVerify([mockAuthContext
setLocalizedFallbackTitle:strings.localizedFallbackTitle]); setLocalizedFallbackTitle:strings.localizedFallbackTitle]);
@ -325,12 +325,12 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testSkippedLocalizedFallbackTitle { - (void)testSkippedLocalizedFallbackTitle {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication;
FLAAuthStrings *strings = [self createAuthStrings]; FLADAuthStrings *strings = [self createAuthStrings];
strings.localizedFallbackTitle = nil; strings.localizedFallbackTitle = nil;
OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES);
@ -348,11 +348,11 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(backgroundThreadReplyCaller); .andDo(backgroundThreadReplyCaller);
XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"];
[plugin authenticateWithOptions:[FLAAuthOptions makeWithBiometricOnly:NO [plugin authenticateWithOptions:[FLADAuthOptions makeWithBiometricOnly:NO
sticky:NO sticky:NO
useErrorDialogs:NO] useErrorDialogs:NO]
strings:strings strings:strings
completion:^(FLAAuthResultDetails *_Nullable resultDetails, completion:^(FLADAuthResultDetails *_Nullable resultDetails,
FlutterError *_Nullable error) { FlutterError *_Nullable error) {
OCMVerify([mockAuthContext setLocalizedFallbackTitle:nil]); OCMVerify([mockAuthContext setLocalizedFallbackTitle:nil]);
[expectation fulfill]; [expectation fulfill];
@ -362,7 +362,7 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testDeviceSupportsBiometrics_withEnrolledHardware { - (void)testDeviceSupportsBiometrics_withEnrolledHardware {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -377,7 +377,7 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testDeviceSupportsBiometrics_withNonEnrolledHardware { - (void)testDeviceSupportsBiometrics_withNonEnrolledHardware {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -404,7 +404,7 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testDeviceSupportsBiometrics_withNoBiometricHardware { - (void)testDeviceSupportsBiometrics_withNoBiometricHardware {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -431,7 +431,7 @@ static const NSTimeInterval kTimeout = 30.0;
- (void)testGetEnrolledBiometricsWithFaceID { - (void)testGetEnrolledBiometricsWithFaceID {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -440,15 +440,15 @@ static const NSTimeInterval kTimeout = 30.0;
OCMStub([mockAuthContext biometryType]).andReturn(LABiometryTypeFaceID); OCMStub([mockAuthContext biometryType]).andReturn(LABiometryTypeFaceID);
FlutterError *error; FlutterError *error;
NSArray<FLAAuthBiometricWrapper *> *result = [plugin getEnrolledBiometricsWithError:&error]; NSArray<FLADAuthBiometricWrapper *> *result = [plugin getEnrolledBiometricsWithError:&error];
XCTAssertEqual([result count], 1); XCTAssertEqual([result count], 1);
XCTAssertEqual(result[0].value, FLAAuthBiometricFace); XCTAssertEqual(result[0].value, FLADAuthBiometricFace);
XCTAssertNil(error); XCTAssertNil(error);
} }
- (void)testGetEnrolledBiometricsWithTouchID { - (void)testGetEnrolledBiometricsWithTouchID {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -457,15 +457,15 @@ static const NSTimeInterval kTimeout = 30.0;
OCMStub([mockAuthContext biometryType]).andReturn(LABiometryTypeTouchID); OCMStub([mockAuthContext biometryType]).andReturn(LABiometryTypeTouchID);
FlutterError *error; FlutterError *error;
NSArray<FLAAuthBiometricWrapper *> *result = [plugin getEnrolledBiometricsWithError:&error]; NSArray<FLADAuthBiometricWrapper *> *result = [plugin getEnrolledBiometricsWithError:&error];
XCTAssertEqual([result count], 1); XCTAssertEqual([result count], 1);
XCTAssertEqual(result[0].value, FLAAuthBiometricFingerprint); XCTAssertEqual(result[0].value, FLADAuthBiometricFingerprint);
XCTAssertNil(error); XCTAssertNil(error);
} }
- (void)testGetEnrolledBiometricsWithoutEnrolledHardware { - (void)testGetEnrolledBiometricsWithoutEnrolledHardware {
id mockAuthContext = OCMClassMock([LAContext class]); id mockAuthContext = OCMClassMock([LAContext class]);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -485,7 +485,7 @@ static const NSTimeInterval kTimeout = 30.0;
.andDo(canEvaluatePolicyHandler); .andDo(canEvaluatePolicyHandler);
FlutterError *error; FlutterError *error;
NSArray<FLAAuthBiometricWrapper *> *result = [plugin getEnrolledBiometricsWithError:&error]; NSArray<FLADAuthBiometricWrapper *> *result = [plugin getEnrolledBiometricsWithError:&error];
XCTAssertEqual([result count], 0); XCTAssertEqual([result count], 0);
XCTAssertNil(error); XCTAssertNil(error);
} }
@ -495,7 +495,7 @@ static const NSTimeInterval kTimeout = 30.0;
OCMStub([mockAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication OCMStub([mockAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication
error:[OCMArg setTo:nil]]) error:[OCMArg setTo:nil]])
.andReturn(YES); .andReturn(YES);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -510,7 +510,7 @@ static const NSTimeInterval kTimeout = 30.0;
OCMStub([mockAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication OCMStub([mockAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication
error:[OCMArg setTo:nil]]) error:[OCMArg setTo:nil]])
.andReturn(NO); .andReturn(NO);
FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] FLALocalAuthPlugin *plugin = [[FLALocalAuthPlugin alloc]
initWithContextFactory:[[StubAuthContextFactory alloc] initWithContextFactory:[[StubAuthContextFactory alloc]
initWithContexts:@[ mockAuthContext ]]]; initWithContexts:@[ mockAuthContext ]]];
@ -520,13 +520,13 @@ static const NSTimeInterval kTimeout = 30.0;
XCTAssertNil(error); XCTAssertNil(error);
} }
// Creates an FLAAuthStrings with placeholder values. // Creates an FLADAuthStrings with placeholder values.
- (FLAAuthStrings *)createAuthStrings { - (FLADAuthStrings *)createAuthStrings {
return [FLAAuthStrings makeWithReason:@"a reason" return [FLADAuthStrings makeWithReason:@"a reason"
lockOut:@"locked out" lockOut:@"locked out"
goToSettingsButton:@"Go To Settings" goToSettingsButton:@"Go To Settings"
goToSettingsDescription:@"Settings" goToSettingsDescription:@"Settings"
cancelButton:@"Cancel" cancelButton:@"Cancel"
localizedFallbackTitle:nil]; localizedFallbackTitle:nil];
} }
@end @end

View File

@ -9,7 +9,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */; }; 0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */; };
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */; }; 3398D2E426164AD8005A052F /* FLALocalAuthPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3398D2E326164AD8005A052F /* FLALocalAuthPluginTests.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
691CB38B382734AF80FBCA4C /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBFA21B380E07A3A585383D /* libPods-RunnerTests.a */; }; 691CB38B382734AF80FBCA4C /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBFA21B380E07A3A585383D /* libPods-RunnerTests.a */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
@ -49,7 +49,7 @@
3398D2D126163948005A052F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 3398D2D126163948005A052F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3398D2DC261649CD005A052F /* liblocal_auth.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblocal_auth.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3398D2DC261649CD005A052F /* liblocal_auth.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblocal_auth.a; sourceTree = BUILT_PRODUCTS_DIR; };
3398D2DF26164A03005A052F /* liblocal_auth.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblocal_auth.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3398D2DF26164A03005A052F /* liblocal_auth.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = liblocal_auth.a; sourceTree = BUILT_PRODUCTS_DIR; };
3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FLTLocalAuthPluginTests.m; path = ../../darwin/Tests/FLTLocalAuthPluginTests.m; sourceTree = SOURCE_ROOT; }; 3398D2E326164AD8005A052F /* FLALocalAuthPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FLALocalAuthPluginTests.m; path = ../../darwin/Tests/FLALocalAuthPluginTests.m; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
658CDD04B21E4EA92F8EF229 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; 658CDD04B21E4EA92F8EF229 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@ -93,7 +93,7 @@
33BF11D226680B2E002967F3 /* RunnerTests */ = { 33BF11D226680B2E002967F3 /* RunnerTests */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */, 3398D2E326164AD8005A052F /* FLALocalAuthPluginTests.m */,
3398D2D126163948005A052F /* Info.plist */, 3398D2D126163948005A052F /* Info.plist */,
); );
path = RunnerTests; path = RunnerTests;
@ -227,7 +227,7 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1430; LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "The Flutter Authors"; ORGANIZATIONNAME = "The Flutter Authors";
TargetAttributes = { TargetAttributes = {
3398D2CC26163948005A052F = { 3398D2CC26163948005A052F = {
@ -377,7 +377,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */, 3398D2E426164AD8005A052F /* FLALocalAuthPluginTests.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1430" LastUpgradeVersion = "1510"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@ -9,7 +9,7 @@ import 'package:pigeon/pigeon.dart';
objcHeaderOut: 'darwin/Classes/messages.g.h', objcHeaderOut: 'darwin/Classes/messages.g.h',
objcSourceOut: 'darwin/Classes/messages.g.m', objcSourceOut: 'darwin/Classes/messages.g.m',
objcOptions: ObjcOptions( objcOptions: ObjcOptions(
prefix: 'FLA', prefix: 'FLAD', // Avoid runtime collisions with old local_auth_ios classes.
), ),
copyrightHeader: 'pigeons/copyright.txt', copyrightHeader: 'pigeons/copyright.txt',
)) ))

View File

@ -2,7 +2,7 @@ name: local_auth_darwin
description: iOS implementation of the local_auth plugin. description: iOS implementation of the local_auth plugin.
repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_darwin repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_darwin
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
version: 1.2.0 version: 1.2.1
environment: environment:
sdk: ^3.2.3 sdk: ^3.2.3
@ -13,7 +13,7 @@ flutter:
implements: local_auth implements: local_auth
platforms: platforms:
ios: ios:
pluginClass: FLTLocalAuthPlugin pluginClass: FLALocalAuthPlugin
dartPluginClass: LocalAuthDarwin dartPluginClass: LocalAuthDarwin
sharedDarwinSource: true sharedDarwinSource: true