@nestbox-ai/cli 1.0.24 → 1.0.26

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 (41) hide show
  1. package/dist/commands/auth/index.d.ts +2 -0
  2. package/dist/commands/auth/index.js +9 -0
  3. package/dist/commands/auth/index.js.map +1 -0
  4. package/dist/commands/auth/login.d.ts +2 -0
  5. package/dist/commands/auth/login.js +186 -0
  6. package/dist/commands/auth/login.js.map +1 -0
  7. package/dist/commands/auth/logout.d.ts +2 -0
  8. package/dist/commands/auth/logout.js +111 -0
  9. package/dist/commands/auth/logout.js.map +1 -0
  10. package/dist/commands/auth.d.ts +4 -1
  11. package/dist/commands/auth.js +8 -270
  12. package/dist/commands/auth.js.map +1 -1
  13. package/dist/commands/compute/apiUtils.d.ts +11 -0
  14. package/dist/commands/compute/apiUtils.js +22 -0
  15. package/dist/commands/compute/apiUtils.js.map +1 -0
  16. package/dist/commands/compute/create.d.ts +2 -0
  17. package/dist/commands/compute/create.js +183 -0
  18. package/dist/commands/compute/create.js.map +1 -0
  19. package/dist/commands/compute/delete.d.ts +2 -0
  20. package/dist/commands/compute/delete.js +145 -0
  21. package/dist/commands/compute/delete.js.map +1 -0
  22. package/dist/commands/compute/index.d.ts +4 -0
  23. package/dist/commands/compute/index.js +14 -0
  24. package/dist/commands/compute/index.js.map +1 -0
  25. package/dist/commands/compute/list.d.ts +2 -0
  26. package/dist/commands/compute/list.js +128 -0
  27. package/dist/commands/compute/list.js.map +1 -0
  28. package/dist/commands/compute.d.ts +3 -0
  29. package/dist/commands/compute.js +10 -400
  30. package/dist/commands/compute.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/commands/auth/index.ts +3 -0
  33. package/src/commands/auth/login.ts +184 -0
  34. package/src/commands/auth/logout.ts +110 -0
  35. package/src/commands/auth.ts +9 -288
  36. package/src/commands/compute/apiUtils.ts +28 -0
  37. package/src/commands/compute/create.ts +195 -0
  38. package/src/commands/compute/delete.ts +147 -0
  39. package/src/commands/compute/index.ts +7 -0
  40. package/src/commands/compute/list.ts +125 -0
  41. package/src/commands/compute.ts +16 -449
