@vigilbase/cli 0.2.0 → 0.2.2

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.
Files changed (235) hide show
  1. package/CLOUDFLARE.md +9 -12
  2. package/COMMANDS.md +192 -111
  3. package/LOCAL.md +77 -84
  4. package/ONE.md +5 -6
  5. package/README.md +349 -173
  6. package/SECURITY.md +6 -4
  7. package/dist/auth/device-auth.d.ts +0 -1
  8. package/dist/auth/device-auth.js +6 -5
  9. package/dist/auth/index.d.ts +1 -2
  10. package/dist/auth/index.js +1 -2
  11. package/dist/auth/provider.d.ts +1 -1
  12. package/dist/auth/provider.js +16 -7
  13. package/dist/auth/refresh.d.ts +23 -4
  14. package/dist/auth/refresh.js +78 -22
  15. package/dist/auth/store.d.ts +78 -4
  16. package/dist/auth/store.js +385 -74
  17. package/dist/auth/token-metadata.d.ts +0 -1
  18. package/dist/auth/token-metadata.js +0 -1
  19. package/dist/auth/types.d.ts +0 -1
  20. package/dist/auth/types.js +0 -1
  21. package/dist/bin.d.ts +0 -1
  22. package/dist/bin.js +0 -1
  23. package/dist/cli.d.ts +4 -2
  24. package/dist/cli.js +13 -11
  25. package/dist/commands/account.d.ts +0 -1
  26. package/dist/commands/account.js +1 -2
  27. package/dist/commands/auth.d.ts +0 -1
  28. package/dist/commands/auth.js +71 -22
  29. package/dist/commands/billing.d.ts +0 -1
  30. package/dist/commands/billing.js +0 -1
  31. package/dist/commands/cloudflare.d.ts +1 -2
  32. package/dist/commands/cloudflare.js +14 -9
  33. package/dist/commands/helpers.d.ts +0 -1
  34. package/dist/commands/helpers.js +0 -1
  35. package/dist/commands/index.d.ts +0 -1
  36. package/dist/commands/index.js +0 -1
  37. package/dist/commands/legacy-validation.d.ts +7 -2
  38. package/dist/commands/legacy-validation.js +15 -3
  39. package/dist/commands/local.d.ts +6 -1
  40. package/dist/commands/local.js +36 -12
  41. package/dist/commands/one.d.ts +0 -1
  42. package/dist/commands/one.js +39 -13
  43. package/dist/commands/public-tools.d.ts +0 -1
  44. package/dist/commands/public-tools.js +63 -29
  45. package/dist/commands/runs.d.ts +0 -1
  46. package/dist/commands/runs.js +1 -2
  47. package/dist/commands/security.d.ts +1 -2
  48. package/dist/commands/security.js +34 -23
  49. package/dist/commands/watchdog.d.ts +0 -1
  50. package/dist/commands/watchdog.js +0 -1
  51. package/dist/index.d.ts +2 -3
  52. package/dist/index.js +1 -2
  53. package/dist/lib/banner.d.ts +0 -1
  54. package/dist/lib/banner.js +0 -1
  55. package/dist/lib/client.d.ts +9 -2
  56. package/dist/lib/client.js +49 -20
  57. package/dist/lib/cloudflare-client.d.ts +0 -1
  58. package/dist/lib/cloudflare-client.js +1 -2
  59. package/dist/lib/config.d.ts +16 -3
  60. package/dist/lib/config.js +41 -14
  61. package/dist/lib/format.d.ts +2 -1
  62. package/dist/lib/format.js +19 -8
  63. package/dist/lib/help.d.ts +4 -2
  64. package/dist/lib/help.js +72 -23
  65. package/dist/lib/network.d.ts +10 -1
  66. package/dist/lib/network.js +31 -4
  67. package/dist/lib/one-client.d.ts +4 -1
  68. package/dist/lib/one-client.js +9 -3
  69. package/dist/lib/one-error-hints.d.ts +19 -0
  70. package/dist/lib/one-error-hints.js +47 -0
  71. package/dist/lib/one-operations.d.ts +0 -1
  72. package/dist/lib/one-operations.js +0 -1
  73. package/dist/lib/open-url.d.ts +0 -1
  74. package/dist/lib/open-url.js +0 -1
  75. package/dist/lib/platform.d.ts +2 -0
  76. package/dist/lib/platform.js +4 -0
  77. package/dist/lib/progress.d.ts +0 -1
  78. package/dist/lib/progress.js +0 -1
  79. package/dist/lib/security-client.d.ts +0 -1
  80. package/dist/lib/security-client.js +0 -1
  81. package/dist/lib/skill-fetch.d.ts +0 -1
  82. package/dist/lib/skill-fetch.js +0 -1
  83. package/dist/lib/system-trust.d.ts +0 -1
  84. package/dist/lib/system-trust.js +0 -1
  85. package/dist/lib/tui.d.ts +0 -1
  86. package/dist/lib/tui.js +0 -1
  87. package/dist/local/cloudflare-checkup/cf/allowlist.d.ts +0 -1
  88. package/dist/local/cloudflare-checkup/cf/allowlist.js +0 -1
  89. package/dist/local/cloudflare-checkup/cf/auth-lifecycle.d.ts +0 -1
  90. package/dist/local/cloudflare-checkup/cf/auth-lifecycle.js +0 -1
  91. package/dist/local/cloudflare-checkup/cf/child-env.d.ts +0 -1
  92. package/dist/local/cloudflare-checkup/cf/child-env.js +0 -1
  93. package/dist/local/cloudflare-checkup/cf/install.d.ts +0 -1
  94. package/dist/local/cloudflare-checkup/cf/install.js +0 -1
  95. package/dist/local/cloudflare-checkup/cf/locate.d.ts +0 -1
  96. package/dist/local/cloudflare-checkup/cf/locate.js +0 -1
  97. package/dist/local/cloudflare-checkup/cf/run-cf.d.ts +0 -1
  98. package/dist/local/cloudflare-checkup/cf/run-cf.js +0 -1
  99. package/dist/local/cloudflare-checkup/collector.d.ts +0 -1
  100. package/dist/local/cloudflare-checkup/collector.js +0 -1
  101. package/dist/local/cloudflare-checkup/contract.d.ts +14 -3
  102. package/dist/local/cloudflare-checkup/contract.js +9 -3
  103. package/dist/local/cloudflare-checkup/email-verification.d.ts +0 -1
  104. package/dist/local/cloudflare-checkup/email-verification.js +0 -1
  105. package/dist/local/cloudflare-checkup/errors.d.ts +4 -1
  106. package/dist/local/cloudflare-checkup/errors.js +8 -2
  107. package/dist/local/cloudflare-checkup/output.d.ts +0 -1
  108. package/dist/local/cloudflare-checkup/output.js +0 -1
  109. package/dist/local/cloudflare-checkup/prompts.d.ts +0 -1
  110. package/dist/local/cloudflare-checkup/prompts.js +0 -1
  111. package/dist/local/cloudflare-checkup/rate-budget.d.ts +0 -1
  112. package/dist/local/cloudflare-checkup/rate-budget.js +0 -1
  113. package/dist/local/cloudflare-checkup/snapshot-file.d.ts +0 -1
  114. package/dist/local/cloudflare-checkup/snapshot-file.js +5 -4
  115. package/dist/local/cloudflare-checkup/submit-client.d.ts +19 -5
  116. package/dist/local/cloudflare-checkup/submit-client.js +63 -17
  117. package/dist/local/cloudflare-checkup/terminal-ui.d.ts +0 -1
  118. package/dist/local/cloudflare-checkup/terminal-ui.js +0 -1
  119. package/dist/types.d.ts +25 -3
  120. package/dist/types.js +16 -1
  121. package/dist/version.d.ts +0 -1
  122. package/dist/version.js +0 -1
  123. package/package.json +5 -9
  124. package/dist/auth/device-auth.d.ts.map +0 -1
  125. package/dist/auth/device-auth.js.map +0 -1
  126. package/dist/auth/index.d.ts.map +0 -1
  127. package/dist/auth/index.js.map +0 -1
  128. package/dist/auth/provider.d.ts.map +0 -1
  129. package/dist/auth/provider.js.map +0 -1
  130. package/dist/auth/refresh.d.ts.map +0 -1
  131. package/dist/auth/refresh.js.map +0 -1
  132. package/dist/auth/store.d.ts.map +0 -1
  133. package/dist/auth/store.js.map +0 -1
  134. package/dist/auth/token-metadata.d.ts.map +0 -1
  135. package/dist/auth/token-metadata.js.map +0 -1
  136. package/dist/auth/types.d.ts.map +0 -1
  137. package/dist/auth/types.js.map +0 -1
  138. package/dist/bin.d.ts.map +0 -1
  139. package/dist/bin.js.map +0 -1
  140. package/dist/cli.d.ts.map +0 -1
  141. package/dist/cli.js.map +0 -1
  142. package/dist/commands/account.d.ts.map +0 -1
  143. package/dist/commands/account.js.map +0 -1
  144. package/dist/commands/auth.d.ts.map +0 -1
  145. package/dist/commands/auth.js.map +0 -1
  146. package/dist/commands/billing.d.ts.map +0 -1
  147. package/dist/commands/billing.js.map +0 -1
  148. package/dist/commands/cloudflare.d.ts.map +0 -1
  149. package/dist/commands/cloudflare.js.map +0 -1
  150. package/dist/commands/helpers.d.ts.map +0 -1
  151. package/dist/commands/helpers.js.map +0 -1
  152. package/dist/commands/index.d.ts.map +0 -1
  153. package/dist/commands/index.js.map +0 -1
  154. package/dist/commands/legacy-validation.d.ts.map +0 -1
  155. package/dist/commands/legacy-validation.js.map +0 -1
  156. package/dist/commands/local.d.ts.map +0 -1
  157. package/dist/commands/local.js.map +0 -1
  158. package/dist/commands/one.d.ts.map +0 -1
  159. package/dist/commands/one.js.map +0 -1
  160. package/dist/commands/public-tools.d.ts.map +0 -1
  161. package/dist/commands/public-tools.js.map +0 -1
  162. package/dist/commands/runs.d.ts.map +0 -1
  163. package/dist/commands/runs.js.map +0 -1
  164. package/dist/commands/security.d.ts.map +0 -1
  165. package/dist/commands/security.js.map +0 -1
  166. package/dist/commands/watchdog.d.ts.map +0 -1
  167. package/dist/commands/watchdog.js.map +0 -1
  168. package/dist/index.d.ts.map +0 -1
  169. package/dist/index.js.map +0 -1
  170. package/dist/lib/banner.d.ts.map +0 -1
  171. package/dist/lib/banner.js.map +0 -1
  172. package/dist/lib/client.d.ts.map +0 -1
  173. package/dist/lib/client.js.map +0 -1
  174. package/dist/lib/cloudflare-client.d.ts.map +0 -1
  175. package/dist/lib/cloudflare-client.js.map +0 -1
  176. package/dist/lib/config.d.ts.map +0 -1
  177. package/dist/lib/config.js.map +0 -1
  178. package/dist/lib/format.d.ts.map +0 -1
  179. package/dist/lib/format.js.map +0 -1
  180. package/dist/lib/help.d.ts.map +0 -1
  181. package/dist/lib/help.js.map +0 -1
  182. package/dist/lib/network.d.ts.map +0 -1
  183. package/dist/lib/network.js.map +0 -1
  184. package/dist/lib/one-client.d.ts.map +0 -1
  185. package/dist/lib/one-client.js.map +0 -1
  186. package/dist/lib/one-operations.d.ts.map +0 -1
  187. package/dist/lib/one-operations.js.map +0 -1
  188. package/dist/lib/open-url.d.ts.map +0 -1
  189. package/dist/lib/open-url.js.map +0 -1
  190. package/dist/lib/progress.d.ts.map +0 -1
  191. package/dist/lib/progress.js.map +0 -1
  192. package/dist/lib/security-client.d.ts.map +0 -1
  193. package/dist/lib/security-client.js.map +0 -1
  194. package/dist/lib/skill-fetch.d.ts.map +0 -1
  195. package/dist/lib/skill-fetch.js.map +0 -1
  196. package/dist/lib/system-trust.d.ts.map +0 -1
  197. package/dist/lib/system-trust.js.map +0 -1
  198. package/dist/lib/tui.d.ts.map +0 -1
  199. package/dist/lib/tui.js.map +0 -1
  200. package/dist/local/cloudflare-checkup/cf/allowlist.d.ts.map +0 -1
  201. package/dist/local/cloudflare-checkup/cf/allowlist.js.map +0 -1
  202. package/dist/local/cloudflare-checkup/cf/auth-lifecycle.d.ts.map +0 -1
  203. package/dist/local/cloudflare-checkup/cf/auth-lifecycle.js.map +0 -1
  204. package/dist/local/cloudflare-checkup/cf/child-env.d.ts.map +0 -1
  205. package/dist/local/cloudflare-checkup/cf/child-env.js.map +0 -1
  206. package/dist/local/cloudflare-checkup/cf/install.d.ts.map +0 -1
  207. package/dist/local/cloudflare-checkup/cf/install.js.map +0 -1
  208. package/dist/local/cloudflare-checkup/cf/locate.d.ts.map +0 -1
  209. package/dist/local/cloudflare-checkup/cf/locate.js.map +0 -1
  210. package/dist/local/cloudflare-checkup/cf/run-cf.d.ts.map +0 -1
  211. package/dist/local/cloudflare-checkup/cf/run-cf.js.map +0 -1
  212. package/dist/local/cloudflare-checkup/collector.d.ts.map +0 -1
  213. package/dist/local/cloudflare-checkup/collector.js.map +0 -1
  214. package/dist/local/cloudflare-checkup/contract.d.ts.map +0 -1
  215. package/dist/local/cloudflare-checkup/contract.js.map +0 -1
  216. package/dist/local/cloudflare-checkup/email-verification.d.ts.map +0 -1
  217. package/dist/local/cloudflare-checkup/email-verification.js.map +0 -1
  218. package/dist/local/cloudflare-checkup/errors.d.ts.map +0 -1
  219. package/dist/local/cloudflare-checkup/errors.js.map +0 -1
  220. package/dist/local/cloudflare-checkup/output.d.ts.map +0 -1
  221. package/dist/local/cloudflare-checkup/output.js.map +0 -1
  222. package/dist/local/cloudflare-checkup/prompts.d.ts.map +0 -1
  223. package/dist/local/cloudflare-checkup/prompts.js.map +0 -1
  224. package/dist/local/cloudflare-checkup/rate-budget.d.ts.map +0 -1
  225. package/dist/local/cloudflare-checkup/rate-budget.js.map +0 -1
  226. package/dist/local/cloudflare-checkup/snapshot-file.d.ts.map +0 -1
  227. package/dist/local/cloudflare-checkup/snapshot-file.js.map +0 -1
  228. package/dist/local/cloudflare-checkup/submit-client.d.ts.map +0 -1
  229. package/dist/local/cloudflare-checkup/submit-client.js.map +0 -1
  230. package/dist/local/cloudflare-checkup/terminal-ui.d.ts.map +0 -1
  231. package/dist/local/cloudflare-checkup/terminal-ui.js.map +0 -1
  232. package/dist/types.d.ts.map +0 -1
  233. package/dist/types.js.map +0 -1
  234. package/dist/version.d.ts.map +0 -1
  235. package/dist/version.js.map +0 -1
