zklib-ts 1.0.4 → 1.0.6
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/README.md +18 -0
- package/dist/helper/command.d.ts +177 -85
- package/dist/index.cjs.js +805 -480
- package/dist/index.d.ts +47 -6
- package/dist/index.es.js +805 -480
- package/dist/models/Attendance.d.ts +7 -2
- package/dist/services/transaction.service.d.ts +9 -0
- package/dist/services/user.service.d.ts +33 -0
- package/dist/ztcp.d.ts +22 -31
- package/dist/zudp.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,24 @@ enrollUser: receives a user `user_id` and finger ID `fid` where `0 <= fid <= 9`
|
|
|
62
62
|
```js
|
|
63
63
|
await zkInstance.enrollUser(50,5)
|
|
64
64
|
```
|
|
65
|
+
|
|
66
|
+
Get a user single finger template
|
|
67
|
+
```js
|
|
68
|
+
const data = await zkInstance.getUserTemplate(
|
|
69
|
+
"144", // user id/pin
|
|
70
|
+
1 // finger index
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Upload a user single finger template
|
|
75
|
+
```js
|
|
76
|
+
const uploaded = await zkInstance.uploadFingerTemplate(
|
|
77
|
+
"144", // user id/pin
|
|
78
|
+
"this_is_a_very_long_string", // finger template in Base64 string
|
|
79
|
+
1, // finger id/index
|
|
80
|
+
1 // finger flag
|
|
81
|
+
)
|
|
82
|
+
```
|
|
65
83
|
delete template. receives user id `uid` and finger id where `0 <= fid <= 9`
|
|
66
84
|
```js
|
|
67
85
|
await zkInstance.deleteTemplate(50,5)
|
package/dist/helper/command.d.ts
CHANGED
|
@@ -1,98 +1,188 @@
|
|
|
1
1
|
export declare enum COMMANDS {
|
|
2
2
|
CMD_ACK_DATA = 2002,
|
|
3
|
-
|
|
3
|
+
/** There was an error when processing the request.*/
|
|
4
|
+
CMD_ACK_ERROR = 2001,
|
|
4
5
|
CMD_ACK_ERROR_CMD = 65533,
|
|
5
6
|
CMD_ACK_ERROR_DATA = 65531,
|
|
6
7
|
CMD_ACK_ERROR_INIT = 65532,
|
|
7
|
-
|
|
8
|
+
/** [0xD0, 0x07] The request was processed sucessfully. */
|
|
9
|
+
CMD_ACK_OK = 2000,
|
|
8
10
|
CMD_ACK_REPEAT = 2004,
|
|
9
11
|
CMD_ACK_RETRY = 2003,
|
|
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
|
-
|
|
12
|
+
/** [0xD5, 0x07] Connection not authorized. */
|
|
13
|
+
CMD_ACK_UNAUTH = 2005,
|
|
14
|
+
/** Received unknown command. */
|
|
15
|
+
CMD_ACK_UNKNOWN = 65535,
|
|
16
|
+
/** Request attendance log. */
|
|
17
|
+
CMD_ATTLOG_RRQ = 13,
|
|
18
|
+
/** [0x4E, 0x04] Request to begin session using commkey. */
|
|
19
|
+
CMD_AUTH = 1102,
|
|
20
|
+
/** Disable normal authentication of users. */
|
|
21
|
+
CMD_CANCELCAPTURE = 62,
|
|
22
|
+
/** Capture fingerprint picture. */
|
|
23
|
+
CMD_CAPTUREFINGER = 1009,
|
|
24
|
+
/** Capture the entire image. */
|
|
25
|
+
CMD_CAPTUREIMAGE = 1012,
|
|
26
|
+
/** Change transmission speed. */
|
|
27
|
+
CMD_CHANGE_SPEED = 1101,
|
|
28
|
+
/** [0x77, 0x00] Get checksum of machine's buffer. */
|
|
29
|
+
CMD_CHECKSUM_BUFFER = 119,
|
|
30
|
+
/** Restore access control to default. */
|
|
31
|
+
CMD_CLEAR_ACC = 32,
|
|
32
|
+
/** Clears admins privileges. */
|
|
33
|
+
CMD_CLEAR_ADMIN = 20,
|
|
34
|
+
/** Delete attendance record. */
|
|
35
|
+
CMD_CLEAR_ATTLOG = 15,
|
|
36
|
+
/** Delete data. */
|
|
37
|
+
CMD_CLEAR_DATA = 14,
|
|
38
|
+
/** Clear screen captions. */
|
|
39
|
+
CMD_CLEAR_LCD = 67,
|
|
40
|
+
/** Delete operations log. */
|
|
41
|
+
CMD_CLEAR_OPLOG = 33,
|
|
42
|
+
/** [0xE8, 0x03] Begin connection. */
|
|
43
|
+
CMD_CONNECT = 1000,
|
|
44
|
+
/** [0xDD, 0x05] Data packet. */
|
|
45
|
+
CMD_DATA = 1501,
|
|
46
|
+
/** Indicates that it is ready to receive data. */
|
|
47
|
+
CMD_DATA_RDY = 1504,
|
|
48
|
+
/** Read/Write a large data set. */
|
|
49
|
+
CMD_DATA_WRRQ = 1503,
|
|
50
|
+
/** Read saved data. */
|
|
51
|
+
CMD_DB_RRQ = 7,
|
|
52
|
+
/** Deletes fingerprint template. */
|
|
53
|
+
CMD_DEL_FPTMP = 134,
|
|
54
|
+
/** Delete short message. */
|
|
55
|
+
CMD_DELETE_SMS = 72,
|
|
56
|
+
/** Delete user short message. */
|
|
57
|
+
CMD_DELETE_UDATA = 74,
|
|
58
|
+
/** Delete user. */
|
|
59
|
+
CMD_DELETE_USER = 18,
|
|
60
|
+
/** Delete user fingerprint template. */
|
|
61
|
+
CMD_DELETE_USERTEMP = 19,
|
|
62
|
+
/** Disables fingerprint, rfid reader and keyboard. */
|
|
63
|
+
CMD_DISABLEDEVICE = 1003,
|
|
64
|
+
/** Get door state. */
|
|
65
|
+
CMD_DOORSTATE_RRQ = 75,
|
|
66
|
+
/** Clear Mifare card. */
|
|
67
|
+
CMD_EMPTY_MIFARE = 78,
|
|
68
|
+
/** Enables the ":" in screen clock. */
|
|
69
|
+
CMD_ENABLE_CLOCK = 57,
|
|
70
|
+
/** Change machine state to "normal work". */
|
|
71
|
+
CMD_ENABLEDEVICE = 1002,
|
|
72
|
+
/** [0xE9, 0x03] Disconnect. */
|
|
73
|
+
CMD_EXIT = 1001,
|
|
74
|
+
/** [0xDE, 0x05] Release buffer used for data transmission. */
|
|
75
|
+
CMD_FREE_DATA = 1502,
|
|
76
|
+
/** Request machine status (remaining space). */
|
|
77
|
+
CMD_GET_FREE_SIZES = 50,
|
|
78
|
+
/** Request max size for users id. */
|
|
79
|
+
CMD_GET_PINWIDTH = 69,
|
|
80
|
+
/** Request machine time. */
|
|
81
|
+
CMD_GET_TIME = 201,
|
|
45
82
|
CMD_GET_USERTEMP = 88,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
/** Request the firmware edition. */
|
|
84
|
+
CMD_GET_VERSION = 1100,
|
|
85
|
+
/** Get group timezone. */
|
|
86
|
+
CMD_GRPTZ_RRQ = 25,
|
|
87
|
+
/** Set group timezone. */
|
|
88
|
+
CMD_GRPTZ_WRQ = 26,
|
|
89
|
+
/** Read operations log. */
|
|
90
|
+
CMD_OPLOG_RRQ = 34,
|
|
91
|
+
/** Read configuration value of the machine. */
|
|
92
|
+
CMD_OPTIONS_RRQ = 11,
|
|
93
|
+
/** Change configuration value of the machine. */
|
|
94
|
+
CMD_OPTIONS_WRQ = 12,
|
|
95
|
+
/** Shut-down machine. */
|
|
96
|
+
CMD_POWEROFF = 1005,
|
|
97
|
+
/** [0xDC, 0x05] Prepare for data transmission. */
|
|
98
|
+
CMD_PREPARE_DATA = 1500,
|
|
99
|
+
/** [0xF5, 0x03] Refresh the machine stored data. */
|
|
100
|
+
CMD_REFRESHDATA = 1013,
|
|
101
|
+
/** Refresh the configuration parameters. */
|
|
102
|
+
CMD_REFRESHOPTION = 1014,
|
|
103
|
+
/** Realtime events. */
|
|
104
|
+
CMD_REG_EVENT = 500,
|
|
105
|
+
/** Restart machine. */
|
|
106
|
+
CMD_RESTART = 1004,
|
|
107
|
+
/** Change machine state to "awaken". */
|
|
108
|
+
CMD_RESUME = 1007,
|
|
109
|
+
/** Set machine time. */
|
|
110
|
+
CMD_SET_TIME = 202,
|
|
111
|
+
/** Change machine state to "idle". */
|
|
112
|
+
CMD_SLEEP = 1006,
|
|
113
|
+
/** Download short message. */
|
|
114
|
+
CMD_SMS_RRQ = 71,
|
|
115
|
+
/** Upload short message. */
|
|
116
|
+
CMD_SMS_WRQ = 70,
|
|
117
|
+
/** Start enroll procedure. */
|
|
118
|
+
CMD_STARTENROLL = 61,
|
|
119
|
+
/** Set the machine to authentication state. */
|
|
120
|
+
CMD_STARTVERIFY = 60,
|
|
121
|
+
/** Query state. */
|
|
122
|
+
CMD_STATE_RRQ = 64,
|
|
123
|
+
/** Test if fingerprint exists. */
|
|
124
|
+
CMD_TEST_TEMP = 1011,
|
|
125
|
+
/** Test voice. */
|
|
126
|
+
CMD_TESTVOICE = 1017,
|
|
127
|
+
/** [0x77, 0x00] Transfer fp template from buffer. */
|
|
128
|
+
CMD_TMP_WRITE = 87,
|
|
129
|
+
/** Get device timezones. */
|
|
130
|
+
CMD_TZ_RRQ = 27,
|
|
131
|
+
/** Set device timezones. */
|
|
132
|
+
CMD_TZ_WRQ = 28,
|
|
133
|
+
/** Set user short message. */
|
|
134
|
+
CMD_UDATA_WRQ = 73,
|
|
135
|
+
/** Get group combination to unlock. */
|
|
136
|
+
CMD_ULG_RRQ = 29,
|
|
137
|
+
/** Set group combination to unlock. */
|
|
138
|
+
CMD_ULG_WRQ = 30,
|
|
139
|
+
/** Unlock door for a specified amount of time. */
|
|
140
|
+
CMD_UNLOCK = 31,
|
|
141
|
+
/** Upload user data. */
|
|
142
|
+
CMD_USER_WRQ = 8,
|
|
143
|
+
/** Read user group. */
|
|
144
|
+
CMD_USERGRP_RRQ = 21,
|
|
145
|
+
/** Set user group. */
|
|
146
|
+
CMD_USERGRP_WRQ = 22,
|
|
147
|
+
/** [0x09, 0x00] Read user fingerprint template. */
|
|
148
|
+
CMD_USERTEMP_RRQ = 9,
|
|
149
|
+
/** Upload user fingerprint template. */
|
|
150
|
+
CMD_USERTEMP_WRQ = 10,
|
|
151
|
+
/** Get user timezones. */
|
|
152
|
+
CMD_USERTZ_RRQ = 23,
|
|
153
|
+
/** Set the user timezones. */
|
|
154
|
+
CMD_USERTZ_WRQ = 24,
|
|
155
|
+
/** Read verification style of a given user. */
|
|
156
|
+
CMD_VERIFY_RRQ = 80,
|
|
157
|
+
/** Change verification style of a given user. */
|
|
158
|
+
CMD_VERIFY_WRQ = 79,
|
|
159
|
+
/** Prints chars to the device screen. */
|
|
160
|
+
CMD_WRITE_LCD = 66,
|
|
161
|
+
/** Write data to Mifare card. */
|
|
162
|
+
CMD_WRITE_MIFARE = 76,
|
|
163
|
+
/** Triggered alarm. */
|
|
164
|
+
EF_ALARM = 512,
|
|
165
|
+
/** Attendance entry. */
|
|
166
|
+
EF_ATTLOG = 1,
|
|
167
|
+
/** Pressed keyboard key. */
|
|
168
|
+
EF_BUTTON = 16,
|
|
169
|
+
/** Upload user data. */
|
|
170
|
+
EF_ENROLLFINGER = 8,
|
|
171
|
+
/** Enrolled user. */
|
|
172
|
+
EF_ENROLLUSER = 4,
|
|
173
|
+
/** Pressed finger. */
|
|
174
|
+
EF_FINGER = 2,
|
|
175
|
+
/** Fingerprint score in enroll procedure. */
|
|
176
|
+
EF_FPFTR = 256,
|
|
177
|
+
/** Restore access control to default. */
|
|
178
|
+
EF_UNLOCK = 32,
|
|
179
|
+
/** Registered user placed finger. */
|
|
94
180
|
EF_VERIFY = 128
|
|
95
181
|
}
|
|
182
|
+
export declare enum DISCOVERED_CMD {
|
|
183
|
+
/** Returned when the Finger id not exists in the user uid, when attempting to download single finger template */
|
|
184
|
+
FID_NOT_FOUND = 4993
|
|
185
|
+
}
|
|
96
186
|
export type CommandKeys = keyof typeof COMMANDS;
|
|
97
187
|
export type CommandValues = typeof COMMANDS[CommandKeys];
|
|
98
188
|
export declare enum Constants {
|
|
@@ -102,6 +192,8 @@ export declare enum Constants {
|
|
|
102
192
|
MACHINE_PREPARE_DATA_2 = 32130
|
|
103
193
|
}
|
|
104
194
|
interface RequestData {
|
|
195
|
+
/** Fixed buffer to start every TCP packet */
|
|
196
|
+
START_TAG: Buffer;
|
|
105
197
|
DISABLE_DEVICE: Buffer;
|
|
106
198
|
GET_REAL_TIME_EVENT: Buffer;
|
|
107
199
|
GET_ATTENDANCE_LOGS: Buffer;
|