Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7ccd968
[local_auth] Windows support.
azchohfi Jan 27, 2022
3906da5
Merge branch 'main' into local_auth_windows
azchohfi Feb 17, 2022
70c341d
Merge branch 'main' into local_auth_windows
azchohfi Feb 23, 2022
c492f89
Merge branch 'main' into local_auth_windows
azchohfi Feb 24, 2022
c997ad8
Handling biometricOnly parameter.
azchohfi Feb 25, 2022
9cf0a1a
Merge branch 'main' into local_auth_windows
azchohfi Apr 7, 2022
975ca8d
Fixed readme
azchohfi Apr 7, 2022
3fcbca7
[local_auth] Fix version and readme.
azchohfi Apr 8, 2022
34afbf5
Merge branch 'main' into local_auth_windows
azchohfi Apr 15, 2022
835f5cc
[local_auth] Small fixes.
azchohfi Apr 15, 2022
9eaba3c
Small fix.
azchohfi Apr 15, 2022
22ec14c
Fixed tests.
azchohfi Apr 15, 2022
9349aab
Added local_auth_windows tests.
azchohfi Apr 15, 2022
1032693
PR Feedback.
azchohfi Apr 18, 2022
1659e49
Merge branch 'local_auth_windows' of https://github.com/azchohfi/plug…
azchohfi Apr 18, 2022
8c7a87b
Fixed tests.
azchohfi Apr 18, 2022
bf47529
Added more tests.
azchohfi Apr 18, 2022
8143983
Revert changes in local_auth.
azchohfi Apr 19, 2022
bcf105b
Merge branch 'main' into local_auth_windows
azchohfi Apr 25, 2022
a4f02f4
Merge branch 'main' into local_auth_windows
azchohfi Apr 26, 2022
7449a5c
Merge branch 'main' into local_auth_windows
azchohfi May 9, 2022
fb26c93
Merge branch 'main' into local_auth_windows
azchohfi May 10, 2022
e9ab4ef
[local_auth_windows] Fixed authors list.
azchohfi May 10, 2022
30f0958
[local_auth_windows] Fixed changelog.
azchohfi May 10, 2022
97e1ee9
[local_auth_windows] PR feedback.
azchohfi May 12, 2022
40aa9a2
Merge branch 'main' into local_auth_windows
azchohfi May 12, 2022
6813b7b
Fixed build
azchohfi May 13, 2022
47823c6
Fixed format.
azchohfi May 13, 2022
45ceb6e
Merge branch 'main' into local_auth_windows
azchohfi May 13, 2022
271a49e
Applied more PR feedback.
azchohfi May 13, 2022
e1e24a6
Added C++ comments.
azchohfi May 13, 2022
cabc43e
Small doc fixes.
azchohfi May 13, 2022
34a58de
Merge branch 'main' into local_auth_windows
azchohfi May 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into local_auth_windows
  • Loading branch information
azchohfi committed Apr 15, 2022
commit 34afbf563928d2a3d3d7fb38d52b4de0804f33a8
39 changes: 38 additions & 1 deletion packages/local_auth/local_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
## NEXT
* Adds Windows support.

## 2.0.0