@@ -6,6 +6,7 @@ import { z } from 'zod';
6
6
  import { validateOneOrigin } from './config.js';
7
7
  import { validateStripePortalUrl } from './open-url.js';
8
8
  import { parseJsonResponse, requestText } from './network.js';
9
+ import { oneErrorHint } from './one-error-hints.js';
9
10
  import { retryAfterSeconds, VigilbaseApiError } from './client.js';
10
11
  /**
11
12
  * Tools that require Vigilbase One authentication (auth-required scanners).
@@ -84,6 +85,8 @@ export class VigilbaseOneClient {
84
85
  config;
85
86
  accessToken;
86
87
  managed;
88
+ /** The userinfo endpoint Identity discovery named for the last getSession, if it used Identity. */
89
+ userinfoEndpoint;
87
90
  constructor(config, accessToken, managed = false) {
88
91
  this.config = config;
89
92
  this.accessToken = accessToken;
@@ -127,9 +130,12 @@ export class VigilbaseOneClient {
127
130
  if (errorDetails.code === 'FLAREHAWK_VIEW_AS_REQUIRED') {
128
131
  message = 'Select a customer with --customer-id <customer UUID> for security commands.';
129
132
  }
133
+ const hint = response.ok ? undefined : oneErrorHint({
134
+ method: init?.method ?? 'GET', path, status: response.status, code: errorDetails.code, hasCustomerScope: options?.hasCustomerScope,
135
+ });
130
136
  if (response.status === 401 || response.status === 403) {
131
137
  throw new VigilbaseApiError(message ||
132
- 'Authentication required. Run `vigilbase login`.', { status: response.status, body: parsed, code: errorDetails.code });
138
+ 'Authentication required. Run `vigilbase login`.', { status: response.status, body: parsed, code: errorDetails.code, hint });
133
139
  }
134
140
  if (response.status === 429) {
135
141
  throw new VigilbaseApiError(message || 'Rate limit exceeded.', {
@@ -142,7 +148,7 @@ export class VigilbaseOneClient {
142
148
  const allowed = options?.allowStatuses ?? [];
143
149
  if (!response.ok && !allowed.includes(response.status)) {
144
150
  throw new VigilbaseApiError(message ||
145
- `Request failed (HTTP ${response.status})`, { status: response.status, body: parsed, code: errorDetails.code });
151
+ `Request failed (HTTP ${response.status})`, { status: response.status, body: parsed, code: errorDetails.code, hint });
146
152
  }
147
153
  if (!z.record(z.string(), z.unknown()).safeParse(body).success) {
148
154
  throw new VigilbaseApiError('Invalid One API response. Expected a JSON object.', { status: response.status });
@@ -157,6 +163,7 @@ export class VigilbaseOneClient {
157
163
  const issuer = this.config.authProvider?.issuer ?? (saved?.version === 2 ? saved.one?.issuer : undefined);
158
164
  if (issuer) {
159
165
  const provider = await identityProvider(this.config, issuer);
166
+ this.userinfoEndpoint = provider.userinfoEndpoint;
160
167
  if (this.managed) {
161
168
  const token = await managedAccessToken(this.config);
162
169
  if (!token)
@@ -283,4 +290,3 @@ export class VigilbaseOneClient {
283
290
  }, { allowStatuses: [422] });
284
291
  }
285
292
  }
286
- //# sourceMappingURL=one-client.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * CLI-authored hints for One errors the CLI recognises. They are chosen only
3
+ * from the request (method, route, whether a customer was selected), the HTTP
4
+ * status and One's own error codes. One's free-text messages are never shown:
5
+ * they can describe its configuration.
6
+ */
7
+ export declare const STAFF_CUSTOMER_SCOPE_HINT = "Vigilbase staff: add --customer-id <uuid>.";
8
+ export declare const PERSONAL_SETTINGS_HINT = "Personal settings belong to each user, so View-as (--customer-id) cannot read them.";
9
+ export declare const BROWSER_SESSION_HINT = "Invitations need a One browser session: manage them at https://one.vigilbase.com.";
10
+ export type OneErrorContext = {
11
+ method: string;
12
+ /** The One path the CLI requested, with its query string. */
13
+ path: string;
14
+ status: number;
15
+ code?: string;
16
+ /** Whether the request named a customer; defaults to a `customerId` query parameter. */
17
+ hasCustomerScope?: boolean;
18
+ };
19
+ export declare function oneErrorHint(context: OneErrorContext): string | undefined;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * CLI-authored hints for One errors the CLI recognises. They are chosen only
3
+ * from the request (method, route, whether a customer was selected), the HTTP
4
+ * status and One's own error codes. One's free-text messages are never shown:
5
+ * they can describe its configuration.
6
+ */
7
+ export const STAFF_CUSTOMER_SCOPE_HINT = 'Vigilbase staff: add --customer-id <uuid>.';
8
+ export const PERSONAL_SETTINGS_HINT = 'Personal settings belong to each user, so View-as (--customer-id) cannot read them.';
9
+ export const BROWSER_SESSION_HINT = 'Invitations need a One browser session: manage them at https://one.vigilbase.com.';
10
+ /** One's security boundary codes that already explain a 403 (apps/one/src/lib/flarehawk/access.ts). */
11
+ const SECURITY_ACCESS_CODES = new Set([
12
+ 'FLAREHAWK_CUSTOMER_ACCESS_DENIED',
13
+ 'FLAREHAWK_ROLE_UNSUPPORTED',
14
+ 'FLAREHAWK_ROLE_INSUFFICIENT',
15
+ 'FLAREHAWK_ORGANIZATION_REQUIRED',
16
+ 'FLAREHAWK_VIEW_AS_REQUIRED',
17
+ ]);
18
+ const RULES = [
19
+ // Staff sessions must name the customer; One answers 400 without one.
20
+ { method: 'GET', route: /^\/api\/support\/tickets$/u, status: 400, hasCustomerScope: false, hint: STAFF_CUSTOMER_SCOPE_HINT },
21
+ { method: 'GET', route: /^\/api\/services\/cloudflare\/checkups$/u, status: 400, hasCustomerScope: false, hint: STAFF_CUSTOMER_SCOPE_HINT },
22
+ { method: 'POST', route: /^\/api\/services\/cloudflare\/checkups\/start$/u, status: 400, hasCustomerScope: false, hint: STAFF_CUSTOMER_SCOPE_HINT },
23
+ { method: 'GET', route: /^\/api\/services\/cloudflare\/workspace(?:\/[a-z-]+)?$/u, status: 400, hasCustomerScope: false, hint: STAFF_CUSTOMER_SCOPE_HINT },
24
+ // Personal security settings are per user; a View-as read is refused.
25
+ {
26
+ method: 'GET',
27
+ route: /^\/api\/flarehawk\/(?:settings\/(?:lifecycle-emails|broadcast-emails)|integrations\/grants|notifications\/preferences)$/u,
28
+ status: 403,
29
+ hasCustomerScope: true,
30
+ hint: PERSONAL_SETTINGS_HINT,
31
+ excludedCodes: SECURITY_ACCESS_CODES,
32
+ },
33
+ // Identity's management API accepts only One browser sessions, so CLI tokens can't read or send invitations.
34
+ { method: 'GET', route: /^\/api\/auth\/orgs\/invitations$/u, status: 403, hasCustomerScope: false, hint: BROWSER_SESSION_HINT, code: 'browser_session_required' },
35
+ { method: 'POST', route: /^\/api\/auth\/orgs\/invite$/u, status: 403, hasCustomerScope: false, hint: BROWSER_SESSION_HINT, code: 'browser_session_required' },
36
+ ];
37
+ export function oneErrorHint(context) {
38
+ const [pathname = '', query = ''] = context.path.split('?', 2);
39
+ const hasCustomerScope = context.hasCustomerScope ?? new URLSearchParams(query).has('customerId');
40
+ const method = context.method.toUpperCase();
41
+ return RULES.find((rule) => rule.method === method &&
42
+ rule.status === context.status &&
43
+ rule.hasCustomerScope === hasCustomerScope &&
44
+ rule.route.test(pathname) &&
45
+ (rule.code === undefined || rule.code === context.code) &&
46
+ !(context.code !== undefined && rule.excludedCodes?.has(context.code)))?.hint;
47
+ }
@@ -8,4 +8,3 @@ export interface OneOperation {
8
8
  export declare function executeOneOperation(client: VigilbaseOneClient, operation: OneOperation): Promise<Record<string, unknown>>;
9
9
  /** Render all fields, including pagination and degraded-health metadata. */
10
10
  export declare function formatOnePayload(value: unknown, indent?: string): string[];
11
- //# sourceMappingURL=one-operations.d.ts.map
@@ -64,4 +64,3 @@ export function formatOnePayload(value, indent = '') {
64
64
  return [`${indent}${safeText(key)}: ${safeText(item)}`];
65
65
  });
66
66
  }
67
- //# sourceMappingURL=one-operations.js.map
@@ -24,4 +24,3 @@ export declare function resolveDeviceVerificationUrl(oneBaseUrl: string, device:
24
24
  verification_uri?: string;
25
25
  verification_uri_complete?: string;
26
26
  }): string;
27
- //# sourceMappingURL=open-url.d.ts.map
@@ -110,4 +110,3 @@ export function resolveDeviceVerificationUrl(oneBaseUrl, device) {
110
110
  // redirect parameters, fragments, or paths, even when they share One's origin.
111
111
  return fallback;
112
112
  }
113
- //# sourceMappingURL=open-url.js.map
@@ -0,0 +1,2 @@
1
+ /** The host platform. A function rather than a constant so tests can simulate Windows. */
2
+ export declare function platform(): NodeJS.Platform;
@@ -0,0 +1,4 @@
1
+ /** The host platform. A function rather than a constant so tests can simulate Windows. */
2
+ export function platform() {
3
+ return process.platform;
4
+ }
@@ -17,4 +17,3 @@ export declare function shouldShowProgress(mode: 'text' | 'json', env?: NodeJS.P
17
17
  }): boolean;
18
18
  /** Tiny helper so call sites stay readable. */
19
19
  export declare function withProgress<T>(label: string, mode: 'text' | 'json', work: () => Promise<T>, writer?: Writer): Promise<T>;
20
- //# sourceMappingURL=progress.d.ts.map
@@ -77,4 +77,3 @@ export async function withProgress(label, mode, work, writer) {
77
77
  throw error;
78
78
  }
79
79
  }
80
- //# sourceMappingURL=progress.js.map
@@ -276,4 +276,3 @@ export declare class SecurityClient {
276
276
  constructor(one: VigilbaseOneClient);
277
277
  request(input: SecurityRequest): Promise<SecurityPayload>;
278
278
  }
279
- //# sourceMappingURL=security-client.d.ts.map
@@ -108,4 +108,3 @@ export class SecurityClient {
108
108
  return payload;
109
109
  }
110
110
  }
