version bump to 3.13.9, auth working on mac

This commit is contained in:
Matthew Fosse 2024-04-05 10:11:54 -07:00
parent 7eed97718e
commit 0043a91d03
9 changed files with 117 additions and 28 deletions

View file

@ -1,32 +1,34 @@
import 'package:local_auth/local_auth.dart';
// import 'package:local_auth/local_auth.dart';
import 'package:flutter/services.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter_local_authentication/flutter_local_authentication.dart';
class BiometricAuth {
final _localAuth = LocalAuthentication();
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
Future<bool> isAuthenticated() async {
try {
return await _localAuth.authenticate(
localizedReason: S.current.biometric_auth_reason,
options: AuthenticationOptions(
biometricOnly: true,
useErrorDialogs: true,
stickyAuth: false));
final authenticated = await _flutterLocalAuthenticationPlugin.authenticate();
return authenticated;
} on PlatformException catch (e) {
print(e);
}
return false;
}
Future<bool> canCheckBiometrics() async {
bool canAuthenticate;
try {
return await _localAuth.canCheckBiometrics;
} on PlatformException catch (e) {
print(e);
canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();
// Setup TouchID Allowable Reuse duration
// It works only in iOS and macOS, but it's safe to call it even on other platforms.
await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(30);
} on Exception catch (error) {
print("Exception checking support. $error");
canAuthenticate = false;
}
return false;
return canAuthenticate;
}
}

View file

@ -751,6 +751,34 @@ class HaMaterialLocalizations extends GlobalMaterialLocalizations {
@override
String get scrimOnTapHintRaw => "Scrip on Tap";
@override
// TODO: implement collapsedHint
String get collapsedHint => throw UnimplementedError();
@override
// TODO: implement expandedHint
String get expandedHint => throw UnimplementedError();
@override
// TODO: implement expansionTileCollapsedHint
String get expansionTileCollapsedHint => throw UnimplementedError();
@override
// TODO: implement expansionTileCollapsedTapHint
String get expansionTileCollapsedTapHint => throw UnimplementedError();
@override
// TODO: implement expansionTileExpandedHint
String get expansionTileExpandedHint => throw UnimplementedError();
@override
// TODO: implement expansionTileExpandedTapHint
String get expansionTileExpandedTapHint => throw UnimplementedError();
@override
// TODO: implement scanTextButtonLabel
String get scanTextButtonLabel => throw UnimplementedError();
}
/// Cupertino Support

View file

@ -751,6 +751,34 @@ String get keyboardKeyMetaWindows => 'Windows';
@override
String get scrimOnTapHintRaw => "Scrip on Tap";
@override
// TODO: implement collapsedHint
String get collapsedHint => throw UnimplementedError();
@override
// TODO: implement expandedHint
String get expandedHint => throw UnimplementedError();
@override
// TODO: implement expansionTileCollapsedHint
String get expansionTileCollapsedHint => throw UnimplementedError();
@override
// TODO: implement expansionTileCollapsedTapHint
String get expansionTileCollapsedTapHint => throw UnimplementedError();
@override
// TODO: implement expansionTileExpandedHint
String get expansionTileExpandedHint => throw UnimplementedError();
@override
// TODO: implement expansionTileExpandedTapHint
String get expansionTileExpandedTapHint => throw UnimplementedError();
@override
// TODO: implement scanTextButtonLabel
String get scanTextButtonLabel => throw UnimplementedError();
}
/// Cupertino Support
@ -955,4 +983,11 @@ String get todayLabel => 'Oyọ';
@override
String get noSpellCheckReplacementsLabel => "";
// @override
// String get clearButtonLabel => '';
// - CupertinoLocalizations.lookUpButtonLabel
// - CupertinoLocalizations.menuDismissLabel
// - CupertinoLocalizations.searchWebButtonLabel
// - CupertinoLocalizations.shareButtonLabel
}

View file

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
import 'package:cake_wallet/routes.dart';
@ -58,7 +60,7 @@ class SecurityBackupPage extends BasePage {
.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
),
),
if (DeviceInfo.instance.isMobile)
if (DeviceInfo.instance.isMobile || Platform.isMacOS || Platform.isLinux)
Observer(builder: (_) {
return SettingsSwitcherCell(
title: S.current.settings_allow_biometrical_authentication,

View file

@ -146,7 +146,7 @@ class ConnectScreen extends StatelessWidget {
ElevatedButton(
onPressed: connect,
style: ElevatedButton.styleFrom(
primary: Colors.blue,
// primary: Colors.blue,
padding: EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
@ -211,7 +211,7 @@ class DisconnectScreen extends StatelessWidget {
ElevatedButton(
onPressed: disconnect,
style: ElevatedButton.styleFrom(
primary: Colors.red,
// primary: Colors.red,
padding: EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),

View file

@ -2,7 +2,30 @@ import 'package:cake_wallet/core/seed_validator.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
class Annotation extends Comparable<Annotation> {
abstract interface class ComparableCopy<T> {
/// Compares this object to another object.
///
/// Returns a value like a [Comparator] when comparing `this` to [other].
/// That is, it returns a negative integer if `this` is ordered before [other],
/// a positive integer if `this` is ordered after [other],
/// and zero if `this` and [other] are ordered together.
///
/// The [other] argument must be a value that is comparable to this object.
int compareTo(T other);
/// A [Comparator] that compares one comparable to another.
///
/// It returns the result of `a.compareTo(b)`.
/// The call may fail at run-time
/// if `a` is not comparable to the type of `b`.
///
/// This utility function is used as the default comparator
/// for ordering collections, for example in the [List] sort function.
static int compare(Comparable a, Comparable b) => a.compareTo(b);
}
class Annotation extends ComparableCopy<Annotation> {
Annotation({required this.range, required this.style});
final TextRange range;
@ -12,7 +35,7 @@ class Annotation extends Comparable<Annotation> {
int compareTo(Annotation other) => range.start.compareTo(other.range.start);
}
class TextAnnotation extends Comparable<TextAnnotation> {
class TextAnnotation extends ComparableCopy<TextAnnotation> {
TextAnnotation({required this.text, required this.style});
final TextStyle style;

View file

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_local_authentication/flutter_local_authentication.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/view_model/auth_state.dart';
@ -105,16 +106,14 @@ abstract class AuthViewModelBase with Store {
@action
Future<void> biometricAuth() async {
final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();
try {
final canBiometricAuth = await _biometricAuth.canCheckBiometrics();
if (canBiometricAuth) {
final isAuthenticated = await _biometricAuth.isAuthenticated();
if (isAuthenticated) {
state = ExecutedSuccessfullyState();
}
final authenticated = await _flutterLocalAuthenticationPlugin.authenticate();
if (!authenticated) {
throw Exception('Biometric authentication failed');
}
state = ExecutedSuccessfullyState();
} catch (e) {
state = FailureState(e.toString());
}

View file

@ -33,8 +33,8 @@ dependencies:
dio: ^4.0.6
hive: ^2.2.3
hive_flutter: ^1.1.0
local_auth: ^2.1.0
local_auth_android: 1.0.21
flutter_local_authentication: ^1.2.0
package_info: ^2.0.0
#package_info_plus: ^1.4.2
devicelocale:

View file

@ -4,4 +4,4 @@ version: 0.0.0
publish_to: none
environment:
sdk: ">=2.17.5 <3.0.0"
sdk: ">=3.1.0 <4.0.0"