* Migrates plugin to federated architecture.
* Adds OS version support information to README.
* Added Windows support.
* 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<bool> authenticate(
localizedReason: 'localized reason',
useErrorDialogs: true,
stickyAuth: false,
androidAuthStrings: const AndroidAuthMessages(),
iOSAuthStrings: const IOSAuthMessages(),
sensitiveTransaction: true,
biometricOnly: false,
);
// New way of calling `authenticate`.
Future<bool> authenticate(
localizedReason: 'localized reason',
authMessages: const <AuthMessages>[
IOSAuthMessages(),
AndroidAuthMessages()
],
options: const AuthenticationOptions(
useErrorDialogs: true,
stickyAuth: false,
sensitiveTransaction: true,
biometricOnly: false,
),
);
```



## 1.1.11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
local_auth
local_auth_windows
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
184 changes: 5 additions & 179 deletions packages/local_auth/local_auth/lib/local_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,182 +2,8 @@
// 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<bool> 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<bool> 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<String, Object> args = <String, Object>{
'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 if (!_platform.isWindows) {
throw PlatformException(
code: otherOperatingSystem,
message:
'Local authentication does not support non-Android/iOS/Windows '
'operating systems.',
details: 'Your operating system is ${_platform.operatingSystem}',
);
}
return (await _channel.invokeMethod<bool>('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<bool> stopAuthentication() async {
if (_platform.isAndroid) {
return await _channel.invokeMethod<bool>('stopAuthentication') ?? false;
}
return true;
}

/// Returns true if device is capable of checking biometrics
///
/// Returns a [Future] bool true or false:
Future<bool> get canCheckBiometrics async =>
(await _channel.invokeListMethod<String>('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<bool> isDeviceSupported() async =>
(await _channel.invokeMethod<bool>('isDeviceSupported')) ?? false;

/// Returns a list of enrolled biometrics
///
/// Returns a [Future] List<BiometricType> with the following possibilities:
/// - BiometricType.face
/// - BiometricType.fingerprint
/// - BiometricType.iris (not yet implemented)
Future<List<BiometricType>> getAvailableBiometrics() async {
final List<String> result = (await _channel.invokeListMethod<String>(
'getAvailableBiometrics',
)) ??
<String>[];
final List<BiometricType> biometrics = <BiometricType>[];
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/auth_options.dart'
show AuthenticationOptions;
export 'package:local_auth_platform_interface/types/biometric_type.dart'
show BiometricType;
Original file line number Diff line number Diff line change
Expand Up @@ -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, Android or Windows.
/// Indicates the device operating system is unsupported.
const String otherOperatingSystem = 'OtherOperatingSystem';

/// Indicates the API lock out due to too many attempts.
Expand Down
5 changes: 3 additions & 2 deletions packages/local_auth/local_auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ flutter:
android:
default_package: local_auth_android
ios:
pluginClass: FLTLocalAuthPlugin
default_package: local_auth_ios
windows:
pluginClass: LocalAuthPlugin
default_package: local_auth_windows

dependencies:
flutter:
sdk: flutter
intl: ^0.17.0
local_auth_android: ^1.0.0
local_auth_ios: ^1.0.1
local_auth_windows: ^1.0.0
local_auth_platform_interface: ^1.0.1

dev_dependencies:
Expand Down
67 changes: 67 additions & 0 deletions packages/local_auth/local_auth_windows/AUTHORS
Original file line number Diff line number Diff line change
@@ -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 <email address>

Google Inc.
The Chromium Authors
German Saprykin <[email protected]>
Benjamin Sauer <[email protected]>
[email protected]
Ali Bitek <[email protected]>
Pol Batlló <[email protected]>
Anatoly Pulyaevskiy
Hayden Flinner <[email protected]>
Stefano Rodriguez <[email protected]>
Salvatore Giordano <[email protected]>
Brian Armstrong <[email protected]>
Paul DeMarco <[email protected]>
Fabricio Nogueira <[email protected]>
Simon Lightfoot <[email protected]>
Ashton Thomas <[email protected]>
Thomas Danner <[email protected]>
Diego Velásquez <[email protected]>
Hajime Nakamura <[email protected]>
Tuyển Vũ Xuân <[email protected]>
Miguel Ruivo <[email protected]>
Sarthak Verma <[email protected]>
Mike Diarmid <[email protected]>
Invertase <[email protected]>
Elliot Hesp <[email protected]>
Vince Varga <[email protected]>
Aawaz Gyawali <[email protected]>
EUI Limited <[email protected]>
Katarina Sheremet <[email protected]>
Thomas Stockx <[email protected]>
Sarbagya Dhaubanjar <[email protected]>
Ozkan Eksi <[email protected]>
Rishab Nayak <[email protected]>
ko2ic <[email protected]>
Jonathan Younger <[email protected]>
Jose Sanchez <[email protected]>
Debkanchan Samadder <[email protected]>
Audrius Karosevicius <[email protected]>
Lukasz Piliszczuk <[email protected]>
SoundReply Solutions GmbH <[email protected]>
Rafal Wachol <[email protected]>
Pau Picas <[email protected]>
Christian Weder <[email protected]>
Alexandru Tuca <[email protected]>
Christian Weder <[email protected]>
Rhodes Davis Jr. <[email protected]>
Luigi Agosti <[email protected]>
Quentin Le Guennec <[email protected]>
Koushik Ravikumar <[email protected]>
Nissim Dsilva <[email protected]>
Giancarlo Rocha <[email protected]>
Ryo Miyake <[email protected]>
Théo Champion <[email protected]>
Kazuki Yamaguchi <[email protected]>
Eitan Schwartz <[email protected]>
Chris Rutkowski <[email protected]>
Juan Alvarez <[email protected]>
Aleksandr Yurkovskiy <[email protected]>
Anton Borries <[email protected]>
Alex Li <[email protected]>
Rahul Raj <[email protected]>
Bodhi Mulders <[email protected]>
3 changes: 3 additions & 0 deletions packages/local_auth/local_auth_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

* Initial release from migration to federated architecture.
25 changes: 25 additions & 0 deletions packages/local_auth/local_auth_windows/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions packages/local_auth/local_auth_windows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# local\_auth\_windows

The Windows 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
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.