@samlab-corp/sfm-node 0.1.0
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 +21 -0
- package/README.md +479 -0
- package/dist/commands/data.d.ts +29 -0
- package/dist/commands/data.d.ts.map +1 -0
- package/dist/commands/data.js +176 -0
- package/dist/commands/data.js.map +1 -0
- package/dist/commands/fingerprint.d.ts +132 -0
- package/dist/commands/fingerprint.d.ts.map +1 -0
- package/dist/commands/fingerprint.js +580 -0
- package/dist/commands/fingerprint.js.map +1 -0
- package/dist/commands/firmware.d.ts +37 -0
- package/dist/commands/firmware.d.ts.map +1 -0
- package/dist/commands/firmware.js +152 -0
- package/dist/commands/firmware.js.map +1 -0
- package/dist/commands/freescan.d.ts +68 -0
- package/dist/commands/freescan.d.ts.map +1 -0
- package/dist/commands/freescan.js +202 -0
- package/dist/commands/freescan.js.map +1 -0
- package/dist/commands/index.d.ts +88 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +104 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/system.d.ts +82 -0
- package/dist/commands/system.d.ts.map +1 -0
- package/dist/commands/system.js +191 -0
- package/dist/commands/system.js.map +1 -0
- package/dist/constants/crypto.d.ts +11 -0
- package/dist/constants/crypto.d.ts.map +1 -0
- package/dist/constants/crypto.js +10 -0
- package/dist/constants/crypto.js.map +1 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +4 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/packet.d.ts +17 -0
- package/dist/constants/packet.d.ts.map +1 -0
- package/dist/constants/packet.js +17 -0
- package/dist/constants/packet.js.map +1 -0
- package/dist/constants/protocol.d.ts +653 -0
- package/dist/constants/protocol.d.ts.map +1 -0
- package/dist/constants/protocol.js +422 -0
- package/dist/constants/protocol.js.map +1 -0
- package/dist/core/client.d.ts +118 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +320 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/crypto.d.ts +86 -0
- package/dist/core/crypto.d.ts.map +1 -0
- package/dist/core/crypto.js +248 -0
- package/dist/core/crypto.js.map +1 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +66 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/packet.d.ts +126 -0
- package/dist/core/packet.d.ts.map +1 -0
- package/dist/core/packet.js +267 -0
- package/dist/core/packet.js.map +1 -0
- package/dist/core/serial.d.ts +123 -0
- package/dist/core/serial.d.ts.map +1 -0
- package/dist/core/serial.js +421 -0
- package/dist/core/serial.js.map +1 -0
- package/dist/core/tcp.d.ts +58 -0
- package/dist/core/tcp.d.ts.map +1 -0
- package/dist/core/tcp.js +219 -0
- package/dist/core/tcp.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/core/tcp.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SFM TCP/IP Communication Module
|
|
3
|
+
*
|
|
4
|
+
* Transmits the same packet protocol as serial port over TCP socket.
|
|
5
|
+
* Provides the same interface as SfmSerial (open, close, read, write)
|
|
6
|
+
* for transparent substitution in SfmClient.
|
|
7
|
+
*
|
|
8
|
+
* Decompilation analysis:
|
|
9
|
+
* - "TCP Port" @ 14004f280: TCP port configuration string
|
|
10
|
+
* - Protocol packet structure is identical to serial (13/15/35 bytes)
|
|
11
|
+
*/
|
|
12
|
+
import net from 'node:net';
|
|
13
|
+
const DEFAULT_PORT = 9870;
|
|
14
|
+
const READ_TIMEOUT_MS = 3000;
|
|
15
|
+
const CONNECT_TIMEOUT_MS = 5000;
|
|
16
|
+
export class SfmTcp {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this.socket = null;
|
|
19
|
+
this.host = options.host || '127.0.0.1';
|
|
20
|
+
this.port = options.port || DEFAULT_PORT;
|
|
21
|
+
this.isOpen = false;
|
|
22
|
+
this._readBuffer = Buffer.alloc(0);
|
|
23
|
+
this._readResolve = null;
|
|
24
|
+
this._readReject = null;
|
|
25
|
+
this._readTimer = null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Open TCP connection
|
|
29
|
+
*/
|
|
30
|
+
async open(hostOrPath) {
|
|
31
|
+
if (this.isOpen) {
|
|
32
|
+
await this.close();
|
|
33
|
+
}
|
|
34
|
+
// Support host:port format
|
|
35
|
+
if (hostOrPath) {
|
|
36
|
+
const parts = hostOrPath.split(':');
|
|
37
|
+
this.host = parts[0];
|
|
38
|
+
if (parts[1]) {
|
|
39
|
+
const parsed = parseInt(parts[1], 10);
|
|
40
|
+
if (isNaN(parsed) || parsed < 1 || parsed > 65535) {
|
|
41
|
+
throw new Error(`Invalid TCP port: "${parts[1]}"`);
|
|
42
|
+
}
|
|
43
|
+
this.port = parsed;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
this.socket = new net.Socket();
|
|
48
|
+
const connectTimer = setTimeout(() => {
|
|
49
|
+
this.socket?.destroy();
|
|
50
|
+
reject(new Error(`TCP connection timeout (${CONNECT_TIMEOUT_MS}ms): ${this.host}:${this.port}`));
|
|
51
|
+
}, CONNECT_TIMEOUT_MS);
|
|
52
|
+
this.socket.on('data', (data) => {
|
|
53
|
+
this._readBuffer = Buffer.concat([this._readBuffer, data]);
|
|
54
|
+
if (this._readResolve) {
|
|
55
|
+
this._resolveRead();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this.socket.on('error', (err) => {
|
|
59
|
+
clearTimeout(connectTimer);
|
|
60
|
+
if (!this.isOpen) {
|
|
61
|
+
reject(new Error(`TCP connection failed: ${err.message}`));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (this._readReject) {
|
|
65
|
+
this._readReject(err);
|
|
66
|
+
this._readResolve = null;
|
|
67
|
+
this._readReject = null;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
this.socket.on('close', () => {
|
|
71
|
+
this.isOpen = false;
|
|
72
|
+
if (this._readReject) {
|
|
73
|
+
this._readReject(new Error('TCP connection closed'));
|
|
74
|
+
this._readResolve = null;
|
|
75
|
+
this._readReject = null;
|
|
76
|
+
}
|
|
77
|
+
if (this._readTimer) {
|
|
78
|
+
clearTimeout(this._readTimer);
|
|
79
|
+
this._readTimer = null;
|
|
80
|
+
}
|
|
81
|
+
this._readBuffer = Buffer.alloc(0);
|
|
82
|
+
});
|
|
83
|
+
this.socket.connect(this.port, this.host, () => {
|
|
84
|
+
clearTimeout(connectTimer);
|
|
85
|
+
this.isOpen = true;
|
|
86
|
+
resolve();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Close TCP connection
|
|
92
|
+
*/
|
|
93
|
+
async close() {
|
|
94
|
+
if (!this.isOpen || !this.socket)
|
|
95
|
+
return;
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
this.socket.end(() => {
|
|
98
|
+
this.isOpen = false;
|
|
99
|
+
this._readBuffer = Buffer.alloc(0);
|
|
100
|
+
resolve();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Write data (TCP doesn't need chunking, but interface-compatible)
|
|
106
|
+
*/
|
|
107
|
+
async write(data) {
|
|
108
|
+
if (!this.isOpen)
|
|
109
|
+
throw new Error('TCP connection is not open');
|
|
110
|
+
const buf = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
this.socket.write(buf, (err) => {
|
|
113
|
+
if (err)
|
|
114
|
+
return reject(err);
|
|
115
|
+
resolve();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Read data (same interface as SfmSerial.read)
|
|
121
|
+
*/
|
|
122
|
+
async read(expectedLength, timeoutMs = READ_TIMEOUT_MS) {
|
|
123
|
+
if (!this.isOpen)
|
|
124
|
+
throw new Error('TCP connection is not open');
|
|
125
|
+
if (this._readBuffer.length >= expectedLength) {
|
|
126
|
+
const result = this._readBuffer.subarray(0, expectedLength);
|
|
127
|
+
this._readBuffer = this._readBuffer.subarray(expectedLength);
|
|
128
|
+
return Buffer.from(result);
|
|
129
|
+
}
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
let settled = false;
|
|
132
|
+
const cleanup = () => {
|
|
133
|
+
if (this._readTimer)
|
|
134
|
+
clearTimeout(this._readTimer);
|
|
135
|
+
this._readTimer = null;
|
|
136
|
+
this._readResolve = null;
|
|
137
|
+
this._readReject = null;
|
|
138
|
+
};
|
|
139
|
+
this._readResolve = () => {
|
|
140
|
+
if (settled)
|
|
141
|
+
return;
|
|
142
|
+
if (this._readBuffer.length >= expectedLength) {
|
|
143
|
+
settled = true;
|
|
144
|
+
cleanup();
|
|
145
|
+
const result = this._readBuffer.subarray(0, expectedLength);
|
|
146
|
+
this._readBuffer = this._readBuffer.subarray(expectedLength);
|
|
147
|
+
resolve(Buffer.from(result));
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
this._readReject = (err) => {
|
|
151
|
+
if (settled)
|
|
152
|
+
return;
|
|
153
|
+
settled = true;
|
|
154
|
+
cleanup();
|
|
155
|
+
reject(err);
|
|
156
|
+
};
|
|
157
|
+
this._readTimer = setTimeout(() => {
|
|
158
|
+
if (settled)
|
|
159
|
+
return;
|
|
160
|
+
settled = true;
|
|
161
|
+
const available = Buffer.from(this._readBuffer);
|
|
162
|
+
this._readBuffer = Buffer.alloc(0);
|
|
163
|
+
cleanup();
|
|
164
|
+
if (available.length > 0) {
|
|
165
|
+
resolve(available);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
reject(new Error(`TCP read timeout (${timeoutMs}ms)`));
|
|
169
|
+
}
|
|
170
|
+
}, timeoutMs);
|
|
171
|
+
this._readResolve();
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Read single byte
|
|
176
|
+
*/
|
|
177
|
+
async readByte(timeoutMs = READ_TIMEOUT_MS) {
|
|
178
|
+
const buf = await this.read(1, timeoutMs);
|
|
179
|
+
return buf[0];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Read until specific string
|
|
183
|
+
*/
|
|
184
|
+
async readUntil(marker, timeoutMs = 5000) {
|
|
185
|
+
const startTime = Date.now();
|
|
186
|
+
let accumulated = '';
|
|
187
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
188
|
+
try {
|
|
189
|
+
const byte = await this.readByte(100);
|
|
190
|
+
accumulated += String.fromCharCode(byte);
|
|
191
|
+
if (accumulated.includes(marker)) {
|
|
192
|
+
return accumulated;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// timeout on single byte, continue
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw new Error(`Marker wait timeout: "${marker}" (${timeoutMs}ms)`);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Clear RX buffer
|
|
203
|
+
*/
|
|
204
|
+
async purgeRX() {
|
|
205
|
+
this._readBuffer = Buffer.alloc(0);
|
|
206
|
+
}
|
|
207
|
+
async purgeTX() {
|
|
208
|
+
// TCP doesn't need separate TX purge
|
|
209
|
+
}
|
|
210
|
+
async purgeAll() {
|
|
211
|
+
await this.purgeRX();
|
|
212
|
+
}
|
|
213
|
+
_resolveRead() {
|
|
214
|
+
if (this._readResolve) {
|
|
215
|
+
this._readResolve();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+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QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,MAAM,SAAS,KAAK,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,qCAAqC;IACvC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAEO,YAAY;QAClB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sfm-node - SFM Protocol Manual V3.6.0 기반 지문인식 라이브러리
|
|
3
|
+
*
|
|
4
|
+
* 사용법:
|
|
5
|
+
* import { SfmCommands } from './sfm-node';
|
|
6
|
+
*
|
|
7
|
+
* const finger = new SfmCommands({ baudRate: 115200 });
|
|
8
|
+
* await finger.connect('/dev/ttyUSB0');
|
|
9
|
+
* await finger.fingerprint.enroll(1);
|
|
10
|
+
* await finger.disconnect();
|
|
11
|
+
*/
|
|
12
|
+
export { SfmCommands } from './commands';
|
|
13
|
+
export type { SfmClientOptions } from './core';
|
|
14
|
+
export type { SerialPortInfo } from './core';
|
|
15
|
+
export type { EncryptionMode } from './constants';
|
|
16
|
+
export { ENCRYPTION_MODE } from './constants';
|
|
17
|
+
export { SFM_ERROR } from './constants';
|
|
18
|
+
export type { EnrollResult, CommandResult, IdentifyResult, VerifyResult, ListUserIdsResult, CaptureImageResult, SystemStatusResult, ParamResult, SelfTestResult, FirmwareOptions, FreeScanResult, FreeScanCallback, } from './commands';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,YAAY,EACV,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EACzD,iBAAiB,EAAE,kBAAkB,EACrC,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAC/C,eAAe,EACf,cAAc,EAAE,gBAAgB,GACjC,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sfm-node - SFM Protocol Manual V3.6.0 기반 지문인식 라이브러리
|
|
3
|
+
*
|
|
4
|
+
* 사용법:
|
|
5
|
+
* import { SfmCommands } from './sfm-node';
|
|
6
|
+
*
|
|
7
|
+
* const finger = new SfmCommands({ baudRate: 115200 });
|
|
8
|
+
* await finger.connect('/dev/ttyUSB0');
|
|
9
|
+
* await finger.fingerprint.enroll(1);
|
|
10
|
+
* await finger.disconnect();
|
|
11
|
+
*/
|
|
12
|
+
// 공개 API
|
|
13
|
+
export { SfmCommands } from './commands';
|
|
14
|
+
export { ENCRYPTION_MODE } from './constants';
|
|
15
|
+
export { SFM_ERROR } from './constants';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,SAAS;AACT,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@samlab-corp/sfm-node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SFM Protocol V3.6.0 based fingerprint recognition library for Node.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"sfm",
|
|
21
|
+
"fingerprint",
|
|
22
|
+
"suprema",
|
|
23
|
+
"biometric",
|
|
24
|
+
"serial",
|
|
25
|
+
"serialport",
|
|
26
|
+
"node"
|
|
27
|
+
],
|
|
28
|
+
"author": "Samlab Corp",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/Samlab-Corp/samlab-lib.git",
|
|
33
|
+
"directory": "packages/sfm-node"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/Samlab-Corp/samlab-lib/tree/main/packages/sfm-node",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/Samlab-Corp/samlab-lib/issues"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"serialport": "^13.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^25.2.3",
|
|
47
|
+
"typescript": "^5.9.3"
|
|
48
|
+
}
|
|
49
|
+
}
|