galaxytus 1.0.0 → 1.0.1

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 (2) hide show
  1. package/index.js +26 -19
  2. package/package.json +1 -1
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
- // URL API Pusat
14
- const API_URL = 'http://localhost:3000/api/v1/scan';
13
+ // Gunakan domain asli lu pas rilis, atau fallback ke localhost pas dev
14
+ const BASE_URL = process.env.GALAXYTUS_URL || 'http://localhost:3000'; // NANTI GANTI PAKE DOMAIN LU
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.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
- // ─── COMMAND: LOGOUT ───
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('http://localhost:3000/api/v1/project', {
117
+ const response = await fetch(API_PROJECT_URL, {
113
118
  method: 'POST',
114
119
  headers: {
115
120
  'Authorization': `Bearer ${apiKey}`,
@@ -124,12 +129,11 @@ 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
  console.log(chalk.cyan('\n➜ Silakan generate API Key baru di: https://dashboard.galaxytus.ai'));
@@ -137,7 +141,6 @@ program
137
141
  process.exit(1);
138
142
  }
139
143
 
140
- // Error biasa
141
144
  console.log(chalk.yellow('Alasan:'), data.error);
142
145
  process.exit(1);
143
146
  }
@@ -167,7 +170,15 @@ program
167
170
 
168
171
  const { apiKey } = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
169
172
 
170
- console.log(chalk.hex('#4ade80').bold('\n[ G A L A X Y T U S A I ]\n'));
173
+ // --- ASCII GALAXY LOGO ---
174
+ console.log('');
175
+ console.log(chalk.hex('#8b5cf6')(' . * . . * * .'));
176
+ console.log(chalk.hex('#a855f7')(' * . ') + chalk.hex('#0ea5e9').bold(',_') + chalk.hex('#a855f7')(' . * .'));
177
+ console.log(chalk.hex('#d946ef')(' . * ') + chalk.hex('#38bdf8').bold('.\' `.') + chalk.hex('#d946ef')(' * . *'));
178
+ console.log(chalk.hex('#ec4899')(' * ') + chalk.hex('#06b6d4').bold('-( ✦ )-') + chalk.hex('#ec4899')(' . *'));
179
+ console.log(chalk.hex('#f43f5e')(' . ') + chalk.hex('#38bdf8').bold('`._.\'') + chalk.hex('#f43f5e')(' * .'));
180
+ console.log(chalk.hex('#60a5fa').bold('\n [ G A L A X Y T U S A I ]\n'));
181
+ // -------------------------
171
182
 
172
183
  const currentFolder = process.cwd();
173
184
  const folderName = path.basename(currentFolder);
@@ -192,20 +203,18 @@ program
192
203
  const spinner = ora('Mengirim kode ke markas Galaxytus dan membangunkan AI...').start();
193
204
 
194
205
  try {
195
- const response = await fetch(API_URL, {
206
+ const response = await fetch(API_SCAN_URL, {
196
207
  method: 'POST',
197
208
  headers: {
198
209
  'Authorization': `Bearer ${apiKey}`,
199
210
  'Content-Type': 'application/json'
200
211
  },
201
- body: JSON.stringify({
212
+ body: JSON.stringify({
202
213
  projectId: projectId,
203
-
204
- // 🚀 FIX: Sesuaikan nama parameter dengan backend!
205
214
  targetUrl: `local://${currentFolder}`,
206
215
  sourceType: 'local_cli',
207
-
208
- sourceCode: sourceCodeData
216
+ sourceCode: sourceCodeData
217
+ })
209
218
  });
210
219
 
211
220
  const data = await response.json();
@@ -214,12 +223,11 @@ program
214
223
  spinner.fail(chalk.red('Pemindaian Gagal'));
215
224
 
216
225
  // --- LOGIKA BARU: AUTO-LOGOUT KALAU EXPIRED ---
217
- if (response.status === 403 && data.error.includes("kedaluwarsa")) {
226
+ if (response.status === 403 && data.error && data.error.includes("kedaluwarsa")) {
218
227
  console.log(chalk.yellow('\n⚠ PERINGATAN KEAMANAN:'));
219
228
  console.log('API Key Anda telah kedaluwarsa (Batas 30 Hari).');
220
229
  console.log('Sesi Anda di komputer ini telah dihapus otomatis untuk keamanan.');
221
230
 
222
- // Hancurkan kunci dari komputer (Auto-Logout)
223
231
  if (fs.existsSync(CONFIG_PATH)) fs.unlinkSync(CONFIG_PATH);
224
232
 
225
233
  console.log(chalk.cyan('\n➜ Silakan generate API Key baru di: https://dashboard.galaxytus.ai'));
@@ -227,7 +235,6 @@ program
227
235
  process.exit(1);
228
236
  }
229
237
 
230
- // Error biasa
231
238
  console.log(chalk.yellow('Alasan:'), data.error);
232
239
  process.exit(1);
233
240
  }
@@ -245,4 +252,4 @@ program
245
252
  }
246
253
  });
247
254
 
248
- program.parse(process.argv);
255
+ program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "galaxytus",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Galaxytus AI Security Agent CLI",
5
5
  "main": "index.js",
6
6
  "bin": {