vibehub-cli 1.0.43 → 1.1.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.
Files changed (38) hide show
  1. package/dist/commands/clone.d.ts.map +1 -1
  2. package/dist/commands/clone.js +24 -2
  3. package/dist/commands/clone.js.map +1 -1
  4. package/dist/commands/login.d.ts +3 -0
  5. package/dist/commands/login.d.ts.map +1 -0
  6. package/dist/commands/login.js +71 -0
  7. package/dist/commands/login.js.map +1 -0
  8. package/dist/commands/logout.d.ts +3 -0
  9. package/dist/commands/logout.d.ts.map +1 -0
  10. package/dist/commands/logout.js +92 -0
  11. package/dist/commands/logout.js.map +1 -0
  12. package/dist/commands/profiles.d.ts +3 -0
  13. package/dist/commands/profiles.d.ts.map +1 -0
  14. package/dist/commands/profiles.js +77 -0
  15. package/dist/commands/profiles.js.map +1 -0
  16. package/dist/commands/use.d.ts +3 -0
  17. package/dist/commands/use.d.ts.map +1 -0
  18. package/dist/commands/use.js +83 -0
  19. package/dist/commands/use.js.map +1 -0
  20. package/dist/commands/whoami.d.ts +3 -0
  21. package/dist/commands/whoami.d.ts.map +1 -0
  22. package/dist/commands/whoami.js +105 -0
  23. package/dist/commands/whoami.js.map +1 -0
  24. package/dist/index.js +12 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/lib/auth-helper.d.ts +14 -3
  27. package/dist/lib/auth-helper.d.ts.map +1 -1
  28. package/dist/lib/auth-helper.js +111 -35
  29. package/dist/lib/auth-helper.js.map +1 -1
  30. package/dist/lib/profile-manager.d.ts +116 -0
  31. package/dist/lib/profile-manager.d.ts.map +1 -0
  32. package/dist/lib/profile-manager.js +351 -0
  33. package/dist/lib/profile-manager.js.map +1 -0
  34. package/dist/lib/supabase-auth.d.ts +42 -0
  35. package/dist/lib/supabase-auth.d.ts.map +1 -0
  36. package/dist/lib/supabase-auth.js +398 -0
  37. package/dist/lib/supabase-auth.js.map +1 -0
  38. package/package.json +4 -3
package/dist/index.js.map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U,CAAC,UAAU,CAAC,CAAC;AAC/B,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACnC,0BAA0B;AAC1B,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC/B,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAElC,uBAAuB;AACvB,OAAO,CAAC,YAAY,EAAE,CAAC;AAEvB,IAAI,CAAC;IACH,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -3,8 +3,15 @@ export interface AuthInfo {
3
3
  token: string;
4
4
  }
5
5
  /**
6
- * Get authentication token - checks global config first, prompts if needed
7
- * This is the main entry point for authentication in all commands
6
+ * Get authentication token - uses profile system with automatic token refresh.
7
+ * This is the main entry point for authentication in all commands.
8
+ *
9
+ * Flow:
10
+ * 1. Check for migration from old format (prompts browser login if needed)
11
+ * 2. Get active profile (project-level override or default)
12
+ * 3. If no profile exists, prompt browser login
13
+ * 4. If token expired/expiring, silently refresh using refresh token
14
+ * 5. Return valid token
8
15
  */
9
16
  export declare function getAuthToken(forceReauth?: boolean): Promise<AuthInfo>;
10
17
  /**
@@ -16,7 +23,11 @@ export declare function isAuthenticated(): Promise<boolean>;
16
23
  */
17
24
  export declare function getStoredEmail(): Promise<string | null>;
18
25
  /**
19
- * Clear authentication (logout)
26
+ * Clear authentication (logout from active profile)
20
27
  */
21
28
  export declare function clearAuth(): Promise<void>;
29
+ /**
30
+ * Get the current profile name (for display purposes)
31
+ */
32
+ export declare function getCurrentProfileName(): Promise<string | null>;
22
33
  //# sourceMappingURL=auth-helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-helper.d.ts","sourceRoot":"","sources":["../../src/lib/auth-helper.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsClF;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAGxD;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAG7D;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAI/C"}
