Unofficial zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices
npm install zklib-ts
An unofficial library that provides a robust solution for Node.js developers to interface with ZKTeco Devices.
js
npm i zklib-ts
`
๐ ๏ธ Usage
create a connection. constructor receives (ip, timeout, inport, port, comm_key)
`js
import Zklib from 'zklib-ts'
const zkInstance = new Zklib("10.0.0.10",10000,10000,4370,0)
await zkInstance.createSocket()
`
Get all users:
`js
const users = await zkInstance.getUsers()
`
Get all attendances:
`js
const attendances = await zkInstance.getAttendances()
`
get All templates
`js
const templates = await zkInstance.getTemplates()
`
save user templates. receives a User instance class and an array of Finger class. currently only save one template per call.
`js
const templates = await zkInstance.saveUserTemplate(user, templates)
`
enrollUser: receives a user user_id and finger ID fid where 0 <= fid <= 9
`js
await zkInstance.enrollUser(50,5)
`
Get a user single finger template
`js
const data = await zkInstance.getUserTemplate(
"144", // user id/pin
1 // finger index
)
`
Upload a user single finger template
`js
const uploaded = await zkInstance.uploadFingerTemplate(
"144", // user id/pin
"this_is_a_very_long_string", // finger template in Base64 string
1, // finger id/index
1 // finger flag
)
`
delete template. receives user id uid and finger id where 0 <= fid <= 9
`js
await zkInstance.deleteTemplate(50,5)
`
Check the Testing section for more functionalities coverage.
๐ ๏ธ Testing
The repo uses Jest. There is a mock file for test without having a phisical device connected. Before start you will need to install dependencies.
`js
npm i
`
for testing your phisical device first create .env file in root directory with the values down below:
`
DEVICE_IP=10.10.10.1
DEVICE_PORT=4370
DEVICE_PASSWORD=1234
`
and then run tests:
`
npm t
`
for testing especific file after "npm t" type some name that matches a test file ...
for example the next command will execute "Generic.test.ts"
`
npm t Generic
``