UNPKG

@vigilbase/cli

Version:

Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.

125 lines (124 loc) • 7.09 kB
/** One's v1 API on api.vigilbase.com: the base every v1 operation path is relative to. */ export declare const DEFAULT_ONE_API_BASE_URL = "https://api.vigilbase.com/one/v1"; /** The Identity resource (token audience) of One's v1 API, linked to the CLI client. */ export declare const ONE_API_RESOURCE = "https://api.vigilbase.com/one"; export type CliConfig = { /** vigilbase.com (apps/com): local checkups, and the agent tools through `toolsApiUrl`. */ publicBaseUrl: string; /** Authenticated Vigilbase One origin (one.vigilbase.com / apps/one). */ oneBaseUrl: string; /** * One's v1 API base (`…/one/v1`), from --one-api-url / VIGILBASE_ONE_API_URL. Unset, it is * https://api.vigilbase.com/one/v1 for production One and `<one origin>/one/v1` for any other One. */ oneApiBaseUrl?: string; /** OAuth client_id for Better Auth device authorization. */ clientId: string; /** Explicit Identity issuer (--auth-url / VIGILBASE_AUTH_URL). One's discovery must name it; unset, only production Identity is trusted. */ identityBaseUrl?: string; authProvider?: import('../auth/provider.js').AuthProvider; /** * Directory for credentials and local config (~/.config/vigilbase). Not validated when the config is built: * the credential store rejects a relative path itself, so commands that never use it work whatever it holds. */ configDir: string; userAgent: string; timeoutMs: number; }; /** @deprecated Prefer `publicBaseUrl`. Kept for library callers. */ export type CliConfigLegacy = CliConfig & { baseUrl: string; }; export declare function parseOrigin(raw: string, option: string): string; /** Default request timeout; also used when library callers omit `timeoutMs`. */ export declare const DEFAULT_TIMEOUT_MS = 60000; /** localhost, 127.0.0.0/8 or [::1]: the hosts every origin option accepts for local development. */ export declare function isLoopbackHostname(hostname: string): boolean; export declare function resolvePublicBaseUrl(explicit?: string | null): string; /** The Tools API on the API host (`servers[0]` of the Tools OpenAPI document). */ export declare const TOOLS_API_URL = "https://api.vigilbase.com/tools/v1"; /** * Where the agent tools (catalog, execute, badges) are called. Production, * the default `--base-url`, uses the API host; any other origin (a local or * preview vigilbase.com) serves the same v1 paths under `/api/v1`. Local * checkups keep using `publicBaseUrl` itself. */ export declare function toolsApiUrl(config: Pick<CliConfig, 'publicBaseUrl'>): string; /** The Docs API (search and read docs.vigilbase.com), served only on the API host. */ export declare const DOCS_API_URL = "https://api.vigilbase.com/docs/v1"; /** * Where the docs commands call the Docs API: only api.vigilbase.com serves it * (a local or preview vigilbase.com has no `/docs/v1`), so any other * `--base-url` gives null and the command refuses before a request. */ export declare function docsApiUrl(config: Pick<CliConfig, 'publicBaseUrl'>): string | null; export declare function resolveOneBaseUrl(explicit?: string | null): string; /** Validate at transport boundaries too: library callers may construct config objects. */ export declare function validateOneOrigin(raw: string): string; /** * Validate a One v1 API base: an HTTP(S) URL (HTTP for loopback only) whose path ends in `/one/v1`, without * credentials, query or fragment. Returns it without a trailing slash. */ export declare function validateOneApiBase(raw: string): string; /** The v1 API base for a One origin when none is configured: api.vigilbase.com for production, One's own host otherwise. */ export declare function defaultOneApiBaseUrl(oneOrigin: string): string; /** The v1 API base a command calls: the configured one, else the default for its One origin. Checked again at use. */ export declare function oneApiBaseUrl(config: Pick<CliConfig, 'oneBaseUrl' | 'oneApiBaseUrl'>): string; /** * The api.vigilbase.com One resource for a One origin, as Identity derives it (configuredOneApiResource): * production One has https://api.vigilbase.com/one, a loopback One `<origin>/one`, and any other One * (staging) none. */ export declare function oneApiResource(oneOrigin: string): string | undefined; /** * The resources a token for this One may name: One's origin (what CLI 0.2.x requested) and, where it * exists, the API resource (what new sign-ins request). A token names exactly one of them. */ export declare function oneResources(oneOrigin: string): string[]; /** Production Identity: the only issuer trusted unless --auth-url / VIGILBASE_AUTH_URL names another. */ export declare const DEFAULT_IDENTITY_ISSUER = "https://auth.vigilbase.com"; /** Internal: accepted when named explicitly, but not offered to users (it isn't deployed publicly). */ export declare const STAGING_IDENTITY_ISSUER = "https://identity-staging.vigilbase.com"; export declare function resolveIdentityBaseUrl(raw: string): string; /** * The one Identity issuer this configuration trusts: --auth-url / VIGILBASE_AUTH_URL * when set, otherwise production. Staging is trusted only when configured explicitly. * Validated here too because library callers may construct config objects. */ export declare function trustedIdentityIssuer(config: Pick<CliConfig, 'oneBaseUrl' | 'identityBaseUrl'>): string; export declare function resolveClientId(explicit?: string | null): string; /** Why a config directory that isn't absolute was refused, naming the variable it came from. */ export declare function relativeConfigDirProblem(configDir: string, env?: NodeJS.ProcessEnv): { reason: string; remedy: string; }; /** The config directory, which must be absolute. */ export declare function resolveConfigDir(explicit?: string | null, env?: NodeJS.ProcessEnv): string; export declare function createConfig(options?: { baseUrl?: string | null; publicBaseUrl?: string | null; oneBaseUrl?: string | null; oneApiBaseUrl?: string | null; clientId?: string | null; identityBaseUrl?: string | null; configDir?: string | null; timeoutMs?: number; /** * Which origins to validate now; both by default. The CLI leaves out those a command never contacts, so a bad * value for them cannot fail it. Every One and Identity transport validates its origin again at use. */ checkOrigins?: { public: boolean; one: boolean; }; }): CliConfigLegacy; /** * Config for `vigilbase local …` and `vigilbase cloudflare-checkup`. Local * checkups resolve their own submit origin (resolveSubmitOrigin) and never * read VIGILBASE_* URLs. They resolve the config directory themselves, and * only when they need it (the managed cf install, the default snapshot path), * so malformed values cannot block offline commands such as `inspect`. */ export declare function createLocalCommandConfig(timeoutMs?: number): CliConfigLegacy; /** Back-compat helper used by older call sites / tests. */ export declare function resolveBaseUrl(explicit?: string | null): string;