zklib-ts 1.0.6 → 1.0.7

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.
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Represents an Attendance Records
3
+ */
1
4
  export declare class Attendance {
2
5
  /** Internal serial number for the user */
3
6
  sn: number;
@@ -4,6 +4,7 @@
4
4
  export declare class Finger {
5
5
  uid: number;
6
6
  fid: number;
7
+ /** Flag indicating 0 = invalid | 1 = valid | 3 = duress. if is not initilizaed, default is 1 = valid */
7
8
  valid: number;
8
9
  template: Buffer;
9
10
  size: number;
@@ -15,7 +16,7 @@ export declare class Finger {
15
16
  * @param valid Flag indicating 0 = invalid | 1 = valid | 3 = duress
16
17
  * @param template Fingerprint template data buffer
17
18
  */
18
- constructor(uid: number, fid: number, valid: number, template: Buffer);
19
+ constructor(uid: number, fid: number, template: Buffer, valid?: number);
19
20
  /**
20
21
  * Packs the fingerprint data with metadata into a Buffer
21
22
  * @returns Buffer containing packed fingerprint data
@@ -0,0 +1,49 @@
1
+ import { ZTCP } from "../ztcp";
2
+ export declare class OptionsService {
3
+ _zkTcp: ZTCP;
4
+ constructor(zkTcp: ZTCP);
5
+ /** Ask if the device doesn't support alphanumeric symbols for user id values. */
6
+ isAbcPinEnable(): Promise<string>;
7
+ /** Ask if the device doesn't support alphanumeric symbols for user id values. */
8
+ isT9FunOn(): Promise<string>;
9
+ getDeviceId(): Promise<any>;
10
+ /**
11
+ * Change Device ID
12
+ * @param id a number between 1 and 254
13
+ */
14
+ setDeviceId(id: number): Promise<boolean>;
15
+ getVendor(): Promise<any>;
16
+ getProductTime(): Promise<Date>;
17
+ getMacAddress(): Promise<string>;
18
+ getNetworkParams(): Promise<{
19
+ IPAddress: string;
20
+ NetMask: string;
21
+ GATEIPAddress: string;
22
+ TCPPort: string;
23
+ }>;
24
+ getSerialNumber(): Promise<string>;
25
+ /**
26
+ * get Zkteko Template version
27
+ * @returns number
28
+ */
29
+ getDeviceVersion(): Promise<string>;
30
+ /**
31
+ * get Device/Model Name
32
+ * @returns
33
+ */
34
+ getDeviceName(): Promise<any>;
35
+ getPlatform(): Promise<any>;
36
+ getOS(): Promise<string>;
37
+ getWorkCode(): Promise<string>;
38
+ /**
39
+ * get User ID max length
40
+ * @returns
41
+ */
42
+ getPIN(): Promise<string>;
43
+ getFaceOn(): Promise<"No" | "Yes">;
44
+ getSSR(): Promise<string>;
45
+ getFirmware(): Promise<string>;
46
+ getTime(): Promise<Date>;
47
+ setTime(tm: Date | string): Promise<boolean>;
48
+ voiceTest(): Promise<void>;
49
+ }
@@ -1,4 +1,4 @@
1
- import { ZTCP } from "../ztcp";
1
+ import { ZTCP } from '../ztcp';
2
2
  export declare class TransactionService {
3
3
  _zkTcp: ZTCP;
4
4
  constructor(zkTcp: ZTCP);
@@ -7,12 +7,12 @@ export declare class UserService {
7
7
  constructor(zkTcp: ZTCP);
8
8
  getUserByUserId(user_id: string): Promise<User>;
9
9
  getUsers(): Promise<{
10
- data: any[];
10
+ data: User[];
11
11
  }>;
12
12
  setUser(user_id: string, name: string, password: string, role?: number, cardno?: number): Promise<boolean>;
13
13
  DeleteUser(user_id: string): Promise<boolean>;
14
- getTemplates(callbackInProcess?: any): Promise<Record<string, Finger[]>>;
15
- DownloadFp(user_id: string, fid: number): Promise<Buffer>;
14
+ getTemplates(cb?: Function): Promise<Record<string, Finger[]>>;
15
+ DownloadFp(user_id: string, fid: number): Promise<Finger>;
16
16
  /**
17
17
  *
18
18
  * @param user_id {string} user
@@ -20,7 +20,7 @@ export declare class UserService {
20
20
  * */
21
21
  saveTemplates(user_id: string, fingers?: Finger[]): Promise<void>;
22
22
  deleteFinger(user_id?: string, fid?: number): Promise<boolean>;
23
- enrollInfo(user_id: string, tempId: number): Promise<boolean>;
23
+ enrollInfo(user_id: string, tempId: number): Promise<unknown>;
24
24
  verify(user_id: string): Promise<boolean>;
25
25
  /**
26
26
  * Upload a single fingerprint for a given user id
package/dist/ztcp.d.ts CHANGED
@@ -1,16 +1,18 @@
1
- import { Socket } from 'net';
2
- import { RealTimeLog } from './helper/utils';
3
- import { Finger } from './models/Finger';
1
+ import { Socket } from "net";
2
+ import { RealTimeLog } from "./helper/utils";
3
+ import { Finger } from "./models/Finger";
4
4
  import { UserService } from "./services/user.service";
5
5
  import { TransactionService } from "./services/transaction.service";
6
+ import { OptionsService } from "./services/options.service";
6
7
  export declare class ZTCP {
8
+ #private;
7
9
  /**
8
- * @param_ip ip address of device
9
- * @param_port port number of device
10
- * @param_timeout connection timout
11
- * @param_comm_key communication key of device (if the case)
12
- * @return Zkteco TCP socket connection instance
13
- */
10
+ * @param_ip ip address of device
11
+ * @param_port port number of device
12
+ * @param_timeout connection timout
13
+ * @param_comm_key communication key of device (if the case)
14
+ * @return Zkteco TCP socket connection instance
15
+ */
14
16
  ip: string;
15
17
  private port;
16
18
  timeout: number;
@@ -35,13 +37,14 @@ export declare class ZTCP {
35
37
  verbose: boolean;
36
38
  private packetNumber;
37
39
  private replyData;
38
- _userService: UserService;
40
+ _optionsService: OptionsService;
39
41
  _transactionService: TransactionService;
42
+ _userService: UserService;
40
43
  constructor(ip: string, port: number, timeout: number, comm_key: number, verbose: boolean);
41
- createSocket(cbError: any, cbClose: any): Promise<unknown>;
44
+ createSocket(cbError: (err: Error) => void, cbClose: (type: string) => void): Promise<unknown>;
42
45
  connect(): Promise<boolean>;
43
46
  closeSocket(): Promise<boolean>;
44
- writeMessage(msg: Buffer, connect: boolean): Promise<Buffer>;
47
+ writeMessage(msg: Buffer, connect: boolean, cb: (data: Buffer) => any): Promise<Buffer>;
45
48
  requestData(msg: Buffer): Promise<Buffer>;
46
49
  /**
47
50
  *
@@ -61,16 +64,13 @@ export declare class ZTCP {
61
64
  * readWithBuffer will reject error if it'wrong when starting request data
62
65
  * readWithBuffer will return { data: replyData , err: Error } when receiving requested data
63
66
  */
64
- readWithBuffer(reqData: Buffer | string, cb?: Function): Promise<Record<string, Buffer | number>>;
67
+ readWithBuffer(reqData: Buffer | string, cb?: (received: number, total: number) => void): Promise<Record<string, Buffer | number | Error>>;
65
68
  /**
66
69
  *
67
70
  * @param {*} callbackInProcess
68
71
  * reject error when starting request data
69
72
  * return { data: records, err: Error } when receiving requested data
70
73
  */
71
- getAttendances(callbackInProcess?: any): Promise<{
72
- data: any[];
73
- }>;
74
74
  freeData(): Promise<boolean>;
75
75
  disableDevice(): Promise<boolean>;
76
76
  enableDevice(): Promise<boolean>;
@@ -96,27 +96,6 @@ export declare class ZTCP {
96
96
  faceCount: number;
97
97
  faceCapacity: number;
98
98
  }>;
99
- getVendor(): Promise<string>;
100
- getProductTime(): Promise<Date>;
101
- getMacAddress(): Promise<string>;
102
- getNetworkParams(): Promise<{
103
- IPAddress: string;
104
- NetMask: string;
105
- GATEIPAddress: string;
106
- }>;
107
- getSerialNumber(): Promise<string>;
108
- getDeviceVersion(): Promise<string>;
109
- getDeviceName(): Promise<string>;
110
- getPlatform(): Promise<string>;
111
- getOS(): Promise<string>;
112
- getWorkCode(): Promise<string>;
113
- getPIN(): Promise<string>;
114
- getFaceOn(): Promise<"No" | "Yes">;
115
- getSSR(): Promise<string>;
116
- getFirmware(): Promise<string>;
117
- getTime(): Promise<Date>;
118
- setTime(tm: Date | string): Promise<boolean>;
119
- voiceTest(): Promise<void>;
120
99
  getAttendanceSize(): Promise<number>;
121
100
  clearAttendanceLog(): Promise<boolean>;
122
101
  /**
package/dist/zudp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RecordData16, UserData28 } from './helper/utils';
2
- import * as dgram from "node:dgram";
2
+ import * as dgram from 'node:dgram';
3
3
  interface DeviceInfo {
4
4
  userCounts: number;
5
5
  logCounts: number;
package/package.json CHANGED
@@ -1,69 +1,70 @@
1
- {
2
- "name": "zklib-ts",
3
- "version": "1.0.6",
4
- "description": "Unofficial zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices",
5
- "main": "dist/index.cjs.js",
6
- "module": "dist/index.es.js",
7
- "typings": "dist/index",
8
- "types": "dist/index.d.ts",
9
- "type": "commonjs",
10
- "files": [
11
- "dist/",
12
- "README.md"
13
- ],
14
- "scripts": {
15
- "test": "jest",
16
- "build": "rollup -c",
17
- "watch": "rollup -c --watch",
18
- "prepare": "npm run build"
19
- },
20
- "repositoryUrl": "https://github.com/guspaz0/zklib-ts.git",
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/guspaz0/zklib-ts.git"
24
- },
25
- "keywords": [
26
- "typescript",
27
- "javascript",
28
- "jest",
29
- "ip",
30
- "libs",
31
- "device",
32
- "zkteco",
33
- "address",
34
- "realtime",
35
- "real-time",
36
- "biometric",
37
- "attendance",
38
- "biometric attendance",
39
- "biometric attendance device"
40
- ],
41
- "author": "Gustavo Paz",
42
- "license": "MIT",
43
- "directories": {
44
- "test": "tests"
45
- },
46
- "devDependencies": {
47
- "@rollup/plugin-commonjs": "^28.0.3",
48
- "@rollup/plugin-node-resolve": "^16.0.1",
49
- "@rollup/plugin-typescript": "^12.1.2",
50
- "@types/jest": "^29.5.14",
51
- "@types/node": "^22.13.14",
52
- "dotenv": "^16.4.7",
53
- "jest": "30.2.0",
54
- "rollup": "^4.37.0",
55
- "rollup-plugin-peer-deps-external": "^2.2.4",
56
- "ts-jest": "29.4.6",
57
- "ts-node": "^10.9.2",
58
- "tslib": "^2.8.1",
59
- "typescript": "^5.8.2"
60
- },
61
- "config": {
62
- "commitizen": {
63
- "path": "./node_modules/cz-conventional-changelog"
64
- }
65
- },
66
- "precommit": [
67
- "build"
68
- ]
69
- }
1
+ {
2
+ "name": "zklib-ts",
3
+ "version": "1.0.7",
4
+ "description": "Unofficial zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.es.js",
7
+ "typings": "dist/index",
8
+ "types": "dist/index.d.ts",
9
+ "type": "commonjs",
10
+ "files": [
11
+ "dist/",
12
+ "README.md"
13
+ ],
14
+ "repositoryUrl": "https://github.com/guspaz0/zklib-ts.git",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/guspaz0/zklib-ts.git"
18
+ },
19
+ "keywords": [
20
+ "typescript",
21
+ "javascript",
22
+ "jest",
23
+ "ip",
24
+ "libs",
25
+ "device",
26
+ "zkteco",
27
+ "address",
28
+ "realtime",
29
+ "real-time",
30
+ "biometric",
31
+ "attendance",
32
+ "biometric attendance",
33
+ "biometric attendance device"
34
+ ],
35
+ "author": "Gustavo Paz",
36
+ "license": "MIT",
37
+ "directories": {
38
+ "test": "tests"
39
+ },
40
+ "devDependencies": {
41
+ "@rollup/plugin-commonjs": "^28.0.3",
42
+ "@rollup/plugin-node-resolve": "^16.0.1",
43
+ "@rollup/plugin-typescript": "^12.1.2",
44
+ "@types/jest": "^29.5.14",
45
+ "@types/mocha": "^10.0.10",
46
+ "@types/node": "^22.19.17",
47
+ "dotenv": "^16.4.7",
48
+ "jest": "30.2.0",
49
+ "rollup": "^4.37.0",
50
+ "rollup-plugin-peer-deps-external": "^2.2.4",
51
+ "ts-jest": "29.4.6",
52
+ "ts-node": "^10.9.2",
53
+ "tslib": "^2.8.1",
54
+ "typescript": "^5.8.2"
55
+ },
56
+ "config": {
57
+ "commitizen": {
58
+ "path": "./node_modules/cz-conventional-changelog"
59
+ }
60
+ },
61
+ "precommit": [
62
+ "build"
63
+ ],
64
+ "scripts": {
65
+ "test": "jest",
66
+ "build": "rollup -c",
67
+ "watch": "rollup -c --watch",
68
+ "lint": "eslint ."
69
+ }
70
+ }