ism-wifi 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +8 -4
  2. package/README.md +421 -24
  3. package/package.json +8 -3
package/CHANGELOG.md CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  ## 1.0.0 (2026-07-26)
4
4
 
5
- - Initial release
6
- - Interactive setup wizard
5
+ - Interactive setup wizard with hidden password input
7
6
  - Connectivity monitoring with configurable interval
8
7
  - Automatic login to IIT ISM Dhanbad captive portal
9
- - Exponential backoff retry logic
10
- - CLI commands: setup, config, login, reset, version, help
8
+ - Exponential backoff retry logic (1s → 2s → 4s → 8s → 16s → 30s)
9
+ - Graceful Ctrl+C shutdown
10
+ - Colorized terminal output with timestamps
11
11
  - Cross-platform support (Windows, Linux, macOS)
12
+ - CLI commands: `setup`, `config`, `login`, `reset`, `change-interval`, `version`, `help`
13
+ - 22 unit tests using Node.js built-in test framework
14
+ - Zero browser automation dependencies
15
+ - Published on npm
package/README.md CHANGED
@@ -1,66 +1,463 @@
1
- # ism-wifi
1
+ <p align="center">
2
+ <h1 align="center">ism-wifi</h1>
3
+ <p align="center">Auto-login to the IIT ISM Dhanbad captive Wi-Fi portal</p>
4
+ <p align="center">
5
+ <a href="https://www.npmjs.com/package/ism-wifi"><img src="https://img.shields.io/npm/v/ism-wifi" alt="npm version"></a>
6
+ <a href="https://www.npmjs.com/package/ism-wifi"><img src="https://img.shields.io/npm/l/ism-wifi" alt="license"></a>
7
+ <a href="https://www.npmjs.com/package/ism-wifi"><img src="https://img.shields.io/node/v/ism-wifi" alt="node version"></a>
8
+ <a href="https://www.npmjs.com/package/ism-wifi"><img src="https://img.shields.io/npm/dm/ism-wifi" alt="downloads"></a>
9
+ </p>
10
+ </p>
2
11
 
