korext 0.9.9 → 0.9.10

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/bin/korext.js +50 -5
  2. package/package.json +1 -1
package/bin/korext.js CHANGED
@@ -367,7 +367,7 @@ program
367
367
  program
368
368
  .command('login [token]')
369
369
  .description('Authenticate with the Korext platform using a personal access token')
370
- .action((tokenArg) => {
370
+ .action(async (tokenArg) => {
371
371
  let token = tokenArg;
372
372
  if (!token) {
373
373
  console.log(`\nTo authenticate, sign in at ${chalk.cyan('https://app.korext.com')} and use your session token.`);
@@ -377,10 +377,31 @@ program
377
377
  console.log(`\nThen run: ${chalk.green('korext login <your-token>')}\n`);
378
378
  process.exit(1);
379
379
  }
380
- const config = getConfig();
381
- config.token = token;
382
- saveConfig(config);
383
- console.log(chalk.green('✔ Successfully logged in and saved token.'));
380
+ // Validate token with the server before saving
381
+ const spinner = ora('Validating token...').start();
382
+ try {
383
+ const res = await fetch(`${API_URL}/api/ide/status`, {
384
+ headers: { Authorization: `Bearer ${token}` },
385
+ signal: AbortSignal.timeout(8000),
386
+ });
387
+ if (res.ok) {
388
+ const config = getConfig();
389
+ config.token = token;
390
+ saveConfig(config);
391
+ const data = await res.json().catch(() => ({}));
392
+ spinner.succeed(chalk.green(`Authenticated as ${data.workspace || 'developer'}. Token saved.`));
393
+ } else {
394
+ spinner.fail(chalk.red('Invalid or expired token. Not saved.'));
395
+ console.log(chalk.dim(`\nSign in at ${chalk.cyan('https://app.korext.com')} to get a valid token.`));
396
+ process.exit(1);
397
+ }
398
+ } catch (e) {
399
+ // Network error: save token optimistically but warn
400
+ const config = getConfig();
401
+ config.token = token;
402
+ saveConfig(config);
403
+ spinner.warn(chalk.yellow('Could not reach server to validate token. Token saved (will be verified on next command).'));
404
+ }
384
405
  });
385
406
 
386
407
  program
@@ -823,6 +844,22 @@ program
823
844
  // Priority 1: User explicitly passed --pack
824
845
  packIds = options.pack.split(',').map(s => s.trim()).filter(Boolean);
825
846
  packSource = 'flag';
847
+
848
+ // Validate pack IDs against cached definitions
849
+ const valDefs = getRuleDefinitionsCache();
850
+ if (valDefs && valDefs.packs) {
851
+ const unknownPacks = packIds.filter(pid => !valDefs.packs[pid]);
852
+ if (unknownPacks.length > 0) {
853
+ if (isText) {
854
+ console.error(chalk.red(`\n✖ Unknown pack ID${unknownPacks.length > 1 ? 's' : ''}: ${unknownPacks.join(', ')}`));
855
+ console.error(chalk.dim(` Run ${chalk.green('korext packs list')} to see available packs.`));
856
+ console.error(chalk.dim(` Run ${chalk.green('korext rules sync')} to update cached definitions.\n`));
857
+ } else {
858
+ console.error(JSON.stringify({ error: `Unknown pack ID(s): ${unknownPacks.join(', ')}` }));
859
+ }
860
+ process.exit(1);
861
+ }
862
+ }
826
863
  } else if (options.industry) {
827
864
  // Priority 2: --industry (and optional --region) flags
828
865
  const taxonomy = tryBuildTaxonomy();
@@ -958,6 +995,14 @@ program
958
995
  console.log(chalk.dim(`Run ${chalk.green('korext login')} to authenticate for unlimited CI/CD analytics.\n`));
959
996
  }
960
997
 
998
+ // BUG-002 fix: Warn when --sign is used without valid auth
999
+ if (options.sign && !token) {
1000
+ if (isText) {
1001
+ console.log(chalk.red('⚠ --sign requires authentication. Proof bundles will not be signed.'));
1002
+ console.log(chalk.dim(` Run ${chalk.green('korext login <token>')} first, then retry with --sign.\n`));
1003
+ }
1004
+ }
1005
+
961
1006
  const report = {
962
1007
  version,
963
1008
  packId: Array.isArray(pack) ? pack[0] : pack,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korext",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "mcpName": "io.github.Korext/governance",
5
5
  "description": "Korext Command Line Interface",
6
6
  "type": "module",