# Fingerprint

### Required Phonegap plugins

cordova-plugin-fingerprint-aio

## API Documentation

### Method Summary

#### isAvailable

Check if fingerprint authentication is available. If successful it will return a result object with information depending on device and OS.

**Params**

| Type     | Name               | Summary             | Required |
| -------- | ------------------ | ------------------- | -------- |
| Function | isAvailableSuccess | on success callback | Optional |
| Function | isAvailableError   | on error callback   | Optional |

#### show

Show authentication dialogue.

**Params**

| Type     | Name            | Summary                                                                                                        | Required |
| -------- | --------------- | -------------------------------------------------------------------------------------------------------------- | -------- |
| Object   | config          | {{clientId: String, clientSecret: String}} configuration for fingerprint, clientSecret only needed for Android | Required |
| Function | successCallback | on success callback                                                                                            | Optional |
| Function | errorCallback   | on error callback                                                                                              | Optional |

#### registerSecret

Register a biometric secret in device vault

**Params**

| Type     | Name            | Summary                                                                                          | Required |
| -------- | --------------- | ------------------------------------------------------------------------------------------------ | -------- |
| Object   | config          | {{description: String, secret: String, invalidateOnEnrollment: boolean, disableBackup: boolean}} | Required |
| Function | successCallback | on success callback                                                                              | Optional |
| Function | errorCallback   | on error callback                                                                                | Optional |

#### loadSecret

Recover secret from device vault

**Params**

| Type     | Name            | Summary                                         | Required |
| -------- | --------------- | ----------------------------------------------- | -------- |
| Object   | config          | {{description: String, disableBackup: boolean}} | Required |
| Function | successCallback | on success callback                             | Optional |
| Function | errorCallback   | on error callback                               | Optional |

## Example Usage

<pre class="language-javascript"><code class="lang-javascript">/**
 * Show fingerprint authentication
 * @properties={typeid:24,uuid:"DE0F95B4-F4EB-4833-A290-94D493075E92"}
 */
function showAuth() {
	var config = {
		description: "Please authenticate to continue.", //show for ios message
		clientId: "Please authenticate to continue.", //what to show for android message
		clientSecret: "password" //Only necessary for Android
	};
	plugins.svyphonegapFingerprintscan.show(config, showAuthSuccess, showAuthErr)
}

/**
 * Authentication success callback
 * @properties={typeid:24,uuid:"40F16C2C-2CF8-411E-99C5-F0ADE69EBE6A"}
 */
function showAuthSuccess(res) {
	application.output('You have authenticated successfully.');
}

/**
 * Authentication failed callback
 * @properties={typeid:24,uuid:"99B266C6-2F4F-424B-9ABC-C2485C187F86"}
 */
function showAuthErr(err) {
	application.output(err + '. You failed to authenticate.');
}

<strong>/**
</strong> * Register a secret in device vault
 * @properties={typeid:24,uuid:"86504131-A2BC-4E15-9652-7DF9732DB76C"}
 */
function authRegisterCallback(){
	plugins.svyphonegapFingerprintscan.registerSecret({
		description: "Some biometric description",
		secret: "my-super-secret",
		invalidateOnEnrollment: true,
		disableBackup: true // always disabled on Android
	}, registerSuccessful, null)
}

/**
 * callback when secret is registered to vault
 * @param e
 *
 * @properties={typeid:24,uuid:"3A7DE52F-6361-42AF-9478-418A66508365"}
 */
function registerSuccessful(e){
	application.output('registered secret successfully');
}

/**
 * Load a vault secret
 *
 * @param {JSEvent} event
 *
 * @private
 *
 * @properties={typeid:24,uuid:"F0941178-FD1B-497E-B8D6-937B7A499A4E"}
 */
function onAction$loadSecret(event) {	
	plugins.svyphonegapFingerprintscan.loadSecret({
		description: "Some biometric description",
		disableBackup: true // always disabled on Android
	},loadSuccessCallback,null)
}

/**
 * callback method when finished loading secret succesfully from device vault
 *
 * @properties={typeid:24,uuid:"063F92C9-47AB-405A-96E4-BB5373D15675"}
 */
function loadSuccessCallback(d){
	application.output('secret from vault recovered: ' + d); 
}


</code></pre>