111
- //# sourceMappingURL=security-client.js.map
@@ -4,4 +4,3 @@ export declare function isPublicSkillAddress(address: string): boolean;
4
4
  export declare function validateSkillUrl(raw: string): URL;
5
5
  /** Resolve once, reject mixed private/public DNS, and pin the validated address to TLS. */
6
6
  export declare function fetchSkillText(config: CliConfig, raw: string): Promise<string>;
7
- //# sourceMappingURL=skill-fetch.d.ts.map
@@ -99,4 +99,3 @@ export async function fetchSkillText(config, raw) {
99
99
  clearTimeout(timer);
100
100
  }
101
101
  }
102
- //# sourceMappingURL=skill-fetch.js.map
@@ -5,4 +5,3 @@ type SystemTrustApi = {
5
5
  /** CLI startup only: preserve bundled/extra CAs and add OS-managed trust. */
6
6
  export declare function configureSystemTrust(api?: SystemTrustApi): boolean;
7
7
  export {};
8
- //# sourceMappingURL=system-trust.d.ts.map
@@ -8,4 +8,3 @@ export function configureSystemTrust(api = tls) {
8
8
  ]);
9
9
  return true;
10
10
  }
11
- //# sourceMappingURL=system-trust.js.map
package/dist/lib/tui.d.ts CHANGED
@@ -306,4 +306,3 @@ export declare function wasRendered(error: unknown): boolean;
306
306
  * own. Leading spaces (an indented line) are kept on every line.
