From 94c4904d145798c752c9bd9991f47dcccee8a3ea Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 14:39:13 +0100 Subject: [PATCH 01/53] Add platform interface for local_auth plugin to prepare for federated architecture --- packages/local_auth/{ => local_auth}/AUTHORS | 0 .../local_auth/{ => local_auth}/CHANGELOG.md | 0 packages/local_auth/{ => local_auth}/LICENSE | 0 .../local_auth/{ => local_auth}/README.md | 0 .../{ => local_auth}/android/build.gradle | 0 .../android/lint-baseline.xml | 0 .../{ => local_auth}/android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../localauth/AuthenticationHelper.java | 0 .../plugins/localauth/LocalAuthPlugin.java | 0 .../res/drawable/fingerprint_initial_icon.xml | 0 .../res/drawable/fingerprint_success_icon.xml | 0 .../res/drawable/fingerprint_warning_icon.xml | 0 .../main/res/drawable/ic_done_white_24dp.xml | 0 .../drawable/ic_fingerprint_white_24dp.xml | 0 .../drawable/ic_priority_high_white_24dp.xml | 0 .../src/main/res/layout/go_to_setting.xml | 0 .../android/src/main/res/layout/scan_fp.xml | 0 .../android/src/main/res/values/colors.xml | 0 .../android/src/main/res/values/dimens.xml | 0 .../android/src/main/res/values/styles.xml | 0 .../plugins/localauth/LocalAuthTest.java | 0 .../{ => local_auth}/example/README.md | 0 .../example/android/app/build.gradle | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../flutter/plugins/DartIntegrationTest.java | 0 .../FlutterFragmentActivityTest.java | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../example/android/settings_aar.gradle | 0 .../integration_test/local_auth_test.dart | 0 .../ios/Flutter/AppFrameworkInfo.plist | 0 .../example/ios/Flutter/Debug.xcconfig | 0 .../example/ios/Flutter/Release.xcconfig | 0 .../{ => local_auth}/example/ios/Podfile | 0 .../ios/Runner.xcodeproj/project.pbxproj | 0 .../contents.xcworkspacedata | 0 .../xcshareddata/xcschemes/Runner.xcscheme | 0 .../contents.xcworkspacedata | 0 .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../example/ios/Runner/AppDelegate.h | 0 .../example/ios/Runner/AppDelegate.m | 0 .../AppIcon.appiconset/Contents.json | 0 .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin .../Icon-App-83.5x83.5@2x.png | Bin .../Runner/Base.lproj/LaunchScreen.storyboard | 0 .../ios/Runner/Base.lproj/Main.storyboard | 0 .../example/ios/Runner/Info.plist | 0 .../example/ios/Runner/main.m | 0 .../ios/RunnerTests/FLTLocalAuthPluginTests.m | 0 .../example/ios/RunnerTests/Info.plist | 0 .../{ => local_auth}/example/lib/main.dart | 0 .../{ => local_auth}/example/pubspec.yaml | 0 .../example/test_driver/integration_test.dart | 0 .../{ => local_auth}/ios/Assets/.gitkeep | 0 .../ios/Classes/FLTLocalAuthPlugin.h | 0 .../ios/Classes/FLTLocalAuthPlugin.m | 0 .../{ => local_auth}/ios/local_auth.podspec | 0 .../{ => local_auth}/lib/auth_strings.dart | 0 .../{ => local_auth}/lib/error_codes.dart | 0 .../{ => local_auth}/lib/local_auth.dart | 0 .../local_auth/{ => local_auth}/pubspec.yaml | 0 .../test/local_auth_test.dart | 0 .../local_auth_platform_interface/AUTHORS | 67 ++++++++++ .../CHANGELOG.md | 3 + .../local_auth_platform_interface/LICENSE | 25 ++++ .../local_auth_platform_interface/README.md | 26 ++++ .../analysis_options.yaml | 4 + .../lib/local_auth_platform_interface.dart | 116 ++++++++++++++++++ .../lib/types/auth_strings.dart | 10 ++ .../lib/types/biometric_type.dart | 5 + .../pubspec.yaml | 22 ++++ 92 files changed, 278 insertions(+) rename packages/local_auth/{ => local_auth}/AUTHORS (100%) rename packages/local_auth/{ => local_auth}/CHANGELOG.md (100%) rename packages/local_auth/{ => local_auth}/LICENSE (100%) rename packages/local_auth/{ => local_auth}/README.md (100%) rename packages/local_auth/{ => local_auth}/android/build.gradle (100%) rename packages/local_auth/{ => local_auth}/android/lint-baseline.xml (100%) rename packages/local_auth/{ => local_auth}/android/settings.gradle (100%) rename packages/local_auth/{ => local_auth}/android/src/main/AndroidManifest.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java (100%) rename packages/local_auth/{ => local_auth}/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/fingerprint_initial_icon.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/fingerprint_success_icon.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/fingerprint_warning_icon.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/ic_done_white_24dp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/ic_priority_high_white_24dp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/layout/go_to_setting.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/layout/scan_fp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/values/colors.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/values/dimens.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/values/styles.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java (100%) rename packages/local_auth/{ => local_auth}/example/README.md (100%) rename packages/local_auth/{ => local_auth}/example/android/app/build.gradle (100%) rename packages/local_auth/{ => local_auth}/example/android/app/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/AndroidManifest.xml (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/build.gradle (100%) rename packages/local_auth/{ => local_auth}/example/android/gradle.properties (100%) rename packages/local_auth/{ => local_auth}/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/local_auth/{ => local_auth}/example/android/settings.gradle (100%) rename packages/local_auth/{ => local_auth}/example/android/settings_aar.gradle (100%) rename packages/local_auth/{ => local_auth}/example/integration_test/local_auth_test.dart (100%) rename packages/local_auth/{ => local_auth}/example/ios/Flutter/AppFrameworkInfo.plist (100%) rename packages/local_auth/{ => local_auth}/example/ios/Flutter/Debug.xcconfig (100%) rename packages/local_auth/{ => local_auth}/example/ios/Flutter/Release.xcconfig (100%) rename packages/local_auth/{ => local_auth}/example/ios/Podfile (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcodeproj/project.pbxproj (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcworkspace/contents.xcworkspacedata (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/AppDelegate.h (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/AppDelegate.m (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Base.lproj/LaunchScreen.storyboard (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Base.lproj/Main.storyboard (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Info.plist (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/main.m (100%) rename packages/local_auth/{ => local_auth}/example/ios/RunnerTests/FLTLocalAuthPluginTests.m (100%) rename packages/local_auth/{ => local_auth}/example/ios/RunnerTests/Info.plist (100%) rename packages/local_auth/{ => local_auth}/example/lib/main.dart (100%) rename packages/local_auth/{ => local_auth}/example/pubspec.yaml (100%) rename packages/local_auth/{ => local_auth}/example/test_driver/integration_test.dart (100%) rename packages/local_auth/{ => local_auth}/ios/Assets/.gitkeep (100%) rename packages/local_auth/{ => local_auth}/ios/Classes/FLTLocalAuthPlugin.h (100%) rename packages/local_auth/{ => local_auth}/ios/Classes/FLTLocalAuthPlugin.m (100%) rename packages/local_auth/{ => local_auth}/ios/local_auth.podspec (100%) rename packages/local_auth/{ => local_auth}/lib/auth_strings.dart (100%) rename packages/local_auth/{ => local_auth}/lib/error_codes.dart (100%) rename packages/local_auth/{ => local_auth}/lib/local_auth.dart (100%) rename packages/local_auth/{ => local_auth}/pubspec.yaml (100%) rename packages/local_auth/{ => local_auth}/test/local_auth_test.dart (100%) create mode 100644 packages/local_auth/local_auth_platform_interface/AUTHORS create mode 100644 packages/local_auth/local_auth_platform_interface/CHANGELOG.md create mode 100644 packages/local_auth/local_auth_platform_interface/LICENSE create mode 100644 packages/local_auth/local_auth_platform_interface/README.md create mode 100644 packages/local_auth/local_auth_platform_interface/analysis_options.yaml create mode 100644 packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart create mode 100644 packages/local_auth/local_auth_platform_interface/pubspec.yaml diff --git a/packages/local_auth/AUTHORS b/packages/local_auth/local_auth/AUTHORS similarity index 100% rename from packages/local_auth/AUTHORS rename to packages/local_auth/local_auth/AUTHORS diff --git a/packages/local_auth/CHANGELOG.md b/packages/local_auth/local_auth/CHANGELOG.md similarity index 100% rename from packages/local_auth/CHANGELOG.md rename to packages/local_auth/local_auth/CHANGELOG.md diff --git a/packages/local_auth/LICENSE b/packages/local_auth/local_auth/LICENSE similarity index 100% rename from packages/local_auth/LICENSE rename to packages/local_auth/local_auth/LICENSE diff --git a/packages/local_auth/README.md b/packages/local_auth/local_auth/README.md similarity index 100% rename from packages/local_auth/README.md rename to packages/local_auth/local_auth/README.md diff --git a/packages/local_auth/android/build.gradle b/packages/local_auth/local_auth/android/build.gradle similarity index 100% rename from packages/local_auth/android/build.gradle rename to packages/local_auth/local_auth/android/build.gradle diff --git a/packages/local_auth/android/lint-baseline.xml b/packages/local_auth/local_auth/android/lint-baseline.xml similarity index 100% rename from packages/local_auth/android/lint-baseline.xml rename to packages/local_auth/local_auth/android/lint-baseline.xml diff --git a/packages/local_auth/android/settings.gradle b/packages/local_auth/local_auth/android/settings.gradle similarity index 100% rename from packages/local_auth/android/settings.gradle rename to packages/local_auth/local_auth/android/settings.gradle diff --git a/packages/local_auth/android/src/main/AndroidManifest.xml b/packages/local_auth/local_auth/android/src/main/AndroidManifest.xml similarity index 100% rename from packages/local_auth/android/src/main/AndroidManifest.xml rename to packages/local_auth/local_auth/android/src/main/AndroidManifest.xml diff --git a/packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java b/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java similarity index 100% rename from packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java rename to packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java diff --git a/packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java similarity index 100% rename from packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java rename to packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java diff --git a/packages/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml diff --git a/packages/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml diff --git a/packages/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml diff --git a/packages/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml diff --git a/packages/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml diff --git a/packages/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml diff --git a/packages/local_auth/android/src/main/res/layout/go_to_setting.xml b/packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml similarity index 100% rename from packages/local_auth/android/src/main/res/layout/go_to_setting.xml rename to packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml diff --git a/packages/local_auth/android/src/main/res/layout/scan_fp.xml b/packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/layout/scan_fp.xml rename to packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml diff --git a/packages/local_auth/android/src/main/res/values/colors.xml b/packages/local_auth/local_auth/android/src/main/res/values/colors.xml similarity index 100% rename from packages/local_auth/android/src/main/res/values/colors.xml rename to packages/local_auth/local_auth/android/src/main/res/values/colors.xml diff --git a/packages/local_auth/android/src/main/res/values/dimens.xml b/packages/local_auth/local_auth/android/src/main/res/values/dimens.xml similarity index 100% rename from packages/local_auth/android/src/main/res/values/dimens.xml rename to packages/local_auth/local_auth/android/src/main/res/values/dimens.xml diff --git a/packages/local_auth/android/src/main/res/values/styles.xml b/packages/local_auth/local_auth/android/src/main/res/values/styles.xml similarity index 100% rename from packages/local_auth/android/src/main/res/values/styles.xml rename to packages/local_auth/local_auth/android/src/main/res/values/styles.xml diff --git a/packages/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java b/packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java similarity index 100% rename from packages/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java rename to packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java diff --git a/packages/local_auth/example/README.md b/packages/local_auth/local_auth/example/README.md similarity index 100% rename from packages/local_auth/example/README.md rename to packages/local_auth/local_auth/example/README.md diff --git a/packages/local_auth/example/android/app/build.gradle b/packages/local_auth/local_auth/example/android/app/build.gradle similarity index 100% rename from packages/local_auth/example/android/app/build.gradle rename to packages/local_auth/local_auth/example/android/app/build.gradle diff --git a/packages/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties rename to packages/local_auth/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java b/packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java similarity index 100% rename from packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java rename to packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java diff --git a/packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java b/packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java similarity index 100% rename from packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java rename to packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java diff --git a/packages/local_auth/example/android/app/src/main/AndroidManifest.xml b/packages/local_auth/local_auth/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from packages/local_auth/example/android/app/src/main/AndroidManifest.xml rename to packages/local_auth/local_auth/example/android/app/src/main/AndroidManifest.xml diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/build.gradle b/packages/local_auth/local_auth/example/android/build.gradle similarity index 100% rename from packages/local_auth/example/android/build.gradle rename to packages/local_auth/local_auth/example/android/build.gradle diff --git a/packages/local_auth/example/android/gradle.properties b/packages/local_auth/local_auth/example/android/gradle.properties similarity index 100% rename from packages/local_auth/example/android/gradle.properties rename to packages/local_auth/local_auth/example/android/gradle.properties diff --git a/packages/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties rename to packages/local_auth/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/local_auth/example/android/settings.gradle b/packages/local_auth/local_auth/example/android/settings.gradle similarity index 100% rename from packages/local_auth/example/android/settings.gradle rename to packages/local_auth/local_auth/example/android/settings.gradle diff --git a/packages/local_auth/example/android/settings_aar.gradle b/packages/local_auth/local_auth/example/android/settings_aar.gradle similarity index 100% rename from packages/local_auth/example/android/settings_aar.gradle rename to packages/local_auth/local_auth/example/android/settings_aar.gradle diff --git a/packages/local_auth/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth/example/integration_test/local_auth_test.dart similarity index 100% rename from packages/local_auth/example/integration_test/local_auth_test.dart rename to packages/local_auth/local_auth/example/integration_test/local_auth_test.dart diff --git a/packages/local_auth/example/ios/Flutter/AppFrameworkInfo.plist b/packages/local_auth/local_auth/example/ios/Flutter/AppFrameworkInfo.plist similarity index 100% rename from packages/local_auth/example/ios/Flutter/AppFrameworkInfo.plist rename to packages/local_auth/local_auth/example/ios/Flutter/AppFrameworkInfo.plist diff --git a/packages/local_auth/example/ios/Flutter/Debug.xcconfig b/packages/local_auth/local_auth/example/ios/Flutter/Debug.xcconfig similarity index 100% rename from packages/local_auth/example/ios/Flutter/Debug.xcconfig rename to packages/local_auth/local_auth/example/ios/Flutter/Debug.xcconfig diff --git a/packages/local_auth/example/ios/Flutter/Release.xcconfig b/packages/local_auth/local_auth/example/ios/Flutter/Release.xcconfig similarity index 100% rename from packages/local_auth/example/ios/Flutter/Release.xcconfig rename to packages/local_auth/local_auth/example/ios/Flutter/Release.xcconfig diff --git a/packages/local_auth/example/ios/Podfile b/packages/local_auth/local_auth/example/ios/Podfile similarity index 100% rename from packages/local_auth/example/ios/Podfile rename to packages/local_auth/local_auth/example/ios/Podfile diff --git a/packages/local_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj similarity index 100% rename from packages/local_auth/example/ios/Runner.xcodeproj/project.pbxproj rename to packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj diff --git a/packages/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/packages/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from packages/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/packages/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata rename to packages/local_auth/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/packages/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/local_auth/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from packages/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to packages/local_auth/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/packages/local_auth/example/ios/Runner/AppDelegate.h b/packages/local_auth/local_auth/example/ios/Runner/AppDelegate.h similarity index 100% rename from packages/local_auth/example/ios/Runner/AppDelegate.h rename to packages/local_auth/local_auth/example/ios/Runner/AppDelegate.h diff --git a/packages/local_auth/example/ios/Runner/AppDelegate.m b/packages/local_auth/local_auth/example/ios/Runner/AppDelegate.m similarity index 100% rename from packages/local_auth/example/ios/Runner/AppDelegate.m rename to packages/local_auth/local_auth/example/ios/Runner/AppDelegate.m diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/packages/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/local_auth/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from packages/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to packages/local_auth/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/packages/local_auth/example/ios/Runner/Base.lproj/Main.storyboard b/packages/local_auth/local_auth/example/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from packages/local_auth/example/ios/Runner/Base.lproj/Main.storyboard rename to packages/local_auth/local_auth/example/ios/Runner/Base.lproj/Main.storyboard diff --git a/packages/local_auth/example/ios/Runner/Info.plist b/packages/local_auth/local_auth/example/ios/Runner/Info.plist similarity index 100% rename from packages/local_auth/example/ios/Runner/Info.plist rename to packages/local_auth/local_auth/example/ios/Runner/Info.plist diff --git a/packages/local_auth/example/ios/Runner/main.m b/packages/local_auth/local_auth/example/ios/Runner/main.m similarity index 100% rename from packages/local_auth/example/ios/Runner/main.m rename to packages/local_auth/local_auth/example/ios/Runner/main.m diff --git a/packages/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m b/packages/local_auth/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m similarity index 100% rename from packages/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m rename to packages/local_auth/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m diff --git a/packages/local_auth/example/ios/RunnerTests/Info.plist b/packages/local_auth/local_auth/example/ios/RunnerTests/Info.plist similarity index 100% rename from packages/local_auth/example/ios/RunnerTests/Info.plist rename to packages/local_auth/local_auth/example/ios/RunnerTests/Info.plist diff --git a/packages/local_auth/example/lib/main.dart b/packages/local_auth/local_auth/example/lib/main.dart similarity index 100% rename from packages/local_auth/example/lib/main.dart rename to packages/local_auth/local_auth/example/lib/main.dart diff --git a/packages/local_auth/example/pubspec.yaml b/packages/local_auth/local_auth/example/pubspec.yaml similarity index 100% rename from packages/local_auth/example/pubspec.yaml rename to packages/local_auth/local_auth/example/pubspec.yaml diff --git a/packages/local_auth/example/test_driver/integration_test.dart b/packages/local_auth/local_auth/example/test_driver/integration_test.dart similarity index 100% rename from packages/local_auth/example/test_driver/integration_test.dart rename to packages/local_auth/local_auth/example/test_driver/integration_test.dart diff --git a/packages/local_auth/ios/Assets/.gitkeep b/packages/local_auth/local_auth/ios/Assets/.gitkeep similarity index 100% rename from packages/local_auth/ios/Assets/.gitkeep rename to packages/local_auth/local_auth/ios/Assets/.gitkeep diff --git a/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.h b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h similarity index 100% rename from packages/local_auth/ios/Classes/FLTLocalAuthPlugin.h rename to packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h diff --git a/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m similarity index 100% rename from packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m rename to packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m diff --git a/packages/local_auth/ios/local_auth.podspec b/packages/local_auth/local_auth/ios/local_auth.podspec similarity index 100% rename from packages/local_auth/ios/local_auth.podspec rename to packages/local_auth/local_auth/ios/local_auth.podspec diff --git a/packages/local_auth/lib/auth_strings.dart b/packages/local_auth/local_auth/lib/auth_strings.dart similarity index 100% rename from packages/local_auth/lib/auth_strings.dart rename to packages/local_auth/local_auth/lib/auth_strings.dart diff --git a/packages/local_auth/lib/error_codes.dart b/packages/local_auth/local_auth/lib/error_codes.dart similarity index 100% rename from packages/local_auth/lib/error_codes.dart rename to packages/local_auth/local_auth/lib/error_codes.dart diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart similarity index 100% rename from packages/local_auth/lib/local_auth.dart rename to packages/local_auth/local_auth/lib/local_auth.dart diff --git a/packages/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml similarity index 100% rename from packages/local_auth/pubspec.yaml rename to packages/local_auth/local_auth/pubspec.yaml diff --git a/packages/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart similarity index 100% rename from packages/local_auth/test/local_auth_test.dart rename to packages/local_auth/local_auth/test/local_auth_test.dart diff --git a/packages/local_auth/local_auth_platform_interface/AUTHORS b/packages/local_auth/local_auth_platform_interface/AUTHORS new file mode 100644 index 000000000000..d5694690c247 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/AUTHORS @@ -0,0 +1,67 @@ +# Below is a list of people and organizations that have contributed +# to the Flutter project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. +The Chromium Authors +German Saprykin +Benjamin Sauer +larsenthomasj@gmail.com +Ali Bitek +Pol Batlló +Anatoly Pulyaevskiy +Hayden Flinner +Stefano Rodriguez +Salvatore Giordano +Brian Armstrong +Paul DeMarco +Fabricio Nogueira +Simon Lightfoot +Ashton Thomas +Thomas Danner +Diego Velásquez +Hajime Nakamura +Tuyển Vũ Xuân +Miguel Ruivo +Sarthak Verma +Mike Diarmid +Invertase +Elliot Hesp +Vince Varga +Aawaz Gyawali +EUI Limited +Katarina Sheremet +Thomas Stockx +Sarbagya Dhaubanjar +Ozkan Eksi +Rishab Nayak +ko2ic +Jonathan Younger +Jose Sanchez +Debkanchan Samadder +Audrius Karosevicius +Lukasz Piliszczuk +SoundReply Solutions GmbH +Rafal Wachol +Pau Picas +Christian Weder +Alexandru Tuca +Christian Weder +Rhodes Davis Jr. +Luigi Agosti +Quentin Le Guennec +Koushik Ravikumar +Nissim Dsilva +Giancarlo Rocha +Ryo Miyake +Théo Champion +Kazuki Yamaguchi +Eitan Schwartz +Chris Rutkowski +Juan Alvarez +Aleksandr Yurkovskiy +Anton Borries +Alex Li +Rahul Raj <64.rahulraj@gmail.com> +Bodhi Mulders diff --git a/packages/local_auth/local_auth_platform_interface/CHANGELOG.md b/packages/local_auth/local_auth_platform_interface/CHANGELOG.md new file mode 100644 index 000000000000..0d8803f93540 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial release. diff --git a/packages/local_auth/local_auth_platform_interface/LICENSE b/packages/local_auth/local_auth_platform_interface/LICENSE new file mode 100644 index 000000000000..c6823b81eb84 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/LICENSE @@ -0,0 +1,25 @@ +Copyright 2013 The Flutter Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/local_auth/local_auth_platform_interface/README.md b/packages/local_auth/local_auth_platform_interface/README.md new file mode 100644 index 000000000000..3b01ced7b93b --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/README.md @@ -0,0 +1,26 @@ +# local_auth_platform_interface + +A common platform interface for the [`local_auth`][1] plugin. + +This interface allows platform-specific implementations of the `local_auth` +plugin, as well as the plugin itself, to ensure they are supporting the +same interface. + +# Usage + +To implement a new platform-specific implementation of `local_auth`, extend +[`LocalAuthPlatform`][2] with an implementation that performs the +platform-specific behavior, and when you register your plugin, set the default +`LocalAuthPlatform` by calling +`LocalAuthPlatform.instance = MyLocalAuthPlatform()`. + +# Note on breaking changes + +Strongly prefer non-breaking changes (such as adding a method to the interface) +over breaking changes for this package. + +See https://flutter.dev/go/platform-interface-breaking-changes for a discussion +on why a less-clean interface is preferable to a breaking change. + +[1]: ../local_auth +[2]: lib/local_auth_platform_interface.dart diff --git a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml b/packages/local_auth/local_auth_platform_interface/analysis_options.yaml new file mode 100644 index 000000000000..a5744c1cfbe7 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart new file mode 100644 index 000000000000..833004b7e032 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -0,0 +1,116 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:local_auth_platform_interface/types/biometric_type.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +/// The interface that implementations of local_auth must implement. +/// +/// Platform implementations should extend this class rather than implement it as `local_auth` +/// does not consider newly added methods to be breaking changes. Extending this class +/// (using `extends`) ensures that the subclass will get the default implementation, while +/// platform implementations that `implements` this interface will be broken by newly added +/// [LocalAuthPlatform] methods. +abstract class LocalAuthPlatform extends PlatformInterface { + /// Constructs a LocalAuthPlatform. + LocalAuthPlatform() : super(token: _token); + + static final Object _token = Object(); + + static LocalAuthPlatform _instance = DefaultLocalAuthPlatform(); + + /// The default instance of [LocalAuthPlatform] to use. + /// + /// Defaults to [DefaultLocalAuthPlatform]. + static LocalAuthPlatform get instance => _instance; + + /// Platform-specific plugins should set this with their own platform-specific + /// class that extends [LocalAuthPlatform] when they register themselves. + static set instance(LocalAuthPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + /// Authenticates the user with biometrics available on the device while also + /// allowing the user to use device authentication - pin, pattern, passcode. + /// + /// Returns a [Future] holding true, if the user successfully authenticated, + /// false otherwise. + /// + /// [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.'. This must not be empty. + /// + /// [useErrorDialogs] = true means the system will attempt to handle user + /// fixable issues encountered while authenticating. For instance, if + /// fingerprint reader exists on the phone but there's no fingerprint + /// registered, the plugin will attempt to take the user to settings to add + /// one. Anything that is not user fixable, such as no biometric sensor on + /// device, will be returned as a [PlatformException]. + /// + /// [stickyAuth] is used when the application goes into background for any + /// reason while the authentication is in progress. Due to security reasons, + /// the authentication has to be stopped at that time. If stickyAuth is set + /// to true, authentication resumes when the app is resumed. If it is set to + /// false (default), then as soon as app is paused a failure message is sent + /// back to Dart and it is up to the client app to restart authentication or + /// do something else. + /// + /// Provide [authStrings] if you want to + /// customize messages in the dialogs. + /// + /// Setting [sensitiveTransaction] to true enables platform specific + /// precautions. For instance, on face unlock, Android opens a confirmation + /// dialog after the face is recognized to make sure the user meant to unlock + /// their phone. + /// + /// Setting [biometricOnly] to true prevents authenticates from using non-biometric + /// local authentication such as pin, passcode, and passcode. + /// + /// Throws an [PlatformException] if there were technical problems with local + /// authentication (e.g. lack of relevant hardware). This might throw + /// [PlatformException] with error code [otherOperatingSystem] on the iOS + /// simulator. + Future authenticate({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + required Map authStrings, + bool sensitiveTransaction = true, + bool biometricOnly = false, + }) async { + throw UnimplementedError('authenticate() has not been implemented.'); + } + + /// Returns a list of enrolled biometrics. + /// + /// Returns a [Future] List with the following possibilities: + /// - BiometricType.face + /// - BiometricType.fingerprint + /// - BiometricType.iris (not yet implemented) + Future> getAvailableBiometrics() async { + throw UnimplementedError( + 'getAvailableBiometrics() has not been implemented.'); + } + + /// Returns true if device is capable of checking biometrics or is able to + /// fail over to device credentials. + /// + /// Returns a [Future] bool true or false: + Future isDeviceSupported() async { + throw UnimplementedError('isDeviceSupported() has not been implemented.'); + } + + /// Returns true if auth was cancelled successfully. + /// Returns false if there was some error or no auth in progress. + /// + /// Returns [Future] bool true or false: + Future stopAuthentication() async { + throw UnimplementedError('stopAuthentication() has not been implemented.'); + } +} + +/// The default interface implementation acting as a placeholder for +/// the native implementation to be set. +class DefaultLocalAuthPlatform extends LocalAuthPlatform {} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart new file mode 100644 index 000000000000..0ad81392edb9 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart @@ -0,0 +1,10 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:intl/intl.dart'; + +String get goToSettings => Intl.message('Go to settings', + desc: 'Message showed on a button that the user can click to go to ' + 'settings pages from the current dialog. It is used on both Android ' + 'and iOS side. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart new file mode 100644 index 000000000000..23556ab37caa --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -0,0 +1,5 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +enum BiometricType { face, fingerprint, iris } diff --git a/packages/local_auth/local_auth_platform_interface/pubspec.yaml b/packages/local_auth/local_auth_platform_interface/pubspec.yaml new file mode 100644 index 000000000000..0f88856bf4ee --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/pubspec.yaml @@ -0,0 +1,22 @@ +name: local_auth_platform_interface +description: A common platform interface for the local_auth plugin. +repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_platform_interface +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0 + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.1.2 + intl: ^0.17.0 + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^5.0.0 \ No newline at end of file From c2b28d2ee895a4031f12c2706827b745d20b1ee6 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 14:53:20 +0100 Subject: [PATCH 02/53] Add iOS implementation for local_auth_platform_interface --- packages/local_auth/local_auth_ios/AUTHORS | 67 ++ .../local_auth/local_auth_ios/CHANGELOG.md | 3 + packages/local_auth/local_auth_ios/LICENSE | 25 + packages/local_auth/local_auth_ios/README.md | 11 + .../local_auth_ios/analysis_options.yaml | 4 + .../local_auth_ios/example/README.md | 8 + .../integration_test/local_auth_test.dart | 19 + .../ios/Flutter/AppFrameworkInfo.plist | 30 + .../example/ios/Flutter/Debug.xcconfig | 2 + .../example/ios/Flutter/Release.xcconfig | 2 + .../local_auth_ios/example/ios/Podfile | 38 ++ .../ios/Runner.xcodeproj/project.pbxproj | 611 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/xcschemes/Runner.xcscheme | 97 +++ .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../example/ios/Runner/AppDelegate.h | 10 + .../example/ios/Runner/AppDelegate.m | 17 + .../AppIcon.appiconset/Contents.json | 116 ++++ .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 0 -> 564 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 0 -> 1283 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 0 -> 1588 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 0 -> 1025 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 0 -> 1716 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 0 -> 1920 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 0 -> 1283 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 0 -> 1895 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 0 -> 2665 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 0 -> 2665 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 0 -> 3831 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 0 -> 1888 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 0 -> 3294 bytes .../Icon-App-83.5x83.5@2x.png | Bin 0 -> 3612 bytes .../Runner/Base.lproj/LaunchScreen.storyboard | 27 + .../ios/Runner/Base.lproj/Main.storyboard | 26 + .../example/ios/Runner/Info.plist | 51 ++ .../local_auth_ios/example/ios/Runner/main.m | 13 + .../ios/RunnerTests/FLTLocalAuthPluginTests.m | 189 ++++++ .../example/ios/RunnerTests/Info.plist | 22 + .../local_auth_ios/example/lib/main.dart | 233 +++++++ .../local_auth_ios/example/pubspec.yaml | 28 + .../example/test_driver/integration_test.dart | 7 + .../local_auth_ios/ios/Assets/.gitkeep | 0 .../ios/Classes/FLTLocalAuthPlugin.h | 8 + .../ios/Classes/FLTLocalAuthPlugin.m | 229 +++++++ .../local_auth_ios/ios/local_auth_ios.podspec | 23 + .../local_auth_ios/lib/local_auth_ios.dart | 75 +++ .../lib/types/auth_strings_ios.dart | 53 ++ .../local_auth/local_auth_ios/pubspec.yaml | 30 + .../local_auth_ios/test/local_auth_test.dart | 110 ++++ 50 files changed, 2209 insertions(+) create mode 100644 packages/local_auth/local_auth_ios/AUTHORS create mode 100644 packages/local_auth/local_auth_ios/CHANGELOG.md create mode 100644 packages/local_auth/local_auth_ios/LICENSE create mode 100644 packages/local_auth/local_auth_ios/README.md create mode 100644 packages/local_auth/local_auth_ios/analysis_options.yaml create mode 100644 packages/local_auth/local_auth_ios/example/README.md create mode 100644 packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart create mode 100644 packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist create mode 100644 packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig create mode 100644 packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig create mode 100644 packages/local_auth/local_auth_ios/example/ios/Podfile create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/LaunchScreen.storyboard create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/main.m create mode 100644 packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m create mode 100644 packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist create mode 100644 packages/local_auth/local_auth_ios/example/lib/main.dart create mode 100644 packages/local_auth/local_auth_ios/example/pubspec.yaml create mode 100644 packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart create mode 100644 packages/local_auth/local_auth_ios/ios/Assets/.gitkeep create mode 100644 packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.h create mode 100644 packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m create mode 100644 packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec create mode 100644 packages/local_auth/local_auth_ios/lib/local_auth_ios.dart create mode 100644 packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart create mode 100644 packages/local_auth/local_auth_ios/pubspec.yaml create mode 100644 packages/local_auth/local_auth_ios/test/local_auth_test.dart diff --git a/packages/local_auth/local_auth_ios/AUTHORS b/packages/local_auth/local_auth_ios/AUTHORS new file mode 100644 index 000000000000..d5694690c247 --- /dev/null +++ b/packages/local_auth/local_auth_ios/AUTHORS @@ -0,0 +1,67 @@ +# Below is a list of people and organizations that have contributed +# to the Flutter project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. +The Chromium Authors +German Saprykin +Benjamin Sauer +larsenthomasj@gmail.com +Ali Bitek +Pol Batlló +Anatoly Pulyaevskiy +Hayden Flinner +Stefano Rodriguez +Salvatore Giordano +Brian Armstrong +Paul DeMarco +Fabricio Nogueira +Simon Lightfoot +Ashton Thomas +Thomas Danner +Diego Velásquez +Hajime Nakamura +Tuyển Vũ Xuân +Miguel Ruivo +Sarthak Verma +Mike Diarmid +Invertase +Elliot Hesp +Vince Varga +Aawaz Gyawali +EUI Limited +Katarina Sheremet +Thomas Stockx +Sarbagya Dhaubanjar +Ozkan Eksi +Rishab Nayak +ko2ic +Jonathan Younger +Jose Sanchez +Debkanchan Samadder +Audrius Karosevicius +Lukasz Piliszczuk +SoundReply Solutions GmbH +Rafal Wachol +Pau Picas +Christian Weder +Alexandru Tuca +Christian Weder +Rhodes Davis Jr. +Luigi Agosti +Quentin Le Guennec +Koushik Ravikumar +Nissim Dsilva +Giancarlo Rocha +Ryo Miyake +Théo Champion +Kazuki Yamaguchi +Eitan Schwartz +Chris Rutkowski +Juan Alvarez +Aleksandr Yurkovskiy +Anton Borries +Alex Li +Rahul Raj <64.rahulraj@gmail.com> +Bodhi Mulders diff --git a/packages/local_auth/local_auth_ios/CHANGELOG.md b/packages/local_auth/local_auth_ios/CHANGELOG.md new file mode 100644 index 000000000000..7f198f2d66c0 --- /dev/null +++ b/packages/local_auth/local_auth_ios/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial release from migration to federated architecture. diff --git a/packages/local_auth/local_auth_ios/LICENSE b/packages/local_auth/local_auth_ios/LICENSE new file mode 100644 index 000000000000..c6823b81eb84 --- /dev/null +++ b/packages/local_auth/local_auth_ios/LICENSE @@ -0,0 +1,25 @@ +Copyright 2013 The Flutter Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/local_auth/local_auth_ios/README.md b/packages/local_auth/local_auth_ios/README.md new file mode 100644 index 000000000000..d9f40436b617 --- /dev/null +++ b/packages/local_auth/local_auth_ios/README.md @@ -0,0 +1,11 @@ +# local\_auth\_ios + +The iOS implementation of [`local_auth`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `local_auth` +normally. This package will be automatically included in your app when you do. + +[1]: https://pub.dev/packages/local_auth +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin diff --git a/packages/local_auth/local_auth_ios/analysis_options.yaml b/packages/local_auth/local_auth_ios/analysis_options.yaml new file mode 100644 index 000000000000..a5744c1cfbe7 --- /dev/null +++ b/packages/local_auth/local_auth_ios/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_ios/example/README.md b/packages/local_auth/local_auth_ios/example/README.md new file mode 100644 index 000000000000..a4a6091c9ba6 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/README.md @@ -0,0 +1,8 @@ +# local_auth_example + +Demonstrates how to use the local_auth plugin. + +## Getting Started + +For help getting started with Flutter, view our online +[documentation](https://flutter.dev/). diff --git a/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart new file mode 100644 index 000000000000..f941a1bdaeed --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart @@ -0,0 +1,19 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:local_auth_ios/local_auth_ios.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('canCheckBiometrics', (WidgetTester tester) async { + expect( + LocalAuthIOS().getAvailableBiometrics(), + completion(isList), + ); + }); +} diff --git a/packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist b/packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000000..3a9c234f96d4 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + UIRequiredDeviceCapabilities + + arm64 + + MinimumOSVersion + 9.0 + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig b/packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000000..e8efba114687 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig b/packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000000..399e9340e6f6 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/packages/local_auth/local_auth_ios/example/ios/Podfile b/packages/local_auth/local_auth_ios/example/ios/Podfile new file mode 100644 index 000000000000..f7d6a5e68c3a --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Podfile @@ -0,0 +1,38 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000000..6e315792cb90 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,611 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */; }; + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 3398D2D226163948005A052F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3398D2CD26163948005A052F /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3398D2D126163948005A052F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 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; }; + 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTLocalAuthPluginTests.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 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 = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + EB36DF6C3F25E00DF4175422 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3398D2CA26163948005A052F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BF11D226680B2E002967F3 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */, + 3398D2D126163948005A052F /* Info.plist */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 33BF11D226680B2E002967F3 /* RunnerTests */, + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + F8CC53B854B121315C7319D2 /* Pods */, + E2D5FA899A019BD3E0DB0917 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 3398D2CD26163948005A052F /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + E2D5FA899A019BD3E0DB0917 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3398D2DF26164A03005A052F /* liblocal_auth.a */, + 3398D2DC261649CD005A052F /* liblocal_auth.a */, + 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + F8CC53B854B121315C7319D2 /* Pods */ = { + isa = PBXGroup; + children = ( + EB36DF6C3F25E00DF4175422 /* Pods-Runner.debug.xcconfig */, + 658CDD04B21E4EA92F8EF229 /* Pods-Runner.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3398D2CC26163948005A052F /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 3398D2C926163948005A052F /* Sources */, + 3398D2CA26163948005A052F /* Frameworks */, + 3398D2CB26163948005A052F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 3398D2D326163948005A052F /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 3398D2CD26163948005A052F /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 98D96A2D1A74AF66E3DD2DBC /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = "The Flutter Authors"; + TargetAttributes = { + 3398D2CC26163948005A052F = { + CreatedOnToolsVersion = 12.4; + ProvisioningStyle = Automatic; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 3398D2CC26163948005A052F /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3398D2CB26163948005A052F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + 98D96A2D1A74AF66E3DD2DBC /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3398D2C926163948005A052F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 3398D2D326163948005A052F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 3398D2D226163948005A052F /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3398D2D526163948005A052F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = RunnerTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Debug; + }; + 3398D2D626163948005A052F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = RunnerTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Release; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.localAuthExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.localAuthExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3398D2D526163948005A052F /* Debug */, + 3398D2D626163948005A052F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000000..919434a6254f --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000000..b2af55dd6d37 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000000..21a3cc14c74e --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h new file mode 100644 index 000000000000..0681d288bb70 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h @@ -0,0 +1,10 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m new file mode 100644 index 000000000000..30b87969f44a --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m @@ -0,0 +1,17 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000000..d22f10b2ab63 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,116 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..28c6bf03016f6c994b70f38d1b7346e5831b531f GIT binary patch literal 564 zcmV-40?Yl0P)Px$?ny*JR5%f>l)FnDQ543{x%ZCiu33$Wg!pQFfT_}?5Q|_VSlIbLC`dpoMXL}9 zHfd9&47Mo(7D231gb+kjFxZHS4-m~7WurTH&doVX2KI5sU4v(sJ1@T9eCIKPjsqSr z)C01LsCxk=72-vXmX}CQD#BD;Cthymh&~=f$Q8nn0J<}ZrusBy4PvRNE}+1ceuj8u z0mW5k8fmgeLnTbWHGwfKA3@PdZxhn|PypR&^p?weGftrtCbjF#+zk_5BJh7;0`#Wr zgDpM_;Ax{jO##IrT`Oz;MvfwGfV$zD#c2xckpcXC6oou4ML~ezCc2EtnsQTB4tWNg z?4bkf;hG7IMfhgNI(FV5Gs4|*GyMTIY0$B=_*mso9Ityq$m^S>15>-?0(zQ<8Qy<_TjHE33(?_M8oaM zyc;NxzRVK@DL6RJnX%U^xW0Gpg(lXp(!uK1v0YgHjs^ZXSQ|m#lV7ip7{`C_J2TxPmfw%h$|%acrYHt)Re^PB%O&&=~a zhS(%I#+V>J-vjIib^<+s%ludY7y^C(P8nmqn9fp!i+?vr`bziDE=bx`%2W#Xyrj|i z!XQ4v1%L`m{7KT7q+LZNB^h8Ha2e=`Wp65^0;J00)_^G=au=8Yo;1b`CV&@#=jIBo zjN^JNVfYSs)+kDdGe7`1&8!?MQYKS?DuHZf3iogk_%#9E|5S zWeHrmAo>P;ejX7mwq#*}W25m^ZI+{(Z8fI?4jM_fffY0nok=+88^|*_DwcW>mR#e+ zX$F_KMdb6sRz!~7KkyN0G(3XQ+;z3X%PZ4gh;n-%62U<*VUKNv(D&Q->Na@Xb&u5Q3`3DGf+a8O5x7c#7+R+EAYl@R5us)CIw z7sT@_y~Ao@uL#&^LIh&QceqiT^+lb0YbFZt_SHOtWA%mgPEKVNvVgCsXy{5+zl*X8 zCJe)Q@y>wH^>l4;h1l^Y*9%-23TSmE>q5nI@?mt%n;Sj4Qq`Z+ib)a*a^cJc%E9^J zB;4s+K@rARbcBLT5P=@r;IVnBMKvT*)ew*R;&8vu%?Z&S>s?8?)3*YawM0P4!q$Kv zMmKh3lgE~&w&v%wVzH3Oe=jeNT=n@Y6J6TdHWTjXfX~-=1A1Bw`EW8rn}MqeI34nh zexFeA?&C3B2(E?0{drE@DA2pu(A#ElY&6el60Rn|Qpn-FkfQ8M93AfWIr)drgDFEU zghdWK)^71EWCP(@(=c4kfH1Y(4iugD4fve6;nSUpLT%!)MUHs1!zJYy4y||C+SwQ! z)KM&$7_tyM`sljP2fz6&Z;jxRn{Wup8IOUx8D4uh&(=O zx-7$a;U><*5L^!%xRlw)vAbh;sdlR||& ze}8_8%)c2Fwy=F&H|LM+p{pZB5DKTx>Y?F1N%BlZkXf!}JeGuMZk~LPi7{cidvUGB zAJ4LVeNV%XO>LTrklB#^-;8nb;}6l;1oW&WS=Mz*Az!4cqqQzbOSFq`$Q%PfD7srM zpKgP-D_0XPTRX*hAqeq0TDkJ;5HB1%$3Np)99#16c{ zJImlNL(npL!W|Gr_kxl1GVmF5&^$^YherS7+~q$p zt}{a=*RiD2Ikv6o=IM1kgc7zqpaZ;OB)P!1zz*i3{U()Dq#jG)egvK}@uFLa`oyWZ zf~=MV)|yJn`M^$N%ul5);JuQvaU1r2wt(}J_Qgyy`qWQI`hEeRX0uC@c1(dQ2}=U$ tNIIaX+dr)NRWXcxoR{>fqI{SF_dm1Ylv~=3YHI)h002ovPDHLkV1g(pWS;;4 literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..f091b6b0bca859a3f474b03065bef75ba58a9e4c GIT binary patch literal 1588 zcmV-42Fv-0P)C1SqPt}wig>|5Crh^=oyX$BK<}M8eLU3e2hGT;=G|!_SP)7zNI6fqUMB=)y zRAZ>eDe#*r`yDAVgB_R*LB*MAc)8(b{g{9McCXW!lq7r(btRoB9!8B-#AI6JMb~YFBEvdsV)`mEQO^&#eRKx@b&x- z5lZm*!WfD8oCLzfHGz#u7sT0^VLMI1MqGxF^v+`4YYnVYgk*=kU?HsSz{v({E3lb9 z>+xILjBN)t6`=g~IBOelGQ(O990@BfXf(DRI5I$qN$0Gkz-FSc$3a+2fX$AedL4u{ z4V+5Ong(9LiGcIKW?_352sR;LtDPmPJXI{YtT=O8=76o9;*n%_m|xo!i>7$IrZ-{l z-x3`7M}qzHsPV@$v#>H-TpjDh2UE$9g6sysUREDy_R(a)>=eHw-WAyfIN z*qb!_hW>G)Tu8nSw9yn#3wFMiLcfc4pY0ek1}8(NqkBR@t4{~oC>ryc-h_ByH(Cg5 z>ao-}771+xE3um9lWAY1FeQFxowa1(!J(;Jg*wrg!=6FdRX+t_<%z&d&?|Bn){>zm zZQj(aA_HeBY&OC^jj*)N`8fa^ePOU72VpInJoI1?`ty#lvlNzs(&MZX+R%2xS~5Kh zX*|AU4QE#~SgPzOXe9>tRj>hjU@c1k5Y_mW*Jp3fI;)1&g3j|zDgC+}2Q_v%YfDax z!?umcN^n}KYQ|a$Lr+51Nf9dkkYFSjZZjkma$0KOj+;aQ&721~t7QUKx61J3(P4P1 zstI~7-wOACnWP4=8oGOwz%vNDqD8w&Q`qcNGGrbbf&0s9L0De{4{mRS?o0MU+nR_! zrvshUau0G^DeMhM_v{5BuLjb#Hh@r23lDAk8oF(C+P0rsBpv85EP>4CVMx#04MOfG z;P%vktHcXwTj~+IE(~px)3*MY77e}p#|c>TD?sMatC0Tu4iKKJ0(X8jxQY*gYtxsC z(zYC$g|@+I+kY;dg_dE>scBf&bP1Nc@Hz<3R)V`=AGkc;8CXqdi=B4l2k|g;2%#m& z*jfX^%b!A8#bI!j9-0Fi0bOXl(-c^AB9|nQaE`*)Hw+o&jS9@7&Gov#HbD~#d{twV zXd^Tr^mWLfFh$@Dr$e;PBEz4(-2q1FF0}c;~B5sA}+Q>TOoP+t>wf)V9Iy=5ruQa;z)y zI9C9*oUga6=hxw6QasLPnee@3^Rr*M{CdaL5=R41nLs(AHk_=Y+A9$2&H(B7!_pURs&8aNw7?`&Z&xY_Ye z)~D5Bog^td-^QbUtkTirdyK^mTHAOuptDflut!#^lnKqU md>ggs(5nOWAqO?umG&QVYK#ibz}*4>0000U6E9hRK9^#O7(mu>ETqrXGsduA8$)?`v2seloOCza43C{NQ$$gAOH**MCn0Q?+L7dl7qnbRdqZ8LSVp1ItDxhxD?t@5_yHg6A8yI zC*%Wgg22K|8E#!~cTNYR~@Y9KepMPrrB8cABapAFa=`H+UGhkXUZV1GnwR1*lPyZ;*K(i~2gp|@bzp8}og7e*#% zEnr|^CWdVV!-4*Y_7rFvlww2Ze+>j*!Z!pQ?2l->4q#nqRu9`ELo6RMS5=br47g_X zRw}P9a7RRYQ%2Vsd0Me{_(EggTnuN6j=-?uFS6j^u69elMypu?t>op*wBx<=Wx8?( ztpe^(fwM6jJX7M-l*k3kEpWOl_Vk3@(_w4oc}4YF4|Rt=2V^XU?#Yz`8(e?aZ@#li0n*=g^qOcVpd-Wbok=@b#Yw zqn8u9a)z>l(1kEaPYZ6hwubN6i<8QHgsu0oE) ziJ(p;Wxm>sf!K+cw>R-(^Y2_bahB+&KI9y^);#0qt}t-$C|Bo71lHi{_+lg#f%RFy z0um=e3$K3i6K{U_4K!EX?F&rExl^W|G8Z8;`5z-k}OGNZ0#WVb$WCpQu-_YsiqKP?BB# vzVHS-CTUF4Ozn5G+mq_~Qqto~ahA+K`|lyv3(-e}00000NkvXXu0mjfd`9t{ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0ef06e7edb86cdfe0d15b4b0d98334a86163658 GIT binary patch literal 1716 zcmds$`#;kQ7{|XelZftyR5~xW7?MLxS4^|Hw3&P7^y)@A9Fj{Xm1~_CIV^XZ%SLBn zA;!r`GqGHg=7>xrB{?psZQs88ZaedDoagm^KF{a*>G|dJWRSe^I$DNW008I^+;Kjt z>9p3GNR^I;v>5_`+91i(*G;u5|L+Bu6M=(afLjtkya#yZ175|z$pU~>2#^Z_pCZ7o z1c6UNcv2B3?; zX%qdxCXQpdKRz=#b*q0P%b&o)5ZrNZt7$fiETSK_VaY=mb4GK`#~0K#~9^ zcY!`#Af+4h?UMR-gMKOmpuYeN5P*RKF!(tb`)oe0j2BH1l?=>y#S5pMqkx6i{*=V9JF%>N8`ewGhRE(|WohnD59R^$_36{4>S zDFlPC5|k?;SPsDo87!B{6*7eqmMdU|QZ84>6)Kd9wNfh90=y=TFQay-0__>=<4pk& zYDjgIhL-jQ9o>z32K)BgAH+HxamL{ZL~ozu)Qqe@a`FpH=oQRA8=L-m-1dam(Ix2V z?du;LdMO+ooBelr^_y4{|44tmgH^2hSzPFd;U^!1p>6d|o)(-01z{i&Kj@)z-yfWQ)V#3Uo!_U}q3u`(fOs`_f^ueFii1xBNUB z6MecwJN$CqV&vhc+)b(p4NzGGEgwWNs z@*lUV6LaduZH)4_g!cE<2G6#+hJrWd5(|p1Z;YJ7ifVHv+n49btR}dq?HHDjl{m$T z!jLZcGkb&XS2OG~u%&R$(X+Z`CWec%QKt>NGYvd5g20)PU(dOn^7%@6kQb}C(%=vr z{?RP(z~C9DPnL{q^@pVw@|Vx~@3v!9dCaBtbh2EdtoNHm4kGxp>i#ct)7p|$QJs+U z-a3qtcPvhihub?wnJqEt>zC@)2suY?%-96cYCm$Q8R%-8$PZYsx3~QOLMDf(piXMm zB=<63yQk1AdOz#-qsEDX>>c)EES%$owHKue;?B3)8aRd}m~_)>SL3h2(9X;|+2#7X z+#2)NpD%qJvCQ0a-uzZLmz*ms+l*N}w)3LRQ*6>|Ub-fyptY(keUxw+)jfwF5K{L9 z|Cl_w=`!l_o><384d&?)$6Nh(GAm=4p_;{qVn#hI8lqewW7~wUlyBM-4Z|)cZr?Rh z=xZ&Ol>4(CU85ea(CZ^aO@2N18K>ftl8>2MqetAR53_JA>Fal`^)1Y--Am~UDa4th zKfCYpcXky$XSFDWBMIl(q=Mxj$iMBX=|j9P)^fDmF(5(5$|?Cx}DKEJa&XZP%OyE`*GvvYQ4PV&!g2|L^Q z?YG}tx;sY@GzMmsY`7r$P+F_YLz)(e}% zyakqFB<6|x9R#TdoP{R$>o7y(-`$$p0NxJ6?2B8tH)4^yF(WhqGZlM3=9Ibs$%U1w zWzcss*_c0=v_+^bfb`kBFsI`d;ElwiU%frgRB%qBjn@!0U2zZehBn|{%uNIKBA7n= zzE`nnwTP85{g;8AkYxA68>#muXa!G>xH22D1I*SiD~7C?7Za+9y7j1SHiuSkKK*^O zsZ==KO(Ua#?YUpXl{ViynyT#Hzk=}5X$e04O@fsMQjb}EMuPWFO0e&8(2N(29$@Vd zn1h8Yd>6z(*p^E{c(L0Lg=wVdupg!z@WG;E0k|4a%s7Up5C0c)55XVK*|x9RQeZ1J@1v9MX;>n34(i>=YE@Iur`0Vah(inE3VUFZNqf~tSz{1fz3Fsn_x4F>o(Yo;kpqvBe-sbwH(*Y zu$JOl0b83zu$JMvy<#oH^Wl>aWL*?aDwnS0iEAwC?DK@aT)GHRLhnz2WCvf3Ba;o=aY7 z2{Asu5MEjGOY4O#Ggz@@J;q*0`kd2n8I3BeNuMmYZf{}pg=jTdTCrIIYuW~luKecn z+E-pHY%ohj@uS0%^ z&(OxwPFPD$+#~`H?fMvi9geVLci(`K?Kj|w{rZ9JgthFHV+=6vMbK~0)Ea<&WY-NC zy-PnZft_k2tfeQ*SuC=nUj4H%SQ&Y$gbH4#2sT0cU0SdFs=*W*4hKGpuR1{)mV;Qf5pw4? zfiQgy0w3fC*w&Bj#{&=7033qFR*<*61B4f9K%CQvxEn&bsWJ{&winp;FP!KBj=(P6 z4Z_n4L7cS;ao2)ax?Tm|I1pH|uLpDSRVghkA_UtFFuZ0b2#>!8;>-_0ELjQSD-DRd z4im;599VHDZYtnWZGAB25W-e(2VrzEh|etsv2YoP#VbIZ{aFkwPrzJ#JvCvA*mXS& z`}Q^v9(W4GiSs}#s7BaN!WA2bniM$0J(#;MR>uIJ^uvgD3GS^%*ikdW6-!VFUU?JV zZc2)4cMsX@j z5HQ^e3BUzOdm}yC-xA%SY``k$rbfk z;CHqifhU*jfGM@DkYCecD9vl*qr58l6x<8URB=&%{!Cu3RO*MrKZ4VO}V6R0a zZw3Eg^0iKWM1dcTYZ0>N899=r6?+adUiBKPciJw}L$=1f4cs^bio&cr9baLF>6#BM z(F}EXe-`F=f_@`A7+Q&|QaZ??Txp_dB#lg!NH=t3$G8&06MFhwR=Iu*Im0s_b2B@| znW>X}sy~m#EW)&6E&!*0%}8UAS)wjt+A(io#wGI@Z2S+Ms1Cxl%YVE800007ip7{`C_J2TxPmfw%h$|%acrYHt)Re^PB%O&&=~a zhS(%I#+V>J-vjIib^<+s%ludY7y^C(P8nmqn9fp!i+?vr`bziDE=bx`%2W#Xyrj|i z!XQ4v1%L`m{7KT7q+LZNB^h8Ha2e=`Wp65^0;J00)_^G=au=8Yo;1b`CV&@#=jIBo zjN^JNVfYSs)+kDdGe7`1&8!?MQYKS?DuHZf3iogk_%#9E|5S zWeHrmAo>P;ejX7mwq#*}W25m^ZI+{(Z8fI?4jM_fffY0nok=+88^|*_DwcW>mR#e+ zX$F_KMdb6sRz!~7KkyN0G(3XQ+;z3X%PZ4gh;n-%62U<*VUKNv(D&Q->Na@Xb&u5Q3`3DGf+a8O5x7c#7+R+EAYl@R5us)CIw z7sT@_y~Ao@uL#&^LIh&QceqiT^+lb0YbFZt_SHOtWA%mgPEKVNvVgCsXy{5+zl*X8 zCJe)Q@y>wH^>l4;h1l^Y*9%-23TSmE>q5nI@?mt%n;Sj4Qq`Z+ib)a*a^cJc%E9^J zB;4s+K@rARbcBLT5P=@r;IVnBMKvT*)ew*R;&8vu%?Z&S>s?8?)3*YawM0P4!q$Kv zMmKh3lgE~&w&v%wVzH3Oe=jeNT=n@Y6J6TdHWTjXfX~-=1A1Bw`EW8rn}MqeI34nh zexFeA?&C3B2(E?0{drE@DA2pu(A#ElY&6el60Rn|Qpn-FkfQ8M93AfWIr)drgDFEU zghdWK)^71EWCP(@(=c4kfH1Y(4iugD4fve6;nSUpLT%!)MUHs1!zJYy4y||C+SwQ! z)KM&$7_tyM`sljP2fz6&Z;jxRn{Wup8IOUx8D4uh&(=O zx-7$a;U><*5L^!%xRlw)vAbh;sdlR||& ze}8_8%)c2Fwy=F&H|LM+p{pZB5DKTx>Y?F1N%BlZkXf!}JeGuMZk~LPi7{cidvUGB zAJ4LVeNV%XO>LTrklB#^-;8nb;}6l;1oW&WS=Mz*Az!4cqqQzbOSFq`$Q%PfD7srM zpKgP-D_0XPTRX*hAqeq0TDkJ;5HB1%$3Np)99#16c{ zJImlNL(npL!W|Gr_kxl1GVmF5&^$^YherS7+~q$p zt}{a=*RiD2Ikv6o=IM1kgc7zqpaZ;OB)P!1zz*i3{U()Dq#jG)egvK}@uFLa`oyWZ zf~=MV)|yJn`M^$N%ul5);JuQvaU1r2wt(}J_Qgyy`qWQI`hEeRX0uC@c1(dQ2}=U$ tNIIaX+dr)NRWXcxoR{>fqI{SF_dm1Ylv~=3YHI)h002ovPDHLkV1g(pWS;;4 literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f9ed8f5cee1c98386d13b17e89f719e83555b2 GIT binary patch literal 1895 zcmV-t2blPYP)FQtfgmafE#=YDCq`qUBt#QpG%*H6QHY765~R=q zZ6iudfM}q!Pz#~9JgOi8QJ|DSu?1-*(kSi1K4#~5?#|rh?sS)(-JQqX*}ciXJ56_H zdw=^s_srbAdqxlvGyrgGet#6T7_|j;95sL%MtM;q86vOxKM$f#puR)Bjv9Zvz9-di zXOTSsZkM83)E9PYBXC<$6(|>lNLVBb&&6y{NByFCp%6+^ALR@NCTse_wqvNmSWI-m z!$%KlHFH2omF!>#%1l3LTZg(s7eof$7*xB)ZQ0h?ejh?Ta9fDv59+u#MokW+1t8Zb zgHv%K(u9G^Lv`lh#f3<6!JVTL3(dCpxHbnbA;kKqQyd1~^Xe0VIaYBSWm6nsr;dFj z4;G-RyL?cYgsN1{L4ZFFNa;8)Rv0fM0C(~Tkit94 zz#~A)59?QjD&pAPSEQ)p8gP|DS{ng)j=2ux)_EzzJ773GmQ_Cic%3JJhC0t2cx>|v zJcVusIB!%F90{+}8hG3QU4KNeKmK%T>mN57NnCZ^56=0?&3@!j>a>B43pi{!u z7JyDj7`6d)qVp^R=%j>UIY6f+3`+qzIc!Y_=+uN^3BYV|o+$vGo-j-Wm<10%A=(Yk^beI{t%ld@yhKjq0iNjqN4XMGgQtbKubPM$JWBz}YA65k%dm*awtC^+f;a-x4+ddbH^7iDWGg&N0n#MW{kA|=8iMUiFYvMoDY@sPC#t$55gn6ykUTPAr`a@!(;np824>2xJthS z*ZdmT`g5-`BuJs`0LVhz+D9NNa3<=6m;cQLaF?tCv8)zcRSh66*Z|vXhG@$I%U~2l z?`Q zykI#*+rQ=z6Jm=Bui-SfpDYLA=|vzGE(dYm=OC8XM&MDo7ux4UF1~0J1+i%aCUpRe zt3L_uNyQ*cE(38Uy03H%I*)*Bh=Lb^Xj3?I^Hnbeq72(EOK^Y93CNp*uAA{5Lc=ky zx=~RKa4{iTm{_>_vSCm?$Ej=i6@=m%@VvAITnigVg{&@!7CDgs908761meDK5azA} z4?=NOH|PdvabgJ&fW2{Mo$Q0CcD8Qc84%{JPYt5EiG{MdLIAeX%T=D7NIP4%Hw}p9 zg)==!2Lbp#j{u_}hMiao9=!VSyx0gHbeCS`;q&vzeq|fs`y&^X-lso(Ls@-706qmA z7u*T5PMo_w3{se1t2`zWeO^hOvTsohG_;>J0wVqVe+n)AbQCx)yh9;w+J6?NF5Lmo zecS@ieAKL8%bVd@+-KT{yI|S}O>pYckUFs;ry9Ow$CD@ztz5K-*D$^{i(_1llhSh^ zEkL$}tsQt5>QA^;QgjgIfBDmcOgi5YDyu?t6vSnbp=1+@6D& z5MJ}B8q;bRlVoxasyhcUF1+)o`&3r0colr}QJ3hcSdLu;9;td>kf@Tcn<@9sIx&=m z;AD;SCh95=&p;$r{Xz3iWCO^MX83AGJ(yH&eTXgv|0=34#-&WAmw{)U7OU9!Wz^!7 zZ%jZFi@JR;>Mhi7S>V7wQ176|FdW2m?&`qa(ScO^CFPR80HucLHOTy%5s*HR0^8)i h0WYBP*#0Ks^FNSabJA*5${_#%002ovPDHLkV1oKhTl@e3 literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 GIT binary patch literal 2665 zcmV-v3YPVWP)oFh3q0MFesq&64WThn3$;G69TfjsAv=f2G9}p zgSx99+!YV6qME!>9MD13x)k(+XE7W?_O4LoLb5ND8 zaV{9+P@>42xDfRiYBMSgD$0!vssptcb;&?u9u(LLBKmkZ>RMD=kvD3h`sk6!QYtBa ztlZI#nu$8lJ^q2Z79UTgZe>BU73(Aospiq+?SdMt8lDZ;*?@tyWVZVS_Q7S&*tJaiRlJ z+aSMOmbg3@h5}v;A*c8SbqM3icg-`Cnwl;7Ts%A1RkNIp+Txl-Ckkvg4oxrqGA5ewEgYqwtECD<_3Egu)xGllKt&J8g&+=ac@Jq4-?w6M3b*>w5 z69N3O%=I^6&UL5gZ!}trC7bUj*12xLdkNs~Bz4QdJJ*UDZox2UGR}SNg@lmOvhCc~ z*f_UeXv(=#I#*7>VZx2ObEN~UoGUTl=-@)E;YtCRZ>SVp$p9yG5hEFZ!`wI!spd)n zSk+vK0Vin7FL{7f&6OB%f;SH22dtbcF<|9fi2Fp%q4kxL!b1#l^)8dUwJ zwEf{(wJj@8iYDVnKB`eSU+;ml-t2`@%_)0jDM`+a46xhDbBj2+&Ih>1A>6aky#(-SYyE{R3f#y57wfLs z6w1p~$bp;6!9DX$M+J~S@D6vJAaElETnsX4h9a5tvPhC3L@qB~bOzkL@^z0k_hS{T4PF*TDrgdXp+dzsE? z>V|VR035Pl9n5&-RePFdS{7KAr2vPOqR9=M$vXA1Yy5>w;EsF`;OK{2pkn-kpp9Pw z)r;5JfJKKaT$4qCb{TaXHjb$QA{y0EYy*+b1XI;6Ah- zw13P)xT`>~eFoJC!>{2XL(a_#upp3gaR1#5+L(Jmzp4TBnx{~WHedpJ1ch8JFk~Sw z>F+gN+i+VD?gMXwcIhn8rz`>e>J^TI3E-MW>f}6R-pL}>WMOa0k#jN+`RyUVUC;#D zg|~oS^$6%wpF{^Qr+}X>0PKcr3Fc&>Z>uv@C);pwDs@2bZWhYP!rvGx?_|q{d`t<*XEb#=aOb=N+L@CVBGqImZf&+a zCQEa3$~@#kC);pasdG=f6tuIi0PO-y&tvX%>Mv=oY3U$nD zJ#gMegnQ46pq+3r=;zmgcG+zRc9D~c>z+jo9&D+`E6$LmyFqlmCYw;-Zooma{sR@~ z)_^|YL1&&@|GXo*pivH7k!msl+$Sew3%XJnxajt0K%3M6Bd&YFNy9}tWG^aovK2eX z1aL1%7;KRDrA@eG-Wr6w+;*H_VD~qLiVI`{_;>o)k`{8xa3EJT1O_>#iy_?va0eR? zDV=N%;Zjb%Z2s$@O>w@iqt!I}tLjGk!=p`D23I}N4Be@$(|iSA zf3Ih7b<{zqpDB4WF_5X1(peKe+rASze%u8eKLn#KKXt;UZ+Adf$_TO+vTqshLLJ5c z52HucO=lrNVae5XWOLm!V@n-ObU11!b+DN<$RuU+YsrBq*lYT;?AwJpmNKniF0Q1< zJCo>Q$=v$@&y=sj6{r!Y&y&`0$-I}S!H_~pI&2H8Z1C|BX4VgZ^-! zje3-;x0PBD!M`v*J_)rL^+$<1VJhH*2Fi~aA7s&@_rUHYJ9zD=M%4AFQ`}k8OC$9s XsPq=LnkwKG00000NkvXXu0mjfhAk5^ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 GIT binary patch literal 2665 zcmV-v3YPVWP)oFh3q0MFesq&64WThn3$;G69TfjsAv=f2G9}p zgSx99+!YV6qME!>9MD13x)k(+XE7W?_O4LoLb5ND8 zaV{9+P@>42xDfRiYBMSgD$0!vssptcb;&?u9u(LLBKmkZ>RMD=kvD3h`sk6!QYtBa ztlZI#nu$8lJ^q2Z79UTgZe>BU73(Aospiq+?SdMt8lDZ;*?@tyWVZVS_Q7S&*tJaiRlJ z+aSMOmbg3@h5}v;A*c8SbqM3icg-`Cnwl;7Ts%A1RkNIp+Txl-Ckkvg4oxrqGA5ewEgYqwtECD<_3Egu)xGllKt&J8g&+=ac@Jq4-?w6M3b*>w5 z69N3O%=I^6&UL5gZ!}trC7bUj*12xLdkNs~Bz4QdJJ*UDZox2UGR}SNg@lmOvhCc~ z*f_UeXv(=#I#*7>VZx2ObEN~UoGUTl=-@)E;YtCRZ>SVp$p9yG5hEFZ!`wI!spd)n zSk+vK0Vin7FL{7f&6OB%f;SH22dtbcF<|9fi2Fp%q4kxL!b1#l^)8dUwJ zwEf{(wJj@8iYDVnKB`eSU+;ml-t2`@%_)0jDM`+a46xhDbBj2+&Ih>1A>6aky#(-SYyE{R3f#y57wfLs z6w1p~$bp;6!9DX$M+J~S@D6vJAaElETnsX4h9a5tvPhC3L@qB~bOzkL@^z0k_hS{T4PF*TDrgdXp+dzsE? z>V|VR035Pl9n5&-RePFdS{7KAr2vPOqR9=M$vXA1Yy5>w;EsF`;OK{2pkn-kpp9Pw z)r;5JfJKKaT$4qCb{TaXHjb$QA{y0EYy*+b1XI;6Ah- zw13P)xT`>~eFoJC!>{2XL(a_#upp3gaR1#5+L(Jmzp4TBnx{~WHedpJ1ch8JFk~Sw z>F+gN+i+VD?gMXwcIhn8rz`>e>J^TI3E-MW>f}6R-pL}>WMOa0k#jN+`RyUVUC;#D zg|~oS^$6%wpF{^Qr+}X>0PKcr3Fc&>Z>uv@C);pwDs@2bZWhYP!rvGx?_|q{d`t<*XEb#=aOb=N+L@CVBGqImZf&+a zCQEa3$~@#kC);pasdG=f6tuIi0PO-y&tvX%>Mv=oY3U$nD zJ#gMegnQ46pq+3r=;zmgcG+zRc9D~c>z+jo9&D+`E6$LmyFqlmCYw;-Zooma{sR@~ z)_^|YL1&&@|GXo*pivH7k!msl+$Sew3%XJnxajt0K%3M6Bd&YFNy9}tWG^aovK2eX z1aL1%7;KRDrA@eG-Wr6w+;*H_VD~qLiVI`{_;>o)k`{8xa3EJT1O_>#iy_?va0eR? zDV=N%;Zjb%Z2s$@O>w@iqt!I}tLjGk!=p`D23I}N4Be@$(|iSA zf3Ih7b<{zqpDB4WF_5X1(peKe+rASze%u8eKLn#KKXt;UZ+Adf$_TO+vTqshLLJ5c z52HucO=lrNVae5XWOLm!V@n-ObU11!b+DN<$RuU+YsrBq*lYT;?AwJpmNKniF0Q1< zJCo>Q$=v$@&y=sj6{r!Y&y&`0$-I}S!H_~pI&2H8Z1C|BX4VgZ^-! zje3-;x0PBD!M`v*J_)rL^+$<1VJhH*2Fi~aA7s&@_rUHYJ9zD=M%4AFQ`}k8OC$9s XsPq=LnkwKG00000NkvXXu0mjfhAk5^ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..75b2d164a5a98e212cca15ea7bf2ab5de5108680 GIT binary patch literal 3831 zcmVjJBgitF5mAp-i>4+KS_oR{|13AP->1TD4=w)g|)JHOx|a2Wk1Va z!k)vP$UcQ#mdj%wNQoaJ!w>jv_6&JPyutpQps?s5dmDQ>`%?Bvj>o<%kYG!YW6H-z zu`g$@mp`;qDR!51QaS}|ZToSuAGcJ7$2HF0z`ln4t!#Yg46>;vGG9N9{V@9z#}6v* zfP?}r6b{*-C*)(S>NECI_E~{QYzN5SXRmVnP<=gzP+_Sp(Aza_hKlZ{C1D&l*(7IKXxQC1Z9#6wx}YrGcn~g%;icdw>T0Rf^w0{ z$_wn1J+C0@!jCV<%Go5LA45e{5gY9PvZp8uM$=1}XDI+9m7!A95L>q>>oe0$nC->i zeexUIvq%Uk<-$>DiDb?!In)lAmtuMWxvWlk`2>4lNuhSsjAf2*2tjT`y;@d}($o)S zn(+W&hJ1p0xy@oxP%AM15->wPLp{H!k)BdBD$toBpJh+crWdsNV)qsHaqLg2_s|Ih z`8E9z{E3sA!}5aKu?T!#enD(wLw?IT?k-yWVHZ8Akz4k5(TZJN^zZgm&zM28sfTD2BYJ|Fde3Xzh;;S` z=GXTnY4Xc)8nYoz6&vF;P7{xRF-{|2Xs5>a5)@BrnQ}I(_x7Cgpx#5&Td^4Q9_FnQ zX5so*;#8-J8#c$OlA&JyPp$LKUhC~-e~Ij!L%uSMu!-VZG7Hx-L{m2DVR2i=GR(_% zCVD!4N`I)&Q5S`?P&fQZ=4#Dgt_v2-DzkT}K(9gF0L(owe-Id$Rc2qZVLqI_M_DyO z9@LC#U28_LU{;wGZ&))}0R2P4MhajKCd^K#D+JJ&JIXZ_p#@+7J9A&P<0kdRujtQ_ zOy>3=C$kgi6$0pW06KaLz!21oOryKM3ZUOWqppndxfH}QpgjEJ`j7Tzn5bk6K&@RA?vl##y z$?V~1E(!wB5rH`>3nc&@)|#<1dN2cMzzm=PGhQ|Yppne(C-Vlt450IXc`J4R0W@I7 zd1e5uW6juvO%ni(WX7BsKx3MLngO7rHO;^R5I~0^nE^9^E_eYLgiR9&KnJ)pBbfno zSVnW$0R+&6jOOsZ82}nJ126+c|%svPo;TeUku<2G7%?$oft zyaO;tVo}(W)VsTUhq^XmFi#2z%-W9a{7mXn{uzivYQ_d6b7VJG{77naW(vHt-uhnY zVN#d!JTqVh(7r-lhtXVU6o})aZbDt_;&wJVGl2FKYFBFpU-#9U)z#(A%=IVnqytR$SY-sO( z($oNE09{D^@OuYPz&w~?9>Fl5`g9u&ecFGhqX=^#fmR=we0CJw+5xna*@oHnkahk+ z9aWeE3v|An+O5%?4fA&$Fgu~H_YmqR!yIU!bFCk4!#pAj%(lI(A5n)n@Id#M)O9Yx zJU9oKy{sRAIV3=5>(s8n{8ryJ!;ho}%pn6hZKTKbqk=&m=f*UnK$zW3YQP*)pw$O* zIfLA^!-bmBl6%d_n$#tP8Zd_(XdA*z*WH|E_yILwjtI~;jK#v-6jMl^?<%Y%`gvpwv&cFb$||^v4D&V=aNy?NGo620jL3VZnA%s zH~I|qPzB~e(;p;b^gJr7Ure#7?8%F0m4vzzPy^^(q4q1OdthF}Fi*RmVZN1OwTsAP zn9CZP`FazX3^kG(KodIZ=Kty8DLTy--UKfa1$6XugS zk%6v$Kmxt6U!YMx0JQ)0qX*{CXwZZk$vEROidEc7=J-1;peNat!vS<3P-FT5po>iE z!l3R+<`#x|+_hw!HjQGV=8!q|76y8L7N8gP3$%0kfush|u0uU^?dKBaeRSBUpOZ0c z62;D&Mdn2}N}xHRFTRI?zRv=>=AjHgH}`2k4WK=#AHB)UFrR-J87GgX*x5fL^W2#d z=(%K8-oZfMO=i{aWRDg=FX}UubM4eotRDcn;OR#{3q=*?3mE3_oJ-~prjhxh%PgQT zyn)Qozaq0@o&|LEgS{Ind4Swsr;b`u185hZPOBLL<`d2%^Yp1?oL)=jnLi;Zo0ZDliTtQ^b5SmfIMe{T==zZkbvn$KTQGlbG8w}s@M3TZnde;1Am46P3juKb zl9GU&3F=q`>j!`?SyH#r@O59%@aMX^rx}Nxe<>NqpUp5=lX1ojGDIR*-D^SDuvCKF z?3$xG(gVUsBERef_YjPFl^rU9EtD{pt z0CXwpN7BN3!8>hajGaTVk-wl=9rxmfWtIhC{mheHgStLi^+Nz12a?4r(fz)?3A%at zMlvQmL<2-R)-@G1wJ0^zQK%mR=r4d{Y3fHp){nWXUL#|CqXl(+v+qDh>FkF9`eWrW zfr^D%LNfOcTNvtx0JXR35J0~Jpi2#P3Q&80w+nqNfc}&G0A~*)lGHKv=^FE+b(37|)zL;KLF>oiGfb(?&1 zV3XRu!Sw>@quKiab%g6jun#oZ%!>V#A%+lNc?q>6+VvyAn=kf_6z^(TZUa4Eelh{{ zqFX-#dY(EV@7l$NE&kv9u9BR8&Ojd#ZGJ6l8_BW}^r?DIS_rU2(XaGOK z225E@kH5Opf+CgD^{y29jD4gHbGf{1MD6ggQ&%>UG4WyPh5q_tb`{@_34B?xfSO*| zZv8!)q;^o-bz`MuxXk*G^}(6)ACb@=Lfs`Hxoh>`Y0NE8QRQ!*p|SH@{r8=%RKd4p z+#Ty^-0kb=-H-O`nAA3_6>2z(D=~Tbs(n8LHxD0`R0_ATFqp-SdY3(bZ3;VUM?J=O zKCNsxsgt@|&nKMC=*+ZqmLHhX1KHbAJs{nGVMs6~TiF%Q)P@>!koa$%oS zjXa=!5>P`vC-a}ln!uH1ooeI&v?=?v7?1n~P(wZ~0>xWxd_Aw;+}9#eULM7M8&E?Y zC-ZLhi3RoM92SXUb-5i-Lmt5_rfjE{6y^+24`y$1lywLyHO!)Boa7438K4#iLe?rh z2O~YGSgFUBH?og*6=r9rme=peP~ah`(8Zt7V)j5!V0KPFf_mebo3z95U8(up$-+EA^9dTRLq>Yl)YMBuch9%=e5B`Vnb>o zt03=kq;k2TgGe4|lGne&zJa~h(UGutjP_zr?a7~#b)@15XNA>Dj(m=gg2Q5V4-$)D|Q9}R#002ovPDHLkV1o7DH3k3x literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..c4df70d39da7941ef3f6dcb7f06a192d8dcb308d GIT binary patch literal 1888 zcmV-m2cP(fP)x~L`~4d)Rspd&<9kFh{hn*KP1LP0~$;u(LfAu zp%fx&qLBcRHx$G|3q(bv@+b;o0*D|jwD-Q9uQR(l*ST}s+uPgQ-MeFwZ#GS?b332? z&Tk$&_miXn3IGq)AmQ)3sisq{raD4(k*bHvpCe-TdWq^NRTEVM)i9xbgQ&ccnUVx* zEY%vS%gDcSg=!tuIK8$Th2_((_h^+7;R|G{n06&O2#6%LK`a}n?h_fL18btz<@lFG za}xS}u?#DBMB> zw^b($1Z)`9G?eP95EKi&$eOy@K%h;ryrR3la%;>|o*>CgB(s>dDcNOXg}CK9SPmD? zmr-s{0wRmxUnbDrYfRvnZ@d z6johZ2sMX{YkGSKWd}m|@V7`Degt-43=2M?+jR%8{(H$&MLLmS;-|JxnX2pnz;el1jsvqQz}pGSF<`mqEXRQ5sC4#BbwnB_4` zc5bFE-Gb#JV3tox9fp-vVEN{(tOCpRse`S+@)?%pz+zVJXSooTrNCUg`R6`hxwb{) zC@{O6MKY8tfZ5@!yy=p5Y|#+myRL=^{tc(6YgAnkg3I(Cd!r5l;|;l-MQ8B`;*SCE z{u)uP^C$lOPM z5d~UhKhRRmvv{LIa^|oavk1$QiEApSrP@~Jjbg`<*dW4TO?4qG%a%sTPUFz(QtW5( zM)lA+5)0TvH~aBaOAs|}?u2FO;yc-CZ1gNM1dAxJ?%m?YsGR`}-xk2*dxC}r5j$d* zE!#Vtbo69h>V4V`BL%_&$} z+oJAo@jQ^Tk`;%xw-4G>hhb&)B?##U+(6Fi7nno`C<|#PVA%$Y{}N-?(Gc$1%tr4Pc}}hm~yY#fTOe!@v9s-ik$dX~|ygArPhByaXn8 zpI^FUjNWMsTFKTP3X7m?UK)3m zp6rI^_zxRYrx6_QmhoWoDR`fp4R7gu6;gdO)!KexaoO2D88F9x#TM1(9Bn7g;|?|o z)~$n&Lh#hCP6_LOPD>a)NmhW})LADx2kq=X7}7wYRj-0?dXr&bHaRWCfSqvzFa=sn z-8^gSyn-RmH=BZ{AJZ~!8n5621GbUJV7Qvs%JNv&$%Q17s_X%s-41vAPfIR>;x0Wlqr5?09S>x#%Qkt>?(&XjFRY}*L6BeQ3 z<6XEBh^S7>AbwGm@XP{RkeEKj6@_o%oV?hDuUpUJ+r#JZO?!IUc;r0R?>mi)*ZpQ) z#((dn=A#i_&EQn|hd)N$#A*fjBFuiHcYvo?@y1 z5|fV=a^a~d!c-%ZbMNqkMKiSzM{Yq=7_c&1H!mXk60Uv32dV;vMg&-kQ)Q{+PFtwc zj|-uQ;b^gts??J*9VxxOro}W~Q9j4Em|zSRv)(WSO9$F$s=Ydu%Q+5DOid~lwk&we zY%W(Z@ofdwPHncEZzZgmqS|!gTj3wQq9rxQy+^eNYKr1mj&?tm@wkO*9@UtnRMG>c aR{jt9+;fr}hV%pg00001^@s67{VYS000c7NklQEG_j zup^)eW&WUIApqy$=APz8jE@awGp)!bsTjDbrJO`$x^ZR^dr;>)LW>{ zs70vpsD38v)19rI=GNk1b(0?Js9~rjsQsu*K;@SD40RB-3^gKU-MYC7G!Bw{fZsqp zih4iIi;Hr_xZ033Iu{sQxLS=}yBXgLMn40d++>aQ0#%8D1EbGZp7+ z5=mK?t31BkVYbGOxE9`i748x`YgCMwL$qMsChbSGSE1`p{nSmadR zcQ#R)(?!~dmtD0+D2!K zR9%!Xp1oOJzm(vbLvT^$IKp@+W2=-}qTzTgVtQ!#Y7Gxz}stUIm<1;oBQ^Sh2X{F4ibaOOx;5ZGSNK z0maF^@(UtV$=p6DXLgRURwF95C=|U8?osGhgOED*b z7woJ_PWXBD>V-NjQAm{~T%sjyJ{5tn2f{G%?J!KRSrrGvQ1(^`YLA5B!~eycY(e5_ z*%aa{at13SxC(=7JT7$IQF~R3sy`Nn%EMv!$-8ZEAryB*yB1k&stni)=)8-ODo41g zkJu~roIgAih94tb=YsL%iH5@^b~kU9M-=aqgXIrbtxMpFy5mekFm#edF9z7RQ6V}R zBIhbXs~pMzt0VWy1Fi$^fh+1xxLDoK09&5&MJl(q#THjPm(0=z2H2Yfm^a&E)V+a5 zbi>08u;bJsDRUKR9(INSc7XyuWv(JsD+BB*0hS)FO&l&7MdViuur@-<-EHw>kHRGY zqoT}3fDv2-m{NhBG8X}+rgOEZ;amh*DqN?jEfQdqxdj08`Sr=C-KmT)qU1 z+9Cl)a1mgXxhQiHVB}l`m;-RpmKy?0*|yl?FXvJkFxuu!fKlcmz$kN(a}i*saM3nr z0!;a~_%Xqy24IxA2rz<+08=B-Q|2PT)O4;EaxP^6qixOv7-cRh?*T?zZU`{nIM-at zTKYWr9rJ=tppQ9I#Z#mLgINVB!pO-^FOcvFw6NhV0gztuO?g ztoA*C-52Q-Z-P#xB4HAY3KQVd%dz1S4PA3vHp0aa=zAO?FCt zC_GaTyVBg2F!bBr3U@Zy2iJgIAt>1sf$JWA9kh{;L+P*HfUBX1Zy{4MgNbDfBV_ly z!y#+753arsZUt@366jIC0klaC@ckuk!qu=pAyf7&QmiBUT^L1&tOHzsK)4n|pmrVT zs2($4=?s~VejTFHbFdDOwG;_58LkIj1Fh@{glkO#F1>a==ymJS$z;gdedT1zPx4Kj ztjS`y_C}%af-RtpehdQDt3a<=W5C4$)9W@QAse;WUry$WYmr51ml9lkeunUrE`-3e zmq1SgSOPNEE-Mf+AGJ$g0M;3@w!$Ej;hMh=v=I+Lpz^n%Pg^MgwyqOkNyu2c^of)C z1~ALor3}}+RiF*K4+4{(1%1j3pif1>sv0r^mTZ?5Jd-It!tfPfiG_p$AY*Vfak%FG z4z#;wLtw&E&?}w+eKG^=#jF7HQzr8rV0mY<1YAJ_uGz~$E13p?F^fPSzXSn$8UcI$ z8er9{5w5iv0qf8%70zV71T1IBB1N}R5Kp%NO0=5wJalZt8;xYp;b{1K) zHY>2wW-`Sl{=NpR%iu3(u6l&)rc%%cSA#aV7WCowfbFR4wcc{LQZv~o1u_`}EJA3>ki`?9CKYTA!rhO)if*zRdd}Kn zEPfYbhoVE~!FI_2YbC5qAj1kq;xP6%J8+?2PAs?`V3}nyFVD#sV3+uP`pi}{$l9U^ zSz}_M9f7RgnnRhaoIJgT8us!1aB&4!*vYF07Hp&}L zCRlop0oK4DL@ISz{2_BPlezc;xj2|I z23RlDNpi9LgTG_#(w%cMaS)%N`e>~1&a3<{Xy}>?WbF>OOLuO+j&hc^YohQ$4F&ze z+hwnro1puQjnKm;vFG~o>`kCeUIlkA-2tI?WBKCFLMBY=J{hpSsQ=PDtU$=duS_hq zHpymHt^uuV1q@uc4bFb{MdG*|VoW@15Osrqt2@8ll0qO=j*uOXn{M0UJX#SUztui9FN4)K3{9!y8PC-AHHvpVTU;x|-7P+taAtyglk#rjlH2 z5Gq8ik}BPaGiM{#Woyg;*&N9R2{J0V+WGB69cEtH7F?U~Kbi6ksi*`CFXsi931q7Y zGO82?whBhN%w1iDetv%~wM*Y;E^)@Vl?VDj-f*RX>{;o_=$fU!&KAXbuadYZ46Zbg z&6jMF=49$uL^73y;;N5jaHYv)BTyfh&`qVLYn?`o6BCA_z-0niZz=qPG!vonK3MW_ zo$V96zM!+kJRs{P-5-rQVse0VBH*n6A58)4uc&gfHMa{gIhV2fGf{st>E8sKyP-$8zp~wJX^A*@DI&-;8>gANXZj zU)R+Y)PB?=)a|Kj>8NXEu^S_h^7R`~Q&7*Kn!xyvzVv&^>?^iu;S~R2e-2fJx-oUb cX)(b1KSk$MOV07*qoM6N<$f&6$jw%VRuvdN2+38CZWny1cRtlsl+0_KtW)EU14Ei(F!UtWuj4IK+3{sK@>rh zs1Z;=(DD&U6+tlyL?UnHVN^&g6QhFi2#HS+*qz;(>63G(`|jRtW|nz$Pv7qTovP!^ zP_jES{mr@O-02w%!^a?^1ZP!_KmQiz0L~jZ=W@Qt`8wzOoclQsAS<5YdH;a(4bGLE zk8s}1If(PSIgVi!XE!5kA?~z*sobvNyohr;=Q_@h2@$6Flyej3J)D-6YfheRGl`HEcPk|~huT_2-U?PfL=4BPV)f1o!%rQ!NMt_MYw-5bUSwQ9Z&zC>u zOrl~UJglJNa%f50Ok}?WB{on`Ci`p^Y!xBA?m@rcJXLxtrE0FhRF3d*ir>yzO|BD$ z3V}HpFcCh6bTzY}Nt_(W%QYd3NG)jJ4<`F<1Od) zfQblTdC&h2lCz`>y?>|9o2CdvC8qZeIZt%jN;B7Hdn2l*k4M4MFEtq`q_#5?}c$b$pf_3y{Y!cRDafZBEj-*OD|gz#PBDeu3QoueOesLzB+O zxjf2wvf6Wwz>@AiOo2mO4=TkAV+g~%_n&R;)l#!cBxjuoD$aS-`IIJv7cdX%2{WT7 zOm%5rs(wqyPE^k5SIpUZ!&Lq4<~%{*>_Hu$2|~Xa;iX*tz8~G6O3uFOS?+)tWtdi| zV2b#;zRN!m@H&jd=!$7YY6_}|=!IU@=SjvGDFtL;aCtw06U;-v^0%k0FOyESt z1Wv$={b_H&8FiRV?MrzoHWd>%v6KTRU;-v^Miiz+@q`(BoT!+<37CKhoKb)|8!+RG z6BQFU^@fRW;s8!mOf2QViKQGk0TVER6EG1`#;Nm39Do^PoT!+<37AD!%oJe86(=et zZ~|sLzU>V-qYiU6V8$0GmU7_K8|Fd0B?+9Un1BhKAz#V~Fk^`mJtlCX#{^8^M8!me z8Yg;8-~>!e<-iG;h*0B1kBKm}hItVGY6WnjVpgnTTAC$rqQ^v)4KvOtpY|sIj@WYg zyw##ZZ5AC2IKNC;^hwg9BPk0wLStlmBr;E|$5GoAo$&Ui_;S9WY62n3)i49|T%C#i017z3J=$RF|KyZWnci*@lW4 z=AKhNN6+m`Q!V3Ye68|8y@%=am>YD0nG99M)NWc20%)gwO!96j7muR}Fr&54SxKP2 zP30S~lt=a*qDlbu3+Av57=9v&vr<6g0&`!8E2fq>I|EJGKs}t|{h7+KT@)LfIV-3K zK)r_fr2?}FFyn*MYoLC>oV-J~eavL2ho4a4^r{E-8m2hi>~hA?_vIG4a*KT;2eyl1 zh_hUvUJpNCFwBvRq5BI*srSle>c6%n`#VNsyC|MGa{(P&08p=C9+WUw9Hl<1o9T4M zdD=_C0F7#o8A_bRR?sFNmU0R6tW`ElnF8p53IdHo#S9(JoZCz}fHwJ6F<&?qrpVqE zte|m%89JQD+XwaPU#%#lVs-@-OL);|MdfINd6!XwP2h(eyafTUsoRkA%&@fe?9m@jw-v(yTTiV2(*fthQH9}SqmsRPVnwwbV$1E(_lkmo&S zF-truCU914_$jpqjr(>Ha4HkM4YMT>m~NosUu&UZ>zirfHo%N6PPs9^_o$WqPA0#5 z%tG>qFCL+b*0s?sZ;Sht0nE7Kl>OVXy=gjWxxK;OJ3yGd7-pZf7JYNcZo2*1SF`u6 zHJyRRxGw9mDlOiXqVMsNe#WX`fC`vrtjSQ%KmLcl(lC>ZOQzG^%iql2w-f_K@r?OE zwCICifM#L-HJyc7Gm>Ern?+Sk3&|Khmu4(~3qa$(m6Ub^U0E5RHq49za|XklN#?kP zl;EstdW?(_4D>kwjWy2f!LM)y?F94kyU3`W!6+AyId-89v}sXJpuic^NLL7GJItl~ zsiuB98AI-(#Mnm|=A-R6&2fwJ0JVSY#Q>&3$zFh|@;#%0qeF=j5Ajq@4i0tIIW z&}sk$&fGwoJpe&u-JeGLi^r?dO`m=y(QO{@h zQqAC7$rvz&5+mo3IqE?h=a~6m>%r5Quapvzq;{y~p zJpyXOBgD9VrW7@#p6l7O?o3feml(DtSL>D^R) zZUY%T2b0-vBAFN7VB;M88!~HuOXi4KcI6aRQ&h|XQ0A?m%j2=l1f0cGP}h(oVfJ`N zz#PpmFC*ieab)zJK<4?^k=g%OjPnkANzbAbmGZHoVRk*mTfm75s_cWVa`l*f$B@xu z5E*?&@seIo#*Y~1rBm!7sF9~~u6Wrj5oICUOuz}CS)jdNIznfzCA(stJ(7$c^e5wN z?lt>eYgbA!kvAR7zYSD&*r1$b|(@;9dcZ^67R0 zXAXJKa|5Sdmj!g578Nwt6d$sXuc&MWezA0Whd`94$h{{?1IwXP4)Tx4obDK%xoFZ_Z zjjHJ_P@R_e5blG@yEjnaJb`l;s%Lb2&=8$&Ct-fV`E^4CUs)=jTk!I}2d&n!f@)bm z@ z_4Dc86+3l2*p|~;o-Sb~oXb_RuLmoifDU^&Te$*FevycC0*nE3Xws8gsWp|Rj2>SM zns)qcYj?^2sd8?N!_w~4v+f-HCF|a$TNZDoNl$I1Uq87euoNgKb6&r26TNrfkUa@o zfdiFA@p{K&mH3b8i!lcoz)V{n8Q@g(vR4ns4r6w;K z>1~ecQR0-<^J|Ndg5fvVUM9g;lbu-){#ghGw(fg>L zh)T5Ljb%lWE;V9L!;Cqk>AV1(rULYF07ZBJbGb9qbSoLAd;in9{)95YqX$J43-dY7YU*k~vrM25 zxh5_IqO0LYZW%oxQ5HOzmk4x{atE*vipUk}sh88$b2tn?!ujEHn`tQLe&vo}nMb&{ zio`xzZ&GG6&ZyN3jnaQy#iVqXE9VT(3tWY$n-)uWDQ|tc{`?fq2F`oQ{;d3aWPg4Hp-(iE{ry>MIPWL> iW8 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard b/packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000000..f3c28516fb38 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist b/packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist new file mode 100644 index 000000000000..f8e0356d0a68 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + local_auth_example + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + NSFaceIDUsageDescription + App needs to authenticate using faces. + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/main.m b/packages/local_auth/local_auth_ios/example/ios/Runner/main.m new file mode 100644 index 000000000000..f97b9ef5c8a1 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/main.m @@ -0,0 +1,13 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m new file mode 100644 index 000000000000..97e78e2f624b --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m @@ -0,0 +1,189 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@import LocalAuthentication; +@import XCTest; + +#import + +#if __has_include() +#import +#else +@import local_auth; +#endif + +// Private API needed for tests. +@interface FLTLocalAuthPlugin (Test) +- (void)setAuthContextOverrides:(NSArray*)authContexts; +@end + +// Set a long timeout to avoid flake due to slow CI. +static const NSTimeInterval kTimeout = 30.0; + +@interface FLTLocalAuthPluginTests : XCTestCase +@end + +@implementation FLTLocalAuthPluginTests + +- (void)setUp { + self.continueAfterFailure = NO; +} + +- (void)testSuccessfullAuthWithBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(YES, nil); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(YES), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertTrue([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +- (void)testSuccessfullAuthWithoutBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(YES, nil); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(NO), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertTrue([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +- (void)testFailedAuthWithBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(NO, [NSError errorWithDomain:@"error" code:99 userInfo:nil]); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(YES), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertFalse([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +- (void)testFailedAuthWithoutBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(NO, [NSError errorWithDomain:@"error" code:99 userInfo:nil]); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(NO), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertFalse([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +@end diff --git a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist new file mode 100644 index 000000000000..64d65ca49577 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart new file mode 100644 index 000000000000..df4a2efbeff3 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -0,0 +1,233 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:local_auth_ios/local_auth_ios.dart'; +import 'package:local_auth_ios/types/auth_strings_ios.dart'; + +void main() { + runApp(MyApp()); +} + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + final LocalAuthIOS auth = LocalAuthIOS(); + _SupportState _supportState = _SupportState.unknown; + bool? _canCheckBiometrics; + List? _availableBiometrics; + String _authorized = 'Not Authorized'; + bool _isAuthenticating = false; + + @override + void initState() { + super.initState(); + auth.isDeviceSupported().then( + (bool isSupported) => setState(() => _supportState = isSupported + ? _SupportState.supported + : _SupportState.unsupported), + ); + } + + Future _checkBiometrics() async { + late bool canCheckBiometrics; + try { + canCheckBiometrics = (await auth.getAvailableBiometrics()).isNotEmpty; + } on PlatformException catch (e) { + canCheckBiometrics = false; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _canCheckBiometrics = canCheckBiometrics; + }); + } + + Future _getAvailableBiometrics() async { + late List availableBiometrics; + try { + availableBiometrics = await auth.getAvailableBiometrics(); + } on PlatformException catch (e) { + availableBiometrics = []; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _availableBiometrics = availableBiometrics; + }); + } + + Future _authenticate() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: 'Let OS determine authentication method', + authStrings: IOSAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true, + ); + setState(() { + _isAuthenticating = false; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + setState( + () => _authorized = authenticated ? 'Authorized' : 'Not Authorized'); + } + + Future _authenticateWithBiometrics() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: + 'Scan your fingerprint (or face or whatever) to authenticate', + authStrings: IOSAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true, + biometricOnly: true, + ); + setState(() { + _isAuthenticating = false; + _authorized = 'Authenticating'; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + final String message = authenticated ? 'Authorized' : 'Not Authorized'; + setState(() { + _authorized = message; + }); + } + + Future _cancelAuthentication() async { + await auth.stopAuthentication(); + setState(() => _isAuthenticating = false); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: ListView( + padding: const EdgeInsets.only(top: 30), + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (_supportState == _SupportState.unknown) + const CircularProgressIndicator() + else if (_supportState == _SupportState.supported) + const Text('This device is supported') + else + const Text('This device is not supported'), + const Divider(height: 100), + Text('Can check biometrics: $_canCheckBiometrics\n'), + ElevatedButton( + child: const Text('Check biometrics'), + onPressed: _checkBiometrics, + ), + const Divider(height: 100), + Text('Available biometrics: $_availableBiometrics\n'), + ElevatedButton( + child: const Text('Get available biometrics'), + onPressed: _getAvailableBiometrics, + ), + const Divider(height: 100), + Text('Current State: $_authorized\n'), + if (_isAuthenticating) + ElevatedButton( + onPressed: _cancelAuthentication, + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Cancel Authentication'), + Icon(Icons.cancel), + ], + ), + ) + else + Column( + children: [ + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Authenticate'), + Icon(Icons.perm_device_information), + ], + ), + onPressed: _authenticate, + ), + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text(_isAuthenticating + ? 'Cancel' + : 'Authenticate: biometrics only'), + const Icon(Icons.fingerprint), + ], + ), + onPressed: _authenticateWithBiometrics, + ), + ], + ), + ], + ), + ], + ), + ), + ); + } +} + +enum _SupportState { + unknown, + supported, + unsupported, +} diff --git a/packages/local_auth/local_auth_ios/example/pubspec.yaml b/packages/local_auth/local_auth_ios/example/pubspec.yaml new file mode 100644 index 000000000000..70a2946d8e01 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/pubspec.yaml @@ -0,0 +1,28 @@ +name: local_auth_ios_example +description: Demonstrates how to use the local_auth_ios plugin. +publish_to: none + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + local_auth_ios: + # When depending on this package from a real application you should use: + # local_auth: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + +dev_dependencies: + flutter_driver: + sdk: flutter + integration_test: + sdk: flutter + pedantic: ^1.10.0 + +flutter: + uses-material-design: true diff --git a/packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart b/packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..4f10f2a522f3 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/local_auth/local_auth_ios/ios/Assets/.gitkeep b/packages/local_auth/local_auth_ios/ios/Assets/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.h b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.h new file mode 100644 index 000000000000..1a1446fb27bd --- /dev/null +++ b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.h @@ -0,0 +1,8 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import + +@interface FLTLocalAuthPlugin : NSObject +@end diff --git a/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m new file mode 100644 index 000000000000..eb567e6afe25 --- /dev/null +++ b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m @@ -0,0 +1,229 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#import + +#import "FLTLocalAuthPlugin.h" + +@interface FLTLocalAuthPlugin () +@property(nonatomic, copy, nullable) NSDictionary *lastCallArgs; +@property(nonatomic, nullable) FlutterResult lastResult; +// For unit tests to inject dummy LAContext instances that will be used when a new context would +// normally be created. Each call to createAuthContext will remove the current first element from +// the array. +- (void)setAuthContextOverrides:(NSArray *)authContexts; +@end + +@implementation FLTLocalAuthPlugin { + NSMutableArray *_authContextOverrides; +} + ++ (void)registerWithRegistrar:(NSObject *)registrar { + FlutterMethodChannel *channel = + [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/local_auth_ios" + binaryMessenger:[registrar messenger]]; + FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init]; + [registrar addMethodCallDelegate:instance channel:channel]; + [registrar addApplicationDelegate:instance]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { + if ([@"authenticate" isEqualToString:call.method]) { + bool isBiometricOnly = [call.arguments[@"biometricOnly"] boolValue]; + if (isBiometricOnly) { + [self authenticateWithBiometrics:call.arguments withFlutterResult:result]; + } else { + [self authenticate:call.arguments withFlutterResult:result]; + } + } else if ([@"getAvailableBiometrics" isEqualToString:call.method]) { + [self getAvailableBiometrics:result]; + } else if ([@"isDeviceSupported" isEqualToString:call.method]) { + result(@YES); + } else { + result(FlutterMethodNotImplemented); + } +} + +#pragma mark Private Methods + +- (void)setAuthContextOverrides:(NSArray *)authContexts { + _authContextOverrides = [authContexts mutableCopy]; +} + +- (LAContext *)createAuthContext { + if ([_authContextOverrides count] > 0) { + LAContext *context = [_authContextOverrides firstObject]; + [_authContextOverrides removeObjectAtIndex:0]; + return context; + } + return [[LAContext alloc] init]; +} + +- (void)alertMessage:(NSString *)message + firstButton:(NSString *)firstButton + flutterResult:(FlutterResult)result + additionalButton:(NSString *)secondButton { + UIAlertController *alert = + [UIAlertController alertControllerWithTitle:@"" + message:message + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:firstButton + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + result(@NO); + }]; + + [alert addAction:defaultAction]; + if (secondButton != nil) { + UIAlertAction *additionalAction = [UIAlertAction + actionWithTitle:secondButton + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + if (UIApplicationOpenSettingsURLString != NULL) { + NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + [[UIApplication sharedApplication] openURL:url]; + result(@NO); + } + }]; + [alert addAction:additionalAction]; + } + [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alert + animated:YES + completion:nil]; +} + +- (void)getAvailableBiometrics:(FlutterResult)result { + LAContext *context = self.createAuthContext; + NSError *authError = nil; + NSMutableArray *biometrics = [[NSMutableArray alloc] init]; + if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + error:&authError]) { + if (authError == nil) { + if (@available(iOS 11.0.1, *)) { + if (context.biometryType == LABiometryTypeFaceID) { + [biometrics addObject:@"face"]; + } else if (context.biometryType == LABiometryTypeTouchID) { + [biometrics addObject:@"fingerprint"]; + } + } else { + [biometrics addObject:@"fingerprint"]; + } + } + } else if (authError.code == LAErrorTouchIDNotEnrolled) { + [biometrics addObject:@"undefined"]; + } + result(biometrics); +} + +- (void)authenticateWithBiometrics:(NSDictionary *)arguments + withFlutterResult:(FlutterResult)result { + LAContext *context = self.createAuthContext; + NSError *authError = nil; + self.lastCallArgs = nil; + self.lastResult = nil; + context.localizedFallbackTitle = @""; + + if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + error:&authError]) { + [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + localizedReason:arguments[@"localizedReason"] + reply:^(BOOL success, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self handleAuthReplyWithSuccess:success + error:error + flutterArguments:arguments + flutterResult:result]; + }); + }]; + } else { + [self handleErrors:authError flutterArguments:arguments withFlutterResult:result]; + } +} + +- (void)authenticate:(NSDictionary *)arguments withFlutterResult:(FlutterResult)result { + LAContext *context = self.createAuthContext; + NSError *authError = nil; + _lastCallArgs = nil; + _lastResult = nil; + context.localizedFallbackTitle = @""; + + if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError]) { + [context evaluatePolicy:kLAPolicyDeviceOwnerAuthentication + localizedReason:arguments[@"localizedReason"] + reply:^(BOOL success, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self handleAuthReplyWithSuccess:success + error:error + flutterArguments:arguments + flutterResult:result]; + }); + }]; + } else { + [self handleErrors:authError flutterArguments:arguments withFlutterResult:result]; + } +} + +- (void)handleAuthReplyWithSuccess:(BOOL)success + error:(NSError *)error + flutterArguments:(NSDictionary *)arguments + flutterResult:(FlutterResult)result { + NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread."); + if (success) { + result(@YES); + } else { + switch (error.code) { + case LAErrorPasscodeNotSet: + case LAErrorTouchIDNotAvailable: + case LAErrorTouchIDNotEnrolled: + case LAErrorTouchIDLockout: + [self handleErrors:error flutterArguments:arguments withFlutterResult:result]; + return; + case LAErrorSystemCancel: + if ([arguments[@"stickyAuth"] boolValue]) { + self->_lastCallArgs = arguments; + self->_lastResult = result; + return; + } + } + result(@NO); + } +} + +- (void)handleErrors:(NSError *)authError + flutterArguments:(NSDictionary *)arguments + withFlutterResult:(FlutterResult)result { + NSString *errorCode = @"NotAvailable"; + switch (authError.code) { + case LAErrorPasscodeNotSet: + case LAErrorTouchIDNotEnrolled: + if ([arguments[@"useErrorDialogs"] boolValue]) { + [self alertMessage:arguments[@"goToSettingDescriptionIOS"] + firstButton:arguments[@"okButton"] + flutterResult:result + additionalButton:arguments[@"goToSetting"]]; + return; + } + errorCode = authError.code == LAErrorPasscodeNotSet ? @"PasscodeNotSet" : @"NotEnrolled"; + break; + case LAErrorTouchIDLockout: + [self alertMessage:arguments[@"lockOut"] + firstButton:arguments[@"okButton"] + flutterResult:result + additionalButton:nil]; + return; + } + result([FlutterError errorWithCode:errorCode + message:authError.localizedDescription + details:authError.domain]); +} + +#pragma mark - AppDelegate + +- (void)applicationDidBecomeActive:(UIApplication *)application { + if (self.lastCallArgs != nil && self.lastResult != nil) { + [self authenticateWithBiometrics:_lastCallArgs withFlutterResult:self.lastResult]; + } +} + +@end diff --git a/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec b/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec new file mode 100644 index 000000000000..a0e59e4df2a8 --- /dev/null +++ b/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec @@ -0,0 +1,23 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# +Pod::Spec.new do |s| + s.name = 'local_auth_ios' + s.version = '0.0.1' + s.summary = 'Flutter Local Auth' + s.description = <<-DESC +This Flutter plugin provides means to perform local, on-device authentication of the user. +Downloaded by pub (not CocoaPods). + DESC + s.homepage = 'https://github.com/flutter/plugins' + s.license = { :type => 'BSD', :file => '../LICENSE' } + s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } + s.source = { :http => 'https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_ios' } + s.documentation_url = 'https://pub.dev/packages/local_auth_ios' + s.source_files = 'Classes/**/*' + s.public_header_files = 'Classes/**/*.h' + s.dependency 'Flutter' + s.platform = :ios, '9.0' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } +end + diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart new file mode 100644 index 000000000000..f9320b591950 --- /dev/null +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -0,0 +1,75 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +export 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = + MethodChannel('plugins.flutter.io/local_auth_ios'); + +// The implementation of [LocalAuthPlatform] for iOS. +class LocalAuthIOS extends LocalAuthPlatform { + /// Registers this class as the default instance of [LocalAuthPlatform]. + static void registerWith() { + LocalAuthPlatform.instance = LocalAuthIOS(); + } + + @override + Future authenticate({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + required Map authStrings, + bool sensitiveTransaction = true, + bool biometricOnly = false, + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': useErrorDialogs, + 'stickyAuth': stickyAuth, + 'sensitiveTransaction': sensitiveTransaction, + 'biometricOnly': biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async { + throw UnimplementedError('stopAuthentication() is not supported on iOS.'); + } +} diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart new file mode 100644 index 000000000000..f41831f98a81 --- /dev/null +++ b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart @@ -0,0 +1,53 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:intl/intl.dart'; +import 'package:local_auth_platform_interface/types/auth_strings.dart'; + +/// iOS side authentication messages. +/// +/// Provides default values for all messages. +class IOSAuthMessages { + const IOSAuthMessages({ + this.lockOut, + this.goToSettingsButton, + this.goToSettingsDescription, + this.cancelButton, + }); + + final String? lockOut; + final String? goToSettingsButton; + final String? goToSettingsDescription; + final String? cancelButton; + + Map get args { + return { + 'lockOut': lockOut ?? iOSLockOut, + 'goToSetting': goToSettingsButton ?? goToSettings, + 'goToSettingDescriptionIOS': + goToSettingsDescription ?? iOSGoToSettingsDescription, + 'okButton': cancelButton ?? iOSOkButton, + }; + } +} + +// Strings for local_authentication plugin. Currently supports English. +// Intl.message must be string literals. +String get iOSLockOut => Intl.message( + 'Biometric authentication is disabled. Please lock and unlock your screen to ' + 'enable it.', + desc: + 'Message advising the user to re-enable biometrics on their device. It ' + 'shows in a dialog on iOS side.'); + +String get iOSGoToSettingsDescription => Intl.message( + 'Biometric authentication is not set up on your device. Please either enable ' + 'Touch ID or Face ID on your phone.', + desc: + 'Message advising the user to go to the settings and configure Biometrics ' + 'for their device. It shows in a dialog on iOS side.'); + +String get iOSOkButton => Intl.message('OK', + desc: 'Message showed on a button that the user can click to leave the ' + 'current dialog. It is used on iOS side. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_ios/pubspec.yaml b/packages/local_auth/local_auth_ios/pubspec.yaml new file mode 100644 index 000000000000..a3d857d6c8ca --- /dev/null +++ b/packages/local_auth/local_auth_ios/pubspec.yaml @@ -0,0 +1,30 @@ +name: local_auth_ios +description: iOS implementation of the local_auth plugin. +repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_ios +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0 + +flutter: + plugin: + platforms: + ios: + pluginClass: FLTLocalAuthPlugin + dartPluginClass: LocalAuthIOS + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + +dependencies: + flutter: + sdk: flutter + local_auth_platform_interface: + path: ../local_auth_platform_interface + intl: ^0.17.0 + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^5.0.0 \ No newline at end of file diff --git a/packages/local_auth/local_auth_ios/test/local_auth_test.dart b/packages/local_auth/local_auth_ios/test/local_auth_test.dart new file mode 100644 index 000000000000..685cb6a77a5c --- /dev/null +++ b/packages/local_auth/local_auth_ios/test/local_auth_test.dart @@ -0,0 +1,110 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_ios/local_auth_ios.dart'; +import 'package:local_auth_ios/types/auth_strings_ios.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('LocalAuth', () { + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth_ios', + ); + + final List log = []; + late LocalAuthIOS localAuthentication; + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = LocalAuthIOS(); + log.clear(); + }); + + group('With device auth fail over', () { + test('authenticate with no args on iOS.', () async { + await localAuthentication.authenticate( + authStrings: IOSAuthMessages().args, + localizedReason: 'Needs secure', + biometricOnly: true, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }..addAll(const IOSAuthMessages().args)), + ], + ); + }); + + test('authenticate with no localizedReason on iOS.', () async { + await expectLater( + localAuthentication.authenticate( + authStrings: IOSAuthMessages().args, + localizedReason: '', + biometricOnly: true, + ), + throwsAssertionError, + ); + }); + }); + + group('With biometrics only', () { + test('authenticate with no args on iOS.', () async { + await localAuthentication.authenticate( + authStrings: IOSAuthMessages().args, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }..addAll(const IOSAuthMessages().args)), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: IOSAuthMessages().args, + localizedReason: 'Insecure', + sensitiveTransaction: false, + useErrorDialogs: false, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }..addAll(const IOSAuthMessages().args)), + ], + ); + }); + }); + }); +} From 7b510a9ed311aafd2ad25ca0c1fa79d21308473c Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 14:59:42 +0100 Subject: [PATCH 03/53] Add Android implementation for local_auth_platform_interface --- .../local_auth/local_auth_android/AUTHORS | 67 ++++ .../local_auth_android/CHANGELOG.md | 3 + .../local_auth/local_auth_android/LICENSE | 25 ++ .../local_auth/local_auth_android/README.md | 11 + .../local_auth_android/analysis_options.yaml | 4 + .../local_auth_android/android/build.gradle | 60 +++ .../android/lint-baseline.xml | 59 +++ .../android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 5 + .../localauth/AuthenticationHelper.java | 300 +++++++++++++++ .../plugins/localauth/LocalAuthPlugin.java | 362 ++++++++++++++++++ .../res/drawable/fingerprint_initial_icon.xml | 16 + .../res/drawable/fingerprint_success_icon.xml | 16 + .../res/drawable/fingerprint_warning_icon.xml | 16 + .../main/res/drawable/ic_done_white_24dp.xml | 9 + .../drawable/ic_fingerprint_white_24dp.xml | 9 + .../drawable/ic_priority_high_white_24dp.xml | 12 + .../src/main/res/layout/go_to_setting.xml | 26 ++ .../android/src/main/res/layout/scan_fp.xml | 47 +++ .../android/src/main/res/values/colors.xml | 9 + .../android/src/main/res/values/dimens.xml | 5 + .../android/src/main/res/values/styles.xml | 9 + .../plugins/localauth/LocalAuthTest.java | 64 ++++ .../local_auth_android/example/README.md | 8 + .../example/android/app/build.gradle | 58 +++ .../gradle/wrapper/gradle-wrapper.properties | 5 + .../flutter/plugins/DartIntegrationTest.java | 14 + .../FlutterFragmentActivityTest.java | 20 + .../android/app/src/main/AndroidManifest.xml | 21 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../example/android/build.gradle | 29 ++ .../example/android/gradle.properties | 4 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../example/android/settings.gradle | 15 + .../example/android/settings_aar.gradle | 1 + .../integration_test/local_auth_test.dart | 19 + .../local_auth_android/example/lib/main.dart | 231 +++++++++++ .../local_auth_android/example/pubspec.yaml | 28 ++ .../example/test_driver/integration_test.dart | 7 + .../lib/local_auth_android.dart | 74 ++++ .../lib/types/auth_strings_android.dart | 102 +++++ .../local_auth_android/pubspec.yaml | 32 ++ .../test/local_auth_test.dart | 122 ++++++ 47 files changed, 1931 insertions(+) create mode 100644 packages/local_auth/local_auth_android/AUTHORS create mode 100644 packages/local_auth/local_auth_android/CHANGELOG.md create mode 100644 packages/local_auth/local_auth_android/LICENSE create mode 100644 packages/local_auth/local_auth_android/README.md create mode 100644 packages/local_auth/local_auth_android/analysis_options.yaml create mode 100644 packages/local_auth/local_auth_android/android/build.gradle create mode 100644 packages/local_auth/local_auth_android/android/lint-baseline.xml create mode 100644 packages/local_auth/local_auth_android/android/settings.gradle create mode 100644 packages/local_auth/local_auth_android/android/src/main/AndroidManifest.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java create mode 100644 packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_initial_icon.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_success_icon.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_warning_icon.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_done_white_24dp.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_priority_high_white_24dp.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/layout/go_to_setting.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/layout/scan_fp.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/values/colors.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/values/dimens.xml create mode 100644 packages/local_auth/local_auth_android/android/src/main/res/values/styles.xml create mode 100644 packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java create mode 100644 packages/local_auth/local_auth_android/example/README.md create mode 100644 packages/local_auth/local_auth_android/example/android/app/build.gradle create mode 100644 packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/build.gradle create mode 100644 packages/local_auth/local_auth_android/example/android/gradle.properties create mode 100644 packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 packages/local_auth/local_auth_android/example/android/settings.gradle create mode 100644 packages/local_auth/local_auth_android/example/android/settings_aar.gradle create mode 100644 packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart create mode 100644 packages/local_auth/local_auth_android/example/lib/main.dart create mode 100644 packages/local_auth/local_auth_android/example/pubspec.yaml create mode 100644 packages/local_auth/local_auth_android/example/test_driver/integration_test.dart create mode 100644 packages/local_auth/local_auth_android/lib/local_auth_android.dart create mode 100644 packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart create mode 100644 packages/local_auth/local_auth_android/pubspec.yaml create mode 100644 packages/local_auth/local_auth_android/test/local_auth_test.dart diff --git a/packages/local_auth/local_auth_android/AUTHORS b/packages/local_auth/local_auth_android/AUTHORS new file mode 100644 index 000000000000..d5694690c247 --- /dev/null +++ b/packages/local_auth/local_auth_android/AUTHORS @@ -0,0 +1,67 @@ +# Below is a list of people and organizations that have contributed +# to the Flutter project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. +The Chromium Authors +German Saprykin +Benjamin Sauer +larsenthomasj@gmail.com +Ali Bitek +Pol Batlló +Anatoly Pulyaevskiy +Hayden Flinner +Stefano Rodriguez +Salvatore Giordano +Brian Armstrong +Paul DeMarco +Fabricio Nogueira +Simon Lightfoot +Ashton Thomas +Thomas Danner +Diego Velásquez +Hajime Nakamura +Tuyển Vũ Xuân +Miguel Ruivo +Sarthak Verma +Mike Diarmid +Invertase +Elliot Hesp +Vince Varga +Aawaz Gyawali +EUI Limited +Katarina Sheremet +Thomas Stockx +Sarbagya Dhaubanjar +Ozkan Eksi +Rishab Nayak +ko2ic +Jonathan Younger +Jose Sanchez +Debkanchan Samadder +Audrius Karosevicius +Lukasz Piliszczuk +SoundReply Solutions GmbH +Rafal Wachol +Pau Picas +Christian Weder +Alexandru Tuca +Christian Weder +Rhodes Davis Jr. +Luigi Agosti +Quentin Le Guennec +Koushik Ravikumar +Nissim Dsilva +Giancarlo Rocha +Ryo Miyake +Théo Champion +Kazuki Yamaguchi +Eitan Schwartz +Chris Rutkowski +Juan Alvarez +Aleksandr Yurkovskiy +Anton Borries +Alex Li +Rahul Raj <64.rahulraj@gmail.com> +Bodhi Mulders diff --git a/packages/local_auth/local_auth_android/CHANGELOG.md b/packages/local_auth/local_auth_android/CHANGELOG.md new file mode 100644 index 000000000000..7f198f2d66c0 --- /dev/null +++ b/packages/local_auth/local_auth_android/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial release from migration to federated architecture. diff --git a/packages/local_auth/local_auth_android/LICENSE b/packages/local_auth/local_auth_android/LICENSE new file mode 100644 index 000000000000..c6823b81eb84 --- /dev/null +++ b/packages/local_auth/local_auth_android/LICENSE @@ -0,0 +1,25 @@ +Copyright 2013 The Flutter Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/local_auth/local_auth_android/README.md b/packages/local_auth/local_auth_android/README.md new file mode 100644 index 000000000000..07244912f231 --- /dev/null +++ b/packages/local_auth/local_auth_android/README.md @@ -0,0 +1,11 @@ +# local\_auth\_android + +The Android implementation of [`local_auth`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `local_auth` +normally. This package will be automatically included in your app when you do. + +[1]: https://pub.dev/packages/local_auth +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin \ No newline at end of file diff --git a/packages/local_auth/local_auth_android/analysis_options.yaml b/packages/local_auth/local_auth_android/analysis_options.yaml new file mode 100644 index 000000000000..a5744c1cfbe7 --- /dev/null +++ b/packages/local_auth/local_auth_android/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_android/android/build.gradle b/packages/local_auth/local_auth_android/android/build.gradle new file mode 100644 index 000000000000..de8ae50641b2 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/build.gradle @@ -0,0 +1,60 @@ +group 'io.flutter.plugins.localauth' +version '1.0-SNAPSHOT' + +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.1' + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' + +android { + compileSdkVersion 31 + + defaultConfig { + minSdkVersion 16 + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + lintOptions { + disable 'InvalidPackage' + disable 'GradleDependency' + baseline file("lint-baseline.xml") + } + + + testOptions { + unitTests.includeAndroidResources = true + unitTests.returnDefaultValues = true + unitTests.all { + testLogging { + events "passed", "skipped", "failed", "standardOut", "standardError" + outputs.upToDateWhen {false} + showStandardStreams = true + } + } + } +} + +dependencies { + api "androidx.core:core:1.3.2" + api "androidx.biometric:biometric:1.1.0" + api "androidx.fragment:fragment:1.3.2" + testImplementation 'junit:junit:4.12' + testImplementation 'org.mockito:mockito-inline:3.9.0' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test:rules:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} diff --git a/packages/local_auth/local_auth_android/android/lint-baseline.xml b/packages/local_auth/local_auth_android/android/lint-baseline.xml new file mode 100644 index 000000000000..e89eaadb3e6d --- /dev/null +++ b/packages/local_auth/local_auth_android/android/lint-baseline.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_android/android/settings.gradle b/packages/local_auth/local_auth_android/android/settings.gradle new file mode 100644 index 000000000000..dca8c623fdf6 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'local_auth' diff --git a/packages/local_auth/local_auth_android/android/src/main/AndroidManifest.xml b/packages/local_auth/local_auth_android/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..cb6cb985a986 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java new file mode 100644 index 000000000000..2b825c6d1f31 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java @@ -0,0 +1,300 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +package io.flutter.plugins.localauth; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Application; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.provider.Settings; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.biometric.BiometricPrompt; +import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.DefaultLifecycleObserver; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleOwner; +import io.flutter.plugin.common.MethodCall; +import java.util.concurrent.Executor; + +/** + * Authenticates the user with biometrics and sends corresponding response back to Flutter. + * + *

One instance per call is generated to ensure readable separation of executable paths across + * method calls. + */ +@SuppressWarnings("deprecation") +class AuthenticationHelper extends BiometricPrompt.AuthenticationCallback + implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { + /** The callback that handles the result of this authentication process. */ + interface AuthCompletionHandler { + /** Called when authentication was successful. */ + void onSuccess(); + + /** + * Called when authentication failed due to user. For instance, when user cancels the auth or + * quits the app. + */ + void onFailure(); + + /** + * Called when authentication fails due to non-user related problems such as system errors, + * phone not having a FP reader etc. + * + * @param code The error code to be returned to Flutter app. + * @param error The description of the error. + */ + void onError(String code, String error); + } + + // This is null when not using v2 embedding; + private final Lifecycle lifecycle; + private final FragmentActivity activity; + private final AuthCompletionHandler completionHandler; + private final MethodCall call; + private final BiometricPrompt.PromptInfo promptInfo; + private final boolean isAuthSticky; + private final UiThreadExecutor uiThreadExecutor; + private boolean activityPaused = false; + private BiometricPrompt biometricPrompt; + + AuthenticationHelper( + Lifecycle lifecycle, + FragmentActivity activity, + MethodCall call, + AuthCompletionHandler completionHandler, + boolean allowCredentials) { + this.lifecycle = lifecycle; + this.activity = activity; + this.completionHandler = completionHandler; + this.call = call; + this.isAuthSticky = call.argument("stickyAuth"); + this.uiThreadExecutor = new UiThreadExecutor(); + + BiometricPrompt.PromptInfo.Builder promptBuilder = + new BiometricPrompt.PromptInfo.Builder() + .setDescription((String) call.argument("localizedReason")) + .setTitle((String) call.argument("signInTitle")) + .setSubtitle((String) call.argument("biometricHint")) + .setConfirmationRequired((Boolean) call.argument("sensitiveTransaction")) + .setConfirmationRequired((Boolean) call.argument("sensitiveTransaction")); + + if (allowCredentials) { + promptBuilder.setDeviceCredentialAllowed(true); + } else { + promptBuilder.setNegativeButtonText((String) call.argument("cancelButton")); + } + this.promptInfo = promptBuilder.build(); + } + + /** Start the biometric listener. */ + void authenticate() { + if (lifecycle != null) { + lifecycle.addObserver(this); + } else { + activity.getApplication().registerActivityLifecycleCallbacks(this); + } + biometricPrompt = new BiometricPrompt(activity, uiThreadExecutor, this); + biometricPrompt.authenticate(promptInfo); + } + + /** Cancels the biometric authentication. */ + void stopAuthentication() { + if (biometricPrompt != null) { + biometricPrompt.cancelAuthentication(); + biometricPrompt = null; + } + } + + /** Stops the biometric listener. */ + private void stop() { + if (lifecycle != null) { + lifecycle.removeObserver(this); + return; + } + activity.getApplication().unregisterActivityLifecycleCallbacks(this); + } + + @SuppressLint("SwitchIntDef") + @Override + public void onAuthenticationError(int errorCode, CharSequence errString) { + switch (errorCode) { + case BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL: + if (call.argument("useErrorDialogs")) { + showGoToSettingsDialog( + (String) call.argument("deviceCredentialsRequired"), + (String) call.argument("deviceCredentialsSetupDescription")); + return; + } + completionHandler.onError("NotAvailable", "Security credentials not available."); + break; + case BiometricPrompt.ERROR_NO_SPACE: + case BiometricPrompt.ERROR_NO_BIOMETRICS: + if (promptInfo.isDeviceCredentialAllowed()) return; + if (call.argument("useErrorDialogs")) { + showGoToSettingsDialog( + (String) call.argument("biometricRequired"), + (String) call.argument("goToSettingDescription")); + return; + } + completionHandler.onError("NotEnrolled", "No Biometrics enrolled on this device."); + break; + case BiometricPrompt.ERROR_HW_UNAVAILABLE: + case BiometricPrompt.ERROR_HW_NOT_PRESENT: + completionHandler.onError("NotAvailable", "Security credentials not available."); + break; + case BiometricPrompt.ERROR_LOCKOUT: + completionHandler.onError( + "LockedOut", + "The operation was canceled because the API is locked out due to too many attempts. This occurs after 5 failed attempts, and lasts for 30 seconds."); + break; + case BiometricPrompt.ERROR_LOCKOUT_PERMANENT: + completionHandler.onError( + "PermanentlyLockedOut", + "The operation was canceled because ERROR_LOCKOUT occurred too many times. Biometric authentication is disabled until the user unlocks with strong authentication (PIN/Pattern/Password)"); + break; + case BiometricPrompt.ERROR_CANCELED: + // If we are doing sticky auth and the activity has been paused, + // ignore this error. We will start listening again when resumed. + if (activityPaused && isAuthSticky) { + return; + } else { + completionHandler.onFailure(); + } + break; + default: + completionHandler.onFailure(); + } + stop(); + } + + @Override + public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) { + completionHandler.onSuccess(); + stop(); + } + + @Override + public void onAuthenticationFailed() {} + + /** + * If the activity is paused, we keep track because biometric dialog simply returns "User + * cancelled" when the activity is paused. + */ + @Override + public void onActivityPaused(Activity ignored) { + if (isAuthSticky) { + activityPaused = true; + } + } + + @Override + public void onActivityResumed(Activity ignored) { + if (isAuthSticky) { + activityPaused = false; + final BiometricPrompt prompt = new BiometricPrompt(activity, uiThreadExecutor, this); + // When activity is resuming, we cannot show the prompt right away. We need to post it to the + // UI queue. + uiThreadExecutor.handler.post( + new Runnable() { + @Override + public void run() { + prompt.authenticate(promptInfo); + } + }); + } + } + + @Override + public void onPause(@NonNull LifecycleOwner owner) { + onActivityPaused(null); + } + + @Override + public void onResume(@NonNull LifecycleOwner owner) { + onActivityResumed(null); + } + + // Suppress inflateParams lint because dialogs do not need to attach to a parent view. + @SuppressLint("InflateParams") + private void showGoToSettingsDialog(String title, String descriptionText) { + View view = LayoutInflater.from(activity).inflate(R.layout.go_to_setting, null, false); + TextView message = (TextView) view.findViewById(R.id.fingerprint_required); + TextView description = (TextView) view.findViewById(R.id.go_to_setting_description); + message.setText(title); + description.setText(descriptionText); + Context context = new ContextThemeWrapper(activity, R.style.AlertDialogCustom); + OnClickListener goToSettingHandler = + new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + completionHandler.onFailure(); + stop(); + activity.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS)); + } + }; + OnClickListener cancelHandler = + new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + completionHandler.onFailure(); + stop(); + } + }; + new AlertDialog.Builder(context) + .setView(view) + .setPositiveButton((String) call.argument("goToSetting"), goToSettingHandler) + .setNegativeButton((String) call.argument("cancelButton"), cancelHandler) + .setCancelable(false) + .show(); + } + + // Unused methods for activity lifecycle. + + @Override + public void onActivityCreated(Activity activity, Bundle bundle) {} + + @Override + public void onActivityStarted(Activity activity) {} + + @Override + public void onActivityStopped(Activity activity) {} + + @Override + public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {} + + @Override + public void onActivityDestroyed(Activity activity) {} + + @Override + public void onDestroy(@NonNull LifecycleOwner owner) {} + + @Override + public void onStop(@NonNull LifecycleOwner owner) {} + + @Override + public void onStart(@NonNull LifecycleOwner owner) {} + + @Override + public void onCreate(@NonNull LifecycleOwner owner) {} + + private static class UiThreadExecutor implements Executor { + final Handler handler = new Handler(Looper.getMainLooper()); + + @Override + public void execute(Runnable command) { + handler.post(command); + } + } +} diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java new file mode 100644 index 000000000000..49a6b788fe46 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java @@ -0,0 +1,362 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.localauth; + +import static android.app.Activity.RESULT_OK; +import static android.content.Context.KEYGUARD_SERVICE; + +import android.app.Activity; +import android.app.KeyguardManager; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Build; +import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; +import androidx.biometric.BiometricManager; +import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.Lifecycle; +import io.flutter.embedding.engine.plugins.FlutterPlugin; +import io.flutter.embedding.engine.plugins.activity.ActivityAware; +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; +import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; +import io.flutter.plugin.common.MethodChannel.Result; +import io.flutter.plugin.common.PluginRegistry; +import io.flutter.plugin.common.PluginRegistry.Registrar; +import io.flutter.plugins.localauth.AuthenticationHelper.AuthCompletionHandler; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * Flutter plugin providing access to local authentication. + * + *

Instantiate this in an add to app scenario to gracefully handle activity and context changes. + */ +@SuppressWarnings("deprecation") +public class LocalAuthPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware { + private static final String CHANNEL_NAME = "plugins.flutter.io/local_auth_android"; + private static final int LOCK_REQUEST_CODE = 221; + private Activity activity; + private final AtomicBoolean authInProgress = new AtomicBoolean(false); + private AuthenticationHelper authHelper; + + // These are null when not using v2 embedding. + private MethodChannel channel; + private Lifecycle lifecycle; + private BiometricManager biometricManager; + private FingerprintManager fingerprintManager; + private KeyguardManager keyguardManager; + private Result lockRequestResult; + private final PluginRegistry.ActivityResultListener resultListener = + new PluginRegistry.ActivityResultListener() { + @Override + public boolean onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == LOCK_REQUEST_CODE) { + if (resultCode == RESULT_OK && lockRequestResult != null) { + authenticateSuccess(lockRequestResult); + } else { + authenticateFail(lockRequestResult); + } + lockRequestResult = null; + } + return false; + } + }; + + /** + * Registers a plugin with the v1 embedding api {@code io.flutter.plugin.common}. + * + *

Calling this will register the plugin with the passed registrar. However, plugins + * initialized this way won't react to changes in activity or context. + * + * @param registrar attaches this plugin's {@link + * io.flutter.plugin.common.MethodChannel.MethodCallHandler} to the registrar's {@link + * io.flutter.plugin.common.BinaryMessenger}. + */ + @SuppressWarnings("deprecation") + public static void registerWith(Registrar registrar) { + final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME); + final LocalAuthPlugin plugin = new LocalAuthPlugin(); + plugin.activity = registrar.activity(); + channel.setMethodCallHandler(plugin); + registrar.addActivityResultListener(plugin.resultListener); + } + + /** + * Default constructor for LocalAuthPlugin. + * + *

Use this constructor when adding this plugin to an app with v2 embedding. + */ + public LocalAuthPlugin() {} + + @Override + public void onMethodCall(MethodCall call, @NonNull final Result result) { + switch (call.method) { + case "authenticate": + authenticate(call, result); + break; + case "getAvailableBiometrics": + getAvailableBiometrics(result); + break; + case "isDeviceSupported": + isDeviceSupported(result); + break; + case "stopAuthentication": + stopAuthentication(result); + break; + default: + result.notImplemented(); + break; + } + } + + /* + * Starts authentication process + */ + private void authenticate(MethodCall call, final Result result) { + if (authInProgress.get()) { + result.error("auth_in_progress", "Authentication in progress", null); + return; + } + + if (activity == null || activity.isFinishing()) { + result.error("no_activity", "local_auth plugin requires a foreground activity", null); + return; + } + + if (!(activity instanceof FragmentActivity)) { + result.error( + "no_fragment_activity", + "local_auth plugin requires activity to be a FragmentActivity.", + null); + return; + } + + if (!isDeviceSupported()) { + authInProgress.set(false); + result.error("NotAvailable", "Required security features not enabled", null); + return; + } + + authInProgress.set(true); + AuthCompletionHandler completionHandler = + new AuthCompletionHandler() { + @Override + public void onSuccess() { + authenticateSuccess(result); + } + + @Override + public void onFailure() { + authenticateFail(result); + } + + @Override + public void onError(String code, String error) { + if (authInProgress.compareAndSet(true, false)) { + result.error(code, error, null); + } + } + }; + + // if is biometricOnly try biometric prompt - might not work + boolean isBiometricOnly = call.argument("biometricOnly"); + if (isBiometricOnly) { + if (!canAuthenticateWithBiometrics()) { + if (!hasBiometricHardware()) { + completionHandler.onError("NoHardware", "No biometric hardware found"); + } + completionHandler.onError("NotEnrolled", "No biometrics enrolled on this device."); + return; + } + authHelper = + new AuthenticationHelper( + lifecycle, (FragmentActivity) activity, call, completionHandler, false); + authHelper.authenticate(); + return; + } + + // API 29 and above + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + authHelper = + new AuthenticationHelper( + lifecycle, (FragmentActivity) activity, call, completionHandler, true); + authHelper.authenticate(); + return; + } + + // API 23 - 28 with fingerprint + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && fingerprintManager != null) { + if (fingerprintManager.hasEnrolledFingerprints()) { + authHelper = + new AuthenticationHelper( + lifecycle, (FragmentActivity) activity, call, completionHandler, false); + authHelper.authenticate(); + return; + } + } + + // API 23 or higher with device credentials + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + && keyguardManager != null + && keyguardManager.isDeviceSecure()) { + String title = call.argument("signInTitle"); + String reason = call.argument("localizedReason"); + Intent authIntent = keyguardManager.createConfirmDeviceCredentialIntent(title, reason); + + // save result for async response + lockRequestResult = result; + activity.startActivityForResult(authIntent, LOCK_REQUEST_CODE); + return; + } + + // Unable to authenticate + result.error("NotSupported", "This device does not support required security features", null); + } + + private void authenticateSuccess(Result result) { + if (authInProgress.compareAndSet(true, false)) { + result.success(true); + } + } + + private void authenticateFail(Result result) { + if (authInProgress.compareAndSet(true, false)) { + result.success(false); + } + } + + /* + * Stops the authentication if in progress. + */ + private void stopAuthentication(Result result) { + try { + if (authHelper != null && authInProgress.get()) { + authHelper.stopAuthentication(); + authHelper = null; + } + authInProgress.set(false); + result.success(true); + } catch (Exception e) { + result.success(false); + } + } + + /* + * Returns biometric types available on device + */ + private void getAvailableBiometrics(final Result result) { + try { + if (activity == null || activity.isFinishing()) { + result.error("no_activity", "local_auth plugin requires a foreground activity", null); + return; + } + ArrayList biometrics = getAvailableBiometrics(); + result.success(biometrics); + } catch (Exception e) { + result.error("no_biometrics_available", e.getMessage(), null); + } + } + + private ArrayList getAvailableBiometrics() { + ArrayList biometrics = new ArrayList<>(); + if (activity == null || activity.isFinishing()) { + return biometrics; + } + PackageManager packageManager = activity.getPackageManager(); + if (Build.VERSION.SDK_INT >= 23) { + if (packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { + biometrics.add("fingerprint"); + } + } + if (Build.VERSION.SDK_INT >= 29) { + if (packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) { + biometrics.add("face"); + } + if (packageManager.hasSystemFeature(PackageManager.FEATURE_IRIS)) { + biometrics.add("iris"); + } + } + + return biometrics; + } + + private boolean isDeviceSupported() { + if (keyguardManager == null) return false; + return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && keyguardManager.isDeviceSecure()); + } + + private boolean canAuthenticateWithBiometrics() { + if (biometricManager == null) return false; + return biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS; + } + + private boolean hasBiometricHardware() { + if (biometricManager == null) return false; + return biometricManager.canAuthenticate() != BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE; + } + + private void isDeviceSupported(Result result) { + result.success(isDeviceSupported()); + } + + @Override + public void onAttachedToEngine(FlutterPluginBinding binding) { + channel = new MethodChannel(binding.getFlutterEngine().getDartExecutor(), CHANNEL_NAME); + channel.setMethodCallHandler(this); + } + + @Override + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} + + private void setServicesFromActivity(Activity activity) { + if (activity == null) return; + this.activity = activity; + Context context = activity.getBaseContext(); + biometricManager = BiometricManager.from(activity); + keyguardManager = (KeyguardManager) context.getSystemService(KEYGUARD_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + fingerprintManager = + (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE); + } + } + + @Override + public void onAttachedToActivity(ActivityPluginBinding binding) { + binding.addActivityResultListener(resultListener); + setServicesFromActivity(binding.getActivity()); + lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding); + channel.setMethodCallHandler(this); + } + + @Override + public void onDetachedFromActivityForConfigChanges() { + lifecycle = null; + activity = null; + } + + @Override + public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) { + binding.addActivityResultListener(resultListener); + setServicesFromActivity(binding.getActivity()); + lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding); + } + + @Override + public void onDetachedFromActivity() { + lifecycle = null; + channel.setMethodCallHandler(null); + activity = null; + } + + @VisibleForTesting + final Activity getActivity() { + return activity; + } +} diff --git a/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_initial_icon.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_initial_icon.xml new file mode 100644 index 000000000000..610f7cd92bae --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_initial_icon.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_success_icon.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_success_icon.xml new file mode 100644 index 000000000000..78e42a8d7f7b --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_success_icon.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_warning_icon.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_warning_icon.xml new file mode 100644 index 000000000000..5020d067e1e0 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_warning_icon.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_done_white_24dp.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_done_white_24dp.xml new file mode 100644 index 000000000000..99caef98dd7b --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_done_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml new file mode 100644 index 000000000000..42d8eef7e929 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_priority_high_white_24dp.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_priority_high_white_24dp.xml new file mode 100644 index 000000000000..f32d4a4f4d79 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_priority_high_white_24dp.xml @@ -0,0 +1,12 @@ + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/layout/go_to_setting.xml b/packages/local_auth/local_auth_android/android/src/main/res/layout/go_to_setting.xml new file mode 100644 index 000000000000..8c932d4d19c8 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/layout/go_to_setting.xml @@ -0,0 +1,26 @@ + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/layout/scan_fp.xml b/packages/local_auth/local_auth_android/android/src/main/res/layout/scan_fp.xml new file mode 100644 index 000000000000..a99dd6a607bb --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/layout/scan_fp.xml @@ -0,0 +1,47 @@ + + + + + + + + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/values/colors.xml b/packages/local_auth/local_auth_android/android/src/main/res/values/colors.xml new file mode 100644 index 000000000000..c011fe33787c --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/values/colors.xml @@ -0,0 +1,9 @@ + + + + #E53935 + #BDBDBD + #43A047 + #212121 + #757575 + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/values/dimens.xml b/packages/local_auth/local_auth_android/android/src/main/res/values/dimens.xml new file mode 100644 index 000000000000..678faebffd61 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + 14sp + 16sp + 20sp + diff --git a/packages/local_auth/local_auth_android/android/src/main/res/values/styles.xml b/packages/local_auth/local_auth_android/android/src/main/res/values/styles.xml new file mode 100644 index 000000000000..7a0719f41882 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/main/res/values/styles.xml @@ -0,0 +1,9 @@ + + + + diff --git a/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java b/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java new file mode 100644 index 000000000000..41868e603ad8 --- /dev/null +++ b/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java @@ -0,0 +1,64 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.localauth; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.app.Activity; +import android.content.Context; +import androidx.lifecycle.Lifecycle; +import io.flutter.embedding.engine.FlutterEngine; +import io.flutter.embedding.engine.dart.DartExecutor; +import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding; +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; +import io.flutter.embedding.engine.plugins.lifecycle.HiddenLifecycleReference; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import org.junit.Test; + +public class LocalAuthTest { + @Test + public void isDeviceSupportedReturnsFalse() { + final LocalAuthPlugin plugin = new LocalAuthPlugin(); + final MethodChannel.Result mockResult = mock(MethodChannel.Result.class); + plugin.onMethodCall(new MethodCall("isDeviceSupported", null), mockResult); + verify(mockResult).success(false); + } + + @Test + public void onDetachedFromActivity_ShouldReleaseActivity() { + final Activity mockActivity = mock(Activity.class); + final ActivityPluginBinding mockActivityBinding = mock(ActivityPluginBinding.class); + when(mockActivityBinding.getActivity()).thenReturn(mockActivity); + + Context mockContext = mock(Context.class); + when(mockActivity.getBaseContext()).thenReturn(mockContext); + + final HiddenLifecycleReference mockLifecycleReference = mock(HiddenLifecycleReference.class); + when(mockActivityBinding.getLifecycle()).thenReturn(mockLifecycleReference); + + final Lifecycle mockLifecycle = mock(Lifecycle.class); + when(mockLifecycleReference.getLifecycle()).thenReturn(mockLifecycle); + + final FlutterPluginBinding mockPluginBinding = mock(FlutterPluginBinding.class); + final FlutterEngine mockFlutterEngine = mock(FlutterEngine.class); + when(mockPluginBinding.getFlutterEngine()).thenReturn(mockFlutterEngine); + + DartExecutor mockDartExecutor = mock(DartExecutor.class); + when(mockFlutterEngine.getDartExecutor()).thenReturn(mockDartExecutor); + + final LocalAuthPlugin plugin = new LocalAuthPlugin(); + plugin.onAttachedToEngine(mockPluginBinding); + plugin.onAttachedToActivity(mockActivityBinding); + assertNotNull(plugin.getActivity()); + + plugin.onDetachedFromActivity(); + assertNull(plugin.getActivity()); + } +} diff --git a/packages/local_auth/local_auth_android/example/README.md b/packages/local_auth/local_auth_android/example/README.md new file mode 100644 index 000000000000..a4a6091c9ba6 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/README.md @@ -0,0 +1,8 @@ +# local_auth_example + +Demonstrates how to use the local_auth plugin. + +## Getting Started + +For help getting started with Flutter, view our online +[documentation](https://flutter.dev/). diff --git a/packages/local_auth/local_auth_android/example/android/app/build.gradle b/packages/local_auth/local_auth_android/example/android/app/build.gradle new file mode 100644 index 000000000000..d1cef4bf53a9 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/build.gradle @@ -0,0 +1,58 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 31 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + applicationId "io.flutter.plugins.localauthexample" + minSdkVersion 16 + targetSdkVersion 28 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} diff --git a/packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..186b71557c50 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java new file mode 100644 index 000000000000..0f4298dca155 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java @@ -0,0 +1,14 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface DartIntegrationTest {} diff --git a/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java new file mode 100644 index 000000000000..68c22371d7dd --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java @@ -0,0 +1,20 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.localauth; + +import androidx.test.rule.ActivityTestRule; +import dev.flutter.plugins.integration_test.FlutterTestRunner; +import io.flutter.embedding.android.FlutterFragmentActivity; +import io.flutter.plugins.DartIntegrationTest; +import org.junit.Rule; +import org.junit.runner.RunWith; + +@DartIntegrationTest +@RunWith(FlutterTestRunner.class) +public class FlutterFragmentActivityTest { + @Rule + public ActivityTestRule rule = + new ActivityTestRule<>(FlutterFragmentActivity.class); +} diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml b/packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..8c091772107a --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/build.gradle b/packages/local_auth/local_auth_android/example/android/build.gradle new file mode 100644 index 000000000000..54c943621de5 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.1' + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/packages/local_auth/local_auth_android/example/android/gradle.properties b/packages/local_auth/local_auth_android/example/android/gradle.properties new file mode 100644 index 000000000000..7fe61a74cee0 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-Xmx1024m +android.useAndroidX=true +android.enableJetifier=true +android.enableR8=true diff --git a/packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..cd9fe1c68282 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Jan 03 14:07:08 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip diff --git a/packages/local_auth/local_auth_android/example/android/settings.gradle b/packages/local_auth/local_auth_android/example/android/settings.gradle new file mode 100644 index 000000000000..115da6cb4f4d --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withInputStream { stream -> plugins.load(stream) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/packages/local_auth/local_auth_android/example/android/settings_aar.gradle b/packages/local_auth/local_auth_android/example/android/settings_aar.gradle new file mode 100644 index 000000000000..e7b4def49cb5 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/settings_aar.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart new file mode 100644 index 000000000000..8e4f4748f05f --- /dev/null +++ b/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart @@ -0,0 +1,19 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:local_auth_android/local_auth_android.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('canCheckBiometrics', (WidgetTester tester) async { + expect( + LocalAuthAndroid().getAvailableBiometrics(), + completion(isList), + ); + }); +} diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart new file mode 100644 index 000000000000..094d7a0cd8cc --- /dev/null +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -0,0 +1,231 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_android/types/auth_strings_android.dart'; + +void main() { + runApp(MyApp()); +} + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + final LocalAuthAndroid auth = LocalAuthAndroid(); + _SupportState _supportState = _SupportState.unknown; + bool? _canCheckBiometrics; + List? _availableBiometrics; + String _authorized = 'Not Authorized'; + bool _isAuthenticating = false; + + @override + void initState() { + super.initState(); + auth.isDeviceSupported().then( + (bool isSupported) => setState(() => _supportState = isSupported + ? _SupportState.supported + : _SupportState.unsupported), + ); + } + + Future _checkBiometrics() async { + late bool canCheckBiometrics; + try { + canCheckBiometrics = (await auth.getAvailableBiometrics()).isNotEmpty; + } on PlatformException catch (e) { + canCheckBiometrics = false; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _canCheckBiometrics = canCheckBiometrics; + }); + } + + Future _getAvailableBiometrics() async { + late List availableBiometrics; + try { + availableBiometrics = await auth.getAvailableBiometrics(); + } on PlatformException catch (e) { + availableBiometrics = []; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _availableBiometrics = availableBiometrics; + }); + } + + Future _authenticate() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: 'Let OS determine authentication method', + authStrings: AndroidAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true); + setState(() { + _isAuthenticating = false; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + setState( + () => _authorized = authenticated ? 'Authorized' : 'Not Authorized'); + } + + Future _authenticateWithBiometrics() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: + 'Scan your fingerprint (or face or whatever) to authenticate', + authStrings: AndroidAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true, + biometricOnly: true); + setState(() { + _isAuthenticating = false; + _authorized = 'Authenticating'; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + final String message = authenticated ? 'Authorized' : 'Not Authorized'; + setState(() { + _authorized = message; + }); + } + + Future _cancelAuthentication() async { + await auth.stopAuthentication(); + setState(() => _isAuthenticating = false); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: ListView( + padding: const EdgeInsets.only(top: 30), + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (_supportState == _SupportState.unknown) + const CircularProgressIndicator() + else if (_supportState == _SupportState.supported) + const Text('This device is supported') + else + const Text('This device is not supported'), + const Divider(height: 100), + Text('Can check biometrics: $_canCheckBiometrics\n'), + ElevatedButton( + child: const Text('Check biometrics'), + onPressed: _checkBiometrics, + ), + const Divider(height: 100), + Text('Available biometrics: $_availableBiometrics\n'), + ElevatedButton( + child: const Text('Get available biometrics'), + onPressed: _getAvailableBiometrics, + ), + const Divider(height: 100), + Text('Current State: $_authorized\n'), + if (_isAuthenticating) + ElevatedButton( + onPressed: _cancelAuthentication, + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Cancel Authentication'), + Icon(Icons.cancel), + ], + ), + ) + else + Column( + children: [ + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Authenticate'), + Icon(Icons.perm_device_information), + ], + ), + onPressed: _authenticate, + ), + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text(_isAuthenticating + ? 'Cancel' + : 'Authenticate: biometrics only'), + const Icon(Icons.fingerprint), + ], + ), + onPressed: _authenticateWithBiometrics, + ), + ], + ), + ], + ), + ], + ), + ), + ); + } +} + +enum _SupportState { + unknown, + supported, + unsupported, +} diff --git a/packages/local_auth/local_auth_android/example/pubspec.yaml b/packages/local_auth/local_auth_android/example/pubspec.yaml new file mode 100644 index 000000000000..efd7c9c79f7f --- /dev/null +++ b/packages/local_auth/local_auth_android/example/pubspec.yaml @@ -0,0 +1,28 @@ +name: local_auth_android_example +description: Demonstrates how to use the local_auth_android plugin. +publish_to: none + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + local_auth_android: + # When depending on this package from a real application you should use: + # local_auth: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + +dev_dependencies: + flutter_driver: + sdk: flutter + integration_test: + sdk: flutter + pedantic: ^1.10.0 + +flutter: + uses-material-design: true diff --git a/packages/local_auth/local_auth_android/example/test_driver/integration_test.dart b/packages/local_auth/local_auth_android/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..4f10f2a522f3 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart new file mode 100644 index 000000000000..a048a4620d6d --- /dev/null +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -0,0 +1,74 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +export 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = + MethodChannel('plugins.flutter.io/local_auth_android'); + +// The implementation of [LocalAuthPlatform] for Android. +class LocalAuthAndroid extends LocalAuthPlatform { + /// Registers this class as the default instance of [LocalAuthPlatform]. + static void registerWith() { + LocalAuthPlatform.instance = LocalAuthAndroid(); + } + + @override + Future authenticate({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + required Map authStrings, + bool sensitiveTransaction = true, + bool biometricOnly = false, + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': useErrorDialogs, + 'stickyAuth': stickyAuth, + 'sensitiveTransaction': sensitiveTransaction, + 'biometricOnly': biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async => + await _channel.invokeMethod('stopAuthentication') ?? false; +} diff --git a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart new file mode 100644 index 000000000000..f67aa8aaa3d5 --- /dev/null +++ b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart @@ -0,0 +1,102 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:intl/intl.dart'; +import 'package:local_auth_platform_interface/types/auth_strings.dart'; + +/// Android side authentication messages. +/// +/// Provides default values for all messages. +class AndroidAuthMessages { + const AndroidAuthMessages({ + this.biometricHint, + this.biometricNotRecognized, + this.biometricRequiredTitle, + this.biometricSuccess, + this.cancelButton, + this.deviceCredentialsRequiredTitle, + this.deviceCredentialsSetupDescription, + this.goToSettingsButton, + this.goToSettingsDescription, + this.signInTitle, + }); + + final String? biometricHint; + final String? biometricNotRecognized; + final String? biometricRequiredTitle; + final String? biometricSuccess; + final String? cancelButton; + final String? deviceCredentialsRequiredTitle; + final String? deviceCredentialsSetupDescription; + final String? goToSettingsButton; + final String? goToSettingsDescription; + final String? signInTitle; + + Map get args { + return { + 'biometricHint': biometricHint ?? androidBiometricHint, + 'biometricNotRecognized': + biometricNotRecognized ?? androidBiometricNotRecognized, + 'biometricSuccess': biometricSuccess ?? androidBiometricSuccess, + 'biometricRequired': + biometricRequiredTitle ?? androidBiometricRequiredTitle, + 'cancelButton': cancelButton ?? androidCancelButton, + 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? + androidDeviceCredentialsRequiredTitle, + 'deviceCredentialsSetupDescription': deviceCredentialsSetupDescription ?? + androidDeviceCredentialsSetupDescription, + 'goToSetting': goToSettingsButton ?? goToSettings, + 'goToSettingDescription': + goToSettingsDescription ?? androidGoToSettingsDescription, + 'signInTitle': signInTitle ?? androidSignInTitle, + }; + } +} + +// Strings for local_authentication plugin. Currently supports English. +// Intl.message must be string literals. +String get androidBiometricHint => Intl.message('Verify identity', + desc: + 'Hint message advising the user how to authenticate with biometrics. It is ' + 'used on Android side. Maximum 60 characters.'); + +String get androidBiometricNotRecognized => + Intl.message('Not recognized. Try again.', + desc: 'Message to let the user know that authentication was failed. It ' + 'is used on Android side. Maximum 60 characters.'); + +String get androidBiometricSuccess => Intl.message('Success', + desc: 'Message to let the user know that authentication was successful. It ' + 'is used on Android side. Maximum 60 characters.'); + +String get androidCancelButton => Intl.message('Cancel', + desc: 'Message showed on a button that the user can click to leave the ' + 'current dialog. It is used on Android side. Maximum 30 characters.'); + +String get androidSignInTitle => Intl.message('Authentication required', + desc: 'Message showed as a title in a dialog which indicates the user ' + 'that they need to scan biometric to continue. It is used on ' + 'Android side. Maximum 60 characters.'); + +String get androidBiometricRequiredTitle => Intl.message('Biometric required', + desc: 'Message showed as a title in a dialog which indicates the user ' + 'has not set up biometric authentication on their device. It is used on Android' + ' side. Maximum 60 characters.'); + +String get androidDeviceCredentialsRequiredTitle => Intl.message( + 'Device credentials required', + desc: 'Message showed as a title in a dialog which indicates the user ' + 'has not set up credentials authentication on their device. It is used on Android' + ' side. Maximum 60 characters.'); + +String get androidDeviceCredentialsSetupDescription => Intl.message( + 'Device credentials required', + desc: 'Message advising the user to go to the settings and configure ' + 'device credentials on their device. It shows in a dialog on Android side.'); + +String get androidGoToSettingsDescription => Intl.message( + 'Biometric authentication is not set up on your device. Go to ' + '\'Settings > Security\' to add biometric authentication.', + desc: 'Message advising the user to go to the settings and configure ' + 'biometric on their device. It shows in a dialog on Android side.'); diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml new file mode 100644 index 000000000000..f146022b62a0 --- /dev/null +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -0,0 +1,32 @@ +name: local_auth_android +description: Android implementation of the local_auth plugin. +repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_android +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0 + +flutter: + plugin: + platforms: + android: + package: io.flutter.plugins.localauth + pluginClass: LocalAuthPlugin + dartPluginClass: LocalAuthAndroid + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + +dependencies: + flutter: + sdk: flutter + local_auth_platform_interface: + path: ../local_auth_platform_interface + intl: ^0.17.0 + flutter_plugin_android_lifecycle: ^2.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^5.0.0 \ No newline at end of file diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart new file mode 100644 index 000000000000..f026ecaba591 --- /dev/null +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -0,0 +1,122 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_android/types/auth_strings_android.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('LocalAuth', () { + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth_android', + ); + + final List log = []; + late LocalAuthAndroid localAuthentication; + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = LocalAuthAndroid(); + log.clear(); + }); + + group('With device auth fail over', () { + test('authenticate with no args on Android.', () async { + await localAuthentication.authenticate( + authStrings: AndroidAuthMessages().args, + localizedReason: 'Needs secure', + biometricOnly: true, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: AndroidAuthMessages().args, + localizedReason: 'Insecure', + sensitiveTransaction: false, + useErrorDialogs: false, + biometricOnly: true, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': true, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + }); + + group('With biometrics only', () { + test('authenticate with no args on Android.', () async { + await localAuthentication.authenticate( + authStrings: AndroidAuthMessages().args, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: AndroidAuthMessages().args, + localizedReason: 'Insecure', + sensitiveTransaction: false, + useErrorDialogs: false, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + }); + }); +} From 0b425bb982fb63d698f74c67cb82e39d8d7a914b Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 15:03:32 +0100 Subject: [PATCH 04/53] Refactor app facing plugin to make use of new platform interface and native implementations --- packages/local_auth/local_auth/AUTHORS | 1 + .../local_auth/android/build.gradle | 60 --- .../local_auth/android/lint-baseline.xml | 59 --- .../local_auth/android/settings.gradle | 1 - .../android/src/main/AndroidManifest.xml | 5 - .../localauth/AuthenticationHelper.java | 300 --------------- .../plugins/localauth/LocalAuthPlugin.java | 362 ------------------ .../res/drawable/fingerprint_initial_icon.xml | 16 - .../res/drawable/fingerprint_success_icon.xml | 16 - .../res/drawable/fingerprint_warning_icon.xml | 16 - .../main/res/drawable/ic_done_white_24dp.xml | 9 - .../drawable/ic_fingerprint_white_24dp.xml | 9 - .../drawable/ic_priority_high_white_24dp.xml | 12 - .../src/main/res/layout/go_to_setting.xml | 26 -- .../android/src/main/res/layout/scan_fp.xml | 47 --- .../android/src/main/res/values/colors.xml | 9 - .../android/src/main/res/values/dimens.xml | 5 - .../android/src/main/res/values/styles.xml | 9 - .../plugins/localauth/LocalAuthTest.java | 64 ---- .../ios/Runner.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../local_auth/local_auth/ios/Assets/.gitkeep | 0 .../ios/Classes/FLTLocalAuthPlugin.h | 8 - .../ios/Classes/FLTLocalAuthPlugin.m | 229 ----------- .../local_auth/ios/local_auth.podspec | 23 -- .../local_auth/lib/auth_strings.dart | 157 -------- .../local_auth/local_auth/lib/local_auth.dart | 185 +-------- .../local_auth/lib/src/local_auth.dart | 146 +++++++ .../lib/{ => src/types}/error_codes.dart | 2 +- packages/local_auth/local_auth/pubspec.yaml | 19 +- .../local_auth/test/local_auth_test.dart | 290 +++++++------- 31 files changed, 301 insertions(+), 1790 deletions(-) delete mode 100644 packages/local_auth/local_auth/android/build.gradle delete mode 100644 packages/local_auth/local_auth/android/lint-baseline.xml delete mode 100644 packages/local_auth/local_auth/android/settings.gradle delete mode 100644 packages/local_auth/local_auth/android/src/main/AndroidManifest.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java delete mode 100644 packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java delete mode 100644 packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/values/colors.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/values/dimens.xml delete mode 100644 packages/local_auth/local_auth/android/src/main/res/values/styles.xml delete mode 100644 packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java delete mode 100644 packages/local_auth/local_auth/ios/Assets/.gitkeep delete mode 100644 packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h delete mode 100644 packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m delete mode 100644 packages/local_auth/local_auth/ios/local_auth.podspec delete mode 100644 packages/local_auth/local_auth/lib/auth_strings.dart create mode 100644 packages/local_auth/local_auth/lib/src/local_auth.dart rename packages/local_auth/local_auth/lib/{ => src/types}/error_codes.dart (93%) diff --git a/packages/local_auth/local_auth/AUTHORS b/packages/local_auth/local_auth/AUTHORS index 493a0b4ef9c2..d5694690c247 100644 --- a/packages/local_auth/local_auth/AUTHORS +++ b/packages/local_auth/local_auth/AUTHORS @@ -64,3 +64,4 @@ Aleksandr Yurkovskiy Anton Borries Alex Li Rahul Raj <64.rahulraj@gmail.com> +Bodhi Mulders diff --git a/packages/local_auth/local_auth/android/build.gradle b/packages/local_auth/local_auth/android/build.gradle deleted file mode 100644 index de8ae50641b2..000000000000 --- a/packages/local_auth/local_auth/android/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -group 'io.flutter.plugins.localauth' -version '1.0-SNAPSHOT' - -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' - -android { - compileSdkVersion 31 - - defaultConfig { - minSdkVersion 16 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - lintOptions { - disable 'InvalidPackage' - disable 'GradleDependency' - baseline file("lint-baseline.xml") - } - - - testOptions { - unitTests.includeAndroidResources = true - unitTests.returnDefaultValues = true - unitTests.all { - testLogging { - events "passed", "skipped", "failed", "standardOut", "standardError" - outputs.upToDateWhen {false} - showStandardStreams = true - } - } - } -} - -dependencies { - api "androidx.core:core:1.3.2" - api "androidx.biometric:biometric:1.1.0" - api "androidx.fragment:fragment:1.3.2" - testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-inline:3.9.0' - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test:rules:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' -} diff --git a/packages/local_auth/local_auth/android/lint-baseline.xml b/packages/local_auth/local_auth/android/lint-baseline.xml deleted file mode 100644 index e89eaadb3e6d..000000000000 --- a/packages/local_auth/local_auth/android/lint-baseline.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/local_auth/local_auth/android/settings.gradle b/packages/local_auth/local_auth/android/settings.gradle deleted file mode 100644 index dca8c623fdf6..000000000000 --- a/packages/local_auth/local_auth/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'local_auth' diff --git a/packages/local_auth/local_auth/android/src/main/AndroidManifest.xml b/packages/local_auth/local_auth/android/src/main/AndroidManifest.xml deleted file mode 100644 index cb6cb985a986..000000000000 --- a/packages/local_auth/local_auth/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - diff --git a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java b/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java deleted file mode 100644 index 2b825c6d1f31..000000000000 --- a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -package io.flutter.plugins.localauth; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Application; -import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.provider.Settings; -import android.view.ContextThemeWrapper; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; -import androidx.annotation.NonNull; -import androidx.biometric.BiometricPrompt; -import androidx.fragment.app.FragmentActivity; -import androidx.lifecycle.DefaultLifecycleObserver; -import androidx.lifecycle.Lifecycle; -import androidx.lifecycle.LifecycleOwner; -import io.flutter.plugin.common.MethodCall; -import java.util.concurrent.Executor; - -/** - * Authenticates the user with biometrics and sends corresponding response back to Flutter. - * - *

One instance per call is generated to ensure readable separation of executable paths across - * method calls. - */ -@SuppressWarnings("deprecation") -class AuthenticationHelper extends BiometricPrompt.AuthenticationCallback - implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver { - /** The callback that handles the result of this authentication process. */ - interface AuthCompletionHandler { - /** Called when authentication was successful. */ - void onSuccess(); - - /** - * Called when authentication failed due to user. For instance, when user cancels the auth or - * quits the app. - */ - void onFailure(); - - /** - * Called when authentication fails due to non-user related problems such as system errors, - * phone not having a FP reader etc. - * - * @param code The error code to be returned to Flutter app. - * @param error The description of the error. - */ - void onError(String code, String error); - } - - // This is null when not using v2 embedding; - private final Lifecycle lifecycle; - private final FragmentActivity activity; - private final AuthCompletionHandler completionHandler; - private final MethodCall call; - private final BiometricPrompt.PromptInfo promptInfo; - private final boolean isAuthSticky; - private final UiThreadExecutor uiThreadExecutor; - private boolean activityPaused = false; - private BiometricPrompt biometricPrompt; - - AuthenticationHelper( - Lifecycle lifecycle, - FragmentActivity activity, - MethodCall call, - AuthCompletionHandler completionHandler, - boolean allowCredentials) { - this.lifecycle = lifecycle; - this.activity = activity; - this.completionHandler = completionHandler; - this.call = call; - this.isAuthSticky = call.argument("stickyAuth"); - this.uiThreadExecutor = new UiThreadExecutor(); - - BiometricPrompt.PromptInfo.Builder promptBuilder = - new BiometricPrompt.PromptInfo.Builder() - .setDescription((String) call.argument("localizedReason")) - .setTitle((String) call.argument("signInTitle")) - .setSubtitle((String) call.argument("biometricHint")) - .setConfirmationRequired((Boolean) call.argument("sensitiveTransaction")) - .setConfirmationRequired((Boolean) call.argument("sensitiveTransaction")); - - if (allowCredentials) { - promptBuilder.setDeviceCredentialAllowed(true); - } else { - promptBuilder.setNegativeButtonText((String) call.argument("cancelButton")); - } - this.promptInfo = promptBuilder.build(); - } - - /** Start the biometric listener. */ - void authenticate() { - if (lifecycle != null) { - lifecycle.addObserver(this); - } else { - activity.getApplication().registerActivityLifecycleCallbacks(this); - } - biometricPrompt = new BiometricPrompt(activity, uiThreadExecutor, this); - biometricPrompt.authenticate(promptInfo); - } - - /** Cancels the biometric authentication. */ - void stopAuthentication() { - if (biometricPrompt != null) { - biometricPrompt.cancelAuthentication(); - biometricPrompt = null; - } - } - - /** Stops the biometric listener. */ - private void stop() { - if (lifecycle != null) { - lifecycle.removeObserver(this); - return; - } - activity.getApplication().unregisterActivityLifecycleCallbacks(this); - } - - @SuppressLint("SwitchIntDef") - @Override - public void onAuthenticationError(int errorCode, CharSequence errString) { - switch (errorCode) { - case BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL: - if (call.argument("useErrorDialogs")) { - showGoToSettingsDialog( - (String) call.argument("deviceCredentialsRequired"), - (String) call.argument("deviceCredentialsSetupDescription")); - return; - } - completionHandler.onError("NotAvailable", "Security credentials not available."); - break; - case BiometricPrompt.ERROR_NO_SPACE: - case BiometricPrompt.ERROR_NO_BIOMETRICS: - if (promptInfo.isDeviceCredentialAllowed()) return; - if (call.argument("useErrorDialogs")) { - showGoToSettingsDialog( - (String) call.argument("biometricRequired"), - (String) call.argument("goToSettingDescription")); - return; - } - completionHandler.onError("NotEnrolled", "No Biometrics enrolled on this device."); - break; - case BiometricPrompt.ERROR_HW_UNAVAILABLE: - case BiometricPrompt.ERROR_HW_NOT_PRESENT: - completionHandler.onError("NotAvailable", "Security credentials not available."); - break; - case BiometricPrompt.ERROR_LOCKOUT: - completionHandler.onError( - "LockedOut", - "The operation was canceled because the API is locked out due to too many attempts. This occurs after 5 failed attempts, and lasts for 30 seconds."); - break; - case BiometricPrompt.ERROR_LOCKOUT_PERMANENT: - completionHandler.onError( - "PermanentlyLockedOut", - "The operation was canceled because ERROR_LOCKOUT occurred too many times. Biometric authentication is disabled until the user unlocks with strong authentication (PIN/Pattern/Password)"); - break; - case BiometricPrompt.ERROR_CANCELED: - // If we are doing sticky auth and the activity has been paused, - // ignore this error. We will start listening again when resumed. - if (activityPaused && isAuthSticky) { - return; - } else { - completionHandler.onFailure(); - } - break; - default: - completionHandler.onFailure(); - } - stop(); - } - - @Override - public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) { - completionHandler.onSuccess(); - stop(); - } - - @Override - public void onAuthenticationFailed() {} - - /** - * If the activity is paused, we keep track because biometric dialog simply returns "User - * cancelled" when the activity is paused. - */ - @Override - public void onActivityPaused(Activity ignored) { - if (isAuthSticky) { - activityPaused = true; - } - } - - @Override - public void onActivityResumed(Activity ignored) { - if (isAuthSticky) { - activityPaused = false; - final BiometricPrompt prompt = new BiometricPrompt(activity, uiThreadExecutor, this); - // When activity is resuming, we cannot show the prompt right away. We need to post it to the - // UI queue. - uiThreadExecutor.handler.post( - new Runnable() { - @Override - public void run() { - prompt.authenticate(promptInfo); - } - }); - } - } - - @Override - public void onPause(@NonNull LifecycleOwner owner) { - onActivityPaused(null); - } - - @Override - public void onResume(@NonNull LifecycleOwner owner) { - onActivityResumed(null); - } - - // Suppress inflateParams lint because dialogs do not need to attach to a parent view. - @SuppressLint("InflateParams") - private void showGoToSettingsDialog(String title, String descriptionText) { - View view = LayoutInflater.from(activity).inflate(R.layout.go_to_setting, null, false); - TextView message = (TextView) view.findViewById(R.id.fingerprint_required); - TextView description = (TextView) view.findViewById(R.id.go_to_setting_description); - message.setText(title); - description.setText(descriptionText); - Context context = new ContextThemeWrapper(activity, R.style.AlertDialogCustom); - OnClickListener goToSettingHandler = - new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - completionHandler.onFailure(); - stop(); - activity.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS)); - } - }; - OnClickListener cancelHandler = - new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - completionHandler.onFailure(); - stop(); - } - }; - new AlertDialog.Builder(context) - .setView(view) - .setPositiveButton((String) call.argument("goToSetting"), goToSettingHandler) - .setNegativeButton((String) call.argument("cancelButton"), cancelHandler) - .setCancelable(false) - .show(); - } - - // Unused methods for activity lifecycle. - - @Override - public void onActivityCreated(Activity activity, Bundle bundle) {} - - @Override - public void onActivityStarted(Activity activity) {} - - @Override - public void onActivityStopped(Activity activity) {} - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {} - - @Override - public void onActivityDestroyed(Activity activity) {} - - @Override - public void onDestroy(@NonNull LifecycleOwner owner) {} - - @Override - public void onStop(@NonNull LifecycleOwner owner) {} - - @Override - public void onStart(@NonNull LifecycleOwner owner) {} - - @Override - public void onCreate(@NonNull LifecycleOwner owner) {} - - private static class UiThreadExecutor implements Executor { - final Handler handler = new Handler(Looper.getMainLooper()); - - @Override - public void execute(Runnable command) { - handler.post(command); - } - } -} diff --git a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java deleted file mode 100644 index a63e22a512d0..000000000000 --- a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package io.flutter.plugins.localauth; - -import static android.app.Activity.RESULT_OK; -import static android.content.Context.KEYGUARD_SERVICE; - -import android.app.Activity; -import android.app.KeyguardManager; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.hardware.fingerprint.FingerprintManager; -import android.os.Build; -import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; -import androidx.biometric.BiometricManager; -import androidx.fragment.app.FragmentActivity; -import androidx.lifecycle.Lifecycle; -import io.flutter.embedding.engine.plugins.FlutterPlugin; -import io.flutter.embedding.engine.plugins.activity.ActivityAware; -import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; -import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter; -import io.flutter.plugin.common.MethodCall; -import io.flutter.plugin.common.MethodChannel; -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; -import io.flutter.plugin.common.MethodChannel.Result; -import io.flutter.plugin.common.PluginRegistry; -import io.flutter.plugin.common.PluginRegistry.Registrar; -import io.flutter.plugins.localauth.AuthenticationHelper.AuthCompletionHandler; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Flutter plugin providing access to local authentication. - * - *

Instantiate this in an add to app scenario to gracefully handle activity and context changes. - */ -@SuppressWarnings("deprecation") -public class LocalAuthPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware { - private static final String CHANNEL_NAME = "plugins.flutter.io/local_auth"; - private static final int LOCK_REQUEST_CODE = 221; - private Activity activity; - private final AtomicBoolean authInProgress = new AtomicBoolean(false); - private AuthenticationHelper authHelper; - - // These are null when not using v2 embedding. - private MethodChannel channel; - private Lifecycle lifecycle; - private BiometricManager biometricManager; - private FingerprintManager fingerprintManager; - private KeyguardManager keyguardManager; - private Result lockRequestResult; - private final PluginRegistry.ActivityResultListener resultListener = - new PluginRegistry.ActivityResultListener() { - @Override - public boolean onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == LOCK_REQUEST_CODE) { - if (resultCode == RESULT_OK && lockRequestResult != null) { - authenticateSuccess(lockRequestResult); - } else { - authenticateFail(lockRequestResult); - } - lockRequestResult = null; - } - return false; - } - }; - - /** - * Registers a plugin with the v1 embedding api {@code io.flutter.plugin.common}. - * - *

Calling this will register the plugin with the passed registrar. However, plugins - * initialized this way won't react to changes in activity or context. - * - * @param registrar attaches this plugin's {@link - * io.flutter.plugin.common.MethodChannel.MethodCallHandler} to the registrar's {@link - * io.flutter.plugin.common.BinaryMessenger}. - */ - @SuppressWarnings("deprecation") - public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME); - final LocalAuthPlugin plugin = new LocalAuthPlugin(); - plugin.activity = registrar.activity(); - channel.setMethodCallHandler(plugin); - registrar.addActivityResultListener(plugin.resultListener); - } - - /** - * Default constructor for LocalAuthPlugin. - * - *

Use this constructor when adding this plugin to an app with v2 embedding. - */ - public LocalAuthPlugin() {} - - @Override - public void onMethodCall(MethodCall call, @NonNull final Result result) { - switch (call.method) { - case "authenticate": - authenticate(call, result); - break; - case "getAvailableBiometrics": - getAvailableBiometrics(result); - break; - case "isDeviceSupported": - isDeviceSupported(result); - break; - case "stopAuthentication": - stopAuthentication(result); - break; - default: - result.notImplemented(); - break; - } - } - - /* - * Starts authentication process - */ - private void authenticate(MethodCall call, final Result result) { - if (authInProgress.get()) { - result.error("auth_in_progress", "Authentication in progress", null); - return; - } - - if (activity == null || activity.isFinishing()) { - result.error("no_activity", "local_auth plugin requires a foreground activity", null); - return; - } - - if (!(activity instanceof FragmentActivity)) { - result.error( - "no_fragment_activity", - "local_auth plugin requires activity to be a FragmentActivity.", - null); - return; - } - - if (!isDeviceSupported()) { - authInProgress.set(false); - result.error("NotAvailable", "Required security features not enabled", null); - return; - } - - authInProgress.set(true); - AuthCompletionHandler completionHandler = - new AuthCompletionHandler() { - @Override - public void onSuccess() { - authenticateSuccess(result); - } - - @Override - public void onFailure() { - authenticateFail(result); - } - - @Override - public void onError(String code, String error) { - if (authInProgress.compareAndSet(true, false)) { - result.error(code, error, null); - } - } - }; - - // if is biometricOnly try biometric prompt - might not work - boolean isBiometricOnly = call.argument("biometricOnly"); - if (isBiometricOnly) { - if (!canAuthenticateWithBiometrics()) { - if (!hasBiometricHardware()) { - completionHandler.onError("NoHardware", "No biometric hardware found"); - } - completionHandler.onError("NotEnrolled", "No biometrics enrolled on this device."); - return; - } - authHelper = - new AuthenticationHelper( - lifecycle, (FragmentActivity) activity, call, completionHandler, false); - authHelper.authenticate(); - return; - } - - // API 29 and above - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - authHelper = - new AuthenticationHelper( - lifecycle, (FragmentActivity) activity, call, completionHandler, true); - authHelper.authenticate(); - return; - } - - // API 23 - 28 with fingerprint - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && fingerprintManager != null) { - if (fingerprintManager.hasEnrolledFingerprints()) { - authHelper = - new AuthenticationHelper( - lifecycle, (FragmentActivity) activity, call, completionHandler, false); - authHelper.authenticate(); - return; - } - } - - // API 23 or higher with device credentials - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && keyguardManager != null - && keyguardManager.isDeviceSecure()) { - String title = call.argument("signInTitle"); - String reason = call.argument("localizedReason"); - Intent authIntent = keyguardManager.createConfirmDeviceCredentialIntent(title, reason); - - // save result for async response - lockRequestResult = result; - activity.startActivityForResult(authIntent, LOCK_REQUEST_CODE); - return; - } - - // Unable to authenticate - result.error("NotSupported", "This device does not support required security features", null); - } - - private void authenticateSuccess(Result result) { - if (authInProgress.compareAndSet(true, false)) { - result.success(true); - } - } - - private void authenticateFail(Result result) { - if (authInProgress.compareAndSet(true, false)) { - result.success(false); - } - } - - /* - * Stops the authentication if in progress. - */ - private void stopAuthentication(Result result) { - try { - if (authHelper != null && authInProgress.get()) { - authHelper.stopAuthentication(); - authHelper = null; - } - authInProgress.set(false); - result.success(true); - } catch (Exception e) { - result.success(false); - } - } - - /* - * Returns biometric types available on device - */ - private void getAvailableBiometrics(final Result result) { - try { - if (activity == null || activity.isFinishing()) { - result.error("no_activity", "local_auth plugin requires a foreground activity", null); - return; - } - ArrayList biometrics = getAvailableBiometrics(); - result.success(biometrics); - } catch (Exception e) { - result.error("no_biometrics_available", e.getMessage(), null); - } - } - - private ArrayList getAvailableBiometrics() { - ArrayList biometrics = new ArrayList<>(); - if (activity == null || activity.isFinishing()) { - return biometrics; - } - PackageManager packageManager = activity.getPackageManager(); - if (Build.VERSION.SDK_INT >= 23) { - if (packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { - biometrics.add("fingerprint"); - } - } - if (Build.VERSION.SDK_INT >= 29) { - if (packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) { - biometrics.add("face"); - } - if (packageManager.hasSystemFeature(PackageManager.FEATURE_IRIS)) { - biometrics.add("iris"); - } - } - - return biometrics; - } - - private boolean isDeviceSupported() { - if (keyguardManager == null) return false; - return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && keyguardManager.isDeviceSecure()); - } - - private boolean canAuthenticateWithBiometrics() { - if (biometricManager == null) return false; - return biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS; - } - - private boolean hasBiometricHardware() { - if (biometricManager == null) return false; - return biometricManager.canAuthenticate() != BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE; - } - - private void isDeviceSupported(Result result) { - result.success(isDeviceSupported()); - } - - @Override - public void onAttachedToEngine(FlutterPluginBinding binding) { - channel = new MethodChannel(binding.getFlutterEngine().getDartExecutor(), CHANNEL_NAME); - channel.setMethodCallHandler(this); - } - - @Override - public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} - - private void setServicesFromActivity(Activity activity) { - if (activity == null) return; - this.activity = activity; - Context context = activity.getBaseContext(); - biometricManager = BiometricManager.from(activity); - keyguardManager = (KeyguardManager) context.getSystemService(KEYGUARD_SERVICE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - fingerprintManager = - (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE); - } - } - - @Override - public void onAttachedToActivity(ActivityPluginBinding binding) { - binding.addActivityResultListener(resultListener); - setServicesFromActivity(binding.getActivity()); - lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding); - channel.setMethodCallHandler(this); - } - - @Override - public void onDetachedFromActivityForConfigChanges() { - lifecycle = null; - activity = null; - } - - @Override - public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) { - binding.addActivityResultListener(resultListener); - setServicesFromActivity(binding.getActivity()); - lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding); - } - - @Override - public void onDetachedFromActivity() { - lifecycle = null; - channel.setMethodCallHandler(null); - activity = null; - } - - @VisibleForTesting - final Activity getActivity() { - return activity; - } -} diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml deleted file mode 100644 index 610f7cd92bae..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml deleted file mode 100644 index 78e42a8d7f7b..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml deleted file mode 100644 index 5020d067e1e0..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml deleted file mode 100644 index 99caef98dd7b..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml deleted file mode 100644 index 42d8eef7e929..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml deleted file mode 100644 index f32d4a4f4d79..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml b/packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml deleted file mode 100644 index 8c932d4d19c8..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml b/packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml deleted file mode 100644 index a99dd6a607bb..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - diff --git a/packages/local_auth/local_auth/android/src/main/res/values/colors.xml b/packages/local_auth/local_auth/android/src/main/res/values/colors.xml deleted file mode 100644 index c011fe33787c..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/values/colors.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - #E53935 - #BDBDBD - #43A047 - #212121 - #757575 - diff --git a/packages/local_auth/local_auth/android/src/main/res/values/dimens.xml b/packages/local_auth/local_auth/android/src/main/res/values/dimens.xml deleted file mode 100644 index 678faebffd61..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/values/dimens.xml +++ /dev/null @@ -1,5 +0,0 @@ - - 14sp - 16sp - 20sp - diff --git a/packages/local_auth/local_auth/android/src/main/res/values/styles.xml b/packages/local_auth/local_auth/android/src/main/res/values/styles.xml deleted file mode 100644 index 7a0719f41882..000000000000 --- a/packages/local_auth/local_auth/android/src/main/res/values/styles.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java b/packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java deleted file mode 100644 index 41868e603ad8..000000000000 --- a/packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package io.flutter.plugins.localauth; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.app.Activity; -import android.content.Context; -import androidx.lifecycle.Lifecycle; -import io.flutter.embedding.engine.FlutterEngine; -import io.flutter.embedding.engine.dart.DartExecutor; -import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding; -import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; -import io.flutter.embedding.engine.plugins.lifecycle.HiddenLifecycleReference; -import io.flutter.plugin.common.MethodCall; -import io.flutter.plugin.common.MethodChannel; -import org.junit.Test; - -public class LocalAuthTest { - @Test - public void isDeviceSupportedReturnsFalse() { - final LocalAuthPlugin plugin = new LocalAuthPlugin(); - final MethodChannel.Result mockResult = mock(MethodChannel.Result.class); - plugin.onMethodCall(new MethodCall("isDeviceSupported", null), mockResult); - verify(mockResult).success(false); - } - - @Test - public void onDetachedFromActivity_ShouldReleaseActivity() { - final Activity mockActivity = mock(Activity.class); - final ActivityPluginBinding mockActivityBinding = mock(ActivityPluginBinding.class); - when(mockActivityBinding.getActivity()).thenReturn(mockActivity); - - Context mockContext = mock(Context.class); - when(mockActivity.getBaseContext()).thenReturn(mockContext); - - final HiddenLifecycleReference mockLifecycleReference = mock(HiddenLifecycleReference.class); - when(mockActivityBinding.getLifecycle()).thenReturn(mockLifecycleReference); - - final Lifecycle mockLifecycle = mock(Lifecycle.class); - when(mockLifecycleReference.getLifecycle()).thenReturn(mockLifecycle); - - final FlutterPluginBinding mockPluginBinding = mock(FlutterPluginBinding.class); - final FlutterEngine mockFlutterEngine = mock(FlutterEngine.class); - when(mockPluginBinding.getFlutterEngine()).thenReturn(mockFlutterEngine); - - DartExecutor mockDartExecutor = mock(DartExecutor.class); - when(mockFlutterEngine.getDartExecutor()).thenReturn(mockDartExecutor); - - final LocalAuthPlugin plugin = new LocalAuthPlugin(); - plugin.onAttachedToEngine(mockPluginBinding); - plugin.onAttachedToActivity(mockActivityBinding); - assertNotNull(plugin.getActivity()); - - plugin.onDetachedFromActivity(); - assertNull(plugin.getActivity()); - } -} diff --git a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj index 3de4b94f9d5c..32bfa9c097d5 100644 --- a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -226,7 +226,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1100; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { 3398D2CC26163948005A052F = { diff --git a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 58a5d07a15c8..b2af55dd6d37 100644 --- a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ - -@interface FLTLocalAuthPlugin : NSObject -@end diff --git a/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m deleted file mode 100644 index c2dc9db25fc8..000000000000 --- a/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -#import - -#import "FLTLocalAuthPlugin.h" - -@interface FLTLocalAuthPlugin () -@property(nonatomic, copy, nullable) NSDictionary *lastCallArgs; -@property(nonatomic, nullable) FlutterResult lastResult; -// For unit tests to inject dummy LAContext instances that will be used when a new context would -// normally be created. Each call to createAuthContext will remove the current first element from -// the array. -- (void)setAuthContextOverrides:(NSArray *)authContexts; -@end - -@implementation FLTLocalAuthPlugin { - NSMutableArray *_authContextOverrides; -} - -+ (void)registerWithRegistrar:(NSObject *)registrar { - FlutterMethodChannel *channel = - [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/local_auth" - binaryMessenger:[registrar messenger]]; - FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init]; - [registrar addMethodCallDelegate:instance channel:channel]; - [registrar addApplicationDelegate:instance]; -} - -- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { - if ([@"authenticate" isEqualToString:call.method]) { - bool isBiometricOnly = [call.arguments[@"biometricOnly"] boolValue]; - if (isBiometricOnly) { - [self authenticateWithBiometrics:call.arguments withFlutterResult:result]; - } else { - [self authenticate:call.arguments withFlutterResult:result]; - } - } else if ([@"getAvailableBiometrics" isEqualToString:call.method]) { - [self getAvailableBiometrics:result]; - } else if ([@"isDeviceSupported" isEqualToString:call.method]) { - result(@YES); - } else { - result(FlutterMethodNotImplemented); - } -} - -#pragma mark Private Methods - -- (void)setAuthContextOverrides:(NSArray *)authContexts { - _authContextOverrides = [authContexts mutableCopy]; -} - -- (LAContext *)createAuthContext { - if ([_authContextOverrides count] > 0) { - LAContext *context = [_authContextOverrides firstObject]; - [_authContextOverrides removeObjectAtIndex:0]; - return context; - } - return [[LAContext alloc] init]; -} - -- (void)alertMessage:(NSString *)message - firstButton:(NSString *)firstButton - flutterResult:(FlutterResult)result - additionalButton:(NSString *)secondButton { - UIAlertController *alert = - [UIAlertController alertControllerWithTitle:@"" - message:message - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:firstButton - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - result(@NO); - }]; - - [alert addAction:defaultAction]; - if (secondButton != nil) { - UIAlertAction *additionalAction = [UIAlertAction - actionWithTitle:secondButton - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - if (UIApplicationOpenSettingsURLString != NULL) { - NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; - [[UIApplication sharedApplication] openURL:url]; - result(@NO); - } - }]; - [alert addAction:additionalAction]; - } - [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alert - animated:YES - completion:nil]; -} - -- (void)getAvailableBiometrics:(FlutterResult)result { - LAContext *context = self.createAuthContext; - NSError *authError = nil; - NSMutableArray *biometrics = [[NSMutableArray alloc] init]; - if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics - error:&authError]) { - if (authError == nil) { - if (@available(iOS 11.0.1, *)) { - if (context.biometryType == LABiometryTypeFaceID) { - [biometrics addObject:@"face"]; - } else if (context.biometryType == LABiometryTypeTouchID) { - [biometrics addObject:@"fingerprint"]; - } - } else { - [biometrics addObject:@"fingerprint"]; - } - } - } else if (authError.code == LAErrorTouchIDNotEnrolled) { - [biometrics addObject:@"undefined"]; - } - result(biometrics); -} - -- (void)authenticateWithBiometrics:(NSDictionary *)arguments - withFlutterResult:(FlutterResult)result { - LAContext *context = self.createAuthContext; - NSError *authError = nil; - self.lastCallArgs = nil; - self.lastResult = nil; - context.localizedFallbackTitle = @""; - - if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics - error:&authError]) { - [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics - localizedReason:arguments[@"localizedReason"] - reply:^(BOOL success, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self handleAuthReplyWithSuccess:success - error:error - flutterArguments:arguments - flutterResult:result]; - }); - }]; - } else { - [self handleErrors:authError flutterArguments:arguments withFlutterResult:result]; - } -} - -- (void)authenticate:(NSDictionary *)arguments withFlutterResult:(FlutterResult)result { - LAContext *context = self.createAuthContext; - NSError *authError = nil; - _lastCallArgs = nil; - _lastResult = nil; - context.localizedFallbackTitle = @""; - - if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError]) { - [context evaluatePolicy:kLAPolicyDeviceOwnerAuthentication - localizedReason:arguments[@"localizedReason"] - reply:^(BOOL success, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self handleAuthReplyWithSuccess:success - error:error - flutterArguments:arguments - flutterResult:result]; - }); - }]; - } else { - [self handleErrors:authError flutterArguments:arguments withFlutterResult:result]; - } -} - -- (void)handleAuthReplyWithSuccess:(BOOL)success - error:(NSError *)error - flutterArguments:(NSDictionary *)arguments - flutterResult:(FlutterResult)result { - NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread."); - if (success) { - result(@YES); - } else { - switch (error.code) { - case LAErrorPasscodeNotSet: - case LAErrorTouchIDNotAvailable: - case LAErrorTouchIDNotEnrolled: - case LAErrorTouchIDLockout: - [self handleErrors:error flutterArguments:arguments withFlutterResult:result]; - return; - case LAErrorSystemCancel: - if ([arguments[@"stickyAuth"] boolValue]) { - self->_lastCallArgs = arguments; - self->_lastResult = result; - return; - } - } - result(@NO); - } -} - -- (void)handleErrors:(NSError *)authError - flutterArguments:(NSDictionary *)arguments - withFlutterResult:(FlutterResult)result { - NSString *errorCode = @"NotAvailable"; - switch (authError.code) { - case LAErrorPasscodeNotSet: - case LAErrorTouchIDNotEnrolled: - if ([arguments[@"useErrorDialogs"] boolValue]) { - [self alertMessage:arguments[@"goToSettingDescriptionIOS"] - firstButton:arguments[@"okButton"] - flutterResult:result - additionalButton:arguments[@"goToSetting"]]; - return; - } - errorCode = authError.code == LAErrorPasscodeNotSet ? @"PasscodeNotSet" : @"NotEnrolled"; - break; - case LAErrorTouchIDLockout: - [self alertMessage:arguments[@"lockOut"] - firstButton:arguments[@"okButton"] - flutterResult:result - additionalButton:nil]; - return; - } - result([FlutterError errorWithCode:errorCode - message:authError.localizedDescription - details:authError.domain]); -} - -#pragma mark - AppDelegate - -- (void)applicationDidBecomeActive:(UIApplication *)application { - if (self.lastCallArgs != nil && self.lastResult != nil) { - [self authenticateWithBiometrics:_lastCallArgs withFlutterResult:self.lastResult]; - } -} - -@end diff --git a/packages/local_auth/local_auth/ios/local_auth.podspec b/packages/local_auth/local_auth/ios/local_auth.podspec deleted file mode 100644 index 4ab779ad50cd..000000000000 --- a/packages/local_auth/local_auth/ios/local_auth.podspec +++ /dev/null @@ -1,23 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html -# -Pod::Spec.new do |s| - s.name = 'local_auth' - s.version = '0.0.1' - s.summary = 'Flutter Local Auth' - s.description = <<-DESC -This Flutter plugin provides means to perform local, on-device authentication of the user. -Downloaded by pub (not CocoaPods). - DESC - s.homepage = 'https://github.com/flutter/plugins' - s.license = { :type => 'BSD', :file => '../LICENSE' } - s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } - s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/local_auth' } - s.documentation_url = 'https://pub.dev/packages/local_auth' - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' - s.dependency 'Flutter' - s.platform = :ios, '9.0' - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } -end - diff --git a/packages/local_auth/local_auth/lib/auth_strings.dart b/packages/local_auth/local_auth/lib/auth_strings.dart deleted file mode 100644 index 537340b79d4e..000000000000 --- a/packages/local_auth/local_auth/lib/auth_strings.dart +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This is a temporary ignore to allow us to land a new set of linter rules in a -// series of manageable patches instead of one gigantic PR. It disables some of -// the new lints that are already failing on this plugin, for this plugin. It -// should be deleted and the failing lints addressed as soon as possible. -// ignore_for_file: public_member_api_docs - -import 'package:intl/intl.dart'; - -/// Android side authentication messages. -/// -/// Provides default values for all messages. -class AndroidAuthMessages { - const AndroidAuthMessages({ - this.biometricHint, - this.biometricNotRecognized, - this.biometricRequiredTitle, - this.biometricSuccess, - this.cancelButton, - this.deviceCredentialsRequiredTitle, - this.deviceCredentialsSetupDescription, - this.goToSettingsButton, - this.goToSettingsDescription, - this.signInTitle, - }); - - final String? biometricHint; - final String? biometricNotRecognized; - final String? biometricRequiredTitle; - final String? biometricSuccess; - final String? cancelButton; - final String? deviceCredentialsRequiredTitle; - final String? deviceCredentialsSetupDescription; - final String? goToSettingsButton; - final String? goToSettingsDescription; - final String? signInTitle; - - Map get args { - return { - 'biometricHint': biometricHint ?? androidBiometricHint, - 'biometricNotRecognized': - biometricNotRecognized ?? androidBiometricNotRecognized, - 'biometricSuccess': biometricSuccess ?? androidBiometricSuccess, - 'biometricRequired': - biometricRequiredTitle ?? androidBiometricRequiredTitle, - 'cancelButton': cancelButton ?? androidCancelButton, - 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? - androidDeviceCredentialsRequiredTitle, - 'deviceCredentialsSetupDescription': deviceCredentialsSetupDescription ?? - androidDeviceCredentialsSetupDescription, - 'goToSetting': goToSettingsButton ?? goToSettings, - 'goToSettingDescription': - goToSettingsDescription ?? androidGoToSettingsDescription, - 'signInTitle': signInTitle ?? androidSignInTitle, - }; - } -} - -/// iOS side authentication messages. -/// -/// Provides default values for all messages. -class IOSAuthMessages { - const IOSAuthMessages({ - this.lockOut, - this.goToSettingsButton, - this.goToSettingsDescription, - this.cancelButton, - }); - - final String? lockOut; - final String? goToSettingsButton; - final String? goToSettingsDescription; - final String? cancelButton; - - Map get args { - return { - 'lockOut': lockOut ?? iOSLockOut, - 'goToSetting': goToSettingsButton ?? goToSettings, - 'goToSettingDescriptionIOS': - goToSettingsDescription ?? iOSGoToSettingsDescription, - 'okButton': cancelButton ?? iOSOkButton, - }; - } -} - -// Strings for local_authentication plugin. Currently supports English. -// Intl.message must be string literals. -String get androidBiometricHint => Intl.message('Verify identity', - desc: - 'Hint message advising the user how to authenticate with biometrics. It is ' - 'used on Android side. Maximum 60 characters.'); - -String get androidBiometricNotRecognized => - Intl.message('Not recognized. Try again.', - desc: 'Message to let the user know that authentication was failed. It ' - 'is used on Android side. Maximum 60 characters.'); - -String get androidBiometricSuccess => Intl.message('Success', - desc: 'Message to let the user know that authentication was successful. It ' - 'is used on Android side. Maximum 60 characters.'); - -String get androidCancelButton => Intl.message('Cancel', - desc: 'Message showed on a button that the user can click to leave the ' - 'current dialog. It is used on Android side. Maximum 30 characters.'); - -String get androidSignInTitle => Intl.message('Authentication required', - desc: 'Message showed as a title in a dialog which indicates the user ' - 'that they need to scan biometric to continue. It is used on ' - 'Android side. Maximum 60 characters.'); - -String get androidBiometricRequiredTitle => Intl.message('Biometric required', - desc: 'Message showed as a title in a dialog which indicates the user ' - 'has not set up biometric authentication on their device. It is used on Android' - ' side. Maximum 60 characters.'); - -String get androidDeviceCredentialsRequiredTitle => Intl.message( - 'Device credentials required', - desc: 'Message showed as a title in a dialog which indicates the user ' - 'has not set up credentials authentication on their device. It is used on Android' - ' side. Maximum 60 characters.'); - -String get androidDeviceCredentialsSetupDescription => Intl.message( - 'Device credentials required', - desc: 'Message advising the user to go to the settings and configure ' - 'device credentials on their device. It shows in a dialog on Android side.'); - -String get goToSettings => Intl.message('Go to settings', - desc: 'Message showed on a button that the user can click to go to ' - 'settings pages from the current dialog. It is used on both Android ' - 'and iOS side. Maximum 30 characters.'); - -String get androidGoToSettingsDescription => Intl.message( - 'Biometric authentication is not set up on your device. Go to ' - '\'Settings > Security\' to add biometric authentication.', - desc: 'Message advising the user to go to the settings and configure ' - 'biometric on their device. It shows in a dialog on Android side.'); - -String get iOSLockOut => Intl.message( - 'Biometric authentication is disabled. Please lock and unlock your screen to ' - 'enable it.', - desc: - 'Message advising the user to re-enable biometrics on their device. It ' - 'shows in a dialog on iOS side.'); - -String get iOSGoToSettingsDescription => Intl.message( - 'Biometric authentication is not set up on your device. Please either enable ' - 'Touch ID or Face ID on your phone.', - desc: - 'Message advising the user to go to the settings and configure Biometrics ' - 'for their device. It shows in a dialog on iOS side.'); - -String get iOSOkButton => Intl.message('OK', - desc: 'Message showed on a button that the user can click to leave the ' - 'current dialog. It is used on iOS side. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart index 3e925c00e5ae..696cc1b35a11 100644 --- a/packages/local_auth/local_auth/lib/local_auth.dart +++ b/packages/local_auth/local_auth/lib/local_auth.dart @@ -1,182 +1,3 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This is a temporary ignore to allow us to land a new set of linter rules in a -// series of manageable patches instead of one gigantic PR. It disables some of -// the new lints that are already failing on this plugin, for this plugin. It -// should be deleted and the failing lints addressed as soon as possible. -// ignore_for_file: public_member_api_docs - -import 'dart:async'; - -import 'package:flutter/foundation.dart' show visibleForTesting; -import 'package:flutter/services.dart'; -import 'package:platform/platform.dart'; - -import 'auth_strings.dart'; -import 'error_codes.dart'; - -enum BiometricType { face, fingerprint, iris } - -const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth'); - -Platform _platform = const LocalPlatform(); - -@visibleForTesting -void setMockPathProviderPlatform(Platform platform) { - _platform = platform; -} - -/// A Flutter plugin for authenticating the user identity locally. -class LocalAuthentication { - /// The `authenticateWithBiometrics` method has been deprecated. - /// Use `authenticate` with `biometricOnly: true` instead - @Deprecated('Use `authenticate` with `biometricOnly: true` instead') - Future authenticateWithBiometrics({ - required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, - AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), - IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), - bool sensitiveTransaction = true, - }) => - authenticate( - localizedReason: localizedReason, - useErrorDialogs: useErrorDialogs, - stickyAuth: stickyAuth, - androidAuthStrings: androidAuthStrings, - iOSAuthStrings: iOSAuthStrings, - sensitiveTransaction: sensitiveTransaction, - biometricOnly: true, - ); - - /// Authenticates the user with biometrics available on the device while also - /// allowing the user to use device authentication - pin, pattern, passcode. - /// - /// Returns a [Future] holding true, if the user successfully authenticated, - /// false otherwise. - /// - /// [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.'. This must not be empty. - /// - /// [useErrorDialogs] = true means the system will attempt to handle user - /// fixable issues encountered while authenticating. For instance, if - /// fingerprint reader exists on the phone but there's no fingerprint - /// registered, the plugin will attempt to take the user to settings to add - /// one. Anything that is not user fixable, such as no biometric sensor on - /// device, will be returned as a [PlatformException]. - /// - /// [stickyAuth] is used when the application goes into background for any - /// reason while the authentication is in progress. Due to security reasons, - /// the authentication has to be stopped at that time. If stickyAuth is set - /// to true, authentication resumes when the app is resumed. If it is set to - /// false (default), then as soon as app is paused a failure message is sent - /// back to Dart and it is up to the client app to restart authentication or - /// do something else. - /// - /// Construct [AndroidAuthStrings] and [IOSAuthStrings] if you want to - /// customize messages in the dialogs. - /// - /// Setting [sensitiveTransaction] to true enables platform specific - /// precautions. For instance, on face unlock, Android opens a confirmation - /// dialog after the face is recognized to make sure the user meant to unlock - /// their phone. - /// - /// Setting [biometricOnly] to true prevents authenticates from using non-biometric - /// local authentication such as pin, passcode, and passcode. - /// - /// Throws an [PlatformException] if there were technical problems with local - /// authentication (e.g. lack of relevant hardware). This might throw - /// [PlatformException] with error code [otherOperatingSystem] on the iOS - /// simulator. - Future authenticate({ - required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, - AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), - IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), - bool sensitiveTransaction = true, - bool biometricOnly = false, - }) async { - assert(localizedReason.isNotEmpty); - - final Map args = { - 'localizedReason': localizedReason, - 'useErrorDialogs': useErrorDialogs, - 'stickyAuth': stickyAuth, - 'sensitiveTransaction': sensitiveTransaction, - 'biometricOnly': biometricOnly, - }; - if (_platform.isIOS) { - args.addAll(iOSAuthStrings.args); - } else if (_platform.isAndroid) { - args.addAll(androidAuthStrings.args); - } else { - throw PlatformException( - code: otherOperatingSystem, - message: 'Local authentication does not support non-Android/iOS ' - 'operating systems.', - details: 'Your operating system is ${_platform.operatingSystem}', - ); - } - return (await _channel.invokeMethod('authenticate', args)) ?? false; - } - - /// Returns true if auth was cancelled successfully. - /// This api only works for Android. - /// Returns false if there was some error or no auth in progress. - /// - /// Returns [Future] bool true or false: - Future stopAuthentication() async { - if (_platform.isAndroid) { - return await _channel.invokeMethod('stopAuthentication') ?? false; - } - return true; - } - - /// Returns true if device is capable of checking biometrics - /// - /// Returns a [Future] bool true or false: - Future get canCheckBiometrics async => - (await _channel.invokeListMethod('getAvailableBiometrics'))! - .isNotEmpty; - - /// Returns true if device is capable of checking biometrics or is able to - /// fail over to device credentials. - /// - /// Returns a [Future] bool true or false: - Future isDeviceSupported() async => - (await _channel.invokeMethod('isDeviceSupported')) ?? false; - - /// Returns a list of enrolled biometrics - /// - /// Returns a [Future] List with the following possibilities: - /// - BiometricType.face - /// - BiometricType.fingerprint - /// - BiometricType.iris (not yet implemented) - Future> getAvailableBiometrics() async { - final List result = (await _channel.invokeListMethod( - 'getAvailableBiometrics', - )) ?? - []; - final List biometrics = []; - for (final String value in result) { - switch (value) { - case 'face': - biometrics.add(BiometricType.face); - break; - case 'fingerprint': - biometrics.add(BiometricType.fingerprint); - break; - case 'iris': - biometrics.add(BiometricType.iris); - break; - case 'undefined': - break; - } - } - return biometrics; - } -} +export 'package:local_auth/src/local_auth.dart' show LocalAuthentication; +export 'package:local_auth_platform_interface/types/biometric_type.dart' + show BiometricType; diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart new file mode 100644 index 000000000000..b6bba9ebeaab --- /dev/null +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -0,0 +1,146 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This is a temporary ignore to allow us to land a new set of linter rules in a +// series of manageable patches instead of one gigantic PR. It disables some of +// the new lints that are already failing on this plugin, for this plugin. It +// should be deleted and the failing lints addressed as soon as possible. +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/foundation.dart' show visibleForTesting; +import 'package:flutter/services.dart'; +import 'package:local_auth/src/types/error_codes.dart'; +import 'package:local_auth_android/types/auth_strings_android.dart'; +import 'package:local_auth_ios/types/auth_strings_ios.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; +import 'package:platform/platform.dart'; + +Platform _platform = const LocalPlatform(); + +@visibleForTesting +void setMockPathProviderPlatform(Platform platform) { + _platform = platform; +} + +/// A Flutter plugin for authenticating the user identity locally. +class LocalAuthentication { + /// The `authenticateWithBiometrics` method has been deprecated. + /// Use `authenticate` with `biometricOnly: true` instead + @Deprecated('Use `authenticate` with `biometricOnly: true` instead') + Future authenticateWithBiometrics({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), + IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), + bool sensitiveTransaction = true, + }) => + authenticate( + localizedReason: localizedReason, + useErrorDialogs: useErrorDialogs, + stickyAuth: stickyAuth, + androidAuthStrings: androidAuthStrings, + iOSAuthStrings: iOSAuthStrings, + sensitiveTransaction: sensitiveTransaction, + biometricOnly: true, + ); + + /// Authenticates the user with biometrics available on the device while also + /// allowing the user to use device authentication - pin, pattern, passcode. + /// + /// Returns a [Future] holding true, if the user successfully authenticated, + /// false otherwise. + /// + /// [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.'. This must not be empty. + /// + /// [useErrorDialogs] = true means the system will attempt to handle user + /// fixable issues encountered while authenticating. For instance, if + /// fingerprint reader exists on the phone but there's no fingerprint + /// registered, the plugin will attempt to take the user to settings to add + /// one. Anything that is not user fixable, such as no biometric sensor on + /// device, will be returned as a [PlatformException]. + /// + /// [stickyAuth] is used when the application goes into background for any + /// reason while the authentication is in progress. Due to security reasons, + /// the authentication has to be stopped at that time. If stickyAuth is set + /// to true, authentication resumes when the app is resumed. If it is set to + /// false (default), then as soon as app is paused a failure message is sent + /// back to Dart and it is up to the client app to restart authentication or + /// do something else. + /// + /// Construct [AndroidAuthStrings] and [IOSAuthStrings] if you want to + /// customize messages in the dialogs. + /// + /// Setting [sensitiveTransaction] to true enables platform specific + /// precautions. For instance, on face unlock, Android opens a confirmation + /// dialog after the face is recognized to make sure the user meant to unlock + /// their phone. + /// + /// Setting [biometricOnly] to true prevents authenticates from using non-biometric + /// local authentication such as pin, passcode, and passcode. + /// + /// Throws an [PlatformException] if there were technical problems with local + /// authentication (e.g. lack of relevant hardware). This might throw + /// [PlatformException] with error code [otherOperatingSystem] on the iOS + /// simulator. + Future authenticate({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), + IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), + bool sensitiveTransaction = true, + bool biometricOnly = false, + }) { + return LocalAuthPlatform.instance.authenticate( + localizedReason: localizedReason, + useErrorDialogs: useErrorDialogs, + stickyAuth: stickyAuth, + authStrings: {} + ..addAll(androidAuthStrings.args) + ..addAll(iOSAuthStrings.args), + sensitiveTransaction: sensitiveTransaction, + biometricOnly: biometricOnly, + ); + } + + /// Returns true if auth was cancelled successfully. + /// This api only works for Android. + /// Returns false if there was some error or no auth in progress. + /// + /// Returns [Future] bool true or false: + Future stopAuthentication() async { + if (_platform.isAndroid) { + return LocalAuthPlatform.instance.stopAuthentication(); + } + return true; + } + + /// Returns true if device is capable of checking biometrics + /// + /// Returns a [Future] bool true or false: + Future get canCheckBiometrics async => + (await getAvailableBiometrics()).isNotEmpty; + + /// Returns true if device is capable of checking biometrics or is able to + /// fail over to device credentials. + /// + /// Returns a [Future] bool true or false: + Future isDeviceSupported() async => + LocalAuthPlatform.instance.isDeviceSupported(); + + /// Returns a list of enrolled biometrics + /// + /// Returns a [Future] List with the following possibilities: + /// - BiometricType.face + /// - BiometricType.fingerprint + /// - BiometricType.iris (not yet implemented) + Future> getAvailableBiometrics() => + LocalAuthPlatform.instance.getAvailableBiometrics(); +} diff --git a/packages/local_auth/local_auth/lib/error_codes.dart b/packages/local_auth/local_auth/lib/src/types/error_codes.dart similarity index 93% rename from packages/local_auth/local_auth/lib/error_codes.dart rename to packages/local_auth/local_auth/lib/src/types/error_codes.dart index bcf15b7b2154..3426099bacbd 100644 --- a/packages/local_auth/local_auth/lib/error_codes.dart +++ b/packages/local_auth/local_auth/lib/src/types/error_codes.dart @@ -15,7 +15,7 @@ const String notEnrolled = 'NotEnrolled'; /// Indicates the device does not have a Touch ID/fingerprint scanner. const String notAvailable = 'NotAvailable'; -/// Indicates the device operating system is not iOS or Android. +/// Indicates the device operating system is unsupported. const String otherOperatingSystem = 'OtherOperatingSystem'; /// Indicates the API lock out due to too many attempts. diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index 08215c566040..82a2f1489b30 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -1,29 +1,33 @@ 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. -repository: https://github.com/flutter/plugins/tree/main/packages/local_auth +repository: https://github.com/flutter/plugins/tree/master/packages/local_auth issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 version: 1.1.10 environment: sdk: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" + flutter: ">=2.8.0" flutter: plugin: platforms: android: - package: io.flutter.plugins.localauth - pluginClass: LocalAuthPlugin + default_package: local_auth_android ios: - pluginClass: FLTLocalAuthPlugin + default_package: local_auth_ios dependencies: flutter: sdk: flutter - flutter_plugin_android_lifecycle: ^2.0.1 intl: ^0.17.0 - platform: ^3.0.0 + platform: ^3.0.2 + local_auth_platform_interface: + path: ../local_auth_platform_interface + local_auth_ios: + path: ../local_auth_ios + local_auth_android: + path: ../local_auth_android dev_dependencies: flutter_driver: @@ -33,3 +37,4 @@ dev_dependencies: integration_test: sdk: flutter pedantic: ^1.10.0 + mockito: ^5.0.0 diff --git a/packages/local_auth/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart index 758b9cec0e97..c0a0a5a4881b 100644 --- a/packages/local_auth/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/local_auth/test/local_auth_test.dart @@ -2,174 +2,154 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - -import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:local_auth/auth_strings.dart'; import 'package:local_auth/local_auth.dart'; +import 'package:local_auth/src/local_auth.dart'; +import 'package:local_auth_android/types/auth_strings_android.dart'; +import 'package:local_auth_ios/types/auth_strings_ios.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + WidgetsFlutterBinding.ensureInitialized(); + late LocalAuthentication localAuthentication; + late MockLocalAuthPlatform mockLocalAuthPlatform; + + setUp(() { + localAuthentication = LocalAuthentication(); + mockLocalAuthPlatform = MockLocalAuthPlatform(); + LocalAuthPlatform.instance = mockLocalAuthPlatform; + }); + + test('authenticateWithBiometrics calls platform implementation', () { + when(mockLocalAuthPlatform.authenticate( + localizedReason: anyNamed('localizedReason'), + authStrings: anyNamed('authStrings'), + useErrorDialogs: anyNamed('useErrorDialogs'), + stickyAuth: anyNamed('stickyAuth'), + sensitiveTransaction: anyNamed('sensitiveTransaction'), + biometricOnly: anyNamed('biometricOnly'), + )).thenAnswer((_) async => true); + localAuthentication.authenticateWithBiometrics( + localizedReason: 'Test Reason'); + verify(mockLocalAuthPlatform.authenticate( + localizedReason: 'Test Reason', + authStrings: {} + ..addAll(const AndroidAuthMessages().args) + ..addAll(const IOSAuthMessages().args), + useErrorDialogs: true, + stickyAuth: false, + sensitiveTransaction: true, + biometricOnly: true, + )).called(1); + }); + + test('authenticate calls platform implementation', () { + when(mockLocalAuthPlatform.authenticate( + localizedReason: anyNamed('localizedReason'), + authStrings: anyNamed('authStrings'), + useErrorDialogs: anyNamed('useErrorDialogs'), + stickyAuth: anyNamed('stickyAuth'), + sensitiveTransaction: anyNamed('sensitiveTransaction'), + biometricOnly: anyNamed('biometricOnly'), + )).thenAnswer((_) async => true); + localAuthentication.authenticate(localizedReason: 'Test Reason'); + verify(mockLocalAuthPlatform.authenticate( + localizedReason: 'Test Reason', + authStrings: {} + ..addAll(const AndroidAuthMessages().args) + ..addAll(const IOSAuthMessages().args), + useErrorDialogs: true, + stickyAuth: false, + sensitiveTransaction: true, + biometricOnly: false, + )).called(1); + }); - group('LocalAuth', () { - const MethodChannel channel = MethodChannel( - 'plugins.flutter.io/local_auth', - ); + test('isDeviceSupported calls platform implementation', () { + when(mockLocalAuthPlatform.isDeviceSupported()) + .thenAnswer((_) async => true); + localAuthentication.isDeviceSupported(); + verify(mockLocalAuthPlatform.isDeviceSupported()).called(1); + }); - final List log = []; - late LocalAuthentication localAuthentication; + test('getAvailableBiometrics calls platform implementation', () { + when(mockLocalAuthPlatform.getAvailableBiometrics()) + .thenAnswer((_) async => []); + localAuthentication.getAvailableBiometrics(); + verify(mockLocalAuthPlatform.getAvailableBiometrics()).called(1); + }); - setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) { - log.add(methodCall); - return Future.value(true); - }); - localAuthentication = LocalAuthentication(); - log.clear(); - }); + test('stopAuthentication calls platform implementation on Android', () { + when(mockLocalAuthPlatform.stopAuthentication()) + .thenAnswer((_) async => true); + setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); + localAuthentication.stopAuthentication(); + verify(mockLocalAuthPlatform.stopAuthentication()).called(1); + }); - group('With device auth fail over', () { - test('authenticate with no args on Android.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); - await localAuthentication.authenticate( - localizedReason: 'Needs secure', - biometricOnly: true, - ); - expect( - log, - [ - isMethodCall('authenticate', - arguments: { - 'localizedReason': 'Needs secure', - 'useErrorDialogs': true, - 'stickyAuth': false, - 'sensitiveTransaction': true, - 'biometricOnly': true, - }..addAll(const AndroidAuthMessages().args)), - ], - ); - }); + test('stopAuthentication does not call platform implementation on iOS', () { + setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); + localAuthentication.stopAuthentication(); + verifyNever(mockLocalAuthPlatform.stopAuthentication()); + }); - test('authenticate with no args on iOS.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); - await localAuthentication.authenticate( - localizedReason: 'Needs secure', - biometricOnly: true, - ); - expect( - log, - [ - isMethodCall('authenticate', - arguments: { - 'localizedReason': 'Needs secure', - 'useErrorDialogs': true, - 'stickyAuth': false, - 'sensitiveTransaction': true, - 'biometricOnly': true, - }..addAll(const IOSAuthMessages().args)), - ], - ); - }); + test('canCheckBiometrics returns correct result', () async { + when(mockLocalAuthPlatform.getAvailableBiometrics()) + .thenAnswer((_) async => []); + bool? result; + result = await localAuthentication.canCheckBiometrics; + expect(result, false); + when(mockLocalAuthPlatform.getAvailableBiometrics()) + .thenAnswer((_) async => [BiometricType.face]); + result = await localAuthentication.canCheckBiometrics; + expect(result, true); + verify(mockLocalAuthPlatform.getAvailableBiometrics()).called(2); + }); +} - test('authenticate with no localizedReason on iOS.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); - await expectLater( - localAuthentication.authenticate( - localizedReason: '', - biometricOnly: true, - ), - throwsAssertionError, - ); - }); +class MockLocalAuthPlatform extends Mock + with MockPlatformInterfaceMixin + implements LocalAuthPlatform { + MockLocalAuthPlatform() { + throwOnMissingStub(this); + } - test('authenticate with no sensitive transaction.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); - await localAuthentication.authenticate( - localizedReason: 'Insecure', - sensitiveTransaction: false, - useErrorDialogs: false, - biometricOnly: true, - ); - expect( - log, - [ - isMethodCall('authenticate', - arguments: { - 'localizedReason': 'Insecure', - 'useErrorDialogs': false, - 'stickyAuth': false, - 'sensitiveTransaction': false, - 'biometricOnly': true, - }..addAll(const AndroidAuthMessages().args)), - ], - ); - }); - }); + @override + Future authenticate( + {String? localizedReason, + bool? useErrorDialogs = true, + bool? stickyAuth = false, + Map? authStrings, + bool? sensitiveTransaction = true, + bool? biometricOnly = false}) => + super.noSuchMethod( + Invocation.method(#authenticate, [], { + #localizedReason: localizedReason, + #useErrorDialogs: useErrorDialogs, + #stickyAuth: stickyAuth, + #authStrings: authStrings, + #sensitiveTransaction: sensitiveTransaction, + #biometricOnly: biometricOnly + }), + returnValue: Future.value(false)) as Future; - group('With biometrics only', () { - test('authenticate with no args on Android.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); - await localAuthentication.authenticate( - localizedReason: 'Needs secure', - ); - expect( - log, - [ - isMethodCall('authenticate', - arguments: { - 'localizedReason': 'Needs secure', - 'useErrorDialogs': true, - 'stickyAuth': false, - 'sensitiveTransaction': true, - 'biometricOnly': false, - }..addAll(const AndroidAuthMessages().args)), - ], - ); - }); + @override + Future> getAvailableBiometrics() => + super.noSuchMethod(Invocation.method(#getAvailableBiometrics, []), + returnValue: Future>.value([])) + as Future>; - test('authenticate with no args on iOS.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); - await localAuthentication.authenticate( - localizedReason: 'Needs secure', - ); - expect( - log, - [ - isMethodCall('authenticate', - arguments: { - 'localizedReason': 'Needs secure', - 'useErrorDialogs': true, - 'stickyAuth': false, - 'sensitiveTransaction': true, - 'biometricOnly': false, - }..addAll(const IOSAuthMessages().args)), - ], - ); - }); + @override + Future isDeviceSupported() => + super.noSuchMethod(Invocation.method(#isDeviceSupported, []), + returnValue: Future.value(false)) as Future; - test('authenticate with no sensitive transaction.', () async { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); - await localAuthentication.authenticate( - localizedReason: 'Insecure', - sensitiveTransaction: false, - useErrorDialogs: false, - ); - expect( - log, - [ - isMethodCall('authenticate', - arguments: { - 'localizedReason': 'Insecure', - 'useErrorDialogs': false, - 'stickyAuth': false, - 'sensitiveTransaction': false, - 'biometricOnly': false, - }..addAll(const AndroidAuthMessages().args)), - ], - ); - }); - }); - }); + @override + Future stopAuthentication() => + super.noSuchMethod(Invocation.method(#stopAuthentication, []), + returnValue: Future.value(false)) as Future; } From 414d74b8147700a4df47deac089f2f96e800ee11 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 15:11:37 +0100 Subject: [PATCH 05/53] Fix format --- packages/local_auth/local_auth/pubspec.yaml | 2 +- packages/local_auth/local_auth_platform_interface/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index 08215c566040..cd9d0d9760f4 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -1,7 +1,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. -repository: https://github.com/flutter/plugins/tree/main/packages/local_auth +repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 version: 1.1.10 diff --git a/packages/local_auth/local_auth_platform_interface/pubspec.yaml b/packages/local_auth/local_auth_platform_interface/pubspec.yaml index 0f88856bf4ee..cdc8f3d31a0c 100644 --- a/packages/local_auth/local_auth_platform_interface/pubspec.yaml +++ b/packages/local_auth/local_auth_platform_interface/pubspec.yaml @@ -1,7 +1,7 @@ name: local_auth_platform_interface description: A common platform interface for the local_auth plugin. repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_platform_interface -issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes version: 1.0.0 From c35fd925c2e1179be3d1197c97cce6a0a86c70f7 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 15:20:24 +0100 Subject: [PATCH 06/53] Fix analysis issues --- .../analysis_options.yaml | 4 ---- .../lib/types/auth_strings.dart | 7 +++++-- .../lib/types/biometric_type.dart | 10 +++++++++- .../local_auth_platform_interface/pubspec.yaml | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) delete mode 100644 packages/local_auth/local_auth_platform_interface/analysis_options.yaml diff --git a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml b/packages/local_auth/local_auth_platform_interface/analysis_options.yaml deleted file mode 100644 index a5744c1cfbe7..000000000000 --- a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart index 0ad81392edb9..be75ea1fe880 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart @@ -4,7 +4,10 @@ import 'package:intl/intl.dart'; +/// Message shown on a button that the user can click to go to settings pages +/// from the current dialog. It is used on both Android and iOS sides. +/// Maximum 30 characters. String get goToSettings => Intl.message('Go to settings', - desc: 'Message showed on a button that the user can click to go to ' + desc: 'Message shown on a button that the user can click to go to ' 'settings pages from the current dialog. It is used on both Android ' - 'and iOS side. Maximum 30 characters.'); + 'and iOS sides. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index 23556ab37caa..84a75cc4c3c5 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -2,4 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -enum BiometricType { face, fingerprint, iris } +/// Various types of biometric authentication. +enum BiometricType { + /// Face authentication. + face, + /// Fingerprint authentication. + fingerprint, + /// Iris authentication. + iris, +} diff --git a/packages/local_auth/local_auth_platform_interface/pubspec.yaml b/packages/local_auth/local_auth_platform_interface/pubspec.yaml index cdc8f3d31a0c..f04268926ebd 100644 --- a/packages/local_auth/local_auth_platform_interface/pubspec.yaml +++ b/packages/local_auth/local_auth_platform_interface/pubspec.yaml @@ -13,8 +13,8 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.1.2 intl: ^0.17.0 + plugin_platform_interface: ^2.1.2 dev_dependencies: flutter_test: From 2c6a9a9dec8eb7be78741e63d4228e692a534b6d Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 15:24:32 +0100 Subject: [PATCH 07/53] Fix format --- .../local_auth_platform_interface/lib/types/biometric_type.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index 84a75cc4c3c5..4265b5ef9ad1 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -6,8 +6,10 @@ enum BiometricType { /// Face authentication. face, + /// Fingerprint authentication. fingerprint, + /// Iris authentication. iris, } From 3ebe894589589cda9e1e7813594363dd0eb671c5 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 15:45:46 +0100 Subject: [PATCH 08/53] Fix analysis warnings --- .../local_auth_ios/analysis_options.yaml | 4 --- .../local_auth_ios/example/lib/main.dart | 4 +-- .../local_auth_ios/lib/local_auth_ios.dart | 2 +- .../lib/types/auth_strings_ios.dart | 27 +++++++++++++++++-- .../local_auth/local_auth_ios/pubspec.yaml | 2 +- .../local_auth_ios/test/local_auth_test.dart | 8 +++--- 6 files changed, 33 insertions(+), 14 deletions(-) delete mode 100644 packages/local_auth/local_auth_ios/analysis_options.yaml diff --git a/packages/local_auth/local_auth_ios/analysis_options.yaml b/packages/local_auth/local_auth_ios/analysis_options.yaml deleted file mode 100644 index a5744c1cfbe7..000000000000 --- a/packages/local_auth/local_auth_ios/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart index df4a2efbeff3..3dc87811ee70 100644 --- a/packages/local_auth/local_auth_ios/example/lib/main.dart +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -81,7 +81,7 @@ class _MyAppState extends State { }); authenticated = await auth.authenticate( localizedReason: 'Let OS determine authentication method', - authStrings: IOSAuthMessages().args, + authStrings: const IOSAuthMessages().args, useErrorDialogs: true, stickyAuth: true, ); @@ -114,7 +114,7 @@ class _MyAppState extends State { authenticated = await auth.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', - authStrings: IOSAuthMessages().args, + authStrings: const IOSAuthMessages().args, useErrorDialogs: true, stickyAuth: true, biometricOnly: true, diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart index f9320b591950..979107d09679 100644 --- a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -11,7 +11,7 @@ export 'package:local_auth_platform_interface/types/biometric_type.dart'; const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth_ios'); -// The implementation of [LocalAuthPlatform] for iOS. +/// The implementation of [LocalAuthPlatform] for iOS. class LocalAuthIOS extends LocalAuthPlatform { /// Registers this class as the default instance of [LocalAuthPlatform]. static void registerWith() { diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart index f41831f98a81..9147cf32c117 100644 --- a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart @@ -9,6 +9,7 @@ import 'package:local_auth_platform_interface/types/auth_strings.dart'; /// /// Provides default values for all messages. class IOSAuthMessages { + /// Constructs a new instance. const IOSAuthMessages({ this.lockOut, this.goToSettingsButton, @@ -16,11 +17,25 @@ class IOSAuthMessages { this.cancelButton, }); + /// Message advising the user to re-enable biometrics on their device. + /// It shows in a dialog on iOS. final String? lockOut; + + /// Message shown on a button that the user can click to go to settings pages + /// from the current dialog. It is used on both Android and iOS sides. + /// Maximum 30 characters. final String? goToSettingsButton; + + /// Message advising the user to go to the settings and configure Biometrics + /// for their device. It shows in a dialog on iOS. final String? goToSettingsDescription; + + /// Message shown on a button that the user can click to leave the current + /// dialog. It is used on iOS. + /// Maximum 30 characters. final String? cancelButton; + /// Gets the messaged stored in this class instance as a string map. Map get args { return { 'lockOut': lockOut ?? iOSLockOut, @@ -34,20 +49,28 @@ class IOSAuthMessages { // Strings for local_authentication plugin. Currently supports English. // Intl.message must be string literals. + +/// Message advising the user to re-enable biometrics on their device. +/// It shows in a dialog on iOS. String get iOSLockOut => Intl.message( 'Biometric authentication is disabled. Please lock and unlock your screen to ' 'enable it.', desc: 'Message advising the user to re-enable biometrics on their device. It ' - 'shows in a dialog on iOS side.'); + 'shows in a dialog on the iOS.'); +/// Message advising the user to go to the settings and configure Biometrics +/// for their device. It shows in a dialog on iOS. String get iOSGoToSettingsDescription => Intl.message( 'Biometric authentication is not set up on your device. Please either enable ' 'Touch ID or Face ID on your phone.', desc: 'Message advising the user to go to the settings and configure Biometrics ' - 'for their device. It shows in a dialog on iOS side.'); + 'for their device. It shows in a dialog on iOS.'); +/// Message shown on a button that the user can click to leave the current +/// dialog. It is used on iOS. +/// Maximum 30 characters. String get iOSOkButton => Intl.message('OK', desc: 'Message showed on a button that the user can click to leave the ' 'current dialog. It is used on iOS side. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_ios/pubspec.yaml b/packages/local_auth/local_auth_ios/pubspec.yaml index a3d857d6c8ca..60f3aa977d5f 100644 --- a/packages/local_auth/local_auth_ios/pubspec.yaml +++ b/packages/local_auth/local_auth_ios/pubspec.yaml @@ -20,9 +20,9 @@ environment: dependencies: flutter: sdk: flutter + intl: ^0.17.0 local_auth_platform_interface: path: ../local_auth_platform_interface - intl: ^0.17.0 dev_dependencies: flutter_test: diff --git a/packages/local_auth/local_auth_ios/test/local_auth_test.dart b/packages/local_auth/local_auth_ios/test/local_auth_test.dart index 685cb6a77a5c..316e3644a933 100644 --- a/packages/local_auth/local_auth_ios/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_ios/test/local_auth_test.dart @@ -32,7 +32,7 @@ void main() { group('With device auth fail over', () { test('authenticate with no args on iOS.', () async { await localAuthentication.authenticate( - authStrings: IOSAuthMessages().args, + authStrings: const IOSAuthMessages().args, localizedReason: 'Needs secure', biometricOnly: true, ); @@ -54,7 +54,7 @@ void main() { test('authenticate with no localizedReason on iOS.', () async { await expectLater( localAuthentication.authenticate( - authStrings: IOSAuthMessages().args, + authStrings: const IOSAuthMessages().args, localizedReason: '', biometricOnly: true, ), @@ -66,7 +66,7 @@ void main() { group('With biometrics only', () { test('authenticate with no args on iOS.', () async { await localAuthentication.authenticate( - authStrings: IOSAuthMessages().args, + authStrings: const IOSAuthMessages().args, localizedReason: 'Needs secure', ); expect( @@ -86,7 +86,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: IOSAuthMessages().args, + authStrings: const IOSAuthMessages().args, localizedReason: 'Insecure', sensitiveTransaction: false, useErrorDialogs: false, From deea66cd209dbc2199bbb02dbca5968ec66b560d Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 26 Jan 2022 17:02:08 +0100 Subject: [PATCH 09/53] Fix analysis warnings --- .../local_auth_android/analysis_options.yaml | 4 - .../local_auth_android/example/lib/main.dart | 4 +- .../lib/local_auth_android.dart | 2 +- .../lib/types/auth_strings_android.dart | 87 +++++++++++++++---- .../local_auth_android/pubspec.yaml | 4 +- .../test/local_auth_test.dart | 8 +- 6 files changed, 81 insertions(+), 28 deletions(-) delete mode 100644 packages/local_auth/local_auth_android/analysis_options.yaml diff --git a/packages/local_auth/local_auth_android/analysis_options.yaml b/packages/local_auth/local_auth_android/analysis_options.yaml deleted file mode 100644 index a5744c1cfbe7..000000000000 --- a/packages/local_auth/local_auth_android/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart index 094d7a0cd8cc..4328f28136c2 100644 --- a/packages/local_auth/local_auth_android/example/lib/main.dart +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -81,7 +81,7 @@ class _MyAppState extends State { }); authenticated = await auth.authenticate( localizedReason: 'Let OS determine authentication method', - authStrings: AndroidAuthMessages().args, + authStrings: const AndroidAuthMessages().args, useErrorDialogs: true, stickyAuth: true); setState(() { @@ -113,7 +113,7 @@ class _MyAppState extends State { authenticated = await auth.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', - authStrings: AndroidAuthMessages().args, + authStrings: const AndroidAuthMessages().args, useErrorDialogs: true, stickyAuth: true, biometricOnly: true); diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index a048a4620d6d..0f82e7cf9158 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -11,7 +11,7 @@ export 'package:local_auth_platform_interface/types/biometric_type.dart'; const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth_android'); -// The implementation of [LocalAuthPlatform] for Android. +/// The implementation of [LocalAuthPlatform] for Android. class LocalAuthAndroid extends LocalAuthPlatform { /// Registers this class as the default instance of [LocalAuthPlatform]. static void registerWith() { diff --git a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart index f67aa8aaa3d5..9d9886ce7168 100644 --- a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart +++ b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart @@ -9,6 +9,7 @@ import 'package:local_auth_platform_interface/types/auth_strings.dart'; /// /// Provides default values for all messages. class AndroidAuthMessages { + /// Constructs a new instance. const AndroidAuthMessages({ this.biometricHint, this.biometricNotRecognized, @@ -22,17 +23,51 @@ class AndroidAuthMessages { this.signInTitle, }); + /// Hint message advising the user how to authenticate with biometrics. It is + /// used on Android. Maximum 60 characters. final String? biometricHint; + + /// Message to let the user know that authentication was failed. It is used + /// on Android. Maximum 60 characters.' final String? biometricNotRecognized; + + /// Message shown as a title in a dialog which indicates the user + /// has not set up biometric authentication on their device. It is used on + /// Android. Maximum 60 characters. final String? biometricRequiredTitle; + + /// Message to let the user know that authentication was successful. It + /// is used on Android. Maximum 60 characters final String? biometricSuccess; + + /// Message shown on a button that the user can click to leave the + /// current dialog. It is used on Android. Maximum 30 characters. final String? cancelButton; + + /// Message shown as a title in a dialog which indicates the user + /// has not set up credentials authentication on their device. It is used on Android. + /// Maximum 60 characters. final String? deviceCredentialsRequiredTitle; + + /// Message advising the user to go to the settings and configure + /// device credentials on their device. It shows in a dialog on Android. final String? deviceCredentialsSetupDescription; + + /// Message shown on a button that the user can click to go to settings pages + /// from the current dialog. It is used on both Android and iOS sides. + /// Maximum 30 characters. final String? goToSettingsButton; + + /// Message advising the user to go to the settings and configure + /// biometric on their device. It shows in a dialog on Android. final String? goToSettingsDescription; + + /// Message shown as a title in a dialog which indicates the user + /// that they need to scan biometric to continue. It is used on + /// Android. Maximum 60 characters. final String? signInTitle; + /// Gets the messaged stored in this class instance as a string map. Map get args { return { 'biometricHint': biometricHint ?? androidBiometricHint, @@ -56,47 +91,69 @@ class AndroidAuthMessages { // Strings for local_authentication plugin. Currently supports English. // Intl.message must be string literals. + +/// Hint message advising the user how to authenticate with biometrics. It is +/// used on Android. Maximum 60 characters. String get androidBiometricHint => Intl.message('Verify identity', desc: 'Hint message advising the user how to authenticate with biometrics. It is ' - 'used on Android side. Maximum 60 characters.'); + 'used on Android. Maximum 60 characters.'); +/// Message to let the user know that authentication was failed. It is used +/// on Android. Maximum 60 characters.' String get androidBiometricNotRecognized => Intl.message('Not recognized. Try again.', desc: 'Message to let the user know that authentication was failed. It ' - 'is used on Android side. Maximum 60 characters.'); + 'is used on Android. Maximum 60 characters.'); +/// Message to let the user know that authentication was successful. It +/// is used on Android. Maximum 60 characters String get androidBiometricSuccess => Intl.message('Success', desc: 'Message to let the user know that authentication was successful. It ' - 'is used on Android side. Maximum 60 characters.'); + 'is used on Android. Maximum 60 characters.'); +/// Message shown on a button that the user can click to leave the +/// current dialog. It is used on Android. Maximum 30 characters. String get androidCancelButton => Intl.message('Cancel', - desc: 'Message showed on a button that the user can click to leave the ' - 'current dialog. It is used on Android side. Maximum 30 characters.'); + desc: 'Message shown on a button that the user can click to leave the ' + 'current dialog. It is used on Android. Maximum 30 characters.'); +/// Message shown as a title in a dialog which indicates the user +/// that they need to scan biometric to continue. It is used on +/// Android. Maximum 60 characters. String get androidSignInTitle => Intl.message('Authentication required', - desc: 'Message showed as a title in a dialog which indicates the user ' + desc: 'Message shown as a title in a dialog which indicates the user ' 'that they need to scan biometric to continue. It is used on ' - 'Android side. Maximum 60 characters.'); + 'Android. Maximum 60 characters.'); +/// Message shown as a title in a dialog which indicates the user +/// has not set up biometric authentication on their device. It is used on +/// Android. Maximum 60 characters. String get androidBiometricRequiredTitle => Intl.message('Biometric required', - desc: 'Message showed as a title in a dialog which indicates the user ' - 'has not set up biometric authentication on their device. It is used on Android' - ' side. Maximum 60 characters.'); + desc: 'Message shown as a title in a dialog which indicates the user ' + 'has not set up biometric authentication on their device. It is used on Android.' + ' Maximum 60 characters.'); +/// Message shown as a title in a dialog which indicates the user +/// has not set up credentials authentication on their device. It is used on Android. +/// Maximum 60 characters. String get androidDeviceCredentialsRequiredTitle => Intl.message( 'Device credentials required', - desc: 'Message showed as a title in a dialog which indicates the user ' - 'has not set up credentials authentication on their device. It is used on Android' - ' side. Maximum 60 characters.'); + desc: 'Message shown as a title in a dialog which indicates the user ' + 'has not set up credentials authentication on their device. It is used on Android.' + ' Maximum 60 characters.'); +/// Message advising the user to go to the settings and configure +/// device credentials on their device. It shows in a dialog on Android. String get androidDeviceCredentialsSetupDescription => Intl.message( 'Device credentials required', desc: 'Message advising the user to go to the settings and configure ' - 'device credentials on their device. It shows in a dialog on Android side.'); + 'device credentials on their device. It shows in a dialog on Android.'); +/// Message advising the user to go to the settings and configure +/// biometric on their device. It shows in a dialog on Android. String get androidGoToSettingsDescription => Intl.message( 'Biometric authentication is not set up on your device. Go to ' '\'Settings > Security\' to add biometric authentication.', desc: 'Message advising the user to go to the settings and configure ' - 'biometric on their device. It shows in a dialog on Android side.'); + 'biometric on their device. It shows in a dialog on Android.'); diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index f146022b62a0..e677132205f2 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -21,10 +21,10 @@ environment: dependencies: flutter: sdk: flutter + flutter_plugin_android_lifecycle: ^2.0.1 + intl: ^0.17.0 local_auth_platform_interface: path: ../local_auth_platform_interface - intl: ^0.17.0 - flutter_plugin_android_lifecycle: ^2.0.1 dev_dependencies: flutter_test: diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart index f026ecaba591..b81884be8051 100644 --- a/packages/local_auth/local_auth_android/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -32,7 +32,7 @@ void main() { group('With device auth fail over', () { test('authenticate with no args on Android.', () async { await localAuthentication.authenticate( - authStrings: AndroidAuthMessages().args, + authStrings: const AndroidAuthMessages().args, localizedReason: 'Needs secure', biometricOnly: true, ); @@ -53,7 +53,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: AndroidAuthMessages().args, + authStrings: const AndroidAuthMessages().args, localizedReason: 'Insecure', sensitiveTransaction: false, useErrorDialogs: false, @@ -78,7 +78,7 @@ void main() { group('With biometrics only', () { test('authenticate with no args on Android.', () async { await localAuthentication.authenticate( - authStrings: AndroidAuthMessages().args, + authStrings: const AndroidAuthMessages().args, localizedReason: 'Needs secure', ); expect( @@ -98,7 +98,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: AndroidAuthMessages().args, + authStrings: const AndroidAuthMessages().args, localizedReason: 'Insecure', sensitiveTransaction: false, useErrorDialogs: false, From bd35a9f9b606fab56ebb03985f2bc967a52d449b Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 10:00:30 +0100 Subject: [PATCH 10/53] Move local_auth plugin into a subfolder in preparation for federation migration --- packages/local_auth/{ => local_auth}/AUTHORS | 0 packages/local_auth/{ => local_auth}/CHANGELOG.md | 0 packages/local_auth/{ => local_auth}/LICENSE | 0 packages/local_auth/{ => local_auth}/README.md | 0 .../{ => local_auth}/android/build.gradle | 0 .../{ => local_auth}/android/lint-baseline.xml | 0 .../{ => local_auth}/android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../plugins/localauth/AuthenticationHelper.java | 0 .../flutter/plugins/localauth/LocalAuthPlugin.java | 0 .../main/res/drawable/fingerprint_initial_icon.xml | 0 .../main/res/drawable/fingerprint_success_icon.xml | 0 .../main/res/drawable/fingerprint_warning_icon.xml | 0 .../src/main/res/drawable/ic_done_white_24dp.xml | 0 .../main/res/drawable/ic_fingerprint_white_24dp.xml | 0 .../res/drawable/ic_priority_high_white_24dp.xml | 0 .../android/src/main/res/layout/go_to_setting.xml | 0 .../android/src/main/res/layout/scan_fp.xml | 0 .../android/src/main/res/values/colors.xml | 0 .../android/src/main/res/values/dimens.xml | 0 .../android/src/main/res/values/styles.xml | 0 .../io/flutter/plugins/localauth/LocalAuthTest.java | 0 .../local_auth/{ => local_auth}/example/README.md | 0 .../example/android/app/build.gradle | 0 .../app/gradle/wrapper/gradle-wrapper.properties | 0 .../io/flutter/plugins/DartIntegrationTest.java | 0 .../localauth/FlutterFragmentActivityTest.java | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../{ => local_auth}/example/android/build.gradle | 0 .../example/android/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.properties | 0 .../example/android/settings.gradle | 0 .../example/android/settings_aar.gradle | 0 .../example/integration_test/local_auth_test.dart | 0 .../example/ios/Flutter/AppFrameworkInfo.plist | 0 .../example/ios/Flutter/Debug.xcconfig | 0 .../example/ios/Flutter/Release.xcconfig | 0 .../local_auth/{ => local_auth}/example/ios/Podfile | 0 .../example/ios/Runner.xcodeproj/project.pbxproj | 0 .../project.xcworkspace/contents.xcworkspacedata | 0 .../xcshareddata/xcschemes/Runner.xcscheme | 0 .../ios/Runner.xcworkspace/contents.xcworkspacedata | 0 .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../example/ios/Runner/AppDelegate.h | 0 .../example/ios/Runner/AppDelegate.m | 0 .../AppIcon.appiconset/Contents.json | 0 .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin .../AppIcon.appiconset/Icon-App-83.5x83.5@2x.png | Bin .../ios/Runner/Base.lproj/LaunchScreen.storyboard | 0 .../example/ios/Runner/Base.lproj/Main.storyboard | 0 .../{ => local_auth}/example/ios/Runner/Info.plist | 0 .../{ => local_auth}/example/ios/Runner/main.m | 0 .../ios/RunnerTests/FLTLocalAuthPluginTests.m | 0 .../example/ios/RunnerTests/Info.plist | 0 .../{ => local_auth}/example/lib/main.dart | 0 .../{ => local_auth}/example/pubspec.yaml | 0 .../example/test_driver/integration_test.dart | 0 .../local_auth/{ => local_auth}/ios/Assets/.gitkeep | 0 .../ios/Classes/FLTLocalAuthPlugin.h | 0 .../ios/Classes/FLTLocalAuthPlugin.m | 0 .../{ => local_auth}/ios/local_auth.podspec | 0 .../{ => local_auth}/lib/auth_strings.dart | 0 .../{ => local_auth}/lib/error_codes.dart | 0 .../local_auth/{ => local_auth}/lib/local_auth.dart | 0 packages/local_auth/{ => local_auth}/pubspec.yaml | 2 +- .../{ => local_auth}/test/local_auth_test.dart | 0 83 files changed, 1 insertion(+), 1 deletion(-) rename packages/local_auth/{ => local_auth}/AUTHORS (100%) rename packages/local_auth/{ => local_auth}/CHANGELOG.md (100%) rename packages/local_auth/{ => local_auth}/LICENSE (100%) rename packages/local_auth/{ => local_auth}/README.md (100%) rename packages/local_auth/{ => local_auth}/android/build.gradle (100%) rename packages/local_auth/{ => local_auth}/android/lint-baseline.xml (100%) rename packages/local_auth/{ => local_auth}/android/settings.gradle (100%) rename packages/local_auth/{ => local_auth}/android/src/main/AndroidManifest.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java (100%) rename packages/local_auth/{ => local_auth}/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/fingerprint_initial_icon.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/fingerprint_success_icon.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/fingerprint_warning_icon.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/ic_done_white_24dp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/drawable/ic_priority_high_white_24dp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/layout/go_to_setting.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/layout/scan_fp.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/values/colors.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/values/dimens.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/main/res/values/styles.xml (100%) rename packages/local_auth/{ => local_auth}/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java (100%) rename packages/local_auth/{ => local_auth}/example/README.md (100%) rename packages/local_auth/{ => local_auth}/example/android/app/build.gradle (100%) rename packages/local_auth/{ => local_auth}/example/android/app/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/AndroidManifest.xml (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename packages/local_auth/{ => local_auth}/example/android/build.gradle (100%) rename packages/local_auth/{ => local_auth}/example/android/gradle.properties (100%) rename packages/local_auth/{ => local_auth}/example/android/gradle/wrapper/gradle-wrapper.properties (100%) rename packages/local_auth/{ => local_auth}/example/android/settings.gradle (100%) rename packages/local_auth/{ => local_auth}/example/android/settings_aar.gradle (100%) rename packages/local_auth/{ => local_auth}/example/integration_test/local_auth_test.dart (100%) rename packages/local_auth/{ => local_auth}/example/ios/Flutter/AppFrameworkInfo.plist (100%) rename packages/local_auth/{ => local_auth}/example/ios/Flutter/Debug.xcconfig (100%) rename packages/local_auth/{ => local_auth}/example/ios/Flutter/Release.xcconfig (100%) rename packages/local_auth/{ => local_auth}/example/ios/Podfile (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcodeproj/project.pbxproj (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcworkspace/contents.xcworkspacedata (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/AppDelegate.h (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/AppDelegate.m (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Base.lproj/LaunchScreen.storyboard (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Base.lproj/Main.storyboard (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/Info.plist (100%) rename packages/local_auth/{ => local_auth}/example/ios/Runner/main.m (100%) rename packages/local_auth/{ => local_auth}/example/ios/RunnerTests/FLTLocalAuthPluginTests.m (100%) rename packages/local_auth/{ => local_auth}/example/ios/RunnerTests/Info.plist (100%) rename packages/local_auth/{ => local_auth}/example/lib/main.dart (100%) rename packages/local_auth/{ => local_auth}/example/pubspec.yaml (100%) rename packages/local_auth/{ => local_auth}/example/test_driver/integration_test.dart (100%) rename packages/local_auth/{ => local_auth}/ios/Assets/.gitkeep (100%) rename packages/local_auth/{ => local_auth}/ios/Classes/FLTLocalAuthPlugin.h (100%) rename packages/local_auth/{ => local_auth}/ios/Classes/FLTLocalAuthPlugin.m (100%) rename packages/local_auth/{ => local_auth}/ios/local_auth.podspec (100%) rename packages/local_auth/{ => local_auth}/lib/auth_strings.dart (100%) rename packages/local_auth/{ => local_auth}/lib/error_codes.dart (100%) rename packages/local_auth/{ => local_auth}/lib/local_auth.dart (100%) rename packages/local_auth/{ => local_auth}/pubspec.yaml (97%) rename packages/local_auth/{ => local_auth}/test/local_auth_test.dart (100%) diff --git a/packages/local_auth/AUTHORS b/packages/local_auth/local_auth/AUTHORS similarity index 100% rename from packages/local_auth/AUTHORS rename to packages/local_auth/local_auth/AUTHORS diff --git a/packages/local_auth/CHANGELOG.md b/packages/local_auth/local_auth/CHANGELOG.md similarity index 100% rename from packages/local_auth/CHANGELOG.md rename to packages/local_auth/local_auth/CHANGELOG.md diff --git a/packages/local_auth/LICENSE b/packages/local_auth/local_auth/LICENSE similarity index 100% rename from packages/local_auth/LICENSE rename to packages/local_auth/local_auth/LICENSE diff --git a/packages/local_auth/README.md b/packages/local_auth/local_auth/README.md similarity index 100% rename from packages/local_auth/README.md rename to packages/local_auth/local_auth/README.md diff --git a/packages/local_auth/android/build.gradle b/packages/local_auth/local_auth/android/build.gradle similarity index 100% rename from packages/local_auth/android/build.gradle rename to packages/local_auth/local_auth/android/build.gradle diff --git a/packages/local_auth/android/lint-baseline.xml b/packages/local_auth/local_auth/android/lint-baseline.xml similarity index 100% rename from packages/local_auth/android/lint-baseline.xml rename to packages/local_auth/local_auth/android/lint-baseline.xml diff --git a/packages/local_auth/android/settings.gradle b/packages/local_auth/local_auth/android/settings.gradle similarity index 100% rename from packages/local_auth/android/settings.gradle rename to packages/local_auth/local_auth/android/settings.gradle diff --git a/packages/local_auth/android/src/main/AndroidManifest.xml b/packages/local_auth/local_auth/android/src/main/AndroidManifest.xml similarity index 100% rename from packages/local_auth/android/src/main/AndroidManifest.xml rename to packages/local_auth/local_auth/android/src/main/AndroidManifest.xml diff --git a/packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java b/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java similarity index 100% rename from packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java rename to packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java diff --git a/packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java similarity index 100% rename from packages/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java rename to packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java diff --git a/packages/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml diff --git a/packages/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml diff --git a/packages/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml diff --git a/packages/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml diff --git a/packages/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml diff --git a/packages/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml b/packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml rename to packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml diff --git a/packages/local_auth/android/src/main/res/layout/go_to_setting.xml b/packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml similarity index 100% rename from packages/local_auth/android/src/main/res/layout/go_to_setting.xml rename to packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml diff --git a/packages/local_auth/android/src/main/res/layout/scan_fp.xml b/packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml similarity index 100% rename from packages/local_auth/android/src/main/res/layout/scan_fp.xml rename to packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml diff --git a/packages/local_auth/android/src/main/res/values/colors.xml b/packages/local_auth/local_auth/android/src/main/res/values/colors.xml similarity index 100% rename from packages/local_auth/android/src/main/res/values/colors.xml rename to packages/local_auth/local_auth/android/src/main/res/values/colors.xml diff --git a/packages/local_auth/android/src/main/res/values/dimens.xml b/packages/local_auth/local_auth/android/src/main/res/values/dimens.xml similarity index 100% rename from packages/local_auth/android/src/main/res/values/dimens.xml rename to packages/local_auth/local_auth/android/src/main/res/values/dimens.xml diff --git a/packages/local_auth/android/src/main/res/values/styles.xml b/packages/local_auth/local_auth/android/src/main/res/values/styles.xml similarity index 100% rename from packages/local_auth/android/src/main/res/values/styles.xml rename to packages/local_auth/local_auth/android/src/main/res/values/styles.xml diff --git a/packages/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java b/packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java similarity index 100% rename from packages/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java rename to packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java diff --git a/packages/local_auth/example/README.md b/packages/local_auth/local_auth/example/README.md similarity index 100% rename from packages/local_auth/example/README.md rename to packages/local_auth/local_auth/example/README.md diff --git a/packages/local_auth/example/android/app/build.gradle b/packages/local_auth/local_auth/example/android/app/build.gradle similarity index 100% rename from packages/local_auth/example/android/app/build.gradle rename to packages/local_auth/local_auth/example/android/app/build.gradle diff --git a/packages/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties rename to packages/local_auth/local_auth/example/android/app/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java b/packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java similarity index 100% rename from packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java rename to packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java diff --git a/packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java b/packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java similarity index 100% rename from packages/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java rename to packages/local_auth/local_auth/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java diff --git a/packages/local_auth/example/android/app/src/main/AndroidManifest.xml b/packages/local_auth/local_auth/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from packages/local_auth/example/android/app/src/main/AndroidManifest.xml rename to packages/local_auth/local_auth/example/android/app/src/main/AndroidManifest.xml diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from packages/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to packages/local_auth/local_auth/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/packages/local_auth/example/android/build.gradle b/packages/local_auth/local_auth/example/android/build.gradle similarity index 100% rename from packages/local_auth/example/android/build.gradle rename to packages/local_auth/local_auth/example/android/build.gradle diff --git a/packages/local_auth/example/android/gradle.properties b/packages/local_auth/local_auth/example/android/gradle.properties similarity index 100% rename from packages/local_auth/example/android/gradle.properties rename to packages/local_auth/local_auth/example/android/gradle.properties diff --git a/packages/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from packages/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties rename to packages/local_auth/local_auth/example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/packages/local_auth/example/android/settings.gradle b/packages/local_auth/local_auth/example/android/settings.gradle similarity index 100% rename from packages/local_auth/example/android/settings.gradle rename to packages/local_auth/local_auth/example/android/settings.gradle diff --git a/packages/local_auth/example/android/settings_aar.gradle b/packages/local_auth/local_auth/example/android/settings_aar.gradle similarity index 100% rename from packages/local_auth/example/android/settings_aar.gradle rename to packages/local_auth/local_auth/example/android/settings_aar.gradle diff --git a/packages/local_auth/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth/example/integration_test/local_auth_test.dart similarity index 100% rename from packages/local_auth/example/integration_test/local_auth_test.dart rename to packages/local_auth/local_auth/example/integration_test/local_auth_test.dart diff --git a/packages/local_auth/example/ios/Flutter/AppFrameworkInfo.plist b/packages/local_auth/local_auth/example/ios/Flutter/AppFrameworkInfo.plist similarity index 100% rename from packages/local_auth/example/ios/Flutter/AppFrameworkInfo.plist rename to packages/local_auth/local_auth/example/ios/Flutter/AppFrameworkInfo.plist diff --git a/packages/local_auth/example/ios/Flutter/Debug.xcconfig b/packages/local_auth/local_auth/example/ios/Flutter/Debug.xcconfig similarity index 100% rename from packages/local_auth/example/ios/Flutter/Debug.xcconfig rename to packages/local_auth/local_auth/example/ios/Flutter/Debug.xcconfig diff --git a/packages/local_auth/example/ios/Flutter/Release.xcconfig b/packages/local_auth/local_auth/example/ios/Flutter/Release.xcconfig similarity index 100% rename from packages/local_auth/example/ios/Flutter/Release.xcconfig rename to packages/local_auth/local_auth/example/ios/Flutter/Release.xcconfig diff --git a/packages/local_auth/example/ios/Podfile b/packages/local_auth/local_auth/example/ios/Podfile similarity index 100% rename from packages/local_auth/example/ios/Podfile rename to packages/local_auth/local_auth/example/ios/Podfile diff --git a/packages/local_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj similarity index 100% rename from packages/local_auth/example/ios/Runner.xcodeproj/project.pbxproj rename to packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj diff --git a/packages/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/packages/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from packages/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to packages/local_auth/local_auth/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/packages/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from packages/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata rename to packages/local_auth/local_auth/example/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/packages/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/local_auth/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from packages/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to packages/local_auth/local_auth/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/packages/local_auth/example/ios/Runner/AppDelegate.h b/packages/local_auth/local_auth/example/ios/Runner/AppDelegate.h similarity index 100% rename from packages/local_auth/example/ios/Runner/AppDelegate.h rename to packages/local_auth/local_auth/example/ios/Runner/AppDelegate.h diff --git a/packages/local_auth/example/ios/Runner/AppDelegate.m b/packages/local_auth/local_auth/example/ios/Runner/AppDelegate.m similarity index 100% rename from packages/local_auth/example/ios/Runner/AppDelegate.m rename to packages/local_auth/local_auth/example/ios/Runner/AppDelegate.m diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from packages/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to packages/local_auth/local_auth/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/packages/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/local_auth/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from packages/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to packages/local_auth/local_auth/example/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/packages/local_auth/example/ios/Runner/Base.lproj/Main.storyboard b/packages/local_auth/local_auth/example/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from packages/local_auth/example/ios/Runner/Base.lproj/Main.storyboard rename to packages/local_auth/local_auth/example/ios/Runner/Base.lproj/Main.storyboard diff --git a/packages/local_auth/example/ios/Runner/Info.plist b/packages/local_auth/local_auth/example/ios/Runner/Info.plist similarity index 100% rename from packages/local_auth/example/ios/Runner/Info.plist rename to packages/local_auth/local_auth/example/ios/Runner/Info.plist diff --git a/packages/local_auth/example/ios/Runner/main.m b/packages/local_auth/local_auth/example/ios/Runner/main.m similarity index 100% rename from packages/local_auth/example/ios/Runner/main.m rename to packages/local_auth/local_auth/example/ios/Runner/main.m diff --git a/packages/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m b/packages/local_auth/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m similarity index 100% rename from packages/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m rename to packages/local_auth/local_auth/example/ios/RunnerTests/FLTLocalAuthPluginTests.m diff --git a/packages/local_auth/example/ios/RunnerTests/Info.plist b/packages/local_auth/local_auth/example/ios/RunnerTests/Info.plist similarity index 100% rename from packages/local_auth/example/ios/RunnerTests/Info.plist rename to packages/local_auth/local_auth/example/ios/RunnerTests/Info.plist diff --git a/packages/local_auth/example/lib/main.dart b/packages/local_auth/local_auth/example/lib/main.dart similarity index 100% rename from packages/local_auth/example/lib/main.dart rename to packages/local_auth/local_auth/example/lib/main.dart diff --git a/packages/local_auth/example/pubspec.yaml b/packages/local_auth/local_auth/example/pubspec.yaml similarity index 100% rename from packages/local_auth/example/pubspec.yaml rename to packages/local_auth/local_auth/example/pubspec.yaml diff --git a/packages/local_auth/example/test_driver/integration_test.dart b/packages/local_auth/local_auth/example/test_driver/integration_test.dart similarity index 100% rename from packages/local_auth/example/test_driver/integration_test.dart rename to packages/local_auth/local_auth/example/test_driver/integration_test.dart diff --git a/packages/local_auth/ios/Assets/.gitkeep b/packages/local_auth/local_auth/ios/Assets/.gitkeep similarity index 100% rename from packages/local_auth/ios/Assets/.gitkeep rename to packages/local_auth/local_auth/ios/Assets/.gitkeep diff --git a/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.h b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h similarity index 100% rename from packages/local_auth/ios/Classes/FLTLocalAuthPlugin.h rename to packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h diff --git a/packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m similarity index 100% rename from packages/local_auth/ios/Classes/FLTLocalAuthPlugin.m rename to packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m diff --git a/packages/local_auth/ios/local_auth.podspec b/packages/local_auth/local_auth/ios/local_auth.podspec similarity index 100% rename from packages/local_auth/ios/local_auth.podspec rename to packages/local_auth/local_auth/ios/local_auth.podspec diff --git a/packages/local_auth/lib/auth_strings.dart b/packages/local_auth/local_auth/lib/auth_strings.dart similarity index 100% rename from packages/local_auth/lib/auth_strings.dart rename to packages/local_auth/local_auth/lib/auth_strings.dart diff --git a/packages/local_auth/lib/error_codes.dart b/packages/local_auth/local_auth/lib/error_codes.dart similarity index 100% rename from packages/local_auth/lib/error_codes.dart rename to packages/local_auth/local_auth/lib/error_codes.dart diff --git a/packages/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart similarity index 100% rename from packages/local_auth/lib/local_auth.dart rename to packages/local_auth/local_auth/lib/local_auth.dart diff --git a/packages/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml similarity index 97% rename from packages/local_auth/pubspec.yaml rename to packages/local_auth/local_auth/pubspec.yaml index 08215c566040..cd9d0d9760f4 100644 --- a/packages/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -1,7 +1,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. -repository: https://github.com/flutter/plugins/tree/main/packages/local_auth +repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/local_auth issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 version: 1.1.10 diff --git a/packages/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart similarity index 100% rename from packages/local_auth/test/local_auth_test.dart rename to packages/local_auth/local_auth/test/local_auth_test.dart From e10bbb855c694527d353f7f81dda2b5ad0c3e8ae Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 11:36:10 +0100 Subject: [PATCH 11/53] Process PR Feedback --- .../lib/default_method_channel_platform.dart | 65 +++++++ .../lib/local_auth_platform_interface.dart | 39 +--- .../lib/types/auth_options.dart | 40 ++++ .../lib/types/biometric_type.dart | 10 + ...default_methbod_channel_platform_test.dart | 172 ++++++++++++++++++ 5 files changed, 294 insertions(+), 32 deletions(-) create mode 100644 packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart create mode 100644 packages/local_auth/local_auth_platform_interface/test/default_methbod_channel_platform_test.dart diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart new file mode 100644 index 000000000000..5256f3d6070d --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -0,0 +1,65 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth'); + +/// The default interface implementation acting as a placeholder for +/// the native implementation to be set. +class DefaultLocalAuthPlatform extends LocalAuthPlatform { + @override + Future authenticate({ + required String localizedReason, + required Map authStrings, + AuthenticationOptions options = const AuthenticationOptions(), + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': options.useErrorDialogs, + 'stickyAuth': options.stickyAuth, + 'sensitiveTransaction': options.sensitiveTransaction, + 'biometricOnly': options.biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async => + await _channel.invokeMethod('stopAuthentication') ?? false; +} diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index 833004b7e032..32f039e86063 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -25,8 +27,9 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// Defaults to [DefaultLocalAuthPlatform]. static LocalAuthPlatform get instance => _instance; - /// Platform-specific plugins should set this with their own platform-specific - /// class that extends [LocalAuthPlatform] when they register themselves. + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [LocalAuthPlatform] when they + /// register themselves. static set instance(LocalAuthPlatform instance) { PlatformInterface.verifyToken(instance, _token); _instance = instance; @@ -42,31 +45,10 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// for authentication. This is typically along the lines of: 'Please scan /// 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 - /// fingerprint reader exists on the phone but there's no fingerprint - /// registered, the plugin will attempt to take the user to settings to add - /// one. Anything that is not user fixable, such as no biometric sensor on - /// device, will be returned as a [PlatformException]. - /// - /// [stickyAuth] is used when the application goes into background for any - /// reason while the authentication is in progress. Due to security reasons, - /// the authentication has to be stopped at that time. If stickyAuth is set - /// to true, authentication resumes when the app is resumed. If it is set to - /// false (default), then as soon as app is paused a failure message is sent - /// back to Dart and it is up to the client app to restart authentication or - /// do something else. - /// /// Provide [authStrings] if you want to /// customize messages in the dialogs. /// - /// Setting [sensitiveTransaction] to true enables platform specific - /// precautions. For instance, on face unlock, Android opens a confirmation - /// dialog after the face is recognized to make sure the user meant to unlock - /// their phone. - /// - /// Setting [biometricOnly] to true prevents authenticates from using non-biometric - /// local authentication such as pin, passcode, and passcode. + /// Provide [options] for configuring further authentication related options. /// /// Throws an [PlatformException] if there were technical problems with local /// authentication (e.g. lack of relevant hardware). This might throw @@ -74,11 +56,8 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// simulator. Future authenticate({ required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, required Map authStrings, - bool sensitiveTransaction = true, - bool biometricOnly = false, + AuthenticationOptions options = const AuthenticationOptions(), }) async { throw UnimplementedError('authenticate() has not been implemented.'); } @@ -110,7 +89,3 @@ abstract class LocalAuthPlatform extends PlatformInterface { throw UnimplementedError('stopAuthentication() has not been implemented.'); } } - -/// The default interface implementation acting as a placeholder for -/// the native implementation to be set. -class DefaultLocalAuthPlatform extends LocalAuthPlatform {} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart new file mode 100644 index 000000000000..8a8efc6c2411 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart @@ -0,0 +1,40 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/// Options wrapper for [LocalAuthPlatform.authenticate] parameters. +class AuthenticationOptions { + /// Construct a new instance. + const AuthenticationOptions({ + this.useErrorDialogs = true, + this.stickyAuth = false, + this.sensitiveTransaction = true, + this.biometricOnly = false, + }); + + /// Whether the system will attempt to handle user fixable issues encountered + /// while authenticating. For instance, if fingerprint reader exists on the + /// phone but there's no fingerprint registered, the plugin will attempt to + /// take the user to settings to add one. Anything that is not user fixable, + /// such as no biometric sensor on device, will be returned + /// as a [PlatformException]. + final bool useErrorDialogs; + + /// Used when the application goes into background for any reason while the + /// authentication is in progress. Due to security reasons, the + /// authentication has to be stopped at that time. If stickyAuth is set to + /// true, authentication resumes when the app is resumed. If it is set to + /// false (default), then as soon as app is paused a failure message is sent + /// back to Dart and it is up to the client app to restart authentication or + /// do something else. + final bool stickyAuth; + + /// Whether platform specific precautions are enabled. For instance, on face + /// unlock, Android opens a confirmation dialog after the face is recognized + /// to make sure the user meant to unlock their phone. + final bool sensitiveTransaction; + + /// Prevent authentications from using non-biometric local authentication + /// such as pin, passcode, and passcode. + final bool biometricOnly; +} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index 4265b5ef9ad1..9c7d2eb8d83e 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -12,4 +12,14 @@ enum BiometricType { /// Iris authentication. iris, + + /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets + /// or exceeds the requirements for Class 3 (formerly Strong), as defined + /// by the Android CDD. Android only. + strong, + + /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets + /// or exceeds the requirements for Class 2 (formerly Weak), as defined + /// by the Android CDD. Android only. + weak, } diff --git a/packages/local_auth/local_auth_platform_interface/test/default_methbod_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_methbod_channel_platform_test.dart new file mode 100644 index 000000000000..d1ee3c504c40 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/test/default_methbod_channel_platform_test.dart @@ -0,0 +1,172 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth', + ); + + final List log = []; + late LocalAuthPlatform localAuthentication; + + test('getAvailableBiometrics', () async { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value([]); + }); + localAuthentication = DefaultLocalAuthPlatform(); + log.clear(); + await localAuthentication.getAvailableBiometrics(); + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + }); + + group('Boolean returning methods', () { + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = DefaultLocalAuthPlatform(); + log.clear(); + }); + + test('isDeviceSupported', () async { + await localAuthentication.isDeviceSupported(); + expect( + log, + [ + isMethodCall('isDeviceSupported', arguments: null), + ], + ); + }); + + test('stopAuthentication', () async { + await localAuthentication.stopAuthentication(); + expect( + log, + [ + isMethodCall('stopAuthentication', arguments: null), + ], + ); + }); + + group('authenticate with device auth fail over', () { + test('authenticate with no args.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Needs secure', + options: const AuthenticationOptions(biometricOnly: true), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }, + ), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Insecure', + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + biometricOnly: true, + ), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': true, + }, + ), + ], + ); + }); + }); + + group('authenticate with biometrics only', () { + test('authenticate with no args.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }, + ), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Insecure', + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + ), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }, + ), + ], + ); + }); + }); + }); +} From c3d5a1b2bacc037287beb2a45d8a9f5c5fa3708f Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 11:37:42 +0100 Subject: [PATCH 12/53] Fix typo in file name --- ...atform_test.dart => default_method_channel_platform_test.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/local_auth/local_auth_platform_interface/test/{default_methbod_channel_platform_test.dart => default_method_channel_platform_test.dart} (100%) diff --git a/packages/local_auth/local_auth_platform_interface/test/default_methbod_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart similarity index 100% rename from packages/local_auth/local_auth_platform_interface/test/default_methbod_channel_platform_test.dart rename to packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart From 24556fab012768e42fd5079759c5233483057620 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 12:17:39 +0100 Subject: [PATCH 13/53] Add iOS implementation of platform interface --- packages/local_auth/local_auth/pubspec.yaml | 8 + packages/local_auth/local_auth_ios/AUTHORS | 67 ++ .../local_auth/local_auth_ios/CHANGELOG.md | 3 + packages/local_auth/local_auth_ios/LICENSE | 25 + packages/local_auth/local_auth_ios/README.md | 11 + .../local_auth_ios/example/README.md | 8 + .../integration_test/local_auth_test.dart | 19 + .../ios/Flutter/AppFrameworkInfo.plist | 30 + .../example/ios/Flutter/Debug.xcconfig | 2 + .../example/ios/Flutter/Release.xcconfig | 2 + .../local_auth_ios/example/ios/Podfile | 38 ++ .../ios/Runner.xcodeproj/project.pbxproj | 611 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/xcschemes/Runner.xcscheme | 97 +++ .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../example/ios/Runner/AppDelegate.h | 10 + .../example/ios/Runner/AppDelegate.m | 17 + .../AppIcon.appiconset/Contents.json | 116 ++++ .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 0 -> 564 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 0 -> 1283 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 0 -> 1588 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 0 -> 1025 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 0 -> 1716 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 0 -> 1920 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 0 -> 1283 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 0 -> 1895 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 0 -> 2665 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 0 -> 2665 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 0 -> 3831 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 0 -> 1888 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 0 -> 3294 bytes .../Icon-App-83.5x83.5@2x.png | Bin 0 -> 3612 bytes .../Runner/Base.lproj/LaunchScreen.storyboard | 27 + .../ios/Runner/Base.lproj/Main.storyboard | 26 + .../example/ios/Runner/Info.plist | 51 ++ .../local_auth_ios/example/ios/Runner/main.m | 13 + .../ios/RunnerTests/FLTLocalAuthPluginTests.m | 189 ++++++ .../example/ios/RunnerTests/Info.plist | 22 + .../local_auth_ios/example/lib/main.dart | 233 +++++++ .../local_auth_ios/example/pubspec.yaml | 28 + .../example/test_driver/integration_test.dart | 7 + .../ios/Assets/.gitkeep | 0 .../ios/Classes/FLTLocalAuthPlugin.h | 0 .../ios/Classes/FLTLocalAuthPlugin.m | 2 +- .../ios/local_auth_ios.podspec} | 6 +- .../local_auth_ios/lib/local_auth_ios.dart | 75 +++ .../lib/types/auth_strings_ios.dart | 76 +++ .../local_auth/local_auth_ios/pubspec.yaml | 30 + .../local_auth_ios/test/local_auth_test.dart | 110 ++++ .../analysis_options.yaml | 4 - .../lib/default_method_channel_platform.dart | 65 ++ .../lib/local_auth_platform_interface.dart | 39 +- .../lib/types/auth_options.dart | 40 ++ .../lib/types/auth_strings.dart | 7 +- .../lib/types/biometric_type.dart | 22 +- .../pubspec.yaml | 4 +- .../default_method_channel_platform_test.dart | 172 +++++ 58 files changed, 2292 insertions(+), 45 deletions(-) create mode 100644 packages/local_auth/local_auth_ios/AUTHORS create mode 100644 packages/local_auth/local_auth_ios/CHANGELOG.md create mode 100644 packages/local_auth/local_auth_ios/LICENSE create mode 100644 packages/local_auth/local_auth_ios/README.md create mode 100644 packages/local_auth/local_auth_ios/example/README.md create mode 100644 packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart create mode 100644 packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist create mode 100644 packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig create mode 100644 packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig create mode 100644 packages/local_auth/local_auth_ios/example/ios/Podfile create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/LaunchScreen.storyboard create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist create mode 100644 packages/local_auth/local_auth_ios/example/ios/Runner/main.m create mode 100644 packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m create mode 100644 packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist create mode 100644 packages/local_auth/local_auth_ios/example/lib/main.dart create mode 100644 packages/local_auth/local_auth_ios/example/pubspec.yaml create mode 100644 packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart rename packages/local_auth/{local_auth => local_auth_ios}/ios/Assets/.gitkeep (100%) rename packages/local_auth/{local_auth => local_auth_ios}/ios/Classes/FLTLocalAuthPlugin.h (100%) rename packages/local_auth/{local_auth => local_auth_ios}/ios/Classes/FLTLocalAuthPlugin.m (99%) rename packages/local_auth/{local_auth/ios/local_auth.podspec => local_auth_ios/ios/local_auth_ios.podspec} (83%) create mode 100644 packages/local_auth/local_auth_ios/lib/local_auth_ios.dart create mode 100644 packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart create mode 100644 packages/local_auth/local_auth_ios/pubspec.yaml create mode 100644 packages/local_auth/local_auth_ios/test/local_auth_test.dart delete mode 100644 packages/local_auth/local_auth_platform_interface/analysis_options.yaml create mode 100644 packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart create mode 100644 packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index cd9d0d9760f4..042ddac137f6 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -5,6 +5,10 @@ repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/loc issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 version: 1.1.10 +# Temporarily disable publishing to allow moving Android and iOS +# implementations. +publish_to: none + environment: sdk: ">=2.14.0 <3.0.0" flutter: ">=2.5.0" @@ -17,12 +21,16 @@ flutter: pluginClass: LocalAuthPlugin ios: pluginClass: FLTLocalAuthPlugin + default_package: local_auth_ios dependencies: flutter: sdk: flutter flutter_plugin_android_lifecycle: ^2.0.1 intl: ^0.17.0 + # Temporary path dependencies to allow moving Android and iOS implementations. + local_auth_ios: + path: ../local_auth_ios platform: ^3.0.0 dev_dependencies: diff --git a/packages/local_auth/local_auth_ios/AUTHORS b/packages/local_auth/local_auth_ios/AUTHORS new file mode 100644 index 000000000000..d5694690c247 --- /dev/null +++ b/packages/local_auth/local_auth_ios/AUTHORS @@ -0,0 +1,67 @@ +# Below is a list of people and organizations that have contributed +# to the Flutter project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. +The Chromium Authors +German Saprykin +Benjamin Sauer +larsenthomasj@gmail.com +Ali Bitek +Pol Batlló +Anatoly Pulyaevskiy +Hayden Flinner +Stefano Rodriguez +Salvatore Giordano +Brian Armstrong +Paul DeMarco +Fabricio Nogueira +Simon Lightfoot +Ashton Thomas +Thomas Danner +Diego Velásquez +Hajime Nakamura +Tuyển Vũ Xuân +Miguel Ruivo +Sarthak Verma +Mike Diarmid +Invertase +Elliot Hesp +Vince Varga +Aawaz Gyawali +EUI Limited +Katarina Sheremet +Thomas Stockx +Sarbagya Dhaubanjar +Ozkan Eksi +Rishab Nayak +ko2ic +Jonathan Younger +Jose Sanchez +Debkanchan Samadder +Audrius Karosevicius +Lukasz Piliszczuk +SoundReply Solutions GmbH +Rafal Wachol +Pau Picas +Christian Weder +Alexandru Tuca +Christian Weder +Rhodes Davis Jr. +Luigi Agosti +Quentin Le Guennec +Koushik Ravikumar +Nissim Dsilva +Giancarlo Rocha +Ryo Miyake +Théo Champion +Kazuki Yamaguchi +Eitan Schwartz +Chris Rutkowski +Juan Alvarez +Aleksandr Yurkovskiy +Anton Borries +Alex Li +Rahul Raj <64.rahulraj@gmail.com> +Bodhi Mulders diff --git a/packages/local_auth/local_auth_ios/CHANGELOG.md b/packages/local_auth/local_auth_ios/CHANGELOG.md new file mode 100644 index 000000000000..7f198f2d66c0 --- /dev/null +++ b/packages/local_auth/local_auth_ios/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial release from migration to federated architecture. diff --git a/packages/local_auth/local_auth_ios/LICENSE b/packages/local_auth/local_auth_ios/LICENSE new file mode 100644 index 000000000000..c6823b81eb84 --- /dev/null +++ b/packages/local_auth/local_auth_ios/LICENSE @@ -0,0 +1,25 @@ +Copyright 2013 The Flutter Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/local_auth/local_auth_ios/README.md b/packages/local_auth/local_auth_ios/README.md new file mode 100644 index 000000000000..d9f40436b617 --- /dev/null +++ b/packages/local_auth/local_auth_ios/README.md @@ -0,0 +1,11 @@ +# local\_auth\_ios + +The iOS implementation of [`local_auth`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `local_auth` +normally. This package will be automatically included in your app when you do. + +[1]: https://pub.dev/packages/local_auth +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin diff --git a/packages/local_auth/local_auth_ios/example/README.md b/packages/local_auth/local_auth_ios/example/README.md new file mode 100644 index 000000000000..a4a6091c9ba6 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/README.md @@ -0,0 +1,8 @@ +# local_auth_example + +Demonstrates how to use the local_auth plugin. + +## Getting Started + +For help getting started with Flutter, view our online +[documentation](https://flutter.dev/). diff --git a/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart new file mode 100644 index 000000000000..f941a1bdaeed --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart @@ -0,0 +1,19 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:local_auth_ios/local_auth_ios.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('canCheckBiometrics', (WidgetTester tester) async { + expect( + LocalAuthIOS().getAvailableBiometrics(), + completion(isList), + ); + }); +} diff --git a/packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist b/packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000000..3a9c234f96d4 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + UIRequiredDeviceCapabilities + + arm64 + + MinimumOSVersion + 9.0 + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig b/packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000000..e8efba114687 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig b/packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000000..399e9340e6f6 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/packages/local_auth/local_auth_ios/example/ios/Podfile b/packages/local_auth/local_auth_ios/example/ios/Podfile new file mode 100644 index 000000000000..f7d6a5e68c3a --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Podfile @@ -0,0 +1,38 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000000..6e315792cb90 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,611 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */; }; + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 3398D2D226163948005A052F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3398D2CD26163948005A052F /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3398D2D126163948005A052F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 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; }; + 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTLocalAuthPluginTests.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 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 = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + EB36DF6C3F25E00DF4175422 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3398D2CA26163948005A052F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 33BF11D226680B2E002967F3 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */, + 3398D2D126163948005A052F /* Info.plist */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 33BF11D226680B2E002967F3 /* RunnerTests */, + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + F8CC53B854B121315C7319D2 /* Pods */, + E2D5FA899A019BD3E0DB0917 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 3398D2CD26163948005A052F /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + E2D5FA899A019BD3E0DB0917 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3398D2DF26164A03005A052F /* liblocal_auth.a */, + 3398D2DC261649CD005A052F /* liblocal_auth.a */, + 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + F8CC53B854B121315C7319D2 /* Pods */ = { + isa = PBXGroup; + children = ( + EB36DF6C3F25E00DF4175422 /* Pods-Runner.debug.xcconfig */, + 658CDD04B21E4EA92F8EF229 /* Pods-Runner.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3398D2CC26163948005A052F /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 3398D2C926163948005A052F /* Sources */, + 3398D2CA26163948005A052F /* Frameworks */, + 3398D2CB26163948005A052F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 3398D2D326163948005A052F /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 3398D2CD26163948005A052F /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 98D96A2D1A74AF66E3DD2DBC /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = "The Flutter Authors"; + TargetAttributes = { + 3398D2CC26163948005A052F = { + CreatedOnToolsVersion = 12.4; + ProvisioningStyle = Automatic; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 3398D2CC26163948005A052F /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3398D2CB26163948005A052F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + 98D96A2D1A74AF66E3DD2DBC /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3398D2C926163948005A052F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 3398D2D326163948005A052F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 3398D2D226163948005A052F /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3398D2D526163948005A052F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = RunnerTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Debug; + }; + 3398D2D626163948005A052F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = RunnerTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Release; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.localAuthExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.localAuthExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3398D2D526163948005A052F /* Debug */, + 3398D2D626163948005A052F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000000..919434a6254f --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000000..b2af55dd6d37 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000000..21a3cc14c74e --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h new file mode 100644 index 000000000000..0681d288bb70 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.h @@ -0,0 +1,10 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m new file mode 100644 index 000000000000..30b87969f44a --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/AppDelegate.m @@ -0,0 +1,17 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000000..d22f10b2ab63 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,116 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..28c6bf03016f6c994b70f38d1b7346e5831b531f GIT binary patch literal 564 zcmV-40?Yl0P)Px$?ny*JR5%f>l)FnDQ543{x%ZCiu33$Wg!pQFfT_}?5Q|_VSlIbLC`dpoMXL}9 zHfd9&47Mo(7D231gb+kjFxZHS4-m~7WurTH&doVX2KI5sU4v(sJ1@T9eCIKPjsqSr z)C01LsCxk=72-vXmX}CQD#BD;Cthymh&~=f$Q8nn0J<}ZrusBy4PvRNE}+1ceuj8u z0mW5k8fmgeLnTbWHGwfKA3@PdZxhn|PypR&^p?weGftrtCbjF#+zk_5BJh7;0`#Wr zgDpM_;Ax{jO##IrT`Oz;MvfwGfV$zD#c2xckpcXC6oou4ML~ezCc2EtnsQTB4tWNg z?4bkf;hG7IMfhgNI(FV5Gs4|*GyMTIY0$B=_*mso9Ityq$m^S>15>-?0(zQ<8Qy<_TjHE33(?_M8oaM zyc;NxzRVK@DL6RJnX%U^xW0Gpg(lXp(!uK1v0YgHjs^ZXSQ|m#lV7ip7{`C_J2TxPmfw%h$|%acrYHt)Re^PB%O&&=~a zhS(%I#+V>J-vjIib^<+s%ludY7y^C(P8nmqn9fp!i+?vr`bziDE=bx`%2W#Xyrj|i z!XQ4v1%L`m{7KT7q+LZNB^h8Ha2e=`Wp65^0;J00)_^G=au=8Yo;1b`CV&@#=jIBo zjN^JNVfYSs)+kDdGe7`1&8!?MQYKS?DuHZf3iogk_%#9E|5S zWeHrmAo>P;ejX7mwq#*}W25m^ZI+{(Z8fI?4jM_fffY0nok=+88^|*_DwcW>mR#e+ zX$F_KMdb6sRz!~7KkyN0G(3XQ+;z3X%PZ4gh;n-%62U<*VUKNv(D&Q->Na@Xb&u5Q3`3DGf+a8O5x7c#7+R+EAYl@R5us)CIw z7sT@_y~Ao@uL#&^LIh&QceqiT^+lb0YbFZt_SHOtWA%mgPEKVNvVgCsXy{5+zl*X8 zCJe)Q@y>wH^>l4;h1l^Y*9%-23TSmE>q5nI@?mt%n;Sj4Qq`Z+ib)a*a^cJc%E9^J zB;4s+K@rARbcBLT5P=@r;IVnBMKvT*)ew*R;&8vu%?Z&S>s?8?)3*YawM0P4!q$Kv zMmKh3lgE~&w&v%wVzH3Oe=jeNT=n@Y6J6TdHWTjXfX~-=1A1Bw`EW8rn}MqeI34nh zexFeA?&C3B2(E?0{drE@DA2pu(A#ElY&6el60Rn|Qpn-FkfQ8M93AfWIr)drgDFEU zghdWK)^71EWCP(@(=c4kfH1Y(4iugD4fve6;nSUpLT%!)MUHs1!zJYy4y||C+SwQ! z)KM&$7_tyM`sljP2fz6&Z;jxRn{Wup8IOUx8D4uh&(=O zx-7$a;U><*5L^!%xRlw)vAbh;sdlR||& ze}8_8%)c2Fwy=F&H|LM+p{pZB5DKTx>Y?F1N%BlZkXf!}JeGuMZk~LPi7{cidvUGB zAJ4LVeNV%XO>LTrklB#^-;8nb;}6l;1oW&WS=Mz*Az!4cqqQzbOSFq`$Q%PfD7srM zpKgP-D_0XPTRX*hAqeq0TDkJ;5HB1%$3Np)99#16c{ zJImlNL(npL!W|Gr_kxl1GVmF5&^$^YherS7+~q$p zt}{a=*RiD2Ikv6o=IM1kgc7zqpaZ;OB)P!1zz*i3{U()Dq#jG)egvK}@uFLa`oyWZ zf~=MV)|yJn`M^$N%ul5);JuQvaU1r2wt(}J_Qgyy`qWQI`hEeRX0uC@c1(dQ2}=U$ tNIIaX+dr)NRWXcxoR{>fqI{SF_dm1Ylv~=3YHI)h002ovPDHLkV1g(pWS;;4 literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..f091b6b0bca859a3f474b03065bef75ba58a9e4c GIT binary patch literal 1588 zcmV-42Fv-0P)C1SqPt}wig>|5Crh^=oyX$BK<}M8eLU3e2hGT;=G|!_SP)7zNI6fqUMB=)y zRAZ>eDe#*r`yDAVgB_R*LB*MAc)8(b{g{9McCXW!lq7r(btRoB9!8B-#AI6JMb~YFBEvdsV)`mEQO^&#eRKx@b&x- z5lZm*!WfD8oCLzfHGz#u7sT0^VLMI1MqGxF^v+`4YYnVYgk*=kU?HsSz{v({E3lb9 z>+xILjBN)t6`=g~IBOelGQ(O990@BfXf(DRI5I$qN$0Gkz-FSc$3a+2fX$AedL4u{ z4V+5Ong(9LiGcIKW?_352sR;LtDPmPJXI{YtT=O8=76o9;*n%_m|xo!i>7$IrZ-{l z-x3`7M}qzHsPV@$v#>H-TpjDh2UE$9g6sysUREDy_R(a)>=eHw-WAyfIN z*qb!_hW>G)Tu8nSw9yn#3wFMiLcfc4pY0ek1}8(NqkBR@t4{~oC>ryc-h_ByH(Cg5 z>ao-}771+xE3um9lWAY1FeQFxowa1(!J(;Jg*wrg!=6FdRX+t_<%z&d&?|Bn){>zm zZQj(aA_HeBY&OC^jj*)N`8fa^ePOU72VpInJoI1?`ty#lvlNzs(&MZX+R%2xS~5Kh zX*|AU4QE#~SgPzOXe9>tRj>hjU@c1k5Y_mW*Jp3fI;)1&g3j|zDgC+}2Q_v%YfDax z!?umcN^n}KYQ|a$Lr+51Nf9dkkYFSjZZjkma$0KOj+;aQ&721~t7QUKx61J3(P4P1 zstI~7-wOACnWP4=8oGOwz%vNDqD8w&Q`qcNGGrbbf&0s9L0De{4{mRS?o0MU+nR_! zrvshUau0G^DeMhM_v{5BuLjb#Hh@r23lDAk8oF(C+P0rsBpv85EP>4CVMx#04MOfG z;P%vktHcXwTj~+IE(~px)3*MY77e}p#|c>TD?sMatC0Tu4iKKJ0(X8jxQY*gYtxsC z(zYC$g|@+I+kY;dg_dE>scBf&bP1Nc@Hz<3R)V`=AGkc;8CXqdi=B4l2k|g;2%#m& z*jfX^%b!A8#bI!j9-0Fi0bOXl(-c^AB9|nQaE`*)Hw+o&jS9@7&Gov#HbD~#d{twV zXd^Tr^mWLfFh$@Dr$e;PBEz4(-2q1FF0}c;~B5sA}+Q>TOoP+t>wf)V9Iy=5ruQa;z)y zI9C9*oUga6=hxw6QasLPnee@3^Rr*M{CdaL5=R41nLs(AHk_=Y+A9$2&H(B7!_pURs&8aNw7?`&Z&xY_Ye z)~D5Bog^td-^QbUtkTirdyK^mTHAOuptDflut!#^lnKqU md>ggs(5nOWAqO?umG&QVYK#ibz}*4>0000U6E9hRK9^#O7(mu>ETqrXGsduA8$)?`v2seloOCza43C{NQ$$gAOH**MCn0Q?+L7dl7qnbRdqZ8LSVp1ItDxhxD?t@5_yHg6A8yI zC*%Wgg22K|8E#!~cTNYR~@Y9KepMPrrB8cABapAFa=`H+UGhkXUZV1GnwR1*lPyZ;*K(i~2gp|@bzp8}og7e*#% zEnr|^CWdVV!-4*Y_7rFvlww2Ze+>j*!Z!pQ?2l->4q#nqRu9`ELo6RMS5=br47g_X zRw}P9a7RRYQ%2Vsd0Me{_(EggTnuN6j=-?uFS6j^u69elMypu?t>op*wBx<=Wx8?( ztpe^(fwM6jJX7M-l*k3kEpWOl_Vk3@(_w4oc}4YF4|Rt=2V^XU?#Yz`8(e?aZ@#li0n*=g^qOcVpd-Wbok=@b#Yw zqn8u9a)z>l(1kEaPYZ6hwubN6i<8QHgsu0oE) ziJ(p;Wxm>sf!K+cw>R-(^Y2_bahB+&KI9y^);#0qt}t-$C|Bo71lHi{_+lg#f%RFy z0um=e3$K3i6K{U_4K!EX?F&rExl^W|G8Z8;`5z-k}OGNZ0#WVb$WCpQu-_YsiqKP?BB# vzVHS-CTUF4Ozn5G+mq_~Qqto~ahA+K`|lyv3(-e}00000NkvXXu0mjfd`9t{ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d0ef06e7edb86cdfe0d15b4b0d98334a86163658 GIT binary patch literal 1716 zcmds$`#;kQ7{|XelZftyR5~xW7?MLxS4^|Hw3&P7^y)@A9Fj{Xm1~_CIV^XZ%SLBn zA;!r`GqGHg=7>xrB{?psZQs88ZaedDoagm^KF{a*>G|dJWRSe^I$DNW008I^+;Kjt z>9p3GNR^I;v>5_`+91i(*G;u5|L+Bu6M=(afLjtkya#yZ175|z$pU~>2#^Z_pCZ7o z1c6UNcv2B3?; zX%qdxCXQpdKRz=#b*q0P%b&o)5ZrNZt7$fiETSK_VaY=mb4GK`#~0K#~9^ zcY!`#Af+4h?UMR-gMKOmpuYeN5P*RKF!(tb`)oe0j2BH1l?=>y#S5pMqkx6i{*=V9JF%>N8`ewGhRE(|WohnD59R^$_36{4>S zDFlPC5|k?;SPsDo87!B{6*7eqmMdU|QZ84>6)Kd9wNfh90=y=TFQay-0__>=<4pk& zYDjgIhL-jQ9o>z32K)BgAH+HxamL{ZL~ozu)Qqe@a`FpH=oQRA8=L-m-1dam(Ix2V z?du;LdMO+ooBelr^_y4{|44tmgH^2hSzPFd;U^!1p>6d|o)(-01z{i&Kj@)z-yfWQ)V#3Uo!_U}q3u`(fOs`_f^ueFii1xBNUB z6MecwJN$CqV&vhc+)b(p4NzGGEgwWNs z@*lUV6LaduZH)4_g!cE<2G6#+hJrWd5(|p1Z;YJ7ifVHv+n49btR}dq?HHDjl{m$T z!jLZcGkb&XS2OG~u%&R$(X+Z`CWec%QKt>NGYvd5g20)PU(dOn^7%@6kQb}C(%=vr z{?RP(z~C9DPnL{q^@pVw@|Vx~@3v!9dCaBtbh2EdtoNHm4kGxp>i#ct)7p|$QJs+U z-a3qtcPvhihub?wnJqEt>zC@)2suY?%-96cYCm$Q8R%-8$PZYsx3~QOLMDf(piXMm zB=<63yQk1AdOz#-qsEDX>>c)EES%$owHKue;?B3)8aRd}m~_)>SL3h2(9X;|+2#7X z+#2)NpD%qJvCQ0a-uzZLmz*ms+l*N}w)3LRQ*6>|Ub-fyptY(keUxw+)jfwF5K{L9 z|Cl_w=`!l_o><384d&?)$6Nh(GAm=4p_;{qVn#hI8lqewW7~wUlyBM-4Z|)cZr?Rh z=xZ&Ol>4(CU85ea(CZ^aO@2N18K>ftl8>2MqetAR53_JA>Fal`^)1Y--Am~UDa4th zKfCYpcXky$XSFDWBMIl(q=Mxj$iMBX=|j9P)^fDmF(5(5$|?Cx}DKEJa&XZP%OyE`*GvvYQ4PV&!g2|L^Q z?YG}tx;sY@GzMmsY`7r$P+F_YLz)(e}% zyakqFB<6|x9R#TdoP{R$>o7y(-`$$p0NxJ6?2B8tH)4^yF(WhqGZlM3=9Ibs$%U1w zWzcss*_c0=v_+^bfb`kBFsI`d;ElwiU%frgRB%qBjn@!0U2zZehBn|{%uNIKBA7n= zzE`nnwTP85{g;8AkYxA68>#muXa!G>xH22D1I*SiD~7C?7Za+9y7j1SHiuSkKK*^O zsZ==KO(Ua#?YUpXl{ViynyT#Hzk=}5X$e04O@fsMQjb}EMuPWFO0e&8(2N(29$@Vd zn1h8Yd>6z(*p^E{c(L0Lg=wVdupg!z@WG;E0k|4a%s7Up5C0c)55XVK*|x9RQeZ1J@1v9MX;>n34(i>=YE@Iur`0Vah(inE3VUFZNqf~tSz{1fz3Fsn_x4F>o(Yo;kpqvBe-sbwH(*Y zu$JOl0b83zu$JMvy<#oH^Wl>aWL*?aDwnS0iEAwC?DK@aT)GHRLhnz2WCvf3Ba;o=aY7 z2{Asu5MEjGOY4O#Ggz@@J;q*0`kd2n8I3BeNuMmYZf{}pg=jTdTCrIIYuW~luKecn z+E-pHY%ohj@uS0%^ z&(OxwPFPD$+#~`H?fMvi9geVLci(`K?Kj|w{rZ9JgthFHV+=6vMbK~0)Ea<&WY-NC zy-PnZft_k2tfeQ*SuC=nUj4H%SQ&Y$gbH4#2sT0cU0SdFs=*W*4hKGpuR1{)mV;Qf5pw4? zfiQgy0w3fC*w&Bj#{&=7033qFR*<*61B4f9K%CQvxEn&bsWJ{&winp;FP!KBj=(P6 z4Z_n4L7cS;ao2)ax?Tm|I1pH|uLpDSRVghkA_UtFFuZ0b2#>!8;>-_0ELjQSD-DRd z4im;599VHDZYtnWZGAB25W-e(2VrzEh|etsv2YoP#VbIZ{aFkwPrzJ#JvCvA*mXS& z`}Q^v9(W4GiSs}#s7BaN!WA2bniM$0J(#;MR>uIJ^uvgD3GS^%*ikdW6-!VFUU?JV zZc2)4cMsX@j z5HQ^e3BUzOdm}yC-xA%SY``k$rbfk z;CHqifhU*jfGM@DkYCecD9vl*qr58l6x<8URB=&%{!Cu3RO*MrKZ4VO}V6R0a zZw3Eg^0iKWM1dcTYZ0>N899=r6?+adUiBKPciJw}L$=1f4cs^bio&cr9baLF>6#BM z(F}EXe-`F=f_@`A7+Q&|QaZ??Txp_dB#lg!NH=t3$G8&06MFhwR=Iu*Im0s_b2B@| znW>X}sy~m#EW)&6E&!*0%}8UAS)wjt+A(io#wGI@Z2S+Ms1Cxl%YVE800007ip7{`C_J2TxPmfw%h$|%acrYHt)Re^PB%O&&=~a zhS(%I#+V>J-vjIib^<+s%ludY7y^C(P8nmqn9fp!i+?vr`bziDE=bx`%2W#Xyrj|i z!XQ4v1%L`m{7KT7q+LZNB^h8Ha2e=`Wp65^0;J00)_^G=au=8Yo;1b`CV&@#=jIBo zjN^JNVfYSs)+kDdGe7`1&8!?MQYKS?DuHZf3iogk_%#9E|5S zWeHrmAo>P;ejX7mwq#*}W25m^ZI+{(Z8fI?4jM_fffY0nok=+88^|*_DwcW>mR#e+ zX$F_KMdb6sRz!~7KkyN0G(3XQ+;z3X%PZ4gh;n-%62U<*VUKNv(D&Q->Na@Xb&u5Q3`3DGf+a8O5x7c#7+R+EAYl@R5us)CIw z7sT@_y~Ao@uL#&^LIh&QceqiT^+lb0YbFZt_SHOtWA%mgPEKVNvVgCsXy{5+zl*X8 zCJe)Q@y>wH^>l4;h1l^Y*9%-23TSmE>q5nI@?mt%n;Sj4Qq`Z+ib)a*a^cJc%E9^J zB;4s+K@rARbcBLT5P=@r;IVnBMKvT*)ew*R;&8vu%?Z&S>s?8?)3*YawM0P4!q$Kv zMmKh3lgE~&w&v%wVzH3Oe=jeNT=n@Y6J6TdHWTjXfX~-=1A1Bw`EW8rn}MqeI34nh zexFeA?&C3B2(E?0{drE@DA2pu(A#ElY&6el60Rn|Qpn-FkfQ8M93AfWIr)drgDFEU zghdWK)^71EWCP(@(=c4kfH1Y(4iugD4fve6;nSUpLT%!)MUHs1!zJYy4y||C+SwQ! z)KM&$7_tyM`sljP2fz6&Z;jxRn{Wup8IOUx8D4uh&(=O zx-7$a;U><*5L^!%xRlw)vAbh;sdlR||& ze}8_8%)c2Fwy=F&H|LM+p{pZB5DKTx>Y?F1N%BlZkXf!}JeGuMZk~LPi7{cidvUGB zAJ4LVeNV%XO>LTrklB#^-;8nb;}6l;1oW&WS=Mz*Az!4cqqQzbOSFq`$Q%PfD7srM zpKgP-D_0XPTRX*hAqeq0TDkJ;5HB1%$3Np)99#16c{ zJImlNL(npL!W|Gr_kxl1GVmF5&^$^YherS7+~q$p zt}{a=*RiD2Ikv6o=IM1kgc7zqpaZ;OB)P!1zz*i3{U()Dq#jG)egvK}@uFLa`oyWZ zf~=MV)|yJn`M^$N%ul5);JuQvaU1r2wt(}J_Qgyy`qWQI`hEeRX0uC@c1(dQ2}=U$ tNIIaX+dr)NRWXcxoR{>fqI{SF_dm1Ylv~=3YHI)h002ovPDHLkV1g(pWS;;4 literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f9ed8f5cee1c98386d13b17e89f719e83555b2 GIT binary patch literal 1895 zcmV-t2blPYP)FQtfgmafE#=YDCq`qUBt#QpG%*H6QHY765~R=q zZ6iudfM}q!Pz#~9JgOi8QJ|DSu?1-*(kSi1K4#~5?#|rh?sS)(-JQqX*}ciXJ56_H zdw=^s_srbAdqxlvGyrgGet#6T7_|j;95sL%MtM;q86vOxKM$f#puR)Bjv9Zvz9-di zXOTSsZkM83)E9PYBXC<$6(|>lNLVBb&&6y{NByFCp%6+^ALR@NCTse_wqvNmSWI-m z!$%KlHFH2omF!>#%1l3LTZg(s7eof$7*xB)ZQ0h?ejh?Ta9fDv59+u#MokW+1t8Zb zgHv%K(u9G^Lv`lh#f3<6!JVTL3(dCpxHbnbA;kKqQyd1~^Xe0VIaYBSWm6nsr;dFj z4;G-RyL?cYgsN1{L4ZFFNa;8)Rv0fM0C(~Tkit94 zz#~A)59?QjD&pAPSEQ)p8gP|DS{ng)j=2ux)_EzzJ773GmQ_Cic%3JJhC0t2cx>|v zJcVusIB!%F90{+}8hG3QU4KNeKmK%T>mN57NnCZ^56=0?&3@!j>a>B43pi{!u z7JyDj7`6d)qVp^R=%j>UIY6f+3`+qzIc!Y_=+uN^3BYV|o+$vGo-j-Wm<10%A=(Yk^beI{t%ld@yhKjq0iNjqN4XMGgQtbKubPM$JWBz}YA65k%dm*awtC^+f;a-x4+ddbH^7iDWGg&N0n#MW{kA|=8iMUiFYvMoDY@sPC#t$55gn6ykUTPAr`a@!(;np824>2xJthS z*ZdmT`g5-`BuJs`0LVhz+D9NNa3<=6m;cQLaF?tCv8)zcRSh66*Z|vXhG@$I%U~2l z?`Q zykI#*+rQ=z6Jm=Bui-SfpDYLA=|vzGE(dYm=OC8XM&MDo7ux4UF1~0J1+i%aCUpRe zt3L_uNyQ*cE(38Uy03H%I*)*Bh=Lb^Xj3?I^Hnbeq72(EOK^Y93CNp*uAA{5Lc=ky zx=~RKa4{iTm{_>_vSCm?$Ej=i6@=m%@VvAITnigVg{&@!7CDgs908761meDK5azA} z4?=NOH|PdvabgJ&fW2{Mo$Q0CcD8Qc84%{JPYt5EiG{MdLIAeX%T=D7NIP4%Hw}p9 zg)==!2Lbp#j{u_}hMiao9=!VSyx0gHbeCS`;q&vzeq|fs`y&^X-lso(Ls@-706qmA z7u*T5PMo_w3{se1t2`zWeO^hOvTsohG_;>J0wVqVe+n)AbQCx)yh9;w+J6?NF5Lmo zecS@ieAKL8%bVd@+-KT{yI|S}O>pYckUFs;ry9Ow$CD@ztz5K-*D$^{i(_1llhSh^ zEkL$}tsQt5>QA^;QgjgIfBDmcOgi5YDyu?t6vSnbp=1+@6D& z5MJ}B8q;bRlVoxasyhcUF1+)o`&3r0colr}QJ3hcSdLu;9;td>kf@Tcn<@9sIx&=m z;AD;SCh95=&p;$r{Xz3iWCO^MX83AGJ(yH&eTXgv|0=34#-&WAmw{)U7OU9!Wz^!7 zZ%jZFi@JR;>Mhi7S>V7wQ176|FdW2m?&`qa(ScO^CFPR80HucLHOTy%5s*HR0^8)i h0WYBP*#0Ks^FNSabJA*5${_#%002ovPDHLkV1oKhTl@e3 literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 GIT binary patch literal 2665 zcmV-v3YPVWP)oFh3q0MFesq&64WThn3$;G69TfjsAv=f2G9}p zgSx99+!YV6qME!>9MD13x)k(+XE7W?_O4LoLb5ND8 zaV{9+P@>42xDfRiYBMSgD$0!vssptcb;&?u9u(LLBKmkZ>RMD=kvD3h`sk6!QYtBa ztlZI#nu$8lJ^q2Z79UTgZe>BU73(Aospiq+?SdMt8lDZ;*?@tyWVZVS_Q7S&*tJaiRlJ z+aSMOmbg3@h5}v;A*c8SbqM3icg-`Cnwl;7Ts%A1RkNIp+Txl-Ckkvg4oxrqGA5ewEgYqwtECD<_3Egu)xGllKt&J8g&+=ac@Jq4-?w6M3b*>w5 z69N3O%=I^6&UL5gZ!}trC7bUj*12xLdkNs~Bz4QdJJ*UDZox2UGR}SNg@lmOvhCc~ z*f_UeXv(=#I#*7>VZx2ObEN~UoGUTl=-@)E;YtCRZ>SVp$p9yG5hEFZ!`wI!spd)n zSk+vK0Vin7FL{7f&6OB%f;SH22dtbcF<|9fi2Fp%q4kxL!b1#l^)8dUwJ zwEf{(wJj@8iYDVnKB`eSU+;ml-t2`@%_)0jDM`+a46xhDbBj2+&Ih>1A>6aky#(-SYyE{R3f#y57wfLs z6w1p~$bp;6!9DX$M+J~S@D6vJAaElETnsX4h9a5tvPhC3L@qB~bOzkL@^z0k_hS{T4PF*TDrgdXp+dzsE? z>V|VR035Pl9n5&-RePFdS{7KAr2vPOqR9=M$vXA1Yy5>w;EsF`;OK{2pkn-kpp9Pw z)r;5JfJKKaT$4qCb{TaXHjb$QA{y0EYy*+b1XI;6Ah- zw13P)xT`>~eFoJC!>{2XL(a_#upp3gaR1#5+L(Jmzp4TBnx{~WHedpJ1ch8JFk~Sw z>F+gN+i+VD?gMXwcIhn8rz`>e>J^TI3E-MW>f}6R-pL}>WMOa0k#jN+`RyUVUC;#D zg|~oS^$6%wpF{^Qr+}X>0PKcr3Fc&>Z>uv@C);pwDs@2bZWhYP!rvGx?_|q{d`t<*XEb#=aOb=N+L@CVBGqImZf&+a zCQEa3$~@#kC);pasdG=f6tuIi0PO-y&tvX%>Mv=oY3U$nD zJ#gMegnQ46pq+3r=;zmgcG+zRc9D~c>z+jo9&D+`E6$LmyFqlmCYw;-Zooma{sR@~ z)_^|YL1&&@|GXo*pivH7k!msl+$Sew3%XJnxajt0K%3M6Bd&YFNy9}tWG^aovK2eX z1aL1%7;KRDrA@eG-Wr6w+;*H_VD~qLiVI`{_;>o)k`{8xa3EJT1O_>#iy_?va0eR? zDV=N%;Zjb%Z2s$@O>w@iqt!I}tLjGk!=p`D23I}N4Be@$(|iSA zf3Ih7b<{zqpDB4WF_5X1(peKe+rASze%u8eKLn#KKXt;UZ+Adf$_TO+vTqshLLJ5c z52HucO=lrNVae5XWOLm!V@n-ObU11!b+DN<$RuU+YsrBq*lYT;?AwJpmNKniF0Q1< zJCo>Q$=v$@&y=sj6{r!Y&y&`0$-I}S!H_~pI&2H8Z1C|BX4VgZ^-! zje3-;x0PBD!M`v*J_)rL^+$<1VJhH*2Fi~aA7s&@_rUHYJ9zD=M%4AFQ`}k8OC$9s XsPq=LnkwKG00000NkvXXu0mjfhAk5^ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d6b8609df07bf62e5100a53a01510388bd2b22 GIT binary patch literal 2665 zcmV-v3YPVWP)oFh3q0MFesq&64WThn3$;G69TfjsAv=f2G9}p zgSx99+!YV6qME!>9MD13x)k(+XE7W?_O4LoLb5ND8 zaV{9+P@>42xDfRiYBMSgD$0!vssptcb;&?u9u(LLBKmkZ>RMD=kvD3h`sk6!QYtBa ztlZI#nu$8lJ^q2Z79UTgZe>BU73(Aospiq+?SdMt8lDZ;*?@tyWVZVS_Q7S&*tJaiRlJ z+aSMOmbg3@h5}v;A*c8SbqM3icg-`Cnwl;7Ts%A1RkNIp+Txl-Ckkvg4oxrqGA5ewEgYqwtECD<_3Egu)xGllKt&J8g&+=ac@Jq4-?w6M3b*>w5 z69N3O%=I^6&UL5gZ!}trC7bUj*12xLdkNs~Bz4QdJJ*UDZox2UGR}SNg@lmOvhCc~ z*f_UeXv(=#I#*7>VZx2ObEN~UoGUTl=-@)E;YtCRZ>SVp$p9yG5hEFZ!`wI!spd)n zSk+vK0Vin7FL{7f&6OB%f;SH22dtbcF<|9fi2Fp%q4kxL!b1#l^)8dUwJ zwEf{(wJj@8iYDVnKB`eSU+;ml-t2`@%_)0jDM`+a46xhDbBj2+&Ih>1A>6aky#(-SYyE{R3f#y57wfLs z6w1p~$bp;6!9DX$M+J~S@D6vJAaElETnsX4h9a5tvPhC3L@qB~bOzkL@^z0k_hS{T4PF*TDrgdXp+dzsE? z>V|VR035Pl9n5&-RePFdS{7KAr2vPOqR9=M$vXA1Yy5>w;EsF`;OK{2pkn-kpp9Pw z)r;5JfJKKaT$4qCb{TaXHjb$QA{y0EYy*+b1XI;6Ah- zw13P)xT`>~eFoJC!>{2XL(a_#upp3gaR1#5+L(Jmzp4TBnx{~WHedpJ1ch8JFk~Sw z>F+gN+i+VD?gMXwcIhn8rz`>e>J^TI3E-MW>f}6R-pL}>WMOa0k#jN+`RyUVUC;#D zg|~oS^$6%wpF{^Qr+}X>0PKcr3Fc&>Z>uv@C);pwDs@2bZWhYP!rvGx?_|q{d`t<*XEb#=aOb=N+L@CVBGqImZf&+a zCQEa3$~@#kC);pasdG=f6tuIi0PO-y&tvX%>Mv=oY3U$nD zJ#gMegnQ46pq+3r=;zmgcG+zRc9D~c>z+jo9&D+`E6$LmyFqlmCYw;-Zooma{sR@~ z)_^|YL1&&@|GXo*pivH7k!msl+$Sew3%XJnxajt0K%3M6Bd&YFNy9}tWG^aovK2eX z1aL1%7;KRDrA@eG-Wr6w+;*H_VD~qLiVI`{_;>o)k`{8xa3EJT1O_>#iy_?va0eR? zDV=N%;Zjb%Z2s$@O>w@iqt!I}tLjGk!=p`D23I}N4Be@$(|iSA zf3Ih7b<{zqpDB4WF_5X1(peKe+rASze%u8eKLn#KKXt;UZ+Adf$_TO+vTqshLLJ5c z52HucO=lrNVae5XWOLm!V@n-ObU11!b+DN<$RuU+YsrBq*lYT;?AwJpmNKniF0Q1< zJCo>Q$=v$@&y=sj6{r!Y&y&`0$-I}S!H_~pI&2H8Z1C|BX4VgZ^-! zje3-;x0PBD!M`v*J_)rL^+$<1VJhH*2Fi~aA7s&@_rUHYJ9zD=M%4AFQ`}k8OC$9s XsPq=LnkwKG00000NkvXXu0mjfhAk5^ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..75b2d164a5a98e212cca15ea7bf2ab5de5108680 GIT binary patch literal 3831 zcmVjJBgitF5mAp-i>4+KS_oR{|13AP->1TD4=w)g|)JHOx|a2Wk1Va z!k)vP$UcQ#mdj%wNQoaJ!w>jv_6&JPyutpQps?s5dmDQ>`%?Bvj>o<%kYG!YW6H-z zu`g$@mp`;qDR!51QaS}|ZToSuAGcJ7$2HF0z`ln4t!#Yg46>;vGG9N9{V@9z#}6v* zfP?}r6b{*-C*)(S>NECI_E~{QYzN5SXRmVnP<=gzP+_Sp(Aza_hKlZ{C1D&l*(7IKXxQC1Z9#6wx}YrGcn~g%;icdw>T0Rf^w0{ z$_wn1J+C0@!jCV<%Go5LA45e{5gY9PvZp8uM$=1}XDI+9m7!A95L>q>>oe0$nC->i zeexUIvq%Uk<-$>DiDb?!In)lAmtuMWxvWlk`2>4lNuhSsjAf2*2tjT`y;@d}($o)S zn(+W&hJ1p0xy@oxP%AM15->wPLp{H!k)BdBD$toBpJh+crWdsNV)qsHaqLg2_s|Ih z`8E9z{E3sA!}5aKu?T!#enD(wLw?IT?k-yWVHZ8Akz4k5(TZJN^zZgm&zM28sfTD2BYJ|Fde3Xzh;;S` z=GXTnY4Xc)8nYoz6&vF;P7{xRF-{|2Xs5>a5)@BrnQ}I(_x7Cgpx#5&Td^4Q9_FnQ zX5so*;#8-J8#c$OlA&JyPp$LKUhC~-e~Ij!L%uSMu!-VZG7Hx-L{m2DVR2i=GR(_% zCVD!4N`I)&Q5S`?P&fQZ=4#Dgt_v2-DzkT}K(9gF0L(owe-Id$Rc2qZVLqI_M_DyO z9@LC#U28_LU{;wGZ&))}0R2P4MhajKCd^K#D+JJ&JIXZ_p#@+7J9A&P<0kdRujtQ_ zOy>3=C$kgi6$0pW06KaLz!21oOryKM3ZUOWqppndxfH}QpgjEJ`j7Tzn5bk6K&@RA?vl##y z$?V~1E(!wB5rH`>3nc&@)|#<1dN2cMzzm=PGhQ|Yppne(C-Vlt450IXc`J4R0W@I7 zd1e5uW6juvO%ni(WX7BsKx3MLngO7rHO;^R5I~0^nE^9^E_eYLgiR9&KnJ)pBbfno zSVnW$0R+&6jOOsZ82}nJ126+c|%svPo;TeUku<2G7%?$oft zyaO;tVo}(W)VsTUhq^XmFi#2z%-W9a{7mXn{uzivYQ_d6b7VJG{77naW(vHt-uhnY zVN#d!JTqVh(7r-lhtXVU6o})aZbDt_;&wJVGl2FKYFBFpU-#9U)z#(A%=IVnqytR$SY-sO( z($oNE09{D^@OuYPz&w~?9>Fl5`g9u&ecFGhqX=^#fmR=we0CJw+5xna*@oHnkahk+ z9aWeE3v|An+O5%?4fA&$Fgu~H_YmqR!yIU!bFCk4!#pAj%(lI(A5n)n@Id#M)O9Yx zJU9oKy{sRAIV3=5>(s8n{8ryJ!;ho}%pn6hZKTKbqk=&m=f*UnK$zW3YQP*)pw$O* zIfLA^!-bmBl6%d_n$#tP8Zd_(XdA*z*WH|E_yILwjtI~;jK#v-6jMl^?<%Y%`gvpwv&cFb$||^v4D&V=aNy?NGo620jL3VZnA%s zH~I|qPzB~e(;p;b^gJr7Ure#7?8%F0m4vzzPy^^(q4q1OdthF}Fi*RmVZN1OwTsAP zn9CZP`FazX3^kG(KodIZ=Kty8DLTy--UKfa1$6XugS zk%6v$Kmxt6U!YMx0JQ)0qX*{CXwZZk$vEROidEc7=J-1;peNat!vS<3P-FT5po>iE z!l3R+<`#x|+_hw!HjQGV=8!q|76y8L7N8gP3$%0kfush|u0uU^?dKBaeRSBUpOZ0c z62;D&Mdn2}N}xHRFTRI?zRv=>=AjHgH}`2k4WK=#AHB)UFrR-J87GgX*x5fL^W2#d z=(%K8-oZfMO=i{aWRDg=FX}UubM4eotRDcn;OR#{3q=*?3mE3_oJ-~prjhxh%PgQT zyn)Qozaq0@o&|LEgS{Ind4Swsr;b`u185hZPOBLL<`d2%^Yp1?oL)=jnLi;Zo0ZDliTtQ^b5SmfIMe{T==zZkbvn$KTQGlbG8w}s@M3TZnde;1Am46P3juKb zl9GU&3F=q`>j!`?SyH#r@O59%@aMX^rx}Nxe<>NqpUp5=lX1ojGDIR*-D^SDuvCKF z?3$xG(gVUsBERef_YjPFl^rU9EtD{pt z0CXwpN7BN3!8>hajGaTVk-wl=9rxmfWtIhC{mheHgStLi^+Nz12a?4r(fz)?3A%at zMlvQmL<2-R)-@G1wJ0^zQK%mR=r4d{Y3fHp){nWXUL#|CqXl(+v+qDh>FkF9`eWrW zfr^D%LNfOcTNvtx0JXR35J0~Jpi2#P3Q&80w+nqNfc}&G0A~*)lGHKv=^FE+b(37|)zL;KLF>oiGfb(?&1 zV3XRu!Sw>@quKiab%g6jun#oZ%!>V#A%+lNc?q>6+VvyAn=kf_6z^(TZUa4Eelh{{ zqFX-#dY(EV@7l$NE&kv9u9BR8&Ojd#ZGJ6l8_BW}^r?DIS_rU2(XaGOK z225E@kH5Opf+CgD^{y29jD4gHbGf{1MD6ggQ&%>UG4WyPh5q_tb`{@_34B?xfSO*| zZv8!)q;^o-bz`MuxXk*G^}(6)ACb@=Lfs`Hxoh>`Y0NE8QRQ!*p|SH@{r8=%RKd4p z+#Ty^-0kb=-H-O`nAA3_6>2z(D=~Tbs(n8LHxD0`R0_ATFqp-SdY3(bZ3;VUM?J=O zKCNsxsgt@|&nKMC=*+ZqmLHhX1KHbAJs{nGVMs6~TiF%Q)P@>!koa$%oS zjXa=!5>P`vC-a}ln!uH1ooeI&v?=?v7?1n~P(wZ~0>xWxd_Aw;+}9#eULM7M8&E?Y zC-ZLhi3RoM92SXUb-5i-Lmt5_rfjE{6y^+24`y$1lywLyHO!)Boa7438K4#iLe?rh z2O~YGSgFUBH?og*6=r9rme=peP~ah`(8Zt7V)j5!V0KPFf_mebo3z95U8(up$-+EA^9dTRLq>Yl)YMBuch9%=e5B`Vnb>o zt03=kq;k2TgGe4|lGne&zJa~h(UGutjP_zr?a7~#b)@15XNA>Dj(m=gg2Q5V4-$)D|Q9}R#002ovPDHLkV1o7DH3k3x literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/local_auth/local_auth_ios/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..c4df70d39da7941ef3f6dcb7f06a192d8dcb308d GIT binary patch literal 1888 zcmV-m2cP(fP)x~L`~4d)Rspd&<9kFh{hn*KP1LP0~$;u(LfAu zp%fx&qLBcRHx$G|3q(bv@+b;o0*D|jwD-Q9uQR(l*ST}s+uPgQ-MeFwZ#GS?b332? z&Tk$&_miXn3IGq)AmQ)3sisq{raD4(k*bHvpCe-TdWq^NRTEVM)i9xbgQ&ccnUVx* zEY%vS%gDcSg=!tuIK8$Th2_((_h^+7;R|G{n06&O2#6%LK`a}n?h_fL18btz<@lFG za}xS}u?#DBMB> zw^b($1Z)`9G?eP95EKi&$eOy@K%h;ryrR3la%;>|o*>CgB(s>dDcNOXg}CK9SPmD? zmr-s{0wRmxUnbDrYfRvnZ@d z6johZ2sMX{YkGSKWd}m|@V7`Degt-43=2M?+jR%8{(H$&MLLmS;-|JxnX2pnz;el1jsvqQz}pGSF<`mqEXRQ5sC4#BbwnB_4` zc5bFE-Gb#JV3tox9fp-vVEN{(tOCpRse`S+@)?%pz+zVJXSooTrNCUg`R6`hxwb{) zC@{O6MKY8tfZ5@!yy=p5Y|#+myRL=^{tc(6YgAnkg3I(Cd!r5l;|;l-MQ8B`;*SCE z{u)uP^C$lOPM z5d~UhKhRRmvv{LIa^|oavk1$QiEApSrP@~Jjbg`<*dW4TO?4qG%a%sTPUFz(QtW5( zM)lA+5)0TvH~aBaOAs|}?u2FO;yc-CZ1gNM1dAxJ?%m?YsGR`}-xk2*dxC}r5j$d* zE!#Vtbo69h>V4V`BL%_&$} z+oJAo@jQ^Tk`;%xw-4G>hhb&)B?##U+(6Fi7nno`C<|#PVA%$Y{}N-?(Gc$1%tr4Pc}}hm~yY#fTOe!@v9s-ik$dX~|ygArPhByaXn8 zpI^FUjNWMsTFKTP3X7m?UK)3m zp6rI^_zxRYrx6_QmhoWoDR`fp4R7gu6;gdO)!KexaoO2D88F9x#TM1(9Bn7g;|?|o z)~$n&Lh#hCP6_LOPD>a)NmhW})LADx2kq=X7}7wYRj-0?dXr&bHaRWCfSqvzFa=sn z-8^gSyn-RmH=BZ{AJZ~!8n5621GbUJV7Qvs%JNv&$%Q17s_X%s-41vAPfIR>;x0Wlqr5?09S>x#%Qkt>?(&XjFRY}*L6BeQ3 z<6XEBh^S7>AbwGm@XP{RkeEKj6@_o%oV?hDuUpUJ+r#JZO?!IUc;r0R?>mi)*ZpQ) z#((dn=A#i_&EQn|hd)N$#A*fjBFuiHcYvo?@y1 z5|fV=a^a~d!c-%ZbMNqkMKiSzM{Yq=7_c&1H!mXk60Uv32dV;vMg&-kQ)Q{+PFtwc zj|-uQ;b^gts??J*9VxxOro}W~Q9j4Em|zSRv)(WSO9$F$s=Ydu%Q+5DOid~lwk&we zY%W(Z@ofdwPHncEZzZgmqS|!gTj3wQq9rxQy+^eNYKr1mj&?tm@wkO*9@UtnRMG>c aR{jt9+;fr}hV%pg00001^@s67{VYS000c7NklQEG_j zup^)eW&WUIApqy$=APz8jE@awGp)!bsTjDbrJO`$x^ZR^dr;>)LW>{ zs70vpsD38v)19rI=GNk1b(0?Js9~rjsQsu*K;@SD40RB-3^gKU-MYC7G!Bw{fZsqp zih4iIi;Hr_xZ033Iu{sQxLS=}yBXgLMn40d++>aQ0#%8D1EbGZp7+ z5=mK?t31BkVYbGOxE9`i748x`YgCMwL$qMsChbSGSE1`p{nSmadR zcQ#R)(?!~dmtD0+D2!K zR9%!Xp1oOJzm(vbLvT^$IKp@+W2=-}qTzTgVtQ!#Y7Gxz}stUIm<1;oBQ^Sh2X{F4ibaOOx;5ZGSNK z0maF^@(UtV$=p6DXLgRURwF95C=|U8?osGhgOED*b z7woJ_PWXBD>V-NjQAm{~T%sjyJ{5tn2f{G%?J!KRSrrGvQ1(^`YLA5B!~eycY(e5_ z*%aa{at13SxC(=7JT7$IQF~R3sy`Nn%EMv!$-8ZEAryB*yB1k&stni)=)8-ODo41g zkJu~roIgAih94tb=YsL%iH5@^b~kU9M-=aqgXIrbtxMpFy5mekFm#edF9z7RQ6V}R zBIhbXs~pMzt0VWy1Fi$^fh+1xxLDoK09&5&MJl(q#THjPm(0=z2H2Yfm^a&E)V+a5 zbi>08u;bJsDRUKR9(INSc7XyuWv(JsD+BB*0hS)FO&l&7MdViuur@-<-EHw>kHRGY zqoT}3fDv2-m{NhBG8X}+rgOEZ;amh*DqN?jEfQdqxdj08`Sr=C-KmT)qU1 z+9Cl)a1mgXxhQiHVB}l`m;-RpmKy?0*|yl?FXvJkFxuu!fKlcmz$kN(a}i*saM3nr z0!;a~_%Xqy24IxA2rz<+08=B-Q|2PT)O4;EaxP^6qixOv7-cRh?*T?zZU`{nIM-at zTKYWr9rJ=tppQ9I#Z#mLgINVB!pO-^FOcvFw6NhV0gztuO?g ztoA*C-52Q-Z-P#xB4HAY3KQVd%dz1S4PA3vHp0aa=zAO?FCt zC_GaTyVBg2F!bBr3U@Zy2iJgIAt>1sf$JWA9kh{;L+P*HfUBX1Zy{4MgNbDfBV_ly z!y#+753arsZUt@366jIC0klaC@ckuk!qu=pAyf7&QmiBUT^L1&tOHzsK)4n|pmrVT zs2($4=?s~VejTFHbFdDOwG;_58LkIj1Fh@{glkO#F1>a==ymJS$z;gdedT1zPx4Kj ztjS`y_C}%af-RtpehdQDt3a<=W5C4$)9W@QAse;WUry$WYmr51ml9lkeunUrE`-3e zmq1SgSOPNEE-Mf+AGJ$g0M;3@w!$Ej;hMh=v=I+Lpz^n%Pg^MgwyqOkNyu2c^of)C z1~ALor3}}+RiF*K4+4{(1%1j3pif1>sv0r^mTZ?5Jd-It!tfPfiG_p$AY*Vfak%FG z4z#;wLtw&E&?}w+eKG^=#jF7HQzr8rV0mY<1YAJ_uGz~$E13p?F^fPSzXSn$8UcI$ z8er9{5w5iv0qf8%70zV71T1IBB1N}R5Kp%NO0=5wJalZt8;xYp;b{1K) zHY>2wW-`Sl{=NpR%iu3(u6l&)rc%%cSA#aV7WCowfbFR4wcc{LQZv~o1u_`}EJA3>ki`?9CKYTA!rhO)if*zRdd}Kn zEPfYbhoVE~!FI_2YbC5qAj1kq;xP6%J8+?2PAs?`V3}nyFVD#sV3+uP`pi}{$l9U^ zSz}_M9f7RgnnRhaoIJgT8us!1aB&4!*vYF07Hp&}L zCRlop0oK4DL@ISz{2_BPlezc;xj2|I z23RlDNpi9LgTG_#(w%cMaS)%N`e>~1&a3<{Xy}>?WbF>OOLuO+j&hc^YohQ$4F&ze z+hwnro1puQjnKm;vFG~o>`kCeUIlkA-2tI?WBKCFLMBY=J{hpSsQ=PDtU$=duS_hq zHpymHt^uuV1q@uc4bFb{MdG*|VoW@15Osrqt2@8ll0qO=j*uOXn{M0UJX#SUztui9FN4)K3{9!y8PC-AHHvpVTU;x|-7P+taAtyglk#rjlH2 z5Gq8ik}BPaGiM{#Woyg;*&N9R2{J0V+WGB69cEtH7F?U~Kbi6ksi*`CFXsi931q7Y zGO82?whBhN%w1iDetv%~wM*Y;E^)@Vl?VDj-f*RX>{;o_=$fU!&KAXbuadYZ46Zbg z&6jMF=49$uL^73y;;N5jaHYv)BTyfh&`qVLYn?`o6BCA_z-0niZz=qPG!vonK3MW_ zo$V96zM!+kJRs{P-5-rQVse0VBH*n6A58)4uc&gfHMa{gIhV2fGf{st>E8sKyP-$8zp~wJX^A*@DI&-;8>gANXZj zU)R+Y)PB?=)a|Kj>8NXEu^S_h^7R`~Q&7*Kn!xyvzVv&^>?^iu;S~R2e-2fJx-oUb cX)(b1KSk$MOV07*qoM6N<$f&6$jw%VRuvdN2+38CZWny1cRtlsl+0_KtW)EU14Ei(F!UtWuj4IK+3{sK@>rh zs1Z;=(DD&U6+tlyL?UnHVN^&g6QhFi2#HS+*qz;(>63G(`|jRtW|nz$Pv7qTovP!^ zP_jES{mr@O-02w%!^a?^1ZP!_KmQiz0L~jZ=W@Qt`8wzOoclQsAS<5YdH;a(4bGLE zk8s}1If(PSIgVi!XE!5kA?~z*sobvNyohr;=Q_@h2@$6Flyej3J)D-6YfheRGl`HEcPk|~huT_2-U?PfL=4BPV)f1o!%rQ!NMt_MYw-5bUSwQ9Z&zC>u zOrl~UJglJNa%f50Ok}?WB{on`Ci`p^Y!xBA?m@rcJXLxtrE0FhRF3d*ir>yzO|BD$ z3V}HpFcCh6bTzY}Nt_(W%QYd3NG)jJ4<`F<1Od) zfQblTdC&h2lCz`>y?>|9o2CdvC8qZeIZt%jN;B7Hdn2l*k4M4MFEtq`q_#5?}c$b$pf_3y{Y!cRDafZBEj-*OD|gz#PBDeu3QoueOesLzB+O zxjf2wvf6Wwz>@AiOo2mO4=TkAV+g~%_n&R;)l#!cBxjuoD$aS-`IIJv7cdX%2{WT7 zOm%5rs(wqyPE^k5SIpUZ!&Lq4<~%{*>_Hu$2|~Xa;iX*tz8~G6O3uFOS?+)tWtdi| zV2b#;zRN!m@H&jd=!$7YY6_}|=!IU@=SjvGDFtL;aCtw06U;-v^0%k0FOyESt z1Wv$={b_H&8FiRV?MrzoHWd>%v6KTRU;-v^Miiz+@q`(BoT!+<37CKhoKb)|8!+RG z6BQFU^@fRW;s8!mOf2QViKQGk0TVER6EG1`#;Nm39Do^PoT!+<37AD!%oJe86(=et zZ~|sLzU>V-qYiU6V8$0GmU7_K8|Fd0B?+9Un1BhKAz#V~Fk^`mJtlCX#{^8^M8!me z8Yg;8-~>!e<-iG;h*0B1kBKm}hItVGY6WnjVpgnTTAC$rqQ^v)4KvOtpY|sIj@WYg zyw##ZZ5AC2IKNC;^hwg9BPk0wLStlmBr;E|$5GoAo$&Ui_;S9WY62n3)i49|T%C#i017z3J=$RF|KyZWnci*@lW4 z=AKhNN6+m`Q!V3Ye68|8y@%=am>YD0nG99M)NWc20%)gwO!96j7muR}Fr&54SxKP2 zP30S~lt=a*qDlbu3+Av57=9v&vr<6g0&`!8E2fq>I|EJGKs}t|{h7+KT@)LfIV-3K zK)r_fr2?}FFyn*MYoLC>oV-J~eavL2ho4a4^r{E-8m2hi>~hA?_vIG4a*KT;2eyl1 zh_hUvUJpNCFwBvRq5BI*srSle>c6%n`#VNsyC|MGa{(P&08p=C9+WUw9Hl<1o9T4M zdD=_C0F7#o8A_bRR?sFNmU0R6tW`ElnF8p53IdHo#S9(JoZCz}fHwJ6F<&?qrpVqE zte|m%89JQD+XwaPU#%#lVs-@-OL);|MdfINd6!XwP2h(eyafTUsoRkA%&@fe?9m@jw-v(yTTiV2(*fthQH9}SqmsRPVnwwbV$1E(_lkmo&S zF-truCU914_$jpqjr(>Ha4HkM4YMT>m~NosUu&UZ>zirfHo%N6PPs9^_o$WqPA0#5 z%tG>qFCL+b*0s?sZ;Sht0nE7Kl>OVXy=gjWxxK;OJ3yGd7-pZf7JYNcZo2*1SF`u6 zHJyRRxGw9mDlOiXqVMsNe#WX`fC`vrtjSQ%KmLcl(lC>ZOQzG^%iql2w-f_K@r?OE zwCICifM#L-HJyc7Gm>Ern?+Sk3&|Khmu4(~3qa$(m6Ub^U0E5RHq49za|XklN#?kP zl;EstdW?(_4D>kwjWy2f!LM)y?F94kyU3`W!6+AyId-89v}sXJpuic^NLL7GJItl~ zsiuB98AI-(#Mnm|=A-R6&2fwJ0JVSY#Q>&3$zFh|@;#%0qeF=j5Ajq@4i0tIIW z&}sk$&fGwoJpe&u-JeGLi^r?dO`m=y(QO{@h zQqAC7$rvz&5+mo3IqE?h=a~6m>%r5Quapvzq;{y~p zJpyXOBgD9VrW7@#p6l7O?o3feml(DtSL>D^R) zZUY%T2b0-vBAFN7VB;M88!~HuOXi4KcI6aRQ&h|XQ0A?m%j2=l1f0cGP}h(oVfJ`N zz#PpmFC*ieab)zJK<4?^k=g%OjPnkANzbAbmGZHoVRk*mTfm75s_cWVa`l*f$B@xu z5E*?&@seIo#*Y~1rBm!7sF9~~u6Wrj5oICUOuz}CS)jdNIznfzCA(stJ(7$c^e5wN z?lt>eYgbA!kvAR7zYSD&*r1$b|(@;9dcZ^67R0 zXAXJKa|5Sdmj!g578Nwt6d$sXuc&MWezA0Whd`94$h{{?1IwXP4)Tx4obDK%xoFZ_Z zjjHJ_P@R_e5blG@yEjnaJb`l;s%Lb2&=8$&Ct-fV`E^4CUs)=jTk!I}2d&n!f@)bm z@ z_4Dc86+3l2*p|~;o-Sb~oXb_RuLmoifDU^&Te$*FevycC0*nE3Xws8gsWp|Rj2>SM zns)qcYj?^2sd8?N!_w~4v+f-HCF|a$TNZDoNl$I1Uq87euoNgKb6&r26TNrfkUa@o zfdiFA@p{K&mH3b8i!lcoz)V{n8Q@g(vR4ns4r6w;K z>1~ecQR0-<^J|Ndg5fvVUM9g;lbu-){#ghGw(fg>L zh)T5Ljb%lWE;V9L!;Cqk>AV1(rULYF07ZBJbGb9qbSoLAd;in9{)95YqX$J43-dY7YU*k~vrM25 zxh5_IqO0LYZW%oxQ5HOzmk4x{atE*vipUk}sh88$b2tn?!ujEHn`tQLe&vo}nMb&{ zio`xzZ&GG6&ZyN3jnaQy#iVqXE9VT(3tWY$n-)uWDQ|tc{`?fq2F`oQ{;d3aWPg4Hp-(iE{ry>MIPWL> iW8 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard b/packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000000..f3c28516fb38 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist b/packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist new file mode 100644 index 000000000000..f8e0356d0a68 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + local_auth_example + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + NSFaceIDUsageDescription + App needs to authenticate using faces. + + diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/main.m b/packages/local_auth/local_auth_ios/example/ios/Runner/main.m new file mode 100644 index 000000000000..f97b9ef5c8a1 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/main.m @@ -0,0 +1,13 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import +#import "AppDelegate.h" + +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m new file mode 100644 index 000000000000..97e78e2f624b --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m @@ -0,0 +1,189 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@import LocalAuthentication; +@import XCTest; + +#import + +#if __has_include() +#import +#else +@import local_auth; +#endif + +// Private API needed for tests. +@interface FLTLocalAuthPlugin (Test) +- (void)setAuthContextOverrides:(NSArray*)authContexts; +@end + +// Set a long timeout to avoid flake due to slow CI. +static const NSTimeInterval kTimeout = 30.0; + +@interface FLTLocalAuthPluginTests : XCTestCase +@end + +@implementation FLTLocalAuthPluginTests + +- (void)setUp { + self.continueAfterFailure = NO; +} + +- (void)testSuccessfullAuthWithBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(YES, nil); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(YES), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertTrue([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +- (void)testSuccessfullAuthWithoutBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(YES, nil); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(NO), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertTrue([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +- (void)testFailedAuthWithBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(NO, [NSError errorWithDomain:@"error" code:99 userInfo:nil]); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(YES), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertFalse([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +- (void)testFailedAuthWithoutBiometrics { + FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + id mockAuthContext = OCMClassMock([LAContext class]); + plugin.authContextOverrides = @[ mockAuthContext ]; + + const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; + NSString* reason = @"a reason"; + OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); + + // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not + // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on + // a background thread. + void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { + void (^reply)(BOOL, NSError*); + [invocation getArgument:&reply atIndex:4]; + dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ + reply(NO, [NSError errorWithDomain:@"error" code:99 userInfo:nil]); + }); + }; + OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) + .andDo(backgroundThreadReplyCaller); + + FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + arguments:@{ + @"biometricOnly" : @(NO), + @"localizedReason" : reason, + }]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + [plugin handleMethodCall:call + result:^(id _Nullable result) { + XCTAssertTrue([NSThread isMainThread]); + XCTAssertTrue([result isKindOfClass:[NSNumber class]]); + XCTAssertFalse([result boolValue]); + [expectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:kTimeout handler:nil]; +} + +@end diff --git a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist new file mode 100644 index 000000000000..64d65ca49577 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart new file mode 100644 index 000000000000..3dc87811ee70 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -0,0 +1,233 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:local_auth_ios/local_auth_ios.dart'; +import 'package:local_auth_ios/types/auth_strings_ios.dart'; + +void main() { + runApp(MyApp()); +} + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + final LocalAuthIOS auth = LocalAuthIOS(); + _SupportState _supportState = _SupportState.unknown; + bool? _canCheckBiometrics; + List? _availableBiometrics; + String _authorized = 'Not Authorized'; + bool _isAuthenticating = false; + + @override + void initState() { + super.initState(); + auth.isDeviceSupported().then( + (bool isSupported) => setState(() => _supportState = isSupported + ? _SupportState.supported + : _SupportState.unsupported), + ); + } + + Future _checkBiometrics() async { + late bool canCheckBiometrics; + try { + canCheckBiometrics = (await auth.getAvailableBiometrics()).isNotEmpty; + } on PlatformException catch (e) { + canCheckBiometrics = false; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _canCheckBiometrics = canCheckBiometrics; + }); + } + + Future _getAvailableBiometrics() async { + late List availableBiometrics; + try { + availableBiometrics = await auth.getAvailableBiometrics(); + } on PlatformException catch (e) { + availableBiometrics = []; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _availableBiometrics = availableBiometrics; + }); + } + + Future _authenticate() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: 'Let OS determine authentication method', + authStrings: const IOSAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true, + ); + setState(() { + _isAuthenticating = false; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + setState( + () => _authorized = authenticated ? 'Authorized' : 'Not Authorized'); + } + + Future _authenticateWithBiometrics() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: + 'Scan your fingerprint (or face or whatever) to authenticate', + authStrings: const IOSAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true, + biometricOnly: true, + ); + setState(() { + _isAuthenticating = false; + _authorized = 'Authenticating'; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + final String message = authenticated ? 'Authorized' : 'Not Authorized'; + setState(() { + _authorized = message; + }); + } + + Future _cancelAuthentication() async { + await auth.stopAuthentication(); + setState(() => _isAuthenticating = false); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: ListView( + padding: const EdgeInsets.only(top: 30), + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (_supportState == _SupportState.unknown) + const CircularProgressIndicator() + else if (_supportState == _SupportState.supported) + const Text('This device is supported') + else + const Text('This device is not supported'), + const Divider(height: 100), + Text('Can check biometrics: $_canCheckBiometrics\n'), + ElevatedButton( + child: const Text('Check biometrics'), + onPressed: _checkBiometrics, + ), + const Divider(height: 100), + Text('Available biometrics: $_availableBiometrics\n'), + ElevatedButton( + child: const Text('Get available biometrics'), + onPressed: _getAvailableBiometrics, + ), + const Divider(height: 100), + Text('Current State: $_authorized\n'), + if (_isAuthenticating) + ElevatedButton( + onPressed: _cancelAuthentication, + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Cancel Authentication'), + Icon(Icons.cancel), + ], + ), + ) + else + Column( + children: [ + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Authenticate'), + Icon(Icons.perm_device_information), + ], + ), + onPressed: _authenticate, + ), + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text(_isAuthenticating + ? 'Cancel' + : 'Authenticate: biometrics only'), + const Icon(Icons.fingerprint), + ], + ), + onPressed: _authenticateWithBiometrics, + ), + ], + ), + ], + ), + ], + ), + ), + ); + } +} + +enum _SupportState { + unknown, + supported, + unsupported, +} diff --git a/packages/local_auth/local_auth_ios/example/pubspec.yaml b/packages/local_auth/local_auth_ios/example/pubspec.yaml new file mode 100644 index 000000000000..70a2946d8e01 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/pubspec.yaml @@ -0,0 +1,28 @@ +name: local_auth_ios_example +description: Demonstrates how to use the local_auth_ios plugin. +publish_to: none + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + local_auth_ios: + # When depending on this package from a real application you should use: + # local_auth: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + +dev_dependencies: + flutter_driver: + sdk: flutter + integration_test: + sdk: flutter + pedantic: ^1.10.0 + +flutter: + uses-material-design: true diff --git a/packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart b/packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..4f10f2a522f3 --- /dev/null +++ b/packages/local_auth/local_auth_ios/example/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/local_auth/local_auth/ios/Assets/.gitkeep b/packages/local_auth/local_auth_ios/ios/Assets/.gitkeep similarity index 100% rename from packages/local_auth/local_auth/ios/Assets/.gitkeep rename to packages/local_auth/local_auth_ios/ios/Assets/.gitkeep diff --git a/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.h similarity index 100% rename from packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.h rename to packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.h diff --git a/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m similarity index 99% rename from packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m rename to packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m index c2dc9db25fc8..eb567e6afe25 100644 --- a/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m +++ b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m @@ -20,7 +20,7 @@ @implementation FLTLocalAuthPlugin { + (void)registerWithRegistrar:(NSObject *)registrar { FlutterMethodChannel *channel = - [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/local_auth" + [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/local_auth_ios" binaryMessenger:[registrar messenger]]; FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init]; [registrar addMethodCallDelegate:instance channel:channel]; diff --git a/packages/local_auth/local_auth/ios/local_auth.podspec b/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec similarity index 83% rename from packages/local_auth/local_auth/ios/local_auth.podspec rename to packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec index 4ab779ad50cd..a0e59e4df2a8 100644 --- a/packages/local_auth/local_auth/ios/local_auth.podspec +++ b/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec @@ -2,7 +2,7 @@ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # Pod::Spec.new do |s| - s.name = 'local_auth' + s.name = 'local_auth_ios' s.version = '0.0.1' s.summary = 'Flutter Local Auth' s.description = <<-DESC @@ -12,8 +12,8 @@ Downloaded by pub (not CocoaPods). s.homepage = 'https://github.com/flutter/plugins' s.license = { :type => 'BSD', :file => '../LICENSE' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } - s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/local_auth' } - s.documentation_url = 'https://pub.dev/packages/local_auth' + s.source = { :http => 'https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_ios' } + s.documentation_url = 'https://pub.dev/packages/local_auth_ios' s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart new file mode 100644 index 000000000000..979107d09679 --- /dev/null +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -0,0 +1,75 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +export 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = + MethodChannel('plugins.flutter.io/local_auth_ios'); + +/// The implementation of [LocalAuthPlatform] for iOS. +class LocalAuthIOS extends LocalAuthPlatform { + /// Registers this class as the default instance of [LocalAuthPlatform]. + static void registerWith() { + LocalAuthPlatform.instance = LocalAuthIOS(); + } + + @override + Future authenticate({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + required Map authStrings, + bool sensitiveTransaction = true, + bool biometricOnly = false, + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': useErrorDialogs, + 'stickyAuth': stickyAuth, + 'sensitiveTransaction': sensitiveTransaction, + 'biometricOnly': biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async { + throw UnimplementedError('stopAuthentication() is not supported on iOS.'); + } +} diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart new file mode 100644 index 000000000000..9147cf32c117 --- /dev/null +++ b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart @@ -0,0 +1,76 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:intl/intl.dart'; +import 'package:local_auth_platform_interface/types/auth_strings.dart'; + +/// iOS side authentication messages. +/// +/// Provides default values for all messages. +class IOSAuthMessages { + /// Constructs a new instance. + const IOSAuthMessages({ + this.lockOut, + this.goToSettingsButton, + this.goToSettingsDescription, + this.cancelButton, + }); + + /// Message advising the user to re-enable biometrics on their device. + /// It shows in a dialog on iOS. + final String? lockOut; + + /// Message shown on a button that the user can click to go to settings pages + /// from the current dialog. It is used on both Android and iOS sides. + /// Maximum 30 characters. + final String? goToSettingsButton; + + /// Message advising the user to go to the settings and configure Biometrics + /// for their device. It shows in a dialog on iOS. + final String? goToSettingsDescription; + + /// Message shown on a button that the user can click to leave the current + /// dialog. It is used on iOS. + /// Maximum 30 characters. + final String? cancelButton; + + /// Gets the messaged stored in this class instance as a string map. + Map get args { + return { + 'lockOut': lockOut ?? iOSLockOut, + 'goToSetting': goToSettingsButton ?? goToSettings, + 'goToSettingDescriptionIOS': + goToSettingsDescription ?? iOSGoToSettingsDescription, + 'okButton': cancelButton ?? iOSOkButton, + }; + } +} + +// Strings for local_authentication plugin. Currently supports English. +// Intl.message must be string literals. + +/// Message advising the user to re-enable biometrics on their device. +/// It shows in a dialog on iOS. +String get iOSLockOut => Intl.message( + 'Biometric authentication is disabled. Please lock and unlock your screen to ' + 'enable it.', + desc: + 'Message advising the user to re-enable biometrics on their device. It ' + 'shows in a dialog on the iOS.'); + +/// Message advising the user to go to the settings and configure Biometrics +/// for their device. It shows in a dialog on iOS. +String get iOSGoToSettingsDescription => Intl.message( + 'Biometric authentication is not set up on your device. Please either enable ' + 'Touch ID or Face ID on your phone.', + desc: + 'Message advising the user to go to the settings and configure Biometrics ' + 'for their device. It shows in a dialog on iOS.'); + +/// Message shown on a button that the user can click to leave the current +/// dialog. It is used on iOS. +/// Maximum 30 characters. +String get iOSOkButton => Intl.message('OK', + desc: 'Message showed on a button that the user can click to leave the ' + 'current dialog. It is used on iOS side. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_ios/pubspec.yaml b/packages/local_auth/local_auth_ios/pubspec.yaml new file mode 100644 index 000000000000..60f3aa977d5f --- /dev/null +++ b/packages/local_auth/local_auth_ios/pubspec.yaml @@ -0,0 +1,30 @@ +name: local_auth_ios +description: iOS implementation of the local_auth plugin. +repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_ios +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0 + +flutter: + plugin: + platforms: + ios: + pluginClass: FLTLocalAuthPlugin + dartPluginClass: LocalAuthIOS + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + +dependencies: + flutter: + sdk: flutter + intl: ^0.17.0 + local_auth_platform_interface: + path: ../local_auth_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^5.0.0 \ No newline at end of file diff --git a/packages/local_auth/local_auth_ios/test/local_auth_test.dart b/packages/local_auth/local_auth_ios/test/local_auth_test.dart new file mode 100644 index 000000000000..316e3644a933 --- /dev/null +++ b/packages/local_auth/local_auth_ios/test/local_auth_test.dart @@ -0,0 +1,110 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_ios/local_auth_ios.dart'; +import 'package:local_auth_ios/types/auth_strings_ios.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('LocalAuth', () { + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth_ios', + ); + + final List log = []; + late LocalAuthIOS localAuthentication; + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = LocalAuthIOS(); + log.clear(); + }); + + group('With device auth fail over', () { + test('authenticate with no args on iOS.', () async { + await localAuthentication.authenticate( + authStrings: const IOSAuthMessages().args, + localizedReason: 'Needs secure', + biometricOnly: true, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }..addAll(const IOSAuthMessages().args)), + ], + ); + }); + + test('authenticate with no localizedReason on iOS.', () async { + await expectLater( + localAuthentication.authenticate( + authStrings: const IOSAuthMessages().args, + localizedReason: '', + biometricOnly: true, + ), + throwsAssertionError, + ); + }); + }); + + group('With biometrics only', () { + test('authenticate with no args on iOS.', () async { + await localAuthentication.authenticate( + authStrings: const IOSAuthMessages().args, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }..addAll(const IOSAuthMessages().args)), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: const IOSAuthMessages().args, + localizedReason: 'Insecure', + sensitiveTransaction: false, + useErrorDialogs: false, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }..addAll(const IOSAuthMessages().args)), + ], + ); + }); + }); + }); +} diff --git a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml b/packages/local_auth/local_auth_platform_interface/analysis_options.yaml deleted file mode 100644 index a5744c1cfbe7..000000000000 --- a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart new file mode 100644 index 000000000000..5256f3d6070d --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -0,0 +1,65 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth'); + +/// The default interface implementation acting as a placeholder for +/// the native implementation to be set. +class DefaultLocalAuthPlatform extends LocalAuthPlatform { + @override + Future authenticate({ + required String localizedReason, + required Map authStrings, + AuthenticationOptions options = const AuthenticationOptions(), + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': options.useErrorDialogs, + 'stickyAuth': options.stickyAuth, + 'sensitiveTransaction': options.sensitiveTransaction, + 'biometricOnly': options.biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async => + await _channel.invokeMethod('stopAuthentication') ?? false; +} diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index 833004b7e032..32f039e86063 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -25,8 +27,9 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// Defaults to [DefaultLocalAuthPlatform]. static LocalAuthPlatform get instance => _instance; - /// Platform-specific plugins should set this with their own platform-specific - /// class that extends [LocalAuthPlatform] when they register themselves. + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [LocalAuthPlatform] when they + /// register themselves. static set instance(LocalAuthPlatform instance) { PlatformInterface.verifyToken(instance, _token); _instance = instance; @@ -42,31 +45,10 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// for authentication. This is typically along the lines of: 'Please scan /// 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 - /// fingerprint reader exists on the phone but there's no fingerprint - /// registered, the plugin will attempt to take the user to settings to add - /// one. Anything that is not user fixable, such as no biometric sensor on - /// device, will be returned as a [PlatformException]. - /// - /// [stickyAuth] is used when the application goes into background for any - /// reason while the authentication is in progress. Due to security reasons, - /// the authentication has to be stopped at that time. If stickyAuth is set - /// to true, authentication resumes when the app is resumed. If it is set to - /// false (default), then as soon as app is paused a failure message is sent - /// back to Dart and it is up to the client app to restart authentication or - /// do something else. - /// /// Provide [authStrings] if you want to /// customize messages in the dialogs. /// - /// Setting [sensitiveTransaction] to true enables platform specific - /// precautions. For instance, on face unlock, Android opens a confirmation - /// dialog after the face is recognized to make sure the user meant to unlock - /// their phone. - /// - /// Setting [biometricOnly] to true prevents authenticates from using non-biometric - /// local authentication such as pin, passcode, and passcode. + /// Provide [options] for configuring further authentication related options. /// /// Throws an [PlatformException] if there were technical problems with local /// authentication (e.g. lack of relevant hardware). This might throw @@ -74,11 +56,8 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// simulator. Future authenticate({ required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, required Map authStrings, - bool sensitiveTransaction = true, - bool biometricOnly = false, + AuthenticationOptions options = const AuthenticationOptions(), }) async { throw UnimplementedError('authenticate() has not been implemented.'); } @@ -110,7 +89,3 @@ abstract class LocalAuthPlatform extends PlatformInterface { throw UnimplementedError('stopAuthentication() has not been implemented.'); } } - -/// The default interface implementation acting as a placeholder for -/// the native implementation to be set. -class DefaultLocalAuthPlatform extends LocalAuthPlatform {} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart new file mode 100644 index 000000000000..8a8efc6c2411 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart @@ -0,0 +1,40 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/// Options wrapper for [LocalAuthPlatform.authenticate] parameters. +class AuthenticationOptions { + /// Construct a new instance. + const AuthenticationOptions({ + this.useErrorDialogs = true, + this.stickyAuth = false, + this.sensitiveTransaction = true, + this.biometricOnly = false, + }); + + /// Whether the system will attempt to handle user fixable issues encountered + /// while authenticating. For instance, if fingerprint reader exists on the + /// phone but there's no fingerprint registered, the plugin will attempt to + /// take the user to settings to add one. Anything that is not user fixable, + /// such as no biometric sensor on device, will be returned + /// as a [PlatformException]. + final bool useErrorDialogs; + + /// Used when the application goes into background for any reason while the + /// authentication is in progress. Due to security reasons, the + /// authentication has to be stopped at that time. If stickyAuth is set to + /// true, authentication resumes when the app is resumed. If it is set to + /// false (default), then as soon as app is paused a failure message is sent + /// back to Dart and it is up to the client app to restart authentication or + /// do something else. + final bool stickyAuth; + + /// Whether platform specific precautions are enabled. For instance, on face + /// unlock, Android opens a confirmation dialog after the face is recognized + /// to make sure the user meant to unlock their phone. + final bool sensitiveTransaction; + + /// Prevent authentications from using non-biometric local authentication + /// such as pin, passcode, and passcode. + final bool biometricOnly; +} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart index 0ad81392edb9..be75ea1fe880 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart @@ -4,7 +4,10 @@ import 'package:intl/intl.dart'; +/// Message shown on a button that the user can click to go to settings pages +/// from the current dialog. It is used on both Android and iOS sides. +/// Maximum 30 characters. String get goToSettings => Intl.message('Go to settings', - desc: 'Message showed on a button that the user can click to go to ' + desc: 'Message shown on a button that the user can click to go to ' 'settings pages from the current dialog. It is used on both Android ' - 'and iOS side. Maximum 30 characters.'); + 'and iOS sides. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index 23556ab37caa..9c7d2eb8d83e 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -2,4 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -enum BiometricType { face, fingerprint, iris } +/// Various types of biometric authentication. +enum BiometricType { + /// Face authentication. + face, + + /// Fingerprint authentication. + fingerprint, + + /// Iris authentication. + iris, + + /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets + /// or exceeds the requirements for Class 3 (formerly Strong), as defined + /// by the Android CDD. Android only. + strong, + + /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets + /// or exceeds the requirements for Class 2 (formerly Weak), as defined + /// by the Android CDD. Android only. + weak, +} diff --git a/packages/local_auth/local_auth_platform_interface/pubspec.yaml b/packages/local_auth/local_auth_platform_interface/pubspec.yaml index 0f88856bf4ee..f04268926ebd 100644 --- a/packages/local_auth/local_auth_platform_interface/pubspec.yaml +++ b/packages/local_auth/local_auth_platform_interface/pubspec.yaml @@ -1,7 +1,7 @@ name: local_auth_platform_interface description: A common platform interface for the local_auth plugin. repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_platform_interface -issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes version: 1.0.0 @@ -13,8 +13,8 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.1.2 intl: ^0.17.0 + plugin_platform_interface: ^2.1.2 dev_dependencies: flutter_test: diff --git a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart new file mode 100644 index 000000000000..d1ee3c504c40 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart @@ -0,0 +1,172 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth', + ); + + final List log = []; + late LocalAuthPlatform localAuthentication; + + test('getAvailableBiometrics', () async { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value([]); + }); + localAuthentication = DefaultLocalAuthPlatform(); + log.clear(); + await localAuthentication.getAvailableBiometrics(); + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + }); + + group('Boolean returning methods', () { + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = DefaultLocalAuthPlatform(); + log.clear(); + }); + + test('isDeviceSupported', () async { + await localAuthentication.isDeviceSupported(); + expect( + log, + [ + isMethodCall('isDeviceSupported', arguments: null), + ], + ); + }); + + test('stopAuthentication', () async { + await localAuthentication.stopAuthentication(); + expect( + log, + [ + isMethodCall('stopAuthentication', arguments: null), + ], + ); + }); + + group('authenticate with device auth fail over', () { + test('authenticate with no args.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Needs secure', + options: const AuthenticationOptions(biometricOnly: true), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }, + ), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Insecure', + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + biometricOnly: true, + ), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': true, + }, + ), + ], + ); + }); + }); + + group('authenticate with biometrics only', () { + test('authenticate with no args.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }, + ), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Insecure', + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + ), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }, + ), + ], + ); + }); + }); + }); +} From cdf2cfee3984c582f044843549bc177bdcf0cd56 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 12:33:05 +0100 Subject: [PATCH 14/53] Add Android implementation of platform interface --- packages/local_auth/local_auth/pubspec.yaml | 7 + .../local_auth/local_auth_android/AUTHORS | 67 +++++ .../local_auth_android/CHANGELOG.md | 3 + .../local_auth/local_auth_android/LICENSE | 25 ++ .../local_auth/local_auth_android/README.md | 11 + .../android/build.gradle | 0 .../android/lint-baseline.xml | 0 .../android/settings.gradle | 0 .../android/src/main/AndroidManifest.xml | 0 .../localauth/AuthenticationHelper.java | 0 .../plugins/localauth/LocalAuthPlugin.java | 2 +- .../res/drawable/fingerprint_initial_icon.xml | 0 .../res/drawable/fingerprint_success_icon.xml | 0 .../res/drawable/fingerprint_warning_icon.xml | 0 .../main/res/drawable/ic_done_white_24dp.xml | 0 .../drawable/ic_fingerprint_white_24dp.xml | 0 .../drawable/ic_priority_high_white_24dp.xml | 0 .../src/main/res/layout/go_to_setting.xml | 0 .../android/src/main/res/layout/scan_fp.xml | 0 .../android/src/main/res/values/colors.xml | 0 .../android/src/main/res/values/dimens.xml | 0 .../android/src/main/res/values/styles.xml | 0 .../plugins/localauth/LocalAuthTest.java | 0 .../local_auth_android/example/README.md | 8 + .../example/android/app/build.gradle | 58 +++++ .../gradle/wrapper/gradle-wrapper.properties | 5 + .../flutter/plugins/DartIntegrationTest.java | 14 ++ .../FlutterFragmentActivityTest.java | 20 ++ .../android/app/src/main/AndroidManifest.xml | 21 ++ .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../example/android/build.gradle | 29 +++ .../example/android/gradle.properties | 4 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../example/android/settings.gradle | 15 ++ .../example/android/settings_aar.gradle | 1 + .../integration_test/local_auth_test.dart | 19 ++ .../local_auth_android/example/lib/main.dart | 231 ++++++++++++++++++ .../local_auth_android/example/pubspec.yaml | 28 +++ .../example/test_driver/integration_test.dart | 7 + .../lib/local_auth_android.dart | 74 ++++++ .../lib/types/auth_strings_android.dart | 159 ++++++++++++ .../local_auth_android/pubspec.yaml | 32 +++ .../test/local_auth_test.dart | 122 +++++++++ .../analysis_options.yaml | 4 - .../lib/default_method_channel_platform.dart | 65 +++++ .../lib/local_auth_platform_interface.dart | 39 +-- .../lib/types/auth_options.dart | 40 +++ .../lib/types/auth_strings.dart | 7 +- .../lib/types/biometric_type.dart | 22 +- .../pubspec.yaml | 4 +- .../default_method_channel_platform_test.dart | 172 +++++++++++++ 55 files changed, 1279 insertions(+), 42 deletions(-) create mode 100644 packages/local_auth/local_auth_android/AUTHORS create mode 100644 packages/local_auth/local_auth_android/CHANGELOG.md create mode 100644 packages/local_auth/local_auth_android/LICENSE create mode 100644 packages/local_auth/local_auth_android/README.md rename packages/local_auth/{local_auth => local_auth_android}/android/build.gradle (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/lint-baseline.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/settings.gradle (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/AndroidManifest.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java (99%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/drawable/fingerprint_initial_icon.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/drawable/fingerprint_success_icon.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/drawable/fingerprint_warning_icon.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/drawable/ic_done_white_24dp.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/drawable/ic_priority_high_white_24dp.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/layout/go_to_setting.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/layout/scan_fp.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/values/colors.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/values/dimens.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/main/res/values/styles.xml (100%) rename packages/local_auth/{local_auth => local_auth_android}/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java (100%) create mode 100644 packages/local_auth/local_auth_android/example/README.md create mode 100644 packages/local_auth/local_auth_android/example/android/app/build.gradle create mode 100644 packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 packages/local_auth/local_auth_android/example/android/build.gradle create mode 100644 packages/local_auth/local_auth_android/example/android/gradle.properties create mode 100644 packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 packages/local_auth/local_auth_android/example/android/settings.gradle create mode 100644 packages/local_auth/local_auth_android/example/android/settings_aar.gradle create mode 100644 packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart create mode 100644 packages/local_auth/local_auth_android/example/lib/main.dart create mode 100644 packages/local_auth/local_auth_android/example/pubspec.yaml create mode 100644 packages/local_auth/local_auth_android/example/test_driver/integration_test.dart create mode 100644 packages/local_auth/local_auth_android/lib/local_auth_android.dart create mode 100644 packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart create mode 100644 packages/local_auth/local_auth_android/pubspec.yaml create mode 100644 packages/local_auth/local_auth_android/test/local_auth_test.dart delete mode 100644 packages/local_auth/local_auth_platform_interface/analysis_options.yaml create mode 100644 packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart create mode 100644 packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index cd9d0d9760f4..f7bba9f26554 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -5,6 +5,10 @@ repository: https://github.com/flutter/plugins/tree/main/packages/local_auth/loc issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 version: 1.1.10 +# Temporarily disable publishing to allow moving Android and iOS +# implementations. +publish_to: none + environment: sdk: ">=2.14.0 <3.0.0" flutter: ">=2.5.0" @@ -15,6 +19,7 @@ flutter: android: package: io.flutter.plugins.localauth pluginClass: LocalAuthPlugin + default_package: local_auth_android ios: pluginClass: FLTLocalAuthPlugin @@ -23,6 +28,8 @@ dependencies: sdk: flutter flutter_plugin_android_lifecycle: ^2.0.1 intl: ^0.17.0 + local_auth_android: + path: ../local_auth_android platform: ^3.0.0 dev_dependencies: diff --git a/packages/local_auth/local_auth_android/AUTHORS b/packages/local_auth/local_auth_android/AUTHORS new file mode 100644 index 000000000000..d5694690c247 --- /dev/null +++ b/packages/local_auth/local_auth_android/AUTHORS @@ -0,0 +1,67 @@ +# Below is a list of people and organizations that have contributed +# to the Flutter project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. +The Chromium Authors +German Saprykin +Benjamin Sauer +larsenthomasj@gmail.com +Ali Bitek +Pol Batlló +Anatoly Pulyaevskiy +Hayden Flinner +Stefano Rodriguez +Salvatore Giordano +Brian Armstrong +Paul DeMarco +Fabricio Nogueira +Simon Lightfoot +Ashton Thomas +Thomas Danner +Diego Velásquez +Hajime Nakamura +Tuyển Vũ Xuân +Miguel Ruivo +Sarthak Verma +Mike Diarmid +Invertase +Elliot Hesp +Vince Varga +Aawaz Gyawali +EUI Limited +Katarina Sheremet +Thomas Stockx +Sarbagya Dhaubanjar +Ozkan Eksi +Rishab Nayak +ko2ic +Jonathan Younger +Jose Sanchez +Debkanchan Samadder +Audrius Karosevicius +Lukasz Piliszczuk +SoundReply Solutions GmbH +Rafal Wachol +Pau Picas +Christian Weder +Alexandru Tuca +Christian Weder +Rhodes Davis Jr. +Luigi Agosti +Quentin Le Guennec +Koushik Ravikumar +Nissim Dsilva +Giancarlo Rocha +Ryo Miyake +Théo Champion +Kazuki Yamaguchi +Eitan Schwartz +Chris Rutkowski +Juan Alvarez +Aleksandr Yurkovskiy +Anton Borries +Alex Li +Rahul Raj <64.rahulraj@gmail.com> +Bodhi Mulders diff --git a/packages/local_auth/local_auth_android/CHANGELOG.md b/packages/local_auth/local_auth_android/CHANGELOG.md new file mode 100644 index 000000000000..7f198f2d66c0 --- /dev/null +++ b/packages/local_auth/local_auth_android/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial release from migration to federated architecture. diff --git a/packages/local_auth/local_auth_android/LICENSE b/packages/local_auth/local_auth_android/LICENSE new file mode 100644 index 000000000000..c6823b81eb84 --- /dev/null +++ b/packages/local_auth/local_auth_android/LICENSE @@ -0,0 +1,25 @@ +Copyright 2013 The Flutter Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/local_auth/local_auth_android/README.md b/packages/local_auth/local_auth_android/README.md new file mode 100644 index 000000000000..07244912f231 --- /dev/null +++ b/packages/local_auth/local_auth_android/README.md @@ -0,0 +1,11 @@ +# local\_auth\_android + +The Android implementation of [`local_auth`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `local_auth` +normally. This package will be automatically included in your app when you do. + +[1]: https://pub.dev/packages/local_auth +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin \ No newline at end of file diff --git a/packages/local_auth/local_auth/android/build.gradle b/packages/local_auth/local_auth_android/android/build.gradle similarity index 100% rename from packages/local_auth/local_auth/android/build.gradle rename to packages/local_auth/local_auth_android/android/build.gradle diff --git a/packages/local_auth/local_auth/android/lint-baseline.xml b/packages/local_auth/local_auth_android/android/lint-baseline.xml similarity index 100% rename from packages/local_auth/local_auth/android/lint-baseline.xml rename to packages/local_auth/local_auth_android/android/lint-baseline.xml diff --git a/packages/local_auth/local_auth/android/settings.gradle b/packages/local_auth/local_auth_android/android/settings.gradle similarity index 100% rename from packages/local_auth/local_auth/android/settings.gradle rename to packages/local_auth/local_auth_android/android/settings.gradle diff --git a/packages/local_auth/local_auth/android/src/main/AndroidManifest.xml b/packages/local_auth/local_auth_android/android/src/main/AndroidManifest.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/AndroidManifest.xml rename to packages/local_auth/local_auth_android/android/src/main/AndroidManifest.xml diff --git a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java similarity index 100% rename from packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java rename to packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/AuthenticationHelper.java diff --git a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java similarity index 99% rename from packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java rename to packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java index a63e22a512d0..49a6b788fe46 100644 --- a/packages/local_auth/local_auth/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java @@ -40,7 +40,7 @@ */ @SuppressWarnings("deprecation") public class LocalAuthPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware { - private static final String CHANNEL_NAME = "plugins.flutter.io/local_auth"; + private static final String CHANNEL_NAME = "plugins.flutter.io/local_auth_android"; private static final int LOCK_REQUEST_CODE = 221; private Activity activity; private final AtomicBoolean authInProgress = new AtomicBoolean(false); diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_initial_icon.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_initial_icon.xml rename to packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_initial_icon.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_success_icon.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_success_icon.xml rename to packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_success_icon.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_warning_icon.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/drawable/fingerprint_warning_icon.xml rename to packages/local_auth/local_auth_android/android/src/main/res/drawable/fingerprint_warning_icon.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_done_white_24dp.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/drawable/ic_done_white_24dp.xml rename to packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_done_white_24dp.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml rename to packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_fingerprint_white_24dp.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml b/packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_priority_high_white_24dp.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/drawable/ic_priority_high_white_24dp.xml rename to packages/local_auth/local_auth_android/android/src/main/res/drawable/ic_priority_high_white_24dp.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml b/packages/local_auth/local_auth_android/android/src/main/res/layout/go_to_setting.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/layout/go_to_setting.xml rename to packages/local_auth/local_auth_android/android/src/main/res/layout/go_to_setting.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml b/packages/local_auth/local_auth_android/android/src/main/res/layout/scan_fp.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/layout/scan_fp.xml rename to packages/local_auth/local_auth_android/android/src/main/res/layout/scan_fp.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/values/colors.xml b/packages/local_auth/local_auth_android/android/src/main/res/values/colors.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/values/colors.xml rename to packages/local_auth/local_auth_android/android/src/main/res/values/colors.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/values/dimens.xml b/packages/local_auth/local_auth_android/android/src/main/res/values/dimens.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/values/dimens.xml rename to packages/local_auth/local_auth_android/android/src/main/res/values/dimens.xml diff --git a/packages/local_auth/local_auth/android/src/main/res/values/styles.xml b/packages/local_auth/local_auth_android/android/src/main/res/values/styles.xml similarity index 100% rename from packages/local_auth/local_auth/android/src/main/res/values/styles.xml rename to packages/local_auth/local_auth_android/android/src/main/res/values/styles.xml diff --git a/packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java b/packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java similarity index 100% rename from packages/local_auth/local_auth/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java rename to packages/local_auth/local_auth_android/android/src/test/java/io/flutter/plugins/localauth/LocalAuthTest.java diff --git a/packages/local_auth/local_auth_android/example/README.md b/packages/local_auth/local_auth_android/example/README.md new file mode 100644 index 000000000000..a4a6091c9ba6 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/README.md @@ -0,0 +1,8 @@ +# local_auth_example + +Demonstrates how to use the local_auth plugin. + +## Getting Started + +For help getting started with Flutter, view our online +[documentation](https://flutter.dev/). diff --git a/packages/local_auth/local_auth_android/example/android/app/build.gradle b/packages/local_auth/local_auth_android/example/android/app/build.gradle new file mode 100644 index 000000000000..d1cef4bf53a9 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/build.gradle @@ -0,0 +1,58 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 31 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + applicationId "io.flutter.plugins.localauthexample" + minSdkVersion 16 + targetSdkVersion 28 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} diff --git a/packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..186b71557c50 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java new file mode 100644 index 000000000000..0f4298dca155 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/DartIntegrationTest.java @@ -0,0 +1,14 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface DartIntegrationTest {} diff --git a/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java new file mode 100644 index 000000000000..68c22371d7dd --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/src/androidTest/java/io/flutter/plugins/localauth/FlutterFragmentActivityTest.java @@ -0,0 +1,20 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.plugins.localauth; + +import androidx.test.rule.ActivityTestRule; +import dev.flutter.plugins.integration_test.FlutterTestRunner; +import io.flutter.embedding.android.FlutterFragmentActivity; +import io.flutter.plugins.DartIntegrationTest; +import org.junit.Rule; +import org.junit.runner.RunWith; + +@DartIntegrationTest +@RunWith(FlutterTestRunner.class) +public class FlutterFragmentActivityTest { + @Rule + public ActivityTestRule rule = + new ActivityTestRule<>(FlutterFragmentActivity.class); +} diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml b/packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..8c091772107a --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/local_auth/local_auth_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/packages/local_auth/local_auth_android/example/android/build.gradle b/packages/local_auth/local_auth_android/example/android/build.gradle new file mode 100644 index 000000000000..54c943621de5 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.1' + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/packages/local_auth/local_auth_android/example/android/gradle.properties b/packages/local_auth/local_auth_android/example/android/gradle.properties new file mode 100644 index 000000000000..7fe61a74cee0 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-Xmx1024m +android.useAndroidX=true +android.enableJetifier=true +android.enableR8=true diff --git a/packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..cd9fe1c68282 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Jan 03 14:07:08 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip diff --git a/packages/local_auth/local_auth_android/example/android/settings.gradle b/packages/local_auth/local_auth_android/example/android/settings.gradle new file mode 100644 index 000000000000..115da6cb4f4d --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withInputStream { stream -> plugins.load(stream) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/packages/local_auth/local_auth_android/example/android/settings_aar.gradle b/packages/local_auth/local_auth_android/example/android/settings_aar.gradle new file mode 100644 index 000000000000..e7b4def49cb5 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/android/settings_aar.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart new file mode 100644 index 000000000000..8e4f4748f05f --- /dev/null +++ b/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart @@ -0,0 +1,19 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:local_auth_android/local_auth_android.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('canCheckBiometrics', (WidgetTester tester) async { + expect( + LocalAuthAndroid().getAvailableBiometrics(), + completion(isList), + ); + }); +} diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart new file mode 100644 index 000000000000..4328f28136c2 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -0,0 +1,231 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_android/types/auth_strings_android.dart'; + +void main() { + runApp(MyApp()); +} + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + final LocalAuthAndroid auth = LocalAuthAndroid(); + _SupportState _supportState = _SupportState.unknown; + bool? _canCheckBiometrics; + List? _availableBiometrics; + String _authorized = 'Not Authorized'; + bool _isAuthenticating = false; + + @override + void initState() { + super.initState(); + auth.isDeviceSupported().then( + (bool isSupported) => setState(() => _supportState = isSupported + ? _SupportState.supported + : _SupportState.unsupported), + ); + } + + Future _checkBiometrics() async { + late bool canCheckBiometrics; + try { + canCheckBiometrics = (await auth.getAvailableBiometrics()).isNotEmpty; + } on PlatformException catch (e) { + canCheckBiometrics = false; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _canCheckBiometrics = canCheckBiometrics; + }); + } + + Future _getAvailableBiometrics() async { + late List availableBiometrics; + try { + availableBiometrics = await auth.getAvailableBiometrics(); + } on PlatformException catch (e) { + availableBiometrics = []; + print(e); + } + if (!mounted) { + return; + } + + setState(() { + _availableBiometrics = availableBiometrics; + }); + } + + Future _authenticate() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: 'Let OS determine authentication method', + authStrings: const AndroidAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true); + setState(() { + _isAuthenticating = false; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + setState( + () => _authorized = authenticated ? 'Authorized' : 'Not Authorized'); + } + + Future _authenticateWithBiometrics() async { + bool authenticated = false; + try { + setState(() { + _isAuthenticating = true; + _authorized = 'Authenticating'; + }); + authenticated = await auth.authenticate( + localizedReason: + 'Scan your fingerprint (or face or whatever) to authenticate', + authStrings: const AndroidAuthMessages().args, + useErrorDialogs: true, + stickyAuth: true, + biometricOnly: true); + setState(() { + _isAuthenticating = false; + _authorized = 'Authenticating'; + }); + } on PlatformException catch (e) { + print(e); + setState(() { + _isAuthenticating = false; + _authorized = 'Error - ${e.message}'; + }); + return; + } + if (!mounted) { + return; + } + + final String message = authenticated ? 'Authorized' : 'Not Authorized'; + setState(() { + _authorized = message; + }); + } + + Future _cancelAuthentication() async { + await auth.stopAuthentication(); + setState(() => _isAuthenticating = false); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: ListView( + padding: const EdgeInsets.only(top: 30), + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (_supportState == _SupportState.unknown) + const CircularProgressIndicator() + else if (_supportState == _SupportState.supported) + const Text('This device is supported') + else + const Text('This device is not supported'), + const Divider(height: 100), + Text('Can check biometrics: $_canCheckBiometrics\n'), + ElevatedButton( + child: const Text('Check biometrics'), + onPressed: _checkBiometrics, + ), + const Divider(height: 100), + Text('Available biometrics: $_availableBiometrics\n'), + ElevatedButton( + child: const Text('Get available biometrics'), + onPressed: _getAvailableBiometrics, + ), + const Divider(height: 100), + Text('Current State: $_authorized\n'), + if (_isAuthenticating) + ElevatedButton( + onPressed: _cancelAuthentication, + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Cancel Authentication'), + Icon(Icons.cancel), + ], + ), + ) + else + Column( + children: [ + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Authenticate'), + Icon(Icons.perm_device_information), + ], + ), + onPressed: _authenticate, + ), + ElevatedButton( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text(_isAuthenticating + ? 'Cancel' + : 'Authenticate: biometrics only'), + const Icon(Icons.fingerprint), + ], + ), + onPressed: _authenticateWithBiometrics, + ), + ], + ), + ], + ), + ], + ), + ), + ); + } +} + +enum _SupportState { + unknown, + supported, + unsupported, +} diff --git a/packages/local_auth/local_auth_android/example/pubspec.yaml b/packages/local_auth/local_auth_android/example/pubspec.yaml new file mode 100644 index 000000000000..efd7c9c79f7f --- /dev/null +++ b/packages/local_auth/local_auth_android/example/pubspec.yaml @@ -0,0 +1,28 @@ +name: local_auth_android_example +description: Demonstrates how to use the local_auth_android plugin. +publish_to: none + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + local_auth_android: + # When depending on this package from a real application you should use: + # local_auth: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + +dev_dependencies: + flutter_driver: + sdk: flutter + integration_test: + sdk: flutter + pedantic: ^1.10.0 + +flutter: + uses-material-design: true diff --git a/packages/local_auth/local_auth_android/example/test_driver/integration_test.dart b/packages/local_auth/local_auth_android/example/test_driver/integration_test.dart new file mode 100644 index 000000000000..4f10f2a522f3 --- /dev/null +++ b/packages/local_auth/local_auth_android/example/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart new file mode 100644 index 000000000000..0f82e7cf9158 --- /dev/null +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -0,0 +1,74 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +export 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = + MethodChannel('plugins.flutter.io/local_auth_android'); + +/// The implementation of [LocalAuthPlatform] for Android. +class LocalAuthAndroid extends LocalAuthPlatform { + /// Registers this class as the default instance of [LocalAuthPlatform]. + static void registerWith() { + LocalAuthPlatform.instance = LocalAuthAndroid(); + } + + @override + Future authenticate({ + required String localizedReason, + bool useErrorDialogs = true, + bool stickyAuth = false, + required Map authStrings, + bool sensitiveTransaction = true, + bool biometricOnly = false, + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': useErrorDialogs, + 'stickyAuth': stickyAuth, + 'sensitiveTransaction': sensitiveTransaction, + 'biometricOnly': biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async => + await _channel.invokeMethod('stopAuthentication') ?? false; +} diff --git a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart new file mode 100644 index 000000000000..9d9886ce7168 --- /dev/null +++ b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart @@ -0,0 +1,159 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:intl/intl.dart'; +import 'package:local_auth_platform_interface/types/auth_strings.dart'; + +/// Android side authentication messages. +/// +/// Provides default values for all messages. +class AndroidAuthMessages { + /// Constructs a new instance. + const AndroidAuthMessages({ + this.biometricHint, + this.biometricNotRecognized, + this.biometricRequiredTitle, + this.biometricSuccess, + this.cancelButton, + this.deviceCredentialsRequiredTitle, + this.deviceCredentialsSetupDescription, + this.goToSettingsButton, + this.goToSettingsDescription, + this.signInTitle, + }); + + /// Hint message advising the user how to authenticate with biometrics. It is + /// used on Android. Maximum 60 characters. + final String? biometricHint; + + /// Message to let the user know that authentication was failed. It is used + /// on Android. Maximum 60 characters.' + final String? biometricNotRecognized; + + /// Message shown as a title in a dialog which indicates the user + /// has not set up biometric authentication on their device. It is used on + /// Android. Maximum 60 characters. + final String? biometricRequiredTitle; + + /// Message to let the user know that authentication was successful. It + /// is used on Android. Maximum 60 characters + final String? biometricSuccess; + + /// Message shown on a button that the user can click to leave the + /// current dialog. It is used on Android. Maximum 30 characters. + final String? cancelButton; + + /// Message shown as a title in a dialog which indicates the user + /// has not set up credentials authentication on their device. It is used on Android. + /// Maximum 60 characters. + final String? deviceCredentialsRequiredTitle; + + /// Message advising the user to go to the settings and configure + /// device credentials on their device. It shows in a dialog on Android. + final String? deviceCredentialsSetupDescription; + + /// Message shown on a button that the user can click to go to settings pages + /// from the current dialog. It is used on both Android and iOS sides. + /// Maximum 30 characters. + final String? goToSettingsButton; + + /// Message advising the user to go to the settings and configure + /// biometric on their device. It shows in a dialog on Android. + final String? goToSettingsDescription; + + /// Message shown as a title in a dialog which indicates the user + /// that they need to scan biometric to continue. It is used on + /// Android. Maximum 60 characters. + final String? signInTitle; + + /// Gets the messaged stored in this class instance as a string map. + Map get args { + return { + 'biometricHint': biometricHint ?? androidBiometricHint, + 'biometricNotRecognized': + biometricNotRecognized ?? androidBiometricNotRecognized, + 'biometricSuccess': biometricSuccess ?? androidBiometricSuccess, + 'biometricRequired': + biometricRequiredTitle ?? androidBiometricRequiredTitle, + 'cancelButton': cancelButton ?? androidCancelButton, + 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? + androidDeviceCredentialsRequiredTitle, + 'deviceCredentialsSetupDescription': deviceCredentialsSetupDescription ?? + androidDeviceCredentialsSetupDescription, + 'goToSetting': goToSettingsButton ?? goToSettings, + 'goToSettingDescription': + goToSettingsDescription ?? androidGoToSettingsDescription, + 'signInTitle': signInTitle ?? androidSignInTitle, + }; + } +} + +// Strings for local_authentication plugin. Currently supports English. +// Intl.message must be string literals. + +/// Hint message advising the user how to authenticate with biometrics. It is +/// used on Android. Maximum 60 characters. +String get androidBiometricHint => Intl.message('Verify identity', + desc: + 'Hint message advising the user how to authenticate with biometrics. It is ' + 'used on Android. Maximum 60 characters.'); + +/// Message to let the user know that authentication was failed. It is used +/// on Android. Maximum 60 characters.' +String get androidBiometricNotRecognized => + Intl.message('Not recognized. Try again.', + desc: 'Message to let the user know that authentication was failed. It ' + 'is used on Android. Maximum 60 characters.'); + +/// Message to let the user know that authentication was successful. It +/// is used on Android. Maximum 60 characters +String get androidBiometricSuccess => Intl.message('Success', + desc: 'Message to let the user know that authentication was successful. It ' + 'is used on Android. Maximum 60 characters.'); + +/// Message shown on a button that the user can click to leave the +/// current dialog. It is used on Android. Maximum 30 characters. +String get androidCancelButton => Intl.message('Cancel', + desc: 'Message shown on a button that the user can click to leave the ' + 'current dialog. It is used on Android. Maximum 30 characters.'); + +/// Message shown as a title in a dialog which indicates the user +/// that they need to scan biometric to continue. It is used on +/// Android. Maximum 60 characters. +String get androidSignInTitle => Intl.message('Authentication required', + desc: 'Message shown as a title in a dialog which indicates the user ' + 'that they need to scan biometric to continue. It is used on ' + 'Android. Maximum 60 characters.'); + +/// Message shown as a title in a dialog which indicates the user +/// has not set up biometric authentication on their device. It is used on +/// Android. Maximum 60 characters. +String get androidBiometricRequiredTitle => Intl.message('Biometric required', + desc: 'Message shown as a title in a dialog which indicates the user ' + 'has not set up biometric authentication on their device. It is used on Android.' + ' Maximum 60 characters.'); + +/// Message shown as a title in a dialog which indicates the user +/// has not set up credentials authentication on their device. It is used on Android. +/// Maximum 60 characters. +String get androidDeviceCredentialsRequiredTitle => Intl.message( + 'Device credentials required', + desc: 'Message shown as a title in a dialog which indicates the user ' + 'has not set up credentials authentication on their device. It is used on Android.' + ' Maximum 60 characters.'); + +/// Message advising the user to go to the settings and configure +/// device credentials on their device. It shows in a dialog on Android. +String get androidDeviceCredentialsSetupDescription => Intl.message( + 'Device credentials required', + desc: 'Message advising the user to go to the settings and configure ' + 'device credentials on their device. It shows in a dialog on Android.'); + +/// Message advising the user to go to the settings and configure +/// biometric on their device. It shows in a dialog on Android. +String get androidGoToSettingsDescription => Intl.message( + 'Biometric authentication is not set up on your device. Go to ' + '\'Settings > Security\' to add biometric authentication.', + desc: 'Message advising the user to go to the settings and configure ' + 'biometric on their device. It shows in a dialog on Android.'); diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml new file mode 100644 index 000000000000..e677132205f2 --- /dev/null +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -0,0 +1,32 @@ +name: local_auth_android +description: Android implementation of the local_auth plugin. +repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_android +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0 + +flutter: + plugin: + platforms: + android: + package: io.flutter.plugins.localauth + pluginClass: LocalAuthPlugin + dartPluginClass: LocalAuthAndroid + +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + +dependencies: + flutter: + sdk: flutter + flutter_plugin_android_lifecycle: ^2.0.1 + intl: ^0.17.0 + local_auth_platform_interface: + path: ../local_auth_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^5.0.0 \ No newline at end of file diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart new file mode 100644 index 000000000000..b81884be8051 --- /dev/null +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -0,0 +1,122 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_android/types/auth_strings_android.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('LocalAuth', () { + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth_android', + ); + + final List log = []; + late LocalAuthAndroid localAuthentication; + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = LocalAuthAndroid(); + log.clear(); + }); + + group('With device auth fail over', () { + test('authenticate with no args on Android.', () async { + await localAuthentication.authenticate( + authStrings: const AndroidAuthMessages().args, + localizedReason: 'Needs secure', + biometricOnly: true, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: const AndroidAuthMessages().args, + localizedReason: 'Insecure', + sensitiveTransaction: false, + useErrorDialogs: false, + biometricOnly: true, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': true, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + }); + + group('With biometrics only', () { + test('authenticate with no args on Android.', () async { + await localAuthentication.authenticate( + authStrings: const AndroidAuthMessages().args, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: const AndroidAuthMessages().args, + localizedReason: 'Insecure', + sensitiveTransaction: false, + useErrorDialogs: false, + ); + expect( + log, + [ + isMethodCall('authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }..addAll(const AndroidAuthMessages().args)), + ], + ); + }); + }); + }); +} diff --git a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml b/packages/local_auth/local_auth_platform_interface/analysis_options.yaml deleted file mode 100644 index a5744c1cfbe7..000000000000 --- a/packages/local_auth/local_auth_platform_interface/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart new file mode 100644 index 000000000000..5256f3d6070d --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -0,0 +1,65 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/services.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth'); + +/// The default interface implementation acting as a placeholder for +/// the native implementation to be set. +class DefaultLocalAuthPlatform extends LocalAuthPlatform { + @override + Future authenticate({ + required String localizedReason, + required Map authStrings, + AuthenticationOptions options = const AuthenticationOptions(), + }) async { + assert(localizedReason.isNotEmpty); + final Map args = { + 'localizedReason': localizedReason, + 'useErrorDialogs': options.useErrorDialogs, + 'stickyAuth': options.stickyAuth, + 'sensitiveTransaction': options.sensitiveTransaction, + 'biometricOnly': options.biometricOnly, + }; + args.addAll(authStrings); + return (await _channel.invokeMethod('authenticate', args)) ?? false; + } + + @override + Future> getAvailableBiometrics() async { + final List result = (await _channel.invokeListMethod( + 'getAvailableBiometrics', + )) ?? + []; + final List biometrics = []; + for (final String value in result) { + switch (value) { + case 'face': + biometrics.add(BiometricType.face); + break; + case 'fingerprint': + biometrics.add(BiometricType.fingerprint); + break; + case 'iris': + biometrics.add(BiometricType.iris); + break; + case 'undefined': + break; + } + } + return biometrics; + } + + @override + Future isDeviceSupported() async => + (await _channel.invokeMethod('isDeviceSupported')) ?? false; + + @override + Future stopAuthentication() async => + await _channel.invokeMethod('stopAuthentication') ?? false; +} diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index 833004b7e032..32f039e86063 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -25,8 +27,9 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// Defaults to [DefaultLocalAuthPlatform]. static LocalAuthPlatform get instance => _instance; - /// Platform-specific plugins should set this with their own platform-specific - /// class that extends [LocalAuthPlatform] when they register themselves. + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [LocalAuthPlatform] when they + /// register themselves. static set instance(LocalAuthPlatform instance) { PlatformInterface.verifyToken(instance, _token); _instance = instance; @@ -42,31 +45,10 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// for authentication. This is typically along the lines of: 'Please scan /// 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 - /// fingerprint reader exists on the phone but there's no fingerprint - /// registered, the plugin will attempt to take the user to settings to add - /// one. Anything that is not user fixable, such as no biometric sensor on - /// device, will be returned as a [PlatformException]. - /// - /// [stickyAuth] is used when the application goes into background for any - /// reason while the authentication is in progress. Due to security reasons, - /// the authentication has to be stopped at that time. If stickyAuth is set - /// to true, authentication resumes when the app is resumed. If it is set to - /// false (default), then as soon as app is paused a failure message is sent - /// back to Dart and it is up to the client app to restart authentication or - /// do something else. - /// /// Provide [authStrings] if you want to /// customize messages in the dialogs. /// - /// Setting [sensitiveTransaction] to true enables platform specific - /// precautions. For instance, on face unlock, Android opens a confirmation - /// dialog after the face is recognized to make sure the user meant to unlock - /// their phone. - /// - /// Setting [biometricOnly] to true prevents authenticates from using non-biometric - /// local authentication such as pin, passcode, and passcode. + /// Provide [options] for configuring further authentication related options. /// /// Throws an [PlatformException] if there were technical problems with local /// authentication (e.g. lack of relevant hardware). This might throw @@ -74,11 +56,8 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// simulator. Future authenticate({ required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, required Map authStrings, - bool sensitiveTransaction = true, - bool biometricOnly = false, + AuthenticationOptions options = const AuthenticationOptions(), }) async { throw UnimplementedError('authenticate() has not been implemented.'); } @@ -110,7 +89,3 @@ abstract class LocalAuthPlatform extends PlatformInterface { throw UnimplementedError('stopAuthentication() has not been implemented.'); } } - -/// The default interface implementation acting as a placeholder for -/// the native implementation to be set. -class DefaultLocalAuthPlatform extends LocalAuthPlatform {} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart new file mode 100644 index 000000000000..8a8efc6c2411 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart @@ -0,0 +1,40 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/// Options wrapper for [LocalAuthPlatform.authenticate] parameters. +class AuthenticationOptions { + /// Construct a new instance. + const AuthenticationOptions({ + this.useErrorDialogs = true, + this.stickyAuth = false, + this.sensitiveTransaction = true, + this.biometricOnly = false, + }); + + /// Whether the system will attempt to handle user fixable issues encountered + /// while authenticating. For instance, if fingerprint reader exists on the + /// phone but there's no fingerprint registered, the plugin will attempt to + /// take the user to settings to add one. Anything that is not user fixable, + /// such as no biometric sensor on device, will be returned + /// as a [PlatformException]. + final bool useErrorDialogs; + + /// Used when the application goes into background for any reason while the + /// authentication is in progress. Due to security reasons, the + /// authentication has to be stopped at that time. If stickyAuth is set to + /// true, authentication resumes when the app is resumed. If it is set to + /// false (default), then as soon as app is paused a failure message is sent + /// back to Dart and it is up to the client app to restart authentication or + /// do something else. + final bool stickyAuth; + + /// Whether platform specific precautions are enabled. For instance, on face + /// unlock, Android opens a confirmation dialog after the face is recognized + /// to make sure the user meant to unlock their phone. + final bool sensitiveTransaction; + + /// Prevent authentications from using non-biometric local authentication + /// such as pin, passcode, and passcode. + final bool biometricOnly; +} diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart index 0ad81392edb9..be75ea1fe880 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart @@ -4,7 +4,10 @@ import 'package:intl/intl.dart'; +/// Message shown on a button that the user can click to go to settings pages +/// from the current dialog. It is used on both Android and iOS sides. +/// Maximum 30 characters. String get goToSettings => Intl.message('Go to settings', - desc: 'Message showed on a button that the user can click to go to ' + desc: 'Message shown on a button that the user can click to go to ' 'settings pages from the current dialog. It is used on both Android ' - 'and iOS side. Maximum 30 characters.'); + 'and iOS sides. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index 23556ab37caa..9c7d2eb8d83e 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -2,4 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -enum BiometricType { face, fingerprint, iris } +/// Various types of biometric authentication. +enum BiometricType { + /// Face authentication. + face, + + /// Fingerprint authentication. + fingerprint, + + /// Iris authentication. + iris, + + /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets + /// or exceeds the requirements for Class 3 (formerly Strong), as defined + /// by the Android CDD. Android only. + strong, + + /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets + /// or exceeds the requirements for Class 2 (formerly Weak), as defined + /// by the Android CDD. Android only. + weak, +} diff --git a/packages/local_auth/local_auth_platform_interface/pubspec.yaml b/packages/local_auth/local_auth_platform_interface/pubspec.yaml index 0f88856bf4ee..f04268926ebd 100644 --- a/packages/local_auth/local_auth_platform_interface/pubspec.yaml +++ b/packages/local_auth/local_auth_platform_interface/pubspec.yaml @@ -1,7 +1,7 @@ name: local_auth_platform_interface description: A common platform interface for the local_auth plugin. repository: https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_platform_interface -issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes version: 1.0.0 @@ -13,8 +13,8 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.1.2 intl: ^0.17.0 + plugin_platform_interface: ^2.1.2 dev_dependencies: flutter_test: diff --git a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart new file mode 100644 index 000000000000..d1ee3c504c40 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart @@ -0,0 +1,172 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + const MethodChannel channel = MethodChannel( + 'plugins.flutter.io/local_auth', + ); + + final List log = []; + late LocalAuthPlatform localAuthentication; + + test('getAvailableBiometrics', () async { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value([]); + }); + localAuthentication = DefaultLocalAuthPlatform(); + log.clear(); + await localAuthentication.getAvailableBiometrics(); + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + }); + + group('Boolean returning methods', () { + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) { + log.add(methodCall); + return Future.value(true); + }); + localAuthentication = DefaultLocalAuthPlatform(); + log.clear(); + }); + + test('isDeviceSupported', () async { + await localAuthentication.isDeviceSupported(); + expect( + log, + [ + isMethodCall('isDeviceSupported', arguments: null), + ], + ); + }); + + test('stopAuthentication', () async { + await localAuthentication.stopAuthentication(); + expect( + log, + [ + isMethodCall('stopAuthentication', arguments: null), + ], + ); + }); + + group('authenticate with device auth fail over', () { + test('authenticate with no args.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Needs secure', + options: const AuthenticationOptions(biometricOnly: true), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': true, + }, + ), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Insecure', + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + biometricOnly: true, + ), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': true, + }, + ), + ], + ); + }); + }); + + group('authenticate with biometrics only', () { + test('authenticate with no args.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Needs secure', + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Needs secure', + 'useErrorDialogs': true, + 'stickyAuth': false, + 'sensitiveTransaction': true, + 'biometricOnly': false, + }, + ), + ], + ); + }); + + test('authenticate with no sensitive transaction.', () async { + await localAuthentication.authenticate( + authStrings: {}, + localizedReason: 'Insecure', + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + ), + ); + expect( + log, + [ + isMethodCall( + 'authenticate', + arguments: { + 'localizedReason': 'Insecure', + 'useErrorDialogs': false, + 'stickyAuth': false, + 'sensitiveTransaction': false, + 'biometricOnly': false, + }, + ), + ], + ); + }); + }); + }); +} From 41843c99ed6a8a211d75961985258e4f2f3b55be Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 12:40:23 +0100 Subject: [PATCH 15/53] Adjust to changes in platform interface --- .../local_auth_ios/example/ios/Runner/main.m | 2 +- .../ios/RunnerTests/FLTLocalAuthPluginTests.m | 50 +++++++++---------- .../local_auth_ios/example/lib/main.dart | 14 ++++-- .../local_auth_ios/lib/local_auth_ios.dart | 15 +++--- .../local_auth_ios/test/local_auth_test.dart | 11 ++-- 5 files changed, 49 insertions(+), 43 deletions(-) diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner/main.m b/packages/local_auth/local_auth_ios/example/ios/Runner/main.m index f97b9ef5c8a1..f143297b30d6 100644 --- a/packages/local_auth/local_auth_ios/example/ios/Runner/main.m +++ b/packages/local_auth/local_auth_ios/example/ios/Runner/main.m @@ -6,7 +6,7 @@ #import #import "AppDelegate.h" -int main(int argc, char* argv[]) { +int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } diff --git a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m index 97e78e2f624b..dc409da9f57c 100644 --- a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m +++ b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m @@ -15,7 +15,7 @@ // Private API needed for tests. @interface FLTLocalAuthPlugin (Test) -- (void)setAuthContextOverrides:(NSArray*)authContexts; +- (void)setAuthContextOverrides:(NSArray *)authContexts; @end // Set a long timeout to avoid flake due to slow CI. @@ -31,19 +31,19 @@ - (void)setUp { } - (void)testSuccessfullAuthWithBiometrics { - FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] init]; id mockAuthContext = OCMClassMock([LAContext class]); plugin.authContextOverrides = @[ mockAuthContext ]; const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; - NSString* reason = @"a reason"; + NSString *reason = @"a reason"; OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on // a background thread. - void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { - void (^reply)(BOOL, NSError*); + void (^backgroundThreadReplyCaller)(NSInvocation *) = ^(NSInvocation *invocation) { + void (^reply)(BOOL, NSError *); [invocation getArgument:&reply atIndex:4]; dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ reply(YES, nil); @@ -52,13 +52,13 @@ - (void)testSuccessfullAuthWithBiometrics { OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) .andDo(backgroundThreadReplyCaller); - FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" arguments:@{ @"biometricOnly" : @(YES), @"localizedReason" : reason, }]; - XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; [plugin handleMethodCall:call result:^(id _Nullable result) { XCTAssertTrue([NSThread isMainThread]); @@ -70,19 +70,19 @@ - (void)testSuccessfullAuthWithBiometrics { } - (void)testSuccessfullAuthWithoutBiometrics { - FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] init]; id mockAuthContext = OCMClassMock([LAContext class]); plugin.authContextOverrides = @[ mockAuthContext ]; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; - NSString* reason = @"a reason"; + NSString *reason = @"a reason"; OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on // a background thread. - void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { - void (^reply)(BOOL, NSError*); + void (^backgroundThreadReplyCaller)(NSInvocation *) = ^(NSInvocation *invocation) { + void (^reply)(BOOL, NSError *); [invocation getArgument:&reply atIndex:4]; dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ reply(YES, nil); @@ -91,13 +91,13 @@ - (void)testSuccessfullAuthWithoutBiometrics { OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) .andDo(backgroundThreadReplyCaller); - FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" arguments:@{ @"biometricOnly" : @(NO), @"localizedReason" : reason, }]; - XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; [plugin handleMethodCall:call result:^(id _Nullable result) { XCTAssertTrue([NSThread isMainThread]); @@ -109,19 +109,19 @@ - (void)testSuccessfullAuthWithoutBiometrics { } - (void)testFailedAuthWithBiometrics { - FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] init]; id mockAuthContext = OCMClassMock([LAContext class]); plugin.authContextOverrides = @[ mockAuthContext ]; const LAPolicy policy = LAPolicyDeviceOwnerAuthenticationWithBiometrics; - NSString* reason = @"a reason"; + NSString *reason = @"a reason"; OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on // a background thread. - void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { - void (^reply)(BOOL, NSError*); + void (^backgroundThreadReplyCaller)(NSInvocation *) = ^(NSInvocation *invocation) { + void (^reply)(BOOL, NSError *); [invocation getArgument:&reply atIndex:4]; dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ reply(NO, [NSError errorWithDomain:@"error" code:99 userInfo:nil]); @@ -130,13 +130,13 @@ - (void)testFailedAuthWithBiometrics { OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) .andDo(backgroundThreadReplyCaller); - FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" arguments:@{ @"biometricOnly" : @(YES), @"localizedReason" : reason, }]; - XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; [plugin handleMethodCall:call result:^(id _Nullable result) { XCTAssertTrue([NSThread isMainThread]); @@ -148,19 +148,19 @@ - (void)testFailedAuthWithBiometrics { } - (void)testFailedAuthWithoutBiometrics { - FLTLocalAuthPlugin* plugin = [[FLTLocalAuthPlugin alloc] init]; + FLTLocalAuthPlugin *plugin = [[FLTLocalAuthPlugin alloc] init]; id mockAuthContext = OCMClassMock([LAContext class]); plugin.authContextOverrides = @[ mockAuthContext ]; const LAPolicy policy = LAPolicyDeviceOwnerAuthentication; - NSString* reason = @"a reason"; + NSString *reason = @"a reason"; OCMStub([mockAuthContext canEvaluatePolicy:policy error:[OCMArg setTo:nil]]).andReturn(YES); // evaluatePolicy:localizedReason:reply: calls back on an internal queue, which is not // guaranteed to be on the main thread. Ensure that's handled correctly by calling back on // a background thread. - void (^backgroundThreadReplyCaller)(NSInvocation*) = ^(NSInvocation* invocation) { - void (^reply)(BOOL, NSError*); + void (^backgroundThreadReplyCaller)(NSInvocation *) = ^(NSInvocation *invocation) { + void (^reply)(BOOL, NSError *); [invocation getArgument:&reply atIndex:4]; dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ reply(NO, [NSError errorWithDomain:@"error" code:99 userInfo:nil]); @@ -169,13 +169,13 @@ - (void)testFailedAuthWithoutBiometrics { OCMStub([mockAuthContext evaluatePolicy:policy localizedReason:reason reply:[OCMArg any]]) .andDo(backgroundThreadReplyCaller); - FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" + FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"authenticate" arguments:@{ @"biometricOnly" : @(NO), @"localizedReason" : reason, }]; - XCTestExpectation* expectation = [self expectationWithDescription:@"Result is called"]; + XCTestExpectation *expectation = [self expectationWithDescription:@"Result is called"]; [plugin handleMethodCall:call result:^(id _Nullable result) { XCTAssertTrue([NSThread isMainThread]); diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart index 3dc87811ee70..7ac36a2e5d78 100644 --- a/packages/local_auth/local_auth_ios/example/lib/main.dart +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -82,8 +82,10 @@ class _MyAppState extends State { authenticated = await auth.authenticate( localizedReason: 'Let OS determine authentication method', authStrings: const IOSAuthMessages().args, - useErrorDialogs: true, - stickyAuth: true, + options: const AuthenticationOptions( + useErrorDialogs: true, + stickyAuth: true, + ), ); setState(() { _isAuthenticating = false; @@ -115,9 +117,11 @@ class _MyAppState extends State { localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', authStrings: const IOSAuthMessages().args, - useErrorDialogs: true, - stickyAuth: true, - biometricOnly: true, + options: const AuthenticationOptions( + useErrorDialogs: true, + stickyAuth: true, + biometricOnly: true, + ), ); setState(() { _isAuthenticating = false; diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart index 979107d09679..5293e06c58fc 100644 --- a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -4,8 +4,10 @@ import 'package:flutter/services.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; +export 'package:local_auth_platform_interface/types/auth_options.dart'; export 'package:local_auth_platform_interface/types/biometric_type.dart'; const MethodChannel _channel = @@ -21,19 +23,16 @@ class LocalAuthIOS extends LocalAuthPlatform { @override Future authenticate({ required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, required Map authStrings, - bool sensitiveTransaction = true, - bool biometricOnly = false, + AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); final Map args = { 'localizedReason': localizedReason, - 'useErrorDialogs': useErrorDialogs, - 'stickyAuth': stickyAuth, - 'sensitiveTransaction': sensitiveTransaction, - 'biometricOnly': biometricOnly, + 'useErrorDialogs': options.useErrorDialogs, + 'stickyAuth': options.stickyAuth, + 'sensitiveTransaction': options.sensitiveTransaction, + 'biometricOnly': options.biometricOnly, }; args.addAll(authStrings); return (await _channel.invokeMethod('authenticate', args)) ?? false; diff --git a/packages/local_auth/local_auth_ios/test/local_auth_test.dart b/packages/local_auth/local_auth_ios/test/local_auth_test.dart index 316e3644a933..f6e7354e6672 100644 --- a/packages/local_auth/local_auth_ios/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_ios/test/local_auth_test.dart @@ -8,6 +8,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth_ios/local_auth_ios.dart'; import 'package:local_auth_ios/types/auth_strings_ios.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -34,7 +35,7 @@ void main() { await localAuthentication.authenticate( authStrings: const IOSAuthMessages().args, localizedReason: 'Needs secure', - biometricOnly: true, + options: const AuthenticationOptions(biometricOnly: true), ); expect( log, @@ -56,7 +57,7 @@ void main() { localAuthentication.authenticate( authStrings: const IOSAuthMessages().args, localizedReason: '', - biometricOnly: true, + options: const AuthenticationOptions(biometricOnly: true), ), throwsAssertionError, ); @@ -88,8 +89,10 @@ void main() { await localAuthentication.authenticate( authStrings: const IOSAuthMessages().args, localizedReason: 'Insecure', - sensitiveTransaction: false, - useErrorDialogs: false, + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + ), ); expect( log, From af311ccc6a5c5ccf87125bdb35827fa437f610ab Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 12:49:28 +0100 Subject: [PATCH 16/53] Adjust to changes in platform interface --- .../local_auth_android/example/lib/main.dart | 20 ++++++++++++------- .../lib/local_auth_android.dart | 15 +++++++------- .../test/local_auth_test.dart | 16 +++++++++------ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart index 4328f28136c2..d94b4ed894c9 100644 --- a/packages/local_auth/local_auth_android/example/lib/main.dart +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -80,10 +80,13 @@ class _MyAppState extends State { _authorized = 'Authenticating'; }); authenticated = await auth.authenticate( - localizedReason: 'Let OS determine authentication method', - authStrings: const AndroidAuthMessages().args, + localizedReason: 'Let OS determine authentication method', + authStrings: const AndroidAuthMessages().args, + options: const AuthenticationOptions( useErrorDialogs: true, - stickyAuth: true); + stickyAuth: true, + ), + ); setState(() { _isAuthenticating = false; }); @@ -111,12 +114,15 @@ class _MyAppState extends State { _authorized = 'Authenticating'; }); authenticated = await auth.authenticate( - localizedReason: - 'Scan your fingerprint (or face or whatever) to authenticate', - authStrings: const AndroidAuthMessages().args, + localizedReason: + 'Scan your fingerprint (or face or whatever) to authenticate', + authStrings: const AndroidAuthMessages().args, + options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, - biometricOnly: true); + biometricOnly: true, + ), + ); setState(() { _isAuthenticating = false; _authorized = 'Authenticating'; diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index 0f82e7cf9158..1869506035f1 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -4,8 +4,10 @@ import 'package:flutter/services.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; +export 'package:local_auth_platform_interface/types/auth_options.dart'; export 'package:local_auth_platform_interface/types/biometric_type.dart'; const MethodChannel _channel = @@ -21,19 +23,16 @@ class LocalAuthAndroid extends LocalAuthPlatform { @override Future authenticate({ required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, required Map authStrings, - bool sensitiveTransaction = true, - bool biometricOnly = false, + AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); final Map args = { 'localizedReason': localizedReason, - 'useErrorDialogs': useErrorDialogs, - 'stickyAuth': stickyAuth, - 'sensitiveTransaction': sensitiveTransaction, - 'biometricOnly': biometricOnly, + 'useErrorDialogs': options.useErrorDialogs, + 'stickyAuth': options.stickyAuth, + 'sensitiveTransaction': options.sensitiveTransaction, + 'biometricOnly': options.biometricOnly, }; args.addAll(authStrings); return (await _channel.invokeMethod('authenticate', args)) ?? false; diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart index b81884be8051..33be63657dee 100644 --- a/packages/local_auth/local_auth_android/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -34,7 +34,7 @@ void main() { await localAuthentication.authenticate( authStrings: const AndroidAuthMessages().args, localizedReason: 'Needs secure', - biometricOnly: true, + options: const AuthenticationOptions(biometricOnly: true), ); expect( log, @@ -55,9 +55,11 @@ void main() { await localAuthentication.authenticate( authStrings: const AndroidAuthMessages().args, localizedReason: 'Insecure', - sensitiveTransaction: false, - useErrorDialogs: false, - biometricOnly: true, + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + biometricOnly: true, + ), ); expect( log, @@ -100,8 +102,10 @@ void main() { await localAuthentication.authenticate( authStrings: const AndroidAuthMessages().args, localizedReason: 'Insecure', - sensitiveTransaction: false, - useErrorDialogs: false, + options: const AuthenticationOptions( + sensitiveTransaction: false, + useErrorDialogs: false, + ), ); expect( log, From 4266130323bbcc31917b4f8d0448dc872bdf9f46 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 12:53:31 +0100 Subject: [PATCH 17/53] Added missing implements field in pubspec --- packages/local_auth/local_auth_android/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index e677132205f2..6b6157bfa68b 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -8,6 +8,7 @@ version: 1.0.0 flutter: plugin: + implements: local_auth platforms: android: package: io.flutter.plugins.localauth From ddf0ba43aba3521e19d0a6860f3599b59d303f67 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 27 Jan 2022 12:54:19 +0100 Subject: [PATCH 18/53] Added missing implements field in pubspec --- packages/local_auth/local_auth_ios/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/local_auth/local_auth_ios/pubspec.yaml b/packages/local_auth/local_auth_ios/pubspec.yaml index 60f3aa977d5f..da15559111c1 100644 --- a/packages/local_auth/local_auth_ios/pubspec.yaml +++ b/packages/local_auth/local_auth_ios/pubspec.yaml @@ -8,6 +8,7 @@ version: 1.0.0 flutter: plugin: + implements: local_auth platforms: ios: pluginClass: FLTLocalAuthPlugin From 24765b28c105ff667637214e37e3b13e7220e34d Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 31 Jan 2022 09:42:15 +0100 Subject: [PATCH 19/53] Update doc in default method channel platform --- .../lib/default_method_channel_platform.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart index 5256f3d6070d..1a44fcf2a5ac 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -11,6 +11,11 @@ const MethodChannel _channel = MethodChannel('plugins.flutter.io/local_auth'); /// The default interface implementation acting as a placeholder for /// the native implementation to be set. +/// +/// This implementation is not used by any of the implementations in this +/// repository, and exists only for backward compatibility with any +/// clients that were relying on internal details of the method channel +/// in the pre-federated plugin. class DefaultLocalAuthPlatform extends LocalAuthPlatform { @override Future authenticate({ From 81ba7e84a15f9daab268e844de21a5de0c97bfb8 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 31 Jan 2022 15:09:45 +0100 Subject: [PATCH 20/53] Implement PR feedback --- .../lib/default_method_channel_platform.dart | 5 ++++ .../lib/local_auth_platform_interface.dart | 23 +++++++++++-------- .../lib/types/auth_options.dart | 16 ++++++------- .../lib/types/auth_strings.dart | 2 +- .../lib/types/biometric_type.dart | 14 ++++++----- .../default_method_channel_platform_test.dart | 7 ++++++ 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart index 1a44fcf2a5ac..866ae44828e5 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -60,6 +60,11 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { return biometrics; } + @override + Future canCheckBiometrics() async { + return (await getAvailableBiometrics()).isNotEmpty; + } + @override Future isDeviceSupported() async => (await _channel.invokeMethod('isDeviceSupported')) ?? false; diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index 32f039e86063..ad363601ee85 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -38,8 +38,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// Authenticates the user with biometrics available on the device while also /// allowing the user to use device authentication - pin, pattern, passcode. /// - /// Returns a [Future] holding true, if the user successfully authenticated, - /// false otherwise. + /// Returns true if the user successfully authenticated, false otherwise. /// /// [localizedReason] is the message to show to user while prompting them /// for authentication. This is typically along the lines of: 'Please scan @@ -50,7 +49,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// /// Provide [options] for configuring further authentication related options. /// - /// Throws an [PlatformException] if there were technical problems with local + /// Throws a [PlatformException] if there were technical problems with local /// authentication (e.g. lack of relevant hardware). This might throw /// [PlatformException] with error code [otherOperatingSystem] on the iOS /// simulator. @@ -62,12 +61,19 @@ abstract class LocalAuthPlatform extends PlatformInterface { throw UnimplementedError('authenticate() has not been implemented.'); } + /// Returns true if the device is capable of checking biometrics. + Future canCheckBiometrics() async { + throw UnimplementedError('canCheckBiometrics() has not been implemented.'); + } + /// Returns a list of enrolled biometrics. /// - /// Returns a [Future] List with the following possibilities: + /// Possible values include: /// - BiometricType.face /// - BiometricType.fingerprint /// - BiometricType.iris (not yet implemented) + /// - BiometricType.strong + /// - BiometricType.weak Future> getAvailableBiometrics() async { throw UnimplementedError( 'getAvailableBiometrics() has not been implemented.'); @@ -75,16 +81,15 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// Returns true if device is capable of checking biometrics or is able to /// fail over to device credentials. - /// - /// Returns a [Future] bool true or false: Future isDeviceSupported() async { throw UnimplementedError('isDeviceSupported() has not been implemented.'); } - /// Returns true if auth was cancelled successfully. - /// Returns false if there was some error or no auth in progress. + /// Cancels any authentication currently in progress. /// - /// Returns [Future] bool true or false: + /// Returns true if auth was cancelled successfully. + /// Returns false if there was no authentication in progress, + /// or an error occurred. Future stopAuthentication() async { throw UnimplementedError('stopAuthentication() has not been implemented.'); } diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart index 8a8efc6c2411..f858126dcb63 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart @@ -4,7 +4,7 @@ /// Options wrapper for [LocalAuthPlatform.authenticate] parameters. class AuthenticationOptions { - /// Construct a new instance. + /// Constructs a new instance. const AuthenticationOptions({ this.useErrorDialogs = true, this.stickyAuth = false, @@ -12,12 +12,12 @@ class AuthenticationOptions { this.biometricOnly = false, }); - /// Whether the system will attempt to handle user fixable issues encountered - /// while authenticating. For instance, if fingerprint reader exists on the - /// phone but there's no fingerprint registered, the plugin will attempt to + /// Whether the system will attempt to handle user-fixable issues encountered + /// while authenticating. For instance, if a fingerprint reader exists on the + /// device but there's no fingerprint registered, the plugin might attempt to /// take the user to settings to add one. Anything that is not user fixable, - /// such as no biometric sensor on device, will be returned - /// as a [PlatformException]. + /// such as no biometric sensor on device, will still result in + /// a [PlatformException]. final bool useErrorDialogs; /// Used when the application goes into background for any reason while the @@ -31,10 +31,10 @@ class AuthenticationOptions { /// Whether platform specific precautions are enabled. For instance, on face /// unlock, Android opens a confirmation dialog after the face is recognized - /// to make sure the user meant to unlock their phone. + /// to make sure the user meant to unlock their device. final bool sensitiveTransaction; /// Prevent authentications from using non-biometric local authentication - /// such as pin, passcode, and passcode. + /// such as pin, passcode, or pattern. final bool biometricOnly; } diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart index be75ea1fe880..d1604cb9df1c 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart @@ -5,7 +5,7 @@ import 'package:intl/intl.dart'; /// Message shown on a button that the user can click to go to settings pages -/// from the current dialog. It is used on both Android and iOS sides. +/// from the current dialog. It is used on applicable platforms. /// Maximum 30 characters. String get goToSettings => Intl.message('Go to settings', desc: 'Message shown on a button that the user can click to go to ' diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index 9c7d2eb8d83e..c4efd0deb3cb 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -3,6 +3,8 @@ // found in the LICENSE file. /// Various types of biometric authentication. +/// Some platforms report specific biometric types, while others report only +/// classifications like strong and weak. enum BiometricType { /// Face authentication. face, @@ -13,13 +15,13 @@ enum BiometricType { /// Iris authentication. iris, - /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets - /// or exceeds the requirements for Class 3 (formerly Strong), as defined - /// by the Android CDD. Android only. + /// Any biometric (e.g. fingerprint, iris, or face) on the device that the + /// platform API considers to be strong. For example, on Android this + /// corresponds to Class 3. strong, - /// Any biometric (e.g. fingerprint, iris, or face) on the device that meets - /// or exceeds the requirements for Class 2 (formerly Weak), as defined - /// by the Android CDD. Android only. + /// Any biometric (e.g. fingerprint, iris, or face) on the device that the + /// platform API considers to be strong. For example, on Android this + /// corresponds to Class 2. weak, } diff --git a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart index d1ee3c504c40..64d8aa0284af 100644 --- a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart +++ b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart @@ -21,6 +21,13 @@ void main() { final List log = []; late LocalAuthPlatform localAuthentication; + test( + 'DefaultLocalAuthPlatform is registered as the default platform implementation', + () async { + expect(LocalAuthPlatform.instance, + const TypeMatcher()); + }); + test('getAvailableBiometrics', () async { channel.setMockMethodCallHandler((MethodCall methodCall) { log.add(methodCall); From 8633ca936d969fb5c1b93b5f54bd77c0de8a99c9 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 09:44:57 +0100 Subject: [PATCH 21/53] Move string to iOS package Move string to iOS package --- .../local_auth_ios/lib/types/auth_strings_ios.dart | 8 +++++++- .../lib/types/auth_strings.dart | 13 ------------- 2 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart index 9147cf32c117..64e12bd27d24 100644 --- a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:intl/intl.dart'; -import 'package:local_auth_platform_interface/types/auth_strings.dart'; /// iOS side authentication messages. /// @@ -50,6 +49,13 @@ class IOSAuthMessages { // Strings for local_authentication plugin. Currently supports English. // Intl.message must be string literals. +/// Message shown on a button that the user can click to go to settings pages +/// from the current dialog. Maximum 30 characters. +String get goToSettings => Intl.message('Go to settings', + desc: 'Message shown on a button that the user can click to go to ' + 'settings pages from the current dialog. It is used on both Android ' + 'and iOS sides. Maximum 30 characters.'); + /// Message advising the user to re-enable biometrics on their device. /// It shows in a dialog on iOS. String get iOSLockOut => Intl.message( diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart deleted file mode 100644 index d1604cb9df1c..000000000000 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:intl/intl.dart'; - -/// Message shown on a button that the user can click to go to settings pages -/// from the current dialog. It is used on applicable platforms. -/// Maximum 30 characters. -String get goToSettings => Intl.message('Go to settings', - desc: 'Message shown on a button that the user can click to go to ' - 'settings pages from the current dialog. It is used on both Android ' - 'and iOS sides. Maximum 30 characters.'); From a371a8701b67e64bbd221c16db19aaa7a1b3a7ca Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 09:46:52 +0100 Subject: [PATCH 22/53] Move string to Android package --- .../lib/types/auth_strings_android.dart | 8 +++++++- .../lib/types/auth_strings.dart | 13 ------------- 2 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart diff --git a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart index 9d9886ce7168..303bec38b36f 100644 --- a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart +++ b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:intl/intl.dart'; -import 'package:local_auth_platform_interface/types/auth_strings.dart'; /// Android side authentication messages. /// @@ -92,6 +91,13 @@ class AndroidAuthMessages { // Strings for local_authentication plugin. Currently supports English. // Intl.message must be string literals. +/// Message shown on a button that the user can click to go to settings pages +/// from the current dialog. Maximum 30 characters. +String get goToSettings => Intl.message('Go to settings', + desc: 'Message shown on a button that the user can click to go to ' + 'settings pages from the current dialog. It is used on both Android ' + 'and iOS sides. Maximum 30 characters.'); + /// Hint message advising the user how to authenticate with biometrics. It is /// used on Android. Maximum 60 characters. String get androidBiometricHint => Intl.message('Verify identity', diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart deleted file mode 100644 index d1604cb9df1c..000000000000 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:intl/intl.dart'; - -/// Message shown on a button that the user can click to go to settings pages -/// from the current dialog. It is used on applicable platforms. -/// Maximum 30 characters. -String get goToSettings => Intl.message('Go to settings', - desc: 'Message shown on a button that the user can click to go to ' - 'settings pages from the current dialog. It is used on both Android ' - 'and iOS sides. Maximum 30 characters.'); From c4086e8dfd5c848f29c5325dbb9b94671cb6e03b Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 09:47:33 +0100 Subject: [PATCH 23/53] Remove auth strings from platform interface --- .../lib/types/auth_strings.dart | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart deleted file mode 100644 index d1604cb9df1c..000000000000 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_strings.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:intl/intl.dart'; - -/// Message shown on a button that the user can click to go to settings pages -/// from the current dialog. It is used on applicable platforms. -/// Maximum 30 characters. -String get goToSettings => Intl.message('Go to settings', - desc: 'Message shown on a button that the user can click to go to ' - 'settings pages from the current dialog. It is used on both Android ' - 'and iOS sides. Maximum 30 characters.'); From 475fd89ed95fd681bf9531902afb106a9c9496ab Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 10:04:42 +0100 Subject: [PATCH 24/53] Change interface for handing platform specific messages --- .../lib/default_method_channel_platform.dart | 7 +++++-- .../lib/local_auth_platform_interface.dart | 5 +++-- .../lib/types/auth_messages.dart | 9 +++++++++ .../test/default_method_channel_platform_test.dart | 9 +++++---- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart index 866ae44828e5..64a4414a966c 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; @@ -20,7 +21,7 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { @override Future authenticate({ required String localizedReason, - required Map authStrings, + required Iterable authMessages, AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); @@ -31,7 +32,9 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { 'sensitiveTransaction': options.sensitiveTransaction, 'biometricOnly': options.biometricOnly, }; - args.addAll(authStrings); + for (final AuthMessages messages in authMessages) { + args.addAll(messages.messageMap); + } return (await _channel.invokeMethod('authenticate', args)) ?? false; } diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index ad363601ee85..824725837794 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -44,7 +45,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// for authentication. This is typically along the lines of: 'Please scan /// your finger to access MyApp.'. This must not be empty. /// - /// Provide [authStrings] if you want to + /// Provide [authMessages] if you want to /// customize messages in the dialogs. /// /// Provide [options] for configuring further authentication related options. @@ -55,7 +56,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// simulator. Future authenticate({ required String localizedReason, - required Map authStrings, + required Iterable authMessages, AuthenticationOptions options = const AuthenticationOptions(), }) async { throw UnimplementedError('authenticate() has not been implemented.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart new file mode 100644 index 000000000000..058319ecdf4a --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -0,0 +1,9 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/// Abstract class for storing platform specific strings. +abstract class AuthMessages { + /// Returns all platform specific messages as a map. + Map get messageMap; +} diff --git a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart index 64d8aa0284af..d3a7bda7effc 100644 --- a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart +++ b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart @@ -8,6 +8,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; @@ -77,7 +78,7 @@ void main() { group('authenticate with device auth fail over', () { test('authenticate with no args.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Needs secure', options: const AuthenticationOptions(biometricOnly: true), ); @@ -100,7 +101,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, @@ -129,7 +130,7 @@ void main() { group('authenticate with biometrics only', () { test('authenticate with no args.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Needs secure', ); expect( @@ -151,7 +152,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, From 37cf40fbf48d83e11add8a83f8f24b069bd88087 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 10:22:40 +0100 Subject: [PATCH 25/53] Implement platform interface changes --- .../local_auth_ios/example/lib/main.dart | 5 ++--- .../local_auth_ios/lib/local_auth_ios.dart | 9 +++++++-- ...h_strings_ios.dart => auth_messages_ios.dart} | 16 +++++++--------- .../lib/default_method_channel_platform.dart | 2 +- .../lib/types/auth_messages.dart | 6 +++++- 5 files changed, 22 insertions(+), 16 deletions(-) rename packages/local_auth/local_auth_ios/lib/types/{auth_strings_ios.dart => auth_messages_ios.dart} (87%) diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart index 7ac36a2e5d78..95dfe31a4a98 100644 --- a/packages/local_auth/local_auth_ios/example/lib/main.dart +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -9,7 +9,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:local_auth_ios/local_auth_ios.dart'; -import 'package:local_auth_ios/types/auth_strings_ios.dart'; void main() { runApp(MyApp()); @@ -81,7 +80,7 @@ class _MyAppState extends State { }); authenticated = await auth.authenticate( localizedReason: 'Let OS determine authentication method', - authStrings: const IOSAuthMessages().args, + authMessages: [const IOSAuthMessages()], options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, @@ -116,7 +115,7 @@ class _MyAppState extends State { authenticated = await auth.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', - authStrings: const IOSAuthMessages().args, + authMessages: [const IOSAuthMessages()], options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart index 5293e06c58fc..8a1384b8af06 100644 --- a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -4,9 +4,12 @@ import 'package:flutter/services.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; +export 'package:local_auth_ios/types/auth_messages_ios.dart'; +export 'package:local_auth_platform_interface/types/auth_messages.dart'; export 'package:local_auth_platform_interface/types/auth_options.dart'; export 'package:local_auth_platform_interface/types/biometric_type.dart'; @@ -23,7 +26,7 @@ class LocalAuthIOS extends LocalAuthPlatform { @override Future authenticate({ required String localizedReason, - required Map authStrings, + required Iterable authMessages, AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); @@ -34,7 +37,9 @@ class LocalAuthIOS extends LocalAuthPlatform { 'sensitiveTransaction': options.sensitiveTransaction, 'biometricOnly': options.biometricOnly, }; - args.addAll(authStrings); + for (final AuthMessages messages in authMessages) { + args.addAll(messages.args); + } return (await _channel.invokeMethod('authenticate', args)) ?? false; } diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart similarity index 87% rename from packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart rename to packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart index 64e12bd27d24..a212d07c44d9 100644 --- a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart @@ -3,11 +3,11 @@ // found in the LICENSE file. import 'package:intl/intl.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; -/// iOS side authentication messages. -/// +/// Class wrapping all authentication messages needed on iOS. /// Provides default values for all messages. -class IOSAuthMessages { +class IOSAuthMessages extends AuthMessages { /// Constructs a new instance. const IOSAuthMessages({ this.lockOut, @@ -34,13 +34,13 @@ class IOSAuthMessages { /// Maximum 30 characters. final String? cancelButton; - /// Gets the messaged stored in this class instance as a string map. + @override Map get args { return { 'lockOut': lockOut ?? iOSLockOut, 'goToSetting': goToSettingsButton ?? goToSettings, 'goToSettingDescriptionIOS': - goToSettingsDescription ?? iOSGoToSettingsDescription, + goToSettingsDescription ?? iOSGoToSettingsDescription, 'okButton': cancelButton ?? iOSOkButton, }; } @@ -61,8 +61,7 @@ String get goToSettings => Intl.message('Go to settings', String get iOSLockOut => Intl.message( 'Biometric authentication is disabled. Please lock and unlock your screen to ' 'enable it.', - desc: - 'Message advising the user to re-enable biometrics on their device. It ' + desc: 'Message advising the user to re-enable biometrics on their device. It ' 'shows in a dialog on the iOS.'); /// Message advising the user to go to the settings and configure Biometrics @@ -70,8 +69,7 @@ String get iOSLockOut => Intl.message( String get iOSGoToSettingsDescription => Intl.message( 'Biometric authentication is not set up on your device. Please either enable ' 'Touch ID or Face ID on your phone.', - desc: - 'Message advising the user to go to the settings and configure Biometrics ' + desc: 'Message advising the user to go to the settings and configure Biometrics ' 'for their device. It shows in a dialog on iOS.'); /// Message shown on a button that the user can click to leave the current diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart index 64a4414a966c..b239f2368b83 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -33,7 +33,7 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { 'biometricOnly': options.biometricOnly, }; for (final AuthMessages messages in authMessages) { - args.addAll(messages.messageMap); + args.addAll(messages.args); } return (await _channel.invokeMethod('authenticate', args)) ?? false; } diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart index 058319ecdf4a..a08cf10325e5 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -4,6 +4,10 @@ /// Abstract class for storing platform specific strings. abstract class AuthMessages { + + /// Constructs an instance of [AuthMessages]. + const AuthMessages(); + /// Returns all platform specific messages as a map. - Map get messageMap; + Map get args; } From c0a867efb44ae9961498d63e9fabcf49f5121aaf Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 10:23:27 +0100 Subject: [PATCH 26/53] Change interface for handing platform specific messages Change interface for handling platform specific messages --- .../lib/default_method_channel_platform.dart | 7 +++++-- .../lib/local_auth_platform_interface.dart | 5 +++-- .../lib/types/auth_messages.dart | 13 +++++++++++++ .../test/default_method_channel_platform_test.dart | 9 +++++---- 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart index 866ae44828e5..b239f2368b83 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; @@ -20,7 +21,7 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { @override Future authenticate({ required String localizedReason, - required Map authStrings, + required Iterable authMessages, AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); @@ -31,7 +32,9 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { 'sensitiveTransaction': options.sensitiveTransaction, 'biometricOnly': options.biometricOnly, }; - args.addAll(authStrings); + for (final AuthMessages messages in authMessages) { + args.addAll(messages.args); + } return (await _channel.invokeMethod('authenticate', args)) ?? false; } diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index ad363601ee85..824725837794 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -44,7 +45,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// for authentication. This is typically along the lines of: 'Please scan /// your finger to access MyApp.'. This must not be empty. /// - /// Provide [authStrings] if you want to + /// Provide [authMessages] if you want to /// customize messages in the dialogs. /// /// Provide [options] for configuring further authentication related options. @@ -55,7 +56,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// simulator. Future authenticate({ required String localizedReason, - required Map authStrings, + required Iterable authMessages, AuthenticationOptions options = const AuthenticationOptions(), }) async { throw UnimplementedError('authenticate() has not been implemented.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart new file mode 100644 index 000000000000..a08cf10325e5 --- /dev/null +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -0,0 +1,13 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/// Abstract class for storing platform specific strings. +abstract class AuthMessages { + + /// Constructs an instance of [AuthMessages]. + const AuthMessages(); + + /// Returns all platform specific messages as a map. + Map get args; +} diff --git a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart index 64d8aa0284af..d3a7bda7effc 100644 --- a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart +++ b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart @@ -8,6 +8,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth_platform_interface/default_method_channel_platform.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; @@ -77,7 +78,7 @@ void main() { group('authenticate with device auth fail over', () { test('authenticate with no args.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Needs secure', options: const AuthenticationOptions(biometricOnly: true), ); @@ -100,7 +101,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, @@ -129,7 +130,7 @@ void main() { group('authenticate with biometrics only', () { test('authenticate with no args.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Needs secure', ); expect( @@ -151,7 +152,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: {}, + authMessages: [], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, From 939d3b3ac93d66d06483044ca1ee0726e7ae0724 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 10:32:30 +0100 Subject: [PATCH 27/53] Implement platform interface changes --- .../local_auth_android/example/lib/main.dart | 5 ++--- .../local_auth_android/lib/local_auth_android.dart | 9 +++++++-- ...strings_android.dart => auth_messages_android.dart} | 5 +++-- .../local_auth_android/test/local_auth_test.dart | 10 +++++----- .../lib/types/auth_messages.dart | 1 - 5 files changed, 17 insertions(+), 13 deletions(-) rename packages/local_auth/local_auth_android/lib/types/{auth_strings_android.dart => auth_messages_android.dart} (98%) diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart index d94b4ed894c9..a5de6c09c763 100644 --- a/packages/local_auth/local_auth_android/example/lib/main.dart +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -9,7 +9,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:local_auth_android/local_auth_android.dart'; -import 'package:local_auth_android/types/auth_strings_android.dart'; void main() { runApp(MyApp()); @@ -81,7 +80,7 @@ class _MyAppState extends State { }); authenticated = await auth.authenticate( localizedReason: 'Let OS determine authentication method', - authStrings: const AndroidAuthMessages().args, + authMessages: [const AndroidAuthMessages()], options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, @@ -116,7 +115,7 @@ class _MyAppState extends State { authenticated = await auth.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', - authStrings: const AndroidAuthMessages().args, + authMessages: [const AndroidAuthMessages()], options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index 1869506035f1..57ac9b04180f 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -4,9 +4,12 @@ import 'package:flutter/services.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; +export 'package:local_auth_android/types/auth_messages_android.dart'; +export 'package:local_auth_platform_interface/types/auth_messages.dart'; export 'package:local_auth_platform_interface/types/auth_options.dart'; export 'package:local_auth_platform_interface/types/biometric_type.dart'; @@ -23,7 +26,7 @@ class LocalAuthAndroid extends LocalAuthPlatform { @override Future authenticate({ required String localizedReason, - required Map authStrings, + required Iterable authMessages, AuthenticationOptions options = const AuthenticationOptions(), }) async { assert(localizedReason.isNotEmpty); @@ -34,7 +37,9 @@ class LocalAuthAndroid extends LocalAuthPlatform { 'sensitiveTransaction': options.sensitiveTransaction, 'biometricOnly': options.biometricOnly, }; - args.addAll(authStrings); + for (final AuthMessages messages in authMessages) { + args.addAll(messages.args); + } return (await _channel.invokeMethod('authenticate', args)) ?? false; } diff --git a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart similarity index 98% rename from packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart rename to packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart index 303bec38b36f..db8e75da9f2b 100644 --- a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart +++ b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart @@ -3,11 +3,12 @@ // found in the LICENSE file. import 'package:intl/intl.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; /// Android side authentication messages. /// /// Provides default values for all messages. -class AndroidAuthMessages { +class AndroidAuthMessages extends AuthMessages { /// Constructs a new instance. const AndroidAuthMessages({ this.biometricHint, @@ -66,7 +67,7 @@ class AndroidAuthMessages { /// Android. Maximum 60 characters. final String? signInTitle; - /// Gets the messaged stored in this class instance as a string map. + @override Map get args { return { 'biometricHint': biometricHint ?? androidBiometricHint, diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart index 33be63657dee..c4a462507a69 100644 --- a/packages/local_auth/local_auth_android/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -7,7 +7,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth_android/local_auth_android.dart'; -import 'package:local_auth_android/types/auth_strings_android.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -32,7 +32,7 @@ void main() { group('With device auth fail over', () { test('authenticate with no args on Android.', () async { await localAuthentication.authenticate( - authStrings: const AndroidAuthMessages().args, + authMessages: [const AndroidAuthMessages()], localizedReason: 'Needs secure', options: const AuthenticationOptions(biometricOnly: true), ); @@ -53,7 +53,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: const AndroidAuthMessages().args, + authMessages: [const AndroidAuthMessages()], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, @@ -80,7 +80,7 @@ void main() { group('With biometrics only', () { test('authenticate with no args on Android.', () async { await localAuthentication.authenticate( - authStrings: const AndroidAuthMessages().args, + authMessages: [const AndroidAuthMessages()], localizedReason: 'Needs secure', ); expect( @@ -100,7 +100,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: const AndroidAuthMessages().args, + authMessages: [const AndroidAuthMessages()], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart index a08cf10325e5..978d2d066421 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -4,7 +4,6 @@ /// Abstract class for storing platform specific strings. abstract class AuthMessages { - /// Constructs an instance of [AuthMessages]. const AuthMessages(); From 6c7d7b6ba41da8202ab36bf3cde12b144e6fbb11 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 10:54:56 +0100 Subject: [PATCH 28/53] Fix unit test --- .../local_auth/local_auth_ios/test/local_auth_test.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/local_auth/local_auth_ios/test/local_auth_test.dart b/packages/local_auth/local_auth_ios/test/local_auth_test.dart index f6e7354e6672..1d5a76aaa459 100644 --- a/packages/local_auth/local_auth_ios/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_ios/test/local_auth_test.dart @@ -7,7 +7,6 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth_ios/local_auth_ios.dart'; -import 'package:local_auth_ios/types/auth_strings_ios.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; void main() { @@ -33,7 +32,7 @@ void main() { group('With device auth fail over', () { test('authenticate with no args on iOS.', () async { await localAuthentication.authenticate( - authStrings: const IOSAuthMessages().args, + authMessages: [const IOSAuthMessages()], localizedReason: 'Needs secure', options: const AuthenticationOptions(biometricOnly: true), ); @@ -55,7 +54,7 @@ void main() { test('authenticate with no localizedReason on iOS.', () async { await expectLater( localAuthentication.authenticate( - authStrings: const IOSAuthMessages().args, + authMessages: [const IOSAuthMessages()], localizedReason: '', options: const AuthenticationOptions(biometricOnly: true), ), @@ -67,7 +66,7 @@ void main() { group('With biometrics only', () { test('authenticate with no args on iOS.', () async { await localAuthentication.authenticate( - authStrings: const IOSAuthMessages().args, + authMessages: [const IOSAuthMessages()], localizedReason: 'Needs secure', ); expect( @@ -87,7 +86,7 @@ void main() { test('authenticate with no sensitive transaction.', () async { await localAuthentication.authenticate( - authStrings: const IOSAuthMessages().args, + authMessages: [const IOSAuthMessages()], localizedReason: 'Insecure', options: const AuthenticationOptions( sensitiveTransaction: false, From 25bb0ca782de676e4b89db4c8dadda86235564e9 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:39:53 +0100 Subject: [PATCH 29/53] Add equality for IOSAuthMessages --- .../lib/types/auth_messages_ios.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart index a212d07c44d9..a647184fd4d6 100644 --- a/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import 'package:local_auth_platform_interface/types/auth_messages.dart'; /// Class wrapping all authentication messages needed on iOS. /// Provides default values for all messages. +@immutable class IOSAuthMessages extends AuthMessages { /// Constructs a new instance. const IOSAuthMessages({ @@ -44,6 +46,20 @@ class IOSAuthMessages extends AuthMessages { 'okButton': cancelButton ?? iOSOkButton, }; } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is IOSAuthMessages && + runtimeType == other.runtimeType && + lockOut == other.lockOut && + goToSettingsButton == other.goToSettingsButton && + goToSettingsDescription == other.goToSettingsDescription && + cancelButton == other.cancelButton; + + @override + int get hashCode => + lockOut.hashCode ^ goToSettingsButton.hashCode ^ goToSettingsDescription.hashCode ^ cancelButton.hashCode; } // Strings for local_authentication plugin. Currently supports English. From 61bd127aea353b08cd56bb8261229f0b39227804 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:40:23 +0100 Subject: [PATCH 30/53] Add equality for AndroidAuthMessages --- .../lib/types/auth_messages_android.dart | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart index db8e75da9f2b..44286a308ea8 100644 --- a/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart +++ b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import 'package:local_auth_platform_interface/types/auth_messages.dart'; /// Android side authentication messages. /// /// Provides default values for all messages. +@immutable class AndroidAuthMessages extends AuthMessages { /// Constructs a new instance. const AndroidAuthMessages({ @@ -77,16 +79,43 @@ class AndroidAuthMessages extends AuthMessages { 'biometricRequired': biometricRequiredTitle ?? androidBiometricRequiredTitle, 'cancelButton': cancelButton ?? androidCancelButton, - 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? - androidDeviceCredentialsRequiredTitle, - 'deviceCredentialsSetupDescription': deviceCredentialsSetupDescription ?? - androidDeviceCredentialsSetupDescription, + 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? androidDeviceCredentialsRequiredTitle, + 'deviceCredentialsSetupDescription': + deviceCredentialsSetupDescription ?? androidDeviceCredentialsSetupDescription, 'goToSetting': goToSettingsButton ?? goToSettings, - 'goToSettingDescription': - goToSettingsDescription ?? androidGoToSettingsDescription, + 'goToSettingDescription': goToSettingsDescription ?? androidGoToSettingsDescription, 'signInTitle': signInTitle ?? androidSignInTitle, }; } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is AndroidAuthMessages && + runtimeType == other.runtimeType && + biometricHint == other.biometricHint && + biometricNotRecognized == other.biometricNotRecognized && + biometricRequiredTitle == other.biometricRequiredTitle && + biometricSuccess == other.biometricSuccess && + cancelButton == other.cancelButton && + deviceCredentialsRequiredTitle == other.deviceCredentialsRequiredTitle && + deviceCredentialsSetupDescription == other.deviceCredentialsSetupDescription && + goToSettingsButton == other.goToSettingsButton && + goToSettingsDescription == other.goToSettingsDescription && + signInTitle == other.signInTitle; + + @override + int get hashCode => + biometricHint.hashCode ^ + biometricNotRecognized.hashCode ^ + biometricRequiredTitle.hashCode ^ + biometricSuccess.hashCode ^ + cancelButton.hashCode ^ + deviceCredentialsRequiredTitle.hashCode ^ + deviceCredentialsSetupDescription.hashCode ^ + goToSettingsButton.hashCode ^ + goToSettingsDescription.hashCode ^ + signInTitle.hashCode; } // Strings for local_authentication plugin. Currently supports English. From 083689fd2ad44b1c73ecfd7031f36bf9502a8974 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:43:17 +0100 Subject: [PATCH 31/53] Add equality for AuthenticationOptions --- .../lib/types/auth_messages.dart | 1 - .../lib/types/auth_options.dart | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart index a08cf10325e5..978d2d066421 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -4,7 +4,6 @@ /// Abstract class for storing platform specific strings. abstract class AuthMessages { - /// Constructs an instance of [AuthMessages]. const AuthMessages(); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart index f858126dcb63..c4b646c0b97a 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_options.dart @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; + /// Options wrapper for [LocalAuthPlatform.authenticate] parameters. +@immutable class AuthenticationOptions { /// Constructs a new instance. const AuthenticationOptions({ @@ -37,4 +40,21 @@ class AuthenticationOptions { /// Prevent authentications from using non-biometric local authentication /// such as pin, passcode, or pattern. final bool biometricOnly; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is AuthenticationOptions && + runtimeType == other.runtimeType && + useErrorDialogs == other.useErrorDialogs && + stickyAuth == other.stickyAuth && + sensitiveTransaction == other.sensitiveTransaction && + biometricOnly == other.biometricOnly; + + @override + int get hashCode => + useErrorDialogs.hashCode ^ + stickyAuth.hashCode ^ + sensitiveTransaction.hashCode ^ + biometricOnly.hashCode; } From bed6110a76fb2d08ccf28fb72919f52d2b7c106b Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:44:35 +0100 Subject: [PATCH 32/53] Fix unit tests --- .../local_auth/example/lib/main.dart | 19 ++- .../local_auth/local_auth/lib/local_auth.dart | 15 +- .../local_auth/lib/src/local_auth.dart | 58 +++++-- .../local_auth/test/local_auth_test.dart | 60 +++---- .../lib/types/auth_strings_android.dart | 159 ------------------ .../lib/types/auth_strings_ios.dart | 76 --------- .../lib/types/auth_messages.dart | 2 + 7 files changed, 94 insertions(+), 295 deletions(-) delete mode 100644 packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart delete mode 100644 packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart diff --git a/packages/local_auth/local_auth/example/lib/main.dart b/packages/local_auth/local_auth/example/lib/main.dart index a9604b3411b7..a0427fa3da11 100644 --- a/packages/local_auth/local_auth/example/lib/main.dart +++ b/packages/local_auth/local_auth/example/lib/main.dart @@ -78,10 +78,13 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.authenticate( - localizedReason: 'Let OS determine authentication method', + authenticated = await auth.requestAuthentication( + localizedReason: 'Let OS determine authentication method', + options: const AuthenticationOptions( useErrorDialogs: true, - stickyAuth: true); + stickyAuth: true, + ), + ); setState(() { _isAuthenticating = false; }); @@ -108,12 +111,14 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.authenticate( - localizedReason: - 'Scan your fingerprint (or face or whatever) to authenticate', + authenticated = await auth.requestAuthentication( + localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', + options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, - biometricOnly: true); + biometricOnly: true, + ), + ); setState(() { _isAuthenticating = false; _authorized = 'Authenticating'; diff --git a/packages/local_auth/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart index 696cc1b35a11..df1bf5129f73 100644 --- a/packages/local_auth/local_auth/lib/local_auth.dart +++ b/packages/local_auth/local_auth/lib/local_auth.dart @@ -1,3 +1,14 @@ export 'package:local_auth/src/local_auth.dart' show LocalAuthentication; -export 'package:local_auth_platform_interface/types/biometric_type.dart' - show BiometricType; + +// TODO(BeMacized): This should be removed the next time a breaking change +// occurs and LocalAuth#authenticate is removed. Packages will be expected +// to depend on the platform specific packages directly if they wish to use +// these classes. +export 'package:local_auth_android/types/auth_messages_android.dart' show AndroidAuthMessages; +// TODO(BeMacized): This should be removed the next time a breaking change +// occurs and LocalAuth#authenticate is removed. Packages will be expected +// to depend on the platform specific packages directly if they wish to use +// these classes. +export 'package:local_auth_ios/types/auth_messages_ios.dart' show IOSAuthMessages; +export 'package:local_auth_platform_interface/types/auth_options.dart' show AuthenticationOptions; +export 'package:local_auth_platform_interface/types/biometric_type.dart' show BiometricType; diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart index b6bba9ebeaab..53e99beeac7d 100644 --- a/packages/local_auth/local_auth/lib/src/local_auth.dart +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -13,9 +13,10 @@ import 'dart:async'; import 'package:flutter/foundation.dart' show visibleForTesting; import 'package:flutter/services.dart'; import 'package:local_auth/src/types/error_codes.dart'; -import 'package:local_auth_android/types/auth_strings_android.dart'; -import 'package:local_auth_ios/types/auth_strings_ios.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_ios/local_auth_ios.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:platform/platform.dart'; @@ -29,8 +30,9 @@ void setMockPathProviderPlatform(Platform platform) { /// A Flutter plugin for authenticating the user identity locally. class LocalAuthentication { /// The `authenticateWithBiometrics` method has been deprecated. - /// Use `authenticate` with `biometricOnly: true` instead - @Deprecated('Use `authenticate` with `biometricOnly: true` instead') + /// Use `requestAuthentication` with `biometricOnly: true` on the + /// `options` parameter instead. + @Deprecated('Use `requestAuthentication` with `biometricOnly: true` on the `options` parameter instead') Future authenticateWithBiometrics({ required String localizedReason, bool useErrorDialogs = true, @@ -52,8 +54,7 @@ class LocalAuthentication { /// Authenticates the user with biometrics available on the device while also /// allowing the user to use device authentication - pin, pattern, passcode. /// - /// Returns a [Future] holding true, if the user successfully authenticated, - /// false otherwise. + /// Returns true, if the user successfully authenticated, false otherwise. /// /// [localizedReason] is the message to show to user while prompting them /// for authentication. This is typically along the lines of: 'Please scan @@ -89,6 +90,7 @@ class LocalAuthentication { /// authentication (e.g. lack of relevant hardware). This might throw /// [PlatformException] with error code [otherOperatingSystem] on the iOS /// simulator. + @Deprecated('Use `requestAuthentication` instead.') Future authenticate({ required String localizedReason, bool useErrorDialogs = true, @@ -100,13 +102,43 @@ class LocalAuthentication { }) { return LocalAuthPlatform.instance.authenticate( localizedReason: localizedReason, - useErrorDialogs: useErrorDialogs, - stickyAuth: stickyAuth, - authStrings: {} - ..addAll(androidAuthStrings.args) - ..addAll(iOSAuthStrings.args), - sensitiveTransaction: sensitiveTransaction, - biometricOnly: biometricOnly, + authMessages: [iOSAuthStrings, androidAuthStrings], + options: AuthenticationOptions( + useErrorDialogs: useErrorDialogs, + stickyAuth: stickyAuth, + sensitiveTransaction: sensitiveTransaction, + biometricOnly: biometricOnly, + ), + ); + } + + /// Authenticates the user with biometrics available on the device while also + /// allowing the user to use device authentication - pin, pattern, passcode. + /// + /// Returns true if the user successfully authenticated, false otherwise. + /// + /// [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.'. This must not be empty. + /// + /// Provide [authMessages] if you want to + /// customize messages in the dialogs. + /// + /// Provide [options] for configuring further authentication related options. + /// + /// Throws a [PlatformException] if there were technical problems with local + /// authentication (e.g. lack of relevant hardware). This might throw + /// [PlatformException] with error code [otherOperatingSystem] on the iOS + /// simulator. + Future requestAuthentication({ + required String localizedReason, + Iterable authMessages = const [IOSAuthMessages(), AndroidAuthMessages()], + AuthenticationOptions options = const AuthenticationOptions() + }) { + return LocalAuthPlatform.instance.authenticate( + localizedReason: localizedReason, + authMessages: authMessages, + options: options, ); } diff --git a/packages/local_auth/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart index c0a0a5a4881b..d8b11bf00de2 100644 --- a/packages/local_auth/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/local_auth/test/local_auth_test.dart @@ -6,9 +6,8 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth/local_auth.dart'; import 'package:local_auth/src/local_auth.dart'; -import 'package:local_auth_android/types/auth_strings_android.dart'; -import 'package:local_auth_ios/types/auth_strings_ios.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -27,45 +26,35 @@ void main() { test('authenticateWithBiometrics calls platform implementation', () { when(mockLocalAuthPlatform.authenticate( localizedReason: anyNamed('localizedReason'), - authStrings: anyNamed('authStrings'), - useErrorDialogs: anyNamed('useErrorDialogs'), - stickyAuth: anyNamed('stickyAuth'), - sensitiveTransaction: anyNamed('sensitiveTransaction'), - biometricOnly: anyNamed('biometricOnly'), + authMessages: anyNamed('authMessages'), + options: anyNamed('options'), )).thenAnswer((_) async => true); localAuthentication.authenticateWithBiometrics( localizedReason: 'Test Reason'); verify(mockLocalAuthPlatform.authenticate( localizedReason: 'Test Reason', - authStrings: {} - ..addAll(const AndroidAuthMessages().args) - ..addAll(const IOSAuthMessages().args), - useErrorDialogs: true, - stickyAuth: false, - sensitiveTransaction: true, - biometricOnly: true, + authMessages: [ + const IOSAuthMessages(), + const AndroidAuthMessages(), + ], + options: const AuthenticationOptions(biometricOnly: true), )).called(1); }); test('authenticate calls platform implementation', () { when(mockLocalAuthPlatform.authenticate( localizedReason: anyNamed('localizedReason'), - authStrings: anyNamed('authStrings'), - useErrorDialogs: anyNamed('useErrorDialogs'), - stickyAuth: anyNamed('stickyAuth'), - sensitiveTransaction: anyNamed('sensitiveTransaction'), - biometricOnly: anyNamed('biometricOnly'), + authMessages: anyNamed('authMessages'), + options: anyNamed('options'), )).thenAnswer((_) async => true); localAuthentication.authenticate(localizedReason: 'Test Reason'); verify(mockLocalAuthPlatform.authenticate( localizedReason: 'Test Reason', - authStrings: {} - ..addAll(const AndroidAuthMessages().args) - ..addAll(const IOSAuthMessages().args), - useErrorDialogs: true, - stickyAuth: false, - sensitiveTransaction: true, - biometricOnly: false, + authMessages: [ + const IOSAuthMessages(), + const AndroidAuthMessages(), + ], + options: const AuthenticationOptions(), )).called(1); }); @@ -119,21 +108,16 @@ class MockLocalAuthPlatform extends Mock } @override - Future authenticate( - {String? localizedReason, - bool? useErrorDialogs = true, - bool? stickyAuth = false, - Map? authStrings, - bool? sensitiveTransaction = true, - bool? biometricOnly = false}) => + Future authenticate({ + String? localizedReason, + Iterable? authMessages = const [IOSAuthMessages(), AndroidAuthMessages()], + AuthenticationOptions? options = const AuthenticationOptions(), + }) => super.noSuchMethod( Invocation.method(#authenticate, [], { #localizedReason: localizedReason, - #useErrorDialogs: useErrorDialogs, - #stickyAuth: stickyAuth, - #authStrings: authStrings, - #sensitiveTransaction: sensitiveTransaction, - #biometricOnly: biometricOnly + #authMessages: authMessages, + #options: options, }), returnValue: Future.value(false)) as Future; diff --git a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart deleted file mode 100644 index 9d9886ce7168..000000000000 --- a/packages/local_auth/local_auth_android/lib/types/auth_strings_android.dart +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:intl/intl.dart'; -import 'package:local_auth_platform_interface/types/auth_strings.dart'; - -/// Android side authentication messages. -/// -/// Provides default values for all messages. -class AndroidAuthMessages { - /// Constructs a new instance. - const AndroidAuthMessages({ - this.biometricHint, - this.biometricNotRecognized, - this.biometricRequiredTitle, - this.biometricSuccess, - this.cancelButton, - this.deviceCredentialsRequiredTitle, - this.deviceCredentialsSetupDescription, - this.goToSettingsButton, - this.goToSettingsDescription, - this.signInTitle, - }); - - /// Hint message advising the user how to authenticate with biometrics. It is - /// used on Android. Maximum 60 characters. - final String? biometricHint; - - /// Message to let the user know that authentication was failed. It is used - /// on Android. Maximum 60 characters.' - final String? biometricNotRecognized; - - /// Message shown as a title in a dialog which indicates the user - /// has not set up biometric authentication on their device. It is used on - /// Android. Maximum 60 characters. - final String? biometricRequiredTitle; - - /// Message to let the user know that authentication was successful. It - /// is used on Android. Maximum 60 characters - final String? biometricSuccess; - - /// Message shown on a button that the user can click to leave the - /// current dialog. It is used on Android. Maximum 30 characters. - final String? cancelButton; - - /// Message shown as a title in a dialog which indicates the user - /// has not set up credentials authentication on their device. It is used on Android. - /// Maximum 60 characters. - final String? deviceCredentialsRequiredTitle; - - /// Message advising the user to go to the settings and configure - /// device credentials on their device. It shows in a dialog on Android. - final String? deviceCredentialsSetupDescription; - - /// Message shown on a button that the user can click to go to settings pages - /// from the current dialog. It is used on both Android and iOS sides. - /// Maximum 30 characters. - final String? goToSettingsButton; - - /// Message advising the user to go to the settings and configure - /// biometric on their device. It shows in a dialog on Android. - final String? goToSettingsDescription; - - /// Message shown as a title in a dialog which indicates the user - /// that they need to scan biometric to continue. It is used on - /// Android. Maximum 60 characters. - final String? signInTitle; - - /// Gets the messaged stored in this class instance as a string map. - Map get args { - return { - 'biometricHint': biometricHint ?? androidBiometricHint, - 'biometricNotRecognized': - biometricNotRecognized ?? androidBiometricNotRecognized, - 'biometricSuccess': biometricSuccess ?? androidBiometricSuccess, - 'biometricRequired': - biometricRequiredTitle ?? androidBiometricRequiredTitle, - 'cancelButton': cancelButton ?? androidCancelButton, - 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? - androidDeviceCredentialsRequiredTitle, - 'deviceCredentialsSetupDescription': deviceCredentialsSetupDescription ?? - androidDeviceCredentialsSetupDescription, - 'goToSetting': goToSettingsButton ?? goToSettings, - 'goToSettingDescription': - goToSettingsDescription ?? androidGoToSettingsDescription, - 'signInTitle': signInTitle ?? androidSignInTitle, - }; - } -} - -// Strings for local_authentication plugin. Currently supports English. -// Intl.message must be string literals. - -/// Hint message advising the user how to authenticate with biometrics. It is -/// used on Android. Maximum 60 characters. -String get androidBiometricHint => Intl.message('Verify identity', - desc: - 'Hint message advising the user how to authenticate with biometrics. It is ' - 'used on Android. Maximum 60 characters.'); - -/// Message to let the user know that authentication was failed. It is used -/// on Android. Maximum 60 characters.' -String get androidBiometricNotRecognized => - Intl.message('Not recognized. Try again.', - desc: 'Message to let the user know that authentication was failed. It ' - 'is used on Android. Maximum 60 characters.'); - -/// Message to let the user know that authentication was successful. It -/// is used on Android. Maximum 60 characters -String get androidBiometricSuccess => Intl.message('Success', - desc: 'Message to let the user know that authentication was successful. It ' - 'is used on Android. Maximum 60 characters.'); - -/// Message shown on a button that the user can click to leave the -/// current dialog. It is used on Android. Maximum 30 characters. -String get androidCancelButton => Intl.message('Cancel', - desc: 'Message shown on a button that the user can click to leave the ' - 'current dialog. It is used on Android. Maximum 30 characters.'); - -/// Message shown as a title in a dialog which indicates the user -/// that they need to scan biometric to continue. It is used on -/// Android. Maximum 60 characters. -String get androidSignInTitle => Intl.message('Authentication required', - desc: 'Message shown as a title in a dialog which indicates the user ' - 'that they need to scan biometric to continue. It is used on ' - 'Android. Maximum 60 characters.'); - -/// Message shown as a title in a dialog which indicates the user -/// has not set up biometric authentication on their device. It is used on -/// Android. Maximum 60 characters. -String get androidBiometricRequiredTitle => Intl.message('Biometric required', - desc: 'Message shown as a title in a dialog which indicates the user ' - 'has not set up biometric authentication on their device. It is used on Android.' - ' Maximum 60 characters.'); - -/// Message shown as a title in a dialog which indicates the user -/// has not set up credentials authentication on their device. It is used on Android. -/// Maximum 60 characters. -String get androidDeviceCredentialsRequiredTitle => Intl.message( - 'Device credentials required', - desc: 'Message shown as a title in a dialog which indicates the user ' - 'has not set up credentials authentication on their device. It is used on Android.' - ' Maximum 60 characters.'); - -/// Message advising the user to go to the settings and configure -/// device credentials on their device. It shows in a dialog on Android. -String get androidDeviceCredentialsSetupDescription => Intl.message( - 'Device credentials required', - desc: 'Message advising the user to go to the settings and configure ' - 'device credentials on their device. It shows in a dialog on Android.'); - -/// Message advising the user to go to the settings and configure -/// biometric on their device. It shows in a dialog on Android. -String get androidGoToSettingsDescription => Intl.message( - 'Biometric authentication is not set up on your device. Go to ' - '\'Settings > Security\' to add biometric authentication.', - desc: 'Message advising the user to go to the settings and configure ' - 'biometric on their device. It shows in a dialog on Android.'); diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart deleted file mode 100644 index 9147cf32c117..000000000000 --- a/packages/local_auth/local_auth_ios/lib/types/auth_strings_ios.dart +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:intl/intl.dart'; -import 'package:local_auth_platform_interface/types/auth_strings.dart'; - -/// iOS side authentication messages. -/// -/// Provides default values for all messages. -class IOSAuthMessages { - /// Constructs a new instance. - const IOSAuthMessages({ - this.lockOut, - this.goToSettingsButton, - this.goToSettingsDescription, - this.cancelButton, - }); - - /// Message advising the user to re-enable biometrics on their device. - /// It shows in a dialog on iOS. - final String? lockOut; - - /// Message shown on a button that the user can click to go to settings pages - /// from the current dialog. It is used on both Android and iOS sides. - /// Maximum 30 characters. - final String? goToSettingsButton; - - /// Message advising the user to go to the settings and configure Biometrics - /// for their device. It shows in a dialog on iOS. - final String? goToSettingsDescription; - - /// Message shown on a button that the user can click to leave the current - /// dialog. It is used on iOS. - /// Maximum 30 characters. - final String? cancelButton; - - /// Gets the messaged stored in this class instance as a string map. - Map get args { - return { - 'lockOut': lockOut ?? iOSLockOut, - 'goToSetting': goToSettingsButton ?? goToSettings, - 'goToSettingDescriptionIOS': - goToSettingsDescription ?? iOSGoToSettingsDescription, - 'okButton': cancelButton ?? iOSOkButton, - }; - } -} - -// Strings for local_authentication plugin. Currently supports English. -// Intl.message must be string literals. - -/// Message advising the user to re-enable biometrics on their device. -/// It shows in a dialog on iOS. -String get iOSLockOut => Intl.message( - 'Biometric authentication is disabled. Please lock and unlock your screen to ' - 'enable it.', - desc: - 'Message advising the user to re-enable biometrics on their device. It ' - 'shows in a dialog on the iOS.'); - -/// Message advising the user to go to the settings and configure Biometrics -/// for their device. It shows in a dialog on iOS. -String get iOSGoToSettingsDescription => Intl.message( - 'Biometric authentication is not set up on your device. Please either enable ' - 'Touch ID or Face ID on your phone.', - desc: - 'Message advising the user to go to the settings and configure Biometrics ' - 'for their device. It shows in a dialog on iOS.'); - -/// Message shown on a button that the user can click to leave the current -/// dialog. It is used on iOS. -/// Maximum 30 characters. -String get iOSOkButton => Intl.message('OK', - desc: 'Message showed on a button that the user can click to leave the ' - 'current dialog. It is used on iOS side. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart index 978d2d066421..fea046cb0431 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -9,4 +9,6 @@ abstract class AuthMessages { /// Returns all platform specific messages as a map. Map get args; + + } From ae3480095e9b0a5cf682596d4ce3f7866f9c317f Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:44:59 +0100 Subject: [PATCH 33/53] Format --- .../lib/types/auth_messages_android.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart index 44286a308ea8..efc15d248942 100644 --- a/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart +++ b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart @@ -79,11 +79,13 @@ class AndroidAuthMessages extends AuthMessages { 'biometricRequired': biometricRequiredTitle ?? androidBiometricRequiredTitle, 'cancelButton': cancelButton ?? androidCancelButton, - 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? androidDeviceCredentialsRequiredTitle, - 'deviceCredentialsSetupDescription': - deviceCredentialsSetupDescription ?? androidDeviceCredentialsSetupDescription, + 'deviceCredentialsRequired': deviceCredentialsRequiredTitle ?? + androidDeviceCredentialsRequiredTitle, + 'deviceCredentialsSetupDescription': deviceCredentialsSetupDescription ?? + androidDeviceCredentialsSetupDescription, 'goToSetting': goToSettingsButton ?? goToSettings, - 'goToSettingDescription': goToSettingsDescription ?? androidGoToSettingsDescription, + 'goToSettingDescription': + goToSettingsDescription ?? androidGoToSettingsDescription, 'signInTitle': signInTitle ?? androidSignInTitle, }; } @@ -98,8 +100,10 @@ class AndroidAuthMessages extends AuthMessages { biometricRequiredTitle == other.biometricRequiredTitle && biometricSuccess == other.biometricSuccess && cancelButton == other.cancelButton && - deviceCredentialsRequiredTitle == other.deviceCredentialsRequiredTitle && - deviceCredentialsSetupDescription == other.deviceCredentialsSetupDescription && + deviceCredentialsRequiredTitle == + other.deviceCredentialsRequiredTitle && + deviceCredentialsSetupDescription == + other.deviceCredentialsSetupDescription && goToSettingsButton == other.goToSettingsButton && goToSettingsDescription == other.goToSettingsDescription && signInTitle == other.signInTitle; From f1cd43d928a0e01c1748bf07d6027e80abad05be Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:45:20 +0100 Subject: [PATCH 34/53] Format --- .../local_auth_ios/lib/types/auth_messages_ios.dart | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart index a647184fd4d6..2cf6b586a1bb 100644 --- a/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart @@ -42,7 +42,7 @@ class IOSAuthMessages extends AuthMessages { 'lockOut': lockOut ?? iOSLockOut, 'goToSetting': goToSettingsButton ?? goToSettings, 'goToSettingDescriptionIOS': - goToSettingsDescription ?? iOSGoToSettingsDescription, + goToSettingsDescription ?? iOSGoToSettingsDescription, 'okButton': cancelButton ?? iOSOkButton, }; } @@ -59,7 +59,10 @@ class IOSAuthMessages extends AuthMessages { @override int get hashCode => - lockOut.hashCode ^ goToSettingsButton.hashCode ^ goToSettingsDescription.hashCode ^ cancelButton.hashCode; + lockOut.hashCode ^ + goToSettingsButton.hashCode ^ + goToSettingsDescription.hashCode ^ + cancelButton.hashCode; } // Strings for local_authentication plugin. Currently supports English. @@ -77,7 +80,8 @@ String get goToSettings => Intl.message('Go to settings', String get iOSLockOut => Intl.message( 'Biometric authentication is disabled. Please lock and unlock your screen to ' 'enable it.', - desc: 'Message advising the user to re-enable biometrics on their device. It ' + desc: + 'Message advising the user to re-enable biometrics on their device. It ' 'shows in a dialog on the iOS.'); /// Message advising the user to go to the settings and configure Biometrics @@ -85,7 +89,8 @@ String get iOSLockOut => Intl.message( String get iOSGoToSettingsDescription => Intl.message( 'Biometric authentication is not set up on your device. Please either enable ' 'Touch ID or Face ID on your phone.', - desc: 'Message advising the user to go to the settings and configure Biometrics ' + desc: + 'Message advising the user to go to the settings and configure Biometrics ' 'for their device. It shows in a dialog on iOS.'); /// Message shown on a button that the user can click to leave the current From bf2004049056b25d62ae701352845bb5611c75ab Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 14:54:06 +0100 Subject: [PATCH 35/53] Add unit test for requestAuthentication. Refactored now deprecated methods to make use of new method. --- .../local_auth/example/lib/main.dart | 3 +- .../local_auth/local_auth/lib/local_auth.dart | 12 ++++--- .../local_auth/lib/src/local_auth.dart | 32 +++++++++++-------- .../local_auth/test/local_auth_test.dart | 22 ++++++++++++- .../lib/types/auth_messages.dart | 2 -- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/packages/local_auth/local_auth/example/lib/main.dart b/packages/local_auth/local_auth/example/lib/main.dart index a0427fa3da11..786f54a09564 100644 --- a/packages/local_auth/local_auth/example/lib/main.dart +++ b/packages/local_auth/local_auth/example/lib/main.dart @@ -112,7 +112,8 @@ class _MyAppState extends State { _authorized = 'Authenticating'; }); authenticated = await auth.requestAuthentication( - localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', + localizedReason: + 'Scan your fingerprint (or face or whatever) to authenticate', options: const AuthenticationOptions( useErrorDialogs: true, stickyAuth: true, diff --git a/packages/local_auth/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart index df1bf5129f73..57afe935b49b 100644 --- a/packages/local_auth/local_auth/lib/local_auth.dart +++ b/packages/local_auth/local_auth/lib/local_auth.dart @@ -4,11 +4,15 @@ export 'package:local_auth/src/local_auth.dart' show LocalAuthentication; // occurs and LocalAuth#authenticate is removed. Packages will be expected // to depend on the platform specific packages directly if they wish to use // these classes. -export 'package:local_auth_android/types/auth_messages_android.dart' show AndroidAuthMessages; +export 'package:local_auth_android/types/auth_messages_android.dart' + show AndroidAuthMessages; // TODO(BeMacized): This should be removed the next time a breaking change // occurs and LocalAuth#authenticate is removed. Packages will be expected // to depend on the platform specific packages directly if they wish to use // these classes. -export 'package:local_auth_ios/types/auth_messages_ios.dart' show IOSAuthMessages; -export 'package:local_auth_platform_interface/types/auth_options.dart' show AuthenticationOptions; -export 'package:local_auth_platform_interface/types/biometric_type.dart' show BiometricType; +export 'package:local_auth_ios/types/auth_messages_ios.dart' + show IOSAuthMessages; +export 'package:local_auth_platform_interface/types/auth_options.dart' + show AuthenticationOptions; +export 'package:local_auth_platform_interface/types/biometric_type.dart' + show BiometricType; diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart index 53e99beeac7d..85fb21199969 100644 --- a/packages/local_auth/local_auth/lib/src/local_auth.dart +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -32,7 +32,8 @@ class LocalAuthentication { /// The `authenticateWithBiometrics` method has been deprecated. /// Use `requestAuthentication` with `biometricOnly: true` on the /// `options` parameter instead. - @Deprecated('Use `requestAuthentication` with `biometricOnly: true` on the `options` parameter instead') + @Deprecated( + 'Use `requestAuthentication` with `biometricOnly: true` on the `options` parameter instead') Future authenticateWithBiometrics({ required String localizedReason, bool useErrorDialogs = true, @@ -41,14 +42,15 @@ class LocalAuthentication { IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), bool sensitiveTransaction = true, }) => - authenticate( + requestAuthentication( localizedReason: localizedReason, - useErrorDialogs: useErrorDialogs, - stickyAuth: stickyAuth, - androidAuthStrings: androidAuthStrings, - iOSAuthStrings: iOSAuthStrings, - sensitiveTransaction: sensitiveTransaction, - biometricOnly: true, + authMessages: [iOSAuthStrings, androidAuthStrings], + options: AuthenticationOptions( + useErrorDialogs: useErrorDialogs, + stickyAuth: stickyAuth, + sensitiveTransaction: sensitiveTransaction, + biometricOnly: true, + ), ); /// Authenticates the user with biometrics available on the device while also @@ -100,7 +102,7 @@ class LocalAuthentication { bool sensitiveTransaction = true, bool biometricOnly = false, }) { - return LocalAuthPlatform.instance.authenticate( + return requestAuthentication( localizedReason: localizedReason, authMessages: [iOSAuthStrings, androidAuthStrings], options: AuthenticationOptions( @@ -130,11 +132,13 @@ class LocalAuthentication { /// authentication (e.g. lack of relevant hardware). This might throw /// [PlatformException] with error code [otherOperatingSystem] on the iOS /// simulator. - Future requestAuthentication({ - required String localizedReason, - Iterable authMessages = const [IOSAuthMessages(), AndroidAuthMessages()], - AuthenticationOptions options = const AuthenticationOptions() - }) { + Future requestAuthentication( + {required String localizedReason, + Iterable authMessages = const [ + IOSAuthMessages(), + AndroidAuthMessages() + ], + AuthenticationOptions options = const AuthenticationOptions()}) { return LocalAuthPlatform.instance.authenticate( localizedReason: localizedReason, authMessages: authMessages, diff --git a/packages/local_auth/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart index d8b11bf00de2..69c7ce8fe7ff 100644 --- a/packages/local_auth/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/local_auth/test/local_auth_test.dart @@ -58,6 +58,23 @@ void main() { )).called(1); }); + test('requestAuthentication calls platform implementation', () { + when(mockLocalAuthPlatform.authenticate( + localizedReason: anyNamed('localizedReason'), + authMessages: anyNamed('authMessages'), + options: anyNamed('options'), + )).thenAnswer((_) async => true); + localAuthentication.requestAuthentication(localizedReason: 'Test Reason'); + verify(mockLocalAuthPlatform.authenticate( + localizedReason: 'Test Reason', + authMessages: [ + const IOSAuthMessages(), + const AndroidAuthMessages(), + ], + options: const AuthenticationOptions(), + )).called(1); + }); + test('isDeviceSupported calls platform implementation', () { when(mockLocalAuthPlatform.isDeviceSupported()) .thenAnswer((_) async => true); @@ -110,7 +127,10 @@ class MockLocalAuthPlatform extends Mock @override Future authenticate({ String? localizedReason, - Iterable? authMessages = const [IOSAuthMessages(), AndroidAuthMessages()], + Iterable? authMessages = const [ + IOSAuthMessages(), + AndroidAuthMessages() + ], AuthenticationOptions? options = const AuthenticationOptions(), }) => super.noSuchMethod( diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart index fea046cb0431..978d2d066421 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -9,6 +9,4 @@ abstract class AuthMessages { /// Returns all platform specific messages as a map. Map get args; - - } From 7c943232251a955aba7170e19512acfd68bc69d6 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 16:00:43 +0100 Subject: [PATCH 36/53] Add current implementation for canCheckBiometrics --- packages/local_auth/local_auth_ios/lib/local_auth_ios.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart index 8a1384b8af06..2124cc2a0a8c 100644 --- a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -43,6 +43,11 @@ class LocalAuthIOS extends LocalAuthPlatform { return (await _channel.invokeMethod('authenticate', args)) ?? false; } + @override + Future canCheckBiometrics() async { + return (await getAvailableBiometrics()).isNotEmpty; + } + @override Future> getAvailableBiometrics() async { final List result = (await _channel.invokeListMethod( From 3b1915b31b0452b6b3b8a19b13dff88a794e6705 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 7 Feb 2022 16:01:14 +0100 Subject: [PATCH 37/53] Add current implementation for canCheckBiometrics --- .../local_auth_android/lib/local_auth_android.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index 57ac9b04180f..fb70fff8c6ad 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -43,6 +43,11 @@ class LocalAuthAndroid extends LocalAuthPlatform { return (await _channel.invokeMethod('authenticate', args)) ?? false; } + @override + Future canCheckBiometrics() async { + return (await getAvailableBiometrics()).isNotEmpty; + } + @override Future> getAvailableBiometrics() async { final List result = (await _channel.invokeListMethod( From 92ec8bc287bd9c2744dbd8101a98f26b251fa5db Mon Sep 17 00:00:00 2001 From: Bodhi Mulders Date: Fri, 11 Feb 2022 09:36:25 +0100 Subject: [PATCH 38/53] Process PR feedback --- .../lib/default_method_channel_platform.dart | 6 +++--- .../lib/local_auth_platform_interface.dart | 6 ++++-- .../lib/types/auth_messages.dart | 2 +- .../lib/types/biometric_type.dart | 2 +- .../test/default_method_channel_platform_test.dart | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart index b239f2368b83..c68a3bfb8371 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/default_method_channel_platform.dart @@ -39,7 +39,7 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { } @override - Future> getAvailableBiometrics() async { + Future> getEnrolledBiometrics() async { final List result = (await _channel.invokeListMethod( 'getAvailableBiometrics', )) ?? @@ -64,8 +64,8 @@ class DefaultLocalAuthPlatform extends LocalAuthPlatform { } @override - Future canCheckBiometrics() async { - return (await getAvailableBiometrics()).isNotEmpty; + Future deviceSupportsBiometrics() async { + return (await getEnrolledBiometrics()).isNotEmpty; } @override diff --git a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart index 824725837794..b909ee90d12b 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/local_auth_platform_interface.dart @@ -63,7 +63,9 @@ abstract class LocalAuthPlatform extends PlatformInterface { } /// Returns true if the device is capable of checking biometrics. - Future canCheckBiometrics() async { + /// + /// This will return true even if there are no biometrics currently enrolled. + Future deviceSupportsBiometrics() async { throw UnimplementedError('canCheckBiometrics() has not been implemented.'); } @@ -75,7 +77,7 @@ abstract class LocalAuthPlatform extends PlatformInterface { /// - BiometricType.iris (not yet implemented) /// - BiometricType.strong /// - BiometricType.weak - Future> getAvailableBiometrics() async { + Future> getEnrolledBiometrics() async { throw UnimplementedError( 'getAvailableBiometrics() has not been implemented.'); } diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart index 978d2d066421..d51980d575cf 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/auth_messages.dart @@ -7,6 +7,6 @@ abstract class AuthMessages { /// Constructs an instance of [AuthMessages]. const AuthMessages(); - /// Returns all platform specific messages as a map. + /// Returns all platform-specific messages as a map. Map get args; } diff --git a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart index c4efd0deb3cb..9c335e25624a 100644 --- a/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart +++ b/packages/local_auth/local_auth_platform_interface/lib/types/biometric_type.dart @@ -21,7 +21,7 @@ enum BiometricType { strong, /// Any biometric (e.g. fingerprint, iris, or face) on the device that the - /// platform API considers to be strong. For example, on Android this + /// platform API considers to be weak. For example, on Android this /// corresponds to Class 2. weak, } diff --git a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart index d3a7bda7effc..3853fd84c6fc 100644 --- a/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart +++ b/packages/local_auth/local_auth_platform_interface/test/default_method_channel_platform_test.dart @@ -36,7 +36,7 @@ void main() { }); localAuthentication = DefaultLocalAuthPlatform(); log.clear(); - await localAuthentication.getAvailableBiometrics(); + await localAuthentication.getEnrolledBiometrics(); expect( log, [ From 2652857f1f75f678c1fdee0ad5c7f5eb813105a3 Mon Sep 17 00:00:00 2001 From: Bodhi Mulders Date: Fri, 11 Feb 2022 10:11:39 +0100 Subject: [PATCH 39/53] Adjust to platform interface changes --- .../example/integration_test/local_auth_test.dart | 2 +- .../local_auth/local_auth_android/example/lib/main.dart | 8 ++++---- .../local_auth_android/lib/local_auth_android.dart | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart index 8e4f4748f05f..1dfc0ae7a6d6 100644 --- a/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart +++ b/packages/local_auth/local_auth_android/example/integration_test/local_auth_test.dart @@ -12,7 +12,7 @@ void main() { testWidgets('canCheckBiometrics', (WidgetTester tester) async { expect( - LocalAuthAndroid().getAvailableBiometrics(), + LocalAuthAndroid().getEnrolledBiometrics(), completion(isList), ); }); diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart index a5de6c09c763..37199d03e1f8 100644 --- a/packages/local_auth/local_auth_android/example/lib/main.dart +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -40,7 +40,7 @@ class _MyAppState extends State { Future _checkBiometrics() async { late bool canCheckBiometrics; try { - canCheckBiometrics = (await auth.getAvailableBiometrics()).isNotEmpty; + canCheckBiometrics = (await auth.getEnrolledBiometrics()).isNotEmpty; } on PlatformException catch (e) { canCheckBiometrics = false; print(e); @@ -54,10 +54,10 @@ class _MyAppState extends State { }); } - Future _getAvailableBiometrics() async { + Future _getEnrolledBiometrics() async { late List availableBiometrics; try { - availableBiometrics = await auth.getAvailableBiometrics(); + availableBiometrics = await auth.getEnrolledBiometrics(); } on PlatformException catch (e) { availableBiometrics = []; print(e); @@ -178,7 +178,7 @@ class _MyAppState extends State { Text('Available biometrics: $_availableBiometrics\n'), ElevatedButton( child: const Text('Get available biometrics'), - onPressed: _getAvailableBiometrics, + onPressed: _getEnrolledBiometrics, ), const Divider(height: 100), Text('Current State: $_authorized\n'), diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index fb70fff8c6ad..9365bfd3455e 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -44,12 +44,12 @@ class LocalAuthAndroid extends LocalAuthPlatform { } @override - Future canCheckBiometrics() async { - return (await getAvailableBiometrics()).isNotEmpty; + Future deviceSupportsBiometrics() async { + return (await getEnrolledBiometrics()).isNotEmpty; } @override - Future> getAvailableBiometrics() async { + Future> getEnrolledBiometrics() async { final List result = (await _channel.invokeListMethod( 'getAvailableBiometrics', )) ?? From 63c6d6fbd04b8c43a5998a6e6f3ae3f65f53b6de Mon Sep 17 00:00:00 2001 From: Bodhi Mulders Date: Fri, 11 Feb 2022 10:19:32 +0100 Subject: [PATCH 40/53] Adjust to platform interface changes --- .../example/integration_test/local_auth_test.dart | 2 +- packages/local_auth/local_auth_ios/example/lib/main.dart | 8 ++++---- .../local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m | 6 +++--- .../local_auth/local_auth_ios/lib/local_auth_ios.dart | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart b/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart index f941a1bdaeed..d73cfd6aa625 100644 --- a/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart +++ b/packages/local_auth/local_auth_ios/example/integration_test/local_auth_test.dart @@ -12,7 +12,7 @@ void main() { testWidgets('canCheckBiometrics', (WidgetTester tester) async { expect( - LocalAuthIOS().getAvailableBiometrics(), + LocalAuthIOS().getEnrolledBiometrics(), completion(isList), ); }); diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart index 95dfe31a4a98..0490144c49e1 100644 --- a/packages/local_auth/local_auth_ios/example/lib/main.dart +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -40,7 +40,7 @@ class _MyAppState extends State { Future _checkBiometrics() async { late bool canCheckBiometrics; try { - canCheckBiometrics = (await auth.getAvailableBiometrics()).isNotEmpty; + canCheckBiometrics = (await auth.getEnrolledBiometrics()).isNotEmpty; } on PlatformException catch (e) { canCheckBiometrics = false; print(e); @@ -54,10 +54,10 @@ class _MyAppState extends State { }); } - Future _getAvailableBiometrics() async { + Future _getEnrolledBiometrics() async { late List availableBiometrics; try { - availableBiometrics = await auth.getAvailableBiometrics(); + availableBiometrics = await auth.getEnrolledBiometrics(); } on PlatformException catch (e) { availableBiometrics = []; print(e); @@ -178,7 +178,7 @@ class _MyAppState extends State { Text('Available biometrics: $_availableBiometrics\n'), ElevatedButton( child: const Text('Get available biometrics'), - onPressed: _getAvailableBiometrics, + onPressed: _getEnrolledBiometrics, ), const Divider(height: 100), Text('Current State: $_authorized\n'), diff --git a/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m index eb567e6afe25..f2b28a81e401 100644 --- a/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m +++ b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m @@ -35,8 +35,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } else { [self authenticate:call.arguments withFlutterResult:result]; } - } else if ([@"getAvailableBiometrics" isEqualToString:call.method]) { - [self getAvailableBiometrics:result]; + } else if ([@"getEnrolledBiometrics" isEqualToString:call.method]) { + [self getEnrolledBiometrics:result]; } else if ([@"isDeviceSupported" isEqualToString:call.method]) { result(@YES); } else { @@ -93,7 +93,7 @@ - (void)alertMessage:(NSString *)message completion:nil]; } -- (void)getAvailableBiometrics:(FlutterResult)result { +- (void)getEnrolledBiometrics:(FlutterResult)result { LAContext *context = self.createAuthContext; NSError *authError = nil; NSMutableArray *biometrics = [[NSMutableArray alloc] init]; diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart index 2124cc2a0a8c..e18b03d834a8 100644 --- a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -44,14 +44,14 @@ class LocalAuthIOS extends LocalAuthPlatform { } @override - Future canCheckBiometrics() async { - return (await getAvailableBiometrics()).isNotEmpty; + Future deviceSupportsBiometrics() async { + return (await getEnrolledBiometrics()).isNotEmpty; } @override - Future> getAvailableBiometrics() async { + Future> getEnrolledBiometrics() async { final List result = (await _channel.invokeListMethod( - 'getAvailableBiometrics', + 'getEnrolledBiometrics', )) ?? []; final List biometrics = []; From 6d205e5e99239d43ddcfbec7fefb9934bd839d3f Mon Sep 17 00:00:00 2001 From: Bodhi Mulders Date: Fri, 11 Feb 2022 10:24:21 +0100 Subject: [PATCH 41/53] Adjust to platform interface changes --- .../io/flutter/plugins/localauth/LocalAuthPlugin.java | 10 +++++----- .../local_auth_android/lib/local_auth_android.dart | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java index 49a6b788fe46..ae590cd5938a 100644 --- a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java @@ -101,8 +101,8 @@ public void onMethodCall(MethodCall call, @NonNull final Result result) { case "authenticate": authenticate(call, result); break; - case "getAvailableBiometrics": - getAvailableBiometrics(result); + case "getEnrolledBiometrics": + getEnrolledBiometrics(result); break; case "isDeviceSupported": isDeviceSupported(result); @@ -251,20 +251,20 @@ private void stopAuthentication(Result result) { /* * Returns biometric types available on device */ - private void getAvailableBiometrics(final Result result) { + private void getEnrolledBiometrics(final Result result) { try { if (activity == null || activity.isFinishing()) { result.error("no_activity", "local_auth plugin requires a foreground activity", null); return; } - ArrayList biometrics = getAvailableBiometrics(); + ArrayList biometrics = getEnrolledBiometrics(); result.success(biometrics); } catch (Exception e) { result.error("no_biometrics_available", e.getMessage(), null); } } - private ArrayList getAvailableBiometrics() { + private ArrayList getEnrolledBiometrics() { ArrayList biometrics = new ArrayList<>(); if (activity == null || activity.isFinishing()) { return biometrics; diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index 9365bfd3455e..e91be66430aa 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -51,7 +51,7 @@ class LocalAuthAndroid extends LocalAuthPlatform { @override Future> getEnrolledBiometrics() async { final List result = (await _channel.invokeListMethod( - 'getAvailableBiometrics', + 'getEnrolledBiometrics', )) ?? []; final List biometrics = []; From dc80c17e225a0f6b86715df967bd571a1fae51bd Mon Sep 17 00:00:00 2001 From: Bodhi Mulders Date: Fri, 11 Feb 2022 12:13:29 +0100 Subject: [PATCH 42/53] Adjust to platform interface changes --- packages/local_auth/local_auth/lib/src/local_auth.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart index 85fb21199969..3586d2f49bdd 100644 --- a/packages/local_auth/local_auth/lib/src/local_auth.dart +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -161,8 +161,8 @@ class LocalAuthentication { /// Returns true if device is capable of checking biometrics /// /// Returns a [Future] bool true or false: - Future get canCheckBiometrics async => - (await getAvailableBiometrics()).isNotEmpty; + Future get canCheckBiometrics => + LocalAuthPlatform.instance.deviceSupportsBiometrics(); /// Returns true if device is capable of checking biometrics or is able to /// fail over to device credentials. @@ -178,5 +178,5 @@ class LocalAuthentication { /// - BiometricType.fingerprint /// - BiometricType.iris (not yet implemented) Future> getAvailableBiometrics() => - LocalAuthPlatform.instance.getAvailableBiometrics(); + LocalAuthPlatform.instance.getEnrolledBiometrics(); } From 116c79578871cc937e2efef71d93433c6251ed7b Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 14 Feb 2022 17:26:57 +0100 Subject: [PATCH 43/53] Update platform interface dependency --- packages/local_auth/local_auth_android/pubspec.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index 6b6157bfa68b..07b7158057d8 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -24,8 +24,7 @@ dependencies: sdk: flutter flutter_plugin_android_lifecycle: ^2.0.1 intl: ^0.17.0 - local_auth_platform_interface: - path: ../local_auth_platform_interface + local_auth_platform_interface: ^1.0.0 dev_dependencies: flutter_test: From 7c97e488f6a83bd4f23c1f0037ccf46922117118 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 14 Feb 2022 17:37:20 +0100 Subject: [PATCH 44/53] Fixed order of keys in pubspec --- packages/local_auth/local_auth_android/pubspec.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index 07b7158057d8..e476d74c8e6e 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -6,6 +6,10 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes version: 1.0.0 +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + flutter: plugin: implements: local_auth @@ -15,10 +19,6 @@ flutter: pluginClass: LocalAuthPlugin dartPluginClass: LocalAuthAndroid -environment: - sdk: ">=2.14.0 <3.0.0" - flutter: ">=2.8.0" - dependencies: flutter: sdk: flutter From 222253f41e4a80fdf38a650438d5194db18c8d46 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 10 Mar 2022 15:19:44 +0100 Subject: [PATCH 45/53] Implement PR feedback (from iOS PR) --- packages/local_auth/local_auth/pubspec.yaml | 2 - .../plugins/localauth/LocalAuthPlugin.java | 10 +- .../local_auth_android/example/lib/main.dart | 16 +-- .../local_auth_android/example/pubspec.yaml | 4 +- .../lib/local_auth_android.dart | 2 +- .../lib/types/auth_messages_android.dart | 102 ++++++++---------- .../local_auth_android/pubspec.yaml | 3 +- .../test/local_auth_test.dart | 61 ++++++++++- 8 files changed, 123 insertions(+), 77 deletions(-) diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index f49c30975e7d..5a533ded7dc2 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -17,8 +17,6 @@ flutter: plugin: platforms: android: - package: io.flutter.plugins.localauth - pluginClass: LocalAuthPlugin default_package: local_auth_android ios: pluginClass: FLTLocalAuthPlugin diff --git a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java index ae590cd5938a..49a6b788fe46 100644 --- a/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java +++ b/packages/local_auth/local_auth_android/android/src/main/java/io/flutter/plugins/localauth/LocalAuthPlugin.java @@ -101,8 +101,8 @@ public void onMethodCall(MethodCall call, @NonNull final Result result) { case "authenticate": authenticate(call, result); break; - case "getEnrolledBiometrics": - getEnrolledBiometrics(result); + case "getAvailableBiometrics": + getAvailableBiometrics(result); break; case "isDeviceSupported": isDeviceSupported(result); @@ -251,20 +251,20 @@ private void stopAuthentication(Result result) { /* * Returns biometric types available on device */ - private void getEnrolledBiometrics(final Result result) { + private void getAvailableBiometrics(final Result result) { try { if (activity == null || activity.isFinishing()) { result.error("no_activity", "local_auth plugin requires a foreground activity", null); return; } - ArrayList biometrics = getEnrolledBiometrics(); + ArrayList biometrics = getAvailableBiometrics(); result.success(biometrics); } catch (Exception e) { result.error("no_biometrics_available", e.getMessage(), null); } } - private ArrayList getEnrolledBiometrics() { + private ArrayList getAvailableBiometrics() { ArrayList biometrics = new ArrayList<>(); if (activity == null || activity.isFinishing()) { return biometrics; diff --git a/packages/local_auth/local_auth_android/example/lib/main.dart b/packages/local_auth/local_auth_android/example/lib/main.dart index 37199d03e1f8..4c045214734d 100644 --- a/packages/local_auth/local_auth_android/example/lib/main.dart +++ b/packages/local_auth/local_auth_android/example/lib/main.dart @@ -9,6 +9,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; void main() { runApp(MyApp()); @@ -20,7 +21,6 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - final LocalAuthAndroid auth = LocalAuthAndroid(); _SupportState _supportState = _SupportState.unknown; bool? _canCheckBiometrics; List? _availableBiometrics; @@ -30,7 +30,7 @@ class _MyAppState extends State { @override void initState() { super.initState(); - auth.isDeviceSupported().then( + LocalAuthPlatform.instance.isDeviceSupported().then( (bool isSupported) => setState(() => _supportState = isSupported ? _SupportState.supported : _SupportState.unsupported), @@ -40,7 +40,8 @@ class _MyAppState extends State { Future _checkBiometrics() async { late bool canCheckBiometrics; try { - canCheckBiometrics = (await auth.getEnrolledBiometrics()).isNotEmpty; + canCheckBiometrics = + (await LocalAuthPlatform.instance.getEnrolledBiometrics()).isNotEmpty; } on PlatformException catch (e) { canCheckBiometrics = false; print(e); @@ -57,7 +58,8 @@ class _MyAppState extends State { Future _getEnrolledBiometrics() async { late List availableBiometrics; try { - availableBiometrics = await auth.getEnrolledBiometrics(); + availableBiometrics = + await LocalAuthPlatform.instance.getEnrolledBiometrics(); } on PlatformException catch (e) { availableBiometrics = []; print(e); @@ -78,7 +80,7 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.authenticate( + authenticated = await LocalAuthPlatform.instance.authenticate( localizedReason: 'Let OS determine authentication method', authMessages: [const AndroidAuthMessages()], options: const AuthenticationOptions( @@ -112,7 +114,7 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.authenticate( + authenticated = await LocalAuthPlatform.instance.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', authMessages: [const AndroidAuthMessages()], @@ -145,7 +147,7 @@ class _MyAppState extends State { } Future _cancelAuthentication() async { - await auth.stopAuthentication(); + await LocalAuthPlatform.instance.stopAuthentication(); setState(() => _isAuthenticating = false); } diff --git a/packages/local_auth/local_auth_android/example/pubspec.yaml b/packages/local_auth/local_auth_android/example/pubspec.yaml index efd7c9c79f7f..92e07cd1a5a8 100644 --- a/packages/local_auth/local_auth_android/example/pubspec.yaml +++ b/packages/local_auth/local_auth_android/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: none environment: sdk: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" + flutter: ">=2.8.0" dependencies: flutter: @@ -16,13 +16,13 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ + local_auth_platform_interface: ^1.0.0 dev_dependencies: flutter_driver: sdk: flutter integration_test: sdk: flutter - pedantic: ^1.10.0 flutter: uses-material-design: true diff --git a/packages/local_auth/local_auth_android/lib/local_auth_android.dart b/packages/local_auth/local_auth_android/lib/local_auth_android.dart index e91be66430aa..9365bfd3455e 100644 --- a/packages/local_auth/local_auth_android/lib/local_auth_android.dart +++ b/packages/local_auth/local_auth_android/lib/local_auth_android.dart @@ -51,7 +51,7 @@ class LocalAuthAndroid extends LocalAuthPlatform { @override Future> getEnrolledBiometrics() async { final List result = (await _channel.invokeListMethod( - 'getEnrolledBiometrics', + 'getAvailableBiometrics', )) ?? []; final List biometrics = []; diff --git a/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart index efc15d248942..ea61a4b06d4e 100644 --- a/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart +++ b/packages/local_auth/local_auth_android/lib/types/auth_messages_android.dart @@ -25,48 +25,49 @@ class AndroidAuthMessages extends AuthMessages { this.signInTitle, }); - /// Hint message advising the user how to authenticate with biometrics. It is - /// used on Android. Maximum 60 characters. + /// Hint message advising the user how to authenticate with biometrics. + /// Maximum 60 characters. final String? biometricHint; - /// Message to let the user know that authentication was failed. It is used - /// on Android. Maximum 60 characters.' + /// Message to let the user know that authentication was failed. + /// Maximum 60 characters. final String? biometricNotRecognized; /// Message shown as a title in a dialog which indicates the user - /// has not set up biometric authentication on their device. It is used on - /// Android. Maximum 60 characters. + /// has not set up biometric authentication on their device. + /// Maximum 60 characters. final String? biometricRequiredTitle; - /// Message to let the user know that authentication was successful. It - /// is used on Android. Maximum 60 characters + /// Message to let the user know that authentication was successful. + /// Maximum 60 characters final String? biometricSuccess; /// Message shown on a button that the user can click to leave the - /// current dialog. It is used on Android. Maximum 30 characters. + /// current dialog. + /// Maximum 30 characters. final String? cancelButton; /// Message shown as a title in a dialog which indicates the user - /// has not set up credentials authentication on their device. It is used on Android. + /// has not set up credentials authentication on their device. /// Maximum 60 characters. final String? deviceCredentialsRequiredTitle; /// Message advising the user to go to the settings and configure - /// device credentials on their device. It shows in a dialog on Android. + /// device credentials on their device. final String? deviceCredentialsSetupDescription; /// Message shown on a button that the user can click to go to settings pages - /// from the current dialog. It is used on both Android and iOS sides. + /// from the current dialog. /// Maximum 30 characters. final String? goToSettingsButton; /// Message advising the user to go to the settings and configure - /// biometric on their device. It shows in a dialog on Android. + /// biometric on their device. final String? goToSettingsDescription; /// Message shown as a title in a dialog which indicates the user - /// that they need to scan biometric to continue. It is used on - /// Android. Maximum 60 characters. + /// that they need to scan biometric to continue. + /// Maximum 60 characters. final String? signInTitle; @override @@ -122,78 +123,69 @@ class AndroidAuthMessages extends AuthMessages { signInTitle.hashCode; } -// Strings for local_authentication plugin. Currently supports English. +// Default strings for AndroidAuthMessages. Currently supports English. // Intl.message must be string literals. /// Message shown on a button that the user can click to go to settings pages -/// from the current dialog. Maximum 30 characters. +/// from the current dialog. String get goToSettings => Intl.message('Go to settings', desc: 'Message shown on a button that the user can click to go to ' - 'settings pages from the current dialog. It is used on both Android ' - 'and iOS sides. Maximum 30 characters.'); + 'settings pages from the current dialog. Maximum 30 characters.'); -/// Hint message advising the user how to authenticate with biometrics. It is -/// used on Android. Maximum 60 characters. +/// Hint message advising the user how to authenticate with biometrics. String get androidBiometricHint => Intl.message('Verify identity', - desc: - 'Hint message advising the user how to authenticate with biometrics. It is ' - 'used on Android. Maximum 60 characters.'); + desc: 'Hint message advising the user how to authenticate with biometrics. ' + 'Maximum 60 characters.'); -/// Message to let the user know that authentication was failed. It is used -/// on Android. Maximum 60 characters.' +/// Message to let the user know that authentication was failed. String get androidBiometricNotRecognized => Intl.message('Not recognized. Try again.', - desc: 'Message to let the user know that authentication was failed. It ' - 'is used on Android. Maximum 60 characters.'); + desc: 'Message to let the user know that authentication was failed. ' + 'Maximum 60 characters.'); /// Message to let the user know that authentication was successful. It -/// is used on Android. Maximum 60 characters String get androidBiometricSuccess => Intl.message('Success', - desc: 'Message to let the user know that authentication was successful. It ' - 'is used on Android. Maximum 60 characters.'); + desc: 'Message to let the user know that authentication was successful. ' + 'Maximum 60 characters.'); /// Message shown on a button that the user can click to leave the -/// current dialog. It is used on Android. Maximum 30 characters. +/// current dialog. String get androidCancelButton => Intl.message('Cancel', desc: 'Message shown on a button that the user can click to leave the ' - 'current dialog. It is used on Android. Maximum 30 characters.'); + 'current dialog. Maximum 30 characters.'); /// Message shown as a title in a dialog which indicates the user -/// that they need to scan biometric to continue. It is used on -/// Android. Maximum 60 characters. +/// that they need to scan biometric to continue. String get androidSignInTitle => Intl.message('Authentication required', desc: 'Message shown as a title in a dialog which indicates the user ' - 'that they need to scan biometric to continue. It is used on ' - 'Android. Maximum 60 characters.'); + 'that they need to scan biometric to continue. Maximum 60 characters.'); /// Message shown as a title in a dialog which indicates the user -/// has not set up biometric authentication on their device. It is used on -/// Android. Maximum 60 characters. +/// has not set up biometric authentication on their device. String get androidBiometricRequiredTitle => Intl.message('Biometric required', desc: 'Message shown as a title in a dialog which indicates the user ' - 'has not set up biometric authentication on their device. It is used on Android.' - ' Maximum 60 characters.'); + 'has not set up biometric authentication on their device. ' + 'Maximum 60 characters.'); /// Message shown as a title in a dialog which indicates the user -/// has not set up credentials authentication on their device. It is used on Android. -/// Maximum 60 characters. -String get androidDeviceCredentialsRequiredTitle => Intl.message( - 'Device credentials required', - desc: 'Message shown as a title in a dialog which indicates the user ' - 'has not set up credentials authentication on their device. It is used on Android.' - ' Maximum 60 characters.'); +/// has not set up credentials authentication on their device. +String get androidDeviceCredentialsRequiredTitle => + Intl.message('Device credentials required', + desc: 'Message shown as a title in a dialog which indicates the user ' + 'has not set up credentials authentication on their device. ' + 'Maximum 60 characters.'); /// Message advising the user to go to the settings and configure -/// device credentials on their device. It shows in a dialog on Android. -String get androidDeviceCredentialsSetupDescription => Intl.message( - 'Device credentials required', - desc: 'Message advising the user to go to the settings and configure ' - 'device credentials on their device. It shows in a dialog on Android.'); +/// device credentials on their device. +String get androidDeviceCredentialsSetupDescription => + Intl.message('Device credentials required', + desc: 'Message advising the user to go to the settings and configure ' + 'device credentials on their device.'); /// Message advising the user to go to the settings and configure -/// biometric on their device. It shows in a dialog on Android. +/// biometric on their device. String get androidGoToSettingsDescription => Intl.message( 'Biometric authentication is not set up on your device. Go to ' '\'Settings > Security\' to add biometric authentication.', desc: 'Message advising the user to go to the settings and configure ' - 'biometric on their device. It shows in a dialog on Android.'); + 'biometric on their device.'); diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml index e476d74c8e6e..2988e9fa65ce 100644 --- a/packages/local_auth/local_auth_android/pubspec.yaml +++ b/packages/local_auth/local_auth_android/pubspec.yaml @@ -28,5 +28,4 @@ dependencies: dev_dependencies: flutter_test: - sdk: flutter - mockito: ^5.0.0 \ No newline at end of file + sdk: flutter \ No newline at end of file diff --git a/packages/local_auth/local_auth_android/test/local_auth_test.dart b/packages/local_auth/local_auth_android/test/local_auth_test.dart index c4a462507a69..31f5e5796445 100644 --- a/packages/local_auth/local_auth_android/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_android/test/local_auth_test.dart @@ -23,14 +23,69 @@ void main() { setUp(() { channel.setMockMethodCallHandler((MethodCall methodCall) { log.add(methodCall); - return Future.value(true); + switch (methodCall.method) { + case 'getAvailableBiometrics': + return Future>.value( + ['face', 'fingerprint', 'iris', 'undefined']); + default: + return Future.value(true); + } }); localAuthentication = LocalAuthAndroid(); log.clear(); }); + test('deviceSupportsBiometrics calls getEnrolledBiometrics', () async { + final bool result = await localAuthentication.deviceSupportsBiometrics(); + + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + expect(result, true); + }); + + test('getEnrolledBiometrics calls platform', () async { + final List result = + await localAuthentication.getEnrolledBiometrics(); + + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + expect(result, [ + BiometricType.face, + BiometricType.fingerprint, + BiometricType.iris + ]); + }); + + test('isDeviceSupported calls platform', () async { + await localAuthentication.isDeviceSupported(); + expect( + log, + [ + isMethodCall('isDeviceSupported', arguments: null), + ], + ); + }); + + test('stopAuthentication calls platform', () async { + await localAuthentication.stopAuthentication(); + expect( + log, + [ + isMethodCall('stopAuthentication', arguments: null), + ], + ); + }); + group('With device auth fail over', () { - test('authenticate with no args on Android.', () async { + test('authenticate with no args.', () async { await localAuthentication.authenticate( authMessages: [const AndroidAuthMessages()], localizedReason: 'Needs secure', @@ -78,7 +133,7 @@ void main() { }); group('With biometrics only', () { - test('authenticate with no args on Android.', () async { + test('authenticate with no args.', () async { await localAuthentication.authenticate( authMessages: [const AndroidAuthMessages()], localizedReason: 'Needs secure', From c9d10a6d81362ac06af43ebad0adcc1ada87e4ce Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Fri, 11 Mar 2022 14:00:35 +0100 Subject: [PATCH 46/53] Update PR with changes from PRs for native functionality --- .../local_auth/local_auth/example/ios/Podfile | 6 - .../ios/Runner.xcodeproj/project.pbxproj | 163 +----------- .../ios/Classes/FLTLocalAuthPlugin.m | 234 ++++++++++++++++++ packages/local_auth/local_auth/pubspec.yaml | 11 +- .../local_auth/test/local_auth_test.dart | 25 +- .../local_auth_ios/example/ios/Podfile | 5 + .../ios/Runner.xcodeproj/project.pbxproj | 57 +++-- .../ios/RunnerTests/FLTLocalAuthPluginTests.m | 2 +- .../local_auth_ios/example/lib/main.dart | 18 +- .../local_auth_ios/example/pubspec.yaml | 4 +- .../ios/Classes/FLTLocalAuthPlugin.m | 15 +- .../local_auth_ios/ios/local_auth_ios.podspec | 2 +- .../local_auth_ios/lib/local_auth_ios.dart | 2 +- .../lib/types/auth_messages_ios.dart | 27 +- .../local_auth/local_auth_ios/pubspec.yaml | 14 +- .../local_auth_ios/test/local_auth_test.dart | 59 ++++- 16 files changed, 393 insertions(+), 251 deletions(-) create mode 100644 packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m diff --git a/packages/local_auth/local_auth/example/ios/Podfile b/packages/local_auth/local_auth/example/ios/Podfile index ef20d8e3c010..f7d6a5e68c3a 100644 --- a/packages/local_auth/local_auth/example/ios/Podfile +++ b/packages/local_auth/local_auth/example/ios/Podfile @@ -29,12 +29,6 @@ flutter_ios_podfile_setup target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) - - target 'RunnerTests' do - inherit! :search_paths - - pod 'OCMock', '3.5' - end end post_install do |installer| diff --git a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj index 32bfa9c097d5..090670067253 100644 --- a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj @@ -9,26 +9,14 @@ /* Begin PBXBuildFile section */ 0CCCD07A2CE24E13C9C1EEA4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - B726772E092FC537C9618264 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 719FE2C7EAF8D9A045E09C29 /* libPods-RunnerTests.a */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 3398D2D226163948005A052F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 97C146E61CF9000F007C117D /* Project object */; - proxyType = 1; - remoteGlobalIDString = 97C146ED1CF9000F007C117D; - remoteInfo = Runner; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXCopyFilesBuildPhase section */ 9705A1C41CF9048500538489 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; @@ -45,11 +33,8 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 3398D2CD26163948005A052F /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 3398D2D126163948005A052F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 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; }; - 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTLocalAuthPluginTests.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 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 = ""; }; 719FE2C7EAF8D9A045E09C29 /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -71,14 +56,6 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 3398D2CA26163948005A052F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - B726772E092FC537C9618264 /* libPods-RunnerTests.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -90,15 +67,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 33BF11D226680B2E002967F3 /* RunnerTests */ = { - isa = PBXGroup; - children = ( - 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */, - 3398D2D126163948005A052F /* Info.plist */, - ); - path = RunnerTests; - sourceTree = ""; - }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -113,7 +81,6 @@ 97C146E51CF9000F007C117D = { isa = PBXGroup; children = ( - 33BF11D226680B2E002967F3 /* RunnerTests */, 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, @@ -126,7 +93,6 @@ isa = PBXGroup; children = ( 97C146EE1CF9000F007C117D /* Runner.app */, - 3398D2CD26163948005A052F /* RunnerTests.xctest */, ); name = Products; sourceTree = ""; @@ -180,25 +146,6 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 3398D2CC26163948005A052F /* RunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */; - buildPhases = ( - B5AF6C7A6759E6F38749E537 /* [CP] Check Pods Manifest.lock */, - 3398D2C926163948005A052F /* Sources */, - 3398D2CA26163948005A052F /* Frameworks */, - 3398D2CB26163948005A052F /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 3398D2D326163948005A052F /* PBXTargetDependency */, - ); - name = RunnerTests; - productName = RunnerTests; - productReference = 3398D2CD26163948005A052F /* RunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; 97C146ED1CF9000F007C117D /* Runner */ = { isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; @@ -229,13 +176,9 @@ LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { - 3398D2CC26163948005A052F = { - CreatedOnToolsVersion = 12.4; - ProvisioningStyle = Automatic; - TestTargetID = 97C146ED1CF9000F007C117D; - }; 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = 7624MWN53C; }; }; }; @@ -253,19 +196,11 @@ projectRoot = ""; targets = ( 97C146ED1CF9000F007C117D /* Runner */, - 3398D2CC26163948005A052F /* RunnerTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 3398D2CB26163948005A052F /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 97C146EC1CF9000F007C117D /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -326,39 +261,9 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - B5AF6C7A6759E6F38749E537 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 3398D2C926163948005A052F /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 97C146EA1CF9000F007C117D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -371,14 +276,6 @@ }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 3398D2D326163948005A052F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 97C146ED1CF9000F007C117D /* Runner */; - targetProxy = 3398D2D226163948005A052F /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ 97C146FA1CF9000F007C117D /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -399,53 +296,6 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 3398D2D526163948005A052F /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 99302E79EC77497F2F274D12 /* Pods-RunnerTests.debug.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = RunnerTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; - }; - name = Debug; - }; - 3398D2D626163948005A052F /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = FEA527BB0A821430FEAA1566 /* Pods-RunnerTests.release.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_STYLE = Automatic; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = RunnerTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; - }; - name = Release; - }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -557,6 +407,7 @@ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 7624MWN53C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -578,6 +429,7 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 7624MWN53C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -597,15 +449,6 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 3398D2D526163948005A052F /* Debug */, - 3398D2D626163948005A052F /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m new file mode 100644 index 000000000000..70113efa00a0 --- /dev/null +++ b/packages/local_auth/local_auth/ios/Classes/FLTLocalAuthPlugin.m @@ -0,0 +1,234 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#import + +#import "FLTLocalAuthPlugin.h" + +@interface FLTLocalAuthPlugin () +@property(nonatomic, copy, nullable) NSDictionary *lastCallArgs; +@property(nonatomic, nullable) FlutterResult lastResult; +// For unit tests to inject dummy LAContext instances that will be used when a new context would +// normally be created. Each call to createAuthContext will remove the current first element from +// the array. +- (void)setAuthContextOverrides:(NSArray *)authContexts; +@end + +@implementation FLTLocalAuthPlugin { + NSMutableArray *_authContextOverrides; +} + ++ (void)registerWithRegistrar:(NSObject *)registrar { + FlutterMethodChannel *channel = + [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/local_auth" + binaryMessenger:[registrar messenger]]; + FLTLocalAuthPlugin *instance = [[FLTLocalAuthPlugin alloc] init]; + [registrar addMethodCallDelegate:instance channel:channel]; + [registrar addApplicationDelegate:instance]; +} + +- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { + if ([@"authenticate" isEqualToString:call.method]) { + bool isBiometricOnly = [call.arguments[@"biometricOnly"] boolValue]; + if (isBiometricOnly) { + [self authenticateWithBiometrics:call.arguments withFlutterResult:result]; + } else { + [self authenticate:call.arguments withFlutterResult:result]; + } + } else if ([@"getAvailableBiometrics" isEqualToString:call.method]) { + [self getAvailableBiometrics:result]; + } else if ([@"isDeviceSupported" isEqualToString:call.method]) { + result(@YES); + } else { + result(FlutterMethodNotImplemented); + } +} + +#pragma mark Private Methods + +- (void)setAuthContextOverrides:(NSArray *)authContexts { + _authContextOverrides = [authContexts mutableCopy]; +} + +- (LAContext *)createAuthContext { + if ([_authContextOverrides count] > 0) { + LAContext *context = [_authContextOverrides firstObject]; + [_authContextOverrides removeObjectAtIndex:0]; + return context; + } + return [[LAContext alloc] init]; +} + +- (void)alertMessage:(NSString *)message + firstButton:(NSString *)firstButton + flutterResult:(FlutterResult)result + additionalButton:(NSString *)secondButton { + UIAlertController *alert = + [UIAlertController alertControllerWithTitle:@"" + message:message + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:firstButton + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + result(@NO); + }]; + + [alert addAction:defaultAction]; + if (secondButton != nil) { + UIAlertAction *additionalAction = [UIAlertAction + actionWithTitle:secondButton + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + if (UIApplicationOpenSettingsURLString != NULL) { + NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + [[UIApplication sharedApplication] openURL:url]; + result(@NO); + } + }]; + [alert addAction:additionalAction]; + } + [[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alert + animated:YES + completion:nil]; +} + +- (void)getAvailableBiometrics:(FlutterResult)result { + LAContext *context = self.createAuthContext; + NSError *authError = nil; + NSMutableArray *biometrics = [[NSMutableArray alloc] init]; + if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + error:&authError]) { + if (authError == nil) { + if (@available(iOS 11.0.1, *)) { + if (context.biometryType == LABiometryTypeFaceID) { + [biometrics addObject:@"face"]; + } else if (context.biometryType == LABiometryTypeTouchID) { + [biometrics addObject:@"fingerprint"]; + } + } else { + [biometrics addObject:@"fingerprint"]; + } + } + } else if (authError.code == LAErrorTouchIDNotEnrolled) { + [biometrics addObject:@"undefined"]; + } + result(biometrics); +} + +- (void)authenticateWithBiometrics:(NSDictionary *)arguments + withFlutterResult:(FlutterResult)result { + LAContext *context = self.createAuthContext; + NSError *authError = nil; + self.lastCallArgs = nil; + self.lastResult = nil; + context.localizedFallbackTitle = arguments[@"localizedFallbackTitle"] == [NSNull null] + ? nil + : arguments[@"localizedFallbackTitle"]; + + if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + error:&authError]) { + [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics + localizedReason:arguments[@"localizedReason"] + reply:^(BOOL success, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self handleAuthReplyWithSuccess:success + error:error + flutterArguments:arguments + flutterResult:result]; + }); + }]; + } else { + [self handleErrors:authError flutterArguments:arguments withFlutterResult:result]; + } +} + +- (void)authenticate:(NSDictionary *)arguments withFlutterResult:(FlutterResult)result { + LAContext *context = self.createAuthContext; + NSError *authError = nil; + _lastCallArgs = nil; + _lastResult = nil; + context.localizedFallbackTitle = arguments[@"localizedFallbackTitle"] == [NSNull null] + ? nil + : arguments[@"localizedFallbackTitle"]; + + if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError]) { + [context evaluatePolicy:kLAPolicyDeviceOwnerAuthentication + localizedReason:arguments[@"localizedReason"] + reply:^(BOOL success, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self handleAuthReplyWithSuccess:success + error:error + flutterArguments:arguments + flutterResult:result]; + }); + }]; + } else { + [self handleErrors:authError flutterArguments:arguments withFlutterResult:result]; + } +} + +- (void)handleAuthReplyWithSuccess:(BOOL)success + error:(NSError *)error + flutterArguments:(NSDictionary *)arguments + flutterResult:(FlutterResult)result { + NSAssert([NSThread isMainThread], @"Response handling must be done on the main thread."); + if (success) { + result(@YES); + } else { + switch (error.code) { + case LAErrorPasscodeNotSet: + case LAErrorTouchIDNotAvailable: + case LAErrorTouchIDNotEnrolled: + case LAErrorUserFallback: + case LAErrorTouchIDLockout: + [self handleErrors:error flutterArguments:arguments withFlutterResult:result]; + return; + case LAErrorSystemCancel: + if ([arguments[@"stickyAuth"] boolValue]) { + self->_lastCallArgs = arguments; + self->_lastResult = result; + return; + } + } + result(@NO); + } +} + +- (void)handleErrors:(NSError *)authError + flutterArguments:(NSDictionary *)arguments + withFlutterResult:(FlutterResult)result { + NSString *errorCode = @"NotAvailable"; + switch (authError.code) { + case LAErrorPasscodeNotSet: + case LAErrorTouchIDNotEnrolled: + if ([arguments[@"useErrorDialogs"] boolValue]) { + [self alertMessage:arguments[@"goToSettingDescriptionIOS"] + firstButton:arguments[@"okButton"] + flutterResult:result + additionalButton:arguments[@"goToSetting"]]; + return; + } + errorCode = authError.code == LAErrorPasscodeNotSet ? @"PasscodeNotSet" : @"NotEnrolled"; + break; + case LAErrorTouchIDLockout: + [self alertMessage:arguments[@"lockOut"] + firstButton:arguments[@"okButton"] + flutterResult:result + additionalButton:nil]; + return; + } + result([FlutterError errorWithCode:errorCode + message:authError.localizedDescription + details:authError.domain]); +} + +#pragma mark - AppDelegate + +- (void)applicationDidBecomeActive:(UIApplication *)application { + if (self.lastCallArgs != nil && self.lastResult != nil) { + [self authenticateWithBiometrics:_lastCallArgs withFlutterResult:self.lastResult]; + } +} + +@end diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index 86f515f1dbed..d5e6a18c0a49 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -25,13 +25,12 @@ dependencies: flutter: sdk: flutter intl: ^0.17.0 - platform: ^3.0.2 - local_auth_platform_interface: - path: ../local_auth_platform_interface - local_auth_ios: - path: ../local_auth_ios local_auth_android: path: ../local_auth_android + local_auth_ios: + path: ../local_auth_ios + local_auth_platform_interface: ^1.0.0 + platform: ^3.0.2 dev_dependencies: flutter_driver: @@ -40,5 +39,5 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter + mockito: ^5.1.0 pedantic: ^1.10.0 - mockito: ^5.0.0 diff --git a/packages/local_auth/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart index 69c7ce8fe7ff..6638317bcf8c 100644 --- a/packages/local_auth/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/local_auth/test/local_auth_test.dart @@ -82,11 +82,11 @@ void main() { verify(mockLocalAuthPlatform.isDeviceSupported()).called(1); }); - test('getAvailableBiometrics calls platform implementation', () { - when(mockLocalAuthPlatform.getAvailableBiometrics()) + test('getEnrolledBiometrics calls platform implementation', () { + when(mockLocalAuthPlatform.getEnrolledBiometrics()) .thenAnswer((_) async => []); localAuthentication.getAvailableBiometrics(); - verify(mockLocalAuthPlatform.getAvailableBiometrics()).called(1); + verify(mockLocalAuthPlatform.getEnrolledBiometrics()).called(1); }); test('stopAuthentication calls platform implementation on Android', () { @@ -104,16 +104,16 @@ void main() { }); test('canCheckBiometrics returns correct result', () async { - when(mockLocalAuthPlatform.getAvailableBiometrics()) - .thenAnswer((_) async => []); + when(mockLocalAuthPlatform.deviceSupportsBiometrics()) + .thenAnswer((_) async => false); bool? result; result = await localAuthentication.canCheckBiometrics; expect(result, false); - when(mockLocalAuthPlatform.getAvailableBiometrics()) - .thenAnswer((_) async => [BiometricType.face]); + when(mockLocalAuthPlatform.deviceSupportsBiometrics()) + .thenAnswer((_) async => true); result = await localAuthentication.canCheckBiometrics; expect(result, true); - verify(mockLocalAuthPlatform.getAvailableBiometrics()).called(2); + verify(mockLocalAuthPlatform.deviceSupportsBiometrics()).called(2); }); } @@ -142,8 +142,8 @@ class MockLocalAuthPlatform extends Mock returnValue: Future.value(false)) as Future; @override - Future> getAvailableBiometrics() => - super.noSuchMethod(Invocation.method(#getAvailableBiometrics, []), + Future> getEnrolledBiometrics() => + super.noSuchMethod(Invocation.method(#getEnrolledBiometrics, []), returnValue: Future>.value([])) as Future>; @@ -156,4 +156,9 @@ class MockLocalAuthPlatform extends Mock Future stopAuthentication() => super.noSuchMethod(Invocation.method(#stopAuthentication, []), returnValue: Future.value(false)) as Future; + + @override + Future deviceSupportsBiometrics() => super.noSuchMethod( + Invocation.method(#deviceSupportsBiometrics, []), + returnValue: Future.value(false)) as Future; } diff --git a/packages/local_auth/local_auth_ios/example/ios/Podfile b/packages/local_auth/local_auth_ios/example/ios/Podfile index f7d6a5e68c3a..ee8f1d9ec3ef 100644 --- a/packages/local_auth/local_auth_ios/example/ios/Podfile +++ b/packages/local_auth/local_auth_ios/example/ios/Podfile @@ -29,6 +29,11 @@ flutter_ios_podfile_setup target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + + pod 'OCMock','3.5' + end end post_install do |installer| diff --git a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj index 6e315792cb90..f8b4056d135d 100644 --- a/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/local_auth/local_auth_ios/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -11,6 +11,7 @@ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3398D2E426164AD8005A052F /* FLTLocalAuthPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3398D2E326164AD8005A052F /* FLTLocalAuthPluginTests.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 691CB38B382734AF80FBCA4C /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBFA21B380E07A3A585383D /* libPods-RunnerTests.a */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; @@ -54,6 +55,7 @@ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 8D6545CD14E27D6F8299FFD5 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -63,6 +65,8 @@ 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + ADBFA21B380E07A3A585383D /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + D9B3BCBC68F8928E2907FB87 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; EB36DF6C3F25E00DF4175422 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -71,6 +75,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 691CB38B382734AF80FBCA4C /* libPods-RunnerTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -156,6 +161,7 @@ 3398D2DF26164A03005A052F /* liblocal_auth.a */, 3398D2DC261649CD005A052F /* liblocal_auth.a */, 9D274A3F79473B1549B2BBD5 /* libPods-Runner.a */, + ADBFA21B380E07A3A585383D /* libPods-RunnerTests.a */, ); name = Frameworks; sourceTree = ""; @@ -165,6 +171,8 @@ children = ( EB36DF6C3F25E00DF4175422 /* Pods-Runner.debug.xcconfig */, 658CDD04B21E4EA92F8EF229 /* Pods-Runner.release.xcconfig */, + 8D6545CD14E27D6F8299FFD5 /* Pods-RunnerTests.debug.xcconfig */, + D9B3BCBC68F8928E2907FB87 /* Pods-RunnerTests.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -176,6 +184,7 @@ isa = PBXNativeTarget; buildConfigurationList = 3398D2D426163948005A052F /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 9C21D3AD392EA849AEB09231 /* [CP] Check Pods Manifest.lock */, 3398D2C926163948005A052F /* Sources */, 3398D2CA26163948005A052F /* Frameworks */, 3398D2CB26163948005A052F /* Resources */, @@ -317,6 +326,28 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 9C21D3AD392EA849AEB09231 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -370,6 +401,7 @@ /* Begin XCBuildConfiguration section */ 3398D2D526163948005A052F /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8D6545CD14E27D6F8299FFD5 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -381,11 +413,7 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = RunnerTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; @@ -397,6 +425,7 @@ }; 3398D2D626163948005A052F /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = D9B3BCBC68F8928E2907FB87 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -408,11 +437,7 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = RunnerTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.google.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -538,10 +563,7 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -562,10 +584,7 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m index dc409da9f57c..56ba8d491074 100644 --- a/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m +++ b/packages/local_auth/local_auth_ios/example/ios/RunnerTests/FLTLocalAuthPluginTests.m @@ -10,7 +10,7 @@ #if __has_include() #import #else -@import local_auth; +@import local_auth_ios; #endif // Private API needed for tests. diff --git a/packages/local_auth/local_auth_ios/example/lib/main.dart b/packages/local_auth/local_auth_ios/example/lib/main.dart index 0490144c49e1..9346be10fd78 100644 --- a/packages/local_auth/local_auth_ios/example/lib/main.dart +++ b/packages/local_auth/local_auth_ios/example/lib/main.dart @@ -9,6 +9,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:local_auth_ios/local_auth_ios.dart'; +import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; +import 'package:local_auth_platform_interface/types/auth_messages.dart'; +import 'package:local_auth_platform_interface/types/biometric_type.dart'; void main() { runApp(MyApp()); @@ -20,7 +23,6 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - final LocalAuthIOS auth = LocalAuthIOS(); _SupportState _supportState = _SupportState.unknown; bool? _canCheckBiometrics; List? _availableBiometrics; @@ -30,7 +32,7 @@ class _MyAppState extends State { @override void initState() { super.initState(); - auth.isDeviceSupported().then( + LocalAuthPlatform.instance.isDeviceSupported().then( (bool isSupported) => setState(() => _supportState = isSupported ? _SupportState.supported : _SupportState.unsupported), @@ -40,7 +42,8 @@ class _MyAppState extends State { Future _checkBiometrics() async { late bool canCheckBiometrics; try { - canCheckBiometrics = (await auth.getEnrolledBiometrics()).isNotEmpty; + canCheckBiometrics = + (await LocalAuthPlatform.instance.getEnrolledBiometrics()).isNotEmpty; } on PlatformException catch (e) { canCheckBiometrics = false; print(e); @@ -57,7 +60,8 @@ class _MyAppState extends State { Future _getEnrolledBiometrics() async { late List availableBiometrics; try { - availableBiometrics = await auth.getEnrolledBiometrics(); + availableBiometrics = + await LocalAuthPlatform.instance.getEnrolledBiometrics(); } on PlatformException catch (e) { availableBiometrics = []; print(e); @@ -78,7 +82,7 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.authenticate( + authenticated = await LocalAuthPlatform.instance.authenticate( localizedReason: 'Let OS determine authentication method', authMessages: [const IOSAuthMessages()], options: const AuthenticationOptions( @@ -112,7 +116,7 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.authenticate( + authenticated = await LocalAuthPlatform.instance.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', authMessages: [const IOSAuthMessages()], @@ -145,7 +149,7 @@ class _MyAppState extends State { } Future _cancelAuthentication() async { - await auth.stopAuthentication(); + await LocalAuthPlatform.instance.stopAuthentication(); setState(() => _isAuthenticating = false); } diff --git a/packages/local_auth/local_auth_ios/example/pubspec.yaml b/packages/local_auth/local_auth_ios/example/pubspec.yaml index 70a2946d8e01..f83806b9d08e 100644 --- a/packages/local_auth/local_auth_ios/example/pubspec.yaml +++ b/packages/local_auth/local_auth_ios/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: none environment: sdk: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" + flutter: ">=2.8.0" dependencies: flutter: @@ -16,13 +16,13 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ + local_auth_platform_interface: ^1.0.0 dev_dependencies: flutter_driver: sdk: flutter integration_test: sdk: flutter - pedantic: ^1.10.0 flutter: uses-material-design: true diff --git a/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m index d1b6bef8c83f..eb567e6afe25 100644 --- a/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m +++ b/packages/local_auth/local_auth_ios/ios/Classes/FLTLocalAuthPlugin.m @@ -35,8 +35,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } else { [self authenticate:call.arguments withFlutterResult:result]; } - } else if ([@"getEnrolledBiometrics" isEqualToString:call.method]) { - [self getEnrolledBiometrics:result]; + } else if ([@"getAvailableBiometrics" isEqualToString:call.method]) { + [self getAvailableBiometrics:result]; } else if ([@"isDeviceSupported" isEqualToString:call.method]) { result(@YES); } else { @@ -93,7 +93,7 @@ - (void)alertMessage:(NSString *)message completion:nil]; } -- (void)getEnrolledBiometrics:(FlutterResult)result { +- (void)getAvailableBiometrics:(FlutterResult)result { LAContext *context = self.createAuthContext; NSError *authError = nil; NSMutableArray *biometrics = [[NSMutableArray alloc] init]; @@ -122,9 +122,7 @@ - (void)authenticateWithBiometrics:(NSDictionary *)arguments NSError *authError = nil; self.lastCallArgs = nil; self.lastResult = nil; - context.localizedFallbackTitle = arguments[@"localizedFallbackTitle"] == [NSNull null] - ? nil - : arguments[@"localizedFallbackTitle"]; + context.localizedFallbackTitle = @""; if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { @@ -148,9 +146,7 @@ - (void)authenticate:(NSDictionary *)arguments withFlutterResult:(FlutterResult) NSError *authError = nil; _lastCallArgs = nil; _lastResult = nil; - context.localizedFallbackTitle = arguments[@"localizedFallbackTitle"] == [NSNull null] - ? nil - : arguments[@"localizedFallbackTitle"]; + context.localizedFallbackTitle = @""; if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&authError]) { [context evaluatePolicy:kLAPolicyDeviceOwnerAuthentication @@ -180,7 +176,6 @@ - (void)handleAuthReplyWithSuccess:(BOOL)success case LAErrorPasscodeNotSet: case LAErrorTouchIDNotAvailable: case LAErrorTouchIDNotEnrolled: - case LAErrorUserFallback: case LAErrorTouchIDLockout: [self handleErrors:error flutterArguments:arguments withFlutterResult:result]; return; diff --git a/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec b/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec index a0e59e4df2a8..0828c6085ea2 100644 --- a/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec +++ b/packages/local_auth/local_auth_ios/ios/local_auth_ios.podspec @@ -12,7 +12,7 @@ Downloaded by pub (not CocoaPods). s.homepage = 'https://github.com/flutter/plugins' s.license = { :type => 'BSD', :file => '../LICENSE' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } - s.source = { :http => 'https://github.com/flutter/plugins/tree/master/packages/local_auth/local_auth_ios' } + s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/local_auth' } s.documentation_url = 'https://pub.dev/packages/local_auth_ios' s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' diff --git a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart index e18b03d834a8..1d0c6e91a5de 100644 --- a/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/local_auth_ios.dart @@ -51,7 +51,7 @@ class LocalAuthIOS extends LocalAuthPlatform { @override Future> getEnrolledBiometrics() async { final List result = (await _channel.invokeListMethod( - 'getEnrolledBiometrics', + 'getAvailableBiometrics', )) ?? []; final List biometrics = []; diff --git a/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart index 2cf6b586a1bb..8a776243d242 100644 --- a/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart +++ b/packages/local_auth/local_auth_ios/lib/types/auth_messages_ios.dart @@ -19,20 +19,19 @@ class IOSAuthMessages extends AuthMessages { }); /// Message advising the user to re-enable biometrics on their device. - /// It shows in a dialog on iOS. final String? lockOut; /// Message shown on a button that the user can click to go to settings pages - /// from the current dialog. It is used on both Android and iOS sides. + /// from the current dialog. /// Maximum 30 characters. final String? goToSettingsButton; /// Message advising the user to go to the settings and configure Biometrics - /// for their device. It shows in a dialog on iOS. + /// for their device. final String? goToSettingsDescription; /// Message shown on a button that the user can click to leave the current - /// dialog. It is used on iOS. + /// dialog. /// Maximum 30 characters. final String? cancelButton; @@ -65,37 +64,33 @@ class IOSAuthMessages extends AuthMessages { cancelButton.hashCode; } -// Strings for local_authentication plugin. Currently supports English. +// Default Strings for IOSAuthMessages plugin. Currently supports English. // Intl.message must be string literals. /// Message shown on a button that the user can click to go to settings pages -/// from the current dialog. Maximum 30 characters. +/// from the current dialog. String get goToSettings => Intl.message('Go to settings', desc: 'Message shown on a button that the user can click to go to ' - 'settings pages from the current dialog. It is used on both Android ' - 'and iOS sides. Maximum 30 characters.'); + 'settings pages from the current dialog. Maximum 30 characters.'); /// Message advising the user to re-enable biometrics on their device. /// It shows in a dialog on iOS. String get iOSLockOut => Intl.message( 'Biometric authentication is disabled. Please lock and unlock your screen to ' 'enable it.', - desc: - 'Message advising the user to re-enable biometrics on their device. It ' - 'shows in a dialog on the iOS.'); + desc: 'Message advising the user to re-enable biometrics on their device.'); /// Message advising the user to go to the settings and configure Biometrics -/// for their device. It shows in a dialog on iOS. +/// for their device. String get iOSGoToSettingsDescription => Intl.message( 'Biometric authentication is not set up on your device. Please either enable ' 'Touch ID or Face ID on your phone.', desc: 'Message advising the user to go to the settings and configure Biometrics ' - 'for their device. It shows in a dialog on iOS.'); + 'for their device.'); /// Message shown on a button that the user can click to leave the current -/// dialog. It is used on iOS. -/// Maximum 30 characters. +/// dialog. String get iOSOkButton => Intl.message('OK', desc: 'Message showed on a button that the user can click to leave the ' - 'current dialog. It is used on iOS side. Maximum 30 characters.'); + 'current dialog. Maximum 30 characters.'); diff --git a/packages/local_auth/local_auth_ios/pubspec.yaml b/packages/local_auth/local_auth_ios/pubspec.yaml index da15559111c1..3872cd06e659 100644 --- a/packages/local_auth/local_auth_ios/pubspec.yaml +++ b/packages/local_auth/local_auth_ios/pubspec.yaml @@ -6,6 +6,10 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes version: 1.0.0 +environment: + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.8.0" + flutter: plugin: implements: local_auth @@ -14,18 +18,12 @@ flutter: pluginClass: FLTLocalAuthPlugin dartPluginClass: LocalAuthIOS -environment: - sdk: ">=2.14.0 <3.0.0" - flutter: ">=2.8.0" - dependencies: flutter: sdk: flutter intl: ^0.17.0 - local_auth_platform_interface: - path: ../local_auth_platform_interface + local_auth_platform_interface: ^1.0.0 dev_dependencies: flutter_test: - sdk: flutter - mockito: ^5.0.0 \ No newline at end of file + sdk: flutter \ No newline at end of file diff --git a/packages/local_auth/local_auth_ios/test/local_auth_test.dart b/packages/local_auth/local_auth_ios/test/local_auth_test.dart index 1d5a76aaa459..b529764adbd6 100644 --- a/packages/local_auth/local_auth_ios/test/local_auth_test.dart +++ b/packages/local_auth/local_auth_ios/test/local_auth_test.dart @@ -23,14 +23,65 @@ void main() { setUp(() { channel.setMockMethodCallHandler((MethodCall methodCall) { log.add(methodCall); - return Future.value(true); + switch (methodCall.method) { + case 'getAvailableBiometrics': + return Future>.value( + ['face', 'fingerprint', 'iris', 'undefined']); + default: + return Future.value(true); + } }); localAuthentication = LocalAuthIOS(); log.clear(); }); + test('deviceSupportsBiometrics calls getEnrolledBiometrics', () async { + final bool result = await localAuthentication.deviceSupportsBiometrics(); + + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + expect(result, true); + }); + + test('getEnrolledBiometrics calls platform', () async { + final List result = + await localAuthentication.getEnrolledBiometrics(); + + expect( + log, + [ + isMethodCall('getAvailableBiometrics', arguments: null), + ], + ); + expect(result, [ + BiometricType.face, + BiometricType.fingerprint, + BiometricType.iris + ]); + }); + + test('isDeviceSupported calls platform', () async { + await localAuthentication.isDeviceSupported(); + + expect( + log, + [ + isMethodCall('isDeviceSupported', arguments: null), + ], + ); + }); + + test('stopAuthentication throws UnimplementedError', () async { + expect(() async => await localAuthentication.stopAuthentication(), + throwsUnimplementedError); + }); + group('With device auth fail over', () { - test('authenticate with no args on iOS.', () async { + test('authenticate with no args.', () async { await localAuthentication.authenticate( authMessages: [const IOSAuthMessages()], localizedReason: 'Needs secure', @@ -51,7 +102,7 @@ void main() { ); }); - test('authenticate with no localizedReason on iOS.', () async { + test('authenticate with no localizedReason.', () async { await expectLater( localAuthentication.authenticate( authMessages: [const IOSAuthMessages()], @@ -64,7 +115,7 @@ void main() { }); group('With biometrics only', () { - test('authenticate with no args on iOS.', () async { + test('authenticate with no args.', () async { await localAuthentication.authenticate( authMessages: [const IOSAuthMessages()], localizedReason: 'Needs secure', From 267c4a8f1ee968de2f90d4b6d7c149e63d10087b Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Tue, 12 Apr 2022 15:00:16 +0200 Subject: [PATCH 47/53] Revert changes to project.pbxproj --- .../local_auth/example/ios/Runner.xcodeproj/project.pbxproj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj index 090670067253..b40fbca4cf66 100644 --- a/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/local_auth/local_auth/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -17,6 +17,7 @@ 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ + /* Begin PBXCopyFilesBuildPhase section */ 9705A1C41CF9048500538489 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; @@ -178,7 +179,6 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 7624MWN53C; }; }; }; @@ -407,7 +407,6 @@ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 7624MWN53C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -429,7 +428,6 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 7624MWN53C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", From 1a6d9edf525619cff21f0fa1d8ece9939ce4fb14 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Tue, 12 Apr 2022 15:05:17 +0200 Subject: [PATCH 48/53] Add missing dev dependency --- packages/local_auth/local_auth/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index 623c92caa1af..d99dc554adf3 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -34,3 +34,4 @@ dev_dependencies: integration_test: sdk: flutter mockito: ^5.1.0 + plugin_platform_interface: ^2.1.2 From 6188c99982420303dde0b66cf7d950b9680e94a2 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Tue, 12 Apr 2022 15:07:51 +0200 Subject: [PATCH 49/53] Add missing license header --- packages/local_auth/local_auth/lib/local_auth.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/local_auth/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart index 57afe935b49b..13ec38df34c7 100644 --- a/packages/local_auth/local_auth/lib/local_auth.dart +++ b/packages/local_auth/local_auth/lib/local_auth.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + export 'package:local_auth/src/local_auth.dart' show LocalAuthentication; // TODO(BeMacized): This should be removed the next time a breaking change From 7103054527b3949569ad726ea9eb147f6c4fa311 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Wed, 13 Apr 2022 13:49:31 +0200 Subject: [PATCH 50/53] Process PR feedback. Removed deprecated methods. --- packages/local_auth/local_auth/CHANGELOG.md | 35 +++++- .../local_auth/example/lib/main.dart | 4 +- .../local_auth/local_auth/lib/local_auth.dart | 13 --- .../local_auth/lib/src/local_auth.dart | 102 +----------------- packages/local_auth/local_auth/pubspec.yaml | 5 +- .../local_auth/test/local_auth_test.dart | 37 +------ 6 files changed, 48 insertions(+), 148 deletions(-) diff --git a/packages/local_auth/local_auth/CHANGELOG.md b/packages/local_auth/local_auth/CHANGELOG.md index c5083f10ff66..a1286496267b 100644 --- a/packages/local_auth/local_auth/CHANGELOG.md +++ b/packages/local_auth/local_auth/CHANGELOG.md @@ -1,7 +1,40 @@ ## 2.0.0 -* Migrated plugin to federated architecture. +* Migrates plugin to federated architecture. * Adds OS version support information to README. +* BREAKING CHANGE: Deprecated method `authenticateWithBiometrics` has been removed + Use `authenticate` instead. +* BREAKING CHANGE: Parameters of `authenticate` have been changed. + + Example: +```dart +// Old way of calling `authenticate`. +Future authenticate( + localizedReason: 'localized reason', + useErrorDialogs: true, + stickyAuth: false, + androidAuthStrings: const AndroidAuthMessages(), + iOSAuthStrings: const IOSAuthMessages(), + sensitiveTransaction: true, + biometricOnly: false, +); +// New way of calling `authenticate`. +Future authenticate( + localizedReason: 'localized reason', + authMessages: const [ + IOSAuthMessages(), + AndroidAuthMessages() + ], + options: const AuthenticationOptions( + useErrorDialogs: true, + stickyAuth: false, + sensitiveTransaction: true, + biometricOnly: false, + ), +); +``` + + ## 1.1.11 diff --git a/packages/local_auth/local_auth/example/lib/main.dart b/packages/local_auth/local_auth/example/lib/main.dart index 786f54a09564..92ad7cf4fb3f 100644 --- a/packages/local_auth/local_auth/example/lib/main.dart +++ b/packages/local_auth/local_auth/example/lib/main.dart @@ -78,7 +78,7 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.requestAuthentication( + authenticated = await auth.authenticate( localizedReason: 'Let OS determine authentication method', options: const AuthenticationOptions( useErrorDialogs: true, @@ -111,7 +111,7 @@ class _MyAppState extends State { _isAuthenticating = true; _authorized = 'Authenticating'; }); - authenticated = await auth.requestAuthentication( + authenticated = await auth.authenticate( localizedReason: 'Scan your fingerprint (or face or whatever) to authenticate', options: const AuthenticationOptions( diff --git a/packages/local_auth/local_auth/lib/local_auth.dart b/packages/local_auth/local_auth/lib/local_auth.dart index 13ec38df34c7..7c42fedc7755 100644 --- a/packages/local_auth/local_auth/lib/local_auth.dart +++ b/packages/local_auth/local_auth/lib/local_auth.dart @@ -3,19 +3,6 @@ // found in the LICENSE file. export 'package:local_auth/src/local_auth.dart' show LocalAuthentication; - -// TODO(BeMacized): This should be removed the next time a breaking change -// occurs and LocalAuth#authenticate is removed. Packages will be expected -// to depend on the platform specific packages directly if they wish to use -// these classes. -export 'package:local_auth_android/types/auth_messages_android.dart' - show AndroidAuthMessages; -// TODO(BeMacized): This should be removed the next time a breaking change -// occurs and LocalAuth#authenticate is removed. Packages will be expected -// to depend on the platform specific packages directly if they wish to use -// these classes. -export 'package:local_auth_ios/types/auth_messages_ios.dart' - show IOSAuthMessages; export 'package:local_auth_platform_interface/types/auth_options.dart' show AuthenticationOptions; export 'package:local_auth_platform_interface/types/biometric_type.dart' diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart index 3586d2f49bdd..beee8f6932e1 100644 --- a/packages/local_auth/local_auth/lib/src/local_auth.dart +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -20,100 +20,8 @@ import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; import 'package:platform/platform.dart'; -Platform _platform = const LocalPlatform(); - -@visibleForTesting -void setMockPathProviderPlatform(Platform platform) { - _platform = platform; -} - /// A Flutter plugin for authenticating the user identity locally. class LocalAuthentication { - /// The `authenticateWithBiometrics` method has been deprecated. - /// Use `requestAuthentication` with `biometricOnly: true` on the - /// `options` parameter instead. - @Deprecated( - 'Use `requestAuthentication` with `biometricOnly: true` on the `options` parameter instead') - Future authenticateWithBiometrics({ - required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, - AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), - IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), - bool sensitiveTransaction = true, - }) => - requestAuthentication( - localizedReason: localizedReason, - authMessages: [iOSAuthStrings, androidAuthStrings], - options: AuthenticationOptions( - useErrorDialogs: useErrorDialogs, - stickyAuth: stickyAuth, - sensitiveTransaction: sensitiveTransaction, - biometricOnly: true, - ), - ); - - /// Authenticates the user with biometrics available on the device while also - /// allowing the user to use device authentication - pin, pattern, passcode. - /// - /// Returns true, if the user successfully authenticated, false otherwise. - /// - /// [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.'. This must not be empty. - /// - /// [useErrorDialogs] = true means the system will attempt to handle user - /// fixable issues encountered while authenticating. For instance, if - /// fingerprint reader exists on the phone but there's no fingerprint - /// registered, the plugin will attempt to take the user to settings to add - /// one. Anything that is not user fixable, such as no biometric sensor on - /// device, will be returned as a [PlatformException]. - /// - /// [stickyAuth] is used when the application goes into background for any - /// reason while the authentication is in progress. Due to security reasons, - /// the authentication has to be stopped at that time. If stickyAuth is set - /// to true, authentication resumes when the app is resumed. If it is set to - /// false (default), then as soon as app is paused a failure message is sent - /// back to Dart and it is up to the client app to restart authentication or - /// do something else. - /// - /// Construct [AndroidAuthStrings] and [IOSAuthStrings] if you want to - /// customize messages in the dialogs. - /// - /// Setting [sensitiveTransaction] to true enables platform specific - /// precautions. For instance, on face unlock, Android opens a confirmation - /// dialog after the face is recognized to make sure the user meant to unlock - /// their phone. - /// - /// Setting [biometricOnly] to true prevents authenticates from using non-biometric - /// local authentication such as pin, passcode, and passcode. - /// - /// Throws an [PlatformException] if there were technical problems with local - /// authentication (e.g. lack of relevant hardware). This might throw - /// [PlatformException] with error code [otherOperatingSystem] on the iOS - /// simulator. - @Deprecated('Use `requestAuthentication` instead.') - Future authenticate({ - required String localizedReason, - bool useErrorDialogs = true, - bool stickyAuth = false, - AndroidAuthMessages androidAuthStrings = const AndroidAuthMessages(), - IOSAuthMessages iOSAuthStrings = const IOSAuthMessages(), - bool sensitiveTransaction = true, - bool biometricOnly = false, - }) { - return requestAuthentication( - localizedReason: localizedReason, - authMessages: [iOSAuthStrings, androidAuthStrings], - options: AuthenticationOptions( - useErrorDialogs: useErrorDialogs, - stickyAuth: stickyAuth, - sensitiveTransaction: sensitiveTransaction, - biometricOnly: biometricOnly, - ), - ); - } - /// Authenticates the user with biometrics available on the device while also /// allowing the user to use device authentication - pin, pattern, passcode. /// @@ -132,7 +40,7 @@ class LocalAuthentication { /// authentication (e.g. lack of relevant hardware). This might throw /// [PlatformException] with error code [otherOperatingSystem] on the iOS /// simulator. - Future requestAuthentication( + Future authenticate( {required String localizedReason, Iterable authMessages = const [ IOSAuthMessages(), @@ -148,14 +56,12 @@ class LocalAuthentication { /// Returns true if auth was cancelled successfully. /// This api only works for Android. - /// Returns false if there was some error or no auth in progress. + /// Returns false if there was some error, no authentication in progress, + /// or the current platform lacks support. /// /// Returns [Future] bool true or false: Future stopAuthentication() async { - if (_platform.isAndroid) { - return LocalAuthPlatform.instance.stopAuthentication(); - } - return true; + return LocalAuthPlatform.instance.stopAuthentication(); } /// Returns true if device is capable of checking biometrics diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index d99dc554adf3..081da9e75bc6 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -22,9 +22,10 @@ dependencies: sdk: flutter intl: ^0.17.0 local_auth_android: ^1.0.0 - local_auth_ios: ^ 1.0.0 + # TODO(BeMacized): Require 1.0.1 minimum once version is published (https://github.com/flutter/plugins/pull/5249) +# local_auth_ios: ^1.0.1 + local_auth_ios: ^1.0.0 local_auth_platform_interface: ^1.0.1 - platform: ^3.0.0 dev_dependencies: flutter_driver: diff --git a/packages/local_auth/local_auth/test/local_auth_test.dart b/packages/local_auth/local_auth/test/local_auth_test.dart index decc44fe03db..d3f92dfe95db 100644 --- a/packages/local_auth/local_auth/test/local_auth_test.dart +++ b/packages/local_auth/local_auth/test/local_auth_test.dart @@ -6,11 +6,12 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:local_auth/local_auth.dart'; import 'package:local_auth/src/local_auth.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_ios/local_auth_ios.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/auth_options.dart'; import 'package:mockito/mockito.dart'; -import 'package:platform/platform.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; void main() { @@ -24,24 +25,6 @@ void main() { LocalAuthPlatform.instance = mockLocalAuthPlatform; }); - test('authenticateWithBiometrics calls platform implementation', () { - when(mockLocalAuthPlatform.authenticate( - localizedReason: anyNamed('localizedReason'), - authMessages: anyNamed('authMessages'), - options: anyNamed('options'), - )).thenAnswer((_) async => true); - localAuthentication.authenticateWithBiometrics( - localizedReason: 'Test Reason'); - verify(mockLocalAuthPlatform.authenticate( - localizedReason: 'Test Reason', - authMessages: [ - const IOSAuthMessages(), - const AndroidAuthMessages(), - ], - options: const AuthenticationOptions(biometricOnly: true), - )).called(1); - }); - test('authenticate calls platform implementation', () { when(mockLocalAuthPlatform.authenticate( localizedReason: anyNamed('localizedReason'), @@ -73,20 +56,13 @@ void main() { verify(mockLocalAuthPlatform.getEnrolledBiometrics()).called(1); }); - test('stopAuthentication calls platform implementation on Android', () { + test('stopAuthentication calls platform implementation', () { when(mockLocalAuthPlatform.stopAuthentication()) .thenAnswer((_) async => true); - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'android')); localAuthentication.stopAuthentication(); verify(mockLocalAuthPlatform.stopAuthentication()).called(1); }); - test('stopAuthentication does not call platform implementation on iOS', () { - setMockPathProviderPlatform(FakePlatform(operatingSystem: 'ios')); - localAuthentication.stopAuthentication(); - verifyNever(mockLocalAuthPlatform.stopAuthentication()); - }); - test('canCheckBiometrics returns correct result', () async { when(mockLocalAuthPlatform.deviceSupportsBiometrics()) .thenAnswer((_) async => false); @@ -110,11 +86,8 @@ class MockLocalAuthPlatform extends Mock @override Future authenticate({ - String? localizedReason, - Iterable? authMessages = const [ - IOSAuthMessages(), - AndroidAuthMessages() - ], + required String? localizedReason, + required Iterable? authMessages, AuthenticationOptions? options = const AuthenticationOptions(), }) => super.noSuchMethod( From 1d47b0f2090b1b29185844bbb58a62ddd42ae3e2 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 14 Apr 2022 09:02:27 +0200 Subject: [PATCH 51/53] Update dependency version --- packages/local_auth/local_auth/pubspec.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/local_auth/local_auth/pubspec.yaml b/packages/local_auth/local_auth/pubspec.yaml index 081da9e75bc6..fa055fab17f8 100644 --- a/packages/local_auth/local_auth/pubspec.yaml +++ b/packages/local_auth/local_auth/pubspec.yaml @@ -22,9 +22,7 @@ dependencies: sdk: flutter intl: ^0.17.0 local_auth_android: ^1.0.0 - # TODO(BeMacized): Require 1.0.1 minimum once version is published (https://github.com/flutter/plugins/pull/5249) -# local_auth_ios: ^1.0.1 - local_auth_ios: ^1.0.0 + local_auth_ios: ^1.0.1 local_auth_platform_interface: ^1.0.1 dev_dependencies: From 546fd6dc69ea2dd06ff6e4fdcb5f08e0af9628ac Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 14 Apr 2022 09:06:17 +0200 Subject: [PATCH 52/53] Fix analysis issue --- packages/local_auth/local_auth/lib/src/local_auth.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart index beee8f6932e1..2e28f1513e0e 100644 --- a/packages/local_auth/local_auth/lib/src/local_auth.dart +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -10,7 +10,6 @@ import 'dart:async'; -import 'package:flutter/foundation.dart' show visibleForTesting; import 'package:flutter/services.dart'; import 'package:local_auth/src/types/error_codes.dart'; import 'package:local_auth_android/local_auth_android.dart'; @@ -18,7 +17,6 @@ import 'package:local_auth_ios/local_auth_ios.dart'; import 'package:local_auth_platform_interface/local_auth_platform_interface.dart'; import 'package:local_auth_platform_interface/types/auth_messages.dart'; import 'package:local_auth_platform_interface/types/biometric_type.dart'; -import 'package:platform/platform.dart'; /// A Flutter plugin for authenticating the user identity locally. class LocalAuthentication { From ae420e68b55cb99c43e56aa48c132eed2844e982 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Thu, 14 Apr 2022 16:56:33 +0200 Subject: [PATCH 53/53] Process PR feedback --- packages/local_auth/local_auth/CHANGELOG.md | 48 ++++++++++--------- .../local_auth/lib/src/local_auth.dart | 25 ++++------ 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/packages/local_auth/local_auth/CHANGELOG.md b/packages/local_auth/local_auth/CHANGELOG.md index a1286496267b..deac871d935f 100644 --- a/packages/local_auth/local_auth/CHANGELOG.md +++ b/packages/local_auth/local_auth/CHANGELOG.md @@ -2,37 +2,39 @@ * Migrates plugin to federated architecture. * Adds OS version support information to README. -* BREAKING CHANGE: Deprecated method `authenticateWithBiometrics` has been removed +* BREAKING CHANGE: Deprecated method `authenticateWithBiometrics` has been removed. Use `authenticate` instead. +* BREAKING CHANGE: Enum `BiometricType` has been expanded with options for `strong` and `weak`, + and applications should be updated to handle these accordingly. * BREAKING CHANGE: Parameters of `authenticate` have been changed. Example: -```dart -// Old way of calling `authenticate`. -Future authenticate( - localizedReason: 'localized reason', - useErrorDialogs: true, - stickyAuth: false, - androidAuthStrings: const AndroidAuthMessages(), - iOSAuthStrings: const IOSAuthMessages(), - sensitiveTransaction: true, - biometricOnly: false, -); -// New way of calling `authenticate`. -Future authenticate( - localizedReason: 'localized reason', - authMessages: const [ - IOSAuthMessages(), - AndroidAuthMessages() - ], - options: const AuthenticationOptions( + ```dart + // Old way of calling `authenticate`. + Future authenticate( + localizedReason: 'localized reason', useErrorDialogs: true, stickyAuth: false, + androidAuthStrings: const AndroidAuthMessages(), + iOSAuthStrings: const IOSAuthMessages(), sensitiveTransaction: true, biometricOnly: false, - ), -); -``` + ); + // New way of calling `authenticate`. + Future authenticate( + localizedReason: 'localized reason', + authMessages: const [ + IOSAuthMessages(), + AndroidAuthMessages() + ], + options: const AuthenticationOptions( + useErrorDialogs: true, + stickyAuth: false, + sensitiveTransaction: true, + biometricOnly: false, + ), + ); + ``` diff --git a/packages/local_auth/local_auth/lib/src/local_auth.dart b/packages/local_auth/local_auth/lib/src/local_auth.dart index 2e28f1513e0e..508e2b14e129 100644 --- a/packages/local_auth/local_auth/lib/src/local_auth.dart +++ b/packages/local_auth/local_auth/lib/src/local_auth.dart @@ -26,8 +26,8 @@ class LocalAuthentication { /// Returns true if the user successfully authenticated, false otherwise. /// /// [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.'. This must not be empty. + /// for authentication. This is typically along the lines of: 'Authenticate + /// to access MyApp.'. This must not be empty. /// /// Provide [authMessages] if you want to /// customize messages in the dialogs. @@ -52,35 +52,26 @@ class LocalAuthentication { ); } - /// Returns true if auth was cancelled successfully. - /// This api only works for Android. + /// Cancels any in-progress authentication, returning true if auth was + /// cancelled successfully. + /// + /// This API is not supported by all platforms. /// Returns false if there was some error, no authentication in progress, /// or the current platform lacks support. - /// - /// Returns [Future] bool true or false: Future stopAuthentication() async { return LocalAuthPlatform.instance.stopAuthentication(); } - /// Returns true if device is capable of checking biometrics - /// - /// Returns a [Future] bool true or false: + /// Returns true if device is capable of checking biometrics. Future get canCheckBiometrics => LocalAuthPlatform.instance.deviceSupportsBiometrics(); /// Returns true if device is capable of checking biometrics or is able to /// fail over to device credentials. - /// - /// Returns a [Future] bool true or false: Future isDeviceSupported() async => LocalAuthPlatform.instance.isDeviceSupported(); - /// Returns a list of enrolled biometrics - /// - /// Returns a [Future] List with the following possibilities: - /// - BiometricType.face - /// - BiometricType.fingerprint - /// - BiometricType.iris (not yet implemented) + /// Returns a list of enrolled biometrics. Future> getAvailableBiometrics() => LocalAuthPlatform.instance.getEnrolledBiometrics(); }