@gopherhole/cli 0.1.19 → 0.1.20

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/dist/index.js CHANGED
@@ -421,17 +421,36 @@ program
421
421
  program
422
422
  .command('whoami')
423
423
  .description('Show current logged in user')
424
- .action(() => {
425
- const user = config.get('user');
426
- const tenant = config.get('tenant');
427
- if (!user) {
424
+ .action(async () => {
425
+ const sessionId = config.get('sessionId');
426
+ const cachedUser = config.get('user');
427
+ const cachedTenant = config.get('tenant');
428
+ if (!sessionId || !cachedUser) {
428
429
  console.log(chalk_1.default.yellow('Not logged in.'));
429
430
  console.log(chalk_1.default.gray('\nTo log in: gopherhole login'));
430
431
  console.log(chalk_1.default.gray('To sign up: gopherhole signup'));
431
432
  process.exit(1);
432
433
  }
433
- console.log(`\n ${chalk_1.default.bold('User:')} ${user.name} <${user.email}>`);
434
- console.log(` ${chalk_1.default.bold('Org:')} ${tenant?.name || 'Personal'}`);
434
+ // Validate session with server
435
+ try {
436
+ const res = await fetch(`${API_URL}/auth/me`, {
437
+ headers: { 'X-Session-ID': sessionId },
438
+ });
439
+ if (!res.ok) {
440
+ const data = await res.json().catch(() => ({}));
441
+ if (data.error === 'Session expired' || res.status === 401) {
442
+ console.log(chalk_1.default.red('Session expired.'));
443
+ console.log(chalk_1.default.gray('\nPlease log in again: gopherhole login'));
444
+ process.exit(1);
445
+ }
446
+ }
447
+ }
448
+ catch {
449
+ // Network error - show cached info with warning
450
+ console.log(chalk_1.default.yellow('⚠ Could not verify session (offline?)\n'));
451
+ }
452
+ console.log(`\n ${chalk_1.default.bold('User:')} ${cachedUser.name} <${cachedUser.email}>`);
453
+ console.log(` ${chalk_1.default.bold('Org:')} ${cachedTenant?.name || 'Personal'}`);
435
454
  console.log(` ${chalk_1.default.bold('Config:')} ${config.path}\n`);
436
455
  });
437
456
  // ========== AGENT COMMANDS ==========
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherhole/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "GopherHole CLI - Connect AI agents to the world",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -463,19 +463,39 @@ program
463
463
  program
464
464
  .command('whoami')
465
465
  .description('Show current logged in user')
466
- .action(() => {
467
- const user = config.get('user') as { email: string; name: string } | undefined;
468
- const tenant = config.get('tenant') as { name: string } | undefined;
466
+ .action(async () => {
467
+ const sessionId = config.get('sessionId') as string | undefined;
468
+ const cachedUser = config.get('user') as { email: string; name: string } | undefined;
469
+ const cachedTenant = config.get('tenant') as { name: string } | undefined;
469
470
 
470
- if (!user) {
471
+ if (!sessionId || !cachedUser) {
471
472
  console.log(chalk.yellow('Not logged in.'));
472
473
  console.log(chalk.gray('\nTo log in: gopherhole login'));
473
474
  console.log(chalk.gray('To sign up: gopherhole signup'));
474
475
  process.exit(1);
475
476
  }
476
477
 
477
- console.log(`\n ${chalk.bold('User:')} ${user.name} <${user.email}>`);
478
- console.log(` ${chalk.bold('Org:')} ${tenant?.name || 'Personal'}`);
478
+ // Validate session with server
479
+ try {
480
+ const res = await fetch(`${API_URL}/auth/me`, {
481
+ headers: { 'X-Session-ID': sessionId },
482
+ });
483
+
484
+ if (!res.ok) {
485
+ const data = await res.json().catch(() => ({}));
486
+ if (data.error === 'Session expired' || res.status === 401) {
487
+ console.log(chalk.red('Session expired.'));
488
+ console.log(chalk.gray('\nPlease log in again: gopherhole login'));
489
+ process.exit(1);
490
+ }
491
+ }
492
+ } catch {
493
+ // Network error - show cached info with warning
494
+ console.log(chalk.yellow('⚠ Could not verify session (offline?)\n'));
495
+ }
496
+
497
+ console.log(`\n ${chalk.bold('User:')} ${cachedUser.name} <${cachedUser.email}>`);
498
+ console.log(` ${chalk.bold('Org:')} ${cachedTenant?.name || 'Personal'}`);
479
499
  console.log(` ${chalk.bold('Config:')} ${config.path}\n`);
480
500
  });
481
501