UNPKG

5 kBTypeScriptView Raw
1export interface AndroidFingerprintAuthOptions {
2 /**
3 * Required
4 * Used as the alias for your key in the Android Key Store.
5 */
6 clientId: string;
7 /**
8 * Used to create credential string for encrypted token and as alias to retrieve the cipher.
9 */
10 username?: string;
11 /**
12 * Used to create credential string for encrypted token
13 */
14 password?: string;
15 /**
16 * Required for decrypt()
17 * Encrypted user credentials to decrypt upon successful authentication.
18 */
19 token?: string;
20 /**
21 * Set to true to remove the "USE BACKUP" button
22 */
23 disableBackup?: boolean;
24 /**
25 * Change the language. (en_US or es)
26 */
27 locale?: string;
28 /**
29 * The device max is 5 attempts. Set this parameter if you want to allow fewer than 5 attempts.
30 */
31 maxAttempts?: number;
32 /**
33 * Require the user to authenticate with a fingerprint to authorize every use of the key.
34 * New fingerprint enrollment will invalidate key and require backup authenticate to
35 * re-enable the fingerprint authentication dialog.
36 */
37 userAuthRequired?: boolean;
38 /**
39 * Set the title of the fingerprint authentication dialog.
40 */
41 dialogTitle?: string;
42 /**
43 * Set the message of the fingerprint authentication dialog.
44 */
45 dialogMessage?: string;
46 /**
47 * Set the hint displayed by the fingerprint icon on the fingerprint authentication dialog.
48 */
49 dialogHint?: string;
50}
51/**
52 * @name Android Fingerprint Auth
53 * @description
54 * 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.
55 * @usage
56 * ```typescript
57 * import { AndroidFingerprintAuth } from 'ionic-native';
58 *
59 * AndroidFingerprintAuth.isAvailable()
60 * .then((result)=> {
61 * if(result.isAvailable){
62 * // it is available
63 *
64 * AndroidFingerprintAuth.encrypt({ clientId: "myAppName", username: "myUsername", password: "myPassword" })
65 * .then(result => {
66 * if (result.withFingerprint) {
67 * console.log("Successfully encrypted credentials.");
68 * console.log("Encrypted credentials: " + result.token);
69 * } else if (result.withBackup) {
70 * console.log('Successfully authenticated with backup password!');
71 * } else console.log('Didn\'t authenticate!');
72 * })
73 * .catch(error => {
74 * if (error === "Cancelled") {
75 * console.log("Fingerprint authentication cancelled");
76 * } else console.error(error)
77 * });
78 *
79 * } else {
80 * // fingerprint auth isn't available
81 * }
82 * })
83 * .catch(error => console.error(error));
84 * ```
85 * @interfaces
86 * AndroidFingerprintAuthOptions
87 */
88export declare class AndroidFingerprintAuth {
89 /**
90 * Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
91 * @param options {AndroidFingerprintAuthOptions} Options
92 * @returns {Promise<any>}
93 */
94 static encrypt(options: AndroidFingerprintAuthOptions): Promise<{
95 /**
96 * Biometric authentication
97 */
98 withFingerprint: boolean;
99 /**
100 * Authentication using backup credential activity
101 */
102 withBackup: boolean;
103 /**
104 * base64encoded string representation of user credentials
105 */
106 token: string;
107 }>;
108 /**
109 * Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
110 * @param options {AndroidFingerprintAuthOptions} Options
111 * @returns {Promise<any>}
112 */
113 static decrypt(options: AndroidFingerprintAuthOptions): Promise<{
114 /**
115 * Biometric authentication
116 */
117 withFingerprint: boolean;
118 /**
119 * Authentication using backup credential activity
120 */
121 withBackup: boolean;
122 /**
123 * FingerprintAuth.CipherMode.DECRYPT
124 * Decrypted password
125 */
126 password: string;
127 }>;
128 /**
129 * Check if service is available
130 * @returns {Promise<any>} Returns a Promise that resolves if fingerprint auth is available on the device
131 */
132 static isAvailable(): Promise<{
133 isAvailable: boolean;
134 }>;
135 /**
136 * Delete the cipher used for encryption and decryption by username
137 * @returns {Promise<any>} Returns a Promise that resolves if the cipher was successfully deleted
138 */
139 static delete(options: {
140 clientId: string;
141 username: string;
142 }): Promise<{
143 deleted: boolean;
144 }>;
145}