@faceio/fiojs 1.0.5 β 1.0.7
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/.github/workflows/npm-publish.yml +33 -0
- package/LICENSE +201 -201
- package/README.md +328 -321
- package/index.js +70 -70
- package/package.json +17 -13
package/README.md
CHANGED
|
@@ -1,321 +1,328 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
|
89
|
-
|
|
90
|
-
| `
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
|
247
|
-
|
|
248
|
-
| `fioErrCode.
|
|
249
|
-
| `fioErrCode.
|
|
250
|
-
| `fioErrCode.
|
|
251
|
-
| `fioErrCode.
|
|
252
|
-
| `fioErrCode.
|
|
253
|
-
| `fioErrCode.
|
|
254
|
-
| `fioErrCode.
|
|
255
|
-
| `fioErrCode.
|
|
256
|
-
| `fioErrCode.
|
|
257
|
-
| `fioErrCode.
|
|
258
|
-
| `fioErrCode.
|
|
259
|
-
| `fioErrCode.
|
|
260
|
-
| `fioErrCode.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
1
|
+
## Release Updates & Announcments:
|
|
2
|
+
|
|
3
|
+
* [New REST API Endpoints Available for FACEIO](https://blog.pixlab.io/2023/04/new-rest-api-endpoints-available-for-faceio)
|
|
4
|
+
* [**Livneness Detection & Face Anti-Spoofing Security Feature Available for FACEIO**](https://www.biometricupdate.com/202303/pixlab-adds-active-liveness-detection-to-faceio-biometrics-framework)
|
|
5
|
+
* [Webhooks Enhancements & Performance Improvements](https://blog.pixlab.io/2022/11/faceios-webhooks-enhancements-performance-improvements)
|
|
6
|
+
* [fio.js V1.9 Released with Face Duplication Prevention](https://blog.pixlab.io/2022/10/fiojs-190-released-with-face-duplication-prevention)
|
|
7
|
+
|
|
8
|
+
## Introducing FACEIO NPM Package
|
|
9
|
+
|
|
10
|
+
* **TLDR;** [FACEIO](https://faceio.net) is a facial authentication framework that is to be implemented on websites or web applications via simple JavaScript snippet (just like Disqus or Google Tag) to easily authenticate users via **Face Recognition instead of the traditional login/password pair or OTP code**.
|
|
11
|
+
* FACEIO is a cross-browser, Cloud & On-Premise deployable, facial authentication framework, with a client-side JavaScript library (fio.js) that [integrates seamlessly](https://faceio.net/integration-guide) with any website or web application desiring to offer secure facial recognition experience to their users...
|
|
12
|
+
* Put it simply, FACEIO is the easiest way to add passwordless authentication to websites or web applications. Simply implement fio.js on your website, and you will be able to **instantly authenticate your existing users, and enroll new ones via Face Recognition** using their computer Webcam or smartphone frontal camera on their favorite browser.
|
|
13
|
+
* Once fio.js [implemented](https://faceio.net/integration-guide) on your website, you'll be able to instantly recognize your existing users, on-board new members securely with maximum convenience, and at real-time thanks to passwordless experience powered by face recognition.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
# `fio.js` LIBRARY & WIDGET INTEGRATION
|
|
18
|
+
|
|
19
|
+
The FACEIO Widget is a simple and elegant interface to provide **secure facial authentication experience to your users** via simple calls to the `enroll()` & `authenticate()` methods. The Widget is powered by the `fio.js `JavaScript library, which is simple enough to [integrate](https://faceio.net/integration-guide#fiojs-integration) in a matter of minutes while being flexible enough to support highly customized setups. Once implemented on your website or web-based application, you'll be able to authenticate your existing users, enroll new ones securely, with maximum convenience on their favorite browser, and at real-time thanks to passwordless experience powered by face recognition.
|
|
20
|
+
|
|
21
|
+
`fio.js` works with regular webcams, and smartphones frontal camera on all modern browsers, **does not require biometric sensors**, and works seemingly with all websites and web applications regardless of the underlying front-end technology used (ie. React, Vue, jQuery, Vanilla Javascript, static HTML, etc.) or server-side language or framework (eg. PHP, Python, Node.js, Rust, Elixir, etc.).
|
|
22
|
+
|
|
23
|
+
Itβs super quick to get FACEIO Up & Running with just few lines of code. Follow the walkthrough below to implement `fio.js` on your site.
|
|
24
|
+
|
|
25
|
+
> ## STEP 1 - IMPORT `fio.js` TO YOUR SITE
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import faceIO from '@faceio/fiojs'
|
|
29
|
+
|
|
30
|
+
const faceio = new faceIO('app-public-id') // Get the application Public ID at https://console.faceio.net.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
π You shouldn't run `fio.js` functions right after initiating it.
|
|
34
|
+
|
|
35
|
+
π‘ Take a look to our **community contributed tutorials** [listed here](https://faceio.net/integration-guide#community-tutorials). They should help you implement `fio.js` on your website or web application using your favorite JavaScript framework whether it is React, Vue, Angular, Next or Vanilla JavaScript.
|
|
36
|
+
|
|
37
|
+
> ## STEP 2 - INVOKE THE WIDGET
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import faceIO from '@faceio/fiojs'
|
|
41
|
+
|
|
42
|
+
const faceio = new faceIO('app-public-id'); // Get the application Public ID at https://console.faceio.net.
|
|
43
|
+
|
|
44
|
+
function App() {
|
|
45
|
+
return (
|
|
46
|
+
<div className="App">
|
|
47
|
+
<button onClick={enrollNewUser}>Enroll New User</button>
|
|
48
|
+
<button onClick={authenticateUser}>Authenticate User</button>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function enrollNewUser() {
|
|
54
|
+
// call to faceio.enroll() here will automatically trigger the on-boarding process
|
|
55
|
+
}
|
|
56
|
+
async function authenticateUser(){
|
|
57
|
+
// call to faceio.authenticate() here will automatically trigger the facial authentication process
|
|
58
|
+
}
|
|
59
|
+
function handleError(errCode){
|
|
60
|
+
// Handle error here
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default App;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> ## `ENROLL()` - ENROLL NEW USER
|
|
67
|
+
β
|
|
68
|
+
> ### SYNTAX
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
const userInfo = await faceio
|
|
72
|
+
.enroll({ parameters })
|
|
73
|
+
.catch(errCode => {
|
|
74
|
+
/* handle the error */
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
console.log(userInfo)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
> ### ALIAS
|
|
81
|
+
`enrol()`, `register()`, `record()`
|
|
82
|
+
|
|
83
|
+
> ### PARAMETERS
|
|
84
|
+
`enroll()` takes a **single, optional `parameters` object** with the properties to be configured. The table below lists all possible `properties` of the parameters object:
|
|
85
|
+
|
|
86
|
+
β
|
|
87
|
+
|
|
88
|
+
| **Property Name** | **Type** | **Default Value** | **Description** |
|
|
89
|
+
|--------------------|-----------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
90
|
+
| `payload` | Any Serializable JSON | NULL | **An arbitrary set of data, you want to associate with the user being enrolled**. Example of useful payloads includes *Email Address, Name, ID, Token*, and so on. This payload will be **forwarded back to you** upon successful [future authentication](https://faceio.net/integration-guide#authenticate_return) of this particular user. Maximum payload size per user is set to 16KB. |
|
|
91
|
+
| `permissionTimeout` | Number | 27 Seconds | **Total number of seconds to wait for the user to grant camera access permission**. Passing this delay, the ongoing `enroll()` operation is aborted and the promise is rejected with the `fioErrCode.PERMISSION_REFUSED` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
92
|
+
| `termsTimeout` | Number | 10 Minutes | **Total number of minutes to wait for the user to accept FACEIO/Host Application Terms of Service**. Passing this delay, the ongoing `enroll()` operation is aborted and the promise is rejected with the `fioErrCode.TERMS_NOT_ACCEPTED` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
93
|
+
| `idleTimeout` | Number | 27 Seconds | **Total number of seconds to wait before giving up if no faces were detected during the enrollment process**. Passing this delay, the ongoing operation is aborted and the promise is rejected with the `fioErrCode.NO_FACES_DETECTED` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
94
|
+
| `replyTimeout` | Number | 40 Seconds | **Total number of seconds to wait before giving up if the remote FACEIO processing node does not return a response (a very unlikely scenario)**. Passing this delay, the ongoing operation is aborted and the promise is rejected with the `fioErrCode.TIMEOUT` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
95
|
+
| `enrollIntroTimeout` | Number | 12 Seconds | Enrollment Widget introduction/instruction screen display delay. |
|
|
96
|
+
| `locale` | String | auto | **Default interaction language for the Widget display**. If this value is missing or set to auto, then the interaction language will be deducted from the [Accept-Language](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language) HTTP request header. Otherwise, just pass the **BCP 47, two letter, language code** of your choice (en, ar, es, ja, de, etc.). If the requested interaction language is not supported, the fallback, default interaction language is **US English: en-us**. |
|
|
97
|
+
| `userConsent` | Boolean | false | **If you have already collected user consent before enrollment** (eg. When the user create a new account on your Website and accept the terms), you can **set this parameter** to true. In which case, the Terms of Use consent screen is not displayed for the end user being enrolled. **It is your responsibility to explicitly ask for consent before enrolling a new user**. For additional information, please consult our Privacy Best Practices for applications. |
|
|
98
|
+
|
|
99
|
+
β
|
|
100
|
+
|
|
101
|
+
> ### RETURN VALUE
|
|
102
|
+
|
|
103
|
+
**A Promise whose fulfillment handler receives a `userInfo` object when the user has successfully been enrolled**. On failure, the promise is rejected with one of the possible **error codes** [listed below](https://faceio.net/integration-guide#error-codes).
|
|
104
|
+
|
|
105
|
+
The table below lists all fields of the `userInfo` object returned to your web application by `enroll()` when its promise is fulfilled:
|
|
106
|
+
|
|
107
|
+
| **Property Name** | **Type** | **Description** |
|
|
108
|
+
|---------------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
109
|
+
| `facialId` | UUID (String) | **A Universally Unique Identifier assigned to this particular user**. FACEIO recommend that your rely on this [Facial ID](https://faceio.net/facialid) (*which is automatically generated for each enrolled user on your application*), if you plan to uniquely identify all enrolled users on your backend for example. The Facial ID is discussed in details [here](https://faceio.net/facialid). |
|
|
110
|
+
| `timestamp` | Timestamp (String) | [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), enrollment completion date & time. |
|
|
111
|
+
| `details` | Object | An object with two fields: gender and age which respectively corresponds to the Gender and Age approximation of the enrolled user. |
|
|
112
|
+
|
|
113
|
+
> ### EXAMPLE
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import faceIO from '@faceio/fiojs'
|
|
117
|
+
|
|
118
|
+
const faceio = new faceIO('app-public-id'); // Get the application Public ID at https://console.faceio.net.
|
|
119
|
+
|
|
120
|
+
function App() {
|
|
121
|
+
return (
|
|
122
|
+
<div className="App">
|
|
123
|
+
<button onClick={enrollNewUser}>Enroll New User</button>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function enrollNewUser() {
|
|
129
|
+
const userInfo = await faceio.enroll({
|
|
130
|
+
"locale": "auto", // Default user locale
|
|
131
|
+
"payload": {
|
|
132
|
+
/* The payload we want to associate with this particular user which is forwarded back to us upon future authentication of this user.*/
|
|
133
|
+
"whoami": 123456, // Dummy ID linked to this particular user
|
|
134
|
+
"email": "john.doe@example.com"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
alert(
|
|
139
|
+
`User Successfully Enrolled! Details:
|
|
140
|
+
Unique Facial ID: ${userInfo.facialId}
|
|
141
|
+
Enrollment Date: ${userInfo.timestamp}
|
|
142
|
+
Gender: ${userInfo.details.gender}
|
|
143
|
+
Age Approximation: ${userInfo.details.age}`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export default App;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
> ## `AUTHENTICATE()` - IDENTIFY/RECOGNIZE ENROLLED USERS
|
|
151
|
+
β
|
|
152
|
+
> ### SYNTAX
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
const userInfo = await faceio
|
|
156
|
+
.authenticate({ parameters })
|
|
157
|
+
.catch(errCode => {
|
|
158
|
+
/* handle the error */
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
console.log(userInfo)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
> ### ALIAS
|
|
165
|
+
`auth()`, `recognize()`, `identify()`
|
|
166
|
+
|
|
167
|
+
> ### PARAMETERS
|
|
168
|
+
|
|
169
|
+
`authenticate()` takes a **single, optional `parameters` object** with the properties to be configured. The table below lists all possible properties of the `parameters` object:
|
|
170
|
+
|
|
171
|
+
| **Property Name** | **Type** | **Default Value** | **Description** |
|
|
172
|
+
|-------------------|--------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
173
|
+
| `permissionTimeout` | Number | 27 Seconds | **Total number of seconds to wait for the user to grant camera access permission**. Passing this delay, the ongoing `authenticate()` operation is aborted and the promise is rejected with the `fioErrCode.PERMISSION_REFUSED` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
174
|
+
| `idleTimeout` | Number | 27 Seconds | **Total number of seconds to wait before giving up if no faces were detected during the authentication process**. Passing this delay, the ongoing operation is aborted and the promise is rejected with the `fioErrCode.NO_FACES_DETECTED` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
175
|
+
| `replyTimeout` | Number | 40 Seconds | **Total number of seconds to wait before giving up if the remote FACEIO processing node does not return a response (a very unlikely scenario)**. Passing this delay, the ongoing operation is aborted and the promise is rejected with the `fioErrCode.TIMEOUT` [error code](https://faceio.net/integration-guide#error-codes). |
|
|
176
|
+
| `locale` | String | auto | **Default interaction language of the FACEIO Widget**. If this value is missing or set to auto, then the interaction language will be deducted from the [Accept-Language](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language) HTTP request header. Otherwise, just pass the **BCP 47, two letter, language code** of your choice (en, ar, es, ja, de, etc.). If the requested interaction language is not supported, the fallback, default interaction language is US **English: en-us**. |
|
|
177
|
+
|
|
178
|
+
> ### RETURN VALUE
|
|
179
|
+
|
|
180
|
+
β
|
|
181
|
+
|
|
182
|
+
**A Promise whose fulfillment handler receives a `userData` object when the user has successfully been identified**. On failure, the promise is rejected with one of the possible **error codes** [listed below](https://faceio.net/integration-guide#error-codes).
|
|
183
|
+
|
|
184
|
+
The table below lists all fields of the `userData` object returned to your web application by `authenticate()` when its promise is fulfilled:
|
|
185
|
+
|
|
186
|
+
| **Property Name** | **Type** | **Description** |
|
|
187
|
+
|---------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
188
|
+
| payload | *Any* | The arbitrary data you have already linked (if any) to this particular user during his enrollment via the payload parameter of the enroll() method. | | |
|
|
189
|
+
| `facialId` | *UUID (String)* | **The Universally Unique Identifier assigned to this particular user**. FACEIO recommend that your rely on this [Facial ID](https://faceio.net/facialid) (*which is automatically generated for each enrolled user on your application*), if you plan to uniquely identify all enrolled users on your backend for example. The Facial ID is discussed in details [here](https://faceio.net/facialid). |
|
|
190
|
+
|
|
191
|
+
> ### EXAMPLE
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
import faceIO from '@faceio/fiojs'
|
|
195
|
+
|
|
196
|
+
const faceio = new faceIO('app-public-id'); // Get the application Public ID at https://console.faceio.net.
|
|
197
|
+
|
|
198
|
+
function App() {
|
|
199
|
+
return (
|
|
200
|
+
<div className="App">
|
|
201
|
+
<button onClick={authenticateUser}>Authenticate User</button>
|
|
202
|
+
</div>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async function authenticateUser() {
|
|
207
|
+
const userData = await faceio.authenticate({
|
|
208
|
+
"locale": "auto", // Default user locale
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
console.log("Success, user identified")
|
|
212
|
+
// Grab the facial ID linked to this particular user which will be same
|
|
213
|
+
// for each of his successful future authentication. FACEIO recommend
|
|
214
|
+
// that your rely on this Facial ID if you plan to uniquely identify
|
|
215
|
+
// all enrolled users on your backend for example.
|
|
216
|
+
console.log("Linked facial Id: " + userData.facialId)
|
|
217
|
+
// Grab the arbitrary data you have already linked (if any) to this particular user
|
|
218
|
+
// during his enrollment via the payload parameter of the enroll() method.
|
|
219
|
+
console.log("Payload: " + JSON.stringify(userData.payload)) // {"whoami": 123456, "email": "john.doe@example.com"} from the enroll() example above
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export default App;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
> ## `RESTARTSESSION()` - REQUEST NEW USER SESSION
|
|
226
|
+
β
|
|
227
|
+
> ### SYNTAX
|
|
228
|
+
β
|
|
229
|
+
```js
|
|
230
|
+
const boolean = await faceio.restartSession({})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
> ### PARAMETERS
|
|
234
|
+
β
|
|
235
|
+
*None*
|
|
236
|
+
|
|
237
|
+
> ### RETURN VALUE
|
|
238
|
+
|
|
239
|
+
`true` if the request for a new session have been granted, and ready for another round of calls to [enroll()](https://faceio.net/integration-guide#enroll) or [authenticate()](https://faceio.net/integration-guide#authenticate) for the same user. false otherwise.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
> ## ERROR CODES
|
|
243
|
+
β
|
|
244
|
+
The table below lists all possible error codes that are returned from either the `enroll()` or the `authenticate()` methods when **their promises are rejected respectively**.
|
|
245
|
+
|
|
246
|
+
| **Error Code** | **Description** | **Effect on `enroll()` or `authenticate()`** |
|
|
247
|
+
|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
248
|
+
| `fioErrCode.PERMISSION_REFUSED` | Access to the camera stream was **denied** by the end user. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
249
|
+
| `fioErrCode.TERMS_NOT_ACCEPTED` | Terms & Conditions set out by FACEIO/host application **rejected** by the end user. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
250
|
+
| `fioErrCode.SESSION_IN_PROGRESS` | Another [authentication](https://faceio.net/integration-guide#authenticate) or [enrollment](https://faceio.net/integration-guide#enroll) operation is processing. This can happen when your application logic calls more than once `enroll()` or `authenticate()` due to poor UI implementation on your side (eg. User taps twice the same button triggering the facial authentication process). **Starting with [fio.js 1.9](https://blog.pixlab.io/2022/10/fiojs-190-released-with-face-duplication-prevention), it is possible now to restart the current user session without reloading the entire HTML page via simple call to the [`restartSession()`](https://faceio.net/integration-guide#restart_sess) method**. | Ongoing operation is **still processing** and the FACEIO Widget **continue** running. Your error handler routine should probably **ignore this error code** as the operation is still ongoing. | | |
|
|
251
|
+
| `fioErrCode.FACE_DUPLICATION` | **This error code is raised when the same user tries to enroll a second time on your application. That is, his facial features are already recorded due to previous enrollment, and can no longer enroll again due to the security settings: *Prevent Same User from Enrolling Twice* or *More* being activated**. | Ongoing `enroll()` operation is **immediately aborted** and control is transferred to the host application. | | |
|
|
252
|
+
| `fioErrCode.TIMEOUT` | **Ongoing operation timed out** (eg, camera Access Permission, ToS Accept, Face not yet detected, Server Reply, etc.). | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
253
|
+
| `fioErrCode.NO_FACES_DETECTED` | **No faces were detected** during the enroll or authentication process. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
254
|
+
| `fioErrCode.UNRECOGNIZED_FACE` | **Unrecognized/unknown face** on this application Facial Index. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
255
|
+
| `fioErrCode.MANY_FACES` | **Two or more faces** were detected during the [enroll](https://faceio.net/integration-guide#enroll) or [authentication](https://faceio.net/integration-guide#authenticate) process. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
256
|
+
| `fioErrCode.PAD_ATTACK` | Presentation attack (PAD), better know as face spoofing attempt is detected during the authentication process. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
257
|
+
| `fioErrCode.UNIQUE_PIN_REQUIRED` | Supplied PIN Code **must be unique** among other PIN's on this application. This warning code is **raised only from the `enroll()` method**, and only if you have enabled the *Enforce PIN Code Uniqueness* [Security Option](https://faceio.net/security-best-practice). | Ongoing `enroll()` operation is **still processing** until the user being enrolled **input a unique PIN code**. | | |
|
|
258
|
+
| `fioErrCode.FACE_MISMATCH` | Calculated Facial Vectors of the **user being [enrolled](https://faceio.net/integration-guide#enroll) do not matches**. This error code **is raised only from the `enroll()` method**. | Ongoing `enroll()` operation is **immediately aborted** and control is transferred to the host application. | | |
|
|
259
|
+
| `fioErrCode.WRONG_PIN_CODE` | **Wrong PIN Code supplied** by the user being [authenticated](https://faceio.net/integration-guide#authenticate). This error code is **raised only from the `authenticate()` method**. | Ongoing `authenticate()` operation is **immediately aborted after three trials** and control is transferred to the host application. | | |
|
|
260
|
+
| `fioErrCode.NETWORK_IO` | Error while establishing network connection with the FACEIO processing node. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
261
|
+
| `fioErrCode.PROCESSING_ERR` | Server side error. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
262
|
+
| `fioErrCode.UNAUTHORIZED` | Your application is not allowed to perform the requested operation (eg. *Invalid ID, Blocked, Paused*, etc.). Refer to the [FACEIO Console](https://console.faceio.net/) for additional information. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
263
|
+
| `fioErrCode.UI_NOT_READY` | The FACEIO `fio.js` library could not be injected onto the client DOM. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
264
|
+
| `fioErrCode.TOO_MANY_REQUESTS` | Widget instantiation requests exceeded for freemium applications. **Does not apply for premium applications as `fio.js` instantiation is unmetered**. | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
265
|
+
| `fioErrCode.EMPTY_ORIGIN` | *Origin* or *Referer* HTTP request header is **empty or missing** while instantiating `fio.js`. This error is **raised only if you have enforced** the *Reject Empty Origin* [Security Option](https://faceio.net/security-best-practice#rejectMissingHeaders). | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
266
|
+
| `fioErrCode.FORBIDDDEN_ORIGIN` | Domain origin is forbidden from instantiating `fio.js`. This error is **raised only if you have created a white list of authorized domain names** via the [FACEIO Console](https://console.faceio.net/). | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
267
|
+
| `fioErrCode.FORBIDDDEN_COUNTRY` | Country ISO-3166-1 Code is forbidden from instantiating `fio.js`. This error is **raised only if you have created a white list of authorized countries** via the [FACEIO Console](https://console.faceio.net/). | Ongoing operation is **immediately aborted** and control is transferred to the host |
|
|
268
|
+
|
|
269
|
+
> ## REACTJS INTEGRATION BOILERPLATE
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
import faceIO from '@faceio/fiojs'
|
|
273
|
+
|
|
274
|
+
const faceio = new faceIO('app-public-id');
|
|
275
|
+
|
|
276
|
+
function App() {
|
|
277
|
+
return (
|
|
278
|
+
<div className="App">
|
|
279
|
+
<button onClick={enrollNewUser}>Enroll New User</button>
|
|
280
|
+
<button onClick={authenticateUser}>Authenticate User</button>
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function enrollNewUser() {
|
|
286
|
+
const userInfo = await faceio.enroll({
|
|
287
|
+
"locale": "auto", // Default user locale
|
|
288
|
+
"payload": {
|
|
289
|
+
/* The payload we want to associate with this particular user which is forwarded back to us upon future authentication of this user.*/
|
|
290
|
+
"whoami": 123456, // Dummy ID linked to this particular user
|
|
291
|
+
"email": "john.doe@example.com"
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
alert(
|
|
296
|
+
`User Successfully Enrolled! Details:
|
|
297
|
+
Unique Facial ID: ${userInfo.facialId}
|
|
298
|
+
Enrollment Date: ${userInfo.timestamp}
|
|
299
|
+
Gender: ${userInfo.details.gender}
|
|
300
|
+
Age Approximation: ${userInfo.details.age}`
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
async function authenticateUser() {
|
|
304
|
+
const userData = await faceio.authenticate({
|
|
305
|
+
"locale": "auto", // Default user locale
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
console.log("Success, user identified")
|
|
309
|
+
// Grab the facial ID linked to this particular user which will be same
|
|
310
|
+
// for each of his successful future authentication. FACEIO recommend
|
|
311
|
+
// that your rely on this Facial ID if you plan to uniquely identify
|
|
312
|
+
// all enrolled users on your backend for example.
|
|
313
|
+
console.log("Linked facial Id: " + userData.facialId)
|
|
314
|
+
// Grab the arbitrary data you have already linked (if any) to this particular user
|
|
315
|
+
// during his enrollment via the payload parameter of the enroll() method.
|
|
316
|
+
console.log("Payload: " + JSON.stringify(userData.payload)) // {"whoami": 123456, "email": "john.doe@example.com"} from the enroll() example above
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export default App;
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
# Further Reading
|
|
323
|
+
Finally, for additional information & to learn more about implementing FACEIO on your website or web application, please refer to the following documents:
|
|
324
|
+
- **[Getting Started Tutorial](https://faceio.net/getting-started)**: Learn the fundamentals about implementing facial authentication on a typical web application.
|
|
325
|
+
- **[Integration Guide](https://faceio.net/integration-guide)**: Learn how to implement ***fio.js***, our facial recognition library on your website.
|
|
326
|
+
- **[Developer Center](https://faceio.net/dev-guides)**: Code samples, documentation, support channels, and all the resources yo need to implement FACEIO on your website.
|
|
327
|
+
- **[Frequently Asked Questions](https://faceio.net/faq)**: Get instant answers to the most common questions.
|
|
328
|
+
- **[Trust Center](https://faceio.net/trust-center)**: Learn how we handle your data securely and in compliance with privacy and legal requirements.
|