cordova-plugin-android-fingerprint-auth
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,1 +1,15 @@ | ||
#Version 1.2.0 | ||
###What's New | ||
* Removed `FingerprintAuth.CipherMode` | ||
* Removed `FingerprintAuth.show() ` in favor of separate actions for encrypt and decrypt | ||
* Added `FingerprintAuth.encrypt()` | ||
* Added `FingerprintAuth.decrypt()` | ||
* Made `username` optional | ||
* `token` is required for `decrypt()` | ||
###Breaking Changes | ||
* Removed `FingerprintAuth.CipherMode` | ||
* Removed `FingerprintAuth.show() ` in favor of separate actions for encrypt and decrypt | ||
#Version 1.1.0 | ||
@@ -2,0 +16,0 @@ Introducing encryption and decryption of user credentials. |
{ | ||
"name": "cordova-plugin-android-fingerprint-auth", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Cordova plugin to use Android fingerprint authentication API", | ||
@@ -5,0 +5,0 @@ "cordova": { |
126
README.md
@@ -1,2 +0,2 @@ | ||
#Update to Version 1.1.0 | ||
#Update to Version 1.2.0 | ||
Please consult the [changelog](https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/blob/master/changelog.md). | ||
@@ -33,14 +33,28 @@ | ||
#How to use | ||
- Call `isAvailable` to check the fingerprint status. | ||
- Call `show` show the Authentication Dialog. | ||
- Call `delete` when you want to delete the cipher for the user. | ||
- Call `isAvailable()` to check the fingerprint status. | ||
- Call `encrypt()` or `decrypt()` show the Authentication Dialog. | ||
- Call `delete()` when you want to delete the cipher for the user. | ||
If you are not concerned with encrypting credentials and just want device authentication (fingerprint or backup), just call `encrypt()` with a `clientId` and look for a callback to the `successCallback`. | ||
###Encrypt/Decrypt User Credentials | ||
* Encrypt user credentials | ||
* Have user sign in with username and password. | ||
* Check plugin availability and pass username and password to `encrypt()`. | ||
* Store encrypted token with user profile. | ||
* Decrypt user credentials | ||
* Prompt for username. | ||
* Query on username to retrieve encrypted token. | ||
* Pass username and token to `decrypt()` to return password. | ||
* Login using username and decrypted password. | ||
#API Reference | ||
* FingerprintAuth | ||
* [isAvailable(isAvailableSuccess, isAvailableError)](#module_fingerprintauth.isAvailable) : `function` | ||
* [show(config, successCallback, errorCallback)](#module_fingerprintauth.show) : `function` | ||
* [delete(confg, successCallback, errorCallback)](#module_fingerprintauth.delete) : `function` | ||
* [CipherMode](#module_fingerprintauth.cipherMode) : `enum` | ||
* [isAvailable(isAvailableSuccess, isAvailableError)](#module_fingerprintauth.isAvailable) | ||
* [encrypt(encryptConfig, successCallback, errorCallback)](#module_fingerprintauth.encrypt) | ||
* [decrypt(decryptConfig, successCallback, errorCallback)](#module_fingerprintauth.decrypt) | ||
* [delete(deleteConfg, successCallback, errorCallback)](#module_fingerprintauth.delete) | ||
* [Config Object](#module_fingerprintauth.config) | ||
<a name="module_fingerprintauth.isAvailable"></a> | ||
@@ -52,2 +66,9 @@ ##FingerprintAuth.isAvailable(successCallback, errorCallback) | ||
###isAvailable() Result Object | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| isAvailable | boolean | Fingerprint Authentication Dialog is available for use. | | ||
| isHardwareDetected | boolean | Device has hardware fingerprint sensor. | | ||
| hasEnrolledFingerprints | boolean | Device has any fingerprints enrolled. | | ||
**Example** | ||
@@ -68,4 +89,4 @@ | ||
if (result.isAvailable) { | ||
var config = {}; // See config object for required parameters | ||
FingerprintAuth.show(config, successCallback, errorCallback); | ||
var encryptConfig = {}; // See config object for required parameters | ||
FingerprintAuth.encrypt(encryptConfig, encryptSuccessCallback, encryptErrorCallback); | ||
} | ||
@@ -79,13 +100,10 @@ } | ||
<a name="module_fingerprintauth.show"></a> | ||
##FingerprintAuth.show(config, successCallback, errorCallback) | ||
###Config Object | ||
<a name="module_fingerprintauth.config"></a> | ||
###FingerprintAuth Config Object | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| clientId | String | undefined | (REQUIRED) Used as the alias for your key in the Android Key Store. | | ||
| username | String | undefined | (REQUIRED) Used to create credential string for encrypted token and as alias to retrieve the cipher. | | ||
| cipherMode | FingerprintAuth.CipherMode | undefined | (REQUIRED) Used to determine if plugin should encrypt or decrypt after authentication. <br/><ul><li>FingerprintAuth.CipherMode.ENCRYPT</li><li>FingerprintAuth.CipherMode.DECRYPT</li></ul>| | ||
| clientId | String | undefined | (**REQUIRED**) Used as the alias for your app's secret key in the Android Key Store. Also used as part of the Shared Preferences key for the cipher userd to encrypt the user credentials. | | ||
| username | String | undefined | Used to create credential string for encrypted token and as alias to retrieve the cipher. | | ||
| password | String | undefined | Used to create credential string for encrypted token | | ||
| token | String | undefined | Used to create credential string for encrypted token. | | ||
| token | String | undefined | Data to be decrypted. ***Required*** for `decrypt()`. | | ||
| disableBackup | boolean | false | Set to true to remove the "USE BACKUP" button | | ||
@@ -99,18 +117,11 @@ | maxAttempts | number | 5 | The device max is 5 attempts. Set this parameter if you want to allow fewer than 5 attempts. | | ||
<a name="module_fingerprintauth.cipherMode"></a> | ||
###CipherMode : `Enum` | ||
<a name="module_fingerprintauth.encrypt"></a> | ||
##FingerprintAuth.encrypt(encryptConfig, encryptSuccessCallback, encryptErrorCallback) | ||
| Option | Type | Value | | ||
| --- | --- | --- | | ||
| ENCRYPT | String | "encrypt" | | ||
| DECRYPT | String | "decrypt" | | ||
###Result Object | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| withFingerprint | boolean | `true` if user authenticated using a fingerprint | | ||
| withBackup | boolean | `true` if user used the backup credentials activity to authenticate. | | ||
| cipherMode | FingerprintAuth.CipherMode | Pass through parameter from config object. | | ||
| token | String | Will contain the base64 encoded credentials if `withFingerprint == true` and `cipherMode == FingerprintAuth.CipherMode.ENCRYPT`. | | ||
| password | String | Will contain the decrypted password if `withFingerprint == true` and `cipherMode == FingerprintAuth.CipherMode.DECRYPT` | ||
| withFingerprint | boolean | User authenticated using a fingerprint | | ||
| withBackup | boolean | User authenticated using backup credentials. | | ||
| token | String | Will contain the base64 encoded credentials upon successful fingerprint authentication. | | ||
@@ -122,3 +133,2 @@ **Example** | ||
clientId: "myAppName", | ||
cipherMode: FingerprintAuth.CipherMode.ENCRYPT, | ||
username: "currentUser", | ||
@@ -128,5 +138,40 @@ password: "currentUserPassword" | ||
FingerprintAuth.encrypt(encryptConfig, successCallback, errorCallback); | ||
function successCallback(result) { | ||
console.log("successCallback(): " + JSON.stringify(result)); | ||
if (result.withFingerprint) { | ||
console.log("Successfully encrypted credentials."); | ||
console.log("Encrypted credentials: " + result.token); | ||
} else if (result.withBackup) { | ||
console.log("Authenticated with backup password"); | ||
} | ||
} | ||
function errorCallback(error) { | ||
if (error === "Cancelled") { | ||
console.log("FingerprintAuth Dialog Cancelled!"); | ||
} else { | ||
console.log("FingerprintAuth Error: " + error); | ||
} | ||
} | ||
``` | ||
<a name="module_fingerprintauth.decrypt"></a> | ||
##FingerprintAuth.decrypt(decryptConfig, encryptSuccessCallback, encryptErrorCallback) | ||
###Result Object | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| withFingerprint | boolean | User authenticated using a fingerprint | | ||
| withBackup | boolean | User authenticated using backup credentials. | | ||
| password | String | Will contain the decrypted password upon successful fingerprint authentication. | ||
**Example** | ||
```javascript | ||
var decryptConfig = { | ||
clientId: "myAppName", | ||
cipherMode: FingerprintAuth.CipherMode.DECRYPT, | ||
username: "currentUser", | ||
@@ -136,3 +181,3 @@ token: "base64encodedUserCredentials" | ||
FingerprintAuth.show(yourConfig, successCallback, errorCallback); | ||
FingerprintAuth.decrypt(decryptConfig, successCallback, errorCallback); | ||
@@ -142,8 +187,6 @@ function successCallback(result) { | ||
if (result.withFingerprint) { | ||
if (result.cipherMode === FingerprintAuth.CipherMode.ENCRYPT) { | ||
console.log("Successfully encrypted credentials."); | ||
console.log("Encrypted credentials: " + result.token); | ||
} else if (result.cipherMode === FingerprintAuth.CipherMode.DECRYPT) { | ||
console.log("Successfully decrypted user credentials."); | ||
console.log("password: " + result.password); | ||
console.log("Successful biometric authentication."); | ||
if (result.password) { | ||
console.log("Successfully decrypted credential token."); | ||
console.log("password: " + result.password); | ||
} | ||
@@ -165,3 +208,2 @@ } else if (result.withBackup) { | ||
<a name="module_fingerprintauth.delete"></a> | ||
@@ -176,3 +218,3 @@ ##FingerprintAuth.delete(config, successCallback, errorCallback) | ||
| clientId | String | undefined | (REQUIRED) Used as the alias for your key in the Android Key Store. | | ||
| username | String | undefined | (REQUIRED) Identify which cipher to delete. | | ||
| username | String | undefined | Identify which cipher to delete. | | ||
@@ -179,0 +221,0 @@ **Example** |
function FingerprintAuth() {} | ||
FingerprintAuth.prototype.show = function (params, successCallback, errorCallback) { | ||
FingerprintAuth.prototype.encrypt = function (params, successCallback, errorCallback) { | ||
cordova.exec( | ||
@@ -8,3 +8,3 @@ successCallback, | ||
"FingerprintAuth", // Java Class | ||
"show", // action | ||
"encrypt", // action | ||
[ // Array of arguments to pass to the Java class | ||
@@ -16,2 +16,14 @@ params | ||
FingerprintAuth.prototype.decrypt = function (params, successCallback, errorCallback) { | ||
cordova.exec( | ||
successCallback, | ||
errorCallback, | ||
"FingerprintAuth", // Java Class | ||
"decrypt", // action | ||
[ // Array of arguments to pass to the Java class | ||
params | ||
] | ||
); | ||
}; | ||
FingerprintAuth.prototype.delete = function (params, successCallback, errorCallback) { | ||
@@ -39,8 +51,3 @@ cordova.exec( | ||
FingerprintAuth.prototype.CipherMode = { | ||
ENCRYPT: "encrypt", | ||
DECRYPT: "decrypt" | ||
}; | ||
FingerprintAuth = new FingerprintAuth(); | ||
module.exports = FingerprintAuth; | ||
module.exports = FingerprintAuth; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
479597
44
226