ionic-native
Version:
Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support
105 lines • 4.62 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Cordova, Plugin } from './plugin';
/**
* @name TouchID
* @description
* Scan the fingerprint of a user with the TouchID sensor.
*
* Requires Cordova plugin: `cordova-plugin-touch-id`. For more info, please see the [TouchID plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-touch-id).
*
* @usage
* ### Import Touch ID Plugin into Project
* ```typescript
* import { TouchID } from 'ionic-native';
* ```
* ### Check for Touch ID Availability
* ```typescript
* TouchID.isAvailable()
* .then(
* res => console.log('TouchID is available!'),
* err => console.error('TouchID is not available', err)
* );
* ```
* ### Invoke Touch ID w/ Custom Message
*
* ```typescript
* TouchID.verifyFingerprint('Scan your fingerprint please')
* .then(
* res => console.log('Ok', res),
* err => console.error('Error', err)
* );
* ```
*
* ### Error Codes
*
* The plugin will reject for various reasons. Your app will most likely need to respond to the cases differently.
*
* Here is a list of some of the error codes:
*
* - `-1` - Fingerprint scan failed more than 3 times
* - `-2` or `-128` - User tapped the 'Cancel' button
* - `-3` - User tapped the 'Enter Passcode' or 'Enter Password' button
* - `-4` - The scan was cancelled by the system (Home button for example)
* - `-6` - TouchID is not Available
* - `-8` - TouchID is locked out from too many tries
*/
export var TouchID = (function () {
function TouchID() {
}
/**
* Checks Whether TouchID is available or not.
*
* @returns {Promise<any>} Returns a Promise that resolves if yes, rejects if no.
*/
TouchID.isAvailable = function () { return; };
/**
* Show TouchID dialog and wait for a fingerprint scan. If user taps 'Enter Password' button, brings up standard system passcode screen.
*
* @param {string} message The message to display
* @returns {Promise<any>} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above).
*/
TouchID.verifyFingerprint = function (message) { return; };
/**
* Show TouchID dialog and wait for a fingerprint scan. If user taps 'Enter Password' button, rejects with code '-3' (see above).
*
* @param {string} message The message to display
* @returns {Promise<any>} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above).
*/
TouchID.verifyFingerprintWithCustomPasswordFallback = function (message) { return; };
/**
* Show TouchID dialog with custom 'Enter Password' message and wait for a fingerprint scan. If user taps 'Enter Password' button, rejects with code '-3' (see above).
*
* @param {string} message The message to display
* @param {string} enterPasswordLabel Custom text for the 'Enter Password' button
* @returns {Promise<any>} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above).
*/
TouchID.verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel = function (message, enterPasswordLabel) { return; };
__decorate([
Cordova()
], TouchID, "isAvailable", null);
__decorate([
Cordova()
], TouchID, "verifyFingerprint", null);
__decorate([
Cordova()
], TouchID, "verifyFingerprintWithCustomPasswordFallback", null);
__decorate([
Cordova()
], TouchID, "verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel", null);
TouchID = __decorate([
Plugin({
pluginName: 'TouchID',
plugin: 'cordova-plugin-touch-id',
pluginRef: 'plugins.touchid',
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-touch-id',
platforms: ['iOS']
})
], TouchID);
return TouchID;
}());
//# sourceMappingURL=touchid.js.map