1
+ {"version":3,"file":"auth-helper.d.ts","sourceRoot":"","sources":["../../src/lib/auth-helper.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4FlF;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAIxD;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAI7D;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAU/C;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIpE"}
@@ -1,58 +1,134 @@
1
- import { GlobalConfigManager } from './global-config.js';
2
- import { authenticateWithFirebase } from './firebase-auth.js';
3
1
  import chalk from 'chalk';
2
+ import { ProfileManager } from './profile-manager.js';
3
+ import { SupabaseAuth } from './supabase-auth.js';
4
4
  /**
5
- * Get authentication token - checks global config first, prompts if needed
6
- * This is the main entry point for authentication in all commands
5
+ * Get authentication token - uses profile system with automatic token refresh.
6
+ * This is the main entry point for authentication in all commands.
7
+ *
8
+ * Flow:
9
+ * 1. Check for migration from old format (prompts browser login if needed)
10
+ * 2. Get active profile (project-level override or default)
11
+ * 3. If no profile exists, prompt browser login
12
+ * 4. If token expired/expiring, silently refresh using refresh token
13
+ * 5. Return valid token
7
14
  */
8
15
  export async function getAuthToken(forceReauth = false) {
9
- const configManager = new GlobalConfigManager();
10
- // If force reauth, clear existing auth
16
+ const profileManager = new ProfileManager();
17
+ // Check for migration from old format
18
+ const needsMigration = await profileManager.migrateIfNeeded();
19
+ if (needsMigration) {
20
+ console.log('');
21
+ console.log(chalk.yellow('═'.repeat(55)));
22
+ console.log(chalk.yellow.bold(' VibeHub Authentication Upgrade'));
23
+ console.log(chalk.yellow('═'.repeat(55)));
24
+ console.log('');
25
+ console.log('VibeHub now uses Google Sign-In for better security');
26
+ console.log('and seamless authentication across all your devices.');
27
+ console.log('');
28
+ console.log(chalk.gray('Your existing configuration has been backed up.'));
29
+ console.log('');
30
+ }
31
+ // If force reauth, delete current profile and re-authenticate
11
32
  if (forceReauth) {
12
- await configManager.clearAuth();
13
- }
14
- // Check for stored token
15
- let token = await configManager.getToken();
16
- let email = await configManager.getUserEmail();
17
- // If we have a valid token, return it
18
- if (token && email) {
19
- return { email, token };
20
- }
21
- // No valid token - need to authenticate
22
- console.log(chalk.yellow('🔐 Authentication required'));
23
- console.log(chalk.gray('Please sign in to continue...\n'));
24
- // Authenticate with Firebase
25
- const authResult = await authenticateWithFirebase(email || undefined);
26
- // Save token globally for future use
27
- await configManager.saveToken(authResult.email, authResult.token, 3600 // 1 hour expiry (Firebase tokens typically last 1 hour)
28
- );
29
- console.log(chalk.green(`✅ Authenticated as ${authResult.email}`));
30
- console.log(chalk.gray('Token saved globally - you won\'t need to authenticate again for other projects.\n'));
33
+ const activeProfile = await profileManager.getActiveProfile();
34
+ if (activeProfile) {
35
+ await profileManager.deleteProfile(activeProfile.name);
36
+ }
37
+ }
38
+ // Get active profile (project-level override or default)
39
+ let profile = await profileManager.getActiveProfile();
40
+ // If no profile exists, prompt for authentication
41
+ if (!profile) {
42
+ console.log('');
43
+ console.log(chalk.yellow('Authentication required'));
44
+ console.log(chalk.blue('Opening browser for Google sign-in...'));
45
+ console.log('');
46
+ console.log(chalk.gray('If your browser doesn\'t open automatically, please visit:'));
47
+ console.log(chalk.gray('https://vibehub.co.in/cli-auth'));
48
+ console.log('');
49
+ try {
50
+ const supabaseAuth = new SupabaseAuth();
51
+ const profileData = await supabaseAuth.loginWithGoogle();
52
+ // Save to default profile
53
+ await profileManager.saveProfile('default', profileData);
54
+ profile = await profileManager.getProfile('default');
55
+ console.log('');
56
+ console.log(chalk.green(`✓ Authenticated as ${profileData.email}`));
57
+ console.log(chalk.gray('Token saved - you won\'t need to authenticate again for a while.'));
58
+ console.log('');
59
+ }
60
+ catch (error) {
61
+ console.log('');
62
+ console.log(chalk.red('✗ Authentication failed'));
63
+ console.log(chalk.red(` ${error.message}`));
64
+ console.log('');
65
+ throw error;
66
+ }
67
+ }
68
+ if (!profile) {
69
+ throw new Error('Authentication failed. Please run \'vibe login\' to sign in.');
70
+ }
71
+ // Refresh token if needed (silent refresh)
72
+ try {
73
+ profile = await profileManager.refreshTokenIfNeeded(profile);
74
+ }
75
+ catch (error) {
76
+ // Token refresh failed - need to re-authenticate
77
+ console.log('');
78
+ console.log(chalk.yellow('Session expired. Re-authenticating...'));
79
+ console.log(chalk.blue('Opening browser for Google sign-in...'));
80
+ console.log('');
81
+ const supabaseAuth = new SupabaseAuth();
82
+ const profileData = await supabaseAuth.loginWithGoogle();
83
+ await profileManager.saveProfile(profile.name, profileData);
84
+ profile = await profileManager.getProfile(profile.name);
85
+ if (!profile) {
86
+ throw new Error('Authentication failed after refresh.');
87
+ }
88
+ console.log(chalk.green(`✓ Re-authenticated as ${profile.email}`));
89
+ console.log('');
90
+ }
31
91
  return {
32
- email: authResult.email,
33
- token: authResult.token
92
+ email: profile.email,
93
+ token: profile.accessToken
34
94
  };
35
95
  }
