This API 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.
var encryptConfig = {
clientId: "myAppName",
username: "currentUser",
password: "currentUserPassword"
};
FingerprintAuth.isAvailable()
.then((result)=> {
if(result.isAvailable){
// it is available
FingerprintAuth.encrypt(encryptConfig)
.then(result => {
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 => {
if (error === this.FingerprintAuth.ERRORS.FINGERPRINT_CANCELLED) {
console.log('Fingerprint authentication cancelled');
} else console.error(error)
});
} else {
// fingerprint auth isn't available
}
}).catch(error => console.error(error));
var encryptConfig = {
clientId: "myAppName",
username: "currentUser",
password: "currentUserPassword",
};
window.FingerprintAuth.isAvailable()
.then((result) => {
if (result.isAvailable) {
// it is available
window.FingerprintAuth.encrypt(encryptConfig)
.then((result) => {
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) => {
if (
error === window.FingerprintAuth.ERRORS.FINGERPRINT_CANCELLED
) {
console.log("Fingerprint authentication cancelled");
} else console.error(error);
});
} else {
// fingerprint auth isn't available
}
})
.catch((error) => console.error(error));
var encryptConfig = {
clientId: "myAppName",
username: "currentUser",
password: "currentUserPassword",
};
window.FingerprintAuth.isAvailable()
.then((result) => {
if (result.isAvailable) {
// it is available
window.FingerprintAuth.encrypt(encryptConfig)
.then((result) => {
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) => {
if (
error === window.FingerprintAuth.ERRORS.FINGERPRINT_CANCELLED
) {
console.log("Fingerprint authentication cancelled");
} else console.error(error);
});
} else {
// fingerprint auth isn't available
}
})
.catch((error) => console.error(error));
var encryptConfig = {
clientId: "myAppName",
username: "currentUser",
password: "currentUserPassword",
};
(<any>window).FingerprintAuth.isAvailable()
.then((result) => {
if (result.isAvailable) {
// it is available
(<any>window).FingerprintAuth.encrypt(encryptConfig)
.then((result) => {
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) => {
if (
error === (<any>window).FingerprintAuth.ERRORS.FINGERPRINT_CANCELLED
) {
console.log("Fingerprint authentication cancelled");
} else console.error(error);
});
} else {
// fingerprint auth isn't available
}
})
.catch((error) => console.error(error));
var encryptConfig = {
clientId: "myAppName",
username: "currentUser",
password: "currentUserPassword",
};
window.FingerprintAuth.isAvailable()
.then((result) => {
if (result.isAvailable) {
// it is available
window.FingerprintAuth.encrypt(encryptConfig)
.then((result) => {
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) => {
if (
error === window.FingerprintAuth.ERRORS.FINGERPRINT_CANCELLED
) {
console.log("Fingerprint authentication cancelled");
} else console.error(error);
});
} else {
// fingerprint auth isn't available
}
})
.catch((error) => console.error(error));
isAvailable(): Promise <IsAvailableResult>
Check the fingerprint status
encrypt(options: EncryptConfig): Promise <EncryptResult>
Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
decrypt(options: EncryptConfig): Promise <DecryptResult>
Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
Used to delete a cipher.
delete(options: DeleteOptions): Promise <any>
Used to dismiss a Fingerprint Authentication Dialog if one is being displayed.
dismiss(): Promise <any>
interface IsAvailableResult {
// Fingerprint Authentication Dialog is available for use
isAvailable: boolean;
// Device has hardware fingerprint sensor
isHardwareDetected: boolean;
// Device has any fingerprints enrolled
hasEnrolledFingerprints: boolean;
}
interface EncryptConfig {
// Used as the alias for your app's secret key
clientId: string;
// Used to create credential string for encrypted token and as alias to retrieve the cipher
username: string;
// Used to create credential string for encrypted token
password: string;
// Data to be decrypted
token: string;
// Set to true to remove the "USE BACKUP" button
disableBackup: boolean;
// The device max is 5 attempts. Set this parameter if you want to allow fewer than 5 attempts
maxAttempts: int;
// Change the language displayed on the authentication dialog
locale: string;
// 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;
// Bypass authentication and just encrypt input. If true this option will not display the authentication dialog for fingerprint or backup credentials. It will just encrypt the input and return a token
encryptNoAuth: 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;
}
interface EncryptResult {
// User authenticated using a fingerprint
isAvailable: withFingerprint;
// User authenticated using backup credentials
withBackup: boolean;
// Will contain the base64 encoded credentials upon successful fingerprint authentication
token: string;
}
interface DecryptResult {
// User authenticated using a fingerprint
isAvailable: withFingerprint;
// User authenticated using backup credentials
withBackup: boolean;
// Will contain the base64 encoded credentials upon successful fingerprint authentication
token: string;
}
interface DeleteOptions {
// (REQUIRED) Used as the alias for your key
clientId: string;
// Identify which cipher to delete
username: string;
}
enum ERRORS = {
BAD_PADDING_EXCEPTION: "BAD_PADDING_EXCEPTION",
CERTIFICATE_EXCEPTION: "CERTIFICATE_EXCEPTION",
FINGERPRINT_CANCELLED: "FINGERPRINT_CANCELLED",
FINGERPRINT_DATA_NOT_DELETED: "FINGERPRINT_DATA_NOT_DELETED",
FINGERPRINT_ERROR: "FINGERPRINT_ERROR",
FINGERPRINT_NOT_AVAILABLE: "FINGERPRINT_NOT_AVAILABLE",
FINGERPRINT_PERMISSION_DENIED: "FINGERPRINT_PERMISSION_DENIED",
FINGERPRINT_PERMISSION_DENIED_SHOW_REQUEST: "FINGERPRINT_PERMISSION_DENIED_SHOW_REQUEST",
ILLEGAL_BLOCK_SIZE_EXCEPTION: "ILLEGAL_BLOCK_SIZE_EXCEPTION",
INIT_CIPHER_FAILED: "INIT_CIPHER_FAILED",
INVALID_ALGORITHM_PARAMETER_EXCEPTION: "INVALID_ALGORITHM_PARAMETER_EXCEPTION",
IO_EXCEPTION: "IO_EXCEPTION",
JSON_EXCEPTION: "JSON_EXCEPTION",
MINIMUM_SDK: "MINIMUM_SDK",
MISSING_ACTION_PARAMETERS: "MISSING_ACTION_PARAMETERS",
MISSING_PARAMETERS: "MISSING_PARAMETERS",
NO_SUCH_ALGORITHM_EXCEPTION: "NO_SUCH_ALGORITHM_EXCEPTION",
SECURITY_EXCEPTION: "SECURITY_EXCEPTION"
}