-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android-fingerprint-auth): add wrapper for plugin
closes #334
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
} |