Skip to content

Commit

Permalink
Revert "2.0.0 biometricpromt and consistent callbacks"
Browse files Browse the repository at this point in the history
  • Loading branch information
greaterking authored Oct 12, 2019
1 parent bbf24eb commit 52abe99
Show file tree
Hide file tree
Showing 39 changed files with 1,385 additions and 554 deletions.
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
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
116 changes: 29 additions & 87 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,101 +1,43 @@
# This Travis configuration file is built after a Cordova Paramedic
# specific template with minimal modifications and adaptations:
# https://github.com/apache/cordova-paramedic/blob/master/.travis.yml

sudo: false
addons:
jwt:
secure: f0G7Z/0N1ACi5pFg32P4kr8tVd5EOADDne5a8/MtabGTjeH0/QZl+4xKIgemXle6BJn949Gqpx4+XkmaKmDHHfIsV+9GmLwqGpGSyQMMoeBI0Lfxzh8aecYDxfJKBYmdmpJcyG3yKa42nxQFEMIljf0NJEmNN8AAglsaSh5VQq2dlv1aXaoJz18dpgRVE1cJ4rvUJN+fOrZYjRsqw9ev+11J7cwRONsBB/Yx+56tsverD2uC4Xutj58CEaw7WRk4BLMqehkGO0/ez2Ofc9dBDfc4ZHqHxZMfqjYO5r95VFclyIgto9ToW2kazuK+NZMgaX5wEBp+ktVQGHQw+rRunANplJt14AXpu7Elpfp04Hb4qjBQTYCXellNJ1TgLJLhP6a3P4nTUBrZ9I5mjSGI8ckvUEb1066KyGJmMIPs64z6BJgDHd91PP+cDq6MqUm+n+m24l6Ou/iLDmxaEs6peEctx5A6hACnNwyyB5MEeqZVbksFkNoYw9pxbTj1bBtBbg5QRHC7+Bd8mrN12VOi2wA2N8dFgO3Np+sfZriq/CXfCPrDNYPX8IwF9HEkm2J+PLW1MD8Kx2XwALCqKjU6md0hKui5LdhNWlpAiNK/eBLtJEF2egaMkQw1JPQYxHIyAAi4yUSYYVd64hb9rgUSTNiywRddmKovBChiwiTsmFc=
env:
global:
- SAUCE_USERNAME=NiklasMerz
- TRAVIS_NODE_VERSION=8
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3

language: node_js
node_js: 8

# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027

_ios: &_ios
os: osx
osx_image: xcode10.2

_android: &_android
language: android
os: linux
jdk: oraclejdk8
android:
components:
- tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

- SAUCE_USERNAME=NiklasMerz
- TRAVIS_NODE_VERSION="lts/*"
matrix:
include:
# local tests, without saucelabs
- env: PLATFORM=local/ios-10.0
<<: *_ios

# many tests with saucelabs

- env: PLATFORM=ios-11.3
<<: *_ios
- env: PLATFORM=ios-12.0
<<: *_ios

- env: PLATFORM=android-8.1
<<: *_android
- env: PLATFORM=android-9.0
<<: *_android

