galaxytus 1.0.0 ā 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/index.js +29 -20
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -10,8 +10,10 @@ import os from 'os';
|
|
|
10
10
|
// Tentukan lokasi penyimpanan API Key di komputer user (~/.galaxytus.json)
|
|
11
11
|
const CONFIG_PATH = path.join(os.homedir(), '.galaxytus.json');
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
const
|
|
13
|
+
// š DOMAIN CLOUD RUN LU UDAH DIPASANG DI SINI
|
|
14
|
+
const BASE_URL = process.env.GALAXYTUS_URL || 'https://galaxytus-web-259656672808.asia-southeast2.run.app';
|
|
15
|
+
const API_PROJECT_URL = `${BASE_URL}/api/cli/project`;
|
|
16
|
+
const API_SCAN_URL = `${BASE_URL}/api/cli/scan`;
|
|
15
17
|
|
|
16
18
|
// --- FUNGSI UTAMA: Menyedot isi file dengan Proteksi Memori (OOM) ---
|
|
17
19
|
function readProjectFiles(dir, fileList = []) {
|
|
@@ -58,7 +60,7 @@ const program = new Command();
|
|
|
58
60
|
program
|
|
59
61
|
.name('galaxytus')
|
|
60
62
|
.description('Galaxytus AI Security Agent CLI')
|
|
61
|
-
.version('1.0.
|
|
63
|
+
.version('1.0.1');
|
|
62
64
|
|
|
63
65
|
// āāā COMMAND: LOGIN āāā
|
|
64
66
|
program
|
|
@@ -68,12 +70,15 @@ program
|
|
|
68
70
|
.action((apiKey) => {
|
|
69
71
|
const config = { apiKey };
|
|
70
72
|
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
73
|
+
|
|
74
|
+
// BIKIN FILE JADI PRIVATE (Hanya pemilik komputer yang bisa baca)
|
|
71
75
|
fs.chmodSync(CONFIG_PATH, 0o600);
|
|
76
|
+
|
|
72
77
|
console.log(chalk.green('ā Berhasil!'), 'API Key telah disimpan dengan aman di komputer Anda.');
|
|
73
78
|
console.log(chalk.cyan('ā Ketik:'), chalk.bold('galaxytus scan <project_id>'), 'untuk mulai memindai.');
|
|
74
79
|
});
|
|
75
80
|
|
|
76
|
-
|
|
81
|
+
// āāā COMMAND: LOGOUT āāā
|
|
77
82
|
program
|
|
78
83
|
.command('logout')
|
|
79
84
|
.description('Hapus sesi login Galaxytus dari komputer ini')
|
|
@@ -109,7 +114,7 @@ program
|
|
|
109
114
|
const spinner = ora(`Mendaftarkan project '${projectName}' ke sistem Galaxytus...`).start();
|
|
110
115
|
|
|
111
116
|
try {
|
|
112
|
-
const response = await fetch(
|
|
117
|
+
const response = await fetch(API_PROJECT_URL, {
|
|
113
118
|
method: 'POST',
|
|
114
119
|
headers: {
|
|
115
120
|
'Authorization': `Bearer ${apiKey}`,
|
|
@@ -124,20 +129,19 @@ program
|
|
|
124
129
|
spinner.fail(chalk.red('Gagal mendaftar project'));
|
|
125
130
|
|
|
126
131
|
// --- LOGIKA BARU: AUTO-LOGOUT KALAU EXPIRED ---
|
|
127
|
-
if (response.status === 403 && data.error.includes("kedaluwarsa")) {
|
|
132
|
+
if (response.status === 403 && data.error && data.error.includes("kedaluwarsa")) {
|
|
128
133
|
console.log(chalk.yellow('\nā PERINGATAN KEAMANAN:'));
|
|
129
134
|
console.log('API Key Anda telah kedaluwarsa (Batas 30 Hari).');
|
|
130
135
|
console.log('Sesi Anda di komputer ini telah dihapus otomatis untuk keamanan.');
|
|
131
136
|
|
|
132
|
-
// Hancurkan kunci dari komputer (Auto-Logout)
|
|
133
137
|
if (fs.existsSync(CONFIG_PATH)) fs.unlinkSync(CONFIG_PATH);
|
|
134
138
|
|
|
135
|
-
|
|
139
|
+
// š URL DASHBOARD DIUPDATE
|
|
140
|
+
console.log(chalk.cyan(`\nā Silakan generate API Key baru di: ${BASE_URL}/dashboard`));
|
|
136
141
|
console.log('ā Lalu login kembali dengan perintah:', chalk.white.bold('galaxytus login <key_baru>'));
|
|
137
142
|
process.exit(1);
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
// Error biasa
|
|
141
145
|
console.log(chalk.yellow('Alasan:'), data.error);
|
|
142
146
|
process.exit(1);
|
|
143
147
|
}
|
|
@@ -167,7 +171,15 @@ program
|
|
|
167
171
|
|
|
168
172
|
const { apiKey } = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
169
173
|
|
|
170
|
-
|
|
174
|
+
// --- ASCII GALAXY LOGO ---
|
|
175
|
+
console.log('');
|
|
176
|
+
console.log(chalk.hex('#8b5cf6')(' . * . . * * .'));
|
|
177
|
+
console.log(chalk.hex('#a855f7')(' * . ') + chalk.hex('#0ea5e9').bold(',_') + chalk.hex('#a855f7')(' . * .'));
|
|
178
|
+
console.log(chalk.hex('#d946ef')(' . * ') + chalk.hex('#38bdf8').bold('.\' `.') + chalk.hex('#d946ef')(' * . *'));
|
|
179
|
+
console.log(chalk.hex('#ec4899')(' * ') + chalk.hex('#06b6d4').bold('-( ⦠)-') + chalk.hex('#ec4899')(' . *'));
|
|
180
|
+
console.log(chalk.hex('#f43f5e')(' . ') + chalk.hex('#38bdf8').bold('`._.\'') + chalk.hex('#f43f5e')(' * .'));
|
|
181
|
+
console.log(chalk.hex('#60a5fa').bold('\n [ G A L A X Y T U S A I ]\n'));
|
|
182
|
+
// -------------------------
|
|
171
183
|
|
|
172
184
|
const currentFolder = process.cwd();
|
|
173
185
|
const folderName = path.basename(currentFolder);
|
|
@@ -192,20 +204,18 @@ program
|
|
|
192
204
|
const spinner = ora('Mengirim kode ke markas Galaxytus dan membangunkan AI...').start();
|
|
193
205
|
|
|
194
206
|
try {
|
|
195
|
-
const response = await fetch(
|
|
207
|
+
const response = await fetch(API_SCAN_URL, {
|
|
196
208
|
method: 'POST',
|
|
197
209
|
headers: {
|
|
198
210
|
'Authorization': `Bearer ${apiKey}`,
|
|
199
211
|
'Content-Type': 'application/json'
|
|
200
212
|
},
|
|
201
|
-
|
|
213
|
+
body: JSON.stringify({
|
|
202
214
|
projectId: projectId,
|
|
203
|
-
|
|
204
|
-
// š FIX: Sesuaikan nama parameter dengan backend!
|
|
205
215
|
targetUrl: `local://${currentFolder}`,
|
|
206
216
|
sourceType: 'local_cli',
|
|
207
|
-
|
|
208
|
-
|
|
217
|
+
sourceCode: sourceCodeData
|
|
218
|
+
})
|
|
209
219
|
});
|
|
210
220
|
|
|
211
221
|
const data = await response.json();
|
|
@@ -214,20 +224,19 @@ program
|
|
|
214
224
|
spinner.fail(chalk.red('Pemindaian Gagal'));
|
|
215
225
|
|
|
216
226
|
// --- LOGIKA BARU: AUTO-LOGOUT KALAU EXPIRED ---
|
|
217
|
-
if (response.status === 403 && data.error.includes("kedaluwarsa")) {
|
|
227
|
+
if (response.status === 403 && data.error && data.error.includes("kedaluwarsa")) {
|
|
218
228
|
console.log(chalk.yellow('\nā PERINGATAN KEAMANAN:'));
|
|
219
229
|
console.log('API Key Anda telah kedaluwarsa (Batas 30 Hari).');
|
|
220
230
|
console.log('Sesi Anda di komputer ini telah dihapus otomatis untuk keamanan.');
|
|
221
231
|
|
|
222
|
-
// Hancurkan kunci dari komputer (Auto-Logout)
|
|
223
232
|
if (fs.existsSync(CONFIG_PATH)) fs.unlinkSync(CONFIG_PATH);
|
|
224
233
|
|
|
225
|
-
|
|
234
|
+
// š URL DASHBOARD DIUPDATE
|
|
235
|
+
console.log(chalk.cyan(`\nā Silakan generate API Key baru di: ${BASE_URL}/dashboard`));
|
|
226
236
|
console.log('ā Lalu login kembali dengan perintah:', chalk.white.bold('galaxytus login <key_baru>'));
|
|
227
237
|
process.exit(1);
|
|
228
238
|
}
|
|
229
239
|
|
|
230
|
-
// Error biasa
|
|
231
240
|
console.log(chalk.yellow('Alasan:'), data.error);
|
|
232
241
|
process.exit(1);
|
|
233
242
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "galaxytus",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Galaxytus AI Security Agent CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"gemini",
|
|
17
17
|
"cli"
|
|
18
18
|
],
|
|
19
|
-
"author": "
|
|
19
|
+
"author": "Dean Jagadita Ahmad Monsi",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"chalk": "^4.1.2",
|