307
307
  */
308
308
  export declare function wrapWords(text: string, width: number): string[];
309
- //# sourceMappingURL=tui.d.ts.map
package/dist/lib/tui.js CHANGED
@@ -844,4 +844,3 @@ function tail(text, width) {
844
844
  used += charWidth(chars[--start]);
845
845
  return chars.slice(start).join('');
846
846
  }
847
- //# sourceMappingURL=tui.js.map
@@ -92,4 +92,3 @@ export declare function loginArgv(profile: string, scopes: readonly string[], op
92
92
  */
93
93
  export declare function logoutArgv(profile: string): string[];
94
94
  export {};
95
- //# sourceMappingURL=allowlist.d.ts.map
@@ -181,4 +181,3 @@ export function loginArgv(profile, scopes, options) {
181
181
  export function logoutArgv(profile) {
182
182
  return ['auth', 'delete', validateProfileName(profile)];
183
183
  }
184
- //# sourceMappingURL=allowlist.js.map
@@ -110,4 +110,3 @@ export declare class CfScheduler {
110
110
  }
111
111
  /** `null` for a clean exit; otherwise the classified failure. */
112
112
  export declare function toFailure(result: CfProcessResult): CfCallFailure | null;
113
- //# sourceMappingURL=auth-lifecycle.d.ts.map
@@ -310,4 +310,3 @@ export function toFailure(result) {
310
310
  }
311
311
  return classified;
312
312
  }
313
- //# sourceMappingURL=auth-lifecycle.js.map
@@ -29,4 +29,3 @@ export declare function childEnvVariableNames(parent: NodeJS.ProcessEnv, authMod
29
29
  /** Shown in profile and default modes when the token variable is set in the parent shell. */
30
30
  export declare function strippedTokenNotice(authMode: CfAuthMode): string;
31
31
  export declare function missingEnvTokenMessage(): string;
32
- //# sourceMappingURL=child-env.d.ts.map
@@ -78,4 +78,3 @@ export function strippedTokenNotice(authMode) {
78
78
  export function missingEnvTokenMessage() {
79
79
  return `--cf-auth env requires ${CF_TOKEN_ENV} in this shell. cf reads it itself; the Vigilbase CLI only passes it through by name.`;
80
80
  }
81
- //# sourceMappingURL=child-env.js.map
@@ -103,4 +103,3 @@ export declare function removeManagedCf(configDir: string): Promise<{
103
103
  path: string;
104
104
  removed: boolean;
105
105
  }>;
106
- //# sourceMappingURL=install.d.ts.map
@@ -306,4 +306,3 @@ export async function removeManagedCf(configDir) {
306
306
  await rm(root, { recursive: true, force: true });
307
307
  return { path: root, removed: true };
308
308
  }
309
- //# sourceMappingURL=install.js.map
@@ -41,4 +41,3 @@ export type CfVersionInfo = {
41
41
  };
42
42
  /** Gate the version cf prints against its package.json and `CF_SUPPORTED`. */
43
43
  export declare function checkCfVersion(printed: string, packageVersion: string): CfVersionInfo;
44
- //# sourceMappingURL=locate.d.ts.map
@@ -225,4 +225,3 @@ export function checkCfVersion(printed, packageVersion) {
225
225
  }
226
226
  return { version, tested: CF_SUPPORTED.tested.includes(version) };
227
227
  }
228
- //# sourceMappingURL=locate.js.map
@@ -86,4 +86,3 @@ export declare function parseCfJson(stdout: string, shape: 'array' | 'object'):
86
86
  } | {
87
87
  ok: false;
88
88
  };
89
- //# sourceMappingURL=run-cf.d.ts.map
@@ -272,4 +272,3 @@ export function parseCfJson(stdout, shape) {
272
272
  return { ok: true, value };
273
273
  return { ok: false };
274
274
  }
275
- //# sourceMappingURL=run-cf.js.map
@@ -45,4 +45,3 @@ export declare function buildSnapshot(accountId: string, collector: SnapshotColl
45
45
  snapshot: CloudflareCheckupSnapshotV1;
46
46
  text: string;
47
47
  };
48
- //# sourceMappingURL=collector.d.ts.map
@@ -293,4 +293,3 @@ export function buildSnapshot(accountId, collector, entries) {
293
293
  }
294
294
  return { snapshot: parsed.data, text };
295
295
  }
