@apocaliss92/nodelink-js 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 apocaliss92
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 all
13
+ 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 THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,445 @@
1
+ # @apocaliss92/nodelink-js
2
+
3
+ A TypeScript library for interacting with Reolink IP cameras and NVRs using the proprietary Baichuan protocol and CGI API.
4
+
5
+ ## Credits
6
+
7
+ This library is inspired by and based on the reverse engineering work done by:
8
+
9
+ - **[neolink](https://github.com/thirtythreeforty/neolink)** - Rust implementation of Baichuan protocol
10
+ - **[reolink_aio](https://github.com/starkillerOG/reolink_aio)** - Python async library for Reolink cameras
11
+
12
+ ## Features
13
+
14
+ - 🔌 **Baichuan Native Protocol** - Direct binary protocol for low-level camera control
15
+ - 🌐 **CGI HTTP API** - RESTful API for camera configuration and management
16
+ - 📺 **RTSP Server** - Stream camera feeds via standard RTSP protocol
17
+ - 📡 **RFC 4571 Server** - Low-latency TCP streaming for home automation integrations
18
+ - 🎤 **Two-way Audio (Intercom)** - Full duplex audio communication
19
+ - 📹 **Video Clips & Recordings** - Download and manage recorded footage
20
+ - 🔍 **Device Discovery** - Automatic camera detection via UDP broadcast
21
+ - 🎯 **PTZ Control** - Pan, Tilt, Zoom, and Preset management
22
+ - 🔔 **Motion & AI Events** - Real-time event notifications and subscriptions
23
+ - 📷 **Multifocal Support** - Composite streams for dual-lens cameras (TrackMix, Duo)
24
+
25
+ ---
26
+
27
+ ## 📚 Full API Documentation
28
+
29
+ For detailed method-by-method documentation, see the [documentation](./documentation/) folder:
30
+
31
+ ### Baichuan Protocol API
32
+
33
+ | Section | Description |
34
+ | ---------------------------------------------------------- | ----------------------------------------------- |
35
+ | [**Overview**](./documentation/baichuan-api/README.md) | API overview and quick start |
36
+ | [Connection](./documentation/baichuan-api/connection.md) | Login, logout, ping, reboot, dedicated sessions |
37
+ | [Device Info](./documentation/baichuan-api/device-info.md) | Device information, channels, capabilities |
38
+ | [Streaming](./documentation/baichuan-api/streaming.md) | Live video streams, codec configuration |
39
+ | [Recordings](./documentation/baichuan-api/recordings.md) | Search, download, replay recorded clips |
40
+ | [PTZ Control](./documentation/baichuan-api/ptz.md) | Pan, tilt, zoom, presets |
41
+ | [Events](./documentation/baichuan-api/events.md) | Motion, AI, doorbell event subscriptions |
42
+ | [Intercom](./documentation/baichuan-api/intercom.md) | Two-way audio, talk sessions |
43
+ | [Snapshots](./documentation/baichuan-api/snapshots.md) | Capture images, thumbnails |
44
+ | [Detection](./documentation/baichuan-api/detection.md) | Motion, AI, PIR, autotracking settings |
45
+ | [Lights](./documentation/baichuan-api/lights.md) | Spotlight, floodlight, siren control |
46
+ | [Battery](./documentation/baichuan-api/battery.md) | Battery status, sleep/wake management |
47
+ | [OSD](./documentation/baichuan-api/osd.md) | On-screen display configuration |
48
+ | [Network](./documentation/baichuan-api/network.md) | Network, WiFi, storage, system settings |
49
+
50
+ ### CGI HTTP API
51
+
52
+ | Section | Description |
53
+ | ---------------------------------------------------------- | ----------------------------------- |
54
+ | [**CGI API Reference**](./documentation/cgi-api/README.md) | Complete HTTP/CGI API documentation |
55
+
56
+ ### Additional Features
57
+
58
+ | Section | Description |
59
+ | ------------------------------------------------- | ------------------------------------- |
60
+ | [Streaming Servers](./documentation/streaming.md) | RTSP, RFC4571, HTTP streaming servers |
61
+ | [Network Discovery](./documentation/discovery.md) | Automatic camera discovery via UDP |
62
+
63
+ ---
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ npm install @apocaliss92/nodelink-js
69
+ ```
70
+
71
+ ## Quick Start
72
+
73
+ ### Baichuan Native API
74
+
75
+ The Baichuan API provides direct access to camera functions through the proprietary binary protocol:
76
+
77
+ ```typescript
78
+ import { ReolinkBaichuanApi } from "@apocaliss92/nodelink-js";
79
+
80
+ const api = new ReolinkBaichuanApi({
81
+ host: "192.168.1.100",
82
+ port: 9000, // Baichuan port
83
+ username: "admin",
84
+ password: "your-password",
85
+ });
86
+
87
+ await api.login();
88
+
89
+ // Get device info
90
+ const deviceInfo = await api.getDeviceInfo();
91
+ console.log("Camera:", deviceInfo.name, deviceInfo.model);
92
+
93
+ // Get stream info
94
+ const streamInfo = await api.getStreamInfoList();
95
+
96
+ // Subscribe to events
97
+ api.onMotionAlarm((event) => {
98
+ console.log("Motion detected:", event);
99
+ });
100
+
101
+ await api.close();
102
+ ```
103
+
104
+ 📖 **[View full Baichuan API documentation →](./documentation/baichuan-api/README.md)**
105
+
106
+ ### CGI HTTP API
107
+
108
+ The CGI API provides HTTP-based access for configuration and management:
109
+
110
+ ```typescript
111
+ import { ReolinkCgiApi } from "@apocaliss92/nodelink-js";
112
+
113
+ const cgi = new ReolinkCgiApi({
114
+ host: "192.168.1.100",
115
+ port: 80, // HTTP port
116
+ username: "admin",
117
+ password: "your-password",
118
+ });
119
+
120
+ // Get device info
121
+ const info = await cgi.getDevInfo();
122
+
123
+ // Get recording files
124
+ const recordings = await cgi.searchRecordings({
125
+ startTime: new Date("2024-01-01"),
126
+ endTime: new Date("2024-01-02"),
127
+ channel: 0,
128
+ });
129
+
130
+ // Get encoding settings
131
+ const enc = await cgi.getEnc(0);
132
+ ```
133
+
134
+ 📖 **[View full CGI API documentation →](./documentation/cgi-api/README.md)**
135
+
136
+ ## Streaming
137
+
138
+ ### RTSP Server
139
+
140
+ Create a local RTSP server that restreams camera feeds:
141
+
142
+ ```typescript
143
+ import {
144
+ BaichuanRtspServer,
145
+ ReolinkBaichuanApi,
146
+ } from "@apocaliss92/nodelink-js";
147
+
148
+ const api = new ReolinkBaichuanApi({
149
+ host: "192.168.1.100",
150
+ port: 9000,
151
+ username: "admin",
152
+ password: "your-password",
153
+ });
154
+
155
+ const rtspServer = new BaichuanRtspServer({
156
+ api,
157
+ profile: "main", // main, sub, or ext
158
+ channel: 0,
159
+ port: 8554,
160
+ logger: console,
161
+ });
162
+
163
+ await rtspServer.start();
164
+ // Stream available at rtsp://localhost:8554/stream
165
+ ```
166
+
167
+ ### RFC 4571 Server
168
+
169
+ Low-latency TCP streaming optimized for home automation systems like Scrypted:
170
+
171
+ ```typescript
172
+ import {
173
+ createRfc4571TcpServer,
174
+ ReolinkBaichuanApi,
175
+ } from "@apocaliss92/nodelink-js";
176
+
177
+ const api = new ReolinkBaichuanApi({
178
+ host: "192.168.1.100",
179
+ port: 9000,
180
+ username: "admin",
181
+ password: "your-password",
182
+ });
183
+
184
+ const server = await createRfc4571TcpServer({
185
+ api,
186
+ profile: "main",
187
+ channel: 0,
188
+ host: "0.0.0.0",
189
+ logger: console,
190
+ username: "admin",
191
+ password: "your-password",
192
+ });
193
+
194
+ // Connect your home automation system to the server
195
+ ```
196
+
197
+ ## Two-Way Audio (Intercom)
198
+
199
+ Send and receive audio for intercom functionality:
200
+
201
+ ```typescript
202
+ import { ReolinkBaichuanApi } from "@apocaliss92/nodelink-js";
203
+
204
+ const api = new ReolinkBaichuanApi({
205
+ host: "192.168.1.100",
206
+ port: 9000,
207
+ username: "admin",
208
+ password: "your-password",
209
+ });
210
+
211
+ await api.login();
212
+
213
+ // Start talk session
214
+ await api.startTalk();
215
+
216
+ // Send audio data (raw PCM or G.711)
217
+ await api.sendTalkAudio(audioBuffer);
218
+
219
+ // Stop talk session
220
+ await api.stopTalk();
221
+ ```
222
+
223
+ ## Video Clips & Recordings
224
+
225
+ Download and manage recorded video clips:
226
+
227
+ ```typescript
228
+ import { ReolinkBaichuanApi } from "@apocaliss92/nodelink-js";
229
+
230
+ const api = new ReolinkBaichuanApi({
231
+ host: "192.168.1.100",
232
+ port: 9000,
233
+ username: "admin",
234
+ password: "your-password",
235
+ });
236
+
237
+ await api.login();
238
+
239
+ // Search recordings by date
240
+ const recordings = await api.searchRecordings({
241
+ channel: 0,
242
+ startTime: new Date("2024-01-01"),
243
+ endTime: new Date("2024-01-02"),
244
+ });
245
+
246
+ // Download a recording
247
+ const stream = await api.downloadRecording(recordings[0].filename);
248
+
249
+ // Pipe to file
250
+ import { createWriteStream } from "node:fs";
251
+ stream.pipe(createWriteStream("recording.mp4"));
252
+ ```
253
+
254
+ ## Device Discovery
255
+
256
+ Automatically discover cameras on your network:
257
+
258
+ ```typescript
259
+ import { AutodiscoveryClient } from "@apocaliss92/nodelink-js";
260
+
261
+ const discovery = new AutodiscoveryClient();
262
+
263
+ discovery.on("device", (device) => {
264
+ console.log("Found camera:", device.ip, device.name, device.uid);
265
+ });
266
+
267
+ await discovery.startDiscovery();
268
+
269
+ // Stop after 10 seconds
270
+ setTimeout(() => {
271
+ discovery.stopDiscovery();
272
+ }, 10000);
273
+ ```
274
+
275
+ ## PTZ Control
276
+
277
+ Control Pan-Tilt-Zoom cameras:
278
+
279
+ ```typescript
280
+ import { ReolinkBaichuanApi } from "@apocaliss92/nodelink-js";
281
+
282
+ const api = new ReolinkBaichuanApi({
283
+ host: "192.168.1.100",
284
+ port: 9000,
285
+ username: "admin",
286
+ password: "your-password",
287
+ });
288
+
289
+ await api.login();
290
+
291
+ // Move camera
292
+ await api.ptzControl({ channel: 0, command: "Right", speed: 32 });
293
+ await api.ptzControl({ channel: 0, command: "Stop" });
294
+
295
+ // Go to preset
296
+ await api.ptzGotoPreset({ channel: 0, preset: 1 });
297
+
298
+ // Get current position
299
+ const position = await api.getPtzPosition(0);
300
+
301
+ // Zoom control
302
+ await api.setZoomFocus({ channel: 0, zoom: { pos: 100 } });
303
+ ```
304
+
305
+ ## Events & Notifications
306
+
307
+ Subscribe to real-time camera events:
308
+
309
+ ```typescript
310
+ import { ReolinkBaichuanApi } from "@apocaliss92/nodelink-js";
311
+
312
+ const api = new ReolinkBaichuanApi({
313
+ host: "192.168.1.100",
314
+ port: 9000,
315
+ username: "admin",
316
+ password: "your-password",
317
+ });
318
+
319
+ await api.login();
320
+
321
+ // Subscribe to motion events
322
+ api.onMotionAlarm((event) => {
323
+ console.log("Motion:", event.state, "at channel", event.channel);
324
+ });
325
+
326
+ // Subscribe to AI events (person, vehicle, pet, etc.)
327
+ api.onAiAlarm((event) => {
328
+ console.log("AI detection:", event.type, event.state);
329
+ });
330
+
331
+ // Subscribe to doorbell events
332
+ api.onVisitor((event) => {
333
+ console.log("Visitor detected");
334
+ });
335
+ ```
336
+
337
+ ## NVR & Multi-Channel Support
338
+
339
+ Work with NVRs and their connected channels:
340
+
341
+ ```typescript
342
+ import { ReolinkBaichuanApi } from "@apocaliss92/nodelink-js";
343
+
344
+ const api = new ReolinkBaichuanApi({
345
+ host: "192.168.1.100",
346
+ port: 9000,
347
+ username: "admin",
348
+ password: "your-password",
349
+ });
350
+
351
+ await api.login();
352
+
353
+ // Get all channels info
354
+ const channels = await api.getChannelInfoAll();
355
+
356
+ // Stream from a specific channel
357
+ const rtspServer = new BaichuanRtspServer({
358
+ api,
359
+ profile: "main",
360
+ channel: 2, // Channel index
361
+ port: 8554,
362
+ logger: console,
363
+ });
364
+ ```
365
+
366
+ ## Configuration
367
+
368
+ ### Environment Variables
369
+
370
+ Create a `.env` file based on `env.template`:
371
+
372
+ ```env
373
+ CAMERA_HOST=192.168.1.100
374
+ CAMERA_PORT=9000
375
+ CAMERA_USERNAME=admin
376
+ CAMERA_PASSWORD=your-password
377
+ ```
378
+
379
+ ### Logging
380
+
381
+ The library supports custom loggers:
382
+
383
+ ```typescript
384
+ import {
385
+ ReolinkBaichuanApi,
386
+ createLogger,
387
+ } from "@apocaliss92/nodelink-js";
388
+
389
+ const logger = createLogger({ level: "debug" });
390
+
391
+ const api = new ReolinkBaichuanApi({
392
+ host: "192.168.1.100",
393
+ port: 9000,
394
+ username: "admin",
395
+ password: "your-password",
396
+ logger,
397
+ });
398
+ ```
399
+
400
+ ## CLI Tools
401
+
402
+ ### RTSP Server
403
+
404
+ Run a standalone RTSP server:
405
+
406
+ ```bash
407
+ npm run rtsp-server
408
+ ```
409
+
410
+ Configure via environment variables:
411
+
412
+ - `CAMERA_HOST` - Camera IP address
413
+ - `CAMERA_PORT` - Baichuan port (default: 9000)
414
+ - `CAMERA_USERNAME` - Username
415
+ - `CAMERA_PASSWORD` - Password
416
+ - `RTSP_PORT` - RTSP server port (default: 8554)
417
+
418
+ ## Supported Devices
419
+
420
+ This library has been tested with:
421
+
422
+ - Reolink IP cameras (RLC series, E1 series, Argus series)
423
+ - Reolink NVRs (RLN series)
424
+ - Reolink Home Hub
425
+ - Reolink TrackMix and Duo (multifocal cameras)
426
+ - Reolink battery cameras (Argus, TrackMix WiFi Battery)
427
+
428
+ ## API Reference
429
+
430
+ 📖 **Full API documentation available in the [documentation](./documentation/) folder.**
431
+
432
+ - [Baichuan Protocol API](./documentation/baichuan-api/README.md) - Binary protocol (port 9000)
433
+ - [CGI HTTP API](./documentation/cgi-api/README.md) - HTTP REST API (port 80)
434
+ - [Streaming Servers](./documentation/streaming.md) - RTSP, RFC4571, HTTP servers
435
+ - [Network Discovery](./documentation/discovery.md) - UDP autodiscovery
436
+
437
+ ## Disclaimer
438
+
439
+ This project is **not affiliated with, endorsed by, or connected to Reolink** in any way.
440
+
441
+ "Reolink" is a trademark of Reolink Innovation Inc.
442
+
443
+ This is an independent, community-driven open-source project created for **interoperability purposes** — enabling users to integrate their own Reolink devices with third-party home automation systems and custom applications.
444
+
445
+ No proprietary code, firmware, or copyrighted materials from Reolink are included in this project. The protocol implementation is based on publicly available reverse engineering efforts from the community.
@@ -0,0 +1,25 @@
1
+ import {
2
+ collectCgiDiagnostics,
3
+ collectMultifocalDiagnostics,
4
+ collectNativeDiagnostics,
5
+ collectNvrDiagnostics,
6
+ createDiagnosticsBundle,
7
+ printNvrDiagnostics,
8
+ runAllDiagnosticsConsecutively,
9
+ runMultifocalDiagnosticsConsecutively,
10
+ sampleStreams,
11
+ testChannelStreams
12
+ } from "./chunk-MC2BRLLE.js";
13
+ export {
14
+ collectCgiDiagnostics,
15
+ collectMultifocalDiagnostics,
16
+ collectNativeDiagnostics,
17
+ collectNvrDiagnostics,
18
+ createDiagnosticsBundle,
19
+ printNvrDiagnostics,
20
+ runAllDiagnosticsConsecutively,
21
+ runMultifocalDiagnosticsConsecutively,
22
+ sampleStreams,
23
+ testChannelStreams
24
+ };
25
+ //# sourceMappingURL=DiagnosticsTools-MTXG65O3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}