mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-22 01:19:36 +08:00
feat(android-fingerprint-auth): update to v1.2.1 (#910)
* 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
This commit is contained in:
parent
56e8eaeb5d
commit
a1b0f885a7
@ -3,15 +3,27 @@ import { Cordova, Plugin } from './plugin';
|
|||||||
export interface AndroidFingerprintAuthOptions {
|
export interface AndroidFingerprintAuthOptions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Required
|
||||||
* Used as the alias for your key in the Android Key Store.
|
* Used as the alias for your key in the Android Key Store.
|
||||||
*/
|
*/
|
||||||
clientId: string;
|
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
|
* Set to true to remove the "USE BACKUP" button
|
||||||
*/
|
*/
|
||||||
@ -21,6 +33,33 @@ export interface AndroidFingerprintAuthOptions {
|
|||||||
* Change the language. (en_US or es)
|
* Change the language. (en_US or es)
|
||||||
*/
|
*/
|
||||||
locale?: string;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,15 +76,20 @@ export interface AndroidFingerprintAuthOptions {
|
|||||||
* if(result.isAvailable){
|
* if(result.isAvailable){
|
||||||
* // it is available
|
* // it is available
|
||||||
*
|
*
|
||||||
* AndroidFingerprintAuth.show({ clientId: "myAppName", clientSecret: "so_encrypted_much_secure_very_secret" })
|
* AndroidFingerprintAuth.encrypt({ clientId: "myAppName", username: "myUsername", password: "myPassword" })
|
||||||
* .then(result => {
|
* .then(result => {
|
||||||
* if(result.withFingerprint) {
|
* if (result.withFingerprint) {
|
||||||
* console.log('Successfully authenticated with fingerprint!');
|
* console.log("Successfully encrypted credentials.");
|
||||||
* } else if(result.withPassword) {
|
* console.log("Encrypted credentials: " + result.token);
|
||||||
|
* } else if (result.withBackup) {
|
||||||
* console.log('Successfully authenticated with backup password!');
|
* console.log('Successfully authenticated with backup password!');
|
||||||
* } else console.log('Didn\'t authenticate!');
|
* } 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 {
|
* } else {
|
||||||
* // fingerprint auth isn't available
|
* // fingerprint auth isn't available
|
||||||
@ -70,15 +114,41 @@ export class AndroidFingerprintAuth {
|
|||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static show(options: AndroidFingerprintAuthOptions): Promise<{
|
static encrypt(options: AndroidFingerprintAuthOptions): Promise<{
|
||||||
/**
|
/**
|
||||||
* Base64 encoded string
|
* Biometric authentication
|
||||||
*/
|
*/
|
||||||
withFingerprint: string;
|
withFingerprint: boolean;
|
||||||
/**
|
/**
|
||||||
*
|
* Authentication using backup credential activity
|
||||||
*/
|
*/
|
||||||
withPassword: boolean;
|
withBackup: boolean;
|
||||||
|
/**
|
||||||
|
* base64encoded string representation of user credentials
|
||||||
|
*/
|
||||||
|
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; }
|
}> {return; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,5 +157,11 @@ export class AndroidFingerprintAuth {
|
|||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static isAvailable(): Promise<{isAvailable: boolean}> {return; }
|
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; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user