296
- //# sourceMappingURL=collector.js.map
@@ -33,6 +33,8 @@ export declare const SESSION_CODE_REGEX: RegExp;
33
33
  export declare const PRODUCTION_ORIGIN: "https://vigilbase.com";
34
34
  export declare const LOCAL_SESSION_PATH: "/api/v1/tools/cloudflare-checkup/local-session";
35
35
  export declare const LOCAL_SNAPSHOT_PATH: "/api/v1/tools/cloudflare-checkup/local-session/snapshot";
36
+ /** Before asking for an email, the CLI checks that local checkups are on and what they accept (no auth, no side effects). */
37
+ export declare const LOCAL_AVAILABILITY_PATH: "/api/v1/tools/cloudflare-checkup/local-session/availability";
36
38
  /** The CLI asks vigilbase.com to email a verification code (no browser, no Turnstile). */
37
39
  export declare const LOCAL_REQUEST_PATH: "/api/v1/tools/cloudflare-checkup/local-session/request";
38
40
  /** The CLI trades the verification token and the emailed code for a session code. */
@@ -2707,6 +2709,15 @@ export declare const LocalSessionResponseSchema: z.ZodObject<{
2707
2709
  minCliVersion: z.ZodString;
2708
2710
  }, z.core.$strip>;
2709
2711
  }, z.core.$strip>;
