Skip to content

Commit

Permalink
feat(android-fingerprint-auth): add wrapper for plugin
Browse files Browse the repository at this point in the history
closes #334
  • Loading branch information
ihadeed committed Jul 23, 2016
1 parent b8f475f commit df326f7
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare var window;

import {ActionSheet} from './plugins/actionsheet';
import {AdMob} from './plugins/admob';
import { AndroidFingerprintAuth } from './plugins/android-fingerprint-auth';
import {AppAvailability} from './plugins/appavailability';
import {AppRate} from './plugins/apprate';
import {AppVersion} from './plugins/appversion';
Expand Down Expand Up @@ -109,6 +110,7 @@ export * from './plugins/twitter-connect';
export {
ActionSheet,
AdMob,
AndroidFingerprintAuth,
AppAvailability,
AppRate,
AppVersion,
Expand Down Expand Up @@ -159,6 +161,7 @@ export * from './plugins/plugin';
window['IonicNative'] = {
ActionSheet: ActionSheet,
AdMob: AdMob,
AndroidFingerprintAuth: AndroidFingerprintAuth,
AppAvailability: AppAvailability,
AppRate: AppRate,
AppVersion: AppVersion,
Expand Down
77 changes: 77 additions & 0 deletions src/plugins/android-fingerprint-auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Cordova, Plugin } from './plugin';
/**
* @name Android Fingerprint Auth
* @description
* 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.
* @usage
* ```typescript
* import { AndroidFingerprintAuth } from 'ionic-native';
*
* AndroidFingerprintAuth.isAvailable()
* .then((result)=> {
* if(result.isAvailable){
* // it is available
*
* AndroidFingerprintAuth.show({ clientId: "myAppName", clientSecret: "so_encrypted_much_secure_very_secret" })
* .then(result => {
* if(result.withFingerprint) {
* console.log('Successfully authenticated with fingerprint!');
* } else if(result.withPassword) {
* console.log('Successfully authenticated with backup password!');
* } else console.log('Didn\'t authenticate!');
* })
* .catch(error => console.error(error));
*
* } else {
* // fingerprint auth isn't available
* }
* })
* .catch(error => console.error(error));
* ```
*/
@Plugin({
plugin: 'cordova-plugin-android-fingerprint-auth',
pluginRef: 'FingerprintAuth',
repo: 'https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth'
})
export class AndroidFingerprintAuth {
/**
* Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
* @param params {any}
*/
@Cordova()
static show(params: {
/**
* Used as the alias for your key in the Android Key Store.
*/
clientId: string;
/**
* Used to encrypt the token returned upon successful fingerprint authentication.
*/
clientSecret: string;
/**
* Set to true to remove the "USE BACKUP" button
*/
disableBackup?: boolean;
/**
* Change the language. (en_US or es)
*/
locale?: string
}): Promise<{
/**
* Base64 encoded string
*/
withFingerprint: string;
/**
*
*/
withPassword: boolean;
}> {return; }

/**
* Check if service is available
*/
@Cordova()
static isAvailable(): Promise<{isAvailable: boolean}> {return; }

}

0 comments on commit df326f7

Please sign in to comment.