diff --git a/dist/plugins/touchid.d.ts b/dist/plugins/touchid.d.ts index 4c068a2e2..49e065c16 100644 --- a/dist/plugins/touchid.d.ts +++ b/dist/plugins/touchid.d.ts @@ -1,6 +1,49 @@ +/** + * 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). + * + * ### 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 declare class TouchID { - isAvailable(): void; - static verifyFingerprint(message: string): void; - static verifyFingerprintWithCustomPasswordFallback(message: string): void; - static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message: string, enterPasswordLabel: string): void; + /** + * Whether TouchID is available or not. + * + * @return {Promise} Returns a Promise that resolves if yes, rejects if no. + */ + isAvailable(): Promise; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + static verifyFingerprint(message: string): Promise; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + static verifyFingerprintWithCustomPasswordFallback(message: string): Promise; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message: string, enterPasswordLabel: string): Promise; } diff --git a/dist/plugins/touchid.js b/dist/plugins/touchid.js index 04e90b72d..ce399b47b 100644 --- a/dist/plugins/touchid.js +++ b/dist/plugins/touchid.js @@ -5,14 +5,85 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, return c > 3 && r && Object.defineProperty(target, key, r), r; }; var plugin_1 = require('./plugin'); +/** + * 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). + * + * ### 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 + * + */ var TouchID = (function () { function TouchID() { } - TouchID.prototype.isAvailable = function () { }; + /** + * Whether TouchID is available or not. + * + * @return {Promise} Returns a Promise that resolves if yes, rejects if no. + */ + TouchID.prototype.isAvailable = function () { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise(function (res, rej) { }); + }; ; - TouchID.verifyFingerprint = function (message) { }; - TouchID.verifyFingerprintWithCustomPasswordFallback = function (message) { }; - TouchID.verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel = function (message, enterPasswordLabel) { }; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + TouchID.verifyFingerprint = function (message) { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise(function (res, rej) { }); + }; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + TouchID.verifyFingerprintWithCustomPasswordFallback = function (message) { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise(function (res, rej) { }); + }; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + TouchID.verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel = function (message, enterPasswordLabel) { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise(function (res, rej) { }); + }; __decorate([ plugin_1.Cordova() ], TouchID.prototype, "isAvailable", null); diff --git a/dist/plugins/touchid.js.map b/dist/plugins/touchid.js.map index c4c4c734e..33b9cb30d 100644 --- a/dist/plugins/touchid.js.map +++ b/dist/plugins/touchid.js.map @@ -1 +1 @@ -{"version":3,"file":"touchid.js","sourceRoot":"","sources":["../../src/plugins/touchid.ts"],"names":["TouchID","TouchID.constructor","TouchID.isAvailable","TouchID.verifyFingerprint","TouchID.verifyFingerprintWithCustomPasswordFallback","TouchID.verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAkBAC,CAACA;IAVCD,6BAAWA,GADXA,cACeE,CAACA;;IAGTF,yBAAiBA,GADxBA,UACyBA,OAAcA,IAAGG,CAACA;IAGpCH,mDAA2CA,GADlDA,UACmDA,OAAcA,IAAGI,CAACA;IAG9DJ,wEAAgEA,GADvEA,UACwEA,OAAcA,EAAEA,kBAAyBA,IAAGK,CAACA;IAVrHL;QAACA,gBAAOA,EAAEA;OACVA,gCAAWA,QAAKA;IAEhBA;QAACA,gBAAOA,EAAEA;OACHA,4BAAiBA,QAAmBA;IAE3CA;QAACA,gBAAOA,EAAEA;OACHA,sDAA2CA,QAAmBA;IAErEA;QAACA,gBAAOA,EAAEA;OACHA,2EAAgEA,QAA8CA;IAjBvHA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,SAASA;YACfA,MAAMA,EAAEA,yBAAyBA;YACjCA,SAASA,EAAEA,iBAAiBA;YAC5BA,IAAIA,EAAEA,2DAA2DA;SAClEA,CAACA;gBAaDA;IAADA,cAACA;AAADA,CAACA,AAlBD,IAkBC;AAZY,eAAO,UAYnB,CAAA"} \ No newline at end of file +{"version":3,"file":"touchid.js","sourceRoot":"","sources":["../../src/plugins/touchid.ts"],"names":["TouchID","TouchID.constructor","TouchID.isAvailable","TouchID.verifyFingerprint","TouchID.verifyFingerprintWithCustomPasswordFallback","TouchID.verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAAAA;IAuEAC,CAACA;IA/DCD;;;;OAIGA;IAEHA,6BAAWA,GADXA;QAEEE,yEAAyEA;QACzEA,oEAAoEA;QACpEA,wEAAwEA;QACxEA,mDAAmDA;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C5BA,IAAIA,EAAEA,2DAA2DA;SAClEA,CAACA;gBAkEDA;IAADA,cAACA;AAADA,CAACA,AAvED,IAuEC;AAjEY,eAAO,UAiEnB,CAAA"} \ No newline at end of file diff --git a/src/plugins/touchid.ts b/src/plugins/touchid.ts index 1b514dece..420b71439 100644 --- a/src/plugins/touchid.ts +++ b/src/plugins/touchid.ts @@ -1,5 +1,24 @@ import {Plugin, Cordova} from './plugin'; +/** + * 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). + * + * ### 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 + * + */ @Plugin({ name: 'TouchID', plugin: 'cordova-plugin-touch-id', @@ -7,15 +26,68 @@ import {Plugin, Cordova} from './plugin'; repo: 'https://github.com/EddyVerbruggen/cordova-plugin-touch-id' }) export class TouchID { - @Cordova() - isAvailable() {}; + /** + * Whether TouchID is available or not. + * + * @return {Promise} Returns a Promise that resolves if yes, rejects if no. + */ @Cordova() - static verifyFingerprint(message:string) {} + isAvailable() { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise((res, rej) => {}); + }; + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ @Cordova() - static verifyFingerprintWithCustomPasswordFallback(message:string) {} + static verifyFingerprint(message: string) { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise((res, rej) => {}); + } + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ @Cordova() - static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message:string, enterPasswordLabel:string) {} + static verifyFingerprintWithCustomPasswordFallback(message: string) { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise((res, rej) => {}); + } + + /** + * 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 + * @return {Promise} Returns a Promise the resolves if the fingerprint scan was successful, rejects with an error code (see above). + */ + @Cordova() + static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message: string, enterPasswordLabel: string) { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise((res, rej) => {}); + } }