2712
+ export declare const LocalAvailabilityResponseSchema: z.ZodObject<{
2713
+ enabled: z.ZodLiteral<true>;
2714
+ minCliVersion: z.ZodString;
2715
+ accepts: z.ZodObject<{
2716
+ schemaVersions: z.ZodArray<z.ZodString>;
2717
+ maxBytes: z.ZodNumber;
2718
+ maxZones: z.ZodNumber;
2719
+ }, z.core.$strip>;
2720
+ }, z.core.$strip>;
2710
2721
  export declare const LocalSnapshotResponseSchema: z.ZodObject<{
2711
2722
  success: z.ZodLiteral<true>;
2712
2723
  replayed: z.ZodBoolean;
@@ -2749,6 +2760,8 @@ export declare const LocalErrorResponseSchema: z.ZodObject<{
2749
2760
  code: z.ZodString;
2750
2761
  reason: z.ZodOptional<z.ZodEnum<{
2751
2762
  rate_limited: "rate_limited";
2763
+ length_required: "length_required";
2764
+ unsupported_media_type: "unsupported_media_type";
2752
2765
  snapshot_invalid: "snapshot_invalid";
2753
2766
  snapshot_incomplete: "snapshot_incomplete";
2754
2767
  secret_like_value: "secret_like_value";
@@ -2761,8 +2774,6 @@ export declare const LocalErrorResponseSchema: z.ZodObject<{
2761
2774
  browser_origin: "browser_origin";
2762
2775
  malformed_json: "malformed_json";
2763
2776
  digest_mismatch: "digest_mismatch";
2764
- unsupported_media_type: "unsupported_media_type";
2765
- length_required: "length_required";
2766
2777
  snapshot_too_large: "snapshot_too_large";
2767
2778
  account_mismatch: "account_mismatch";
2768
2779
  snapshot_stale: "snapshot_stale";
@@ -2783,6 +2794,7 @@ export declare const LocalErrorResponseSchema: z.ZodObject<{
2783
2794
  }, z.core.$strip>>>;
2784
2795
  }, z.core.$strip>;
2785
2796
  export type LocalSessionResponse = z.infer<typeof LocalSessionResponseSchema>;
2797
+ export type LocalAvailabilityResponse = z.infer<typeof LocalAvailabilityResponseSchema>;
2786
2798
  export type LocalSnapshotResponse = z.infer<typeof LocalSnapshotResponseSchema>;
2787
2799
  export type LocalErrorResponse = z.infer<typeof LocalErrorResponseSchema>;
2788
2800
  export type LocalRequestBody = z.infer<typeof LocalRequestBodySchema>;
@@ -2790,4 +2802,3 @@ export type LocalVerifyBody = z.infer<typeof LocalVerifyBodySchema>;
2790
2802
  export type LocalRequestResponse = z.infer<typeof LocalRequestResponseSchema>;
2791
2803
  export type LocalVerifyResponse = z.infer<typeof LocalVerifyResponseSchema>;
2792
2804
  export {};
2793
- //# sourceMappingURL=contract.d.ts.map
@@ -37,6 +37,8 @@ export const SESSION_CODE_REGEX = /^vbcs1_[A-Za-z0-9_-]{66}$/;
37
37
  export const PRODUCTION_ORIGIN = 'https://vigilbase.com';
38
38
  export const LOCAL_SESSION_PATH = '/api/v1/tools/cloudflare-checkup/local-session';
39
39
  export const LOCAL_SNAPSHOT_PATH = '/api/v1/tools/cloudflare-checkup/local-session/snapshot';
40
+ /** Before asking for an email, the CLI checks that local checkups are on and what they accept (no auth, no side effects). */
41
+ export const LOCAL_AVAILABILITY_PATH = '/api/v1/tools/cloudflare-checkup/local-session/availability';
40
42
  /** The CLI asks vigilbase.com to email a verification code (no browser, no Turnstile). */
41
43
  export const LOCAL_REQUEST_PATH = '/api/v1/tools/cloudflare-checkup/local-session/request';
42
44
  /** The CLI trades the verification token and the emailed code for a session code. */
@@ -1586,12 +1588,17 @@ export const LOCAL_ERROR_REASONS = ['session_invalid', 'session_expired', 'sessi
1586
1588
  'collector_unsupported', 'secret_like_value', 'evaluation_failed', 'rate_limited', 'local_mode_disabled', 'storage_unavailable',
1587
1589
  'request_invalid', 'email_invalid', 'code_invalid', 'verification_invalid', 'verification_expired'];
1588
1590
  export const LOCAL_SESSION_STATES = ['awaiting_upload', 'processing', 'completed'];
1591
+ const LocalAcceptsSchema = z.object({ schemaVersions: z.array(z.string()).min(1), maxBytes: z.number().int().positive(),
1592
+ maxZones: z.number().int().positive() });
1589
1593
  // `accountId` is null until an uploaded snapshot binds the run (the CLI chooses the account); runs created
1590
1594
  // with an account keep it, and a completed run reports the evaluated account.
1591
1595
  export const LocalSessionResponseSchema = z.object({ success: z.literal(true), session: z.object({ accountId: hex32.nullable(),
1592
1596
  requester: z.string().max(260), expiresAt: iso, state: z.enum(LOCAL_SESSION_STATES),
1593
- accepts: z.object({ schemaVersions: z.array(z.string()).min(1), maxBytes: z.number().int().positive(),
1594
- maxZones: z.number().int().positive() }), minCliVersion: semver }) });
1597
+ accepts: LocalAcceptsSchema, minCliVersion: semver }) });
1598
+ // `GET local-session/availability`: local checkups are on, with what a checkup would accept. While they are
1599
+ // off it answers 503 `local_mode_disabled`, like every local-session route.
1600
+ export const LocalAvailabilityResponseSchema = z.object({ enabled: z.literal(true), minCliVersion: semver,
1601
+ accepts: LocalAcceptsSchema });
1595
1602
  // `resultsUrl` is the run's results page; the CLI opens it only when it is on the upload origin.
