@aparajita/capacitor-biometric-auth 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -147,14 +147,15 @@ Register a function that will be called when the app resumes. The function will
147
147
 
148
148
  #### AuthenticateOptions
149
149
 
150
- | Prop | Type | Description |
151
- | :-------------------- | :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
152
- | reason | string | The reason for requesting authentication. Displays in the authentication dialog presented to the user. If not supplied, a default message is displayed. |
153
- | cancelTitle | string | iOS: The system presents a cancel button during biometric authentication to let the user abort the authentication attempt. The button appears every time the system asks the user to present a finger registered with Touch ID. For Face ID, the button only appears if authentication fails and the user is prompted to try again. Either way, the user can stop trying to authenticate by tapping the button.<br><br>Android: The text for the negative button. This would typically be used as a "Cancel" button, but may be also used to show an alternative method for authentication, such as a screen that asks for a backup password.<br><br>Default: "Cancel" |
154
- | allowDeviceCredential | boolean | If true, allows for authentication using device unlock credentials. Default is false.<br><br>iOS: If biometry is available, enrolled, and not disabled, the system uses that first. After the first Touch ID failure or second Face ID failure, if `iosFallbackTitle` is not an empty string, a fallback button appears in the authentication dialog. If the user taps the fallback button, the system prompts the user for the device passcode or the user’s password. If `iosFallbackTitle` is an empty string, no fallback button will appear.<br><br>If biometry is not available, enrolled and enabled, and a passcode is set, the system immediately prompts the user for the device passcode or user’s password. Authentication fails with the error code `passcodeNotSet` if the device passcode isn’t enabled.<br><br>If a passcode is not set on the device, a `passcodeNotSet` error is returned.<br><br>The system disables passcode authentication after 6 unsuccessful attempts, with progressively increasing delays between attempts.<br><br>The title of the fallback button may be customized by setting `iosFallbackTitle` to a non-empty string.<br><br>Android: The user will first be prompted to authenticate with biometrics, but also given the option to authenticate with their device PIN, pattern, or password by tapping a button in the authentication dialog. The title of the button is supplied by the system. |
155
- | iosFallbackTitle | string | The system presents a fallback button when biometric authentication fails — for example, because the system doesn’t recognize the presented finger, or after several failed attempts to recognize the user’s face.<br><br>If `allowDeviceCredential` is false, tapping this button dismisses the authentication dialog and returns the error code userFallback. If undefined, the localized system default title is used. Passing an empty string hides the fallback button completely.<br><br>If `allowDeviceCredential` is true and this is undefined, the localized system default title is used. |
156
- | androidTitle | string | Title for the Android dialog. If not supplied, the system default is used. |
157
- | androidSubtitle | string | Subtitle for the Android dialog. If not supplied, the system default is used. |
150
+ | Prop | Type | Description |
151
+ | :-------------------------- | :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
152
+ | reason | string | The reason for requesting authentication. Displays in the authentication dialog presented to the user. If not supplied, a default message is displayed. |
153
+ | cancelTitle | string | iOS: The system presents a cancel button during biometric authentication to let the user abort the authentication attempt. The button appears every time the system asks the user to present a finger registered with Touch ID. For Face ID, the button only appears if authentication fails and the user is prompted to try again. Either way, the user can stop trying to authenticate by tapping the button.<br><br>Android: The text for the negative button. This would typically be used as a "Cancel" button, but may be also used to show an alternative method for authentication, such as a screen that asks for a backup password.<br><br>Default: "Cancel" |
154
+ | allowDeviceCredential | boolean | If true, allows for authentication using device unlock credentials. Default is false.<br><br>iOS: If biometry is available, enrolled, and not disabled, the system uses that first. After the first Touch ID failure or second Face ID failure, if `iosFallbackTitle` is not an empty string, a fallback button appears in the authentication dialog. If the user taps the fallback button, the system prompts the user for the device passcode or the user’s password. If `iosFallbackTitle` is an empty string, no fallback button will appear.<br><br>If biometry is not available, enrolled and enabled, and a passcode is set, the system immediately prompts the user for the device passcode or user’s password. Authentication fails with the error code `passcodeNotSet` if the device passcode isn’t enabled.<br><br>If a passcode is not set on the device, a `passcodeNotSet` error is returned.<br><br>The system disables passcode authentication after 6 unsuccessful attempts, with progressively increasing delays between attempts.<br><br>The title of the fallback button may be customized by setting `iosFallbackTitle` to a non-empty string.<br><br>Android: The user will first be prompted to authenticate with biometrics, but also given the option to authenticate with their device PIN, pattern, or password by tapping a button in the authentication dialog. The title of the button is supplied by the system. |
155
+ | iosFallbackTitle | string | The system presents a fallback button when biometric authentication fails — for example, because the system doesn’t recognize the presented finger, or after several failed attempts to recognize the user’s face.<br><br>If `allowDeviceCredential` is false, tapping this button dismisses the authentication dialog and returns the error code userFallback. If undefined, the localized system default title is used. Passing an empty string hides the fallback button completely.<br><br>If `allowDeviceCredential` is true and this is undefined, the localized system default title is used. |
156
+ | androidTitle | string | Title for the Android dialog. If not supplied, the system default is used. |
157
+ | androidSubtitle | string | Subtitle for the Android dialog. If not supplied, the system default is used. |
158
+ | androidConfirmationRequired | boolean | For information on this setting, see:<br><br>https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt.Builder#setConfirmationRequired(boolean)<br><br>If not set, defaults to true. |
158
159
 
