@faceio/fiojs 1.1.0 → 3.0.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/LICENSE +201 -201
- package/README.md +279 -365
- package/index.js +121 -102
- package/package.json +24 -17
package/index.js
CHANGED
|
@@ -1,102 +1,121 @@
|
|
|
1
|
-
/*eslint no-undef: 0*/
|
|
2
|
-
let internalCDN;
|
|
3
|
-
|
|
4
|
-
module.exports = class faceio {
|
|
5
|
-
constructor(appID){
|
|
6
|
-
if(internalCDN) return;
|
|
7
|
-
|
|
8
|
-
let script = document.createElement('script')
|
|
9
|
-
|
|
10
|
-
script.setAttribute('src', 'https://cdn.faceio.net/fio.js');
|
|
11
|
-
|
|
12
|
-
document.head.appendChild(script);
|
|
13
|
-
|
|
14
|
-
script.addEventListener('load', () => {
|
|
15
|
-
internalCDN = new faceIO(appID)
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} parameters
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {Number} parameters.
|
|
24
|
-
* @param {Number} parameters.
|
|
25
|
-
* @param {Number} parameters.
|
|
26
|
-
* @param {Number} parameters.
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @returns {
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {Number} parameters.
|
|
51
|
-
* @param {
|
|
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
|
-
|
|
1
|
+
/*eslint no-undef: 0*/
|
|
2
|
+
let internalCDN;
|
|
3
|
+
|
|
4
|
+
module.exports = class faceio {
|
|
5
|
+
constructor(appID){
|
|
6
|
+
if(internalCDN) return;
|
|
7
|
+
|
|
8
|
+
let script = document.createElement('script')
|
|
9
|
+
|
|
10
|
+
script.setAttribute('src', 'https://cdn.faceio.net/fio.js');
|
|
11
|
+
|
|
12
|
+
document.head.appendChild(script);
|
|
13
|
+
|
|
14
|
+
script.addEventListener('load', () => {
|
|
15
|
+
internalCDN = new faceIO(appID)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enroll new user.
|
|
21
|
+
* @param {Object} parameters enroll() takes a single, optional parameters object with the properties to be configured.
|
|
22
|
+
* @param {Object} parameters.payload An arbitrary set of data, you want to associate with the user being enrolled.
|
|
23
|
+
* @param {Number} parameters.permissionTimeout Total number of seconds to wait for the user to grant camera access permission.
|
|
24
|
+
* @param {Number} parameters.termsTimeout Total number of minutes to wait for the user to accept FACEIO/Host Application Terms of Service.
|
|
25
|
+
* @param {Number} parameters.idleTimeout Total number of seconds to wait before giving up if no faces were detected during the enrollment process.
|
|
26
|
+
* @param {Number} parameters.replyTimeout Total number of seconds to wait before giving up if the remote FACEIO processing node does not return a response (a very unlikely scenario).
|
|
27
|
+
* @param {Number} parameters.enrollIntroTimeout Enrollment Widget introduction/instruction screen display delay.
|
|
28
|
+
* @param {String} parameters.locale Default interaction language for the Widget display.
|
|
29
|
+
* @param {Boolean} parameters.userConsent 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.
|
|
30
|
+
* @param {Boolean} parameters.showAbortBtn Set to true if you want the abort button (close modal) to always appear during enrollment. If the user explicitly aborts, the fioErrCode.ABORTED_BY_USER error will be raised.
|
|
31
|
+
* @returns {String} facialId: A Universally Unique Identifier assigned to this particular user.
|
|
32
|
+
* @returns {String} timestamp: ISO 8601, enrollment completion date & time.
|
|
33
|
+
* @returns {Object} details: An object with two fields: gender and age which respectively corresponds to the Gender and Age approximation of the enrolled user.
|
|
34
|
+
* @example
|
|
35
|
+
* faceio.enroll({
|
|
36
|
+
* "locale": "auto", // Default user locale
|
|
37
|
+
* "payload": {
|
|
38
|
+
* "whoami": 123456, // Dummy ID linked to this particular user
|
|
39
|
+
* "email": "john.doe@example.com"
|
|
40
|
+
* }
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
43
|
+
async enroll(parameters) {
|
|
44
|
+
return await internalCDN.enroll(parameters)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Transactionally authenticate previously enrolled users.
|
|
49
|
+
* @param {Object} parameters authenticate() takes a single, optional parameters object with the properties to be configured.
|
|
50
|
+
* @param {Number} parameters.permissionTimeout Total number of seconds to wait for the user to grant camera access permission.
|
|
51
|
+
* @param {Number} parameters.idleTimeout Total number of seconds to wait before giving up if no faces were detected during the authentication process.
|
|
52
|
+
* @param {Number} parameters.replyTimeout Total number of seconds to wait before giving up if the remote FACEIO processing node does not return a response (a very unlikely scenario)
|
|
53
|
+
* @param {String} parameters.locale Default interaction language of the FACEIO Widget.
|
|
54
|
+
* @returns {any} payload: The arbitrary data you have already linked (if any) to this particular user during his enrollment via the payload parameter of the enroll() method.
|
|
55
|
+
* @returns {String} facialId: A Universally Unique Identifier assigned to this particular user.
|
|
56
|
+
* @example
|
|
57
|
+
* faceio.authenticate({
|
|
58
|
+
* "locale": "auto" // Default user locale
|
|
59
|
+
* });
|
|
60
|
+
*/
|
|
61
|
+
async authenticate(parameters) {
|
|
62
|
+
return await internalCDN.authenticate(parameters)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Perform Liveness Detection (PAD) without Authentication.
|
|
67
|
+
* @param {Object} parameters Configuration parameters
|
|
68
|
+
*/
|
|
69
|
+
async liveness(parameters) {
|
|
70
|
+
return await internalCDN.liveness(parameters)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Perform Age Verification Check.
|
|
75
|
+
* @param {Object} parameters Configuration parameters
|
|
76
|
+
*/
|
|
77
|
+
async ageVerify(parameters) {
|
|
78
|
+
return await internalCDN.ageVerify(parameters)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Purge the current session and request a new one.
|
|
83
|
+
* @returns true if the request for a new session have been granted, and ready for another round of calls to enroll() or authenticate() for the same user. false otherwise.
|
|
84
|
+
*/
|
|
85
|
+
restartSession() {
|
|
86
|
+
return internalCDN.restartSession()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Return the list of all possible error codes than can be triggered during failed authentication or enrollment.
|
|
91
|
+
* @returns fioErrorCode object
|
|
92
|
+
*/
|
|
93
|
+
fetchAllErrorCodes(){
|
|
94
|
+
return {
|
|
95
|
+
PERMISSION_REFUSED: 1, /* Access to the Camera stream was denied by the end user */
|
|
96
|
+
NO_FACES_DETECTED: 2, /* No faces were detected during the enroll or authentication process */
|
|
97
|
+
UNRECOGNIZED_FACE: 3, /* Unrecognized face on this application's Facial Index */
|
|
98
|
+
MANY_FACES: 4, /* Two or more faces were detected during the scan process */
|
|
99
|
+
PAD_ATTACK: 5, /* Presentation (Spoof) Attack (PAD) detected during the scan process */
|
|
100
|
+
FACE_MISMATCH: 6, /* Calculated Facial Vectors of the user being enrolled do not matches */
|
|
101
|
+
NETWORK_IO: 7, /* Error while establishing network connection with the target FACEIO processing node */
|
|
102
|
+
WRONG_PIN_CODE: 8, /* Wrong PIN code supplied by the user being authenticated */
|
|
103
|
+
PROCESSING_ERR: 9, /* Server side error */
|
|
104
|
+
UNAUTHORIZED: 10, /* Your application is not allowed to perform the requested operation */
|
|
105
|
+
TERMS_NOT_ACCEPTED: 11, /* Terms & Conditions set out by FACEIO/host application rejected by the end user */
|
|
106
|
+
UI_NOT_READY: 12, /* The FACEIO Widget code could not be (or is being) injected onto the client DOM */
|
|
107
|
+
SESSION_EXPIRED: 13, /* Client session expired. */
|
|
108
|
+
TIMEOUT: 14, /* Ongoing operation timed out */
|
|
109
|
+
TOO_MANY_REQUESTS: 15, /* Widget instantiation requests exceeded the allowed limits */
|
|
110
|
+
EMPTY_ORIGIN: 16, /* Origin or Referer HTTP request header is empty or missing */
|
|
111
|
+
FORBIDDEN_ORIGIN: 17, /* Domain origin is forbidden from instantiating fio.js */
|
|
112
|
+
FORBIDDEN_COUNTRY: 18, /* Country ISO-3166-1 Code is forbidden from instantiating fio.js */
|
|
113
|
+
UNIQUE_PIN_REQUIRED: 19, /* Supplied PIN Code must be unique among other PIN's on this application */
|
|
114
|
+
SESSION_IN_PROGRESS: 20, /* Another authentication or enrollment session is in progress */
|
|
115
|
+
FACE_DUPLICATION: 21, /* Prevent face duplication during enrollment. Same user trying to enroll twice or more */
|
|
116
|
+
MINORS_NOT_ALLOWED: 22, /* Minors not allowed to enroll on this application */
|
|
117
|
+
UPGRADE_REQUIRED: 23, /* Upgrade Required in order to activate the said feature */
|
|
118
|
+
ABORTED_BY_USER: 24, /* Ongoing operation was aborted by user (eg. close button click) */
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@faceio/fiojs",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Facial Authentication for the Web",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"homepage": "https://faceio.net/",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+ssh://git@github.com/symisc/faceio-npm.git"
|
|
10
|
-
},
|
|
11
|
-
"license": "APACHE 2",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@faceio/fiojs",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Facial Authentication for the Web",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"homepage": "https://faceio.net/",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+ssh://git@github.com/symisc/faceio-npm.git"
|
|
10
|
+
},
|
|
11
|
+
"license": "APACHE 2",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"facial authentication",
|
|
17
|
+
"Biometric authentication",
|
|
18
|
+
"face recognition",
|
|
19
|
+
"passwordless authentication",
|
|
20
|
+
"face identification",
|
|
21
|
+
"face biometrics"
|
|
22
|
+
],
|
|
23
|
+
"author": "PixLab | Symisc Systems - https://faceio.net"
|
|
24
|
+
}
|