@capgo/capacitor-native-biometric 7.1.7 → 7.1.13
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
|
|
6
|
-
<h2><a href="https://capgo.app/consulting/?ref=plugin">
|
|
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
|
|
12
|
+
## Installation (Only supports Capacitor 7)
|
|
13
13
|
|
|
14
14
|
- `npm i @capgo/capacitor-native-biometric`
|
|
15
15
|
|
|
@@ -278,26 +278,6 @@ To use android's BiometricPrompt api you must add the following permission to yo
|
|
|
278
278
|
<uses-permission android:name="android.permission.USE_BIOMETRIC">
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
And register the plugin by adding it to you MainActivity's onCreate (Not needed for Capacitor 3):
|
|
282
|
-
|
|
283
|
-
```java
|
|
284
|
-
import ee.forgr.biometric.NativeBiometric;
|
|
285
|
-
|
|
286
|
-
public class MainActivity extends BridgeActivity {
|
|
287
|
-
@Override
|
|
288
|
-
public void onCreate(Bundle savedInstanceState) {
|
|
289
|
-
super.onCreate(savedInstanceState);
|
|
290
|
-
|
|
291
|
-
// Initializes the Bridge
|
|
292
|
-
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
|
|
293
|
-
// Additional plugins you've installed go here
|
|
294
|
-
// Ex: add(TotallyAwesomePlugin.class);
|
|
295
|
-
add(NativeBiometric.class);
|
|
296
|
-
}});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
```
|
|
300
|
-
|
|
301
281
|
## Contributors
|
|
302
282
|
|
|
303
283
|
[Jonthia](https://github.com/jonthia)
|
|
@@ -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
|
-
|
|
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