-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[local_auth] Migrate iOS to Pigeon #3974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
auto-submit
merged 15 commits into
flutter:main
from
stuartmorgan-g:local-auth-ios-pigeon
May 19, 2023
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
086e8ad
Remove useless check
stuartmorgan-g 093b0a2
Add todo for incorrect implementation to mark it as staying native
stuartmorgan-g 5b7888b
Initial Pigeon definition, modified from Android
stuartmorgan-g 10a3ab4
Adjust native implementation to conform to Pigeon API, adjusting Pige…
stuartmorgan-g e6a6a61
Update native tests, add missing test
stuartmorgan-g a97c41a
Update Dart implmeentation, modeled on Android
stuartmorgan-g ecd6e93
Replace Dart unit tests, based on Android
stuartmorgan-g 99c2963
Version bump
stuartmorgan-g 6bd50db
Autoformat
stuartmorgan-g 830a8df
Typo fix
stuartmorgan-g 167c018
Merge branch 'main' into local-auth-ios-pigeon
stuartmorgan-g 9794851
Typo fix
stuartmorgan-g 99f60e9
Rename result enum field
stuartmorgan-g 933c0d4
Other review fixes
stuartmorgan-g 3e707a8
Fix call sites
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Initial Pigeon definition, modified from Android
- Loading branch information
commit 5b7888b5e747c9247ad0f1d4e1bbf32073872bd3
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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. |
101 changes: 101 additions & 0 deletions
101
packages/local_auth/local_auth_ios/pigeons/messages.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // 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:pigeon/pigeon.dart'; | ||
|
|
||
| @ConfigurePigeon(PigeonOptions( | ||
| dartOut: 'lib/src/messages.g.dart', | ||
| objcHeaderOut: 'ios/Classes/messages.g.h', | ||
| objcSourceOut: 'ios/Classes/messages.g.m', | ||
| objcOptions: ObjcOptions( | ||
| prefix: 'FLA', | ||
| ), | ||
| copyrightHeader: 'pigeons/copyright.txt', | ||
| )) | ||
|
|
||
| /// Pigeon version of IOSAuthMessages, plus the authorization reason. | ||
| /// | ||
| /// See auth_messages_ios.dart for details. | ||
| class AuthStrings { | ||
| /// Constructs a new instance. | ||
| const AuthStrings({ | ||
| required this.reason, | ||
| required this.lockOut, | ||
| required this.goToSettingsButton, | ||
| required this.goToSettingsDescription, | ||
| required this.cancelButton, | ||
| required this.localizedFallbackTitle, | ||
| }); | ||
|
|
||
| final String reason; | ||
| final String lockOut; | ||
| final String goToSettingsButton; | ||
| final String goToSettingsDescription; | ||
| final String cancelButton; | ||
| final String localizedFallbackTitle; | ||
| } | ||
|
|
||
| /// Possible outcomes of an authentication attempt. | ||
| enum AuthResult { | ||
| /// The user authenticated successfully. | ||
| success, | ||
|
|
||
| /// The user failed to successfully authenticate. | ||
| failure, | ||
|
|
||
| /// The authentication system was not available. | ||
| errorNotAvailable, | ||
|
|
||
| /// No biometrics are enrolled. | ||
| errorNotEnrolled, | ||
|
|
||
| /// No passcode is set. | ||
| errorPasscodeNotSet, | ||
| } | ||
|
|
||
| class AuthOptions { | ||
| AuthOptions( | ||
| {required this.biometricOnly, | ||
| required this.sticky, | ||
| required this.useErrorDialgs}); | ||
| final bool biometricOnly; | ||
| final bool sticky; | ||
| final bool useErrorDialgs; | ||
| } | ||
|
|
||
| // TODO(stuartmorgan): Remove this when | ||
| // https://github.com/flutter/flutter/issues/87307 is implemented. | ||
| class AuthResultWrapper { | ||
| AuthResultWrapper({required this.value}); | ||
| final AuthResult value; | ||
| } | ||
|
|
||
| /// Pigeon equivalent of the subset of BiometricType used by iOS. | ||
| enum AuthBiometrics { weak, strong } | ||
|
|
||
| // TODO(stuartmorgan): Remove this when | ||
| // https://github.com/flutter/flutter/issues/87307 is implemented. | ||
| class AuthClassificationWrapper { | ||
| AuthClassificationWrapper({required this.value}); | ||
| final AuthBiometrics value; | ||
| } | ||
|
|
||
| @HostApi() | ||
| abstract class LocalAuthApi { | ||
| /// Returns true if this device supports authentication. | ||
| bool isDeviceSupported(); | ||
|
|
||
| /// Returns true if this device can support biometric authentication, whether | ||
| /// any biometrics are enrolled or not. | ||
| bool deviceCanSupportBiometrics(); | ||
|
|
||
| /// Returns the biometric types that are enrolled, and can thus be used | ||
| /// without additional setup. | ||
| List<AuthClassificationWrapper> getEnrolledBiometrics(); | ||
|
|
||
| /// Attempts to authenticate the user with the provided [options], and using | ||
| /// [strings] for any UI. | ||
| @async | ||
| AuthResultWrapper authenticate(AuthOptions options, AuthStrings strings); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.