36
96
  /**
37
97
  * Check if user is authenticated (without prompting)
38
98
  */
39
99
  export async function isAuthenticated() {
40
- const configManager = new GlobalConfigManager();
41
- return await configManager.isAuthenticated();
100
+ const profileManager = new ProfileManager();
101
+ const profile = await profileManager.getActiveProfile();
102
+ return profile !== null;
42
103
  }
43
104
  /**
44
105
  * Get stored email without prompting
45
106
  */
46
107
  export async function getStoredEmail() {
47
- const configManager = new GlobalConfigManager();
48
- return await configManager.getUserEmail();
108
+ const profileManager = new ProfileManager();
109
+ const profile = await profileManager.getActiveProfile();
110
+ return profile?.email || null;
49
111
  }
50
112
  /**
51
- * Clear authentication (logout)
113
+ * Clear authentication (logout from active profile)
52
114
  */
53
115
  export async function clearAuth() {
54
- const configManager = new GlobalConfigManager();
55
- await configManager.clearAuth();
56
- console.log(chalk.green('✅ Logged out successfully'));
116
+ const profileManager = new ProfileManager();
117
+ const profile = await profileManager.getActiveProfile();
118
+ if (profile) {
119
+ await profileManager.deleteProfile(profile.name);
120
+ console.log(chalk.green(`✓ Logged out from ${profile.email}`));
121
+ }
122
+ else {
123
+ console.log(chalk.yellow('Not logged in.'));
124
+ }
125
+ }
126
+ /**
127
+ * Get the current profile name (for display purposes)
128
+ */
129
+ export async function getCurrentProfileName() {
130
+ const profileManager = new ProfileManager();
131
+ const profile = await profileManager.getActiveProfile();
132
+ return profile?.name || null;
57
133
  }
58
134
  //# sourceMappingURL=auth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CAAC;IACxD,OAAO,OAAO,KAAK,IAAI,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,gBAAgB,EAAE,CAAC;IACxD,OAAO,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAExD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,gBAAgB,EAAE,CAAC;IACxD,OAAO,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Profile data structure for storing authentication tokens
