Package Exports
- zklib-ts
- zklib-ts/dist/index.cjs.js
- zklib-ts/dist/index.es.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (zklib-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
zklib ts
An unofficial library that provides a robust solution for Node.js developers to interface with ZKTeco Devices.
Disclaimer ⚠️ This repository is not recommended for use in production. ⚠️ 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)
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 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
🗄️ Alternatives
Javascript
Python:
☕ Java:
📄 Documentation
License
The MIT License (MIT). Please see License File for more information.