open-vtop 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ashman Singh
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,72 @@
1
+ # Open-VTOP
2
+
3
+ An open-source VTOP client with automatic session management.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Automatic Session Initialization**: VTOP session cookies and CSRF tokens are automatically established when the server starts
8
+ - 🔄 **Background Processing**: Session setup happens in the background, no need to hit any endpoints first
9
+ - 📊 **Session Monitoring**: Check session status in real-time via the web interface
10
+
11
+ ## Getting Started
12
+
13
+ ### Installation
14
+
15
+ ```bash
16
+ npm install
17
+ ```
18
+
19
+ ### Development
20
+
21
+ ```bash
22
+ npm run dev
23
+ ```
24
+
25
+ Then open http://localhost:3000
26
+
27
+ ### Production
28
+
29
+ ```bash
30
+ npm run build
31
+ npm start
32
+ ```
33
+
34
+ ## How It Works
35
+
36
+ When the server starts, it automatically:
37
+
38
+ 1. **Establishes cookies** - Gets `SERVERID` and `JSESSIONID` cookies from VTOP
39
+ 2. **Retrieves CSRF token** - Extracts the `_csrf` token from `/vtop/openPage`
40
+ 3. **Completes prelogin setup** - POSTs to `/vtop/prelogin/setup` with flag=VTOP
41
+ 4. **Maintains session state** - Stores cookies and tokens for subsequent requests
42
+
43
+ All of this happens in the background using Node.js's native fetch API.
44
+
45
+ ## API Endpoints
46
+
47
+ - `GET /api/session/status` - View current session status (cookies, CSRF, etc.)
48
+ - `POST /api/session/refresh` - Manually refresh the VTOP session
49
+
50
+ ## Session Manager
51
+
52
+ The session manager (`src/session-manager.ts`) is a singleton that:
53
+ - Initializes automatically on server startup
54
+ - Stores cookies and CSRF tokens
55
+ - Can be imported and used by other modules
56
+ - Supports manual refresh when needed
57
+
58
+ ```typescript
59
+ import { sessionManager } from "./session-manager.js";
60
+
61
+ // Check if initialized
62
+ const isReady = sessionManager.isInitialized();
63
+
64
+ // Get CSRF token
65
+ const csrf = sessionManager.getCsrf();
66
+
67
+ // Get cookies as header string
68
+ const cookies = sessionManager.getCookies();
69
+
70
+ // Manually refresh
71
+ await sessionManager.refresh();
72
+ ```