3
+ */
4
+ export interface ProfileData {
5
+ name: string;
6
+ email: string;
7
+ userId: string;
8
+ accessToken: string;
9
+ refreshToken: string;
10
+ tokenExpiresAt: string;
11
+ createdAt: string;
12
+ lastUsedAt: string;
13
+ }
14
+ /**
15
+ * Global configuration structure
16
+ */
17
+ export interface GlobalConfig {
18
+ version: string;
19
+ defaultProfile: string;
20
+ migratedFrom?: string;
21
+ }
22
+ /**
23
+ * Project-level profile configuration
24
+ */
25
+ export interface ProjectProfileConfig {
26
+ profile?: string;
27
+ }
28
+ /**
29
+ * ProfileManager handles multi-profile authentication token storage and management.
30
+ *
31
+ * Storage structure:
32
+ * ~/.vibehub/
33
+ * ├── config.json # Global settings (defaultProfile, version)
34
+ * └── profiles/
35
+ * ├── default.json # Default profile tokens
36
+ * └── work.json # Named profile tokens
37
+ *
38
+ * Project-level override:
39
+ * project/.vibehub/config.json # Contains "profile" field to override default
40
+ */
41
+ export declare class ProfileManager {
42
+ private baseDir;
43
+ private configPath;
44
+ private profilesDir;
45
+ private supabase;
46
+ constructor();
47
+ /**
48
+ * Ensure the profile directories exist
49
+ */
50
+ private ensureDirectories;
51
+ /**
52
+ * Get the global configuration
53
+ */
54
+ getGlobalConfig(): Promise<GlobalConfig>;
55
+ /**
56
+ * Save the global configuration
57
+ */
58
+ saveGlobalConfig(config: GlobalConfig): Promise<void>;
59
+ /**
60
+ * Get a profile by name
61
+ */
62
+ getProfile(name: string): Promise<ProfileData | null>;
63
+ /**
64
+ * Save a profile
65
+ */
66
+ saveProfile(name: string, data: Omit<ProfileData, 'name'>): Promise<void>;
67
+ /**
68
+ * Delete a profile
69
+ */
70
+ deleteProfile(name: string): Promise<boolean>;
71
+ /**
72
+ * List all profiles
73
+ */
74
+ listProfiles(): Promise<ProfileData[]>;
75
+ /**
76
+ * Delete all profiles
77
+ */
78
+ deleteAllProfiles(): Promise<number>;
79
+ /**
80
+ * Get the project-level profile override (if any)
81
+ */
82
+ getProjectProfile(projectPath?: string): Promise<string | null>;
83
+ /**
84
+ * Set the profile for the current project
85
+ */
86
+ setProjectProfile(profileName: string, projectPath?: string): Promise<void>;
87
+ /**
88
+ * Clear the project profile override
89
+ */
90
+ clearProjectProfile(projectPath?: string): Promise<void>;
91
+ /**
92
+ * Get the active profile (project-level override or default)
93
+ */
94
+ getActiveProfile(projectPath?: string): Promise<ProfileData | null>;
95
+ /**
96
+ * Check if a token is expired or about to expire
97
+ */
98
+ isTokenExpired(profile: ProfileData, bufferMinutes?: number): boolean;
99
+ /**
100
+ * Refresh tokens if needed (silent refresh using refresh token)
101
+ */
102
+ refreshTokenIfNeeded(profile: ProfileData): Promise<ProfileData>;
103
+ /**
104
+ * Check if migration from old format is needed and perform it
105
+ */
106
+ migrateIfNeeded(): Promise<boolean>;
107
+ /**
108
+ * Get the profile status (for display)
109
+ */
110
+ getProfileStatus(profile: ProfileData): 'active' | 'expiring' | 'expired';
111
+ /**
112
+ * Get time until token expires (formatted string)
113
+ */
114
+ getTokenExpiryString(profile: ProfileData): string;
115
+ }
116
+ //# sourceMappingURL=profile-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-manager.d.ts","sourceRoot":"","sources":["../../src/lib/profile-manager.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAi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