@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.
- package/CLOUDFLARE.md +9 -12
- package/COMMANDS.md +192 -111
- package/LOCAL.md +77 -84
- package/ONE.md +5 -6
- package/README.md +349 -173
- package/SECURITY.md +6 -4
- 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 +13 -11
- package/dist/commands/account.d.ts +0 -1
- package/dist/commands/account.js +1 -2
- package/dist/commands/auth.d.ts +0 -1
- package/dist/commands/auth.js +71 -22
- 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 +14 -9
- 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 +7 -2
- package/dist/commands/legacy-validation.js +15 -3
- package/dist/commands/local.d.ts +6 -1
- package/dist/commands/local.js +36 -12
- package/dist/commands/one.d.ts +0 -1
- package/dist/commands/one.js +39 -13
- package/dist/commands/public-tools.d.ts +0 -1
- package/dist/commands/public-tools.js +63 -29
- package/dist/commands/runs.d.ts +0 -1
- package/dist/commands/runs.js +1 -2
- package/dist/commands/security.d.ts +1 -2
- package/dist/commands/security.js +34 -23
- 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 +9 -2
- package/dist/lib/client.js +49 -20
- package/dist/lib/cloudflare-client.d.ts +0 -1
- package/dist/lib/cloudflare-client.js +1 -2
- 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 +4 -2
- package/dist/lib/help.js +72 -23
- package/dist/lib/network.d.ts +10 -1
- package/dist/lib/network.js +31 -4
- package/dist/lib/one-client.d.ts +4 -1
- package/dist/lib/one-client.js +9 -3
- package/dist/lib/one-error-hints.d.ts +19 -0
- package/dist/lib/one-error-hints.js +47 -0
- 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 +4 -1
- package/dist/local/cloudflare-checkup/errors.js +8 -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 +5 -4
- 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
package/dist/lib/one-client.js
CHANGED
|
@@ -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
|
package/dist/lib/open-url.d.ts
CHANGED
package/dist/lib/open-url.js
CHANGED
package/dist/lib/progress.d.ts
CHANGED
|
@@ -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
|
package/dist/lib/progress.js
CHANGED
|
@@ -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
|
package/dist/lib/skill-fetch.js
CHANGED
package/dist/lib/system-trust.js
CHANGED
package/dist/lib/tui.d.ts
CHANGED
package/dist/lib/tui.js
CHANGED
|
@@ -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
|
|
@@ -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:
|
|
1594
|
-
|
|
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
|
|
@@ -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:
|
|
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
|
|
@@ -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
|
|
@@ -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
|
|
94
|
-
throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot file does not exist
|
|
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
|
-
*
|
|
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
|
|
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
|