@aparajita/capacitor-biometric-auth 7.0.1 → 7.1.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 +5 -3
- package/android/src/main/java/com/aparajita/capacitor/biometricauth/BiometricAuthNative.java +24 -11
- package/dist/esm/definitions.d.ts +27 -5
- package/dist/esm/native.js +2 -0
- package/dist/plugin.cjs.js +2 -0
- package/dist/plugin.js +2 -0
- package/ios/Plugin/Plugin.swift +3 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -252,8 +252,10 @@ Register a function that will be called when the app resumes. The function will
|
|
|
252
252
|
| biometryType | <a href="#biometrytype">BiometryType</a> | The primary (most secure) type of biometry supported by the device. Note that _supported_ is not the same as _available_, which requires the biometry to be enrolled. |
|
|
253
253
|
| biometryTypes | BiometryType[] | All of the biometry types supported by the hardware on the device (currently only Android devices support multiple biometry types). If no biometry is supported, i.e. `biometryType === <a href="#biometrytype">BiometryType.none`</a>, this will be an empty array.<br><br>Note that _supported_ is not the same as _available_, which requires the biometry to be enrolled. |
|
|
254
254
|
| deviceIsSecure | boolean | Returns true if the device is secure. On iOS, this means that the device has a passcode set. On Android, this means that the device has a PIN, pattern, or password set. |
|
|
255
|
-
| reason | string | If biometry is not available and the system gives a reason why, it will be returned here. Otherwise it's an empty string.
|
|
256
|
-
| code | <a href="#biometryerrortype">BiometryErrorType</a> | If biometry is not available, the error code will be returned here. Otherwise it's an empty string. The error code will be one of the <a href="#biometryerrortype">`BiometryErrorType`</a> enum values, and is consistent across platforms.
|
|
255
|
+
| reason | string | If weak or better biometry is not available and the system gives a reason why, it will be returned here. Otherwise it's an empty string. |
|
|
256
|
+
| code | <a href="#biometryerrortype">BiometryErrorType</a> | If weak or better biometry is not available, the error code will be returned here. Otherwise it's an empty string. The error code will be one of the <a href="#biometryerrortype">`BiometryErrorType`</a> enum values, and is consistent across platforms. |
|
|
257
|
+
| strongReason | string | If strong biometry is not available and the system gives a reason why, it will be returned here. Otherwise it's an empty string.<br><br>On iOS, this will always be the same as `reason`, since all biometry on iOS is strong. |
|
|
258
|
+
| strongCode | <a href="#biometryerrortype">BiometryErrorType</a> | If strong biometry is not available, the error code will be returned here. Otherwise it's an empty string. The error code will be one of the <a href="#biometryerrortype">`BiometryErrorType`</a> enum values, and is consistent across platforms.<br><br>On iOS, this will always be the same as `code`, since all biometry on iOS is strong. |
|
|
257
259
|
|
|
258
260
|
#### Array
|
|
259
261
|
|
|
@@ -324,7 +326,7 @@ This method mutates the array and returns a reference to the same array. |
|
|
|
324
326
|
| androidTitle | string | Title for the Android dialog. If not supplied, the system default is used. |
|
|
325
327
|
| androidSubtitle | string | Subtitle for the Android dialog. If not supplied, the system default is used. |
|
|
326
328
|
| androidConfirmationRequired | boolean | Determines if successful weak biometric authentication must be confirmed.<br><br>For information on this setting, see https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt.Builder#setConfirmationRequired(boolean).<br><br>Default: `true` |
|
|
327
|
-
| androidBiometryStrength | <a href="#androidbiometrystrength">AndroidBiometryStrength</a> | Set the strength of Android biometric authentication that will be accepted.<br><br>Default: <a href="#androidbiometrystrength">`AndroidBiometryStrength.weak`</a>
|
|
329
|
+
| androidBiometryStrength | <a href="#androidbiometrystrength">AndroidBiometryStrength</a> | Set the strength of Android biometric authentication that will be accepted.<br><br>👉 **NOTE:** On Android 9 & 10 (API 28-29), this will effectively always be `.weak` if `allowDeviceCredential` is true. This is a known limitation of the Android API. 🤯<br><br>Default: <a href="#androidbiometrystrength">`AndroidBiometryStrength.weak`</a> |
|
|
328
330
|
|
|
329
331
|
#### PluginListenerHandle
|
|
330
332
|
|
package/android/src/main/java/com/aparajita/capacitor/biometricauth/BiometricAuthNative.java
CHANGED
|
@@ -112,25 +112,31 @@ public class BiometricAuthNative extends Plugin {
|
|
|
112
112
|
*/
|
|
113
113
|
@PluginMethod
|
|
114
114
|
public void checkBiometry(PluginCall call) {
|
|
115
|
+
JSObject result = new JSObject();
|
|
115
116
|
BiometricManager manager = BiometricManager.from(getContext());
|
|
116
117
|
|
|
117
118
|
// First check for weak biometry or better.
|
|
118
|
-
int
|
|
119
|
+
int weakBiometryResult = manager.canAuthenticate(
|
|
119
120
|
BiometricManager.Authenticators.BIOMETRIC_WEAK
|
|
120
121
|
);
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
setReasonAndCode(weakBiometryResult, false, result);
|
|
124
|
+
|
|
123
125
|
result.put(
|
|
124
126
|
"isAvailable",
|
|
125
|
-
|
|
127
|
+
weakBiometryResult == BiometricManager.BIOMETRIC_SUCCESS
|
|
126
128
|
);
|
|
127
129
|
|
|
128
130
|
// Now check for strong biometry.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
int strongBiometryResult = manager.canAuthenticate(
|
|
132
|
+
BiometricManager.Authenticators.BIOMETRIC_STRONG
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
setReasonAndCode(strongBiometryResult, true, result);
|
|
136
|
+
|
|
131
137
|
result.put(
|
|
132
138
|
"strongBiometryIsAvailable",
|
|
133
|
-
|
|
139
|
+
strongBiometryResult == BiometricManager.BIOMETRIC_SUCCESS
|
|
134
140
|
);
|
|
135
141
|
|
|
136
142
|
biometryTypes = getDeviceBiometryTypes();
|
|
@@ -155,9 +161,17 @@ public class BiometricAuthNative extends Plugin {
|
|
|
155
161
|
result.put("deviceIsSecure", false);
|
|
156
162
|
}
|
|
157
163
|
|
|
164
|
+
call.resolve(result);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private static void setReasonAndCode(
|
|
168
|
+
int canAuthenticateResult,
|
|
169
|
+
boolean strong,
|
|
170
|
+
JSObject result
|
|
171
|
+
) {
|
|
158
172
|
String reason = "";
|
|
159
173
|
|
|
160
|
-
switch (
|
|
174
|
+
switch (canAuthenticateResult) {
|
|
161
175
|
case BiometricManager.BIOMETRIC_SUCCESS:
|
|
162
176
|
break;
|
|
163
177
|
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
|
|
@@ -182,15 +196,14 @@ public class BiometricAuthNative extends Plugin {
|
|
|
182
196
|
break;
|
|
183
197
|
}
|
|
184
198
|
|
|
185
|
-
String errorCode = biometryErrorCodeMap.get(
|
|
199
|
+
String errorCode = biometryErrorCodeMap.get(canAuthenticateResult);
|
|
186
200
|
|
|
187
201
|
if (errorCode == null) {
|
|
188
202
|
errorCode = "biometryNotAvailable";
|
|
189
203
|
}
|
|
190
204
|
|
|
191
|
-
result.put("reason", reason);
|
|
192
|
-
result.put("code", errorCode);
|
|
193
|
-
call.resolve(result);
|
|
205
|
+
result.put(strong ? "strongReason" : "reason", reason);
|
|
206
|
+
result.put(strong ? "strongCode" : "code", errorCode);
|
|
194
207
|
}
|
|
195
208
|
|
|
196
209
|
private ArrayList<BiometryType> getDeviceBiometryTypes() {
|
|
@@ -127,6 +127,10 @@ export interface AuthenticateOptions {
|
|
|
127
127
|
/**
|
|
128
128
|
* Set the strength of Android biometric authentication that will be accepted.
|
|
129
129
|
*
|
|
130
|
+
* 👉 **NOTE:** On Android 9 & 10 (API 28-29), this will effectively always
|
|
131
|
+
* be `.weak` if `allowDeviceCredential` is true. This is a known limitation
|
|
132
|
+
* of the Android API. 🤯
|
|
133
|
+
*
|
|
130
134
|
* Default: `AndroidBiometryStrength.weak`
|
|
131
135
|
*/
|
|
132
136
|
androidBiometryStrength?: AndroidBiometryStrength;
|
|
@@ -206,17 +210,35 @@ export interface CheckBiometryResult {
|
|
|
206
210
|
*/
|
|
207
211
|
deviceIsSecure: boolean;
|
|
208
212
|
/**
|
|
209
|
-
* If biometry is not available and the system gives
|
|
210
|
-
* it will be returned here. Otherwise it's an empty string.
|
|
213
|
+
* If weak or better biometry is not available and the system gives
|
|
214
|
+
* a reason why, it will be returned here. Otherwise it's an empty string.
|
|
211
215
|
*/
|
|
212
216
|
reason: string;
|
|
213
217
|
/**
|
|
214
|
-
* If biometry is not available, the error code will be
|
|
215
|
-
* Otherwise it's an empty string. The error code will be
|
|
216
|
-
* `BiometryErrorType` enum values, and is consistent across
|
|
218
|
+
* If weak or better biometry is not available, the error code will be
|
|
219
|
+
* returned here. Otherwise it's an empty string. The error code will be
|
|
220
|
+
* one of the `BiometryErrorType` enum values, and is consistent across
|
|
217
221
|
* platforms.
|
|
218
222
|
*/
|
|
219
223
|
code: BiometryErrorType;
|
|
224
|
+
/**
|
|
225
|
+
* If strong biometry is not available and the system gives
|
|
226
|
+
* a reason why, it will be returned here. Otherwise it's an empty string.
|
|
227
|
+
*
|
|
228
|
+
* On iOS, this will always be the same as `reason`, since all biometry
|
|
229
|
+
* on iOS is strong.
|
|
230
|
+
*/
|
|
231
|
+
strongReason?: string;
|
|
232
|
+
/**
|
|
233
|
+
* If strong biometry is not available, the error code will be
|
|
234
|
+
* returned here. Otherwise it's an empty string. The error code will be
|
|
235
|
+
* one of the `BiometryErrorType` enum values, and is consistent across
|
|
236
|
+
* platforms.
|
|
237
|
+
*
|
|
238
|
+
* On iOS, this will always be the same as `code`, since all biometry
|
|
239
|
+
* on iOS is strong.
|
|
240
|
+
*/
|
|
241
|
+
strongCode?: BiometryErrorType;
|
|
220
242
|
}
|
|
221
243
|
/**
|
|
222
244
|
* The signature of the callback passed to `addResumeListener()`.
|
package/dist/esm/native.js
CHANGED
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.js
CHANGED
package/ios/Plugin/Plugin.swift
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aparajita/capacitor-biometric-auth",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "Provides access to the native biometric auth & device security APIs for Capacitor apps",
|
|
5
5
|
"author": "Aparajita Fishman",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,26 +58,26 @@
|
|
|
58
58
|
"@aparajita/prettier-config": "^2.0.0",
|
|
59
59
|
"@aparajita/swiftly": "^1.0.4",
|
|
60
60
|
"@capacitor/cli": "^5.6.0",
|
|
61
|
-
"@commitlint/cli": "^18.4.
|
|
62
|
-
"@commitlint/config-conventional": "^18.4.
|
|
61
|
+
"@commitlint/cli": "^18.4.4",
|
|
62
|
+
"@commitlint/config-conventional": "^18.4.4",
|
|
63
63
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
64
64
|
"@rollup/plugin-json": "^6.1.0",
|
|
65
|
-
"@types/node": "^20.10.
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
67
|
-
"@typescript-eslint/parser": "^6.
|
|
68
|
-
"commit-and-tag-version": "^12.
|
|
65
|
+
"@types/node": "^20.10.8",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
67
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
68
|
+
"commit-and-tag-version": "^12.1.0",
|
|
69
69
|
"eslint": "^8.56.0",
|
|
70
70
|
"eslint-config-prettier": "^9.1.0",
|
|
71
71
|
"eslint-config-standard": "^17.1.0",
|
|
72
72
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
73
73
|
"eslint-plugin-import": "^2.29.1",
|
|
74
|
-
"eslint-plugin-n": "^16.6.
|
|
74
|
+
"eslint-plugin-n": "^16.6.2",
|
|
75
75
|
"eslint-plugin-promise": "^6.1.1",
|
|
76
76
|
"nodemon": "^3.0.2",
|
|
77
77
|
"prettier": "^3.1.1",
|
|
78
78
|
"prettier-plugin-java": "^2.5.0",
|
|
79
79
|
"rimraf": "^5.0.5",
|
|
80
|
-
"rollup": "^4.9.
|
|
80
|
+
"rollup": "^4.9.4",
|
|
81
81
|
"simple-git-hooks": "^2.9.0",
|
|
82
82
|
"swiftlint": "^1.0.2",
|
|
83
83
|
"typescript": "~5.3.3"
|