You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log(`Biometric ID available? ${result.any}`);
40
-
console.log(`Touch? ${result.touch}`);
41
-
console.log(`Face? ${result.face}`);
42
-
console.log(`Biometrics? ${result.biometrics}`);
43
-
});
44
-
}
45
-
46
-
47
-
}
54
+
55
+
#### Biometrics authentification support on Android
56
+
57
+
- It's only supported on `API 23+`.
58
+
- In some devices, the OS does not consider face recognition secure enough and as a result, your app cannot use it for biometric authentication.
59
+
This is the case with many Samsung devices. For example, Samsung Galaxy S10 ha Consequently, if the device has Face Recognition enabled and face scan saved, `available()` returns `{ any: true, biometrics: false }`.
60
+
61
+
#### Face ID authentification support on iOS
62
+
63
+
- It is only supported in iOS 11+.
64
+
65
+
- To allow Face ID support in your app, provide the reason of supporting it as the value of the `NSFaceIDUsageDescription` key in the `app/App_Resources/ios/Info.plist` file:
66
+
67
+
```xml
68
+
<key>NSFaceIDUsageDescription</key>
69
+
<string>For easy authentication with our app.</string>
48
70
```
49
-
> **Note: Android**
50
-
It's only supported on `API 23+`. <br> <br>In some devices, face recognition isn't considered secure enough by the system to be used as biometric authentication,therefore it cannot be used for biometric authentication. This is decided by the device itself.
51
-
This is the case in many Samsung devices. For example, Samsung Galaxy S10 has both fingerprint scanner and face recognition but only fingerprints are accepted as biometric authentication. <br> <br>So what happens is: <br>- If the device has Face Recognition enabled and face scan saved,calling `available()` returns `{ any: true, biometrics: false }`. You might expect the device to show Face Recognition when you call `verifyBiometric()` but Samsung does not consider Face Recognition secure on this device so you'll never be prompted. <br>- If you enroll a fingerprint in the Touch Recognition and call the `verifyBiometric()` method, the user will be prompted for the fingerprint scan.
71
+
- On a simulator, to enroll a face and test Face ID authentification, use the `Features->Face ID` menu items.
52
72
53
-
### Verifying a user's biometric
73
+
### Verify user biometrics
54
74
55
-
To verify a user's biometric, call the `verifyBiometric()` method.
75
+
To verify user biometrics, call the `verifyBiometric()` method and pass it a [VerifyBiometricOptions](#verifybiometricoptions) object.
56
76
57
77
> **Note: iOS**
58
-
Use `Features->Face ID` menu items to enroll a face and signal a successs/failure to recognize a face.
59
78
`verifyBiometric()` will fail on IOS simulator unless the `pinfallBack` option is used.
60
79
61
80
```typescript
@@ -74,22 +93,14 @@ biometricAuth
74
93
.catch((err) =>console.log(`Biometric ID NOT OK: ${JSON.stringify(err)}`));
75
94
```
76
95
77
-
### Requirements for Face ID Auth (iOS)
78
96
79
-
Support for Face ID was added in iOS 11+. To allow Face ID support in your app, you need to state the reason for it by adding the value for the `NSFaceIDUsageDescription` key to the `app/App_Resources/ios/Info.plist` file:
97
+
### Detect change in enrolled fingerprints (iOS)
80
98
81
-
```xml
82
-
<key>NSFaceIDUsageDescription</key>
83
-
<string>For easy authentication with our app.</string>
84
-
```
85
-
86
-
### Detecting change in enrolled fingerprints (iOS)
99
+
For iOS 9+ you can check if enrolled fingerprints have changed since
100
+
the last time you checked it. It's recommended you add this check to counter hacker attacks
101
+
on your app. For more details, see [this article](https://www.linkedin.com/pulse/fingerprint-trojan-per-thorsheim/).
87
102
88
-
Since iOS 9 you can check if there is a change in enrolled fingerprints since
89
-
the last time you checked it. It's recommended you add this check so you can counter hacker attacks
90
-
to your app. See [this article](https://www.linkedin.com/pulse/fingerprint-trojan-per-thorsheim/) for more details.
91
-
92
-
To check if there is a change in enrolled fingerprints, call the `didBiometricDatabaseChange()` method. If it returns `true`, you probably want to re-authenticate your user
103
+
To check if enrolled fingerprints have changed, call the `didBiometricDatabaseChange()` method. If it returns `true`, you probably want to re-authenticate your user
To combine biometrics authentification with cryptography, for more secure data protection, set the `secret` and `keyName` options when you call `verifyBiometric()`.
124
+
125
+
If you do not pass the `pinFallback` or `keyName` options to the `verifyBiometric()` method, the plugin will automatically:
126
+
1. create a secure key
127
+
2. prompts the user to authenticate for a face/fingerprint
128
+
3. attempts to use the key to encrypt some text.
113
129
114
-
If you do not pass the `pinFallback` or `keyName` options to the `verifyBiometric()` method, then the plugin will create a secure key, call the authorization methods to trigger face/fingerprint and then attempt to use the key to encrypt some text. The idea being that the key will not be accessible unless the user has successfully authenticated.
130
+
That automatic key generation, however, is not foolproof.
115
131
116
-
This ,however, is not foolproof and the most secure method is to pass the `secret` and `keyName`options to encrypt/decrypt text.
117
132
118
-
### Encrypting/Decrypting with Authentication
133
+
### Encrypting/Decrypting with biometrics authentication
119
134
120
135
The best practice is to use the options to encrypt some secret that is validated independently.
121
136
122
137
#### Encrypting your secret
123
138
124
-
To encrypt a secret key name, pass the `secret` and `keyName`options to the `verifyBiometric()` method.
139
+
140
+
To encrypt some sensitive string, pass the `secret` and `keyName`options to the `verifyBiometric()` method. Set the sensitive string as the `secret` property's value and the name of the key to access that secret as the value of the `keyName` property.
125
141
126
142
```typescript
127
143
biometricAuth
@@ -141,7 +157,7 @@ biometricAuth
141
157
.catch((err) =>this.set('status', `Biometric ID NOT OK: " + ${JSON.stringify(err)}`));
142
158
```
143
159
144
-
For Android the encrypted result and vector would then be stored in your app and used the next time when signing in the user by calling `verifyBiometric()` again:
160
+
For Android, the encrypted and initialization vector is then stored in your app and used each time when signing in the user with `verifyBiometric()`:
145
161
146
162
#### Decrypting your secret
147
163
@@ -165,9 +181,10 @@ biometricAuth
165
181
.catch((err) =>this.set('status', `Biometric ID NOT OK: " + ${JSON.stringify(err)}`));
166
182
```
167
183
168
-
### Fallback to Pin
184
+
#### Fallback to Pin
185
+
186
+
To allow biometrics authentification to fallback on lock screen credentials, set `pinFallback` to `true`. Note that thissetting also disables cryptography.
169
187
170
-
To allow the user to fallback on lock screen credentials, set `pinFallback` to `true`. This also disables cryptography.
171
188
172
189
```typescript
173
190
biometricAuth
@@ -187,23 +204,26 @@ biometricAuth
187
204
## API
188
205
189
206
### BiometricAuth Class
207
+
190
208
| Name | Return Type | Description|
191
209
|-----|-------|-----------|
192
210
|`available()`|`Promise<BiometricIDAvailableResult>`| Checks if biometric authentification is supported on the device. See [BiometricIDAvailableResult](#biometricidavailableresult) for more details.|
193
211
|`didBiometricDatabaseChange(options?: VerifyBiometricOptions)`|`Promise<boolean>`| Checks if there is a change in a biometric of the user.|
194
212
|`verifyBiometric(options: VerifyBiometricOptions)`|`Promise<BiometricResult>`| Verifies the biometrics auth using the specified [VerifyBiometricOptions](#verifybiometricoptions) object. |
195
-
|`close()`|`void`| Closes Face/Fingerprint prompt. Will not do anything on Android if `pinFallBack` is `true`.|
213
+
|`close()`|`void`| Closes Face/Fingerprint prompt. If `pinFallBack` is `true`, `close()` does not have effect on Android.|
196
214
|`deleteKey(keyName?: string)`|`void`| Deletes the specified key. |
197
215
198
-
### BiometricIDAvailableResult
216
+
### BiometricIDAvailableResult interface
217
+
199
218
| Name | Type| Description|
200
219
|------|-----|------------|
201
220
|`any`|`boolean`|`true` if no biometric authentification is available on android but device has pin/pattern/password set.|
202
221
|`touch`|`boolean`|_Optional_: `iOS only`|
203
222
|`face`|`boolean`|_Optional_: `iOS only`|
204
223
|`biometrics`|`boolean`|_Optional_: (`Android only`) indicates if Face/Fingerprint is available.|
205
224
206
-
### VerifyBiometricOptions
225
+
### VerifyBiometricOptions interface
226
+
207
227
| Name | Type| Description|
208
228
|------|-----|------------|
209
229
|`title`|`string`|_Optional_: (`Android only`)The title for the the fingerprint screen. Defaults to whatever the device default is.|
|`customFallback`|`boolean`|_Optional_: Indicates whether to allow a custom fallback from biometrics.|
223
244
|`fetchSecret`|`boolean`|_Optional_: Indicates whether to attempt to fetch secret from the specified key.|
224
245
225
-
### AndroidOptions
246
+
### AndroidOptions interface
247
+
226
248
| Name | Type| Description|
227
249
|------|-----|------------|
228
250
|`decryptText`|`string`| If set and `pinFallback` is `true`, and `keyName` is set then this string will be decrypted via the Biometric controlled Key. |
229
251
If set and pinFallback is true, and keyName is set then this string will be decrypted via the Biometric controlled Key.|
230
252
|`iv`|`string`|_Optional_: Retrieved from the result of an encryption. |
231
253
|`validityDuration`|`number`|_Optional_: The period, in seconds, for which operations on the key are valid without triggering a biometric prompt.|
0 commit comments