tciv-client 0.0.2 → 0.0.4

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 CHANGED
@@ -28,6 +28,7 @@ This library is intended for **system integrators and IT administrators** managi
28
28
  - [Call Button (DAK)](#call-button-dak-configuration)
29
29
  - [Provisioning](#full-device-provisioning)
30
30
  - [Video](#video)
31
+ - [Factory Reset](#factory-reset)
31
32
  - [Reboot](#device-reboot)
32
33
  - [API](#api)
33
34
  - [Connectivity](#connectivity)
@@ -42,6 +43,7 @@ This library is intended for **system integrators and IT administrators** managi
42
43
  - [Provisioning](#full-device-provisioning-1)
43
44
  - [Audio Settings](#audio-settings)
44
45
  - [Reboot](#reboot)
46
+ - [Factory Reset](#factory-reset-1)
45
47
  - [Device Discovery](#scannetwork)
46
48
  - [Supported Hardware](#supported-hardware)
47
49
  - [HTTP API Reference](#http-api-reference)
@@ -225,6 +227,19 @@ tciv provision -h 192.168.1.143 \
225
227
  tciv reboot -h 192.168.1.143
226
228
  ```
227
229
 
230
+ ### Factory Reset
231
+
232
+ ```bash
233
+ # Full reset (IP → 169.254.1.100)
234
+ tciv factory-reset -h 192.168.1.143
235
+
236
+ # Reset but keep current IP settings (recommended)
237
+ tciv factory-reset -h 192.168.1.143 --keep-ip
238
+
239
+ # Reset with DHCP enabled
240
+ tciv factory-reset -h 192.168.1.143 --dhcp
241
+ ```
242
+
228
243
  ### CLI Options
229
244
 
230
245
  | Flag | Short | Description | Default |
@@ -244,6 +259,8 @@ tciv reboot -h 192.168.1.143
244
259
  | `--no-reboot` | | Skip reboot after DAK set | |
245
260
  | `--sip-user` | | SIP auth username (provision) | |
246
261
  | `--sip-pass` | | SIP auth password (provision) | |
262
+ | `--keep-ip` | | Factory reset: keep IP settings | |
263
+ | `--dhcp` | | Factory reset: enable DHCP | |
247
264
 
248
265
  ---
249
266
 
@@ -398,6 +415,25 @@ fs.writeFileSync('audio-backup.json', JSON.stringify(raw, null, 2));
398
415
  await z.reboot(); // ~30 seconds offline
399
416
  ```
400
417
 
418
+ #### Factory Reset
419
+
420
+ ```typescript
421
+ // Full reset (static IP 169.254.1.100)
422
+ await z.factoryReset('full');
423
+
424
+ // Reset but keep current IP (recommended)
425
+ await z.factoryReset('keep-ip');
426
+
427
+ // Reset with DHCP
428
+ await z.factoryReset('dhcp');
429
+ ```
430
+
431
+ | Mode | Behavior |
432
+ |------|----------|
433
+ | `full` | All defaults, IP → 169.254.1.100 |
434
+ | `dhcp` | All defaults, DHCP enabled |
435
+ | `keep-ip` | All defaults, current IP preserved |
436
+
401
437
  ---
402
438
 
403
439
  ### `scanNetwork()`
@@ -440,6 +476,7 @@ All endpoints require valid administrator credentials via HTTP Basic Auth.
440
476
  | `/goform/zForm_config_backup` | POST | Config restore (upload) |
441
477
  | `/ipst_config.tar.gz` | GET | Config backup download |
442
478
  | `/goform/zForm_system_prefs` | POST | Reboot device |
479
+ | `/goform/zForm_send_cmd` | POST | Factory reset (full/DHCP/keep-ip) |
443
480
  | `/mjpg/video.mjpg` | GET | Live MJPG stream |
444
481
 
445
482
  ## License
package/dist/cli.js CHANGED
@@ -222,6 +222,15 @@ async function main() {
222
222
  console.log('✅ Reboot command sent. Device will be offline for ~30 seconds.');
223
223
  break;
224
224
  }
225
+ case 'factory-reset': {
226
+ const client = getClient();
227
+ const mode = hasFlag('keep-ip') ? 'keep-ip' : hasFlag('dhcp') ? 'dhcp' : 'full';
228
+ const labels = { 'full': 'full (IP → 169.254.1.100)', 'dhcp': 'full + DHCP', 'keep-ip': 'keep IP settings' };
229
+ console.log(`⚠️ Factory reset (${labels[mode]}) — all settings will be lost!`);
230
+ await client.factoryReset(mode);
231
+ console.log('✅ Factory reset sent. Device will reboot with default settings.');
232
+ break;
233
+ }
225
234
  case 'video': {
226
235
  const client = getClient();
227
236
  console.log(`📷 Video URLs for ${flag('host', 'h')}:\n`);
package/dist/client.d.ts CHANGED
@@ -7,13 +7,13 @@
7
7
  * Auth: HTTP Basic Auth (admin/alphaadmin by default).
8
8
  * All goform endpoints use POST with form-urlencoded bodies.
9
9
  */
10
- import type { ZenitelClientOptions, DeviceInfo, RelayOptions, RelayStatus, CallStatus, SIPConfig, ProvisionConfig, AudioSettings } from './types.js';
10
+ import type { TcivClientOptions, DeviceInfo, RelayOptions, RelayStatus, CallStatus, SIPConfig, ProvisionConfig, AudioSettings } from './types.js';
11
11
  export declare class TcivClient {
12
12
  private opts;
13
13
  private readonly baseUrl;
14
14
  private readonly authHeader;
15
15
  private readonly timeout;
16
- constructor(opts: ZenitelClientOptions);
16
+ constructor(opts: TcivClientOptions);
17
17
  /** Check if the Zenitel is reachable */
18
18
  isReachable(): Promise<boolean>;
19
19
  /** Scrape station info + header for full device data */
@@ -126,8 +126,17 @@ export declare class TcivClient {
126
126
  private _replaceFileInTar;
127
127
  /** Recalculate tar header checksum (sum of all header bytes with checksum field as spaces) */
128
128
  private _updateTarChecksum;
129
- /** Reboot the Zenitel (required after config changes) */
129
+ /** Reboot the device (required after config changes) */
130
130
  reboot(): Promise<void>;
131
+ /**
132
+ * Factory reset — restores all settings to defaults. Device will reboot.
133
+ *
134
+ * @param mode - Reset mode:
135
+ * - 'full' → Static IP 169.254.1.100 (default)
136
+ * - 'dhcp' → Factory defaults + DHCP enabled
137
+ * - 'keep-ip' → Factory defaults but keep current IP settings
138
+ */
139
+ factoryReset(mode?: 'full' | 'dhcp' | 'keep-ip'): Promise<void>;
131
140
  private _fetch;
132
141
  private _html;
133
142
  private _post;
package/dist/client.js CHANGED
@@ -642,7 +642,7 @@ export class TcivClient {
642
642
  Buffer.from(checksumStr).copy(header, 148);
643
643
  }
644
644
  // ── Reboot ─────────────────────────────────────────────────────────────
645
- /** Reboot the Zenitel (required after config changes) */
645
+ /** Reboot the device (required after config changes) */
646
646
  async reboot() {
647
647
  try {
648
648
  await this._post('/goform/zForm_system_prefs', { reboot: 'Reboot' });
@@ -651,6 +651,28 @@ export class TcivClient {
651
651
  // May disconnect before response — that's expected
652
652
  }
653
653
  }
654
+ /**
655
+ * Factory reset — restores all settings to defaults. Device will reboot.
656
+ *
657
+ * @param mode - Reset mode:
658
+ * - 'full' → Static IP 169.254.1.100 (default)
659
+ * - 'dhcp' → Factory defaults + DHCP enabled
660
+ * - 'keep-ip' → Factory defaults but keep current IP settings
661
+ */
662
+ async factoryReset(mode = 'full') {
663
+ const params = {
664
+ 'full': 'factory_reset',
665
+ 'dhcp': 'factory_reset_dhcp',
666
+ 'keep-ip': 'factory_reset_keep_ip_settings',
667
+ };
668
+ const name = params[mode];
669
+ try {
670
+ await this._post('/goform/zForm_send_cmd', { [name]: '1' });
671
+ }
672
+ catch {
673
+ // Device disconnects during reset — expected
674
+ }
675
+ }
654
676
  // ── Internal helpers ────────────────────────────────────────────────────
655
677
  async _fetch(path, method = 'GET', timeout, body, contentType) {
656
678
  const controller = new AbortController();
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { TcivClient } from './client.js';
2
- export { TcivClient as ZenitelClient } from './client.js';
3
2
  export { scanNetwork } from './scanner.js';
4
- export type { ZenitelClientOptions as TcivClientOptions, ZenitelClientOptions, ZenitelDevice, ScanOptions, DeviceInfo, RelayOptions, RelayStatus, CallStatus, SIPConfig, ProvisionConfig, AudioSettings, AudioOutputDevice, AudioInputDevice, AECSettings, ANCSettings, FESSSettings, DRCSettings, AVCSettings, } from './types.js';
3
+ export type { TcivClientOptions, TcivDevice, ScanOptions, DeviceInfo, RelayOptions, RelayStatus, CallStatus, SIPConfig, ProvisionConfig, AudioSettings, AudioOutputDevice, AudioInputDevice, AECSettings, ANCSettings, FESSSettings, DRCSettings, AVCSettings, } from './types.js';
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export { TcivClient } from './client.js';
2
- export { TcivClient as ZenitelClient } from './client.js';
3
2
  export { scanNetwork } from './scanner.js';
package/dist/scanner.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  *
7
7
  * Both strategies run in parallel and results are merged by IP.
8
8
  */
9
- import type { ZenitelDevice, ScanOptions } from './types.js';
10
- export declare function scanNetwork(opts?: ScanOptions): Promise<ZenitelDevice[]>;
9
+ import type { TcivDevice, ScanOptions } from './types.js';
10
+ export declare function scanNetwork(opts?: ScanOptions): Promise<TcivDevice[]>;
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * All interfaces for the Zenitel HTTP scraper, scanner, and CLI.
5
5
  */
6
- export interface ZenitelClientOptions {
6
+ export interface TcivClientOptions {
7
7
  /** IP or hostname of the Zenitel intercom (e.g. "192.168.1.143") */
8
8
  host: string;
9
9
  /** Web UI username. Default: "admin" */
@@ -15,7 +15,7 @@ export interface ZenitelClientOptions {
15
15
  /** HTTP request timeout in ms. Default: 5000 */
16
16
  timeout?: number;
17
17
  }
18
- export interface ZenitelDevice {
18
+ export interface TcivDevice {
19
19
  ip: string;
20
20
  mac: string;
21
21
  model?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tciv-client",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "HTTP client for TCIV-series intercom systems (TCIV-2+, TCIV-3). Control relays, SIP configuration, DAK provisioning, webcall, audio settings, and camera feeds.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",