raqeb-cli 1.3.3 → 1.3.5
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/bin/raqeb.js +9 -18
- package/lib/interactive.js +30 -24
- package/package.json +1 -1
package/bin/raqeb.js
CHANGED
|
@@ -32,17 +32,19 @@ function saveConfig(config) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Get API client
|
|
35
|
-
function getClient() {
|
|
35
|
+
function getClient(allowUnauthenticated = false) {
|
|
36
36
|
const config = loadConfig();
|
|
37
|
-
if (!config.api_key) {
|
|
37
|
+
if (!config.api_key && !allowUnauthenticated) {
|
|
38
38
|
console.error(chalk.red('❌ Not authenticated. Run: raqeb login --api-key <key>'));
|
|
39
39
|
process.exit(1);
|
|
40
40
|
}
|
|
41
41
|
return axios.create({
|
|
42
|
-
baseURL: config.base_url,
|
|
43
|
-
headers: {
|
|
42
|
+
baseURL: config.base_url || 'https://app.raqeb.cloud/api/v1',
|
|
43
|
+
headers: config.api_key ? {
|
|
44
44
|
'Authorization': `Bearer ${config.api_key}`,
|
|
45
45
|
'Content-Type': 'application/json'
|
|
46
|
+
} : {
|
|
47
|
+
'Content-Type': 'application/json'
|
|
46
48
|
}
|
|
47
49
|
});
|
|
48
50
|
}
|
|
@@ -327,7 +329,7 @@ Examples:
|
|
|
327
329
|
`)
|
|
328
330
|
.action(async () => {
|
|
329
331
|
const InteractiveShell = require('../lib/interactive');
|
|
330
|
-
const client = getClient();
|
|
332
|
+
const client = getClient(true); // Allow unauthenticated for interactive mode
|
|
331
333
|
const shell = new InteractiveShell(client);
|
|
332
334
|
await shell.start();
|
|
333
335
|
});
|
|
@@ -360,22 +362,11 @@ Installation:
|
|
|
360
362
|
program
|
|
361
363
|
.name('raqeb')
|
|
362
364
|
.description('Raqeb CLI - Database PAM and Secrets Management')
|
|
363
|
-
.version('1.3.
|
|
364
|
-
.option('-i, --interactive', 'Launch interactive mode')
|
|
365
|
-
.hook('preAction', async (thisCommand, actionCommand) => {
|
|
366
|
-
// Handle -i flag
|
|
367
|
-
if (thisCommand.opts().interactive) {
|
|
368
|
-
const InteractiveShell = require('../lib/interactive');
|
|
369
|
-
const client = getClient();
|
|
370
|
-
const shell = new InteractiveShell(client);
|
|
371
|
-
await shell.start();
|
|
372
|
-
process.exit(0);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
365
|
+
.version('1.3.5');
|
|
375
366
|
|
|
376
367
|
program.parse();
|
|
377
368
|
|
|
378
|
-
// If no command specified
|
|
369
|
+
// If no command specified, show help
|
|
379
370
|
if (!process.argv.slice(2).length) {
|
|
380
371
|
program.outputHelp();
|
|
381
372
|
}
|
package/lib/interactive.js
CHANGED
|
@@ -29,11 +29,15 @@ class InteractiveShell {
|
|
|
29
29
|
|
|
30
30
|
async fetchUserInfo() {
|
|
31
31
|
try {
|
|
32
|
+
// Check if we have a valid API key
|
|
33
|
+
if (!this.config || !this.config.api_key) {
|
|
34
|
+
throw new Error('No API key found');
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
const response = await this.client.get('/auth/me');
|
|
33
38
|
this.userInfo = response.data;
|
|
34
|
-
console.log('User info loaded:', this.userInfo); // Debug
|
|
35
39
|
} catch (error) {
|
|
36
|
-
|
|
40
|
+
// Set defaults if not logged in
|
|
37
41
|
this.userInfo = {
|
|
38
42
|
email: 'Not logged in',
|
|
39
43
|
tenant_name: 'Unknown',
|
|
@@ -91,25 +95,27 @@ class InteractiveShell {
|
|
|
91
95
|
showWelcome() {
|
|
92
96
|
console.clear();
|
|
93
97
|
|
|
94
|
-
// Raqeb ASCII Logo -
|
|
98
|
+
// Raqeb ASCII Logo - Exact from user's screenshot
|
|
95
99
|
const blue = chalk.hex('#0066cc');
|
|
96
|
-
const green = chalk.hex('#
|
|
97
|
-
const cyan = chalk.hex('#
|
|
100
|
+
const green = chalk.hex('#00cc99');
|
|
101
|
+
const cyan = chalk.hex('#00ffcc');
|
|
98
102
|
|
|
99
103
|
console.log('');
|
|
100
|
-
console.log('
|
|
101
|
-
console.log('
|
|
102
|
-
console.log('
|
|
103
|
-
console.log('
|
|
104
|
-
console.log('
|
|
105
|
-
console.log('
|
|
106
|
-
console.log('
|
|
107
|
-
console.log('
|
|
108
|
-
console.log('
|
|
109
|
-
console.log('
|
|
110
|
-
console.log(' ' + blue('
|
|
111
|
-
console.log('
|
|
112
|
-
console.log('
|
|
104
|
+
console.log(' ' + blue('●'));
|
|
105
|
+
console.log(' ' + blue('╱ ╲'));
|
|
106
|
+
console.log(' ' + blue('╭───○') + ' ' + blue('○───╮'));
|
|
107
|
+
console.log(' ' + blue('╱') + ' ' + green('╱') + cyan(' ● ') + green('╲') + ' ' + blue('╲'));
|
|
108
|
+
console.log(' ' + blue('╱') + ' ' + green('╱') + cyan(' ╱ ╲ ') + green('╲') + ' ' + blue('╲'));
|
|
109
|
+
console.log(' ' + blue('╱') + ' ' + green('╱') + cyan(' ╱ ╲ ') + green('╲') + ' ' + blue('╲'));
|
|
110
|
+
console.log(' ' + blue('│') + ' ' + green('│') + cyan(' │ │ ') + green('│') + ' ' + blue('│'));
|
|
111
|
+
console.log(' ' + blue('│') + ' ' + chalk.bold.white('RAQEB') + ' ' + cyan('│') + green(' ● ') + cyan('│') + ' ' + blue('│'));
|
|
112
|
+
console.log(' ' + blue('│') + ' ' + green('│') + cyan(' │ │ ') + green('│') + ' ' + blue('│'));
|
|
113
|
+
console.log(' ' + blue('╲') + ' ' + green('╲') + cyan(' ╲ ╱ ') + green('╱') + ' ' + blue('╱'));
|
|
114
|
+
console.log(' ' + blue('╲') + ' ' + green('╲') + cyan(' ╲ ╱ ') + green('╱') + ' ' + blue('╱'));
|
|
115
|
+
console.log(' ' + blue('╲') + ' ' + green('╲') + cyan(' ● ') + green('╱') + ' ' + blue('╱'));
|
|
116
|
+
console.log(' ' + blue('╰───○') + ' ' + blue('○───╯'));
|
|
117
|
+
console.log(' ' + blue('╲ ╱'));
|
|
118
|
+
console.log(' ' + blue('●'));
|
|
113
119
|
console.log('');
|
|
114
120
|
|
|
115
121
|
// Header box with user info
|
|
@@ -118,7 +124,7 @@ class InteractiveShell {
|
|
|
118
124
|
const userRole = this.userInfo?.role || 'user';
|
|
119
125
|
|
|
120
126
|
console.log(blue('╔════════════════════════════════════════════════════════════════════════════╗'));
|
|
121
|
-
console.log(blue('║') + chalk.bold.white(' 🌐 Raqeb CLI - Interactive Mode v1.3.
|
|
127
|
+
console.log(blue('║') + chalk.bold.white(' 🌐 Raqeb CLI - Interactive Mode v1.3.5 ') + blue('║'));
|
|
122
128
|
console.log(blue('╠════════════════════════════════════════════════════════════════════════════╣'));
|
|
123
129
|
console.log(blue('║ ') + chalk.gray('User: ') + green(userEmail.padEnd(64)) + blue(' ║'));
|
|
124
130
|
console.log(blue('║ ') + chalk.gray('Tenant: ') + green(tenantName.padEnd(64)) + blue(' ║'));
|
|
@@ -175,15 +181,15 @@ class InteractiveShell {
|
|
|
175
181
|
pageSize: 10
|
|
176
182
|
}]);
|
|
177
183
|
|
|
178
|
-
//
|
|
184
|
+
// Show the submenu for the selected command
|
|
179
185
|
if (answer.command === '/db') {
|
|
180
|
-
this.
|
|
186
|
+
await this.handleDatabase('/db');
|
|
181
187
|
} else if (answer.command === '/secrets') {
|
|
182
|
-
this.
|
|
188
|
+
await this.handleSecrets('/secrets');
|
|
183
189
|
} else if (answer.command === '/keys') {
|
|
184
|
-
this.
|
|
190
|
+
await this.handleKeys('/keys');
|
|
185
191
|
} else if (answer.command === '/audit') {
|
|
186
|
-
this.
|
|
192
|
+
await this.handleAudit('/audit');
|
|
187
193
|
} else if (answer.command === '/help') {
|
|
188
194
|
this.showHelp();
|
|
189
195
|
} else if (answer.command === '/clear') {
|