UNPKG

@vigilbase/cli

Version:

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

65 lines (64 loc) • 5.72 kB
export declare const LOCAL_ERROR_CODES: readonly ["NODE_UNSUPPORTED", "CWD_UNAVAILABLE", "CF_NOT_FOUND", "CF_WRONG_BINARY", "CF_UNSUPPORTED_VERSION", "CF_ALLOWLIST_MISMATCH", "CF_INSTALL_FAILED", "CF_AUTH_REQUIRED", "CF_PERMISSION_DENIED", "CF_RATE_LIMITED", "CF_ERROR", "CANCELLED", "ACCOUNT_SELECTION_REQUIRED", "ACCOUNT_NOT_VISIBLE", "ACCOUNT_TOO_LARGE", "ACCOUNT_MISMATCH", "OUTPUT_EXISTS", "SNAPSHOT_INVALID", "SNAPSHOT_TOO_LARGE", "SNAPSHOT_STALE", "SNAPSHOT_SECRET_LIKE_VALUE", "EMAIL_INVALID", "EMAIL_CODE_INVALID", "VERIFICATION_INVALID", "VERIFICATION_EXPIRED", "SESSION_INVALID", "SESSION_EXPIRED", "SESSION_USED", "SESSION_BUSY", "SESSION_CLOSED", "SUBMIT_ORIGIN_UNTRUSTED", "CONFIRMATION_REQUIRED", "CLI_UPGRADE_REQUIRED", "LOCAL_MODE_DISABLED", "VIGILBASE_RATE_LIMITED", "VIGILBASE_CHALLENGED", "SUBMIT_FAILED"]; export type LocalCheckupErrorCode = (typeof LOCAL_ERROR_CODES)[number]; /** LOCAL_MODE_DISABLED: the browser checkup on the origin the CLI talks to (vigilbase.com, or a loopback dev server). */ export declare function browserCheckupHint(origin: string): string; /** One fix per code; shown after the error and in `--json` as `hint`. */ export declare const LOCAL_ERROR_HINTS: Record<LocalCheckupErrorCode, string>; /** * CF_AUTH_REQUIRED in env mode (`--cf-auth env`, or `auto` with the variable * set): the browser sign-in is never offered while the token is used, so the * hint names both ways out. */ export declare const ENV_TOKEN_AUTH_HINT = "Set CLOUDFLARE_API_TOKEN in this shell to a valid read-only Cloudflare API token (read -rs CLOUDFLARE_API_TOKEN && export CLOUDFLARE_API_TOKEN) and run the same command again, or unset it (or use --cf-auth profile) to sign in with your browser instead."; /** SNAPSHOT_INVALID for an `inspect` or `submit` path with no file: nothing to collect again, so how to make one. */ export declare const SNAPSHOT_MISSING_HINT = "Check the file path. To collect a snapshot into a file, run `npx @vigilbase/cli cloudflare-checkup collect --out <file>`."; /** SNAPSHOT_INVALID for a file that cannot be read: its permissions, not its contents. */ export declare const SNAPSHOT_UNREADABLE_HINT = "Check the permissions of the file and of its directories, or copy it somewhere you can read it."; /** * A snapshot file that cannot be uploaded, from a command that only reads it * (inspect, submit, or the re-read before the one command uploads): running * that command again reads the same file, so how to collect a fresh one. */ export declare const SNAPSHOT_INVALID_FILE_HINT = "The file is not a valid snapshot. Collect a fresh one with `npx @vigilbase/cli cloudflare-checkup` (or `npx @vigilbase/cli cloudflare-checkup collect --out <file>`)."; export declare const SNAPSHOT_STALE_FILE_HINT = "Snapshots are accepted for 24 hours. Collect a fresh one with `npx @vigilbase/cli cloudflare-checkup` (or `npx @vigilbase/cli cloudflare-checkup collect --out <file>`)."; export declare const SNAPSHOT_SECRET_FILE_HINT = "Remove the credential-like value from your Cloudflare settings. Collect a fresh one with `npx @vigilbase/cli cloudflare-checkup` (or `npx @vigilbase/cli cloudflare-checkup collect --out <file>`)."; /** CF_NOT_FOUND from the advanced commands (and `--cf-bin`), which never install cf. */ export declare const CF_NOT_FOUND_ADVANCED_HINT = "Run `npx @vigilbase/cli cloudflare-checkup` without --cf-bin (it can install cf), install cf with `npm install --global cf@1.0.0-beta.13`, or pass --cf-bin <path> to a cf package."; /** CF_WRONG_BINARY when a cf package was found but `cf --version` fails. */ export declare const CF_DAMAGED_HINT = "Reinstall cf with `npm install --global cf@1.0.0-beta.13`, or run `npx @vigilbase/cli cloudflare-checkup` without --cf-bin and let it install the tested cf."; /** CF_PERMISSION_DENIED in env mode: the token lacks a read permission; the browser sign-in is the other way out. */ export declare const ENV_TOKEN_PERMISSION_HINT = "The API token in CLOUDFLARE_API_TOKEN cannot read everything the checkup needs. Add the read permissions to it, or unset it (or use --cf-auth profile) to sign in with your browser instead, then run the same command again."; export declare class LocalCheckupError extends Error { readonly code: LocalCheckupErrorCode; readonly hint: string; /** HTTP status of the Cloudflare or Vigilbase response, when one caused the error. */ readonly status?: number; readonly retryAfterSec?: number; constructor(code: LocalCheckupErrorCode, message: string, options?: { hint?: string; status?: number; retryAfterSec?: number; }); /** Mapped to exit code 2 by `runCli`. */ get isRateLimited(): boolean; } export declare function isLocalCheckupError(error: unknown): error is LocalCheckupError; /** The signals that cancel a cf run or the cf install, and the exit code each gives (128 + its number). */ export declare const CANCEL_EXIT_CODES: Readonly<{ readonly SIGINT: 130; readonly SIGTERM: 143; readonly SIGHUP: 129; }>; export type CancelSignal = keyof typeof CANCEL_EXIT_CODES; export declare const CANCEL_SIGNALS: CancelSignal[]; /** Where cancellation is heard: the process, or a plain emitter in tests. */ export type CancelSignalSource = { on(event: CancelSignal, listener: () => void): unknown; removeListener(event: CancelSignal, listener: () => void): unknown; }; /** CANCELLED: cf (or npm) was stopped and its files removed; `runCli` exits with `exitCode` and prints no result. */ export declare class CheckupCancelledError extends LocalCheckupError { readonly signal: CancelSignal; readonly exitCode: (typeof CANCEL_EXIT_CODES)[CancelSignal]; constructor(signal: CancelSignal); }