1596
1603
  export const LocalSnapshotResponseSchema = z.object({ success: z.literal(true), replayed: z.boolean(),
1597
1604
  snapshotSha256: z.string().regex(/^[0-9a-f]{64}$/),
@@ -1611,4 +1618,3 @@ export const LocalVerifyResponseSchema = z.object({ success: z.literal(true), se
1611
1618
  export const LocalErrorResponseSchema = z.object({ success: z.literal(false), status: z.number().int(), code: z.string(),
1612
1619
  reason: z.enum(LOCAL_ERROR_REASONS).optional(), retryAfterSec: z.number().int().nonnegative().optional(),
1613
1620
  issues: z.array(z.object({ path: z.string().max(200), code: z.string().max(64) })).max(20).optional() });
1614
- //# sourceMappingURL=contract.js.map
@@ -122,4 +122,3 @@ export declare const SAME_ADDRESS_WAIT = "The same address can get a new code 8
122
122
  * same address would be refused for 8 minutes.
123
123
  */
124
124
  export declare function verifyEmail(options: EmailVerificationOptions): Promise<VerifiedEmail>;
125
- //# sourceMappingURL=email-verification.d.ts.map
@@ -209,4 +209,3 @@ export async function verifyEmail(options) {
209
209
  }
210
210
  }
211
211
  }
212
- //# sourceMappingURL=email-verification.js.map
@@ -1,5 +1,7 @@
1
1
  export declare const LOCAL_ERROR_CODES: readonly ["NODE_UNSUPPORTED", "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", "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"];
2
2
  export type LocalCheckupErrorCode = (typeof LOCAL_ERROR_CODES)[number];
3
+ /** LOCAL_MODE_DISABLED: the browser checkup on the origin the CLI talks to (vigilbase.com, or a loopback dev server). */
4
+ export declare function browserCheckupHint(origin: string): string;
3
5
  /** One fix per code; shown after the error and in `--json` as `hint`. */
4
6
  export declare const LOCAL_ERROR_HINTS: Record<LocalCheckupErrorCode, string>;
5
7
  /**
@@ -8,6 +10,8 @@ export declare const LOCAL_ERROR_HINTS: Record<LocalCheckupErrorCode, string>;
8
10
  * hint names both ways out.
9
11
  */
10
12
  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.";
13
+ /** SNAPSHOT_INVALID for an `inspect` or `submit` path with no file: nothing to collect again, so how to make one. */
14
+ 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>`.";
11
15
  /** CF_PERMISSION_DENIED in env mode: the token lacks a read permission; the browser sign-in is the other way out. */
12
16
  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.";
13
17
  export declare class LocalCheckupError extends Error {
@@ -25,4 +29,3 @@ export declare class LocalCheckupError extends Error {
25
29
  get isRateLimited(): boolean;
26
30
  }
27
31
  export declare function isLocalCheckupError(error: unknown): error is LocalCheckupError;
28
- //# sourceMappingURL=errors.d.ts.map
@@ -8,6 +8,7 @@
8
8
  * troubleshooting accordion mirrors the code set.
9
9
  */
10
10
  import { CF_TOKEN_ENV } from './cf/child-env.js';
11
+ import { PRODUCTION_ORIGIN } from './contract.js';
11
12
  export const LOCAL_ERROR_CODES = [
12
13
  // Environment and cf
13
14
  'NODE_UNSUPPORTED', 'CF_NOT_FOUND', 'CF_WRONG_BINARY', 'CF_UNSUPPORTED_VERSION', 'CF_ALLOWLIST_MISMATCH',
@@ -25,6 +26,10 @@ export const LOCAL_ERROR_CODES = [
25
26
  'VIGILBASE_RATE_LIMITED', 'VIGILBASE_CHALLENGED', 'SUBMIT_FAILED',
26
27
  ];
27
28
  const INSTALL_CF = '`npm install --global cf@1.0.0-beta.13`';
29
+ /** LOCAL_MODE_DISABLED: the browser checkup on the origin the CLI talks to (vigilbase.com, or a loopback dev server). */
30
+ export function browserCheckupHint(origin) {
31
+ return `Run the Cloudflare Checkup in your browser instead: ${origin}/tools/cloudflare-checkup`;
32
+ }
28
33
  /** One fix per code; shown after the error and in `--json` as `hint`. */
29
34
  export const LOCAL_ERROR_HINTS = {
30
35
  NODE_UNSUPPORTED: 'Install Node.js 22.18 or newer from https://nodejs.org (cf runs under the same Node), then run the same command again.',
@@ -59,7 +64,7 @@ export const LOCAL_ERROR_HINTS = {
59
64
  SUBMIT_ORIGIN_UNTRUSTED: 'Upload only to https://vigilbase.com (or a loopback origin for local testing).',
60
65
  CONFIRMATION_REQUIRED: 'Run the command in a terminal to confirm the upload, or add --yes.',
61
66
  CLI_UPGRADE_REQUIRED: 'Run `npx @vigilbase/cli@latest cloudflare-checkup`, or upgrade with `npm install --global @vigilbase/cli@latest`.',
62
- LOCAL_MODE_DISABLED: 'Local checkups are temporarily unavailable. Use the browser token mode on vigilbase.com, or try later.',
67
+ LOCAL_MODE_DISABLED: browserCheckupHint(PRODUCTION_ORIGIN),
63
68
  VIGILBASE_RATE_LIMITED: 'Too many requests to vigilbase.com. Wait as long as the error says (a few minutes if it says nothing), then run the same command again.',
64
69
  VIGILBASE_CHALLENGED: 'vigilbase.com asked for a browser challenge. Try another network, or contact help@vigilbase.com.',
65
70
  SUBMIT_FAILED: 'Run the same command again in a few minutes. If it persists, contact help@vigilbase.com.',
@@ -70,6 +75,8 @@ export const LOCAL_ERROR_HINTS = {
70
75
  * hint names both ways out.
71
76
  */
72
77
  export const ENV_TOKEN_AUTH_HINT = `Set ${CF_TOKEN_ENV} in this shell to a valid read-only Cloudflare API token (read -rs ${CF_TOKEN_ENV} && export ${CF_TOKEN_ENV}) and run the same command again, or unset it (or use --cf-auth profile) to sign in with your browser instead.`;
78
+ /** SNAPSHOT_INVALID for an `inspect` or `submit` path with no file: nothing to collect again, so how to make one. */
79
+ export const SNAPSHOT_MISSING_HINT = 'Check the file path. To collect a snapshot into a file, run `npx @vigilbase/cli cloudflare-checkup collect --out <file>`.';
73
80
  /** CF_PERMISSION_DENIED in env mode: the token lacks a read permission; the browser sign-in is the other way out. */
74
81
  export const ENV_TOKEN_PERMISSION_HINT = `The API token in ${CF_TOKEN_ENV} 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.`;
75
82
  export class LocalCheckupError extends Error {
@@ -96,4 +103,3 @@ export class LocalCheckupError extends Error {
96
103
  export function isLocalCheckupError(error) {
97
104
  return error instanceof LocalCheckupError;
98
105
  }
99
- //# sourceMappingURL=errors.js.map
@@ -21,4 +21,3 @@ export type CountsProgress = {
21
21
  };
22
22
  /** A single updating stderr line, or nothing when progress is disabled. */
23
23
  export declare function startCountsProgress(enabled: boolean, stream?: NodeJS.WritableStream): CountsProgress;
24
- //# sourceMappingURL=output.d.ts.map
@@ -86,4 +86,3 @@ export function startCountsProgress(enabled, stream = process.stderr) {
86
86
  },
87
87
  };
88
88
  }
89
- //# sourceMappingURL=output.js.map
@@ -38,4 +38,3 @@ export declare function confirmUpload(io: PromptIO, question: string, options: {
38
38
  * CONFIRMATION_REQUIRED.
39
39
  */
40
40
  export declare function confirmDefaultYes(io: PromptIO, question: string): Promise<boolean>;
41
- //# sourceMappingURL=prompts.d.ts.map
@@ -137,4 +137,3 @@ export async function confirmDefaultYes(io, question) {
137
137
  function inputEnded(message) {
138
138
  return new LocalCheckupError('CONFIRMATION_REQUIRED', message, { hint: 'Run the same command again and answer the question, or add --yes.' });
139
139
  }
140
- //# sourceMappingURL=prompts.js.map
@@ -39,4 +39,3 @@ export declare class RequestBudget {
39
39
  }
40
40
  /** Seconds a full bucket needs to admit `requests` calls at `limit` per 5 minutes. */
41
41
  export declare function estimateBudgetSeconds(limit: number, requests: number, burst?: number): number;
42
- //# sourceMappingURL=rate-budget.d.ts.map
@@ -77,4 +77,3 @@ export class RequestBudget {
77
77
  export function estimateBudgetSeconds(limit, requests, burst = BUDGET_BURST) {
78
78
  return Math.max(0, ((requests - burst) * BUDGET_WINDOW_MS) / (limit - burst) / 1000);
79
79
  }
80
- //# sourceMappingURL=rate-budget.js.map
@@ -50,4 +50,3 @@ export type DataCategories = {
50
50
  export declare function dataCategories(snapshot: CloudflareCheckupSnapshotV1): DataCategories;
51
51
  export declare function zoneCount(snapshot: CloudflareCheckupSnapshotV1): number;
52
52
  export declare function accountName(snapshot: CloudflareCheckupSnapshotV1): string | null;
53
- //# sourceMappingURL=snapshot-file.d.ts.map
@@ -13,7 +13,7 @@ import { createHash, randomBytes } from 'node:crypto';
13
13
  import { link, open, readFile, rename, rm, stat } from 'node:fs/promises';
14
14
  import { basename, dirname, join } from 'node:path';
15
15
  import { CloudflareCheckupSnapshotV1Schema, SNAPSHOT_LIMITS, SNAPSHOT_SCHEMA_VERSION, expandRuleRuns, snapshotIssueList, snapshotRejectReason, } from './contract.js';
16
- import { LocalCheckupError } from './errors.js';
16
+ import { LocalCheckupError, SNAPSHOT_MISSING_HINT } from './errors.js';
17
17
  export function sha256Hex(bytes) {
18
18
  return createHash('sha256').update(bytes).digest('hex');
19
19
  }
@@ -90,8 +90,10 @@ export function snapshotParseError(issues) {
90
90
  /** Read, hash and validate a snapshot file against the vendored contract. */
91
91
  export async function loadSnapshotFile(path) {
92
92
  const info = await stat(path).catch(() => null);
93
- if (!info || !info.isFile())
94
- throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot file does not exist or is not a regular file.');
93
+ if (!info)
94
+ throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot file does not exist.', { hint: SNAPSHOT_MISSING_HINT });
95
+ if (!info.isFile())
96
+ throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot path is not a file.', { hint: SNAPSHOT_MISSING_HINT });
95
97
  if (info.size > SNAPSHOT_LIMITS.maxBytes) {
96
98
  throw new LocalCheckupError('SNAPSHOT_TOO_LARGE', `The snapshot is larger than the ${SNAPSHOT_LIMITS.maxBytes / 1024 / 1024} MiB contract limit.`);
97
99
  }
@@ -183,4 +185,3 @@ export function accountName(snapshot) {
183
185
  const account = snapshot.entries.find((entry) => entry.kind === 'account');
184
186
  return account && account.kind === 'account' && account.result.ok ? account.result.data.name : null;
185
187
  }
186
- //# sourceMappingURL=snapshot-file.js.map
@@ -1,20 +1,26 @@
1
- import { type LocalRequestBody, type LocalRequestResponse, type LocalSessionResponse, type LocalVerifyBody, type LocalVerifyResponse } from './contract.js';
1
+ import { type LocalAvailabilityResponse, type LocalRequestBody, type LocalRequestResponse, type LocalSessionResponse, type LocalVerifyBody, type LocalVerifyResponse } from './contract.js';
2
2
  /**
3
3
  * `GET local-session`. The account is chosen in the CLI and bound by the
4
4
  * uploaded snapshot, so `accountId` is `null` until then; runs created before
5
5
  * that change still carry their bound account.
6
6
  */
7
7
  export type LocalSession = LocalSessionResponse['session'];
8
+ /** `GET local-session/availability`: local checkups are on, with the oldest CLI and the snapshots vigilbase.com accepts. */
9
+ export type LocalAvailability = LocalAvailabilityResponse;
8
10
  /** `POST local-session/request`: the token naming the run that awaits its emailed code. */
9
11
  export type PendingVerification = LocalRequestResponse['verification'];
10
12
  /** `POST local-session/verify`: the session code for the upload (kept in memory only). */
11
13
  export type VerifiedSession = LocalVerifyResponse['session'];
12
14
  export declare const GET_TIMEOUT_MS = 30000;
15
+ /** The availability check is skipped (the run goes on) when vigilbase.com does not answer it within this. */
16
+ export declare const AVAILABILITY_TIMEOUT_MS = 10000;
13
17
  export declare const POST_TIMEOUT_MS = 120000;
14
18
  export declare const MAX_SUBMIT_RESPONSE_BYTES: number;
15
19
  export declare const POST_RETRY_DELAYS_MS: readonly [2000, 5000];
16
20
  /** A verify that failed on the network or with a 503 is sent once more, after this pause. */
17
21
  export declare const VERIFY_RETRY_DELAYS_MS: readonly [2000];
22
+ /** True for http(s) loopback origins (local development), the only ones besides production that `--base-url` accepts. */
23
+ export declare function isLoopbackOrigin(origin: string): boolean;
18
24
  /**
19
25
  * The submit origin. Only `https://vigilbase.com` and loopback origins are
20
26
  * accepted; there is no `*.vigilbase.com` wildcard (other subdomains are
@@ -52,7 +58,8 @@ declare abstract class LocalHttpClient {
52
58
  }>;
53
59
  }
54
60
  /**
55
- * Email verification without a bearer. A code request is never retried: a
61
+ * The requests before the session code, without a bearer: the availability
62
+ * check and the email verification. A code request is never retried: a
56
63
  * repeated request would send a second email. A verify that failed on the
57
64
  * network (or timed out) or with a 503 is sent once more, after 2 s, with the
58
65
  * same token and code: One counts only wrong codes, and the right code
@@ -61,6 +68,14 @@ declare abstract class LocalHttpClient {
61
68
  */
62
69
  export declare class VerificationClient extends LocalHttpClient {
63
70
  private postJson;
71
+ /**
72
+ * `GET local-session/availability`, before the email is asked for: what
73
+ * vigilbase.com accepts, or null when it gave no usable answer (a 404 from a
74
+ * server without the route, a network error, a timeout, a challenge or any
75
+ * other response), and the run goes on as before. Throws LOCAL_MODE_DISABLED
76
+ * when it answers that local checkups are switched off. Never retried.
77
+ */
78
+ availability(): Promise<LocalAvailability | null>;
64
79
  /** `POST local-session/request`: vigilbase.com emails a 6-digit code and returns the token for it. */
65
80
  requestCode(body: LocalRequestBody): Promise<PendingVerification>;
66
81
  /** `POST local-session/verify`: trades the token and the emailed code for a session code (the next one on every call). */
@@ -87,12 +102,11 @@ export declare class SubmitClient extends LocalHttpClient {
87
102
  */
88
103
  postSnapshot(bytes: Buffer, sha256: string): Promise<UploadResult>;
89
104
  }
90
- /** Refuse a server that requires a newer CLI, or does not accept this schema version. */
91
- export declare function assertSessionAccepts(session: LocalSession, cliVersion: string, schemaVersion: string): void;
105
+ /** Refuse a server (its session, or its availability answer) that requires a newer CLI, or does not accept this schema version. */
106
+ export declare function assertServerAccepts(server: Pick<LocalSession, 'accepts' | 'minCliVersion'>, cliVersion: string, schemaVersion: string): void;
92
107
  /**
93
108
  * The masked address as the server masks it (first character, `***`, the
94
109
  * domain); any other text from the server is replaced by `fallback`.
95
110
  */
96
111
  export declare function displayRequester(requester: string, fallback?: string): string;
97
112
  export {};
98
- //# sourceMappingURL=submit-client.d.ts.map