Skip to content

Commit

Permalink
feat(android-fingerprint-auth): update to v1.2.1 (#910)
Browse files Browse the repository at this point in the history
* update to use plugin v1.1.0

Updated example
Added new configuration options.
Added new show() result fields
Added new delete method

* Update to plugin v1.2.0

Removed show()
Added encrypt()
Added decrypt()
Removed requirement of username

* edit comments

* edited comments
  • Loading branch information
mjwheatley authored and ihadeed committed Dec 27, 2016
1 parent 56e8eae commit a1b0f88
Showing 1 changed file with 89 additions and 13 deletions.
102 changes: 89 additions & 13 deletions src/plugins/android-fingerprint-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ import { Cordova, Plugin } from './plugin';
export interface AndroidFingerprintAuthOptions {

/**
* Required
* Used as the alias for your key in the Android Key Store.
*/
clientId: string;

/**
* Used to encrypt the token returned upon successful fingerprint authentication.
* Used to create credential string for encrypted token and as alias to retrieve the cipher.
*/
clientSecret: string;
username?: string;

/**
* Used to create credential string for encrypted token
*/
password?: string;

/**
* Required for decrypt()
* Encrypted user credentials to decrypt upon successful authentication.
*/
token?: string;

/**
* Set to true to remove the "USE BACKUP" button
*/
Expand All @@ -21,6 +33,33 @@ export interface AndroidFingerprintAuthOptions {
* Change the language. (en_US or es)
*/
locale?: string;

/**
* The device max is 5 attempts. Set this parameter if you want to allow fewer than 5 attempts.
*/
maxAttempts?: number;

/**
* Require the user to authenticate with a fingerprint to authorize every use of the key.
* New fingerprint enrollment will invalidate key and require backup authenticate to
* re-enable the fingerprint authentication dialog.
*/
userAuthRequired?: boolean;

/**
* Set the title of the fingerprint authentication dialog.
*/
dialogTitle?: string;

/**
* Set the message of the fingerprint authentication dialog.
*/
dialogMessage?: string;

/**
* Set the hint displayed by the fingerprint icon on the fingerprint authentication dialog.
*/
dialogHint?: string;

}

Expand All @@ -37,15 +76,20 @@ export interface AndroidFingerprintAuthOptions {
* if(result.isAvailable){
* // it is available
*
* AndroidFingerprintAuth.show({ clientId: "myAppName", clientSecret: "so_encrypted_much_secure_very_secret" })
* AndroidFingerprintAuth.encrypt({ clientId: "myAppName", username: "myUsername", password: "myPassword" })
* .then(result => {
* if(result.withFingerprint) {
* console.log('Successfully authenticated with fingerprint!');
* } else if(result.withPassword) {
* if (result.withFingerprint) {
* console.log("Successfully encrypted credentials.");
* console.log("Encrypted credentials: " + result.token);
* } else if (result.withBackup) {
* console.log('Successfully authenticated with backup password!');
* } else console.log('Didn\'t authenticate!');
* })
* .catch(error => console.error(error));
* .catch(error => {
* if (error === "Cancelled") {
* console.log("Fingerprint authentication cancelled");
* } else console.error(error)
* });
*
* } else {
* // fingerprint auth isn't available
Expand All @@ -70,15 +114,41 @@ export class AndroidFingerprintAuth {
* @returns {Promise<any>}
*/
@Cordova()
static show(options: AndroidFingerprintAuthOptions): Promise<{
static encrypt(options: AndroidFingerprintAuthOptions): Promise<{
/**
* Biometric authentication
*/
withFingerprint: boolean;
/**
* Base64 encoded string
* Authentication using backup credential activity
*/
withFingerprint: string;
withBackup: boolean;
/**
*
* base64encoded string representation of user credentials
*/
withPassword: boolean;
token: string;
}> {return; }

/**
* Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
* @param options {AndroidFingerprintAuthOptions} Options
* @returns {Promise<any>}
*/
@Cordova()
static decrypt(options: AndroidFingerprintAuthOptions): Promise<{
/**
* Biometric authentication
*/
withFingerprint: boolean;
/**
* Authentication using backup credential activity
*/
withBackup: boolean;
/**
* FingerprintAuth.CipherMode.DECRYPT
* Decrypted password
*/
password: string;
}> {return; }

/**
Expand All @@ -87,5 +157,11 @@ export class AndroidFingerprintAuth {
*/
@Cordova()
static isAvailable(): Promise<{isAvailable: boolean}> {return; }


/**
* Delete the cipher used for encryption and decryption by username
* @returns {Promise<any>} Returns a Promise that resolves if the cipher was successfully deleted
*/
@Cordova()
static delete(options: {clientId: string; username: string;}): Promise<{deleted: boolean}> {return; }
}

0 comments on commit a1b0f88

Please sign in to comment.