forked from xxpauloxx/nodejs-nbiobsp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
62 lines (57 loc) · 2.08 KB
/
test.js
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
console.log(" ");
const nitgenBSP = require('./index.js');
console.warn(nitgenBSP);
const init = nitgenBSP.init();
// nitgenBSP.setSkin("NBSP2Jpn.dll"); // Japanese
// nitgenBSP.setSkin("NBSP2Kor.dll"); // Korean
// nitgenBSP.setSkin("NBSP2Por.dll"); // Portuguese
let fir1, fir2;
console.warn(`init: ${init}`);
if(init === nitgenBSP.NBioAPIERROR_NONE){
console.log("Enroll the fingerprints you may want: ");
fir1 = nitgenBSP.capture(4000, nitgenBSP.NBioAPI_FIR_PURPOSE_ENROLL);
if (typeof fir1 === 'number') {
switch(fir1) {
case nitgenBSP.NBioAPIERROR_USER_CANCEL:
console.warn('User canceled');
process.exit(fir1);
case nitgenBSP.NBioAPIERROR_CAPTURE_TIMEOUT:
console.warn('Capture timeout');
process.exit(fir1);
}
}
console.log('First fingerprint:', fir1);
console.log("Capture a new fingerprint to verify against enrolled: ");
fir2 = nitgenBSP.capture(4000, nitgenBSP.NBioAPI_FIR_PURPOSE_VERIFY);
if (typeof fir2 === 'number') {
switch(fir2) {
case nitgenBSP.NBioAPIERROR_USER_CANCEL:
console.warn('User canceled');
process.exit(fir2);
case nitgenBSP.NBioAPIERROR_CAPTURE_TIMEOUT:
console.warn('Capture timeout');
process.exit(fir2);
}
}
console.log('Second fingerprint:', fir2);
const match = nitgenBSP.match(fir1, fir2);
switch(match) {
case nitgenBSP.NBioAPIERROR_NONE:
console.log('Captured fingerprint compared to enrolled ones: NOT MATCHED', match);
break;
case nitgenBSP.NBioAPIERROR_DATA_PROCESS_FAIL:
case nitgenBSP.NBioAPIERROR_MUST_BE_PROCESSED_DATA:
case nitgenBSP.NBioAPIERROR_UNKNOWN_INPUTFORMAT:
case nitgenBSP.NBioAPIERROR_UNKNOWN_FORMAT:
console.log('Captured fingerprint compared to enrolled ones: INVALID DATA', match);
break;
case nitgenBSP.NBioAPIERROR_INTERNAL_CHECKSUM_FAIL:
console.log('Captured fingerprint compared to enrolled ones: DATA LOOKS FORGED', match);
break;
case true:
console.log('Captured fingerprint compared to enrolled ones: MATCHED', match);
}
console.log('Close device: ', nitgenBSP.close());
} else {
console.log("Device disconnected or had error during initialization.");
}