@@ -0,0 +1,2 @@
1
+ export { registerLoginCommand } from "./login";
2
+ export { registerLogoutCommand } from "./logout";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerLogoutCommand = exports.registerLoginCommand = void 0;
4
+ // Auth command exports
5
+ var login_1 = require("./login");
6
+ Object.defineProperty(exports, "registerLoginCommand", { enumerable: true, get: function () { return login_1.registerLoginCommand; } });
7
+ var logout_1 = require("./logout");
8
+ Object.defineProperty(exports, "registerLogoutCommand", { enumerable: true, get: function () { return logout_1.registerLogoutCommand; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/auth/index.ts"],"names":[],"mappings":";;;AAAA,uBAAuB;AACvB,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAC7B,mCAAiD;AAAxC,+GAAA,qBAAqB,OAAA"}
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerLoginCommand(program: Command): void;
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.registerLoginCommand = registerLoginCommand;
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const inquirer_1 = __importDefault(require("inquirer"));
18
+ const open_1 = __importDefault(require("open"));
19
+ const ora_1 = __importDefault(require("ora"));
20
+ const fs_1 = __importDefault(require("fs"));
21
+ const os_1 = __importDefault(require("os"));
22
+ const path_1 = __importDefault(require("path"));
23
+ const admin_1 = require("@nestbox-ai/admin");
24
+ const axios_1 = __importDefault(require("axios"));
25
+ function registerLoginCommand(program) {
26
+ program
27
+ .command('login <nestbox-domain>')
28
+ .description('Login using Google SSO')
29
+ .action((domain) => __awaiter(this, void 0, void 0, function* () {
30
+ console.log('Login command triggered for domain:', domain);
31
+ const spinner = (0, ora_1.default)('Initiating Google login...').start();
32
+ try {
33
+ // Determine the protocol and construct the auth URL based on the provided domain
34
+ let authUrl;
35
+ if (domain.includes('localhost')) {
36
+ // Use HTTP for localhost and specific port
37
+ authUrl = `http://${domain}/cli/auth`;
38
+ }
39
+ else {
40
+ // Use HTTPS for all other domains
41
+ authUrl = `https://${domain}/cli/auth`;
42
+ }
43
+ spinner.text = 'Opening browser for Google authentication...';
44
+ // Open the browser for authentication
45
+ yield (0, open_1.default)(authUrl);
46
+ spinner.succeed('Browser opened for authentication');
47
+ // Prompt user to paste the combined token and API URL
48
+ const { combinedInput } = yield inquirer_1.default.prompt([
49
+ {
50
+ type: 'input',
51
+ name: 'combinedInput',
52
+ message: 'After authenticating, please paste the data here:',
53
+ validate: (input) => input.trim().length > 0 || 'Input is required'
54
+ }
55
+ ]);
56
+ // Split the input by comma
57
+ const [accessToken, apiServerUrl] = combinedInput.split(',').map(item => item.trim());
58
+ if (!accessToken || !apiServerUrl) {
59
+ spinner.fail('Invalid input format. Expected: token,apiServerUrl');
60
+ return;
61
+ }
62
+ console.log(chalk_1.default.green('Credentials received. Extracting user information...'));
63
+ // Fetch user data from the token
64
+ let email = '';
65
+ let name = '';
66
+ let picture = '';
67
+ try {
68
+ // Try to decode JWT to get user data (email, name, picture, etc.)
69
+ const tokenParts = accessToken.split('.');
70
+ if (tokenParts.length === 3) {
71
+ // Base64 decode the payload part of JWT
72
+ const base64Payload = tokenParts[1].replace(/-/g, '+').replace(/_/g, '/');
73
+ const decodedPayload = Buffer.from(base64Payload, 'base64').toString('utf-8');
74
+ const tokenPayload = JSON.parse(decodedPayload);
75
+ // Extract user information
76
+ email = tokenPayload.email || '';
77
+ name = tokenPayload.name || '';
78
+ picture = tokenPayload.picture || '';
79
+ }
80
+ }
81
+ catch (e) {
82
+ console.log(chalk_1.default.yellow('Could not decode token payload. Will prompt for email.'));
83
+ }
84
+ // If email couldn't be extracted from token, prompt user
85
+ if (!email) {
86
+ const response = yield inquirer_1.default.prompt([
87
+ {
88
+ type: 'input',
89
+ name: 'email',
90
+ message: 'Enter your email address:',
91
+ validate: (input) => /\S+@\S+\.\S+/.test(input) || 'Please enter a valid email'
92
+ }
93
+ ]);
94
+ email = response.email;
95
+ }
96
+ spinner.start('Verifying access token...');
97
+ if (apiServerUrl && email && accessToken) {
98
+ // Verify the access token
99
+ const configuration = new admin_1.Configuration({
100
+ basePath: apiServerUrl,
101
+ accessToken: accessToken,
102
+ });
103
+ const authApi = new admin_1.AuthApi(configuration);
104
+ try {
105
+ const response = yield authApi.authControllerOAuthLogin({
106
+ providerId: accessToken,
107
+ type: admin_1.OAuthLoginRequestDTOTypeEnum.Google,
108
+ email,
109
+ profilePictureUrl: picture || '',
110
+ });
111
+ const authResponse = response.data;
112
+ // Save credentials to file
113
+ try {
114
+ // Create directory structure
115
+ const configDir = path_1.default.join(os_1.default.homedir(), '.config', '.nestbox');
116
+ if (!fs_1.default.existsSync(configDir)) {
117
+ fs_1.default.mkdirSync(configDir, { recursive: true });
118
+ }
119
+ // Create the file path
120
+ const fileName = `${email.replace('@', '_at_')}_${domain}.json`;
121
+ const filePath = path_1.default.join(configDir, fileName);
122
+ // Create credentials object
123
+ const credentials = {
124
+ domain,
125
+ email,
126
+ token: authResponse.token,
127
+ accessToken, // Save the original accessToken
128
+ apiServerUrl,
129
+ name,
130
+ picture,
131
+ timestamp: new Date().toISOString()
132
+ };
133
+ // Write to file
134
+ fs_1.default.writeFileSync(filePath, JSON.stringify(credentials, null, 2));
135
+ spinner.succeed('Authentication successful');
136
+ console.log(chalk_1.default.green(`Successfully logged in as ${email}`));
137
+ console.log(chalk_1.default.blue(`Credentials saved to: ${filePath}`));
138
+ }
139
+ catch (fileError) {
140
+ spinner.warn('Authentication successful, but failed to save credentials file');
141
+ console.error(chalk_1.default.yellow('File error:'), fileError instanceof Error ? fileError.message : 'Unknown error');
142
+ }
143
+ }
144
+ catch (authError) {
145
+ spinner.fail('Failed to verify access token');
146
+ if (axios_1.default.isAxiosError(authError) && authError.response) {
147
+ if (authError.response.data.message === "user.not_found") {
148
+ console.error(chalk_1.default.red('Authentication Error:'), "You need to register your email with the Nestbox platform");
149
+ const { openSignup } = yield inquirer_1.default.prompt([
150
+ {
151
+ type: 'confirm',
152
+ name: 'openSignup',
153
+ message: 'Would you like to open the signup page to register?',
154
+ default: true
155
+ }
156
+ ]);
157
+ if (openSignup) {
158
+ // Construct signup URL with the same protocol logic as login
159
+ let signupUrl;
160
+ if (domain.includes('localhost')) {
161
+ signupUrl = `http://${domain}`;
162
+ }
163
+ else {
164
+ signupUrl = `https://${domain}`;
165
+ }
166
+ console.log(chalk_1.default.blue(`Opening signup page: ${signupUrl}`));
167
+ yield (0, open_1.default)(signupUrl);
168
+ }
169
+ }
170
+ }
171
+ else {
172
+ console.error(chalk_1.default.red('Authentication Error:'), authError instanceof Error ? authError.message : 'Unknown error');
173
+ }
174
+ }
175
+ }
176
+ else {
177
+ spinner.fail('Missing required information for authentication');
178
+ }
179
+ }
180
+ catch (error) {
181
+ spinner.fail('Authentication failed');
182
+ console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
183
+ }
184
+ }));
185
+ }
186
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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C;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACtC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerLogoutCommand(program: Command): void;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.registerLogoutCommand = registerLogoutCommand;
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const inquirer_1 = __importDefault(require("inquirer"));
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const os_1 = __importDefault(require("os"));
20
+ const path_1 = __importDefault(require("path"));
21
+ const auth_1 = require("../../utils/auth");
22
+ function registerLogoutCommand(program) {
23
+ program
24
+ .command('logout [nestbox-domain]')
25
+ .description('Logout from Nestbox platform')
26
+ .action((domain) => __awaiter(this, void 0, void 0, function* () {
27
+ try {
28
+ const authToken = (0, auth_1.getAuthToken)(domain);
29
+ if (!authToken) {
30
+ console.log(chalk_1.default.yellow('No authentication token found. Please log in first.'));
31
+ return;
32
+ }
33
+ // Function to remove all credential files for a domain
34
+ const removeCredentialFiles = (domain) => {
35
+ try {
36
+ const configDir = path_1.default.join(os_1.default.homedir(), '.config', '.nestbox');
37
+ if (!fs_1.default.existsSync(configDir)) {
38
+ return false;
39
+ }
40
+ // Sanitize domain for file matching
41
+ // Replace characters that are problematic in filenames
42
+ const sanitizedDomain = domain.replace(/:/g, '_');
43
+ // Get all files in the directory
44
+ const files = fs_1.default.readdirSync(configDir);
45
+ // Find and remove all files that match the domain
46
+ let removedCount = 0;
47
+ for (const file of files) {
48
+ // Check if the file matches any of the possible domain formats
49
+ if (file.endsWith(`_${domain}.json`) ||
50
+ file.endsWith(`_${sanitizedDomain}.json`)) {
51
+ fs_1.default.unlinkSync(path_1.default.join(configDir, file));
52
+ removedCount++;
53
+ }
54
+ }
55
+ return removedCount > 0;
56
+ }
57
+ catch (error) {
58
+ console.warn(chalk_1.default.yellow(`Warning: Could not remove credential files. ${error instanceof Error ? error.message : ''}`));
59
+ return false;
60
+ }
61
+ };
62
+ if (domain) {
63
+ // Logout from specific domain
64
+ // Remove credentials using utility function
65
+ const removed = (0, auth_1.removeCredentials)(domain);
66
+ // Also remove all credential files for this domain
67
+ const filesRemoved = removeCredentialFiles(domain);
68
+ if (removed || filesRemoved) {
69
+ console.log(chalk_1.default.green(`Successfully logged out from ${domain}`));
70
+ }
71
+ else {
72
+ console.log(chalk_1.default.yellow(`No credentials found for ${domain}`));
73
+ }
74
+ }
75
+ else {
76
+ // Ask which domain to logout from
77
+ const credentials = (0, auth_1.listCredentials)();
78
+ if (credentials.length === 0) {
79
+ console.log(chalk_1.default.yellow('No credentials found'));
80
+ return;
81
+ }
82
+ // Group credentials by domain
83
+ const domains = Array.from(new Set(credentials.map(cred => cred.domain)));
84
+ const domainChoices = domains.map(domain => {
85
+ const accounts = credentials.filter(cred => cred.domain === domain);
86
+ return `${domain} (${accounts.length} account${accounts.length > 1 ? 's' : ''})`;
87
+ });
88
+ const { selected } = yield inquirer_1.default.prompt([
89
+ {
90
+ type: 'list',
91
+ name: 'selected',
92
+ message: 'Select domain to logout from:',
93
+ choices: domainChoices,
94
+ }
95
+ ]);
96
+ // Extract domain from the selected choice
97
+ const selectedDomain = selected.split(' ')[0];
98
+ // Remove credentials using utility function
99
+ (0, auth_1.removeCredentials)(selectedDomain);
100
+ // Also remove all credential files for this domain
101
+ removeCredentialFiles(selectedDomain);
102
+ console.log(chalk_1.default.green(`Successfully logged out from ${selectedDomain}`));
103
+ }
104
+ }
105
+ catch (error) {
106
+ const err = error;
107
+ console.error(chalk_1.default.red('Error:'), err.message);
108
+ }
109
+ }));
110
+ }
111
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAQA,sDAqGC;AA5GD,kDAA0B;AAC1B,wDAAgC;AAChC,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,2CAAoF;AAEpF,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,yBAAyB,CAAC;SAClC,WAAW,CAAC,8BAA8B,CAAC;SAC3C,MAAM,CAAC,CAAO,MAAe,EAAE,EAAE;QAChC,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAA,mBAAY,EAAC,MAAM,CAAC,CAAC;YACvC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,qDAAqD,CAAC,CAAC,CAAC;gBACjF,OAAO;YACT,CAAC;YAED,uDAAuD;YACvD,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,EAAE;gBAC/C,IA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,MAAM;wBACZ,IAAI,EAAE,UAAU;wBAChB,OAAO,EAAE,+BAA+B;wBACxC,OAAO,EAAE,aAAa;qBACvB;iBACF,CAAC,CAAC;gBAEH,0CAA0C;gBAC1C,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE9C,4CAA4C;gBAC5C,IAAA,wBAAiB,EAAC,cAAc,CAAC,CAAC;gBAElC,mDAAmD;gBACnD,qBAAqB,CAAC,cAAc,CAAC,CAAC;gBAEtC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,gCAAgC,cAAc,EAAE,CAAC,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAc,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AACP,CAAC"}
@@ -1,2 +1,5 @@
1
- import { Command } from 'commander';
1
+ import { Command } from "commander";
2
+ /**
3
+ * Register all auth-related commands
4
+ */
2
5
  export declare function registerAuthCommands(program: Command): void;
@@ -1,276 +1,14 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.registerAuthCommands = registerAuthCommands;
16
- const chalk_1 = __importDefault(require("chalk"));
17
- const inquirer_1 = __importDefault(require("inquirer"));
18
- const open_1 = __importDefault(require("open"));
19
- const ora_1 = __importDefault(require("ora"));
20
- const fs_1 = __importDefault(require("fs"));
21
- const os_1 = __importDefault(require("os"));
22
- const path_1 = __importDefault(require("path"));
23
- const auth_1 = require("../utils/auth");
24
- const admin_1 = require("@nestbox-ai/admin");
25
- const axios_1 = __importDefault(require("axios"));
4
+ const login_1 = require("./auth/login");
5
+ const logout_1 = require("./auth/logout");
6
+ /**
7
+ * Register all auth-related commands
8
+ */
26
9
  function registerAuthCommands(program) {
27
- // Login command
28
- program
29
- .command('login <nestbox-domain>')
30
- .description('Login using Google SSO')
31
- .action((domain) => __awaiter(this, void 0, void 0, function* () {
32
- console.log('Login command triggered for domain:', domain);
33
- const spinner = (0, ora_1.default)('Initiating Google login...').start();
34
- try {
35
- // Determine the protocol and construct the auth URL based on the provided domain
36
- let authUrl;
37
- if (domain.includes('localhost')) {
38
- // Use HTTP for localhost and specific port
39
- authUrl = `http://${domain}/cli/auth`;
40
- }
41
- else {
42
- // Use HTTPS for all other domains
43
- authUrl = `https://${domain}/cli/auth`;
44
- }
45
- spinner.text = 'Opening browser for Google authentication...';
46
- // Open the browser for authentication
47
- yield (0, open_1.default)(authUrl);
48
- spinner.succeed('Browser opened for authentication');
49
- // Prompt user to paste the combined token and API URL
50
- const { combinedInput } = yield inquirer_1.default.prompt([
51
- {
52
- type: 'input',
53
- name: 'combinedInput',
54
- message: 'After authenticating, please paste the data here:',
55
- validate: (input) => input.trim().length > 0 || 'Input is required'
56
- }
57
- ]);
58
- // Split the input by comma
59
- const [accessToken, apiServerUrl] = combinedInput.split(',').map(item => item.trim());
60
- if (!accessToken || !apiServerUrl) {
61
- spinner.fail('Invalid input format. Expected: token,apiServerUrl');
62
- return;
63
- }
64
- console.log(chalk_1.default.green('Credentials received. Extracting user information...'));
65
- // Fetch user data from the token
66
- let email = '';
67
- let name = '';
68
- let picture = '';
69
- try {
70
- // Try to decode JWT to get user data (email, name, picture, etc.)
71
- const tokenParts = accessToken.split('.');
72
- if (tokenParts.length === 3) {
73
- // Base64 decode the payload part of JWT
74
- const base64Payload = tokenParts[1].replace(/-/g, '+').replace(/_/g, '/');
75
- const decodedPayload = Buffer.from(base64Payload, 'base64').toString('utf-8');
76
- const tokenPayload = JSON.parse(decodedPayload);
77
- // Extract user information
78
- email = tokenPayload.email || '';
79
- name = tokenPayload.name || '';
80
- picture = tokenPayload.picture || '';
81
- }
82
- }
83
- catch (e) {
84
- console.log(chalk_1.default.yellow('Could not decode token payload. Will prompt for email.'));
85
- }
86
- // If email couldn't be extracted from token, prompt user
87
- if (!email) {
88
- const response = yield inquirer_1.default.prompt([
89
- {
90
- type: 'input',
91
- name: 'email',
92
- message: 'Enter your email address:',
93
- validate: (input) => /\S+@\S+\.\S+/.test(input) || 'Please enter a valid email'
94
- }
95
- ]);
96
- email = response.email;
97
- }
98
- spinner.start('Verifying access token...');
99
- if (apiServerUrl && email && accessToken) {
100
- // Verify the access token
101
- const configuration = new admin_1.Configuration({
102
- basePath: apiServerUrl,
103
- accessToken: accessToken,
104
- });
105
- const authApi = new admin_1.AuthApi(configuration);
106
- try {
107
- const response = yield authApi.authControllerOAuthLogin({
108
- providerId: accessToken,
109
- type: admin_1.OAuthLoginRequestDTOTypeEnum.Google,
110
- email,
111
- profilePictureUrl: picture || '',
112
- });
113
- const authResponse = response.data;
114
- // Save credentials to file
115
- try {
116
- // Create directory structure
117
- const configDir = path_1.default.join(os_1.default.homedir(), '.config', '.nestbox');
118
- if (!fs_1.default.existsSync(configDir)) {
119
- fs_1.default.mkdirSync(configDir, { recursive: true });
120
- }
121
- // Create the file path
122
- const fileName = `${email.replace('@', '_at_')}_${domain}.json`;
123
- const filePath = path_1.default.join(configDir, fileName);
124
- // Create credentials object
125
- const credentials = {
126
- domain,
127
- email,
128
- token: authResponse.token,
129
- accessToken, // Save the original accessToken
130
- apiServerUrl,
131
- name,
132
- picture,
133
- timestamp: new Date().toISOString()
134
- };
135
- // Write to file
136
- fs_1.default.writeFileSync(filePath, JSON.stringify(credentials, null, 2));
137
- spinner.succeed('Authentication successful');
138
- console.log(chalk_1.default.green(`Successfully logged in as ${email}`));
139
- console.log(chalk_1.default.blue(`Credentials saved to: ${filePath}`));
140
- }
141
- catch (fileError) {
142
- spinner.warn('Authentication successful, but failed to save credentials file');
143
- console.error(chalk_1.default.yellow('File error:'), fileError instanceof Error ? fileError.message : 'Unknown error');
144
- }
145
- }
146
- catch (authError) {
147
- spinner.fail('Failed to verify access token');
148
- if (axios_1.default.isAxiosError(authError) && authError.response) {
149
- if (authError.response.data.message === "user.not_found") {
150
- console.error(chalk_1.default.red('Authentication Error:'), "You need to register your email with the Nestbox platform");
151
- const { openSignup } = yield inquirer_1.default.prompt([
152
- {
153
- type: 'confirm',
154
- name: 'openSignup',
155
- message: 'Would you like to open the signup page to register?',
156
- default: true
157
- }
158
- ]);
159
- if (openSignup) {
160
- // Construct signup URL with the same protocol logic as login
161
- let signupUrl;
162
- if (domain.includes('localhost')) {
163
- signupUrl = `http://${domain}`;
164
- }
165
- else {
166
- signupUrl = `https://${domain}`;
167
- }
168
- console.log(chalk_1.default.blue(`Opening signup page: ${signupUrl}`));
169
- yield (0, open_1.default)(signupUrl);
170
- }
171
- }
172
- }
173
- else {
174
- console.error(chalk_1.default.red('Authentication Error:'), authError instanceof Error ? authError.message : 'Unknown error');
175
- }
176
- }
177
- }
178
- else {
179
- spinner.fail('Missing required information for authentication');
180
- }
181
- }
182
- catch (error) {
183
- spinner.fail('Authentication failed');
184
- console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
185
- }
186
- }));
187
- // Logout command
188
- program
189
- .command('logout [nestbox-domain]')
190
- .description('Logout from Nestbox platform')
191
- .action((domain) => __awaiter(this, void 0, void 0, function* () {
192
- try {
193
- const authToken = (0, auth_1.getAuthToken)(domain);
194
- if (!authToken) {
195
- console.log(chalk_1.default.yellow('No authentication token found. Please log in first.'));
196
- return;
197
- }
198
- // Function to remove all credential files for a domain
199
- const removeCredentialFiles = (domain) => {
200
- try {
201
- const configDir = path_1.default.join(os_1.default.homedir(), '.config', '.nestbox');
202
- if (!fs_1.default.existsSync(configDir)) {
203
- return false;
204
- }
205
- // Sanitize domain for file matching
206
- // Replace characters that are problematic in filenames
207
- const sanitizedDomain = domain.replace(/:/g, '_');
208
- // Get all files in the directory
209
- const files = fs_1.default.readdirSync(configDir);
210
- // Find and remove all files that match the domain
211
- let removedCount = 0;
212
- for (const file of files) {
213
- // Check if the file matches any of the possible domain formats
214
- if (file.endsWith(`_${domain}.json`) ||
215
- file.endsWith(`_${sanitizedDomain}.json`)) {
216
- fs_1.default.unlinkSync(path_1.default.join(configDir, file));
217
- removedCount++;
218
- }
219
- }
220
- return removedCount > 0;
221
- }
222
- catch (error) {
223
- console.warn(chalk_1.default.yellow(`Warning: Could not remove credential files. ${error instanceof Error ? error.message : ''}`));
224
- return false;
225
- }
226
- };
227
- if (domain) {
228
- // Logout from specific domain
229
- // Remove credentials using utility function
230
- const removed = (0, auth_1.removeCredentials)(domain);
231
- // Also remove all credential files for this domain
232
- const filesRemoved = removeCredentialFiles(domain);
233
- if (removed || filesRemoved) {
234
- console.log(chalk_1.default.green(`Successfully logged out from ${domain}`));
235
- }
236
- else {
237
- console.log(chalk_1.default.yellow(`No credentials found for ${domain}`));
238
- }
239
- }
240
- else {
241
- // Ask which domain to logout from
242
- const credentials = (0, auth_1.listCredentials)();
243
- if (credentials.length === 0) {
244
- console.log(chalk_1.default.yellow('No credentials found'));
245
- return;
246
- }
247
- // Group credentials by domain
248
- const domains = Array.from(new Set(credentials.map(cred => cred.domain)));
249
- const domainChoices = domains.map(domain => {
250
- const accounts = credentials.filter(cred => cred.domain === domain);
251
- return `${domain} (${accounts.length} account${accounts.length > 1 ? 's' : ''})`;
252
- });
253
- const { selected } = yield inquirer_1.default.prompt([
254
- {
255
- type: 'list',
256
- name: 'selected',
257
- message: 'Select domain to logout from:',
258
- choices: domainChoices,
259
- }
260
- ]);
261
- // Extract domain from the selected choice
262
- const selectedDomain = selected.split(' ')[0];
263
- // Remove credentials using utility function
264
- (0, auth_1.removeCredentials)(selectedDomain);
265
- // Also remove all credential files for this domain
266
- removeCredentialFiles(selectedDomain);
267
- console.log(chalk_1.default.green(`Successfully logged out from ${selectedDomain}`));
268
- }
269
- }
270
- catch (error) {
271
- const err = error;
272
- console.error(chalk_1.default.red('Error:'), err.message);
273
- }
274
- }));
10
+ // Register auth commands directly on the program (not as subcommands)
11
+ (0, login_1.registerLoginCommand)(program);
12
+ (0, logout_1.registerLogoutCommand)(program);
275
13
  }
276
14
  //# sourceMappingURL=auth.js.map