@vigilbase/cli 0.1.2 → 0.1.4
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 +112 -0
- package/COMMANDS.md +147 -0
- package/ONE.md +99 -0
- package/README.md +188 -54
- package/SECURITY.md +134 -0
- package/dist/auth/device-auth.d.ts +1 -1
- package/dist/auth/device-auth.d.ts.map +1 -1
- package/dist/auth/device-auth.js +68 -72
- package/dist/auth/device-auth.js.map +1 -1
- package/dist/auth/store.d.ts +4 -6
- package/dist/auth/store.d.ts.map +1 -1
- package/dist/auth/store.js +136 -54
- package/dist/auth/store.js.map +1 -1
- package/dist/auth/types.d.ts +2 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/bin.js +2 -0
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +89 -8
- package/dist/cli.js.map +1 -1
- package/dist/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +25 -9
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/auth.d.ts +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +49 -10
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +5 -1
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/cloudflare.d.ts +1 -0
- package/dist/commands/cloudflare.d.ts.map +1 -1
- package/dist/commands/cloudflare.js +328 -40
- package/dist/commands/cloudflare.js.map +1 -1
- package/dist/commands/helpers.d.ts +35 -0
- package/dist/commands/helpers.d.ts.map +1 -1
- package/dist/commands/helpers.js +12 -0
- package/dist/commands/helpers.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/legacy-validation.d.ts +21 -0
- package/dist/commands/legacy-validation.d.ts.map +1 -0
- package/dist/commands/legacy-validation.js +20 -0
- package/dist/commands/legacy-validation.js.map +1 -0
- package/dist/commands/one.d.ts +6 -0
- package/dist/commands/one.d.ts.map +1 -0
- package/dist/commands/one.js +200 -0
- package/dist/commands/one.js.map +1 -0
- package/dist/commands/public-tools.d.ts.map +1 -1
- package/dist/commands/public-tools.js +68 -11
- package/dist/commands/public-tools.js.map +1 -1
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/runs.js +19 -12
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/security.d.ts +6 -0
- package/dist/commands/security.d.ts.map +1 -0
- package/dist/commands/security.js +391 -0
- package/dist/commands/security.js.map +1 -0
- package/dist/commands/watchdog.d.ts.map +1 -1
- package/dist/commands/watchdog.js +15 -12
- package/dist/commands/watchdog.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +3 -0
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +35 -62
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/cloudflare-client.d.ts +40 -0
- package/dist/lib/cloudflare-client.d.ts.map +1 -0
- package/dist/lib/cloudflare-client.js +81 -0
- package/dist/lib/cloudflare-client.js.map +1 -0
- package/dist/lib/config.d.ts +2 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +37 -12
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/format.d.ts +2 -0
- package/dist/lib/format.d.ts.map +1 -1
- package/dist/lib/format.js +23 -8
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/help.d.ts +2 -2
- package/dist/lib/help.d.ts.map +1 -1
- package/dist/lib/help.js +45 -12
- package/dist/lib/help.js.map +1 -1
- package/dist/lib/network.d.ts +17 -0
- package/dist/lib/network.d.ts.map +1 -0
- package/dist/lib/network.js +108 -0
- package/dist/lib/network.js.map +1 -0
- package/dist/lib/one-client.d.ts +10 -1
- package/dist/lib/one-client.d.ts.map +1 -1
- package/dist/lib/one-client.js +52 -50
- package/dist/lib/one-client.js.map +1 -1
- package/dist/lib/one-operations.d.ts +11 -0
- package/dist/lib/one-operations.d.ts.map +1 -0
- package/dist/lib/one-operations.js +67 -0
- package/dist/lib/one-operations.js.map +1 -0
- package/dist/lib/open-url.d.ts +2 -0
- package/dist/lib/open-url.d.ts.map +1 -1
- package/dist/lib/open-url.js +23 -22
- package/dist/lib/open-url.js.map +1 -1
- package/dist/lib/progress.d.ts +1 -1
- package/dist/lib/progress.d.ts.map +1 -1
- package/dist/lib/progress.js +3 -1
- package/dist/lib/progress.js.map +1 -1
- package/dist/lib/security-client.d.ts +279 -0
- package/dist/lib/security-client.d.ts.map +1 -0
- package/dist/lib/security-client.js +111 -0
- package/dist/lib/security-client.js.map +1 -0
- package/dist/lib/skill-fetch.d.ts +7 -0
- package/dist/lib/skill-fetch.d.ts.map +1 -0
- package/dist/lib/skill-fetch.js +102 -0
- package/dist/lib/skill-fetch.js.map +1 -0
- package/dist/lib/system-trust.d.ts +8 -0
- package/dist/lib/system-trust.d.ts.map +1 -0
- package/dist/lib/system-trust.js +11 -0
- package/dist/lib/system-trust.js.map +1 -0
- package/package.json +12 -2
package/SECURITY.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Security command reference
|
|
2
|
+
|
|
3
|
+
All commands start with `vigilbase security`. Sign in with `vigilbase login` first. Commands use the configured One origin and its authenticated `/api/flarehawk` boundary. One independently checks permissions and maps the current organization to its security tenant. Internal operators can supply `--customer-id <One customer UUID>` for validated View-as access; this never supplies an upstream organization identity.
|
|
4
|
+
|
|
5
|
+
Every operation below is **GET/read-only**, except `incidents update`, which is **PATCH/write** and requires `--confirm` plus server service-write permission. Reads require server service-read permission. No command directly accesses the retained service, runs archived chat, changes remediation authority, or approves provider effects.
|
|
6
|
+
|
|
7
|
+
Append `--json` for the complete validated wire envelope, including evidence, total counts, pagination cursors, warnings, and unavailable states. Text output preserves full resource IDs, sanitizes terminal control characters, and displays nested results. `--timeout <milliseconds>` controls request timeout; analytical queries can need `--timeout 120000`.
|
|
8
|
+
|
|
9
|
+
All endpoint paths in the tables are relative to `/api/flarehawk`. `<id>`, `<asset>`, `<connection>`, and `<job>` are UUIDs copied from the relevant inventories. Unsupported filters and extra positional arguments are rejected. `get` aliases `show` on incidents, connections, reports, and alerts; `ls` aliases `list` on incidents, connections, and reports.
|
|
10
|
+
|
|
11
|
+
## Incidents, signals, logs, and evidence
|
|
12
|
+
|
|
13
|
+
| Grammar after `security` | Flags | Endpoint |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `[overview]` | None | `/dashboard/overview` |
|
|
16
|
+
| `incidents [list]` | `--limit`, `--offset`, `--status`, `--severity`, `--attack-category`, `--order-by`, `--order-direction` | `/incidents` |
|
|
17
|
+
| `incidents show <id>` | None | `/incidents/<id>` |
|
|
18
|
+
| `incidents timeline <id>` | `--limit`, `--before` | `/incidents/<id>/timeline` |
|
|
19
|
+
| `incidents fabric <id>` | `--dataset`, `--min-weight`, `--limit` | `/incidents/<id>/fabric` |
|
|
20
|
+
| `incidents share-links <id>` | None | `/incidents/<id>/share-links` |
|
|
21
|
+
| `incidents update <id> <status> --confirm` | `--note` | **PATCH** `/incidents/<id>`; JSON body `{status,note?}` |
|
|
22
|
+
| `alerts [list]` | `--limit`, `--asset-id`, `--start` | `/alerts`; `start` maps to `since` |
|
|
23
|
+
| `alerts show <id>` | None | `/alerts/<id>` |
|
|
24
|
+
| `logs` | `--limit`, `--asset-id`, `--provider`, `--dataset`, `--search`, `--start`, `--end`, `--sort`, `--frs-min`, `--cursor` | `/logs` |
|
|
25
|
+
| `audit` | `--limit`, `--cursor`, `--action-prefix`, `--outcome` | `/vigilbase-one/audit-events` |
|
|
26
|
+
|
|
27
|
+
Incident list statuses: `open`, `active`, `acknowledged`, `investigating`, `mitigating`, `mitigated`, `resolved`, `false_positive`. Update statuses: `acknowledged`, `mitigating`, `resolved`, `false_positive`. Severity: `critical`, `high`, `medium`, `low`. Ordering: `last_alert_at`, `first_alert_at`, `created_at`, `severity_rank`, `combined_score`, `alert_count`; direction: `asc` or `desc`. Hyphenated filter names map to snake_case on the wire. Incident updates report a `feedback_sync_error` warning when status changed but signal feedback synchronization failed; confirmation does not bypass server authorization.
|
|
28
|
+
|
|
29
|
+
Logs require `--start` and `--end` together as ISO timestamps with an explicit timezone; start must precede end. They map to `start_time` and `end_time`. Sort: `ts`, `frs`, or `frs_desc`; FRS minimum: integer 0–100. Other hyphenated filter names map to snake_case. Audit outcome: `success`, `failure`, or `denied`; `--action-prefix` maps to `action_prefix`. Alerts accept a single ISO `--start` timestamp as the lower bound.
|
|
30
|
+
|
|
31
|
+
## Assets, providers, and connection health
|
|
32
|
+
|
|
33
|
+
| Grammar after `security` | Flags | Endpoint |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `assets` | None | `/domains` |
|
|
36
|
+
| `assets allowlist <asset>` | None | `/domains/<asset>/allowlist` |
|
|
37
|
+
| `assets blocklist <asset>` | None | `/domains/<asset>/blocklist` |
|
|
38
|
+
| `assets remediation <asset>` | None | `/assets/<asset>/remediation-settings` |
|
|
39
|
+
| `assets autonomy <asset>` | None | `/assets/<asset>/vigil-autonomy` |
|
|
40
|
+
| `assets datasets <asset>` | None | `/fabric/assets/<asset>/datasets` |
|
|
41
|
+
| `assets graph <asset>` | `--dataset`, `--hours`, `--min-weight`, `--limit` | `/fabric/assets/<asset>/graph` |
|
|
42
|
+
| `fabric default-asset` | None | `/fabric/default-asset` |
|
|
43
|
+
| `detections` | `--asset-id` | `/detections?asset_id=…` when scoped |
|
|
44
|
+
| `providers` | None | `/providers?connectable=false` |
|
|
45
|
+
| `connections [list]` | None | `/connections` |
|
|
46
|
+
| `connections show <connection>` | None | `/connections/<connection>` |
|
|
47
|
+
| `connections available-assets <connection>` | None | `/connections/<connection>/available-assets` |
|
|
48
|
+
| `connections remediation <connection>` | None | `/connections/<connection>/remediation-settings` |
|
|
49
|
+
| `connections logpush-status <connection> <job>` | None | `/connections/<connection>/logpush-jobs/<job>/status` |
|
|
50
|
+
| `connections worker-stats <connection> <job>` | None | `/connections/<connection>/worker-routes/<job>/stats` |
|
|
51
|
+
|
|
52
|
+
Graph `--hours` maps to `window_hours`; `--min-weight` maps to `min_weight`. Incident graphs use the incident window and reject `--hours`. IP lists retain enforcement verification and synchronization status. Connection health includes stored state, provider status, receipt health, and available warnings. Credential-bearing HEC profile retrieval is outside this command set.
|
|
53
|
+
|
|
54
|
+
## Analytics and Cloudflare security
|
|
55
|
+
|
|
56
|
+
The time-window flags **W** are `--hours`, `--start`, `--end`, and `--asset-id`. Default: 24 hours. `--hours` is an integer 1–720. An explicit ISO `--start`/`--end` pair replaces `--hours`; these forms cannot be combined. `--asset-id` narrows the authenticated tenant's data. Wire keys are `hours`, `start`, `end`, and `asset_id`.
|
|
57
|
+
|
|
58
|
+
| Grammar after `security` | Flags | Endpoint |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| `analytics [overview]` | W, `--metrics` | `/analytics` |
|
|
61
|
+
| `analytics security-analysis` | W | `/analytics/security-analysis` |
|
|
62
|
+
| `analytics bot-activity` | W | `/analytics/bot-activity` |
|
|
63
|
+
| `analytics top-attacker-ips` | W | `/analytics/top-attacker-ips` |
|
|
64
|
+
| `analytics bot-asns` | W | `/analytics/bot-asns` |
|
|
65
|
+
| `analytics dns-security` | W | `/analytics/dns-security` |
|
|
66
|
+
| `analytics page-shield` | W | `/analytics/page-shield` |
|
|
67
|
+
| `analytics provider-events` | Required `--provider`, `--dataset`, `--start`, `--end`; optional `--asset-id`, `--search`, `--limit` | `/analytics/provider-events` |
|
|
68
|
+
| `zero-trust device-health` | W | `/zero-trust/device-health` |
|
|
69
|
+
| `zero-trust app-tests` | W | `/zero-trust/app-tests` |
|
|
70
|
+
| `zero-trust gateway <dns\|http\|network>` | W | `/zero-trust/gateway?surface=…` |
|
|
71
|
+
| `zero-trust access` | W | `/zero-trust/access` |
|
|
72
|
+
| `zero-trust sessions` | W | `/zero-trust/sessions` |
|
|
73
|
+
| `zero-trust device-posture` | W | `/zero-trust/device-posture` |
|
|
74
|
+
| `cloudflare-account [inventory]` | None | `/cloudflare-account/inventory` |
|
|
75
|
+
| `cloudflare-account audit` | W | `/cloudflare-account/audit` |
|
|
76
|
+
| `cloudflare-account ingestion` | W | `/cloudflare-account/ingestion` |
|
|
77
|
+
| `cloudflare-account posture` | W | `/cloudflare-account/posture` |
|
|
78
|
+
|
|
79
|
+
Analytics metrics are a comma-separated selection of `summary`, `hourly`, `by_domain`, `by_dataset`, `response_status`, `waf_scores`, `alerts`, `geographic`, `top_paths`, `waf_rules`, and `performance`. Default: `hourly,by_domain,by_dataset`.
|
|
80
|
+
|
|
81
|
+
Provider events map `--provider` to `provider_id`, `--dataset` to `dataset_id`, and `--asset-id` to `asset_ids`; start/end retain their names. Search is limited to 200 characters. Provider/dataset response identity and Gateway surface identity must match the request. `unavailable` results stay explicitly unavailable rather than implying healthy empty data.
|
|
82
|
+
|
|
83
|
+
## Notifications, reports, intelligence, and personal settings
|
|
84
|
+
|
|
85
|
+
| Grammar after `security` | Flags | Endpoint |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `notifications [list]` | `--limit` | `/notifications` |
|
|
88
|
+
| `notifications settings` | None | `/notifications/settings` |
|
|
89
|
+
| `notifications preferences` | None | `/notifications/preferences` |
|
|
90
|
+
| `notifications slack-channels` | None | `/notifications/slack/channels` |
|
|
91
|
+
| `reports [list]` | `--limit`, `--offset` | `/reports` |
|
|
92
|
+
| `reports show <id>` | None | `/reports/<id>` |
|
|
93
|
+
| `reports settings` | None | `/reports/settings` |
|
|
94
|
+
| `intel quota` | None | `/intel/quota` |
|
|
95
|
+
| `intel <ip\|asn\|cidr\|ja3\|ja4> <query>` | None | `/intel/lookup?q=…&type=…` |
|
|
96
|
+
| `settings lifecycle-emails` | None | `/settings/lifecycle-emails` |
|
|
97
|
+
| `settings broadcast-emails` | None | `/settings/broadcast-emails` |
|
|
98
|
+
| `settings applications` | None | `/integrations/grants` |
|
|
99
|
+
|
|
100
|
+
Intel lookup input is trimmed and limited to 512 characters; the server validates the indicator and applies lookup quota. Personal settings show existing preferences and authorized application grants. They do not change preferences or revoke grants. Reports are fetched on demand; this CLI does not persist report or billing records.
|
|
101
|
+
|
|
102
|
+
## Limits and pagination
|
|
103
|
+
|
|
104
|
+
These are CLI validation bounds; the service can impose stricter limits.
|
|
105
|
+
|
|
106
|
+
| Operation | Default `--limit` | Allowed range | Continuation |
|
|
107
|
+
|---|---:|---:|---|
|
|
108
|
+
| Incidents list | 50 | 1–100 | `--offset`; `has_more`, `filters_applied` preserved |
|
|
109
|
+
| Timeline | 100 | 1–200 | `--before` using `next_cursor` |
|
|
110
|
+
| Logs | 100 | 1–1000 | `--cursor` using `nextCursor` |
|
|
111
|
+
| Audit | 50 | 1–100 | `--cursor` using `next_cursor` |
|
|
112
|
+
| Reports list | 50 | 1–100 | `--offset` |
|
|
113
|
+
| Alerts list | 100 | 1–100 | Bounded list; use `--start` and `--asset-id` to narrow |
|
|
114
|
+
| Notifications list | 100 | 1–100 | Bounded list |
|
|
115
|
+
| Provider events | 200 | 1–500 | Bounded sample; aggregates remain server-provided |
|
|
116
|
+
| Asset/incident graph | 200 | 1–1000 | Bounded graph |
|
|
117
|
+
|
|
118
|
+
Offsets are integers 0–1,000,000 and are omitted unless supplied. Graph minimum weight defaults to 1 and accepts integers 1–1,000,000. Graph hours default to 24 and accept 1–720. No command auto-fetches unbounded pages.
|
|
119
|
+
|
|
120
|
+
Examples:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
vigilbase security incidents --status open --severity high
|
|
124
|
+
vigilbase security incidents timeline <incident-uuid> --before '<cursor>'
|
|
125
|
+
vigilbase security incidents update <incident-uuid> acknowledged --note 'Review started' --confirm
|
|
126
|
+
vigilbase security assets graph <asset-uuid> --dataset http_requests --hours 24 --json
|
|
127
|
+
vigilbase security analytics security-analysis --asset-id <asset-uuid> --hours 48
|
|
128
|
+
vigilbase security zero-trust gateway dns --hours 24 --json
|
|
129
|
+
vigilbase security cloudflare-account posture --customer-id <one-customer-uuid>
|
|
130
|
+
vigilbase security connections logpush-status <connection-uuid> <job-uuid>
|
|
131
|
+
vigilbase security intel ip 1.1.1.1
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The API contract sources are One's `flarehawk/policy.ts`, `flarehawk-ui/client.ts`, `flarehawk-ui/normalizers.ts`, specialized analytics request/normalizer modules, personal-controls schemas, and incident-share schemas. Binary log downloads and routes without a verified JSON consumer are not exposed. The standalone `scripts/fixtures/security.mjs` catalog covers every named wire operation for compiled CLI end-to-end verification.
|
|
@@ -41,7 +41,7 @@ export type PollResult = {
|
|
|
41
41
|
error: DeviceTokenPendingError;
|
|
42
42
|
};
|
|
43
43
|
export declare function pollDeviceToken(config: CliConfig, deviceCode: string): Promise<PollResult>;
|
|
44
|
-
export declare function sleep(ms: number): Promise<void>;
|
|
44
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
45
45
|
/**
|
|
46
46
|
* Run the full device-code poll loop until authorized, denied, or expired.
|
|
47
47
|
* Returns the token payload on success.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-auth.d.ts","sourceRoot":"","sources":["../../src/auth/device-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"device-auth.d.ts","sourceRoot":"","sources":["../../src/auth/device-auth.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAOnB,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAA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C9B,KAAK,IAAI,CAAA;IACV,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC,GACA,OAAO,CAAC,kBAAkB,CAAC,CAkF7B"}
|
package/dist/auth/device-auth.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Server plugin: https://better-auth.com/docs/plugins/device-authorization
|
|
5
|
-
* Endpoints (relative to One's Better Auth base, typically `/api/auth`):
|
|
6
|
-
* POST /device/code
|
|
7
|
-
* POST /device/token
|
|
8
|
-
*
|
|
9
|
-
* Public tool commands do not use this module. One-scoped commands will.
|
|
10
|
-
*/
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { validateOneOrigin } from '../lib/config.js';
|
|
3
|
+
import { NetworkError, parseJsonResponse, requestText } from '../lib/network.js';
|
|
11
4
|
const DEVICE_GRANT = 'urn:ietf:params:oauth:grant-type:device_code';
|
|
12
5
|
/** How many consecutive unreachable token polls before aborting a live login. */
|
|
13
6
|
const MAX_CONSECUTIVE_TRANSIENT = 8;
|
|
@@ -24,7 +17,7 @@ export class DeviceAuthError extends Error {
|
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
19
|
function authBase(config) {
|
|
27
|
-
return `${config.oneBaseUrl}/api/auth`;
|
|
20
|
+
return `${validateOneOrigin(config.oneBaseUrl)}/api/auth`;
|
|
28
21
|
}
|
|
29
22
|
function isRetryableTokenStatus(status) {
|
|
30
23
|
return (status === 404 ||
|
|
@@ -35,34 +28,16 @@ function isRetryableTokenStatus(status) {
|
|
|
35
28
|
}
|
|
36
29
|
async function postJson(config, path, body) {
|
|
37
30
|
const url = `${authBase(config)}${path}`;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
body: JSON.stringify(body),
|
|
50
|
-
});
|
|
51
|
-
const text = await response.text();
|
|
52
|
-
let json = null;
|
|
53
|
-
if (text) {
|
|
54
|
-
try {
|
|
55
|
-
json = JSON.parse(text);
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
json = { raw: text };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return { status: response.status, json };
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
clearTimeout(timer);
|
|
65
|
-
}
|
|
31
|
+
const { response, text } = await requestText(config, url, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: {
|
|
34
|
+
Accept: 'application/json',
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
'User-Agent': config.userAgent,
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify(body),
|
|
39
|
+
});
|
|
40
|
+
return { status: response.status, json: parseJsonResponse(response, text) };
|
|
66
41
|
}
|
|
67
42
|
export async function requestDeviceCode(config, options) {
|
|
68
43
|
const { status, json } = await postJson(config, '/device/code', {
|
|
@@ -71,29 +46,25 @@ export async function requestDeviceCode(config, options) {
|
|
|
71
46
|
});
|
|
72
47
|
if (status === 404) {
|
|
73
48
|
throw new DeviceAuthError(`Device authorization is not enabled on ${config.oneBaseUrl} yet. ` +
|
|
74
|
-
'Enable Better Auth\'s deviceAuthorization plugin on Vigilbase One, then retry `vigilbase login`.', { status,
|
|
49
|
+
'Enable Better Auth\'s deviceAuthorization plugin on Vigilbase One, then retry `vigilbase login`.', { status, code: 'not_enabled' });
|
|
75
50
|
}
|
|
76
51
|
if (status < 200 || status >= 300) {
|
|
77
|
-
|
|
78
|
-
typeof json === 'object' &&
|
|
79
|
-
'message' in json &&
|
|
80
|
-
typeof json.message === 'string'
|
|
81
|
-
? json.message
|
|
82
|
-
: `Device code request failed (HTTP ${status})`;
|
|
83
|
-
throw new DeviceAuthError(message, { status, body: json });
|
|
52
|
+
throw new DeviceAuthError(`Device code request failed (HTTP ${status})`, { status });
|
|
84
53
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
const result = z.object({
|
|
55
|
+
device_code: z.string().min(1),
|
|
56
|
+
user_code: z.string().min(1),
|
|
57
|
+
verification_uri: z.string().min(1),
|
|
58
|
+
verification_uri_complete: z.string().min(1).optional(),
|
|
59
|
+
expires_in: z.number().int().positive().max(86_400).default(600),
|
|
60
|
+
interval: z.number().int().positive().max(86_400).default(5),
|
|
61
|
+
}).safeParse(json);
|
|
62
|
+
if (!result.success) {
|
|
63
|
+
throw new DeviceAuthError('Device code response was missing required fields or contained invalid values.', {
|
|
64
|
+
status, code: 'invalid_response',
|
|
65
|
+
});
|
|
88
66
|
}
|
|
89
|
-
return
|
|
90
|
-
device_code: data.device_code,
|
|
91
|
-
user_code: data.user_code,
|
|
92
|
-
verification_uri: data.verification_uri,
|
|
93
|
-
verification_uri_complete: data.verification_uri_complete,
|
|
94
|
-
expires_in: data.expires_in ?? 600,
|
|
95
|
-
interval: data.interval ?? 5,
|
|
96
|
-
};
|
|
67
|
+
return result.data;
|
|
97
68
|
}
|
|
98
69
|
export async function pollDeviceToken(config, deviceCode) {
|
|
99
70
|
let status;
|
|
@@ -107,6 +78,8 @@ export async function pollDeviceToken(config, deviceCode) {
|
|
|
107
78
|
}));
|
|
108
79
|
}
|
|
109
80
|
catch (error) {
|
|
81
|
+
if (error instanceof NetworkError && /CERT|SELF_SIGNED|UNABLE_TO_VERIFY|UNABLE_TO_GET_ISSUER|INVALID_RESPONSE/.test(error.code))
|
|
82
|
+
throw error;
|
|
110
83
|
const description = error instanceof Error ? error.message : 'Network error while polling';
|
|
111
84
|
return {
|
|
112
85
|
status: 'transient',
|
|
@@ -117,14 +90,24 @@ export async function pollDeviceToken(config, deviceCode) {
|
|
|
117
90
|
},
|
|
118
91
|
};
|
|
119
92
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
93
|
+
const token = z.object({
|
|
94
|
+
access_token: z.string().trim().min(1),
|
|
95
|
+
token_type: z.string().optional(),
|
|
96
|
+
expires_in: z.number().int().positive().optional(),
|
|
97
|
+
refresh_token: z.string().optional(),
|
|
98
|
+
scope: z.string().optional(),
|
|
99
|
+
}).safeParse(json);
|
|
100
|
+
if (status >= 200 && status < 300 && token.success) {
|
|
101
|
+
return { status: 'authorized', token: token.data };
|
|
125
102
|
}
|
|
126
|
-
|
|
127
|
-
|
|
103
|
+
if (status >= 200 && status < 300) {
|
|
104
|
+
throw new DeviceAuthError('Invalid device token response.', { status, code: 'invalid_response' });
|
|
105
|
+
}
|
|
106
|
+
const parsedError = z.object({
|
|
107
|
+
error: z.string(), error_description: z.string().optional(),
|
|
108
|
+
}).safeParse(json);
|
|
109
|
+
const errorBody = parsedError.success ? parsedError.data : { error: `http_${status}` };
|
|
110
|
+
const code = errorBody.error;
|
|
128
111
|
switch (code) {
|
|
129
112
|
case 'authorization_pending':
|
|
130
113
|
case 'slow_down':
|
|
@@ -150,12 +133,23 @@ export async function pollDeviceToken(config, deviceCode) {
|
|
|
150
133
|
},
|
|
151
134
|
};
|
|
152
135
|
}
|
|
153
|
-
throw new DeviceAuthError(errorBody
|
|
154
|
-
errorBody.error ||
|
|
155
|
-
`Device token request failed (HTTP ${status})`, { status, body: json, code });
|
|
136
|
+
throw new DeviceAuthError(`Device token request failed (HTTP ${status})`, { status, code, body: errorBody });
|
|
156
137
|
}
|
|
157
|
-
export async function sleep(ms) {
|
|
158
|
-
await new Promise((resolve) =>
|
|
138
|
+
export async function sleep(ms, signal) {
|
|
139
|
+
await new Promise((resolve, reject) => {
|
|
140
|
+
const cancel = () => {
|
|
141
|
+
clearTimeout(timer);
|
|
142
|
+
signal?.removeEventListener('abort', cancel);
|
|
143
|
+
reject(new DeviceAuthError('Login cancelled.', { status: 0, code: 'cancelled' }));
|
|
144
|
+
};
|
|
145
|
+
const timer = setTimeout(() => {
|
|
146
|
+
signal?.removeEventListener('abort', cancel);
|
|
147
|
+
resolve();
|
|
148
|
+
}, ms);
|
|
149
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
150
|
+
if (signal?.aborted)
|
|
151
|
+
cancel();
|
|
152
|
+
});
|
|
159
153
|
}
|
|
160
154
|
/**
|
|
161
155
|
* Run the full device-code poll loop until authorized, denied, or expired.
|
|
@@ -181,7 +175,9 @@ export async function waitForDeviceAuthorization(config, device, options) {
|
|
|
181
175
|
intervalSec,
|
|
182
176
|
kind: consecutiveTransient > 0 ? 'transient' : 'pending',
|
|
183
177
|
});
|
|
184
|
-
await sleep(intervalSec * 1000);
|
|
178
|
+
await sleep(Math.min(intervalSec * 1000, Math.max(0, deadline - Date.now())), options?.signal);
|
|
179
|
+
if (Date.now() >= deadline)
|
|
180
|
+
break;
|
|
185
181
|
const result = await pollDeviceToken(config, device.device_code);
|
|
186
182
|
switch (result.status) {
|
|
187
183
|
case 'authorized':
|
|
@@ -200,7 +196,7 @@ export async function waitForDeviceAuthorization(config, device, options) {
|
|
|
200
196
|
(lastTransientStatus
|
|
201
197
|
? ` (HTTP ${lastTransientStatus})`
|
|
202
198
|
: '') +
|
|
203
|
-
|
|
199
|
+
`. ${result.error.error_description ?? 'Retry `vigilbase login` once One is healthy.'}`, {
|
|
204
200
|
status: lastTransientStatus,
|
|
205
201
|
code: 'unreachable',
|
|
206
202
|
body: result.error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-auth.js","sourceRoot":"","sources":["../../src/auth/device-auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"device-auth.js","sourceRoot":"","sources":["../../src/auth/device-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAmBhF,MAAM,YAAY,GAAG,8CA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AG;oBACX,IAAI,EAAE,eAAe;oBACrB,IAAI,EAAE,MAAM,CAAC,KAAK;iBACnB,CAAC,CAAA;YACJ,KAAK,SAAS;gBACZ,MAAM,IAAI,eAAe,CACvB,uDAAuD,EACvD,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,CAC3D,CAAA;YACH,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,WAAW,GAAU,MAAM,CAAA;gBACjC,MAAM,IAAI,eAAe,CACvB,2BAA2B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,EACxD;oBACE,MAAM,EAAE,CAAC;oBACT,IAAI,EAAE,YAAY;iBACnB,CACF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAI,eAAe,CACvB,2EAA2E,EAC3E,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAC/B,CAAA;AACH,CAAC"}
|
package/dist/auth/store.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { CliConfig } from '../lib/config.js';
|
|
2
2
|
import type { CredentialsFile, OneCredentials } from './types.js';
|
|
3
|
-
|
|
4
|
-
* Resolve the credentials file path and reject path traversal outside configDir.
|
|
5
|
-
* Filename is a fixed constant — only configDir varies (from env / XDG).
|
|
6
|
-
*/
|
|
3
|
+
type CredentialsConfig = Pick<CliConfig, 'configDir'> & Partial<Pick<CliConfig, 'oneBaseUrl'>>;
|
|
7
4
|
export declare function credentialsPath(config: Pick<CliConfig, 'configDir'>): string;
|
|
8
5
|
export declare function readCredentials(config: Pick<CliConfig, 'configDir'>): Promise<CredentialsFile>;
|
|
9
|
-
export declare function writeOneCredentials(config:
|
|
6
|
+
export declare function writeOneCredentials(config: CredentialsConfig, one: OneCredentials): Promise<void>;
|
|
10
7
|
export declare function clearOneCredentials(config: Pick<CliConfig, 'configDir'>): Promise<boolean>;
|
|
11
|
-
export declare function getOneAccessToken(config:
|
|
8
|
+
export declare function getOneAccessToken(config: CredentialsConfig): Promise<string | null>;
|
|
9
|
+
export {};
|
|
12
10
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/auth/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/auth/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/auth/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMjE,KAAK,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAA;AAQ9F,wBAAgB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,MAAM,CAG5E;AA4DD,wBAAsB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAepG;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBvG;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAKhG;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAczF"}
|