zklib-ts
v1.0.6
Published
Unofficial zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices
Maintainers
Readme
[!WARNING] This repository is currently in development and may contain bugs or incomplete features. Use at your own risk and do not deploy to a production environment
📋 Index
Installation
You must have Node.js ^18 before run the command down below:
npm i zklib-ts🛠️ Usage
create a connection. constructor receives (ip, timeout, inport, port, comm_key)
import Zklib from 'zklib-ts'
const zkInstance = new Zklib("10.0.0.10",10000,10000,4370,0)
await zkInstance.createSocket()
Get all users:
const users = await zkInstance.getUsers()
Get all attendances:
const attendances = await zkInstance.getAttendances()
get All templates
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.
const templates = await zkInstance.saveUserTemplate(user, templates) enrollUser: receives a user user_id and finger ID fid where 0 <= fid <= 9
await zkInstance.enrollUser(50,5)Get a user single finger template
const data = await zkInstance.getUserTemplate(
"144", // user id/pin
1 // finger index
)Upload a user single finger template
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
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.
npm ifor 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=1234and then run tests:
npm tfor 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🗄️ Alternatives
Javascript
Python:
☕ Java:
📄 Documentation
License
The MIT License (MIT). Please see License File for more information.

