UNPKG

4.25 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 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;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name Android Fingerprint Auth
11 * @description
12 * This plugin 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.
13 * @usage
14 * ```typescript
15 * import { AndroidFingerprintAuth } from 'ionic-native';
16 *
17 * AndroidFingerprintAuth.isAvailable()
18 * .then((result)=> {
19 * if(result.isAvailable){
20 * // it is available
21 *
22 * AndroidFingerprintAuth.encrypt({ clientId: "myAppName", username: "myUsername", password: "myPassword" })
23 * .then(result => {
24 * if (result.withFingerprint) {
25 * console.log("Successfully encrypted credentials.");
26 * console.log("Encrypted credentials: " + result.token);
27 * } else if (result.withBackup) {
28 * console.log('Successfully authenticated with backup password!');
29 * } else console.log('Didn\'t authenticate!');
30 * })
31 * .catch(error => {
32 * if (error === "Cancelled") {
33 * console.log("Fingerprint authentication cancelled");
34 * } else console.error(error)
35 * });
36 *
37 * } else {
38 * // fingerprint auth isn't available
39 * }
40 * })
41 * .catch(error => console.error(error));
42 * ```
43 * @interfaces
44 * AndroidFingerprintAuthOptions
45 */
46var AndroidFingerprintAuth = (function () {
47 function AndroidFingerprintAuth() {
48 }
49 /**
50 * Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
51 * @param options {AndroidFingerprintAuthOptions} Options
52 * @returns {Promise<any>}
53 */
54 AndroidFingerprintAuth.encrypt = function (options) { return; };
55 /**
56 * Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
57 * @param options {AndroidFingerprintAuthOptions} Options
58 * @returns {Promise<any>}
59 */
60 AndroidFingerprintAuth.decrypt = function (options) { return; };
61 /**
62 * Check if service is available
63 * @returns {Promise<any>} Returns a Promise that resolves if fingerprint auth is available on the device
64 */
65 AndroidFingerprintAuth.isAvailable = function () { return; };
66 /**
67 * Delete the cipher used for encryption and decryption by username
68 * @returns {Promise<any>} Returns a Promise that resolves if the cipher was successfully deleted
69 */
70 AndroidFingerprintAuth.delete = function (options) { return; };
71 __decorate([
72 plugin_1.Cordova()
73 ], AndroidFingerprintAuth, "encrypt", null);
74 __decorate([
75 plugin_1.Cordova()
76 ], AndroidFingerprintAuth, "decrypt", null);
77 __decorate([
78 plugin_1.Cordova()
79 ], AndroidFingerprintAuth, "isAvailable", null);
80 __decorate([
81 plugin_1.Cordova()
82 ], AndroidFingerprintAuth, "delete", null);
83 AndroidFingerprintAuth = __decorate([
84 plugin_1.Plugin({
85 pluginName: 'AndroidFingerprintAuth',
86 plugin: 'cordova-plugin-android-fingerprint-auth',
87 pluginRef: 'FingerprintAuth',
88 repo: 'https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth'
89 })
90 ], AndroidFingerprintAuth);
91 return AndroidFingerprintAuth;
92}());
93exports.AndroidFingerprintAuth = AndroidFingerprintAuth;
94//# sourceMappingURL=android-fingerprint-auth.js.map
\No newline at end of file