@trading-boy/cli 1.2.8 → 1.2.9

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.
@@ -45742,7 +45742,7 @@ function registerInfraCommand(program2) {
45742
45742
  // dist/commands/login.js
45743
45743
  init_source();
45744
45744
  var logger19 = createLogger("cli-login");
45745
- var API_KEY_PATTERN = /^tb_(live|test)_[a-f0-9]{32}$/;
45745
+ var API_KEY_PATTERN = /^tb_(live|test|free)_[a-f0-9]{32}$/;
45746
45746
  function validateApiKeyFormat(key) {
45747
45747
  return API_KEY_PATTERN.test(key);
45748
45748
  }
@@ -45750,8 +45750,11 @@ async function verifyApiKey(apiKey) {
45750
45750
  const apiBase = getApiBase();
45751
45751
  const response = await fetch(`${apiBase}/api/v1/auth/verify`, {
45752
45752
  method: "POST",
45753
- headers: { "Content-Type": "application/json" },
45754
- body: JSON.stringify({ apiKey })
45753
+ headers: {
45754
+ "Content-Type": "application/json",
45755
+ "Authorization": `Bearer ${apiKey}`
45756
+ },
45757
+ body: "{}"
45755
45758
  });
45756
45759
  if (!response.ok) {
45757
45760
  if (response.status === 401) {
@@ -45782,7 +45785,7 @@ async function executeLogin(apiKey) {
45782
45785
  };
45783
45786
  }
45784
45787
  function registerLoginCommand(program2) {
45785
- program2.command("login").description("Authenticate with your Trading Boy API key").option("--api-key <key>", "API key for CI/CD (prefer TRADING_BOY_API_KEY env var to avoid shell history exposure)").action(async (opts) => {
45788
+ program2.command("login").description("Authenticate with your Trading Boy API key").addOption(new Option("--api-key <key>", "API key (deprecated \u2014 use TRADING_BOY_API_KEY env var)").hideHelp()).action(async (opts) => {
45786
45789
  try {
45787
45790
  let apiKey;
45788
45791
  if (opts.apiKey) {
@@ -45801,14 +45804,14 @@ function registerLoginCommand(program2) {
45801
45804
  if (!input)
45802
45805
  return "API key is required";
45803
45806
  if (!validateApiKeyFormat(input)) {
45804
- return "Invalid key format. Expected: tb_live_<32hex> or tb_test_<32hex>";
45807
+ return "Invalid key format. Expected: tb_live_<32hex>, tb_test_<32hex>, or tb_free_<32hex>";
45805
45808
  }
45806
45809
  return true;
45807
45810
  }
45808
45811
  });
45809
45812
  }
45810
45813
  if (!validateApiKeyFormat(apiKey)) {
45811
- console.error(source_default.red(" Invalid key format. Expected: tb_live_<32hex> or tb_test_<32hex>"));
45814
+ console.error(source_default.red(" Invalid key format. Expected: tb_live_<32hex>, tb_test_<32hex>, or tb_free_<32hex>"));
45812
45815
  process.exitCode = 1;
45813
45816
  return;
45814
45817
  }
@@ -1,10 +1,11 @@
1
+ import { Option } from 'commander';
1
2
  import chalk from 'chalk';
2
3
  import { createLogger } from '@trading-boy/core';
3
4
  import { storeCredentials, redactApiKey } from '../credentials.js';
4
5
  import { getApiBase } from '../api-client.js';
5
6
  const logger = createLogger('cli-login');
6
7
  // ─── API Key Validation ───
7
- const API_KEY_PATTERN = /^tb_(live|test)_[a-f0-9]{32}$/;
8
+ const API_KEY_PATTERN = /^tb_(live|test|free)_[a-f0-9]{32}$/;
8
9
  export function validateApiKeyFormat(key) {
9
10
  return API_KEY_PATTERN.test(key);
10
11
  }
@@ -13,8 +14,11 @@ export async function verifyApiKey(apiKey) {
13
14
  const apiBase = getApiBase();
14
15
  const response = await fetch(`${apiBase}/api/v1/auth/verify`, {
15
16
  method: 'POST',
16
- headers: { 'Content-Type': 'application/json' },
17
- body: JSON.stringify({ apiKey }),
17
+ headers: {
18
+ 'Content-Type': 'application/json',
19
+ 'Authorization': `Bearer ${apiKey}`,
20
+ },
21
+ body: '{}',
18
22
  });
19
23
  if (!response.ok) {
20
24
  if (response.status === 401) {
@@ -53,7 +57,7 @@ export function registerLoginCommand(program) {
53
57
  program
54
58
  .command('login')
55
59
  .description('Authenticate with your Trading Boy API key')
56
- .option('--api-key <key>', 'API key for CI/CD (prefer TRADING_BOY_API_KEY env var to avoid shell history exposure)')
60
+ .addOption(new Option('--api-key <key>', 'API key (deprecated use TRADING_BOY_API_KEY env var)').hideHelp())
57
61
  .action(async (opts) => {
58
62
  try {
59
63
  let apiKey;
@@ -76,7 +80,7 @@ export function registerLoginCommand(program) {
76
80
  if (!input)
77
81
  return 'API key is required';
78
82
  if (!validateApiKeyFormat(input)) {
79
- return 'Invalid key format. Expected: tb_live_<32hex> or tb_test_<32hex>';
83
+ return 'Invalid key format. Expected: tb_live_<32hex>, tb_test_<32hex>, or tb_free_<32hex>';
80
84
  }
81
85
  return true;
82
86
  },
@@ -84,7 +88,7 @@ export function registerLoginCommand(program) {
84
88
  }
85
89
  // Validate format before making network request
86
90
  if (!validateApiKeyFormat(apiKey)) {
87
- console.error(chalk.red(' Invalid key format. Expected: tb_live_<32hex> or tb_test_<32hex>'));
91
+ console.error(chalk.red(' Invalid key format. Expected: tb_live_<32hex>, tb_test_<32hex>, or tb_free_<32hex>'));
88
92
  process.exitCode = 1;
89
93
  return;
90
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trading-boy/cli",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "Trading Boy CLI — crypto context intelligence for traders and AI agents",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,10 +16,17 @@
16
16
  "!dist/**/*.test.*",
17
17
  "!dist/**/*.map"
18
18
  ],
19
+ "scripts": {
20
+ "build": "tsc && node esbuild.config.js",
21
+ "typecheck": "tsc --noEmit",
22
+ "test": "vitest run",
23
+ "lint": "eslint src/",
24
+ "clean": "rm -rf dist .turbo"
25
+ },
19
26
  "dependencies": {
20
27
  "@inquirer/prompts": "~7.10.1",
21
28
  "@napi-rs/keyring": "~1.1.3",
22
- "@trading-boy/core": "~1.2.0",
29
+ "@trading-boy/core": "workspace:~1.2.0",
23
30
  "chalk": "~5.6.2",
24
31
  "commander": "~13.1.0",
25
32
  "open": "~10.2.0",
@@ -29,12 +36,5 @@
29
36
  "devDependencies": {
30
37
  "esbuild": "~0.27.4",
31
38
  "typescript": "^5.7.0"
32
- },
33
- "scripts": {
34
- "build": "tsc && node esbuild.config.js",
35
- "typecheck": "tsc --noEmit",
36
- "test": "vitest run",
37
- "lint": "eslint src/",
38
- "clean": "rm -rf dist .turbo"
39
39
  }
40
- }
40
+ }