@vigilbase/cli 0.2.0 → 0.2.1
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/CLOUDFLARE.md +2 -5
- package/COMMANDS.md +150 -112
- package/LOCAL.md +73 -83
- package/ONE.md +2 -4
- package/README.md +337 -171
- package/SECURITY.md +2 -2
- package/dist/auth/device-auth.d.ts +0 -1
- package/dist/auth/device-auth.js +6 -5
- package/dist/auth/index.d.ts +1 -2
- package/dist/auth/index.js +1 -2
- package/dist/auth/provider.d.ts +1 -1
- package/dist/auth/provider.js +16 -7
- package/dist/auth/refresh.d.ts +23 -4
- package/dist/auth/refresh.js +78 -22
- package/dist/auth/store.d.ts +78 -4
- package/dist/auth/store.js +385 -74
- package/dist/auth/token-metadata.d.ts +0 -1
- package/dist/auth/token-metadata.js +0 -1
- package/dist/auth/types.d.ts +0 -1
- package/dist/auth/types.js +0 -1
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +0 -1
- package/dist/cli.d.ts +4 -2
- package/dist/cli.js +7 -8
- package/dist/commands/account.d.ts +0 -1
- package/dist/commands/account.js +0 -1
- package/dist/commands/auth.d.ts +0 -1
- package/dist/commands/auth.js +69 -21
- package/dist/commands/billing.d.ts +0 -1
- package/dist/commands/billing.js +0 -1
- package/dist/commands/cloudflare.d.ts +1 -2
- package/dist/commands/cloudflare.js +6 -6
- package/dist/commands/helpers.d.ts +0 -1
- package/dist/commands/helpers.js +0 -1
- package/dist/commands/index.d.ts +0 -1
- package/dist/commands/index.js +0 -1
- package/dist/commands/legacy-validation.d.ts +0 -1
- package/dist/commands/legacy-validation.js +0 -1
- package/dist/commands/local.d.ts +6 -1
- package/dist/commands/local.js +34 -11
- package/dist/commands/one.d.ts +0 -1
- package/dist/commands/one.js +6 -7
- package/dist/commands/public-tools.d.ts +0 -1
- package/dist/commands/public-tools.js +52 -18
- package/dist/commands/runs.d.ts +0 -1
- package/dist/commands/runs.js +0 -1
- package/dist/commands/security.d.ts +1 -2
- package/dist/commands/security.js +1 -2
- package/dist/commands/watchdog.d.ts +0 -1
- package/dist/commands/watchdog.js +0 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -2
- package/dist/lib/banner.d.ts +0 -1
- package/dist/lib/banner.js +0 -1
- package/dist/lib/client.d.ts +4 -2
- package/dist/lib/client.js +42 -18
- package/dist/lib/cloudflare-client.d.ts +0 -1
- package/dist/lib/cloudflare-client.js +0 -1
- package/dist/lib/config.d.ts +16 -3
- package/dist/lib/config.js +41 -14
- package/dist/lib/format.d.ts +2 -1
- package/dist/lib/format.js +19 -8
- package/dist/lib/help.d.ts +1 -2
- package/dist/lib/help.js +29 -18
- package/dist/lib/network.d.ts +10 -1
- package/dist/lib/network.js +31 -4
- package/dist/lib/one-client.d.ts +2 -1
- package/dist/lib/one-client.js +3 -1
- package/dist/lib/one-operations.d.ts +0 -1
- package/dist/lib/one-operations.js +0 -1
- package/dist/lib/open-url.d.ts +0 -1
- package/dist/lib/open-url.js +0 -1
- package/dist/lib/platform.d.ts +2 -0
- package/dist/lib/platform.js +4 -0
- package/dist/lib/progress.d.ts +0 -1
- package/dist/lib/progress.js +0 -1
- package/dist/lib/security-client.d.ts +0 -1
- package/dist/lib/security-client.js +0 -1
- package/dist/lib/skill-fetch.d.ts +0 -1
- package/dist/lib/skill-fetch.js +0 -1
- package/dist/lib/system-trust.d.ts +0 -1
- package/dist/lib/system-trust.js +0 -1
- package/dist/lib/tui.d.ts +0 -1
- package/dist/lib/tui.js +0 -1
- package/dist/local/cloudflare-checkup/cf/allowlist.d.ts +0 -1
- package/dist/local/cloudflare-checkup/cf/allowlist.js +0 -1
- package/dist/local/cloudflare-checkup/cf/auth-lifecycle.d.ts +0 -1
- package/dist/local/cloudflare-checkup/cf/auth-lifecycle.js +0 -1
- package/dist/local/cloudflare-checkup/cf/child-env.d.ts +0 -1
- package/dist/local/cloudflare-checkup/cf/child-env.js +0 -1
- package/dist/local/cloudflare-checkup/cf/install.d.ts +0 -1
- package/dist/local/cloudflare-checkup/cf/install.js +0 -1
- package/dist/local/cloudflare-checkup/cf/locate.d.ts +0 -1
- package/dist/local/cloudflare-checkup/cf/locate.js +0 -1
- package/dist/local/cloudflare-checkup/cf/run-cf.d.ts +0 -1
- package/dist/local/cloudflare-checkup/cf/run-cf.js +0 -1
- package/dist/local/cloudflare-checkup/collector.d.ts +0 -1
- package/dist/local/cloudflare-checkup/collector.js +0 -1
- package/dist/local/cloudflare-checkup/contract.d.ts +14 -3
- package/dist/local/cloudflare-checkup/contract.js +9 -3
- package/dist/local/cloudflare-checkup/email-verification.d.ts +0 -1
- package/dist/local/cloudflare-checkup/email-verification.js +0 -1
- package/dist/local/cloudflare-checkup/errors.d.ts +2 -1
- package/dist/local/cloudflare-checkup/errors.js +6 -2
- package/dist/local/cloudflare-checkup/output.d.ts +0 -1
- package/dist/local/cloudflare-checkup/output.js +0 -1
- package/dist/local/cloudflare-checkup/prompts.d.ts +0 -1
- package/dist/local/cloudflare-checkup/prompts.js +0 -1
- package/dist/local/cloudflare-checkup/rate-budget.d.ts +0 -1
- package/dist/local/cloudflare-checkup/rate-budget.js +0 -1
- package/dist/local/cloudflare-checkup/snapshot-file.d.ts +0 -1
- package/dist/local/cloudflare-checkup/snapshot-file.js +0 -1
- package/dist/local/cloudflare-checkup/submit-client.d.ts +19 -5
- package/dist/local/cloudflare-checkup/submit-client.js +63 -17
- package/dist/local/cloudflare-checkup/terminal-ui.d.ts +0 -1
- package/dist/local/cloudflare-checkup/terminal-ui.js +0 -1
- package/dist/types.d.ts +25 -3
- package/dist/types.js +16 -1
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -1
- package/package.json +5 -9
- package/dist/auth/device-auth.d.ts.map +0 -1
- package/dist/auth/device-auth.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/provider.d.ts.map +0 -1
- package/dist/auth/provider.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/store.d.ts.map +0 -1
- package/dist/auth/store.js.map +0 -1
- package/dist/auth/token-metadata.d.ts.map +0 -1
- package/dist/auth/token-metadata.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/account.d.ts.map +0 -1
- package/dist/commands/account.js.map +0 -1
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/billing.d.ts.map +0 -1
- package/dist/commands/billing.js.map +0 -1
- package/dist/commands/cloudflare.d.ts.map +0 -1
- package/dist/commands/cloudflare.js.map +0 -1
- package/dist/commands/helpers.d.ts.map +0 -1
- package/dist/commands/helpers.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/legacy-validation.d.ts.map +0 -1
- package/dist/commands/legacy-validation.js.map +0 -1
- package/dist/commands/local.d.ts.map +0 -1
- package/dist/commands/local.js.map +0 -1
- package/dist/commands/one.d.ts.map +0 -1
- package/dist/commands/one.js.map +0 -1
- package/dist/commands/public-tools.d.ts.map +0 -1
- package/dist/commands/public-tools.js.map +0 -1
- package/dist/commands/runs.d.ts.map +0 -1
- package/dist/commands/runs.js.map +0 -1
- package/dist/commands/security.d.ts.map +0 -1
- package/dist/commands/security.js.map +0 -1
- package/dist/commands/watchdog.d.ts.map +0 -1
- package/dist/commands/watchdog.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/banner.d.ts.map +0 -1
- package/dist/lib/banner.js.map +0 -1
- package/dist/lib/client.d.ts.map +0 -1
- package/dist/lib/client.js.map +0 -1
- package/dist/lib/cloudflare-client.d.ts.map +0 -1
- package/dist/lib/cloudflare-client.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/format.d.ts.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/help.d.ts.map +0 -1
- package/dist/lib/help.js.map +0 -1
- package/dist/lib/network.d.ts.map +0 -1
- package/dist/lib/network.js.map +0 -1
- package/dist/lib/one-client.d.ts.map +0 -1
- package/dist/lib/one-client.js.map +0 -1
- package/dist/lib/one-operations.d.ts.map +0 -1
- package/dist/lib/one-operations.js.map +0 -1
- package/dist/lib/open-url.d.ts.map +0 -1
- package/dist/lib/open-url.js.map +0 -1
- package/dist/lib/progress.d.ts.map +0 -1
- package/dist/lib/progress.js.map +0 -1
- package/dist/lib/security-client.d.ts.map +0 -1
- package/dist/lib/security-client.js.map +0 -1
- package/dist/lib/skill-fetch.d.ts.map +0 -1
- package/dist/lib/skill-fetch.js.map +0 -1
- package/dist/lib/system-trust.d.ts.map +0 -1
- package/dist/lib/system-trust.js.map +0 -1
- package/dist/lib/tui.d.ts.map +0 -1
- package/dist/lib/tui.js.map +0 -1
- package/dist/local/cloudflare-checkup/cf/allowlist.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/cf/allowlist.js.map +0 -1
- package/dist/local/cloudflare-checkup/cf/auth-lifecycle.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/cf/auth-lifecycle.js.map +0 -1
- package/dist/local/cloudflare-checkup/cf/child-env.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/cf/child-env.js.map +0 -1
- package/dist/local/cloudflare-checkup/cf/install.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/cf/install.js.map +0 -1
- package/dist/local/cloudflare-checkup/cf/locate.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/cf/locate.js.map +0 -1
- package/dist/local/cloudflare-checkup/cf/run-cf.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/cf/run-cf.js.map +0 -1
- package/dist/local/cloudflare-checkup/collector.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/collector.js.map +0 -1
- package/dist/local/cloudflare-checkup/contract.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/contract.js.map +0 -1
- package/dist/local/cloudflare-checkup/email-verification.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/email-verification.js.map +0 -1
- package/dist/local/cloudflare-checkup/errors.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/errors.js.map +0 -1
- package/dist/local/cloudflare-checkup/output.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/output.js.map +0 -1
- package/dist/local/cloudflare-checkup/prompts.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/prompts.js.map +0 -1
- package/dist/local/cloudflare-checkup/rate-budget.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/rate-budget.js.map +0 -1
- package/dist/local/cloudflare-checkup/snapshot-file.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/snapshot-file.js.map +0 -1
- package/dist/local/cloudflare-checkup/submit-client.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/submit-client.js.map +0 -1
- package/dist/local/cloudflare-checkup/terminal-ui.d.ts.map +0 -1
- package/dist/local/cloudflare-checkup/terminal-ui.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -387,5 +387,4 @@ export const handleSecurity = async (ctx) => {
|
|
|
387
387
|
display(ctx, request, payload);
|
|
388
388
|
return ok();
|
|
389
389
|
};
|
|
390
|
-
export const SECURITY_HELP = "vigilbase security \u2014 managed security in Vigilbase One\n\n [overview]\n incidents [list]
|
|
391
|
-
//# sourceMappingURL=security.js.map
|
|
390
|
+
export const SECURITY_HELP = "vigilbase security \u2014 managed security in Vigilbase One\n\n [overview]\n incidents [list] --status --severity --attack-category\n --order-by --order-direction --limit --offset\n incidents show <id>\n incidents timeline <id> --limit --before\n incidents fabric <id> --dataset --min-weight --limit\n incidents share-links <id>\n incidents update <id> <status> --confirm [--note]\n alerts [list] --limit --asset-id --start\n alerts show <id>\n logs --limit --asset-id --provider --dataset --search\n --start --end --sort --frs-min --cursor\n audit --limit --cursor --action-prefix --outcome\n assets\n assets <allowlist|blocklist|remediation|autonomy|datasets> <asset-id>\n assets graph <asset-id> --dataset --hours --min-weight --limit\n fabric default-asset\n detections --asset-id\n providers\n connections [list]\n connections show <id>\n connections <available-assets|remediation> <id>\n connections <logpush-status|worker-stats> <connection-id> <job-id>\n analytics [overview] --metrics + time-window flags\n analytics <security-analysis|bot-activity|top-attacker-ips|bot-asns|dns-security|page-shield>\n analytics provider-events --provider --dataset --start --end\n [--asset-id --search --limit]\n zero-trust <device-health|app-tests|access|sessions|device-posture>\n zero-trust gateway <dns|http|network>\n cloudflare-account [inventory]\n cloudflare-account <audit|ingestion|posture>\n notifications [list] --limit\n notifications <settings|preferences|slack-channels>\n reports [list] --limit --offset\n reports show <id>\n reports settings\n intel quota\n intel <ip|asn|cidr|ja3|ja4> <query>\n settings <lifecycle-emails|broadcast-emails|applications>\n\nTime-window flags: --hours (1\u2013720, default 24) or --start/--end ISO timestamps;\noptional --asset-id. Apply to analytics (except provider-events), zero-trust,\nand cloudflare-account audit/ingestion/posture. Inventory has no window flags.\nLimits: list incidents/reports/audit 1\u2013100 (default 50); alerts/notifications\n1\u2013100 (default 100); timeline 1\u2013200 (default 100); logs 1\u20131000 (default 100);\nprovider-events 1\u2013500 (default 200); graph 1\u20131000 (default 200).\nOffsets: 0\u20131000000. Graph min-weight: 1\u20131000000 (default 1).\nAll: --json, --timeout <ms>, --customer-id <One customer UUID> (internal View-as).\nAll operations read data except confirmed incident status updates.\nUpdate status: acknowledged, mitigating, resolved, false_positive.\nSee SECURITY.md for every endpoint, supported value, alias, and pagination contract.\n";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export { runCli, CLI_VERSION } from './cli.js';
|
|
2
2
|
export { VigilbaseClient, VigilbaseApiError } from './lib/client.js';
|
|
3
3
|
export { createConfig, resolveBaseUrl, resolvePublicBaseUrl, resolveOneBaseUrl, } from './lib/config.js';
|
|
4
|
-
export { discoverAuthProvider, identityProvider, managedAccessToken, revokeSavedCredentials, clearOneCredentials, credentialsPath, DeviceAuthError, getOneAccessToken, readCredentials, requestDeviceCode, waitForDeviceAuthorization, writeOneCredentials, } from './auth/index.js';
|
|
4
|
+
export { discoverAuthProvider, identityProvider, managedAccessToken, revokeSavedCredentials, clearOneCredentials, credentialsPath, DeviceAuthError, getOneAccessToken, identityCredentialsPath, readCredentials, requestDeviceCode, waitForDeviceAuthorization, writeOneCredentials, } from './auth/index.js';
|
|
5
5
|
export { isOneAuthRequiredTool, isOneExecutableTool, ONE_AUTH_REQUIRED_TOOLS, ONE_AUTH_REQUIRED_TOOL_DEFINITIONS, ONE_EXECUTABLE_TOOLS, VigilbaseOneClient, } from './lib/one-client.js';
|
|
6
6
|
export { EXIT } from './types.js';
|
|
7
|
-
export type { AgentToolDefinition, AgentToolExecuteResponse, AgentToolsCatalogResponse, CliOutputMode, ExitCode, } from './types.js';
|
|
7
|
+
export type { AgentApiError, AgentApiErrorCode, AgentApiErrorResponse, AgentToolDefinition, AgentToolExecuteResponse, AgentToolsCatalogResponse, CliOutputMode, ExitCode, } from './types.js';
|
|
8
8
|
export type { AuthProvider } from './auth/provider.js';
|
|
9
9
|
export type { CredentialsFile, OneCredentials } from './auth/types.js';
|
|
10
10
|
export { CloudflareClient } from './lib/cloudflare-client.js';
|
|
11
11
|
export type { CloudflareScope, WorkspaceSection } from './lib/cloudflare-client.js';
|
|
12
12
|
export { SecurityClient } from './lib/security-client.js';
|
|
13
13
|
export type { SecurityPayload, SecurityQuery, SecurityRequest } from './lib/security-client.js';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { runCli, CLI_VERSION } from './cli.js';
|
|
2
2
|
export { VigilbaseClient, VigilbaseApiError } from './lib/client.js';
|
|
3
3
|
export { createConfig, resolveBaseUrl, resolvePublicBaseUrl, resolveOneBaseUrl, } from './lib/config.js';
|
|
4
|
-
export { discoverAuthProvider, identityProvider, managedAccessToken, revokeSavedCredentials, clearOneCredentials, credentialsPath, DeviceAuthError, getOneAccessToken, readCredentials, requestDeviceCode, waitForDeviceAuthorization, writeOneCredentials, } from './auth/index.js';
|
|
4
|
+
export { discoverAuthProvider, identityProvider, managedAccessToken, revokeSavedCredentials, clearOneCredentials, credentialsPath, DeviceAuthError, getOneAccessToken, identityCredentialsPath, readCredentials, requestDeviceCode, waitForDeviceAuthorization, writeOneCredentials, } from './auth/index.js';
|
|
5
5
|
export { isOneAuthRequiredTool, isOneExecutableTool, ONE_AUTH_REQUIRED_TOOLS, ONE_AUTH_REQUIRED_TOOL_DEFINITIONS, ONE_EXECUTABLE_TOOLS, VigilbaseOneClient, } from './lib/one-client.js';
|
|
6
6
|
export { EXIT } from './types.js';
|
|
7
7
|
export { CloudflareClient } from './lib/cloudflare-client.js';
|
|
8
8
|
export { SecurityClient } from './lib/security-client.js';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/dist/lib/banner.d.ts
CHANGED
package/dist/lib/banner.js
CHANGED
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentToolExecuteResponse, type AgentToolsCatalogResponse } from '../types.js';
|
|
2
2
|
import type { CliConfig } from './config.js';
|
|
3
3
|
export declare class VigilbaseApiError extends Error {
|
|
4
4
|
readonly status: number;
|
|
5
5
|
readonly body: unknown;
|
|
6
6
|
readonly retryAfterSec?: number;
|
|
7
7
|
readonly code?: string;
|
|
8
|
+
/** The server's sanitised explanation, set only for known vigilbase.com problem errors. */
|
|
9
|
+
readonly reason?: string;
|
|
8
10
|
constructor(message: string, options: {
|
|
9
11
|
status: number;
|
|
10
12
|
body?: unknown;
|
|
11
13
|
retryAfterSec?: number;
|
|
12
14
|
code?: string;
|
|
15
|
+
reason?: string;
|
|
13
16
|
});
|
|
14
17
|
}
|
|
15
18
|
export declare function retryAfterSeconds(response: Response, body: unknown): number | undefined;
|
|
@@ -27,4 +30,3 @@ export declare class VigilbaseClient {
|
|
|
27
30
|
fetchSkillMarkdown(skillUrl: string): Promise<string>;
|
|
28
31
|
badgeUrl(domain: string, style?: 'default' | 'compact' | 'mini'): string;
|
|
29
32
|
}
|
|
30
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/lib/client.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { singleLine } from './format.js';
|
|
2
3
|
import { parseJsonResponse, requestText } from './network.js';
|
|
3
4
|
import { fetchSkillText } from './skill-fetch.js';
|
|
5
|
+
import { AGENT_API_ERROR_CODES, } from '../types.js';
|
|
4
6
|
export class VigilbaseApiError extends Error {
|
|
5
7
|
status;
|
|
6
8
|
body;
|
|
7
9
|
retryAfterSec;
|
|
8
10
|
code;
|
|
11
|
+
/** The server's sanitised explanation, set only for known vigilbase.com problem errors. */
|
|
12
|
+
reason;
|
|
9
13
|
constructor(message, options) {
|
|
10
14
|
super(message);
|
|
11
15
|
this.name = 'VigilbaseApiError';
|
|
@@ -13,6 +17,7 @@ export class VigilbaseApiError extends Error {
|
|
|
13
17
|
this.body = options.body;
|
|
14
18
|
this.retryAfterSec = options.retryAfterSec;
|
|
15
19
|
this.code = options.code;
|
|
20
|
+
this.reason = options.reason;
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
export function retryAfterSeconds(response, body) {
|
|
@@ -30,6 +35,39 @@ export function retryAfterSeconds(response, body) {
|
|
|
30
35
|
}
|
|
31
36
|
return undefined;
|
|
32
37
|
}
|
|
38
|
+
/** Longer messages are withheld rather than cut. */
|
|
39
|
+
const MAX_REASON_SOURCE_LENGTH = 1000;
|
|
40
|
+
const problemSchema = z.object({
|
|
41
|
+
error: z.object({ code: z.unknown(), message: z.string().max(MAX_REASON_SOURCE_LENGTH) }),
|
|
42
|
+
code: z.unknown(),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* The reason a vigilbase.com problem+json error gives, when its code is one com sends.
|
|
46
|
+
* Anything else stays redacted: other media types, unknown codes, odd messages.
|
|
47
|
+
*/
|
|
48
|
+
function problemReason(response, body) {
|
|
49
|
+
const mediaType = response.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase();
|
|
50
|
+
if (mediaType !== 'application/problem+json')
|
|
51
|
+
return undefined;
|
|
52
|
+
const problem = problemSchema.safeParse(body);
|
|
53
|
+
if (!problem.success)
|
|
54
|
+
return undefined;
|
|
55
|
+
const code = z.enum(AGENT_API_ERROR_CODES).safeParse(problem.data.error.code ?? problem.data.code);
|
|
56
|
+
if (!code.success)
|
|
57
|
+
return undefined;
|
|
58
|
+
const message = singleLine(problem.data.error.message);
|
|
59
|
+
return message ? { code: code.data, message } : undefined;
|
|
60
|
+
}
|
|
61
|
+
function publicApiError(fallback, response, body) {
|
|
62
|
+
const reason = problemReason(response, body);
|
|
63
|
+
return new VigilbaseApiError(reason?.message ?? fallback, {
|
|
64
|
+
status: response.status,
|
|
65
|
+
body,
|
|
66
|
+
retryAfterSec: retryAfterSeconds(response, body),
|
|
67
|
+
code: reason?.code,
|
|
68
|
+
reason: reason?.message,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
33
71
|
/**
|
|
34
72
|
* Public (unauthenticated) vigilbase.com tools client.
|
|
35
73
|
* Vigilbase One authenticated calls will use a separate client + device-auth tokens.
|
|
@@ -57,12 +95,7 @@ export class VigilbaseClient {
|
|
|
57
95
|
async listTools() {
|
|
58
96
|
const { response, body } = await this.request('/api/agent/tools');
|
|
59
97
|
if (!response.ok) {
|
|
60
|
-
|
|
61
|
-
throw new VigilbaseApiError(message, {
|
|
62
|
-
status: response.status,
|
|
63
|
-
body,
|
|
64
|
-
retryAfterSec: retryAfterSeconds(response, body),
|
|
65
|
-
});
|
|
98
|
+
throw publicApiError(`Failed to list tools (HTTP ${response.status})`, response, body);
|
|
66
99
|
}
|
|
67
100
|
const schema = z.object({
|
|
68
101
|
success: z.literal(true),
|
|
@@ -84,24 +117,16 @@ export class VigilbaseClient {
|
|
|
84
117
|
});
|
|
85
118
|
const parsed = (body ?? {});
|
|
86
119
|
if (response.status === 429) {
|
|
87
|
-
throw
|
|
88
|
-
status: 429,
|
|
89
|
-
body: parsed,
|
|
90
|
-
retryAfterSec: retryAfterSeconds(response, body),
|
|
91
|
-
});
|
|
120
|
+
throw publicApiError('Rate limit exceeded. Retry after the indicated delay.', response, parsed);
|
|
92
121
|
}
|
|
93
122
|
if (!response.ok && response.status !== 422) {
|
|
94
|
-
throw
|
|
95
|
-
status: response.status,
|
|
96
|
-
body: parsed,
|
|
97
|
-
retryAfterSec: retryAfterSeconds(response, body),
|
|
98
|
-
});
|
|
123
|
+
throw publicApiError(`Tool execution failed (HTTP ${response.status})`, response, parsed);
|
|
99
124
|
}
|
|
100
125
|
if (!z.object({ success: z.boolean() }).passthrough().safeParse(body).success) {
|
|
101
126
|
throw new VigilbaseApiError('Invalid tool execution response. Check the API URL or retry later.', { status: response.status });
|
|
102
127
|
}
|
|
103
128
|
if (!parsed.success) {
|
|
104
|
-
throw
|
|
129
|
+
throw publicApiError('Tool execution was unsuccessful.', response, body);
|
|
105
130
|
}
|
|
106
131
|
return parsed;
|
|
107
132
|
}
|
|
@@ -116,4 +141,3 @@ export class VigilbaseClient {
|
|
|
116
141
|
return `${this.origin}/api/badge/${encodeURIComponent(domain)}${query ? `?${query}` : ''}`;
|
|
117
142
|
}
|
|
118
143
|
}
|
|
119
|
-
//# sourceMappingURL=client.js.map
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -5,10 +5,13 @@ export type CliConfig = {
|
|
|
5
5
|
oneBaseUrl: string;
|
|
6
6
|
/** OAuth client_id for Better Auth device authorization. */
|
|
7
7
|
clientId: string;
|
|
8
|
-
/** Explicit
|
|
8
|
+
/** Explicit Identity issuer (--auth-url / VIGILBASE_AUTH_URL). One's discovery must name it; unset, only production Identity is trusted. */
|
|
9
9
|
identityBaseUrl?: string;
|
|
10
10
|
authProvider?: import('../auth/provider.js').AuthProvider;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Directory for credentials and local config (~/.config/vigilbase). Not validated when the config is built:
|
|
13
|
+
* the credential store rejects a relative path itself, so commands that never use it work whatever it holds.
|
|
14
|
+
*/
|
|
12
15
|
configDir: string;
|
|
13
16
|
userAgent: string;
|
|
14
17
|
timeoutMs: number;
|
|
@@ -17,14 +20,25 @@ export type CliConfig = {
|
|
|
17
20
|
export type CliConfigLegacy = CliConfig & {
|
|
18
21
|
baseUrl: string;
|
|
19
22
|
};
|
|
23
|
+
export declare function parseOrigin(raw: string, option: string): string;
|
|
20
24
|
/** Default request timeout; also used when library callers omit `timeoutMs`. */
|
|
21
25
|
export declare const DEFAULT_TIMEOUT_MS = 60000;
|
|
22
26
|
export declare function resolvePublicBaseUrl(explicit?: string | null): string;
|
|
23
27
|
export declare function resolveOneBaseUrl(explicit?: string | null): string;
|
|
24
28
|
/** Validate at transport boundaries too: library callers may construct config objects. */
|
|
25
29
|
export declare function validateOneOrigin(raw: string): string;
|
|
30
|
+
/** Production Identity: the only issuer trusted unless --auth-url / VIGILBASE_AUTH_URL names another. */
|
|
31
|
+
export declare const DEFAULT_IDENTITY_ISSUER = "https://auth.vigilbase.com";
|
|
32
|
+
export declare const STAGING_IDENTITY_ISSUER = "https://identity-staging.vigilbase.com";
|
|
26
33
|
export declare function resolveIdentityBaseUrl(raw: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* The one Identity issuer this configuration trusts: --auth-url / VIGILBASE_AUTH_URL
|
|
36
|
+
* when set, otherwise production. Staging is trusted only when configured explicitly.
|
|
37
|
+
* Validated here too because library callers may construct config objects.
|
|
38
|
+
*/
|
|
39
|
+
export declare function trustedIdentityIssuer(config: Pick<CliConfig, 'oneBaseUrl' | 'identityBaseUrl'>): string;
|
|
27
40
|
export declare function resolveClientId(explicit?: string | null): string;
|
|
41
|
+
/** The config directory, which must be absolute. */
|
|
28
42
|
export declare function resolveConfigDir(explicit?: string | null, env?: NodeJS.ProcessEnv): string;
|
|
29
43
|
export declare function createConfig(options?: {
|
|
30
44
|
baseUrl?: string | null;
|
|
@@ -45,4 +59,3 @@ export declare function createConfig(options?: {
|
|
|
45
59
|
export declare function createLocalCommandConfig(timeoutMs?: number): CliConfigLegacy;
|
|
46
60
|
/** Back-compat helper used by older call sites / tests. */
|
|
47
61
|
export declare function resolveBaseUrl(explicit?: string | null): string;
|
|
48
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/lib/config.js
CHANGED
|
@@ -9,7 +9,7 @@ const DEFAULT_CLIENT_ID = 'vigilbase-cli';
|
|
|
9
9
|
const originSchema = z.string().url().transform((raw) => new URL(raw)).refine((url) => (url.protocol === 'https:' || url.protocol === 'http:') &&
|
|
10
10
|
!url.username && !url.password &&
|
|
11
11
|
/^\/+$/.test(url.pathname) && !url.search && !url.hash, 'Expected an HTTP(S) origin without credentials, a path, query, or fragment.').transform((url) => url.origin);
|
|
12
|
-
function parseOrigin(raw, option) {
|
|
12
|
+
export function parseOrigin(raw, option) {
|
|
13
13
|
const result = originSchema.safeParse(raw);
|
|
14
14
|
if (!result.success) {
|
|
15
15
|
// Do not echo the input: malformed URLs can contain credentials.
|
|
@@ -44,10 +44,32 @@ export function validateOneOrigin(raw) {
|
|
|
44
44
|
}
|
|
45
45
|
return origin;
|
|
46
46
|
}
|
|
47
|
+
/** Production Identity: the only issuer trusted unless --auth-url / VIGILBASE_AUTH_URL names another. */
|
|
48
|
+
export const DEFAULT_IDENTITY_ISSUER = 'https://auth.vigilbase.com';
|
|
49
|
+
export const STAGING_IDENTITY_ISSUER = 'https://identity-staging.vigilbase.com';
|
|
50
|
+
const IDENTITY_OPTION = '--auth-url / VIGILBASE_AUTH_URL';
|
|
51
|
+
function isIdentityLoopback(origin) {
|
|
52
|
+
return ['localhost', '127.0.0.1', '[::1]'].includes(new URL(origin).hostname);
|
|
53
|
+
}
|
|
47
54
|
export function resolveIdentityBaseUrl(raw) {
|
|
48
|
-
const origin =
|
|
49
|
-
if (
|
|
50
|
-
throw new Error(
|
|
55
|
+
const origin = parseOrigin(raw, IDENTITY_OPTION);
|
|
56
|
+
if (origin !== DEFAULT_IDENTITY_ISSUER && origin !== STAGING_IDENTITY_ISSUER && !isIdentityLoopback(origin)) {
|
|
57
|
+
throw new Error(`${IDENTITY_OPTION} must be ${DEFAULT_IDENTITY_ISSUER}, ${STAGING_IDENTITY_ISSUER} or a loopback development origin.`);
|
|
58
|
+
}
|
|
59
|
+
return origin;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The one Identity issuer this configuration trusts: --auth-url / VIGILBASE_AUTH_URL
|
|
63
|
+
* when set, otherwise production. Staging is trusted only when configured explicitly.
|
|
64
|
+
* Validated here too because library callers may construct config objects.
|
|
65
|
+
*/
|
|
66
|
+
export function trustedIdentityIssuer(config) {
|
|
67
|
+
if (!config.identityBaseUrl)
|
|
68
|
+
return DEFAULT_IDENTITY_ISSUER;
|
|
69
|
+
const origin = resolveIdentityBaseUrl(config.identityBaseUrl);
|
|
70
|
+
if (isIdentityLoopback(origin) && !isIdentityLoopback(validateOneOrigin(config.oneBaseUrl))) {
|
|
71
|
+
throw new Error(`${IDENTITY_OPTION} can be a loopback origin only when --one-url / VIGILBASE_ONE_URL is loopback too.`);
|
|
72
|
+
}
|
|
51
73
|
return origin;
|
|
52
74
|
}
|
|
53
75
|
export function resolveClientId(explicit) {
|
|
@@ -55,17 +77,23 @@ export function resolveClientId(explicit) {
|
|
|
55
77
|
process.env.VIGILBASE_CLIENT_ID?.trim() ||
|
|
56
78
|
DEFAULT_CLIENT_ID);
|
|
57
79
|
}
|
|
58
|
-
|
|
80
|
+
/**
|
|
81
|
+
* VIGILBASE_CONFIG_DIR (or `explicit`), else $XDG_CONFIG_HOME/vigilbase, else ~/.config/vigilbase. A relative
|
|
82
|
+
* XDG_CONFIG_HOME is ignored, as the XDG Base Directory spec says; a relative custom directory is returned as is.
|
|
83
|
+
*/
|
|
84
|
+
function configDirFromEnvironment(explicit, env) {
|
|
59
85
|
const custom = explicit?.trim() || env.VIGILBASE_CONFIG_DIR?.trim();
|
|
60
|
-
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
61
|
-
if ((custom && !isAbsolute(custom)) || (xdg && !isAbsolute(xdg))) {
|
|
62
|
-
throw new Error('Custom config directories and XDG_CONFIG_HOME must be absolute paths.');
|
|
63
|
-
}
|
|
64
86
|
if (custom)
|
|
65
87
|
return custom;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
89
|
+
return xdg && isAbsolute(xdg) ? join(xdg, 'vigilbase') : join(homedir(), '.config', 'vigilbase');
|
|
90
|
+
}
|
|
91
|
+
/** The config directory, which must be absolute. */
|
|
92
|
+
export function resolveConfigDir(explicit, env = process.env) {
|
|
93
|
+
const configDir = configDirFromEnvironment(explicit, env);
|
|
94
|
+
if (!isAbsolute(configDir))
|
|
95
|
+
throw new Error('VIGILBASE_CONFIG_DIR must be an absolute path.');
|
|
96
|
+
return configDir;
|
|
69
97
|
}
|
|
70
98
|
export function createConfig(options) {
|
|
71
99
|
const publicBaseUrl = resolvePublicBaseUrl(options?.publicBaseUrl ?? options?.baseUrl);
|
|
@@ -80,7 +108,7 @@ export function createConfig(options) {
|
|
|
80
108
|
oneBaseUrl: resolveOneBaseUrl(options?.oneBaseUrl),
|
|
81
109
|
...(options?.identityBaseUrl || process.env.VIGILBASE_AUTH_URL ? { identityBaseUrl: resolveIdentityBaseUrl(options?.identityBaseUrl || process.env.VIGILBASE_AUTH_URL) } : {}),
|
|
82
110
|
clientId: resolveClientId(options?.clientId),
|
|
83
|
-
configDir:
|
|
111
|
+
configDir: configDirFromEnvironment(options?.configDir, process.env),
|
|
84
112
|
userAgent: `@vigilbase/cli/${CLI_VERSION} (+https://vigilbase.com; node/${process.version})`,
|
|
85
113
|
timeoutMs,
|
|
86
114
|
};
|
|
@@ -112,4 +140,3 @@ export function createLocalCommandConfig(timeoutMs) {
|
|
|
112
140
|
export function resolveBaseUrl(explicit) {
|
|
113
141
|
return resolvePublicBaseUrl(explicit);
|
|
114
142
|
}
|
|
115
|
-
//# sourceMappingURL=config.js.map
|
package/dist/lib/format.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type Writer = {
|
|
|
5
5
|
};
|
|
6
6
|
/** Untrusted API data must never become terminal control sequences or bidi overrides. */
|
|
7
7
|
export declare function sanitizeTerminal(value: string): string;
|
|
8
|
+
/** One sanitised line, cut to `maxLength` characters with an ellipsis. */
|
|
9
|
+
export declare function singleLine(value: string, maxLength?: number): string;
|
|
8
10
|
export declare function createWriter(stdout?: NodeJS.WritableStream, stderr?: NodeJS.WritableStream): Writer;
|
|
9
11
|
export declare function printJson(writer: Writer, value: unknown): void;
|
|
10
12
|
export declare function formatToolsList(catalog: AgentToolsCatalogResponse, mode: CliOutputMode, writer: Writer, options?: {
|
|
@@ -16,4 +18,3 @@ export declare function formatToolsList(catalog: AgentToolsCatalogResponse, mode
|
|
|
16
18
|
export declare function formatToolDescription(tool: AgentToolDefinition, mode: CliOutputMode, writer: Writer, skillMarkdown?: string): void;
|
|
17
19
|
export declare function formatExecuteResult(result: AgentToolExecuteResponse, mode: CliOutputMode, writer: Writer): void;
|
|
18
20
|
export declare function formatError(error: unknown, mode: CliOutputMode, writer: Writer): void;
|
|
19
|
-
//# sourceMappingURL=format.d.ts.map
|
package/dist/lib/format.js
CHANGED
|
@@ -3,6 +3,11 @@ import { stripVTControlCharacters } from 'node:util';
|
|
|
3
3
|
export function sanitizeTerminal(value) {
|
|
4
4
|
return stripVTControlCharacters(value).replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, '');
|
|
5
5
|
}
|
|
6
|
+
/** One sanitised line, cut to `maxLength` characters with an ellipsis. */
|
|
7
|
+
export function singleLine(value, maxLength = 300) {
|
|
8
|
+
const line = sanitizeTerminal(value).replace(/\s+/g, ' ').trim();
|
|
9
|
+
return line.length > maxLength ? `${line.slice(0, maxLength - 1).trimEnd()}…` : line;
|
|
10
|
+
}
|
|
6
11
|
export function createWriter(stdout = process.stdout, stderr = process.stderr) {
|
|
7
12
|
return {
|
|
8
13
|
stdout: (line = '') => {
|
|
@@ -257,8 +262,9 @@ export function formatExecuteResult(result, mode, writer) {
|
|
|
257
262
|
writer.stdout(head);
|
|
258
263
|
else
|
|
259
264
|
writer.stderr(head);
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
const error = typeof result.error === 'string' ? result.error : result.error?.message;
|
|
266
|
+
if (error) {
|
|
267
|
+
writer.stderr(` ${error}`);
|
|
262
268
|
}
|
|
263
269
|
for (const line of summarizeResultCompact(result.result)) {
|
|
264
270
|
writer.stdout(` ${line}`);
|
|
@@ -266,11 +272,17 @@ export function formatExecuteResult(result, mode, writer) {
|
|
|
266
272
|
}
|
|
267
273
|
export function formatError(error, mode, writer) {
|
|
268
274
|
let message = error instanceof Error ? error.message : String(error);
|
|
275
|
+
let reason = '';
|
|
269
276
|
// Server bodies can contain credentials, customer data, or arbitrary error text.
|
|
270
277
|
if (error && typeof error === 'object' && 'body' in error && error.body != null && 'status' in error && typeof error.status === 'number') {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
278
|
+
if ('code' in error && error.code === 'FLAREHAWK_VIEW_AS_REQUIRED') {
|
|
279
|
+
message = 'Select a customer with --customer-id <customer UUID> for security commands.';
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
// Only the reason the public client accepted from a known problem+json error is shown.
|
|
283
|
+
reason = 'reason' in error && typeof error.reason === 'string' ? singleLine(error.reason) : '';
|
|
284
|
+
message = reason || `Request failed (HTTP ${error.status}).`;
|
|
285
|
+
}
|
|
274
286
|
}
|
|
275
287
|
const payload = {
|
|
276
288
|
success: false,
|
|
@@ -294,7 +306,7 @@ export function formatError(error, mode, writer) {
|
|
|
294
306
|
}
|
|
295
307
|
// CLI-authored remediation (never server text); bounded and sanitised like any output.
|
|
296
308
|
if ('hint' in error && typeof error.hint === 'string') {
|
|
297
|
-
const hint =
|
|
309
|
+
const hint = singleLine(error.hint);
|
|
298
310
|
if (hint)
|
|
299
311
|
payload.hint = hint;
|
|
300
312
|
}
|
|
@@ -303,7 +315,7 @@ export function formatError(error, mode, writer) {
|
|
|
303
315
|
printJson(writer, payload);
|
|
304
316
|
return;
|
|
305
317
|
}
|
|
306
|
-
writer.stderr(`Error: ${message}`);
|
|
318
|
+
writer.stderr(`Error: ${message}${reason && typeof payload.code === 'string' ? ` (${payload.code})` : ''}`);
|
|
307
319
|
if (typeof payload.retryAfterSec === 'number') {
|
|
308
320
|
writer.stderr(`Retry after ${payload.retryAfterSec}s`);
|
|
309
321
|
}
|
|
@@ -311,4 +323,3 @@ export function formatError(error, mode, writer) {
|
|
|
311
323
|
writer.stderr(`Hint: ${payload.hint}`);
|
|
312
324
|
}
|
|
313
325
|
}
|
|
314
|
-
//# sourceMappingURL=format.js.map
|
package/dist/lib/help.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const HELP_TAGLINE = "one \u00B7 security \u00B7 tools";
|
|
2
|
-
export declare const HELP_TEXT
|
|
2
|
+
export declare const HELP_TEXT: string;
|
|
3
3
|
export declare function helpForCommand(command: string): string | null;
|
|
4
|
-
//# sourceMappingURL=help.d.ts.map
|
package/dist/lib/help.js
CHANGED
|
@@ -3,6 +3,24 @@ import { LOCAL_HELP } from '../commands/local.js';
|
|
|
3
3
|
import { ONE_HELP } from '../commands/one.js';
|
|
4
4
|
import { SECURITY_HELP } from '../commands/security.js';
|
|
5
5
|
export const HELP_TAGLINE = 'one · security · tools';
|
|
6
|
+
/** Column where descriptions start in the main help: two-space indent, term, at least two spaces. */
|
|
7
|
+
const DESCRIPTION_COLUMN = 31;
|
|
8
|
+
/** Two-column help rows whose descriptions all start at DESCRIPTION_COLUMN. */
|
|
9
|
+
function helpRows(rows) {
|
|
10
|
+
return rows
|
|
11
|
+
.map(([term, description]) => ` ${term.padEnd(DESCRIPTION_COLUMN - 4)} ${description}`)
|
|
12
|
+
.join('\n');
|
|
13
|
+
}
|
|
14
|
+
const GLOBAL_OPTIONS = helpRows([
|
|
15
|
+
['-j, --json', 'JSON output'],
|
|
16
|
+
['-h, --help', 'Help for the current command'],
|
|
17
|
+
['-V, --version', 'Installed version'],
|
|
18
|
+
['--timeout <milliseconds>', 'Request timeout (default: 60000)'],
|
|
19
|
+
['--base-url <origin>', 'Public API origin'],
|
|
20
|
+
['--one-url <origin>', 'Vigilbase One origin'],
|
|
21
|
+
['--auth-url <origin>', 'Identity issuer (default: auth.vigilbase.com)'],
|
|
22
|
+
['--client-id <id>', 'Device authorization client ID'],
|
|
23
|
+
]);
|
|
6
24
|
export const HELP_TEXT = `Usage: vigilbase <command>
|
|
7
25
|
|
|
8
26
|
Public tools (no login)
|
|
@@ -28,23 +46,16 @@ Account (login required)
|
|
|
28
46
|
account invites [list|create]
|
|
29
47
|
billing [summary|portal] Billing summary / Stripe portal
|
|
30
48
|
runs [list|get <id>] Tool run history
|
|
31
|
-
cf <command>
|
|
32
|
-
security <command>
|
|
49
|
+
cf <command> Cloudflare accounts, zones, DNS, WAF, analytics
|
|
50
|
+
security <command> Incidents, logs, assets, detections, intel, reports
|
|
33
51
|
watchdog [list|scans] Watchdog targets / scans
|
|
34
|
-
customers <command>
|
|
35
|
-
orgs <command>
|
|
36
|
-
monitoring <command>
|
|
37
|
-
support tickets
|
|
52
|
+
customers <command> Customer records, billing, reports, investigations
|
|
53
|
+
orgs <command> Organizations, members, permission roles
|
|
54
|
+
monitoring <command> Health, probes, metrics, customer targets
|
|
55
|
+
support tickets Support ticket history
|
|
38
56
|
|
|
39
57
|
Options
|
|
40
|
-
|
|
41
|
-
-h, --help Help for the current command
|
|
42
|
-
-V, --version Installed version
|
|
43
|
-
--timeout <milliseconds> Request timeout (default: 60000)
|
|
44
|
-
--base-url <origin> Public API origin
|
|
45
|
-
--one-url <origin> Vigilbase One origin
|
|
46
|
-
--auth-url <origin> Explicit registered Identity or loopback development issuer
|
|
47
|
-
--client-id <id> Device authorization client ID
|
|
58
|
+
${GLOBAL_OPTIONS}
|
|
48
59
|
|
|
49
60
|
Use vigilbase <command> --help for command options.
|
|
50
61
|
|
|
@@ -76,9 +87,10 @@ Login: website-security, react2shell, fortibleed-check`;
|
|
|
76
87
|
case 'doctor':
|
|
77
88
|
return `Usage: vigilbase doctor [--json]
|
|
78
89
|
|
|
79
|
-
Checks the public tools API
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
Checks the public tools API, your session (Identity's userinfo endpoint when
|
|
91
|
+
signed in through Identity, otherwise One's session endpoint) and any saved
|
|
92
|
+
sign-in independently. Login is optional. Exits with status 1 if any check fails.
|
|
93
|
+
Use --base-url, --one-url, --auth-url and --timeout to check other environments.`;
|
|
82
94
|
case 'account':
|
|
83
95
|
return `Usage: vigilbase account [services|org|endpoints|sessions|invites|billing] [--json]
|
|
84
96
|
|
|
@@ -122,4 +134,3 @@ Prefer --token-stdin with piped input to keep tokens out of command arguments.`;
|
|
|
122
134
|
return null;
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
|
-
//# sourceMappingURL=help.js.map
|
package/dist/lib/network.d.ts
CHANGED
|
@@ -8,10 +8,19 @@ export declare function networkError(error: unknown, url: string, timeoutMs: num
|
|
|
8
8
|
export declare const MAX_RESPONSE_BYTES: number;
|
|
9
9
|
/** Bound decoded bytes even when Content-Length is absent, compressed, or dishonest. */
|
|
10
10
|
export declare function readBoundedBody(response: Response, signal: AbortSignal, maxBytes?: number): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* A signal that aborts with the reason of the first of `signals` to abort.
|
|
13
|
+
* Uses `AbortSignal.any` (Node 20.3+) and combines them by hand on older
|
|
14
|
+
* Node 20; `dispose` then removes the listeners so a long-lived signal does
|
|
15
|
+
* not collect one per request.
|
|
16
|
+
*/
|
|
17
|
+
export declare function anySignal(signals: AbortSignal[]): {
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
dispose: () => void;
|
|
20
|
+
};
|
|
11
21
|
/** Keep the timeout active until the complete response body has been read. */
|
|
12
22
|
export declare function requestText(config: CliConfig, url: string, init?: RequestInit): Promise<{
|
|
13
23
|
response: Response;
|
|
14
24
|
text: string;
|
|
15
25
|
}>;
|
|
16
26
|
export declare function parseJsonResponse(response: Response, text: string): unknown;
|
|
17
|
-
//# sourceMappingURL=network.d.ts.map
|
package/dist/lib/network.js
CHANGED
|
@@ -70,13 +70,40 @@ export async function readBoundedBody(response, signal, maxBytes = MAX_RESPONSE_
|
|
|
70
70
|
reader.releaseLock();
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A signal that aborts with the reason of the first of `signals` to abort.
|
|
75
|
+
* Uses `AbortSignal.any` (Node 20.3+) and combines them by hand on older
|
|
76
|
+
* Node 20; `dispose` then removes the listeners so a long-lived signal does
|
|
77
|
+
* not collect one per request.
|
|
78
|
+
*/
|
|
79
|
+
export function anySignal(signals) {
|
|
80
|
+
if (typeof AbortSignal.any === 'function')
|
|
81
|
+
return { signal: AbortSignal.any(signals), dispose: () => undefined };
|
|
82
|
+
const controller = new AbortController();
|
|
83
|
+
const dispose = () => {
|
|
84
|
+
for (const signal of signals)
|
|
85
|
+
signal.removeEventListener('abort', onAbort);
|
|
86
|
+
};
|
|
87
|
+
function onAbort(event) {
|
|
88
|
+
dispose();
|
|
89
|
+
controller.abort(event.target.reason);
|
|
90
|
+
}
|
|
91
|
+
const aborted = signals.find((signal) => signal.aborted);
|
|
92
|
+
if (aborted) {
|
|
93
|
+
controller.abort(aborted.reason);
|
|
94
|
+
return { signal: controller.signal, dispose: () => undefined };
|
|
95
|
+
}
|
|
96
|
+
for (const signal of signals)
|
|
97
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
98
|
+
return { signal: controller.signal, dispose };
|
|
99
|
+
}
|
|
73
100
|
/** Keep the timeout active until the complete response body has been read. */
|
|
74
101
|
export async function requestText(config, url, init = {}) {
|
|
75
102
|
const controller = new AbortController();
|
|
76
103
|
const timer = setTimeout(() => controller.abort(), config.timeoutMs);
|
|
77
|
-
const signal = init.signal
|
|
78
|
-
?
|
|
79
|
-
: controller.signal;
|
|
104
|
+
const { signal, dispose } = init.signal
|
|
105
|
+
? anySignal([init.signal, controller.signal])
|
|
106
|
+
: { signal: controller.signal, dispose: () => undefined };
|
|
80
107
|
try {
|
|
81
108
|
// Never forward token-bearing POST bodies (or credentials) through redirects.
|
|
82
109
|
// 'manual' is honoured because it surfaces the 3xx without following it.
|
|
@@ -93,6 +120,7 @@ export async function requestText(config, url, init = {}) {
|
|
|
93
120
|
}
|
|
94
121
|
finally {
|
|
95
122
|
clearTimeout(timer);
|
|
123
|
+
dispose();
|
|
96
124
|
}
|
|
97
125
|
}
|
|
98
126
|
export function parseJsonResponse(response, text) {
|
|
@@ -106,4 +134,3 @@ export function parseJsonResponse(response, text) {
|
|
|
106
134
|
throw new NetworkError(`Expected JSON but received a non-JSON response (HTTP ${response.status}). Check the configured API URL and any proxy or sign-in page.`, 'INVALID_RESPONSE');
|
|
107
135
|
}
|
|
108
136
|
}
|
|
109
|
-
//# sourceMappingURL=network.js.map
|
package/dist/lib/one-client.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare class VigilbaseOneClient {
|
|
|
47
47
|
private readonly config;
|
|
48
48
|
private accessToken;
|
|
49
49
|
private readonly managed;
|
|
50
|
+
/** The userinfo endpoint Identity discovery named for the last getSession, if it used Identity. */
|
|
51
|
+
userinfoEndpoint?: string;
|
|
50
52
|
constructor(config: CliConfig, accessToken: string, managed?: boolean);
|
|
51
53
|
private request;
|
|
52
54
|
/** Authenticated JSON transport shared by the One command clients. */
|
|
@@ -89,4 +91,3 @@ export declare class VigilbaseOneClient {
|
|
|
89
91
|
executeTool(toolName: string, target: string): Promise<OneToolExecuteResponse>;
|
|
90
92
|
}
|
|
91
93
|
export {};
|
|
92
|
-
//# sourceMappingURL=one-client.d.ts.map
|