@capgo/capacitor-native-biometric 7.1.7 → 7.1.12

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
@@ -1,15 +1,15 @@
1
1
  # Capacitor Native Biometric
2
2
  <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
-
3
+
4
4
  <div align="center">
5
- <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo 🚀</a></h2>
6
- <h2><a href="https://capgo.app/consulting/?ref=plugin"> Fix your annoying bug now, Hire a Capacitor expert 💪</a></h2>
5
+ <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
7
7
  </div>
8
8
 
9
9
 
10
10
  Use biometrics confirm device owner presence or authenticate users. A couple of methods are provided to handle user credentials. These are securely stored using Keychain (iOS) and Keystore (Android).
11
11
 
12
- ## Installation (Only supports Capacitor 6)
12
+ ## Installation (Only supports Capacitor 7)
13
13
 
14
14
  - `npm i @capgo/capacitor-native-biometric`
15
15
 
@@ -14,6 +14,7 @@ import java.util.concurrent.Executor;
14
14
 
15
15
  public class AuthActivity extends AppCompatActivity {
16
16
 
17
+ private BiometricPrompt biometricPrompt;
17
18
  private int maxAttempts;
18
19
  private int counter = 0;
19
20
 
@@ -76,7 +77,7 @@ public class AuthActivity extends AppCompatActivity {
76
77
 
77
78
  BiometricPrompt.PromptInfo promptInfo = builder.build();
78
79
 
79
- BiometricPrompt biometricPrompt = new BiometricPrompt(
80
+ biometricPrompt = new BiometricPrompt(
80
81
  this,
81
82
  executor,
82
83
  new BiometricPrompt.AuthenticationCallback() {
@@ -112,6 +113,7 @@ public class AuthActivity extends AppCompatActivity {
112
113
  super.onAuthenticationFailed();
113
114
  counter++;
114
115
  if (counter >= maxAttempts) {
116
+ biometricPrompt.cancelAuthentication();
115
117
  // Use error code 4 for too many attempts to match iOS behavior
116
118
  finishActivity("error", 4, "Too many failed attempts");
117
119
  }
@@ -468,9 +468,18 @@ public class NativeBiometric extends Plugin {
468
468
  )
469
469
  .setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA512)
470
470
  .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)
471
+ .setUserAuthenticationRequired(true)
472
+ // Set authentication validity duration to 0 to require authentication for every use
473
+ .setUserAuthenticationParameters(
474
+ 0,
475
+ KeyProperties.AUTH_BIOMETRIC_STRONG
476
+ )
471
477
  .build()
472
478
  );
473
479
  keyPairGenerator.generateKeyPair();
480
+ // Get the newly generated key entry
481
+ privateKeyEntry = (KeyStore.PrivateKeyEntry) getKeyStore()
482
+ .getEntry(KEY_ALIAS, null);
474
483
  }
475
484
 
476
485
  return privateKeyEntry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-biometric",
3
- "version": "7.1.7",
3
+ "version": "7.1.12",
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",