zklib-ts 1.0.2-development → 1.0.4-development
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.md +20 -20
- package/README.md +2 -0
- package/dist/index.cjs.js +33 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +33 -3
- package/dist/ztcp.d.ts +5 -0
- package/package.json +6 -7
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) Gustavo Paz <gusti.paz@gmail.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Gustavo Paz <gusti.paz@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
21
|
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/is-electron)
|
|
1
2
|
<h1 align="center">zklib ts</h1>
|
|
2
3
|
<p align="center">An unofficial library that provides a robust solution for Node.js developers to interface with ZKTeco Devices.</p>
|
|
3
4
|
<p align="center">
|
|
@@ -107,3 +108,4 @@ npm t Generic
|
|
|
107
108
|
## License
|
|
108
109
|
|
|
109
110
|
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
|
111
|
+
|
package/dist/index.cjs.js
CHANGED
|
@@ -365,7 +365,7 @@ const parseTimeToDate = (time) => {
|
|
|
365
365
|
const month = time % 12;
|
|
366
366
|
time = (time - month) / 12;
|
|
367
367
|
const year = time + 2000;
|
|
368
|
-
return new Date(year, month, day, hour, minute, second);
|
|
368
|
+
return new Date(Date.UTC(year, month, day, hour, minute, second));
|
|
369
369
|
};
|
|
370
370
|
const decodeUserData28 = (userData) => {
|
|
371
371
|
return {
|
|
@@ -1249,9 +1249,9 @@ class ZTCP {
|
|
|
1249
1249
|
async getVendor() {
|
|
1250
1250
|
const keyword = '~OEMVendor';
|
|
1251
1251
|
try {
|
|
1252
|
-
// Execute the command to get
|
|
1252
|
+
// Execute the command to get oem vendor
|
|
1253
1253
|
const data = await this.executeCmd(COMMANDS.CMD_OPTIONS_RRQ, keyword);
|
|
1254
|
-
// Extract and format the
|
|
1254
|
+
// Extract and format the oem bendor from the response data
|
|
1255
1255
|
const vendor = data.slice(8) // Skip the first 8 bytes (header)
|
|
1256
1256
|
.toString('ascii') // Convert buffer to string
|
|
1257
1257
|
.replace(`${keyword}=`, '') // Remove the keyword prefix
|
|
@@ -1303,6 +1303,29 @@ class ZTCP {
|
|
|
1303
1303
|
throw err;
|
|
1304
1304
|
}
|
|
1305
1305
|
}
|
|
1306
|
+
async getNetworkParams() {
|
|
1307
|
+
try {
|
|
1308
|
+
const params = {
|
|
1309
|
+
IPAddress: this.ip,
|
|
1310
|
+
NetMask: '',
|
|
1311
|
+
GATEIPAddress: ''
|
|
1312
|
+
};
|
|
1313
|
+
const keywords = Object.keys(params);
|
|
1314
|
+
for await (const keyword of keywords) {
|
|
1315
|
+
const data = await this.executeCmd(COMMANDS.CMD_OPTIONS_RRQ, keyword);
|
|
1316
|
+
params[keyword] = data.slice(8)
|
|
1317
|
+
.toString('utf-8')
|
|
1318
|
+
.replace(`${keyword}=`, '') // Remove the keyword prefix
|
|
1319
|
+
.replace(/\u0000/g, '')
|
|
1320
|
+
.replace('=', '.'); // Replace equal simbol to dot, due to sometimes there are parsing errors
|
|
1321
|
+
}
|
|
1322
|
+
return params;
|
|
1323
|
+
}
|
|
1324
|
+
catch (err) {
|
|
1325
|
+
console.error("Error getting Network Params: ", err);
|
|
1326
|
+
throw err;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1306
1329
|
async getSerialNumber() {
|
|
1307
1330
|
const keyword = '~SerialNumber';
|
|
1308
1331
|
try {
|
|
@@ -1312,7 +1335,11 @@ class ZTCP {
|
|
|
1312
1335
|
const serialNumber = data.slice(8) // Skip the first 8 bytes (header)
|
|
1313
1336
|
.toString('utf-8') // Convert buffer to string
|
|
1314
1337
|
.replace(`${keyword}=`, '') // Remove the keyword prefix
|
|
1338
|
+
.replace('=', '') // Remove sometines last number is a character equal to = or unknow character
|
|
1315
1339
|
.replace(/\u0000/g, ''); // Remove null characters
|
|
1340
|
+
if (serialNumber.length !== 13 && this.verbose) {
|
|
1341
|
+
console.warn('Serial number length not equal to 13, check');
|
|
1342
|
+
}
|
|
1316
1343
|
return serialNumber;
|
|
1317
1344
|
}
|
|
1318
1345
|
catch (err) {
|
|
@@ -2754,6 +2781,9 @@ class Zklib {
|
|
|
2754
2781
|
async executeCmd(command, data = '') {
|
|
2755
2782
|
return this.functionWrapper(() => this.ztcp.executeCmd(command, data), () => this.zudp.executeCmd(command, data), 'EXECUTE_CMD');
|
|
2756
2783
|
}
|
|
2784
|
+
async getNetworkParams() {
|
|
2785
|
+
return this.functionWrapper(() => this.ztcp.getNetworkParams(), async () => { throw new Error('UDP getNetworkParams not implemented'); }, 'NETWORK_PARAMS');
|
|
2786
|
+
}
|
|
2757
2787
|
}
|
|
2758
2788
|
|
|
2759
2789
|
module.exports = Zklib;
|
package/dist/index.d.ts
CHANGED
|
@@ -69,5 +69,10 @@ export default class Zklib {
|
|
|
69
69
|
clearAttendanceLog(): Promise<any>;
|
|
70
70
|
clearData(): Promise<any>;
|
|
71
71
|
executeCmd(command: number, data?: string | Buffer): Promise<Buffer>;
|
|
72
|
+
getNetworkParams(): Promise<{
|
|
73
|
+
IPAddress: string;
|
|
74
|
+
NetMask: string;
|
|
75
|
+
GATEIPAddress: string;
|
|
76
|
+
}>;
|
|
72
77
|
}
|
|
73
78
|
export type { Attendance, User, Finger, DeviceInfo, Zklib };
|
package/dist/index.es.js
CHANGED
|
@@ -344,7 +344,7 @@ const parseTimeToDate = (time) => {
|
|
|
344
344
|
const month = time % 12;
|
|
345
345
|
time = (time - month) / 12;
|
|
346
346
|
const year = time + 2000;
|
|
347
|
-
return new Date(year, month, day, hour, minute, second);
|
|
347
|
+
return new Date(Date.UTC(year, month, day, hour, minute, second));
|
|
348
348
|
};
|
|
349
349
|
const decodeUserData28 = (userData) => {
|
|
350
350
|
return {
|
|
@@ -1228,9 +1228,9 @@ class ZTCP {
|
|
|
1228
1228
|
async getVendor() {
|
|
1229
1229
|
const keyword = '~OEMVendor';
|
|
1230
1230
|
try {
|
|
1231
|
-
// Execute the command to get
|
|
1231
|
+
// Execute the command to get oem vendor
|
|
1232
1232
|
const data = await this.executeCmd(COMMANDS.CMD_OPTIONS_RRQ, keyword);
|
|
1233
|
-
// Extract and format the
|
|
1233
|
+
// Extract and format the oem bendor from the response data
|
|
1234
1234
|
const vendor = data.slice(8) // Skip the first 8 bytes (header)
|
|
1235
1235
|
.toString('ascii') // Convert buffer to string
|
|
1236
1236
|
.replace(`${keyword}=`, '') // Remove the keyword prefix
|
|
@@ -1282,6 +1282,29 @@ class ZTCP {
|
|
|
1282
1282
|
throw err;
|
|
1283
1283
|
}
|
|
1284
1284
|
}
|
|
1285
|
+
async getNetworkParams() {
|
|
1286
|
+
try {
|
|
1287
|
+
const params = {
|
|
1288
|
+
IPAddress: this.ip,
|
|
1289
|
+
NetMask: '',
|
|
1290
|
+
GATEIPAddress: ''
|
|
1291
|
+
};
|
|
1292
|
+
const keywords = Object.keys(params);
|
|
1293
|
+
for await (const keyword of keywords) {
|
|
1294
|
+
const data = await this.executeCmd(COMMANDS.CMD_OPTIONS_RRQ, keyword);
|
|
1295
|
+
params[keyword] = data.slice(8)
|
|
1296
|
+
.toString('utf-8')
|
|
1297
|
+
.replace(`${keyword}=`, '') // Remove the keyword prefix
|
|
1298
|
+
.replace(/\u0000/g, '')
|
|
1299
|
+
.replace('=', '.'); // Replace equal simbol to dot, due to sometimes there are parsing errors
|
|
1300
|
+
}
|
|
1301
|
+
return params;
|
|
1302
|
+
}
|
|
1303
|
+
catch (err) {
|
|
1304
|
+
console.error("Error getting Network Params: ", err);
|
|
1305
|
+
throw err;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1285
1308
|
async getSerialNumber() {
|
|
1286
1309
|
const keyword = '~SerialNumber';
|
|
1287
1310
|
try {
|
|
@@ -1291,7 +1314,11 @@ class ZTCP {
|
|
|
1291
1314
|
const serialNumber = data.slice(8) // Skip the first 8 bytes (header)
|
|
1292
1315
|
.toString('utf-8') // Convert buffer to string
|
|
1293
1316
|
.replace(`${keyword}=`, '') // Remove the keyword prefix
|
|
1317
|
+
.replace('=', '') // Remove sometines last number is a character equal to = or unknow character
|
|
1294
1318
|
.replace(/\u0000/g, ''); // Remove null characters
|
|
1319
|
+
if (serialNumber.length !== 13 && this.verbose) {
|
|
1320
|
+
console.warn('Serial number length not equal to 13, check');
|
|
1321
|
+
}
|
|
1295
1322
|
return serialNumber;
|
|
1296
1323
|
}
|
|
1297
1324
|
catch (err) {
|
|
@@ -2733,6 +2760,9 @@ class Zklib {
|
|
|
2733
2760
|
async executeCmd(command, data = '') {
|
|
2734
2761
|
return this.functionWrapper(() => this.ztcp.executeCmd(command, data), () => this.zudp.executeCmd(command, data), 'EXECUTE_CMD');
|
|
2735
2762
|
}
|
|
2763
|
+
async getNetworkParams() {
|
|
2764
|
+
return this.functionWrapper(() => this.ztcp.getNetworkParams(), async () => { throw new Error('UDP getNetworkParams not implemented'); }, 'NETWORK_PARAMS');
|
|
2765
|
+
}
|
|
2736
2766
|
}
|
|
2737
2767
|
|
|
2738
2768
|
export { Zklib as default };
|
package/dist/ztcp.d.ts
CHANGED
|
@@ -104,6 +104,11 @@ export declare class ZTCP {
|
|
|
104
104
|
getVendor(): Promise<string>;
|
|
105
105
|
getProductTime(): Promise<Date>;
|
|
106
106
|
getMacAddress(): Promise<string>;
|
|
107
|
+
getNetworkParams(): Promise<{
|
|
108
|
+
IPAddress: string;
|
|
109
|
+
NetMask: string;
|
|
110
|
+
GATEIPAddress: string;
|
|
111
|
+
}>;
|
|
107
112
|
getSerialNumber(): Promise<string>;
|
|
108
113
|
getDeviceVersion(): Promise<string>;
|
|
109
114
|
getDeviceName(): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zklib-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4-development",
|
|
4
4
|
"description": "Unofficial zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"test": "jest",
|
|
16
16
|
"build": "rollup -c",
|
|
17
17
|
"watch": "rollup -c --watch",
|
|
18
|
-
"prepare": "npm run build"
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"publish": "npm run publish --tag latest"
|
|
19
20
|
},
|
|
20
21
|
"repositoryUrl": "https://github.com/guspaz0/zklib-ts.git",
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/guspaz0/zklib-ts.git"
|
|
24
|
+
"url": "git+https://github.com/guspaz0/zklib-ts.git"
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|
|
26
27
|
"typescript",
|
|
@@ -49,13 +50,11 @@
|
|
|
49
50
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
50
51
|
"@types/jest": "^29.5.14",
|
|
51
52
|
"@types/node": "^22.13.14",
|
|
52
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
53
53
|
"dotenv": "^16.4.7",
|
|
54
|
-
"jest": "
|
|
54
|
+
"jest": "30.2.0",
|
|
55
55
|
"rollup": "^4.37.0",
|
|
56
56
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
57
|
-
"
|
|
58
|
-
"ts-jest": "^29.3.0",
|
|
57
|
+
"ts-jest": "29.4.6",
|
|
59
58
|
"ts-node": "^10.9.2",
|
|
60
59
|
"tslib": "^2.8.1",
|
|
61
60
|
"typescript": "^5.8.2"
|