Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update plugin android-fingerprint-auth to v1.2.1 #910

Merged
merged 4 commits into from
Dec 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; }
}