tbib_biometric_storage 1.0.0+2
tbib_biometric_storage: ^1.0.0+2 copied to clipboard
Secure Storage: Encrypted data store optionally secured by biometric lock with support for iOS, Android
biometric_storage #
Encrypted file store, optionally secured by biometric lock for Android, iOS but android 5 not supported biometric but can use encrypt with random token
Meant as a way to store small data in a hardware encrypted fashion. E.g. to store passwords, secret keys, etc. but not massive amounts of data.
-
Android: Uses androidx with KeyStore. but android 5 not supported biometric but can use encrypt with random token
-
iOS LocalAuthentication with KeyChain.
Getting Started #
Installation #
Android
- Requirements:
-
Android: API Level >= 21 (android/app/build.gradle
minSdkVersion 21
) -
Make sure to use the latest kotlin version:
android/build.gradle
:ext.kotlin_version = '1.7.10'
with gradle:7.3.0- classpath 'com.android.tools.build:gradle:7.3.0'
-
MainActivity must extend FlutterFragmentActivity
-
Theme for the main activity must use
Theme.AppCompat
thme. (Otherwise there will be crases on Android < 29) For example:AndroidManifest.xml:
<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme">
xml/styles.xml:
<style name="LaunchTheme" parent="Theme.AppCompat.NoActionBar"> <!-- Show a splash screen on the activity. Automatically removed when Flutter draws its first frame --> <item name="android:windowBackground">@drawable/launch_background</item> <item name="android:windowNoTitle">true</item> <item name="android:windowActionBar">false</item> <item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item> </style>
-
Resources
- https://developer.android.com/topic/security/data
- https://developer.android.com/topic/security/best-practices
iOS
- include the NSFaceIDUsageDescription key in your app’s Info.plist file
- Requires at least iOS 9
Known Issue: since iOS 15 the simulator seem to no longer support local authentication: https://developer.apple.com/forums/thread/685773
Usage #
You basically only need 4 methods.
- Check whether biometric authentication is supported by the device
final bool isBioSupported = await BiometricStorage().canAuth();
- init AuthBio
TBIBAuth().init(
android: const AndroidAuthMessages(
cancelButton: "Cancel",
goToSettingsButton: "Settings",
goToSettingsDescription: "Please set up your Touch IDs .",
biometricHint: "Touch sensors",
biometricNotRecognized: "Fingerprint not recognizeds.",
deviceCredentialsRequiredTitle: "Fingerprint requireds",
deviceCredentialsSetupDescription:
"Please set up your Touch ID or Face IDs.",
),
ios: const IOSAuthMessages(
cancelButton: "Cancel",
goToSettingsButton: "Settings",
goToSettingsDescription: "Please set up your Touch ID.",
lockOut: "Please reenable your Touch ID"));
- need ask for auth before encrypt or decrypt data // need reason for auth
await BiometricStorage().auth("Login to save data");
- Write data // need send key , value
await BiometricStorage().write("Login", "data to save");
- Read data // need key
await BiometricStorage().read("Login");