@nourmohamed/vaultix-cli 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/bin/cli.js +43 -11
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -32,33 +32,65 @@ async function run() {
|
|
|
32
32
|
console.error('\x1b[31m[Error]\x1b[0m Please provide your API key: vaultix login vtx_your_key');
|
|
33
33
|
process.exit(1);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
|
|
36
|
+
const newConfig = { ...config, apiKey: key };
|
|
37
|
+
|
|
38
|
+
// Auto-detect URL from smart token vtx_BASE64URL_HASH
|
|
39
|
+
const parts = key.split('_');
|
|
40
|
+
if (parts.length === 3 && parts[0] === 'vtx') {
|
|
41
|
+
try {
|
|
42
|
+
const decodedUrl = Buffer.from(parts[1], 'base64').toString('utf8');
|
|
43
|
+
if (decodedUrl.startsWith('http')) {
|
|
44
|
+
newConfig.baseUrl = decodedUrl;
|
|
45
|
+
console.log(`\x1b[36m[Auto-Config]\x1b[0m Detected Platform URL: ${decodedUrl}`);
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
// Fallback to existing or default
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
saveConfig(newConfig);
|
|
53
|
+
console.log('\x1b[32m[Success]\x1b[0m Authenticated successfully.');
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (command === 'config') {
|
|
58
|
+
const key = args[1];
|
|
59
|
+
const val = args[2];
|
|
60
|
+
if (!key || !val) {
|
|
61
|
+
console.log('\x1b[33mUsage:\x1b[0m vaultix config <key> <value>');
|
|
62
|
+
console.log('Available keys: baseUrl');
|
|
63
|
+
console.log(`Current Config: ${JSON.stringify(config, null, 2)}`);
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
config[key] = val;
|
|
67
|
+
saveConfig(config);
|
|
68
|
+
console.log(`\x1b[32m[Success]\x1b[0m Config ${key} updated.`);
|
|
37
69
|
process.exit(0);
|
|
38
70
|
}
|
|
39
71
|
|
|
40
72
|
if (!command) {
|
|
41
73
|
console.error(`
|
|
42
|
-
\x1b[
|
|
43
|
-
----------------
|
|
74
|
+
\x1b[36m--- Vaultix CLI v1.0.2 ---\x1b[0m
|
|
44
75
|
Steps to get started:
|
|
45
|
-
1. \x1b[33mvaultix login <API_KEY
|
|
46
|
-
2. \x1b[33mvaultix list\x1b[0m
|
|
47
|
-
3. \x1b[33mvaultix get <NAME>\x1b[0m
|
|
76
|
+
1. \x1b[33mvaultix login <API_KEY> [URL]\x1b[0m (Authenticates your machine)
|
|
77
|
+
2. \x1b[33mvaultix list\x1b[0m (Shows your secrets)
|
|
78
|
+
3. \x1b[33mvaultix get <NAME>\x1b[0m (Retrieves a secret)
|
|
48
79
|
|
|
49
|
-
|
|
50
|
-
vaultix login <KEY>
|
|
80
|
+
Commands:
|
|
81
|
+
vaultix login <KEY> [URL]
|
|
51
82
|
vaultix get <NAME>
|
|
52
83
|
vaultix list
|
|
53
84
|
vaultix set <NAME> <VALUE>
|
|
54
85
|
vaultix delete <NAME>
|
|
86
|
+
vaultix config baseUrl <URL>
|
|
55
87
|
`);
|
|
56
88
|
process.exit(1);
|
|
57
89
|
}
|
|
58
90
|
|
|
59
|
-
const { apiKey } = loadConfig();
|
|
91
|
+
const { apiKey, baseUrl: configUrl } = loadConfig();
|
|
60
92
|
const token = process.env.VAULTIX_API_KEY || apiKey;
|
|
61
|
-
const baseUrl = process.env.VAULTIX_URL || 'http://localhost:3000';
|
|
93
|
+
const baseUrl = process.env.VAULTIX_URL || configUrl || 'http://localhost:3000';
|
|
62
94
|
|
|
63
95
|
if (!token) {
|
|
64
96
|
console.error(`\x1b[31m[Error]\x1b[0m No API key found.`);
|