@aparajita/capacitor-biometric-auth 7.0.2 → 7.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/README.md +4 -2
- package/android/src/main/java/com/aparajita/capacitor/biometricauth/BiometricAuthNative.java +27 -13
- package/dist/esm/definitions.d.ts +23 -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 +11 -11
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
|
|
package/android/src/main/java/com/aparajita/capacitor/biometricauth/BiometricAuthNative.java
CHANGED
|
@@ -94,13 +94,14 @@ public class BiometricAuthNative extends Plugin {
|
|
|
94
94
|
private ArrayList<BiometryType> biometryTypes;
|
|
95
95
|
|
|
96
96
|
private int getAuthenticatorFromCall(PluginCall call) {
|
|
97
|
+
int authenticator = BiometricManager.Authenticators.BIOMETRIC_WEAK;
|
|
98
|
+
|
|
97
99
|
Integer value = call.getInt(
|
|
98
100
|
"androidBiometryStrength",
|
|
99
101
|
BiometryStrength.WEAK.ordinal()
|
|
100
102
|
);
|
|
101
|
-
int authenticator = BiometricManager.Authenticators.BIOMETRIC_WEAK;
|
|
102
103
|
|
|
103
|
-
if (value == BiometryStrength.STRONG.ordinal()) {
|
|
104
|
+
if (value != null && value == BiometryStrength.STRONG.ordinal()) {
|
|
104
105
|
authenticator = BiometricManager.Authenticators.BIOMETRIC_STRONG;
|
|
105
106
|
}
|
|
106
107
|
|
|
@@ -112,25 +113,31 @@ public class BiometricAuthNative extends Plugin {
|
|
|
112
113
|
*/
|
|
113
114
|
@PluginMethod
|
|
114
115
|
public void checkBiometry(PluginCall call) {
|
|
116
|
+
JSObject result = new JSObject();
|
|
115
117
|
BiometricManager manager = BiometricManager.from(getContext());
|
|
116
118
|
|
|
117
119
|
// First check for weak biometry or better.
|
|
118
|
-
int
|
|
120
|
+
int weakBiometryResult = manager.canAuthenticate(
|
|
119
121
|
BiometricManager.Authenticators.BIOMETRIC_WEAK
|
|
120
122
|
);
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
setReasonAndCode(weakBiometryResult, false, result);
|
|
125
|
+
|
|
123
126
|
result.put(
|
|
124
127
|
"isAvailable",
|
|
125
|
-
|
|
128
|
+
weakBiometryResult == BiometricManager.BIOMETRIC_SUCCESS
|
|
126
129
|
);
|
|
127
130
|
|
|
128
131
|
// Now check for strong biometry.
|
|
129
|
-
|
|
130
|
-
|
|
132
|
+
int strongBiometryResult = manager.canAuthenticate(
|
|
133
|
+
BiometricManager.Authenticators.BIOMETRIC_STRONG
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
setReasonAndCode(strongBiometryResult, true, result);
|
|
137
|
+
|
|
131
138
|
result.put(
|
|
132
139
|
"strongBiometryIsAvailable",
|
|
133
|
-
|
|
140
|
+
strongBiometryResult == BiometricManager.BIOMETRIC_SUCCESS
|
|
134
141
|
);
|
|
135
142
|
|
|
136
143
|
biometryTypes = getDeviceBiometryTypes();
|
|
@@ -155,9 +162,17 @@ public class BiometricAuthNative extends Plugin {
|
|
|
155
162
|
result.put("deviceIsSecure", false);
|
|
156
163
|
}
|
|
157
164
|
|
|
165
|
+
call.resolve(result);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private static void setReasonAndCode(
|
|
169
|
+
int canAuthenticateResult,
|
|
170
|
+
boolean strong,
|
|
171
|
+
JSObject result
|
|
172
|
+
) {
|
|
158
173
|
String reason = "";
|
|
159
174
|
|
|
160
|
-
switch (
|
|
175
|
+
switch (canAuthenticateResult) {
|
|
161
176
|
case BiometricManager.BIOMETRIC_SUCCESS:
|
|
162
177
|
break;
|
|
163
178
|
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
|
|
@@ -182,15 +197,14 @@ public class BiometricAuthNative extends Plugin {
|
|
|
182
197
|
break;
|
|
183
198
|
}
|
|
184
199
|
|
|
185
|
-
String errorCode = biometryErrorCodeMap.get(
|
|
200
|
+
String errorCode = biometryErrorCodeMap.get(canAuthenticateResult);
|
|
186
201
|
|
|
187
202
|
if (errorCode == null) {
|
|
188
203
|
errorCode = "biometryNotAvailable";
|
|
189
204
|
}
|
|
190
205
|
|
|
191
|
-
result.put("reason", reason);
|
|
192
|
-
result.put("code", errorCode);
|
|
193
|
-
call.resolve(result);
|
|
206
|
+
result.put(strong ? "strongReason" : "reason", reason);
|
|
207
|
+
result.put(strong ? "strongCode" : "code", errorCode);
|
|
194
208
|
}
|
|
195
209
|
|
|
196
210
|
private ArrayList<BiometryType> getDeviceBiometryTypes() {
|
|
@@ -210,17 +210,35 @@ export interface CheckBiometryResult {
|
|
|
210
210
|
*/
|
|
211
211
|
deviceIsSecure: boolean;
|
|
212
212
|
/**
|
|
213
|
-
* If biometry is not available and the system gives
|
|
214
|
-
* 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.
|
|
215
215
|
*/
|
|
216
216
|
reason: string;
|
|
217
217
|
/**
|
|
218
|
-
* If biometry is not available, the error code will be
|
|
219
|
-
* Otherwise it's an empty string. The error code will be
|
|
220
|
-
* `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
|
|
221
221
|
* platforms.
|
|
222
222
|
*/
|
|
223
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;
|
|
224
242
|
}
|
|
225
243
|
/**
|
|
226
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.
|
|
3
|
+
"version": "7.1.1",
|
|
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.
|
|
62
|
-
"@commitlint/config-conventional": "^18.
|
|
61
|
+
"@commitlint/cli": "^18.5.0",
|
|
62
|
+
"@commitlint/config-conventional": "^18.5.0",
|
|
63
63
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
64
64
|
"@rollup/plugin-json": "^6.1.0",
|
|
65
|
-
"@types/node": "^20.
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
67
|
-
"@typescript-eslint/parser": "^6.
|
|
68
|
-
"commit-and-tag-version": "^12.
|
|
65
|
+
"@types/node": "^20.11.6",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
67
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
68
|
+
"commit-and-tag-version": "^12.2.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
|
-
"nodemon": "^3.0.
|
|
77
|
-
"prettier": "^3.
|
|
76
|
+
"nodemon": "^3.0.3",
|
|
77
|
+
"prettier": "^3.2.4",
|
|
78
78
|
"prettier-plugin-java": "^2.5.0",
|
|
79
79
|
"rimraf": "^5.0.5",
|
|
80
|
-
"rollup": "^4.9.
|
|
80
|
+
"rollup": "^4.9.6",
|
|
81
81
|
"simple-git-hooks": "^2.9.0",
|
|
82
82
|
"swiftlint": "^1.0.2",
|
|
83
83
|
"typescript": "~5.3.3"
|