From 25bead8af1239201fd50260931bd9019270eeca2 Mon Sep 17 00:00:00 2001 From: Enrico Benedos Date: Fri, 2 Apr 2021 08:26:56 +0200 Subject: [PATCH 1/6] Fix iOS crash when no localizedReason --- packages/local_auth/lib/local_auth.dart | 2 ++ packages/local_auth/test/local_auth_test.dart | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/lib/local_auth.dart index 3f332592a4dd..b6675e046f26 100644 --- a/packages/local_auth/lib/local_auth.dart +++ b/packages/local_auth/lib/local_auth.dart @@ -101,6 +101,8 @@ class LocalAuthentication { bool biometricOnly = false, }) async { assert(localizedReason != null); + assert(localizedReason.isNotEmpty); + final Map args = { 'localizedReason': localizedReason, 'useErrorDialogs': useErrorDialogs, diff --git a/packages/local_auth/test/local_auth_test.dart b/packages/local_auth/test/local_auth_test.dart index d0a4dc8fc594..b24de8bd3c11 100644 --- a/packages/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/test/local_auth_test.dart @@ -73,6 +73,17 @@ void main() { ); }); + test('authenticate with no localizedReason on iOS.', () async { + setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); + await expectLater( + localAuthentication.authenticate( + localizedReason: '', + biometricOnly: true, + ), + throwsAssertionError, + ); + }); + test('authenticate with no sensitive transaction.', () async { setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); await localAuthentication.authenticate( From 64db76c5b653132de2f491d6a5b2315ead329c55 Mon Sep 17 00:00:00 2001 From: Enrico Benedos Date: Fri, 2 Apr 2021 08:52:18 +0200 Subject: [PATCH 2/6] Updated versioning files --- packages/local_auth/CHANGELOG.md | 4 ++++ packages/local_auth/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/local_auth/CHANGELOG.md b/packages/local_auth/CHANGELOG.md index 258144cd0daa..c555ef810487 100644 --- a/packages/local_auth/CHANGELOG.md +++ b/packages/local_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.2 + +* Fixed iOS app crash when fill `localizedReason` with an empty string + ## 1.1.1 * Update flutter_plugin_android_lifecycle dependency to 2.0.1 to fix an R8 issue diff --git a/packages/local_auth/pubspec.yaml b/packages/local_auth/pubspec.yaml index 76722c00a147..e9d406d891c5 100644 --- a/packages/local_auth/pubspec.yaml +++ b/packages/local_auth/pubspec.yaml @@ -2,7 +2,7 @@ name: local_auth description: Flutter plugin for Android and iOS devices to allow local authentication via fingerprint, touch ID, face ID, passcode, pin, or pattern. homepage: https://github.com/flutter/plugins/tree/master/packages/local_auth -version: 1.1.1 +version: 1.1.2 flutter: plugin: From 52bfb1d3bf303aefd19771a91e8d3df8815d8b4a Mon Sep 17 00:00:00 2001 From: Enrico Benedos Date: Thu, 8 Apr 2021 19:35:16 +0200 Subject: [PATCH 3/6] Removed null assertion due to null safety --- packages/local_auth/lib/local_auth.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/lib/local_auth.dart index b6675e046f26..a9ba0891817e 100644 --- a/packages/local_auth/lib/local_auth.dart +++ b/packages/local_auth/lib/local_auth.dart @@ -100,7 +100,6 @@ class LocalAuthentication { bool sensitiveTransaction = true, bool biometricOnly = false, }) async { - assert(localizedReason != null); assert(localizedReason.isNotEmpty); final Map args = { From 60c4e520191eb527a14957241edc12b305e8730a Mon Sep 17 00:00:00 2001 From: Enrico Benedos Date: Thu, 8 Apr 2021 20:00:00 +0200 Subject: [PATCH 4/6] Updated authenticate() method documnetation --- packages/local_auth/lib/local_auth.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/lib/local_auth.dart index a9ba0891817e..63987276792f 100644 --- a/packages/local_auth/lib/local_auth.dart +++ b/packages/local_auth/lib/local_auth.dart @@ -59,7 +59,8 @@ class LocalAuthentication { /// /// [localizedReason] is the message to show to user while prompting them /// for authentication. This is typically along the lines of: 'Please scan - /// your finger to access MyApp.' + /// your finger to access MyApp.'. If the given value is an empty string + /// an [AssertionError] will be thrown. /// /// [useErrorDialogs] = true means the system will attempt to handle user /// fixable issues encountered while authenticating. For instance, if From 2f8a09af8bcba8bd8f7149b80dde2e69cdb74a83 Mon Sep 17 00:00:00 2001 From: enricobenedos Date: Fri, 9 Apr 2021 08:58:39 +0200 Subject: [PATCH 5/6] Update packages/local_auth/CHANGELOG.md Co-authored-by: Chris Yang --- packages/local_auth/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/local_auth/CHANGELOG.md b/packages/local_auth/CHANGELOG.md index 8cab862e761e..f6c38489d8bb 100644 --- a/packages/local_auth/CHANGELOG.md +++ b/packages/local_auth/CHANGELOG.md @@ -1,6 +1,6 @@ ## 1.1.4 -* Fixed iOS app crash when fill `localizedReason` with an empty string +* Add debug assertion that `localizedReason` in `LocalAuthentication.authenticateWithBiometrics` must not be empty. ## 1.1.3 From 8e3fe6e800612ef4a30b4c9e03e0b68a81465a9c Mon Sep 17 00:00:00 2001 From: enricobenedos Date: Fri, 9 Apr 2021 08:59:07 +0200 Subject: [PATCH 6/6] Update packages/local_auth/lib/local_auth.dart Co-authored-by: Chris Yang --- packages/local_auth/lib/local_auth.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/lib/local_auth.dart index 63987276792f..0b75a83d4029 100644 --- a/packages/local_auth/lib/local_auth.dart +++ b/packages/local_auth/lib/local_auth.dart @@ -59,8 +59,7 @@ class LocalAuthentication { /// /// [localizedReason] is the message to show to user while prompting them /// for authentication. This is typically along the lines of: 'Please scan - /// your finger to access MyApp.'. If the given value is an empty string - /// an [AssertionError] will be thrown. + /// your finger to access MyApp.'. This must not be empty. /// /// [useErrorDialogs] = true means the system will attempt to handle user /// fixable issues encountered while authenticating. For instance, if