3
- Auto-login to the IIT ISM Dhanbad captive Wi-Fi portal.
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ - [Installation](#installation)
17
+ - [Quick Start](#quick-start)
18
+ - [CLI Commands](#cli-commands)
19
+ - [Configuration](#configuration)
20
+ - [How It Works](#how-it-works)
21
+ - [Project Architecture](#project-architecture)
22
+ - [Project Structure](#project-structure)
23
+ - [Exponential Backoff](#exponential-backoff)
24
+ - [Troubleshooting](#troubleshooting)
25
+ - [FAQ](#faq)
26
+ - [Contributing](#contributing)
27
+ - [License](#license)
28
+
29
+ ---
4
30
 
5
31
  ## Installation
6
32
 
33
+ **Prerequisites:** [Node.js](https://nodejs.org) 20+ and npm.
34
+
7
35
  ```bash
8
36
  npm install -g ism-wifi
9
37
  ```
10
38
 
11
- ## Usage
39
+ Verify it's installed:
40
+
41
+ ```bash
42
+ ism-wifi --version
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Quick Start
48
+
49
+ Run the tool:
12
50
 
13
51
  ```bash
14
52
  ism-wifi
15
53
  ```
16
54
 
17
- On first run you will be prompted for your credentials. The configuration is saved automatically. The tool monitors your internet connectivity and re-authenticates when the connection drops.
55
+ On first execution, you'll be guided through setup:
56
+
57
+ ```
58
+ ======================================
59
+ ISM WiFi Auto Login
60
+ ======================================
61
+
62
+ No configuration found.
63
+
64
+ Let's configure ISM WiFi.
65
+
66
+ Username: 24je0758
67
+ Password: ********
68
+ Connectivity check interval [30]:
69
+
70
+ Configuration saved.
71
+
72
+ Starting monitoring...
73
+
74
+ [15:31:11] ✓ Internet OK
75
+ ```
76
+
77
+ The tool runs in the terminal until you press **Ctrl+C**.
78
+
79
+ ---
18
80
 
19
81
  ## CLI Commands
20
82
 
21
83
  | Command | Description |
22
84
  |---------|-------------|
23
- | `ism-wifi` | Start monitoring |
24
- | `ism-wifi setup` | Re-run configuration setup |
85
+ | `ism-wifi` | Start monitoring (runs setup first if no config) |
86
+ | `ism-wifi setup` | Re-run interactive configuration |
25
87
  | `ism-wifi config` | Display current configuration |
26
- | `ism-wifi login` | Single login attempt |
88
+ | `ism-wifi login` | Perform a single login attempt and exit |
27
89
  | `ism-wifi reset` | Delete saved configuration |
28
90
  | `ism-wifi change-interval` | Change the connectivity check interval |
29
- | `ism-wifi version` | Print version |
30
- | `ism-wifi help` | Display usage |
91
+ | `ism-wifi version` | Print package version |
92
+ | `ism-wifi help` | Display usage information |
93
+
94
+ ### `ism-wifi`
95
+
96
+ Starts the monitoring loop. Checks internet connectivity every N seconds. If the connection drops, it attempts to log in to the captive portal automatically.
97
+
98
+ If no configuration exists, the interactive setup wizard runs first.
99
+
100
+ ### `ism-wifi setup`
101
+
102
+ Re-runs the interactive configuration wizard. Useful if your credentials change or you want to reconfigure the tool.
103
+
104
+ ```
105
+ Username:
106
+ Password:
107
+ Connectivity check interval [30]:
108
+ ```
109
+
110
+ ### `ism-wifi config`
111
+
112
+ Displays your current saved configuration. The password is masked for security.
113
+
114
+ ```
115
+ Username : 24je0758
116
+
117
+ Interval : 30 seconds
118
+
119
+ SSL Verify : false
120
+
121
+ Password : 2********
122
+ ```
123
+
124
+ ### `ism-wifi login`
125
+
126
+ Performs a single login attempt and exits. Useful for testing or scripting.
127
+
128
+ ### `ism-wifi reset`
129
+
130
+ Deletes the saved configuration. Asks for confirmation first.
131
+
132
+ ```
133
+ ? Are you sure you want to delete the saved configuration? (y/N)
134
+ ```
135
+
136
+ ### `ism-wifi change-interval`
137
+
138
+ Change the check interval interactively without re-entering credentials.
139
+
140
+ ```
141
+ New check interval in seconds (current: 30):
142
+ ```
143
+
144
+ ---
31
145
 
32
146
  ## Configuration
33
147
 
34
- Stored automatically at:
148
+ Configuration is stored automatically in your home directory. **No manual file editing required.**
149
+
150
+ | OS | Config path |
151
+ |----|------------|
152
+ | Windows | `C:\Users\<username>\.ism-wifi\config.json` |
153
+ | Linux | `~/.ism-wifi/config.json` |
154
+ | macOS | `~/.ism-wifi/config.json` |
35
155
 
36
- - **Windows:** `C:\Users\<username>\.ism-wifi\config.json`
37
- - **Linux/macOS:** `~/.ism-wifi/config.json`
156
+ Example `config.json`:
157
+
158
+ ```json
159
+ {
160
+ "username": "24je0758",
161
+ "password": "...",
162
+ "checkInterval": 30,
163
+ "verifySSL": false
164
+ }
165
+ ```
166
+
167
+ | Field | Type | Default | Description |
168
+ |-------|------|---------|-------------|
169
+ | `username` | string | — | Your IIT ISM network credential username |
170
+ | `password` | string | — | Your network password (stored in plain text) |
171
+ | `checkInterval` | number | `30` | Seconds between connectivity checks (max 30) |
172
+ | `verifySSL` | boolean | `false` | Whether to verify the portal SSL certificate |
173
+
174
+ ---
38
175
 
39
176
  ## How It Works
40
177
 
41
- 1. Every N seconds (default 30), the tool checks internet connectivity via `clients3.google.com/generate_204`
42
- 2. If connectivity is lost, it posts your credentials to the ISM captive portal
43
- 3. After a 3-second pause, it verifies the connection was restored
44
- 4. If login fails, it retries with exponential backoff (1s, 2s, 4s, 8s, 16s, 30s)
178
+ ### High-Level Flow
179
+
180
+ ```mermaid
181
+ flowchart TD
182
+ A[Start] --> B{Config exists?}
183
+ B -->|No| C[Run setup wizard]
184
+ C --> D[Save config]
185
+ B -->|Yes| D
186
+ D --> E[Start monitoring loop]
187
+ E --> F[Check internet]
188
+ F --> G{Internet OK?}
189
+ G -->|Yes| H[Sleep N seconds]
190
+ H --> E
191
+ G -->|No| I[Attempt login]
192
+ I --> J[Verify after 3s]
193
+ J --> K{Access granted?}
194
+ K -->|Yes| H
195
+ K -->|No| L[Wait with backoff]
196
+ L --> I
197
+ ```
198
+
199
+ ### Login Retry Flow
200
+
201
+ ```mermaid
202
+ flowchart LR
203
+ A[Login failed] --> B[Wait 1s]
204
+ B --> C[Retry login]
205
+ C --> D{Success?}
206
+ D -->|No| E[Wait 2s]
207
+ E --> F[Retry login]
208
+ F --> G{Success?}
209
+ G -->|No| H[Wait 4s]
210
+ H --> I[Retry login]
211
+ I --> J{Success?}
212
+ J -->|No| K[Wait 8s]
213
+ K --> L[Retry login]
214
+ L --> M{Success?}
215
+ M -->|No| N[Wait 16s]
216
+ N --> O[Retry login]
217
+ O --> P{Success?}
218
+ P -->|No| Q[Wait 30s]
219
+ Q --> R[Retry login]
220
+ R --> S{Success?}
221
+ S -->|No| T[Give up until next cycle]
222
+ D -->|Yes| U[✓ Internet restored]
223
+ G -->|Yes| U
224
+ J -->|Yes| U
225
+ M -->|Yes| U
226
+ P -->|Yes| U
227
+ S -->|Yes| U
228
+ ```
229
+
230
+ ### Connectivity Check
231
+
232
+ Every `checkInterval` seconds, the tool sends a `GET` request to:
233
+
234
+ ```
235
+ https://clients3.google.com/generate_204
236
+ ```
237
+
238
+ - **HTTP 204** → Internet is available ✓
239
+ - **Anything else** (timeout, redirect, DNS failure, SSL error, connection refused) → Internet unavailable ✗
240
+
241
+ The request has a **10-second timeout**. If no response is received within that time, connectivity is assumed lost.
242
+
243
+ ### Login
244
+
245
+ When connectivity is lost, the tool sends a `POST` request to the captive portal:
246
+
247
+ ```
248
+ POST https://netaccess.iitism.ac.in:6082/?url=
249
+
250
+ Content-Type: application/x-www-form-urlencoded
251
+
252
+ username=<username>&password=<password>
253
+ ```
254
+
255
+ After the login request, it **waits 3 seconds**, then performs another connectivity check. Only when `HTTP 204` is received is the login considered successful.
256
+
257
+ ---
258
+
259
+ ## Project Architecture
260
+
261
+ ```mermaid
262
+ flowchart TD
263
+ CLI[cli.js] --> CONFIG[config.js]
264
+ CLI --> MONITOR[monitor.js]
265
+ CLI --> LOGIN[login.js]
266
+ MONITOR --> CONN[connectivity.js]
267
+ MONITOR --> LOGIN
268
+ LOGIN --> CONN
269
+ CONFIG --> UTILS[utils.js]
270
+ LOGGER[logger.js] --> UTILS
271
+ MONITOR --> LOGGER
272
+ CLI --> LOGGER
273
+
274
+ subgraph Entry
275
+ BIN[bin/ism-wifi.js] --> CLI
276
+ end
277
+
278
+ subgraph Core
279
+ CONFIG
280
+ CONN
281
+ LOGIN
282
+ MONITOR
283
+ end
284
+
285
+ subgraph Shared
286
+ UTILS
287
+ LOGGER
288
+ CONST[constants.js]
289
+ end
290
+
291
+ CLI --> CONST
292
+ CONFIG --> CONST
293
+ CONN --> CONST
294
+ LOGIN --> CONST
295
+ MONITOR --> CONST
296
+ ```
297
+
298
+ | Module | Responsibility |
299
+ |--------|---------------|
300
+ | `bin/ism-wifi.js` | Entry point — calls `src/index.js` |
301
+ | `src/cli.js` | Commander setup, command routing |
302
+ | `src/config.js` | Load, save, delete config; interactive setup |
303
+ | `src/connectivity.js` | HTTP 204 check via native `fetch` |
304
+ | `src/login.js` | POST credentials to portal, verify |
305
+ | `src/monitor.js` | Main monitoring loop, retry logic |
306
+ | `src/logger.js` | Colored terminal output |
307
+ | `src/utils.js` | sleep, path helpers, formatting |
308
+ | `src/constants.js` | URLs, delays, messages |
309
+
310
+ ---
311
+
312
+ ## Project Structure
313
+
314
+ ```
315
+ ism-wifi/
316
+ ├── bin/
317
+ │ └── ism-wifi.js # CLI entry point
318
+ ├── src/
319
+ │ ├── cli.js # Command definitions and routing
320
+ │ ├── config.js # Configuration management
321
+ │ ├── connectivity.js # Internet connectivity checking
322
+ │ ├── login.js # Captive portal login
323
+ │ ├── monitor.js # Monitoring loop
324
+ │ ├── logger.js # Colored terminal output
325
+ │ ├── utils.js # Shared utilities
326
+ │ ├── constants.js # Shared constants
327
+ │ └── index.js # Public API
328
+ ├── test/
329
+ │ ├── cli.test.js # CLI command tests
330
+ │ ├── config.test.js # Config roundtrip tests
331
+ │ ├── connectivity.test.js # Connectivity check tests
332
+ │ ├── login.test.js # Login module tests
333
+ │ └── utils.test.js # Utility function tests
334
+ ├── package.json
335
+ ├── CHANGELOG.md
336
+ ├── LICENSE
337
+ ├── README.md
338
+ └── .gitignore
339
+ ```
340
+
341
+ ---
342
+
343
+ ## Exponential Backoff
344
+
345
+ When a login attempt fails, the tool retries with increasing delays:
346
+
347
+ ```
348
+ Attempt 1 → wait 1 second
349
+ Attempt 2 → wait 2 seconds
350
+ Attempt 3 → wait 4 seconds
351
+ Attempt 4 → wait 8 seconds
352
+ Attempt 5 → wait 16 seconds
353
+ Attempt 6+ → wait 30 seconds (capped)
354
+ ```
355
+
356
+ This prevents hammering the portal while still recovering quickly from transient failures. If all retries fail, the tool returns to the main monitoring loop and tries again on the next interval.
357
+
358
+ ---
45
359
 
46
360
  ## Troubleshooting
47
361
 
48
- **Login keeps failing:** Run `ism-wifi setup` to re-enter your credentials.
362
+ ### Login keeps failing
363
+
364
+ Run `ism-wifi setup` to re-enter your credentials. Ensure your username and password match what you use on the IIT ISM network portal.
365
+
366
+ ### SSL / certificate errors
367
+
368
+ The tool disables SSL certificate verification for the captive portal by default (`verifySSL: false`). This is because the portal often uses self-signed certificates. You can enable verification by editing `~/.ism-wifi/config.json` and setting `"verifySSL": true`.
369
+
370
+ ### Network not detected
49
371
 
50
- **SSL errors:** The tool disables SSL verification by default for the captive portal endpoint.
372
+ The tool checks connectivity by requesting `https://clients3.google.com/generate_204`. If this URL is blocked or redirected by your network (other than the captive portal), the tool may incorrectly report no internet. You can test this URL manually in your browser.
373
+
374
+ ### "No configuration found" after setup
375
+
376
+ Ensure the config file was saved correctly. Check `~/.ism-wifi/config.json` exists and contains valid JSON.
377
+
378
+ ### Permission denied (Linux/macOS)
379
+
380
+ If you installed globally with `npm install -g`, you might need `sudo` on some systems:
381
+
382
+ ```bash
383
+ sudo npm install -g ism-wifi
384
+ ```
385
+
386
+ Alternatively, [configure npm for global installs without sudo](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally).
387
+
388
+ ---
51
389
 
52
390
  ## FAQ
53
391
 
54
- **Q: Does this run in the background?**
55
- A: No, it runs in the terminal until you press Ctrl+C.
392
+ **Q: Does this run in the background?**
393
+ A: No. It runs in the terminal and stays active until you press **Ctrl+C**.
56
394
 
57
- **Q: Is my password stored securely?**
58
- A: It is stored in plain text in your home directory. Use OS-level disk encryption for security.
395
+ **Q: Is my password stored securely?**
396
+ A: It is stored in plain text in `~/.ism-wifi/config.json`. Use OS-level disk encryption (BitLocker, FileVault, LUKS) to protect your home directory.
397
+
398
+ **Q: Does it work on macOS?**
399
+ A: Yes. The tool is tested on Windows, Linux, and macOS.
400
+
401
+ **Q: Can I change the check interval without re-entering my password?**
402
+ A: Yes. Use `ism-wifi change-interval` to update just the interval.
403
+
404
+ **Q: What happens if the internet goes down while I'm away?**
405
+ A: The tool automatically detects the outage, logs in when connectivity is partially restored, and resumes monitoring.
406
+
407
+ **Q: How do I stop the tool?**
408
+ A: Press **Ctrl+C**. You'll see:
409
+
410
+ ```
411
+ Stopping ISM WiFi...
412
+
413
+ Goodbye!
414
+ ```
415
+
416
+ **Q: Do I need to run this on startup?**
417
+ A: Not required. Run it manually when you need it, or set it up as a startup command in your terminal profile.
418
+
419
+ ---
59
420
 
60
421
  ## Contributing
61
422
 
62
- Contributions welcome. Please open an issue or PR.
423
+ Contributions are welcome!
424
+
425
+ ### Setup
426
+
427
+ ```bash
428
+ git clone <your-fork>
429
+ cd ism-wifi
430
+ npm install
431
+ ```
432
+
433
+ ### Running tests
434
+
435
+ ```bash
436
+ npm test
437
+ ```
438
+
439
+ Tests use Node's built-in `node:test` framework — no external test runner needed.
440
+
441
+ ### Guidelines
442
+
443
+ - ES Modules only (`import`/`export`)
444
+ - Async/await throughout
445
+ - JSDoc comments on all exported functions
446
+ - Small focused functions
447
+ - No global mutable state
448
+ - Cross-platform compatible
449
+ - Run `npm test` before submitting
450
+
451
+ ### Pull requests
452
+
453
+ 1. Fork the repo
454
+ 2. Create a feature branch
455
+ 3. Make your changes
456
+ 4. Run tests
457
+ 5. Submit a PR with a clear description
458
+
459
+ ---
63
460
 
64
461
  ## License
65
462
 
66
- MIT
463
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "ism-wifi",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Auto-login to IIT ISM Dhanbad captive Wi-Fi portal",
5
5
  "type": "module",
6
6
  "bin": {
7
- "ism-wifi": "./bin/ism-wifi.js"
7
+ "ism-wifi": "bin/ism-wifi.js"
8
8
  },
9
9
  "files": [
10
10
  "bin/",
@@ -18,7 +18,12 @@
18
18
  "test": "node --test",
19
19
  "start": "node bin/ism-wifi.js"
20
20
  },
21
- "keywords": ["iit-ism", "wifi", "captive-portal", "cli"],
21
+ "keywords": [
22
+ "iit-ism",
23
+ "wifi",
24
+ "captive-portal",
25
+ "cli"
26
+ ],
22
27
  "license": "MIT",
23
28
  "dependencies": {
24
29
  "@inquirer/prompts": "^7.0.0",