vaultfs 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaultfs",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A CLI-based secure file system simulator with OAuth 2.0 authentication and advanced data structures",
5
5
  "bin": {
6
6
  "vaultfs": "bin/vaultfs-npm.js"
@@ -8,7 +8,6 @@ import com.sun.net.httpserver.HttpHandler;
8
8
 
9
9
  import com.sun.net.httpserver.HttpServer;
10
10
 
11
- import java.awt.Desktop;
12
11
  import java.io.BufferedReader;
13
12
  import java.io.File;
14
13
  import java.io.FileReader;
@@ -16,7 +15,6 @@ import java.io.FileWriter;
16
15
  import java.io.IOException;
17
16
  import java.io.OutputStream;
18
17
  import java.net.InetSocketAddress;
19
- import java.net.URI;
20
18
  import java.net.URLDecoder;
21
19
  import java.nio.file.Files;
22
20
  import java.util.UUID;
@@ -129,25 +127,6 @@ public class AuthManager {
129
127
 
130
128
 
131
129
 
132
- System.out.println(Colors.c(Colors.WHITE, "Opening browser for authentication..."));
133
-
134
- System.out.println(Colors.c(Colors.GRAY, "→ " + authURL));
135
-
136
-
137
-
138
- if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
139
- Desktop.getDesktop().browse(new URI(authURL));
140
- } else {
141
- System.out.println(Colors.c(Colors.YELLOW, "Could not open browser automatically."));
142
- System.out.println(Colors.c(Colors.WHITE, "Please open this URL manually: ") + authURL);
143
- }
144
-
145
-
146
-
147
- System.out.println(Colors.c(Colors.GRAY, "Waiting for authentication... (timeout: 120s)"));
148
-
149
-
150
-
151
130
  final CountDownLatch loginLatch = new CountDownLatch(1);
152
131
  final HttpServer server = HttpServer.create(new InetSocketAddress(9000), 0);
153
132
 
@@ -322,10 +301,41 @@ public class AuthManager {
322
301
  server.setExecutor(null);
323
302
  server.start();
324
303
 
325
- boolean completed = loginLatch.await(120, TimeUnit.SECONDS);
304
+ // Print styled login URL box
305
+ System.out.println();
306
+ System.out.println(Colors.c(Colors.CYAN, " ╔══════════════════════════════════════════╗"));
307
+ System.out.println(Colors.c(Colors.CYAN, " ║ VaultFS — Login Required ║"));
308
+ System.out.println(Colors.c(Colors.CYAN, " ║ ║"));
309
+ System.out.println(Colors.c(Colors.CYAN, " ║ Opening browser at: ║"));
310
+ System.out.println(Colors.c(Colors.CYAN, " ║ http://localhost:9000 ║"));
311
+ System.out.println(Colors.c(Colors.CYAN, " ║ ║"));
312
+ System.out.println(Colors.c(Colors.CYAN, " ║ If browser doesn't open, visit the ║"));
313
+ System.out.println(Colors.c(Colors.CYAN, " ║ URL above manually. ║"));
314
+ System.out.println(Colors.c(Colors.CYAN, " ╚══════════════════════════════════════════╝"));
315
+ System.out.println();
316
+
317
+ // Open browser (cross-platform)
318
+ openBrowser(authURL);
319
+
320
+ // Wait up to 120 seconds with periodic progress
321
+ System.out.println(Colors.c(Colors.GRAY, "\uD83D\uDD10 Waiting for login... (120s timeout)"));
322
+ System.out.println(Colors.c(Colors.GRAY, "\uD83D\uDC49 If browser didn't open, visit: http://localhost:9000"));
323
+ System.out.println();
324
+
325
+ boolean completed = false;
326
+ for (int waited = 0; waited < 120; waited++) {
327
+ if (loginLatch.await(1, TimeUnit.SECONDS)) {
328
+ completed = true;
329
+ break;
330
+ }
331
+ if ((waited + 1) % 10 == 0) {
332
+ System.out.println(Colors.c(Colors.GRAY, " Still waiting... (" + (120 - waited - 1) + "s remaining)"));
333
+ }
334
+ }
326
335
 
327
336
  if (!completed && !isLoggedIn()) {
328
- System.out.println(Colors.c(Colors.RED, "Login timeout. Please try again."));
337
+ System.out.println(Colors.c(Colors.YELLOW, "\u26A0\uFE0F Login timed out. Continuing as Guest."));
338
+ persistLogin(UUID.randomUUID().toString(), "guest@local", "Guest");
329
339
  server.stop(0);
330
340
  }
331
341
 
@@ -337,6 +347,36 @@ public class AuthManager {
337
347
 
338
348
  }
339
349
 
350
+ /** Opens a URL in the default browser using platform-specific commands. */
351
+ private static void openBrowser(String url) {
352
+ String os = System.getProperty("os.name").toLowerCase();
353
+ Runtime rt = Runtime.getRuntime();
354
+ try {
355
+ if (os.contains("win")) {
356
+ rt.exec(new String[]{"rundll32", "url.dll,FileProtocolHandler", url});
357
+ } else if (os.contains("mac")) {
358
+ rt.exec(new String[]{"open", url});
359
+ } else {
360
+ // Linux/WSL
361
+ String[] browsers = {"xdg-open", "firefox", "google-chrome", "chromium-browser"};
362
+ boolean opened = false;
363
+ for (String browser : browsers) {
364
+ try {
365
+ rt.exec(new String[]{browser, url});
366
+ opened = true;
367
+ break;
368
+ } catch (Exception ignored) {}
369
+ }
370
+ if (!opened) {
371
+ System.out.println("Please open this URL manually: " + url);
372
+ }
373
+ }
374
+ } catch (Exception e) {
375
+ System.out.println("Could not open browser automatically.");
376
+ System.out.println("Please open this URL manually: " + url);
377
+ }
378
+ }
379
+
340
380
 
341
381
 
342
382
  /** Clears local auth files and logs the user out. */
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2