fullcourtdefense-cli 1.3.0 → 1.3.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/dist/api.d.ts +13 -0
- package/dist/api.js +4 -1
- package/dist/commands/configure.d.ts +3 -0
- package/dist/commands/configure.js +36 -4
- package/dist/commands/discover.d.ts +2 -0
- package/dist/commands/discover.js +285 -154
- package/dist/commands/discoverAgentFiles.d.ts +15 -0
- package/dist/commands/discoverAgentFiles.js +204 -0
- package/dist/commands/discoverBlastRadius.d.ts +30 -0
- package/dist/commands/discoverBlastRadius.js +139 -0
- package/dist/commands/discoverSecrets.d.ts +24 -0
- package/dist/commands/discoverSecrets.js +286 -0
- package/dist/commands/hook.js +9 -27
- package/dist/commands/installAll.d.ts +11 -0
- package/dist/commands/installAll.js +55 -0
- package/dist/commands/installCursorHook.js +16 -27
- package/dist/commands/mcpGateway.d.ts +23 -0
- package/dist/commands/mcpGateway.js +313 -67
- package/dist/config.d.ts +26 -0
- package/dist/config.js +92 -16
- package/dist/index.js +191 -120
- package/dist/version.json +3 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -91,6 +91,14 @@ export interface ApiError {
|
|
|
91
91
|
code?: string;
|
|
92
92
|
remaining?: number;
|
|
93
93
|
}
|
|
94
|
+
export interface SetupValidationResponse {
|
|
95
|
+
organizationId: string;
|
|
96
|
+
organizationName: string;
|
|
97
|
+
shieldId: string;
|
|
98
|
+
shieldName: string;
|
|
99
|
+
shieldKeyRequired: boolean;
|
|
100
|
+
gatewayMode: boolean;
|
|
101
|
+
}
|
|
94
102
|
export declare class BotGuardApi {
|
|
95
103
|
private apiUrl;
|
|
96
104
|
private apiKey;
|
|
@@ -100,4 +108,9 @@ export declare class BotGuardApi {
|
|
|
100
108
|
getScanStatus(jobId: string): Promise<AsyncJobResponse>;
|
|
101
109
|
pollUntilDone(jobId: string, intervalMs?: number, maxWaitMs?: number): Promise<ScanResult>;
|
|
102
110
|
getCredits(): Promise<CreditsResponse>;
|
|
111
|
+
validateSetup(input: {
|
|
112
|
+
organizationId?: string;
|
|
113
|
+
shieldId: string;
|
|
114
|
+
shieldKey?: string;
|
|
115
|
+
}): Promise<SetupValidationResponse>;
|
|
103
116
|
}
|
package/dist/api.js
CHANGED
|
@@ -22,7 +22,7 @@ class BotGuardApi {
|
|
|
22
22
|
const data = await resp.json();
|
|
23
23
|
if (!resp.ok || data.success === false) {
|
|
24
24
|
const err = data;
|
|
25
|
-
const msg = err.error || `API error (${resp.status})
|
|
25
|
+
const msg = err.code ? `${err.error} (${err.code})` : (err.error || `API error (${resp.status})`);
|
|
26
26
|
if (err.code === 'CREDITS_EXHAUSTED') {
|
|
27
27
|
throw new Error(`No scan credits remaining this month. Upgrade your plan at https://fullcourtdefense.ai/pricing`);
|
|
28
28
|
}
|
|
@@ -58,5 +58,8 @@ class BotGuardApi {
|
|
|
58
58
|
async getCredits() {
|
|
59
59
|
return this.request('GET', '/api/cicd/credits');
|
|
60
60
|
}
|
|
61
|
+
async validateSetup(input) {
|
|
62
|
+
return this.request('POST', '/api/cicd/setup/validate', input);
|
|
63
|
+
}
|
|
61
64
|
}
|
|
62
65
|
exports.BotGuardApi = BotGuardApi;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { BotGuardConfig } from '../config';
|
|
2
2
|
export interface ConfigureArgs {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
organizationId?: string;
|
|
3
5
|
shieldId?: string;
|
|
4
6
|
shieldKey?: string;
|
|
5
7
|
apiUrl?: string;
|
|
8
|
+
skipValidate?: boolean;
|
|
6
9
|
}
|
|
7
10
|
export declare function configureCommand(args: ConfigureArgs, config: BotGuardConfig): Promise<void>;
|
|
@@ -36,23 +36,55 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.configureCommand = configureCommand;
|
|
37
37
|
const readline = __importStar(require("readline/promises"));
|
|
38
38
|
const process_1 = require("process");
|
|
39
|
+
const api_1 = require("../api");
|
|
39
40
|
const config_1 = require("../config");
|
|
40
41
|
async function ask(rl, question, fallback) {
|
|
41
42
|
const suffix = fallback ? ` (${fallback})` : '';
|
|
42
43
|
const answer = (await rl.question(`${question}${suffix}: `)).trim();
|
|
43
44
|
return answer || fallback || '';
|
|
44
45
|
}
|
|
46
|
+
function resolveApiKey(args, config) {
|
|
47
|
+
return args.apiKey || config.apiKey || process.env.FULLCOURTDEFENSE_API_KEY || '';
|
|
48
|
+
}
|
|
45
49
|
async function configureCommand(args, config) {
|
|
46
50
|
const rl = readline.createInterface({ input: process_1.stdin, output: process_1.stdout });
|
|
47
51
|
try {
|
|
52
|
+
const apiUrl = args.apiUrl || await ask(rl, 'FullCourtDefense API URL', config.apiUrl || 'https://api.fullcourtdefense.ai');
|
|
53
|
+
const apiKey = resolveApiKey(args, config) || await ask(rl, 'Organization API key (from Settings → API Keys)', '');
|
|
54
|
+
if (!apiKey) {
|
|
55
|
+
throw new Error('Organization API key is required to validate your setup.');
|
|
56
|
+
}
|
|
57
|
+
const organizationId = args.organizationId || await ask(rl, 'Organization ID (from Settings → Organization)', config.organizationId || '');
|
|
58
|
+
if (!organizationId) {
|
|
59
|
+
throw new Error('Organization ID is required.');
|
|
60
|
+
}
|
|
48
61
|
const shieldId = args.shieldId || await ask(rl, 'Shield ID', config.shieldId || 'sh_...');
|
|
49
62
|
if (!shieldId || shieldId === 'sh_...') {
|
|
50
63
|
throw new Error('Shield ID is required.');
|
|
51
64
|
}
|
|
52
|
-
const shieldKey = args.shieldKey
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
const shieldKey = args.shieldKey ?? await ask(rl, 'Shield key if locked, blank if not required', config.shieldKey || '');
|
|
66
|
+
if (args.skipValidate !== true) {
|
|
67
|
+
console.log('Validating organization, Shield ID, and Shield key against FullCourtDefense...');
|
|
68
|
+
const api = new api_1.BotGuardApi(apiKey, apiUrl);
|
|
69
|
+
const validated = await api.validateSetup({
|
|
70
|
+
organizationId,
|
|
71
|
+
shieldId,
|
|
72
|
+
shieldKey: shieldKey || undefined,
|
|
73
|
+
});
|
|
74
|
+
if (validated.organizationId !== organizationId) {
|
|
75
|
+
throw new Error(`Organization mismatch: API key belongs to "${validated.organizationName}" (${validated.organizationId}), not "${organizationId}".`);
|
|
76
|
+
}
|
|
77
|
+
console.log(`Verified: ${validated.organizationName} → Shield "${validated.shieldName}" (${validated.shieldId})`);
|
|
78
|
+
}
|
|
79
|
+
const savedPath = (0, config_1.saveSetupConfig)({
|
|
80
|
+
apiKey,
|
|
81
|
+
organizationId,
|
|
82
|
+
shieldId,
|
|
83
|
+
shieldKey: shieldKey || undefined,
|
|
84
|
+
apiUrl,
|
|
85
|
+
});
|
|
86
|
+
console.log(`Saved setup to ${savedPath}`);
|
|
87
|
+
console.log('All other CLI commands (install, discover --upload, scan, hooks) will use these credentials automatically.');
|
|
56
88
|
}
|
|
57
89
|
finally {
|
|
58
90
|
rl.close();
|