Skip to content

Commit

Permalink
Merge pull request #179 from greaterking/2.0.0-biometricpromt-and-con…
Browse files Browse the repository at this point in the history
…sistent-callbacks

Use biometricpromt and more consistent callbacks
  • Loading branch information
NiklasMerz authored Nov 12, 2019
2 parents 5735838 + ccc8a47 commit 67e877d
Show file tree
Hide file tree
Showing 41 changed files with 660 additions and 1,379 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
node_modules/
package-lock.json
/.idea/$CACHE_FILE$
/.idea/.gitignore
/.idea/cordova-plugin-fingerprint-aio.iml
/.idea/misc.xml
/.idea/modules.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/vcs.xml
src/android/.project
63 changes: 44 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

## How to use

---

**[Tutorial about using this plugin with Ionic](https://www.youtube.com/watch?v=tQDChMJ6er8)** thanks to Paul Halliday

[Examples](https://github.com/NiklasMerz/fingerprint-aio-demo)
Expand Down Expand Up @@ -84,34 +82,59 @@ Fingerprint.isAvailable(isAvailableSuccess, isAvailableError);
alert("Fingerprint available");
}

function isAvailableError(message) {
// 'message' will be an object with an error code and message
console.log(message);
function isAvailableError(error) {
// 'error' will be an object with an error code and message
alert(error.message);
}
```

### Show authentication dialogue
```javascript
Fingerprint.show({
clientId: "Fingerprint-Demo", //Android: Used for encryption. iOS: used for dialogue if no `localizedReason` is given.
clientSecret: "o7aoOMYUbyxaD23oFAnJ" //Necessary for Android encrpytion of keys. Use random secret key.
description: "Some biometric description"
}, successCallback, errorCallback);

function successCallback(){
alert("Authentication successfull");
alert("Authentication successful");
}

function errorCallback(err){
alert("Authentication invalid " + err);
function errorCallback(error){
alert("Authentication invalid " + error.message);
}
```
**Optional parameters**

* __disableBackup__: If `true` remove backup option on authentication dialogue for Android. Default: `false`.
* __localizedFallbackTitle__ (iOS only): Title of fallback button.
* __localizedReason__ (iOS only): Description in authentication dialogue.

## Thanks to the authors of the original fingerprint plugins
### Optional parameters

* __title__: Title in authentication dialogue. Default: `"<APP_NAME> Biometric Sign On"`
* __subtitle__: Subtitle in authentication dialogue. Default: `null`
* __description__: Description in authentication dialogue. Defaults:
* iOS: `"Authenticate"` (iOS' [evaluatePolicy()](https://developer.apple.com/documentation/localauthentication/lacontext/1514176-evaluatepolicy?language=objc) requires this field)
* Android: `null`
* __fallbackButtonTitle__: Title of fallback button. Defaults:
* When **disableBackup** is true
* `"Cancel"`
* When **disableBackup** is false
* iOS: `"Use PIN"`
* Android: `"Use Backup"` (Because backup could be anything pin/pattern/password ..haven't figured out a reliable way to determine lock type yet [source](https://stackoverflow.com/questions/7768879/check-whether-lock-was-enabled-or-not/18720287))
* __disableBackup__: If `true` remove backup option on authentication dialogue. Default: `false`. This is useful if you want to implement your own fallback.
* __cancelButtonTitle__: For cancel button on Android

### Constants
- **BIOMETRIC_UNKNOWN_ERROR** = `-100`;
- **BIOMETRIC_UNAVAILABLE** = `-101`;
- **BIOMETRIC_AUTHENTICATION_FAILED** = `-102`;
- **BIOMETRIC_SDK_NOT_SUPPORTED** = `-103`;
- **BIOMETRIC_HARDWARE_NOT_SUPPORTED** = `-104`;
- **BIOMETRIC_PERMISSION_NOT_GRANTED** = `-105`;
- **BIOMETRIC_NOT_ENROLLED** = `-106`;
- **BIOMETRIC_INTERNAL_PLUGIN_ERROR** = `-107`;
- **BIOMETRIC_DISMISSED** = `-108`;
- **BIOMETRIC_PIN_OR_PATTERN_DISMISSED** = `-109`;
- **BIOMETRIC_SCREEN_GUARD_UNSECURED** = `-110`;
- **BIOMETRIC_LOCKED_OUT** = `-111`;
- **BIOMETRIC_LOCKED_OUT_PERMANENT** = `-112`;
***

Thanks to the authors of the original fingerprint plugins

Some code is refactored from their projects and I learned how to make Cordova plugins from their great plugins:

Expand All @@ -121,7 +144,9 @@ Some code is refactored from their projects and I learned how to make Cordova pl

[iOS](https://github.com/EddyVerbruggen/cordova-plugin-touch-id)

Starting with version 3.0.0 the iOS and Android parts are written from scratch.

## License

* Project and iOS source: [MIT](https://opensource.org/licenses/MIT)
* Android source: [MIT](https://opensource.org/licenses/MIT) and [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
The project is MIT licensed: [MIT](https://opensource.org/licenses/MIT).

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-fingerprint-aio",
"version": "2.0.0",
"version": "3.0.0",
"description": "Cordova plugin to use fingerprint authentication on Android and iOS",
"cordova": {
"id": "cordova-plugin-fingerprint-aio",
Expand Down Expand Up @@ -53,5 +53,12 @@
"test-saucelabs-ios": "npx cordova-paramedic --config ./pr/ios-10.0 --plugin $(pwd) --shouldUseSauce",
"test-saucelabs-android": "npx cordova-paramedic --config ./pr/android-7.0 --plugin $(pwd) --shouldUseSauce",
"plugin-version": "cordova-plugin-xml setVersion"
},
"engines": {
"cordovaDependencies": {
">=3.0.0": {
"cordova-android": ">=8.0.0"
}
}
}
}
53 changes: 23 additions & 30 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-fingerprint-aio" version="2.0.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-fingerprint-aio" version="3.0.0">
<name>FingerprintAllInOne</name>
<description>Cordova plugin to use fingerprint on Android and iOS</description>
<license>MIT</license>
Expand All @@ -11,7 +11,6 @@
<clobbers target="Fingerprint"/>
</js-module>



<!-- ios -->
<platform name="ios">
Expand All @@ -35,40 +34,34 @@
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Fingerprint">
<param name="android-package" value="de.niklasmerz.cordova.fingerprint.Fingerprint"/>
<param name="android-package" value="de.niklasmerz.cordova.biometric.Fingerprint"/>
</feature>
</config-file>

<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
</config-file>

<source-file src="src/android/Fingerprint.java" target-dir="src/de/niklasmerz/cordova/fingerprint"/>
<source-file src="src/android/FingerprintAuthenticationDialogFragment.java" target-dir="src/de/niklasmerz/cordova/fingerprint"/>
<source-file src="src/android/FingerprintUiHelper.java" target-dir="src/de/niklasmerz/cordova/fingerprint"/>
<source-file src="res/android/drawable/ic_aio_fingerprint_error.xml" target-dir="res/drawable"/>
<source-file src="res/android/drawable/ic_aio_fingerprint_success.xml" target-dir="res/drawable"/>
<resource-file src="res/android/drawable-hdpi/aio_ic_fp_40px.png" target="res/drawable-hdpi/aio_ic_fp_40px.png"/>
<resource-file src="res/android/drawable-mdpi/aio_ic_fp_40px.png" target="res/drawable-mdpi/aio_ic_fp_40px.png"/>
<resource-file src="res/android/drawable-nodpi/aio_android_robot.png" target="res/drawable-nodpi/aio_android_robot.png"/>
<resource-file src="res/android/drawable-xhdpi/aio_ic_fp_40px.png" target="res/drawable-xhdpi/aio_ic_fp_40px.png"/>
<resource-file src="res/android/drawable-xxhdpi/aio_ic_fp_40px.png" target="res/drawable-xxhdpi/aio_ic_fp_40px.png"/>
<resource-file src="res/android/drawable-xxxhdpi/aio_ic_fp_40px.png" target="res/drawable-xxxhdpi/aio_ic_fp_40px.png"/>
<source-file src="res/android/layout/aio_fingerprint_dialog_container.xml" target-dir="res/layout"/>
<source-file src="res/android/layout/aio_fingerprint_dialog_content.xml" target-dir="res/layout"/>
<source-file src="res/android/values/aio_fpauth-colors.xml" target-dir="res/values"/>
<source-file src="res/android/values/aio_fpauth-strings.xml" target-dir="res/values"/>
<source-file src="res/android/values-es/aio_fpauth-strings.xml" target-dir="res/values-es"/>
<source-file src="res/android/values-de/aio_fpauth-strings.xml" target-dir="res/values-de"/>
<source-file src="res/android/values-fr/aio_fpauth-strings.xml" target-dir="res/values-fr"/>
<source-file src="res/android/values-zh/aio_fpauth-strings.xml" target-dir="res/values-zh"/>
<source-file src="res/android/values-pt/aio_fpauth-strings.xml" target-dir="res/values-pt"/>
<source-file src="res/android/values-it/aio_fpauth-strings.xml" target-dir="res/values-it"/>
<source-file src="res/android/values-el/aio_fpauth-strings.xml" target-dir="res/values-el"/>
<source-file src="res/android/values-zh-rTW/aio_fpauth-strings.xml" target-dir="res/values-zh-rTW"/>
<source-file src="res/android/values-nl/aio_fpauth-strings.xml" target-dir="res/values-nl"/>
<source-file src="res/android/values-da/aio_fpauth-strings.xml" target-dir="res/values-da"/>
<source-file src="res/android/values-sv/aio_fpauth-strings.xml" target-dir="res/values-sv"/>
<source-file src="res/android/values-ru/aio_fpauth-strings.xml" target-dir="res/values-ru"/>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity
android:name="de.niklasmerz.cordova.biometric.BiometricActivity"
android:theme="@style/TransparentTheme"
android:exported="true" />
</config-file>

<framework src="src/android/build.gradle" custom="true" type="gradleReference"/>
<resource-file src="src/android/res/biometric_activity.xml" target="res/layout/biometric_activity.xml" />
<resource-file src="src/android/res/styles.xml" target="res/values/biometric-styles.xml" />
<resource-file src="src/android/android-biometric.aar" target="libs/android-biometric.aar" />
<source-file src="src/android/PromptInfo.java" target-dir="src/de/niklasmerz/cordova/biometric"/>
<source-file src="src/android/BiometricActivity.java" target-dir="src/de/niklasmerz/cordova/biometric"/>
<source-file src="src/android/Fingerprint.java" target-dir="src/de/niklasmerz/cordova/biometric"/>
<source-file src="src/android/PluginError.java" target-dir="src/de/niklasmerz/cordova/biometric"/>
</platform>

<engines>
<engine name="cordova-android" version=">=8.0.0" />
</engines>

</plugin>
Binary file removed res/android/drawable-hdpi/aio_ic_fp_40px.png
Binary file not shown.
Binary file removed res/android/drawable-mdpi/aio_ic_fp_40px.png
Binary file not shown.
Binary file removed res/android/drawable-nodpi/aio_android_robot.png
Binary file not shown.
Binary file removed res/android/drawable-xhdpi/aio_ic_fp_40px.png
Binary file not shown.
Binary file removed res/android/drawable-xxhdpi/aio_ic_fp_40px.png
Binary file not shown.
Binary file removed res/android/drawable-xxxhdpi/aio_ic_fp_40px.png
Binary file not shown.
28 changes: 0 additions & 28 deletions res/android/drawable/ic_aio_fingerprint_error.xml

This file was deleted.

28 changes: 0 additions & 28 deletions res/android/drawable/ic_aio_fingerprint_success.xml

This file was deleted.

61 changes: 0 additions & 61 deletions res/android/layout/aio_fingerprint_dialog_container.xml

This file was deleted.

58 changes: 0 additions & 58 deletions res/android/layout/aio_fingerprint_dialog_content.xml

This file was deleted.

Loading

0 comments on commit 67e877d

Please sign in to comment.