@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
118 lines (117 loc) • 5.4 kB
TypeScript
import { type DpopAuthentication } from '../auth/dpop.js';
import type { Operation, OperationOutput } from '../vendor/api-contract/core/operation.js';
import { type V1Input } from './one-v1.js';
/**
* Vigilbase One authenticated API client.
* Public (unauthenticated) tools stay on VigilbaseClient / vigilbase.com.
*/
import type { AgentToolDefinition } from '../types.js';
import type { CliConfig } from './config.js';
export type OneToolExecuteResponse = {
success: boolean;
error?: string;
/** `scan_unassessed`: the scanner ran but could not assess the target. */
code?: string;
data?: {
toolRunId?: string;
status?: string;
grade?: string | null;
gradeScore?: number | null;
result?: Record<string, unknown> | null;
};
};
export type OneSessionResponse = {
session?: Record<string, unknown> | null;
user?: {
id?: string;
email?: string | null;
name?: string | null;
} | null;
};
type ApiErrorBody = {
error?: string;
message?: string;
success?: boolean;
};
/**
* Tools that require Vigilbase One authentication (auth-required scanners).
* Keep preference order aligned with `@vigilbase/tools` catalog
* (`requiresAuthentication: true` entries in VIGILBASE_TOOLS).
* Public agent tools remain available without login via vigilbase.com.
*/
export declare const ONE_AUTH_REQUIRED_TOOLS: readonly ["website-security", "react2shell", "fortibleed-check"];
export type OneAuthRequiredTool = (typeof ONE_AUTH_REQUIRED_TOOLS)[number];
export declare function isOneAuthRequiredTool(toolName: string): toolName is OneAuthRequiredTool;
/** Static catalog entries for auth-required tools (not listed on the public agent API). */
export declare const ONE_AUTH_REQUIRED_TOOL_DEFINITIONS: Record<OneAuthRequiredTool, AgentToolDefinition>;
export declare function resolveToolDefinition(toolName: string, publicTools: AgentToolDefinition[], oneBaseUrl: string): AgentToolDefinition | null;
/** Tools executable through One's authenticated `/api/tools/{tool}/execute` bridge. */
export declare const ONE_EXECUTABLE_TOOLS: readonly ["security-headers", "email-security", "website-security", "react2shell", "fortibleed-check"];
export declare function isOneExecutableTool(toolName: string): boolean;
export declare class VigilbaseOneClient {
private readonly config;
private accessToken;
private readonly managed;
private readonly auth?;
/** The userinfo endpoint Identity discovery named for the last getSession, if it used Identity. */
userinfoEndpoint?: string;
constructor(config: CliConfig, accessToken: string, managed?: boolean, auth?: DpopAuthentication | undefined);
private authentication;
private request;
/**
* A fetch for the contract client over the CLI's own transport (timeout, size bound, no redirects). A
* successful answer that isn't JSON (a proxy's sign-in page) fails as INVALID_RESPONSE, like the legacy
* paths; 204, 205 and 304 carry no body. `seen` keeps the last answer for its Retry-After.
*/
private v1Fetch;
/**
* Call a One v1 operation on the v1 base (oneApiBaseUrl: api.vigilbase.com/one/v1 by default) with the same
* token as the legacy /api paths: One accepts either One audience on every host. A managed sign-in is
* refreshed first, and once more after a 401. Every operation the CLI calls answers JSON.
*/
callV1<const O extends Operation>(op: O, input: V1Input<O>): Promise<OperationOutput<O> & {
requestId: string | null;
headers: Headers;
}>;
/** Authenticated JSON transport shared by the One command clients. */
requestJson<T extends ApiErrorBody = Record<string, unknown>>(path: string, init?: RequestInit, options?: {
allowStatuses?: number[];
/** Whether the request names a customer outside the query string (a JSON body). */
hasCustomerScope?: boolean;
}): Promise<T>;
getSession(): Promise<OneSessionResponse>;
getAccount(): Promise<Record<string, unknown>>;
getAccountServices(): Promise<Record<string, unknown>>;
getAccountOrganization(): Promise<Record<string, unknown>>;
getAccountEndpoints(): Promise<Record<string, unknown>>;
getAccountSessions(): Promise<Record<string, unknown>>;
getAccountInvitations(): Promise<Record<string, unknown>>;
createAccountInvitation(input: {
email: string;
role?: string;
}): Promise<Record<string, unknown>>;
getAccountBilling(): Promise<Record<string, unknown>>;
createBillingPortal(): Promise<{
success: boolean;
url?: string;
}>;
getWatchdogTargets(): Promise<Record<string, unknown>>;
getWatchdogScans(options?: {
targetId?: string;
limit?: number;
}): Promise<Record<string, unknown>>;
getCloudflareZones(): Promise<Record<string, unknown>>;
getCloudflareCheckups(options?: {
accountId?: string;
}): Promise<Record<string, unknown>>;
startCloudflareCheckup(options?: {
accountId?: string;
}): Promise<Record<string, unknown>>;
listToolRuns(options?: {
toolName?: string;
limit?: number;
}): Promise<Record<string, unknown>>;
getToolRun(id: string): Promise<Record<string, unknown>>;
executeTool(toolName: string, target: string): Promise<OneToolExecuteResponse>;
}
export {};