159
160
  #### PluginListenerHandle
160
161
 
@@ -7,6 +7,7 @@ import android.hardware.biometrics.BiometricManager;
7
7
  import android.os.Build;
8
8
  import android.os.Bundle;
9
9
  import android.os.Handler;
10
+ import android.util.Log;
10
11
  import androidx.annotation.NonNull;
11
12
  import androidx.appcompat.app.AppCompatActivity;
12
13
  import androidx.biometric.BiometricPrompt;
@@ -81,6 +82,10 @@ public class AuthActivity extends AppCompatActivity {
81
82
  );
82
83
  }
83
84
 
85
+ builder.setConfirmationRequired(
86
+ intent.getBooleanExtra(BiometricAuthNative.CONFIRMATION_REQUIRED, true)
87
+ );
88
+
84
89
  BiometricPrompt.PromptInfo promptInfo = builder.build();
85
90
  BiometricPrompt prompt = new BiometricPrompt(
86
91
  this,
@@ -30,6 +30,8 @@ public class BiometricAuthNative extends Plugin {
30
30
  public static final String REASON = "reason";
31
31
  public static final String CANCEL_TITLE = "cancelTitle";
32
32
  public static final String DEVICE_CREDENTIAL = "allowDeviceCredential";
33
+ public static final String CONFIRMATION_REQUIRED =
34
+ "androidConfirmationRequired";
33
35
  public static final String MAX_ATTEMPTS = "androidMaxAttempts";
34
36
  public static final int DEFAULT_MAX_ATTEMPTS = 3;
35
37
  // Error code when biometry is not recognized
@@ -205,6 +207,13 @@ public class BiometricAuthNative extends Plugin {
205
207
  call.getBoolean(DEVICE_CREDENTIAL, false)
206
208
  );
207
209
 
210
+ if (call.hasOption(CONFIRMATION_REQUIRED)) {
211
+ intent.putExtra(
212
+ CONFIRMATION_REQUIRED,
213
+ call.getBoolean(CONFIRMATION_REQUIRED, true)
214
+ );
215
+ }
216
+
208
217
  // Just in case the developer does something dumb like using a number < 1...
209
218
  Integer maxAttemptsConfig = call.getInt(MAX_ATTEMPTS, DEFAULT_MAX_ATTEMPTS);
210
219
  int maxAttempts = Math.max(
@@ -100,6 +100,14 @@ export interface AuthenticateOptions {
100
100
  * Subtitle for the Android dialog. If not supplied, the system default is used.
101
101
  */
102
102
  androidSubtitle?: string;
103
+ /**
104
+ * For information on this setting, see:
105
+ *
106
+ * https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt.Builder#setConfirmationRequired(boolean)
107
+ *
108
+ * If not set, defaults to true.
109
+ */
110
+ androidConfirmationRequired?: boolean;
103
111
  }
104
112
  /**
105
113
  * If the `authenticate()` method throws an exception, the error object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aparajita/capacitor-biometric-auth",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "Provides access to the native biometric auth APIs for Capacitor apps",
5
5
  "author": "Aparajita Fishman",
6
6
  "license": "MIT",