@capgo/capacitor-native-biometric 7.1.6 → 7.1.7

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.
@@ -86,9 +86,16 @@ public class AuthActivity extends AppCompatActivity {
86
86
  @NonNull CharSequence errString
87
87
  ) {
88
88
  super.onAuthenticationError(errorCode, errString);
89
- int pluginErrorCode = AuthActivity.convertToPluginErrorCode(
90
- errorCode
91
- );
89
+ // Handle lockout cases explicitly
90
+ if (
91
+ errorCode == BiometricPrompt.ERROR_LOCKOUT ||
92
+ errorCode == BiometricPrompt.ERROR_LOCKOUT_PERMANENT
93
+ ) {
94
+ int pluginErrorCode = convertToPluginErrorCode(errorCode);
95
+ finishActivity("error", pluginErrorCode, errString.toString());
96
+ return;
97
+ }
98
+ int pluginErrorCode = convertToPluginErrorCode(errorCode);
92
99
  finishActivity("error", pluginErrorCode, errString.toString());
93
100
  }
94
101
 
@@ -104,11 +111,10 @@ public class AuthActivity extends AppCompatActivity {
104
111
  public void onAuthenticationFailed() {
105
112
  super.onAuthenticationFailed();
106
113
  counter++;
107
- if (counter == maxAttempts) finishActivity(
108
- "failed",
109
- 10,
110
- "Authentication failed."
111
- );
114
+ if (counter >= maxAttempts) {
115
+ // Use error code 4 for too many attempts to match iOS behavior
116
+ finishActivity("error", 4, "Too many failed attempts");
117
+ }
112
118
  }
113
119
  }
114
120
  );
@@ -146,11 +152,11 @@ public class AuthActivity extends AppCompatActivity {
146
152
  case BiometricPrompt.ERROR_HW_NOT_PRESENT:
147
153
  return 1;
148
154
  case BiometricPrompt.ERROR_LOCKOUT_PERMANENT:
149
- return 2;
155
+ return 2; // Permanent lockout
150
156
  case BiometricPrompt.ERROR_NO_BIOMETRICS:
151
157
  return 3;
152
158
  case BiometricPrompt.ERROR_LOCKOUT:
153
- return 4;
159
+ return 4; // Temporary lockout (too many attempts)
154
160
  // Authentication Failure (10) Handled by `onAuthenticationFailed`.
155
161
  // App Cancel (11), Invalid Context (12), and Not Interactive (13) are not valid error codes for Android.
156
162
  case BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL:
@@ -161,6 +167,8 @@ public class AuthActivity extends AppCompatActivity {
161
167
  case BiometricPrompt.ERROR_USER_CANCELED:
162
168
  case BiometricPrompt.ERROR_NEGATIVE_BUTTON:
163
169
  return 16;
170
+ case BiometricPrompt.AUTHENTICATION_RESULT_TYPE_BIOMETRIC:
171
+ return 0; // Success case, should not be handled here
164
172
  default:
165
173
  return 0;
166
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-biometric",
3
- "version": "7.1.6",
3
+ "version": "7.1.7",
4
4
  "description": "This plugin gives access to the native biometric apis for android and iOS",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",