Skip to content

A cordova plugin for fingerprint authentication using the hardware fingerprint scanner on devices running Android 6+

License

Notifications You must be signed in to change notification settings

BendingBender/cordova-plugin-android-fingerprint-auth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#About This plugin was created referencing the Fingerprint Dialog sample and the Confirm Credential sample referenced by the Android 6.0 APIs webpage.

This plugin will open a native dialog fragment prompting the user to authenticate using their fingerprint. If the device has a secure lockscreen (pattern, PIN, or password), the user may opt to authenticate using that method as a backup.

Changes by Kilian:

  • onCancel returns successfully with data instead of returing an error
  • removed backup functionality

#Screenshots ###Fingerprint Auth Dialog### Fingerprint Auth Dialog | Fingerprint Auth Dialog Success | Fingerprint Auth Dialog Fail | Fingerprint Auth Dialog Too Many | Fingerprint Auth Dialog No Backup | Fingerprint Auth Dialog No Backup ###Backup Credentials### Confirm Password | Confirm PIN | Confirm Pattern

#Installation meteor add cordova:cordova-plugin-android-fingerprint-auth

#Setup Add preference to mobile-config.js

App.setPreference('android-targetSdkVersion', '23');

set compile version and build tools in build.gradle

compileSdkVersion 23
buildToolsVersion "23.0.2"

#API ###FingerprintAuth.show###

FingerprintAuth.show({
            clientId: "myAppName",
            clientSecret: "a_very_secret_encryption_key"
        }, successCallback, errorCallback);

/**
 * @return {withFingerprint:base64EncodedString, withPassword:boolean}
 */
function successCallback(result) {
    console.log("successCallback(): " + JSON.stringify(result));
    if (result.withFingerprint) {
        console.log("Successfully authenticated using a fingerprint");
    } else if (result.withPassword) {
        console.log("Authenticated with backup password");
    }
}

function errorCallback(error) {
    console.log(error); // "Fingerprint authentication not available"
}

Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.

clientId will be used as the alias for your key in the Android Key Store. clientSecret will be used to encrypt the token returned upon successful fingerprint authentication.

###FingerprintAuth.isAvailable###

FingerprintAuth.isAvailable(isAvailableSuccess, isAvailableError);

/**
 * @return {
 *      isAvailable:boolean,
 *      isHardwareDetected:boolean,
 *      hasEnrolledFingerprints:boolean
 *   }
 */
function isAvailableSuccess(result) {
    console.log("FingerprintAuth available: " + JSON.stringify(result));
    if (result.isAvailable) {
        FingerprintAuth.show({
                    clientId: "myAppName",
                    clientSecret: "a_very_secret_encryption_key"
                }, successCallback, errorCallback);
    }
}

function isAvailableError(message) {
    console.log("isAvailableError(): " + message);
}

About

A cordova plugin for fingerprint authentication using the hardware fingerprint scanner on devices running Android 6+

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 94.6%
  • JavaScript 5.4%