@capgo/capacitor-native-biometric 5.0.1 → 5.1.1
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/LICENSE +2 -2
- package/{readme.md → README.md} +49 -22
- package/android/build.gradle +9 -9
- package/android/gradlew +8 -4
- package/android/src/main/java/ee/forgr/biometric/AuthActivity.java +69 -37
- package/android/src/main/java/ee/forgr/biometric/NativeBiometric.java +121 -74
- package/dist/docs.json +27 -13
- package/dist/esm/definitions.d.ts +31 -3
- package/dist/esm/definitions.js +27 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +3 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +24 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +26 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Plugin.swift +60 -58
- package/ios/Podfile.lock +4 -4
- package/ios/Pods/Local Podspecs/Capacitor.podspec.json +2 -2
- package/ios/Pods/Local Podspecs/CapacitorCordova.podspec.json +2 -2
- package/ios/Pods/Manifest.lock +4 -4
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +572 -572
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-Info.plist +1 -1
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-Info.plist +1 -1
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh +0 -0
- package/package.json +17 -22
- package/android/.gradle/8.0.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.0.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.0.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.0.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.0.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.0.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.0.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.0.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.0.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.0.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/android.iml +0 -40
- package/android/local.properties +0 -8
- package/ios/Plugin.xcodeproj/project.xcworkspace/xcuserdata/pilito.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Plugin.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Plugin.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Plugin.xcodeproj/xcuserdata/pilito.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Plugin.xcworkspace/xcuserdata/jmartinez.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Plugin.xcworkspace/xcuserdata/josemartinez.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Plugin.xcworkspace/xcuserdata/pilito.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/Capacitor.xcscheme +0 -60
- package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/xcschememanagement.plist +0 -39
- package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/Capacitor.xcscheme +0 -60
- package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/xcschememanagement.plist +0 -39
- package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/Capacitor.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +0 -58
- package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/xcschememanagement.plist +0 -31
- package/ios/Pods/Pods.xcodeproj/xcuserdata/pilito.xcuserdatad/xcschemes/xcschememanagement.plist +0 -29
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) Martin Donadieu.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/{readme.md → README.md}
RENAMED
|
@@ -9,9 +9,9 @@ Use biometrics confirm device owner presence or authenticate users. A couple of
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import { NativeBiometric } from "@capgo/capacitor-native-biometric";
|
|
12
|
+
import { NativeBiometric, BiometryType } from "@capgo/capacitor-native-biometric";
|
|
13
13
|
|
|
14
|
-
async
|
|
14
|
+
async performBiometricVerification(){
|
|
15
15
|
const result = await NativeBiometric.isAvailable();
|
|
16
16
|
|
|
17
17
|
if(!result.isAvailable) return;
|
|
@@ -46,6 +46,27 @@ NativeBiometric.deleteCredentials({
|
|
|
46
46
|
server: "www.example.com",
|
|
47
47
|
}).then();
|
|
48
48
|
```
|
|
49
|
+
|
|
50
|
+
### Biometric Auth Errors
|
|
51
|
+
|
|
52
|
+
This is a plugin specific list of error codes that can be thrown on verifyIdentity failure, or set as a part of isAvailable. It consolidates Android and iOS specific Authentication Error codes into one combined error list.
|
|
53
|
+
|
|
54
|
+
| Code | Description | Platform |
|
|
55
|
+
| ---- | --------------------------- | ---------------------------- |
|
|
56
|
+
| 0 | Unknown Error | Android, iOS |
|
|
57
|
+
| 1 | Biometrics Unavailable | Android, iOS |
|
|
58
|
+
| 2 | User Lockout | Android, iOS |
|
|
59
|
+
| 3 | Biometrics Not Enrolled | Android, iOS |
|
|
60
|
+
| 4 | User Temporary Lockout | Android (Lockout for 30sec) |
|
|
61
|
+
| 10 | Authentication Failed | Android, iOS |
|
|
62
|
+
| 11 | App Cancel | iOS |
|
|
63
|
+
| 12 | Invalid Context | iOS |
|
|
64
|
+
| 13 | Not Interactive | iOS |
|
|
65
|
+
| 14 | Passcode Not Set | Android, iOS |
|
|
66
|
+
| 15 | System Cancel | Android, iOS |
|
|
67
|
+
| 16 | User Cancel | Android, iOS |
|
|
68
|
+
| 17 | User Fallback | Android, iOS |
|
|
69
|
+
|
|
49
70
|
<docgen-index>
|
|
50
71
|
|
|
51
72
|
* [`isAvailable(...)`](#isavailable)
|
|
@@ -64,7 +85,7 @@ NativeBiometric.deleteCredentials({
|
|
|
64
85
|
### isAvailable(...)
|
|
65
86
|
|
|
66
87
|
```typescript
|
|
67
|
-
isAvailable(options?: IsAvailableOptions) => any
|
|
88
|
+
isAvailable(options?: IsAvailableOptions | undefined) => any
|
|
68
89
|
```
|
|
69
90
|
|
|
70
91
|
Checks if biometric authentication hardware is available.
|
|
@@ -83,7 +104,7 @@ Checks if biometric authentication hardware is available.
|
|
|
83
104
|
### verifyIdentity(...)
|
|
84
105
|
|
|
85
106
|
```typescript
|
|
86
|
-
verifyIdentity(options?: BiometricOptions) => any
|
|
107
|
+
verifyIdentity(options?: BiometricOptions | undefined) => any
|
|
87
108
|
```
|
|
88
109
|
|
|
89
110
|
Prompts the user to authenticate with biometrics.
|
|
@@ -177,15 +198,16 @@ Deletes the stored credentials for a given server.
|
|
|
177
198
|
|
|
178
199
|
#### BiometricOptions
|
|
179
200
|
|
|
180
|
-
| Prop | Type | Description
|
|
181
|
-
| ------------------------ | -------------------- |
|
|
182
|
-
| **`reason`** | <code>string</code> |
|
|
183
|
-
| **`title`** | <code>string</code> |
|
|
184
|
-
| **`subtitle`** | <code>string</code> |
|
|
185
|
-
| **`description`** | <code>string</code> |
|
|
186
|
-
| **`negativeButtonText`** | <code>string</code> |
|
|
187
|
-
| **`useFallback`** | <code>boolean</code> |
|
|
188
|
-
| **`
|
|
201
|
+
| Prop | Type | Description | Default |
|
|
202
|
+
| ------------------------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
|
203
|
+
| **`reason`** | <code>string</code> | | |
|
|
204
|
+
| **`title`** | <code>string</code> | | |
|
|
205
|
+
| **`subtitle`** | <code>string</code> | | |
|
|
206
|
+
| **`description`** | <code>string</code> | | |
|
|
207
|
+
| **`negativeButtonText`** | <code>string</code> | | |
|
|
208
|
+
| **`useFallback`** | <code>boolean</code> | Specifies if should fallback to passcode authentication if biometric authentication fails. | |
|
|
209
|
+
| **`fallbackTitle`** | <code>string</code> | Only for iOS. Set the text for the fallback button in the authentication dialog. If this property is not specified, the default text is set by the system. | |
|
|
210
|
+
| **`maxAttempts`** | <code>number</code> | Only for Android. Set a maximum number of attempts for biometric authentication. The maximum allowed by android is 5. | <code>1</code> |
|
|
189
211
|
|
|
190
212
|
|
|
191
213
|
#### GetCredentialOptions
|
|
@@ -224,15 +246,15 @@ Deletes the stored credentials for a given server.
|
|
|
224
246
|
|
|
225
247
|
#### BiometryType
|
|
226
248
|
|
|
227
|
-
| Members |
|
|
228
|
-
| ------------------------- |
|
|
229
|
-
| **`NONE`** |
|
|
230
|
-
| **`TOUCH_ID`** |
|
|
231
|
-
| **`FACE_ID`** |
|
|
232
|
-
| **`FINGERPRINT`** |
|
|
233
|
-
| **`FACE_AUTHENTICATION`** |
|
|
234
|
-
| **`IRIS_AUTHENTICATION`** |
|
|
235
|
-
| **`MULTIPLE`** |
|
|
249
|
+
| Members | Value |
|
|
250
|
+
| ------------------------- | -------------- |
|
|
251
|
+
| **`NONE`** | <code>0</code> |
|
|
252
|
+
| **`TOUCH_ID`** | <code>1</code> |
|
|
253
|
+
| **`FACE_ID`** | <code>2</code> |
|
|
254
|
+
| **`FINGERPRINT`** | <code>3</code> |
|
|
255
|
+
| **`FACE_AUTHENTICATION`** | <code>4</code> |
|
|
256
|
+
| **`IRIS_AUTHENTICATION`** | <code>5</code> |
|
|
257
|
+
| **`MULTIPLE`** | <code>6</code> |
|
|
236
258
|
|
|
237
259
|
</docgen-api>
|
|
238
260
|
## Face ID (iOS)
|
|
@@ -278,6 +300,11 @@ public class MainActivity extends BridgeActivity {
|
|
|
278
300
|
|
|
279
301
|
[Jonthia](https://github.com/jonthia)
|
|
280
302
|
[One Click Web Studio](https://github.com/oneclickwebstudio)
|
|
303
|
+
[Brian Weasner](https://github.com/brian-weasner)
|
|
304
|
+
[Mohamed Diarra](https://github.com/mohdiarra)
|
|
305
|
+
### Want to Contribute?
|
|
306
|
+
|
|
307
|
+
Learn about contributing [HERE](./CONTRIBUTING.md)
|
|
281
308
|
|
|
282
309
|
## Notes
|
|
283
310
|
|
package/android/build.gradle
CHANGED
|
@@ -2,15 +2,16 @@ ext {
|
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
3
|
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
4
4
|
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
5
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
buildscript {
|
|
8
9
|
repositories {
|
|
9
10
|
google()
|
|
10
|
-
|
|
11
|
+
mavenCentral()
|
|
11
12
|
}
|
|
12
13
|
dependencies {
|
|
13
|
-
classpath 'com.android.tools.build:gradle:8.0.
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.0.2'
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -39,20 +40,19 @@ android {
|
|
|
39
40
|
|
|
40
41
|
repositories {
|
|
41
42
|
google()
|
|
42
|
-
jcenter()
|
|
43
43
|
mavenCentral()
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
dependencies {
|
|
48
|
-
implementation 'androidx.biometric:biometric:1.0
|
|
48
|
+
implementation 'androidx.biometric:biometric:1.1.0'
|
|
49
49
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
50
50
|
implementation project(':capacitor-android')
|
|
51
|
-
implementation
|
|
52
|
-
implementation 'com.google.android.material:material:1.
|
|
53
|
-
implementation 'androidx.constraintlayout:constraintlayout:
|
|
54
|
-
implementation 'androidx.navigation:navigation-fragment:2.
|
|
55
|
-
implementation 'androidx.navigation:navigation-ui:2.
|
|
51
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
52
|
+
implementation 'com.google.android.material:material:1.9.0'
|
|
53
|
+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
|
54
|
+
implementation 'androidx.navigation:navigation-fragment:2.5.3'
|
|
55
|
+
implementation 'androidx.navigation:navigation-ui:2.5.3'
|
|
56
56
|
testImplementation "junit:junit:$junitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
58
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
package/android/gradlew
CHANGED
|
@@ -85,9 +85,6 @@ done
|
|
|
85
85
|
APP_BASE_NAME=${0##*/}
|
|
86
86
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
|
87
87
|
|
|
88
|
-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
89
|
-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
90
|
-
|
|
91
88
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
89
|
MAX_FD=maximum
|
|
93
90
|
|
|
@@ -133,10 +130,13 @@ location of your Java installation."
|
|
|
133
130
|
fi
|
|
134
131
|
else
|
|
135
132
|
JAVACMD=java
|
|
136
|
-
|
|
133
|
+
if ! command -v java >/dev/null 2>&1
|
|
134
|
+
then
|
|
135
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
137
136
|
|
|
138
137
|
Please set the JAVA_HOME variable in your environment to match the
|
|
139
138
|
location of your Java installation."
|
|
139
|
+
fi
|
|
140
140
|
fi
|
|
141
141
|
|
|
142
142
|
# Increase the maximum file descriptors if we can.
|
|
@@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
|
|
|
197
197
|
done
|
|
198
198
|
fi
|
|
199
199
|
|
|
200
|
+
|
|
201
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
202
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
203
|
+
|
|
200
204
|
# Collect all arguments for the java command;
|
|
201
205
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
|
202
206
|
# shell script including quotes and variable substitutions, so put them in
|
|
@@ -4,15 +4,10 @@ import android.content.Intent;
|
|
|
4
4
|
import android.os.Build;
|
|
5
5
|
import android.os.Bundle;
|
|
6
6
|
import android.os.Handler;
|
|
7
|
-
import android.util.Log;
|
|
8
|
-
import android.view.View;
|
|
9
7
|
import androidx.annotation.NonNull;
|
|
10
8
|
import androidx.appcompat.app.AppCompatActivity;
|
|
11
|
-
import androidx.appcompat.widget.Toolbar;
|
|
12
9
|
import androidx.biometric.BiometricPrompt;
|
|
13
10
|
import ee.forgr.biometric.capacitornativebiometric.R;
|
|
14
|
-
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
15
|
-
import com.google.android.material.snackbar.Snackbar;
|
|
16
11
|
import java.util.concurrent.Executor;
|
|
17
12
|
|
|
18
13
|
public class AuthActivity extends AppCompatActivity {
|
|
@@ -40,29 +35,31 @@ public class AuthActivity extends AppCompatActivity {
|
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
BiometricPrompt.PromptInfo.Builder builder =
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
getIntent().
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
getIntent().
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
getIntent().
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
38
|
+
BiometricPrompt.PromptInfo.Builder builder = new BiometricPrompt.PromptInfo.Builder()
|
|
39
|
+
.setTitle(
|
|
40
|
+
getIntent().hasExtra("title")
|
|
41
|
+
? getIntent().getStringExtra("title")
|
|
42
|
+
: "Authenticate"
|
|
43
|
+
)
|
|
44
|
+
.setSubtitle(
|
|
45
|
+
getIntent().hasExtra("subtitle")
|
|
46
|
+
? getIntent().getStringExtra("subtitle")
|
|
47
|
+
: null
|
|
48
|
+
)
|
|
49
|
+
.setDescription(
|
|
50
|
+
getIntent().hasExtra("description")
|
|
51
|
+
? getIntent().getStringExtra("description")
|
|
52
|
+
: null
|
|
53
|
+
);
|
|
60
54
|
|
|
61
55
|
boolean useFallback = getIntent().getBooleanExtra("useFallback", false);
|
|
62
56
|
|
|
63
57
|
if (useFallback) {
|
|
58
|
+
// TODO: Deprecated function, probably want to migrate to `setAllowedAuthenticators`
|
|
64
59
|
builder.setDeviceCredentialAllowed(true);
|
|
65
60
|
} else {
|
|
61
|
+
// Note that this option is incompatible with device credential authentication and must NOT be set if the latter is enabled via `setAllowedAuthenticators` or `setDeviceCredentialAllowed`.
|
|
62
|
+
// @see https://developer.android.com/reference/androidx/biometric/BiometricPrompt.PromptInfo.Builder#setNegativeButtonText(java.lang.CharSequence)
|
|
66
63
|
builder.setNegativeButtonText(
|
|
67
64
|
getIntent().hasExtra("negativeButtonText")
|
|
68
65
|
? getIntent().getStringExtra("negativeButtonText")
|
|
@@ -82,8 +79,10 @@ public class AuthActivity extends AppCompatActivity {
|
|
|
82
79
|
@NonNull CharSequence errString
|
|
83
80
|
) {
|
|
84
81
|
super.onAuthenticationError(errorCode, errString);
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
int pluginErrorCode = AuthActivity.convertToPluginErrorCode(
|
|
83
|
+
errorCode
|
|
84
|
+
);
|
|
85
|
+
finishActivity("error", pluginErrorCode, errString.toString());
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
@Override
|
|
@@ -91,14 +90,18 @@ public class AuthActivity extends AppCompatActivity {
|
|
|
91
90
|
@NonNull BiometricPrompt.AuthenticationResult result
|
|
92
91
|
) {
|
|
93
92
|
super.onAuthenticationSucceeded(result);
|
|
94
|
-
finishActivity("success"
|
|
93
|
+
finishActivity("success");
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
@Override
|
|
98
97
|
public void onAuthenticationFailed() {
|
|
99
98
|
super.onAuthenticationFailed();
|
|
100
99
|
counter++;
|
|
101
|
-
if (counter == maxAttempts) finishActivity(
|
|
100
|
+
if (counter == maxAttempts) finishActivity(
|
|
101
|
+
"failed",
|
|
102
|
+
10,
|
|
103
|
+
"Authentication failed."
|
|
104
|
+
);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
);
|
|
@@ -107,23 +110,52 @@ public class AuthActivity extends AppCompatActivity {
|
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
void finishActivity(String result) {
|
|
110
|
-
|
|
111
|
-
intent.putExtra("result", "failed");
|
|
112
|
-
intent.putExtra("errorDetails", "Authentication failed.");
|
|
113
|
-
setResult(RESULT_OK, intent);
|
|
114
|
-
finish();
|
|
113
|
+
finishActivity(result, null, null);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
void finishActivity(String result,
|
|
116
|
+
void finishActivity(String result, Integer errorCode, String errorDetails) {
|
|
118
117
|
Intent intent = new Intent();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
intent.putExtra("errorDetails", result);
|
|
118
|
+
intent.putExtra("result", result);
|
|
119
|
+
if (errorCode != null) {
|
|
122
120
|
intent.putExtra("errorCode", String.valueOf(errorCode));
|
|
123
|
-
}
|
|
124
|
-
|
|
121
|
+
}
|
|
122
|
+
if (errorDetails != null) {
|
|
123
|
+
intent.putExtra("errorDetails", errorDetails);
|
|
125
124
|
}
|
|
126
125
|
setResult(RESULT_OK, intent);
|
|
127
126
|
finish();
|
|
128
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Convert Auth Error Codes to plugin expected Biometric Auth Errors (in README.md)
|
|
131
|
+
* This way both iOS and Android return the same error codes for the same authentication failure reasons.
|
|
132
|
+
* !!IMPORTANT!!: Whenever this is modified, check if similar function in iOS Plugin.swift needs to be modified as well
|
|
133
|
+
* @see <a href="https://developer.android.com/reference/androidx/biometric/BiometricPrompt#constants">...</a>
|
|
134
|
+
* @return BiometricAuthError
|
|
135
|
+
*/
|
|
136
|
+
public static int convertToPluginErrorCode(int errorCode) {
|
|
137
|
+
switch (errorCode) {
|
|
138
|
+
case BiometricPrompt.ERROR_HW_UNAVAILABLE:
|
|
139
|
+
case BiometricPrompt.ERROR_HW_NOT_PRESENT:
|
|
140
|
+
return 1;
|
|
141
|
+
case BiometricPrompt.ERROR_LOCKOUT_PERMANENT:
|
|
142
|
+
return 2;
|
|
143
|
+
case BiometricPrompt.ERROR_NO_BIOMETRICS:
|
|
144
|
+
return 3;
|
|
145
|
+
case BiometricPrompt.ERROR_LOCKOUT:
|
|
146
|
+
return 4;
|
|
147
|
+
// Authentication Failure (10) Handled by `onAuthenticationFailed`.
|
|
148
|
+
// App Cancel (11), Invalid Context (12), and Not Interactive (13) are not valid error codes for Android.
|
|
149
|
+
case BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL:
|
|
150
|
+
return 14;
|
|
151
|
+
case BiometricPrompt.ERROR_TIMEOUT:
|
|
152
|
+
case BiometricPrompt.ERROR_CANCELED:
|
|
153
|
+
return 15;
|
|
154
|
+
case BiometricPrompt.ERROR_USER_CANCELED:
|
|
155
|
+
case BiometricPrompt.ERROR_NEGATIVE_BUTTON:
|
|
156
|
+
return 16;
|
|
157
|
+
default:
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
129
161
|
}
|