- env: PLATFORM=android-7.0
os: linux
language: android
jdk: oraclejdk8
android:
components:
- tools
- build-tools-26.0.2
- env: PLATFORM=ios-10.0
os: osx
osx_image: xcode9.2
language: node_js
node_js: 'lts/*'
before_install:
# manually install Node for `language: android`
- if [[ "$PLATFORM" =~ android ]]; then nvm install $TRAVIS_NODE_VERSION; fi
- node --version
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
- npm install -g cordova
# install paramedic if not running on paramedic repo
- if ! [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then npm install -g github:apache/cordova-paramedic; fi

- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
install $TRAVIS_NODE_VERSION
- node --version
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-25,android-26;
fi
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
&& npm install && popd
- npm install -g [email protected]
install:
- npm install

before_script:
- |
if [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then
# when used in the cordova-paramedic repo
TEST_COMMAND="npm run eslint"
PARAMEDIC_PLUGIN_TO_TEST="./spec/testable-plugin/"
PARAMEDIC_COMMAND="node main.js"
else
# when used in any other (plugin) repo
TEST_COMMAND="npm test"
PARAMEDIC_PLUGIN_TO_TEST=$(pwd)
PARAMEDIC_COMMAND="cordova-paramedic"
fi
- PARAMEDIC_BUILDNAME=travis-$TRAVIS_REPO_SLUG-$TRAVIS_JOB_NUMBER
- |
echo "Variables now are set to:"
echo "TEST_COMMAND=$TEST_COMMAND"
echo "ADDITIONAL_TESTS=$ADDITIONAL_TESTS"
echo "PARAMEDIC_COMMAND=$PARAMEDIC_COMMAND"
echo "PLATFORM=$PLATFORM"
echo "PARAMEDIC_PLUGIN_TO_TEST=$PARAMEDIC_PLUGIN_TO_TEST"
echo "PARAMEDIC_BUILDNAME=$PARAMEDIC_BUILDNAME"
- npm install
script:
- $TEST_COMMAND
- if [[ "$ADDITIONAL_TESTS_DIR" != "" ]]; then
cd $ADDITIONAL_TESTS_DIR && npm install && npm test;
else
$PARAMEDIC_COMMAND --config ./pr/$PLATFORM --plugin $PARAMEDIC_PLUGIN_TO_TEST --buildName $PARAMEDIC_BUILDNAME;
fi
- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
--buildName travis-plugin-fingerprint-aio-$TRAVIS_JOB_NUMBER
notifications:
email: false
slack:
Expand Down
67 changes: 18 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

## 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 @@ -82,58 +84,33 @@ Fingerprint.isAvailable(isAvailableSuccess, isAvailableError);
alert("Fingerprint available");
}

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

### Show authentication dialogue
```javascript
Fingerprint.show({
description: "Some biometric description"
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.
}, successCallback, errorCallback);

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

function errorCallback(error){
alert("Authentication invalid " + error.message);
function errorCallback(err){
alert("Authentication invalid " + err);
}
```
### 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.

### 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_FINGERPRINT_NOT_ENROLLED** = `-106`;
- **BIOMETRIC_INTERNAL_PLUGIN_ERROR** = `-107`;
- **BIOMETRIC_FINGERPRINT_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
**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

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

Expand All @@ -143,15 +120,7 @@ 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.

Special thanks also to @anitaa1990 for the biometric lib that aar the file in this plugin is based on and to @pabloerag's fork that removed the androidx requirements.

[Biometric-Auth-Sample](https://github.com/anitaa1990/Biometric-Auth-Sample)

[Forked version used to create aar](https://github.com/greaterking/Biometric-Auth-Sample/tree/changes-for-fingerprint-aio)

## License

The project is MIT licensed: [MIT](https://opensource.org/licenses/MIT).

* 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)
20 changes: 2 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-fingerprint-aio",
"version": "3.0.0",
"version": "1.7.0",
"description": "Cordova plugin to use fingerprint authentication on Android and iOS",
"cordova": {
"id": "cordova-plugin-fingerprint-aio",
Expand Down Expand Up @@ -40,23 +40,7 @@
"jasmine": "^3.2.0"
},
"scripts": {
"test": "npm run eslint",
"eslint": "npx eslint www",
"test-travis": "npm run test-ios",
"test-appveyor": "npm run test-browser",
"test-local": "npm run test-browser && npm run test-android && npm run test-ios",
"test-android": "npx cordova-paramedic --platform android --plugin $(pwd)",
"test-ios": "npx cordova-paramedic --platform ios --plugin $(pwd) --verbose",
"test-windows": "npx cordova-paramedic --platform windows --plugin $(pwd)",
"test-browser": "npx cordova-paramedic --platform browser --plugin $(pwd)",
"test-saucelabs": "npm run test-saucelabs-ios && npm run test-saucelabs-android",
"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",
"test": "./node_modules/cordova-paramedic/main.js --plugin . --args=--buildFlag='-UseModernBuildSystem=0' --platform",
"plugin-version": "cordova-plugin-xml setVersion"
},
"engines": {
"cordovaDependencies": {
">=3.0.0": { "cordova-android": ">=8.0.0" }
}
}
}
44 changes: 32 additions & 12 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="3.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="1.7.0">
<name>FingerprintAllInOne</name>
<description>Cordova plugin to use fingerprint on Android and iOS</description>
<license>MIT</license>
Expand All @@ -11,6 +11,7 @@
<clobbers target="Fingerprint"/>
</js-module>



<!-- ios -->
<platform name="ios">
Expand All @@ -20,7 +21,7 @@
<param name="ios-package" value="Fingerprint"/>
</feature>
</config-file>
<header-file src="src/ios/Bridging-Header.h"/>
<header-file src="src/ios/Bridging-Header.h" />
<source-file src="src/ios/Fingerprint.swift"/>

<!-- Usage description of Face ID for iOS 11+ -->
Expand All @@ -34,21 +35,40 @@
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Fingerprint">
<param name="android-package" value="de.niklasmerz.cordova.biometric.Fingerprint"/>
<param name="android-package" value="de.niklasmerz.cordova.fingerprint.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>

<framework src="src/android/build.gradle" custom="true" type="gradleReference"/>
<source-file src="src/android/Fingerprint.java" target-dir="src/de/niklasmerz/cordova/biometric"/>
</platform>

<engines>
<engine name="cordova-android" version=">=8.0.0" />
</engines>
<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_fingerprint_error.xml" target-dir="res/drawable"/>
<source-file src="res/android/drawable/ic_fingerprint_success.xml" target-dir="res/drawable"/>
<resource-file src="res/android/drawable-hdpi/ic_fp_40px.png" target="res/drawable-hdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-mdpi/ic_fp_40px.png" target="res/drawable-mdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-nodpi/android_robot.png" target="res/drawable-nodpi/android_robot.png"/>
<resource-file src="res/android/drawable-xhdpi/ic_fp_40px.png" target="res/drawable-xhdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-xxhdpi/ic_fp_40px.png" target="res/drawable-xxhdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-xxxhdpi/ic_fp_40px.png" target="res/drawable-xxxhdpi/ic_fp_40px.png"/>
<source-file src="res/android/layout/fingerprint_dialog_container.xml" target-dir="res/layout"/>
<source-file src="res/android/layout/fingerprint_dialog_content.xml" target-dir="res/layout"/>
<source-file src="res/android/values/fpauth-colors.xml" target-dir="res/values"/>
<source-file src="res/android/values/fpauth-strings.xml" target-dir="res/values"/>
<source-file src="res/android/values-es/fpauth-strings.xml" target-dir="res/values-es"/>
<source-file src="res/android/values-de/fpauth-strings.xml" target-dir="res/values-de"/>
<source-file src="res/android/values-fr/fpauth-strings.xml" target-dir="res/values-fr"/>
<source-file src="res/android/values-zh/fpauth-strings.xml" target-dir="res/values-zh"/>
<source-file src="res/android/values-pt/fpauth-strings.xml" target-dir="res/values-pt"/>
<source-file src="res/android/values-it/fpauth-strings.xml" target-dir="res/values-it"/>
<source-file src="res/android/values-el/fpauth-strings.xml" target-dir="res/values-el"/>
<source-file src="res/android/values-zh-rTW/fpauth-strings.xml" target-dir="res/values-zh-rTW"/>
<source-file src="res/android/values-nl/fpauth-strings.xml" target-dir="res/values-nl"/>
<source-file src="res/android/values-da/fpauth-strings.xml" target-dir="res/values-da"/>
<source-file src="res/android/values-sv/fpauth-strings.xml" target-dir="res/values-sv"/>
<source-file src="res/android/values-ru/fpauth-strings.xml" target-dir="res/values-ru"/>
</platform>

</plugin>
Binary file added res/android/drawable-hdpi/ic_fp_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/android/drawable-mdpi/ic_fp_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/android/drawable-nodpi/android_robot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/android/drawable-xhdpi/ic_fp_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/android/drawable-xxhdpi/ic_fp_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/android/drawable-xxxhdpi/ic_fp_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions res/android/drawable/ic_fingerprint_error.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,0.0C8.96,0.0 0.0,8.95 0.0,20.0s8.96,20.0 20.0,20.0c11.04,0.0 20.0,-8.95 20.0,-20.0S31.04,0.0 20.0,0.0z"
android:fillColor="#F4511E"/>
<path
android:pathData="M21.33,29.33l-2.67,0.0l0.0,-2.67l2.67,0.0L21.33,29.33zM21.33,22.67l-2.67,0.0l0.0,-12.0l2.67,0.0L21.33,22.67z"
android:fillColor="#FFFFFF"/>
</vector>
Loading

0 comments on commit 52abe99

Please sign in to comment.