diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 92f1ae4e..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# These are supported funding model platforms - -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: https://www.paypal.me/niklasmerz diff --git a/.gitignore b/.gitignore index 4c9527ba..504afef8 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml index 35931890..a4628bf1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 cordova@7.0.1 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: diff --git a/README.md b/README.md index 71c1634f..d0179016 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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: `" 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: @@ -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) diff --git a/package.json b/package.json index f7b90dec..6b696583 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } - } } } diff --git a/plugin.xml b/plugin.xml index 3150ab36..81f7ca39 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + FingerprintAllInOne Cordova plugin to use fingerprint on Android and iOS MIT @@ -11,6 +11,7 @@ + @@ -20,7 +21,7 @@ - + @@ -34,21 +35,40 @@ - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/android/drawable-hdpi/ic_fp_40px.png b/res/android/drawable-hdpi/ic_fp_40px.png new file mode 100644 index 00000000..48ebd8ad Binary files /dev/null and b/res/android/drawable-hdpi/ic_fp_40px.png differ diff --git a/res/android/drawable-mdpi/ic_fp_40px.png b/res/android/drawable-mdpi/ic_fp_40px.png new file mode 100644 index 00000000..122f4425 Binary files /dev/null and b/res/android/drawable-mdpi/ic_fp_40px.png differ diff --git a/res/android/drawable-nodpi/android_robot.png b/res/android/drawable-nodpi/android_robot.png new file mode 100644 index 00000000..40bf934b Binary files /dev/null and b/res/android/drawable-nodpi/android_robot.png differ diff --git a/res/android/drawable-xhdpi/ic_fp_40px.png b/res/android/drawable-xhdpi/ic_fp_40px.png new file mode 100644 index 00000000..e1c9590b Binary files /dev/null and b/res/android/drawable-xhdpi/ic_fp_40px.png differ diff --git a/res/android/drawable-xxhdpi/ic_fp_40px.png b/res/android/drawable-xxhdpi/ic_fp_40px.png new file mode 100644 index 00000000..f7e87240 Binary files /dev/null and b/res/android/drawable-xxhdpi/ic_fp_40px.png differ diff --git a/res/android/drawable-xxxhdpi/ic_fp_40px.png b/res/android/drawable-xxxhdpi/ic_fp_40px.png new file mode 100644 index 00000000..0fb85452 Binary files /dev/null and b/res/android/drawable-xxxhdpi/ic_fp_40px.png differ diff --git a/res/android/drawable/ic_fingerprint_error.xml b/res/android/drawable/ic_fingerprint_error.xml new file mode 100644 index 00000000..be46116d --- /dev/null +++ b/res/android/drawable/ic_fingerprint_error.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/res/android/drawable/ic_fingerprint_success.xml b/res/android/drawable/ic_fingerprint_success.xml new file mode 100644 index 00000000..261f3e7f --- /dev/null +++ b/res/android/drawable/ic_fingerprint_success.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/res/android/layout/fingerprint_dialog_container.xml b/res/android/layout/fingerprint_dialog_container.xml new file mode 100644 index 00000000..0c6face9 --- /dev/null +++ b/res/android/layout/fingerprint_dialog_container.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + +