@fuzdev/fuz_app 0.163.0 → 0.165.0
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/README.md +2 -1
- package/dist/actions/action_event_data.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -0
- package/dist/actions/action_spec.d.ts +3 -3
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/auth/CLAUDE.md +1 -1
- package/dist/auth/account_route_schema.d.ts +3 -27
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +6 -20
- package/dist/auth/admin_action_specs.d.ts +56 -56
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +4 -5
- package/dist/auth/audit_log_schema.d.ts +18 -18
- package/dist/auth/bootstrap_route_schema.d.ts +1 -30
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +3 -8
- package/dist/auth/daemon_token.d.ts +4 -4
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +3 -3
- package/dist/auth/daemon_token_middleware.d.ts +1 -1
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +5 -5
- package/dist/auth/middleware.js +4 -4
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +3 -7
- package/dist/db/CLAUDE.md +2 -1
- package/dist/db/file_fact_url.d.ts +11 -6
- package/dist/db/file_fact_url.d.ts.map +1 -1
- package/dist/db/file_fact_url.js +5 -5
- package/dist/db/schema_ready.d.ts +0 -5
- package/dist/db/schema_ready.d.ts.map +1 -1
- package/dist/db/schema_ready.js +0 -5
- package/dist/http/CLAUDE.md +105 -71
- package/dist/http/auth_shape.d.ts +48 -29
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +12 -85
- package/dist/http/body_limit.d.ts +12 -0
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +15 -0
- package/dist/http/body_limit_schema.d.ts +20 -0
- package/dist/http/body_limit_schema.d.ts.map +1 -0
- package/dist/http/body_limit_schema.js +20 -0
- package/dist/http/common_routes.d.ts +1 -1
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +11 -14
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +59 -69
- package/dist/http/dev_route_error_check.d.ts +70 -0
- package/dist/http/dev_route_error_check.d.ts.map +1 -0
- package/dist/http/dev_route_error_check.js +119 -0
- package/dist/http/error_schemas.d.ts +365 -189
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +256 -149
- package/dist/http/health_schema.d.ts +10 -6
- package/dist/http/health_schema.d.ts.map +1 -1
- package/dist/http/health_schema.js +3 -3
- package/dist/http/middleware_spec.d.ts +8 -3
- package/dist/http/middleware_spec.d.ts.map +1 -1
- package/dist/http/origin.d.ts +12 -43
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +10 -6
- package/dist/http/route_error_check.d.ts +179 -0
- package/dist/http/route_error_check.d.ts.map +1 -0
- package/dist/http/route_error_check.js +283 -0
- package/dist/http/route_errors.d.ts +80 -0
- package/dist/http/route_errors.d.ts.map +1 -0
- package/dist/http/route_errors.js +83 -0
- package/dist/http/route_spec.d.ts +33 -17
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +48 -62
- package/dist/http/schema_helpers.d.ts +15 -34
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +11 -47
- package/dist/http/surface.d.ts +19 -12
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +25 -38
- package/dist/http/surface_query.d.ts +11 -2
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +7 -1
- package/dist/primitive_schemas_fuz.d.ts +17 -3
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +13 -3
- package/dist/rate_limiter.d.ts +13 -0
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +20 -2
- package/dist/schema_issues.d.ts +29 -11
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +11 -10
- package/dist/schema_meta.d.ts +8 -1
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +2 -1
- package/dist/server/app_server.d.ts +3 -1
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +24 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +8 -31
- package/dist/server/surface_route.d.ts.map +1 -1
- package/dist/server/surface_route.js +5 -6
- package/dist/server/x_accel.d.ts +12 -7
- package/dist/server/x_accel.d.ts.map +1 -1
- package/dist/server/x_accel.js +7 -9
- package/dist/testing/CLAUDE.md +105 -61
- package/dist/testing/admin_integration.js +2 -2
- package/dist/testing/adversarial_404.d.ts +4 -18
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +20 -52
- package/dist/testing/adversarial_headers.d.ts +3 -4
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -6
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +20 -19
- package/dist/testing/assertions.d.ts +46 -14
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +73 -16
- package/dist/testing/attack_surface.d.ts +17 -35
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +36 -95
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +11 -11
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +2 -1
- package/dist/testing/cross_backend/conformance_table.js +1 -1
- package/dist/testing/cross_backend/fact_serving.js +3 -3
- package/dist/testing/cross_backend/in_process_setup.d.ts +7 -3
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +11 -4
- package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_conformance.js +21 -21
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
- package/dist/testing/cross_backend/setup.d.ts +13 -0
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +24 -7
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -2
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +5 -2
- package/dist/testing/cross_backend/standard.d.ts +31 -0
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +9 -3
- package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +16 -13
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/data_exposure.d.ts +7 -0
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +8 -7
- package/dist/testing/error_coverage.d.ts +53 -61
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +86 -119
- package/dist/testing/integration.d.ts +28 -1
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +54 -29
- package/dist/testing/integration_helpers.d.ts +37 -9
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +75 -40
- package/dist/testing/middleware.d.ts +3 -5
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -4
- package/dist/testing/middleware_gate_probes.d.ts +90 -0
- package/dist/testing/middleware_gate_probes.d.ts.map +1 -0
- package/dist/testing/middleware_gate_probes.js +179 -0
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +5 -4
- package/dist/testing/round_trip.d.ts +7 -0
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +8 -5
- package/dist/testing/schema_generators.d.ts +40 -11
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +71 -17
- package/dist/testing/stubs.d.ts +10 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +15 -5
- package/dist/testing/surface_invariants.d.ts +36 -115
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +106 -269
- package/dist/testing/transports/raw_http.d.ts +10 -2
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +10 -4
- package/dist/ui/CLAUDE.md +4 -2
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +2 -8
- package/dist/ui/backend_probe.svelte.js +3 -3
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +1 -8
- package/dist/ui/ui_fetch.d.ts +12 -2
- package/dist/ui/ui_fetch.d.ts.map +1 -1
- package/dist/ui/ui_fetch.js +22 -4
- package/package.json +1 -1
|
@@ -15,48 +15,27 @@ import './assert_dev_env.js';
|
|
|
15
15
|
* @module
|
|
16
16
|
*/
|
|
17
17
|
import { test, assert, describe } from 'vitest';
|
|
18
|
-
import { assert_surface_invariants, assert_rpc_ws_surface_invariants, assert_surface_security_policy
|
|
18
|
+
import { assert_surface_invariants, assert_rpc_ws_surface_invariants, assert_surface_security_policy } from './surface_invariants.js';
|
|
19
19
|
import { describe_adversarial_input } from './adversarial_input.js';
|
|
20
20
|
import { describe_adversarial_404 } from './adversarial_404.js';
|
|
21
21
|
import { create_auth_test_apps, create_route_skip_filter, select_auth_app } from './auth_apps.js';
|
|
22
22
|
import { resolve_valid_path, to_route_content_type } from './schema_generators.js';
|
|
23
|
-
import { assert_surface_matches_snapshot, assert_surface_deterministic, assert_only_expected_public_routes, assert_full_middleware_stack, assert_error_schema_valid } from './assertions.js';
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { filter_protected_routes, filter_role_routes, filter_credential_gated_routes } from '../http/surface_query.js';
|
|
23
|
+
import { assert_surface_matches_snapshot, assert_surface_deterministic, assert_only_expected_public_routes, assert_full_middleware_stack, assert_error_schema_valid, assert_error_response_declared } from './assertions.js';
|
|
24
|
+
import { get_route_error_map } from '../http/route_errors.js';
|
|
25
|
+
import { filter_protected_routes, filter_role_routes, filter_credential_gated_routes, format_route_key } from '../http/surface_query.js';
|
|
27
26
|
import { BUILTIN_CREDENTIAL_TYPES, CREDENTIAL_TYPE_SESSION } from '../auth/credential_type_schema.js';
|
|
28
27
|
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_CREDENTIAL_TYPE_REQUIRED } from '../http/error_schemas.js';
|
|
29
28
|
// --- Adversarial test runner ---
|
|
30
|
-
/**
|
|
31
|
-
* Build a lookup from `"METHOD /path"` to merged error schemas (auto-derived + middleware + explicit).
|
|
32
|
-
*
|
|
33
|
-
* Uses `merge_error_schemas` to ensure consistency with surface generation —
|
|
34
|
-
* accounts for auth, input, params, and middleware when auto-deriving error schemas.
|
|
35
|
-
*/
|
|
36
|
-
const build_error_schema_lookup = (route_specs, middleware_specs) => {
|
|
37
|
-
const lookup = new Map();
|
|
38
|
-
for (const spec of route_specs) {
|
|
39
|
-
const key = `${spec.method} ${spec.path}`;
|
|
40
|
-
const mw_errors = middleware_specs
|
|
41
|
-
? collect_middleware_errors(middleware_specs, spec.path)
|
|
42
|
-
: null;
|
|
43
|
-
const merged = merge_error_schemas(spec, mw_errors);
|
|
44
|
-
if (merged && Object.keys(merged).length > 0) {
|
|
45
|
-
lookup.set(key, merged);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return lookup;
|
|
49
|
-
};
|
|
50
29
|
/**
|
|
51
30
|
* Build a lookup from `"METHOD /path"` to the route's own `RouteSpec` — the
|
|
52
|
-
* companion of `
|
|
31
|
+
* companion of the surface spec's `route_error_maps`, so a generated request can reach
|
|
53
32
|
* the route's `params` schema and synthesize path segments the route will
|
|
54
33
|
* actually accept.
|
|
55
34
|
*/
|
|
56
35
|
const build_route_spec_lookup = (route_specs) => {
|
|
57
36
|
const lookup = new Map();
|
|
58
37
|
for (const spec of route_specs) {
|
|
59
|
-
lookup.set(
|
|
38
|
+
lookup.set(format_route_key(spec), spec);
|
|
60
39
|
}
|
|
61
40
|
return lookup;
|
|
62
41
|
};
|
|
@@ -74,21 +53,24 @@ const build_route_spec_lookup = (route_specs) => {
|
|
|
74
53
|
*/
|
|
75
54
|
export const describe_adversarial_auth = (options) => {
|
|
76
55
|
const { build, roles } = options;
|
|
77
|
-
const { surface, route_specs,
|
|
56
|
+
const { surface, route_specs, route_error_maps } = build();
|
|
78
57
|
const is_skipped = create_route_skip_filter(options.skip_routes);
|
|
79
58
|
const protected_routes = filter_protected_routes(surface).filter((r) => !is_skipped(r));
|
|
80
59
|
if (protected_routes.length === 0)
|
|
81
60
|
return;
|
|
82
61
|
const role_routes = filter_role_routes(surface).filter((r) => !is_skipped(r));
|
|
83
62
|
const credential_gated_routes = filter_credential_gated_routes(surface).filter((r) => !is_skipped(r));
|
|
84
|
-
//
|
|
85
|
-
const error_schema_lookup =
|
|
63
|
+
// each route's error map (derived, middleware, and handler-specific), for response validation
|
|
64
|
+
const error_schema_lookup = route_error_maps;
|
|
86
65
|
// The route's own spec, so a path param with a declared format (a
|
|
87
66
|
// `blake3:…` fact hash, a `tok_…` id) is synthesized into a value params
|
|
88
67
|
// validation accepts. Otherwise the generated request 400s on the path
|
|
89
68
|
// before ever reaching the 401 / 403 gate the case is asserting.
|
|
90
69
|
const spec_lookup = build_route_spec_lookup(route_specs);
|
|
91
|
-
const test_path = (route) =>
|
|
70
|
+
const test_path = (route) => {
|
|
71
|
+
const key = format_route_key(route);
|
|
72
|
+
return resolve_valid_path(route.path, spec_lookup.get(key)?.params, options.param_values?.[key]);
|
|
73
|
+
};
|
|
92
74
|
const apps = create_auth_test_apps(route_specs, roles);
|
|
93
75
|
// every probe carries the content type a real client sends, so the
|
|
94
76
|
// per-route content-type check (415) never answers ahead of the auth gate
|
|
@@ -99,9 +81,9 @@ export const describe_adversarial_auth = (options) => {
|
|
|
99
81
|
describe('adversarial HTTP auth enforcement', () => {
|
|
100
82
|
describe('unauthenticated → 401', () => {
|
|
101
83
|
for (const route of protected_routes) {
|
|
102
|
-
test(
|
|
84
|
+
test(format_route_key(route), async () => {
|
|
103
85
|
const res = await apps.public.request(test_path(route), probe_init(route));
|
|
104
|
-
assert.strictEqual(res.status, 401,
|
|
86
|
+
assert.strictEqual(res.status, 401, format_route_key(route));
|
|
105
87
|
const body = await res.json();
|
|
106
88
|
assert.strictEqual(body.error, ERROR_AUTHENTICATION_REQUIRED);
|
|
107
89
|
assert_error_schema_valid(error_schema_lookup, route, 401, body);
|
|
@@ -130,7 +112,7 @@ export const describe_adversarial_auth = (options) => {
|
|
|
130
112
|
if (!app)
|
|
131
113
|
throw new Error(`No test app for role '${wrong_role}'`);
|
|
132
114
|
const res = await app.request(test_path(route), probe_init(route));
|
|
133
|
-
assert.strictEqual(res.status, 403,
|
|
115
|
+
assert.strictEqual(res.status, 403, format_route_key(route));
|
|
134
116
|
const body = await res.json();
|
|
135
117
|
assert.strictEqual(body.error, ERROR_INSUFFICIENT_PERMISSIONS);
|
|
136
118
|
assert.deepStrictEqual(body.required_roles, required_roles);
|
|
@@ -141,9 +123,9 @@ export const describe_adversarial_auth = (options) => {
|
|
|
141
123
|
});
|
|
142
124
|
describe('authenticated without role → 403', () => {
|
|
143
125
|
for (const route of role_only_routes) {
|
|
144
|
-
test(
|
|
126
|
+
test(format_route_key(route), async () => {
|
|
145
127
|
const res = await apps.authed.request(test_path(route), probe_init(route));
|
|
146
|
-
assert.strictEqual(res.status, 403,
|
|
128
|
+
assert.strictEqual(res.status, 403, format_route_key(route));
|
|
147
129
|
const body = await res.json();
|
|
148
130
|
assert.strictEqual(body.error, ERROR_INSUFFICIENT_PERMISSIONS);
|
|
149
131
|
assert.deepStrictEqual(body.required_roles, route.auth.roles ?? []);
|
|
@@ -177,7 +159,7 @@ export const describe_adversarial_auth = (options) => {
|
|
|
177
159
|
const res = await apps.by_credential_type
|
|
178
160
|
.get(refused)
|
|
179
161
|
.request(test_path(route), probe_init(route));
|
|
180
|
-
assert.strictEqual(res.status, 403,
|
|
162
|
+
assert.strictEqual(res.status, 403, format_route_key(route));
|
|
181
163
|
const body = await res.json();
|
|
182
164
|
assert.strictEqual(body.error, ERROR_CREDENTIAL_TYPE_REQUIRED);
|
|
183
165
|
assert.deepStrictEqual(body.required_credential_types, admitted);
|
|
@@ -188,18 +170,23 @@ export const describe_adversarial_auth = (options) => {
|
|
|
188
170
|
}
|
|
189
171
|
describe('correct auth passes guard', () => {
|
|
190
172
|
for (const route of protected_routes) {
|
|
191
|
-
test(
|
|
173
|
+
test(format_route_key(route), async () => {
|
|
192
174
|
const res = await select_auth_app(apps, route.auth).request(test_path(route), probe_init(route));
|
|
193
|
-
// handler
|
|
175
|
+
// the handler runs on stub deps, so any status it answers is fine
|
|
176
|
+
// but the gates' — and an error it answers must be one the route declares
|
|
194
177
|
assert.notStrictEqual(res.status, 401, 'should not be 401 (auth rejected)');
|
|
195
178
|
assert.notStrictEqual(res.status, 403, 'should not be 403 (role rejected)');
|
|
196
179
|
assert.notStrictEqual(res.status, 415, 'should not be 415 (content type refused)');
|
|
197
|
-
//
|
|
198
|
-
// only reject router-level 404 (route not registered)
|
|
180
|
+
// only reject router-level 404 (route not registered), Hono's plain text
|
|
199
181
|
if (res.status === 404) {
|
|
200
|
-
const body = await res
|
|
182
|
+
const body = await res
|
|
183
|
+
.clone()
|
|
184
|
+
.json()
|
|
185
|
+
.catch(() => null);
|
|
201
186
|
assert.ok(body?.error, `route not registered: ${route.method} ${route.path}`);
|
|
202
187
|
}
|
|
188
|
+
const spec = spec_lookup.get(format_route_key(route));
|
|
189
|
+
await assert_error_response_declared(get_route_error_map(route_error_maps, spec), spec.jsonrpc ?? false, res, format_route_key(route));
|
|
203
190
|
// SSE streams need explicit cleanup — the suspended promise keeps the event loop alive.
|
|
204
191
|
// Only cancel streaming responses; regular JSON bodies don't need it.
|
|
205
192
|
if (res.headers.get('Content-Type')?.includes('text/event-stream')) {
|
|
@@ -210,35 +197,6 @@ export const describe_adversarial_auth = (options) => {
|
|
|
210
197
|
});
|
|
211
198
|
});
|
|
212
199
|
};
|
|
213
|
-
// --- Standard attack surface test suite ---
|
|
214
|
-
/**
|
|
215
|
-
* Merge a consumer's `error_schema_tightness` option with
|
|
216
|
-
* `default_error_schema_tightness` so `allowlist` and `ignore_statuses` are
|
|
217
|
-
* additive rather than replacing.
|
|
218
|
-
*
|
|
219
|
-
* - `undefined` → return the default as-is.
|
|
220
|
-
* - `null` → return `null` (opt out of the assertion).
|
|
221
|
-
* - object → spread the default, then consumer overrides for scalar fields
|
|
222
|
-
* (`min_specificity`), then concat stock-then-consumer for the list fields
|
|
223
|
-
* (`allowlist`, `ignore_statuses`) so consumer entries extend rather than
|
|
224
|
-
* replace.
|
|
225
|
-
*
|
|
226
|
-
* Exported for direct use when a consumer calls `assert_error_schema_tightness`
|
|
227
|
-
* outside the standard suite but still wants the additive merge.
|
|
228
|
-
*/
|
|
229
|
-
export const resolve_standard_error_schema_tightness = (consumer) => {
|
|
230
|
-
if (consumer === null)
|
|
231
|
-
return null;
|
|
232
|
-
return {
|
|
233
|
-
...default_error_schema_tightness,
|
|
234
|
-
...consumer,
|
|
235
|
-
allowlist: [...fuz_app_stock_route_tightness_allowlist, ...(consumer?.allowlist ?? [])],
|
|
236
|
-
ignore_statuses: [
|
|
237
|
-
...(default_error_schema_tightness.ignore_statuses ?? []),
|
|
238
|
-
...(consumer?.ignore_statuses ?? [])
|
|
239
|
-
]
|
|
240
|
-
};
|
|
241
|
-
};
|
|
242
200
|
/**
|
|
243
201
|
* Run the standard attack surface test suite.
|
|
244
202
|
*
|
|
@@ -250,17 +208,15 @@ export const resolve_standard_error_schema_tightness = (consumer) => {
|
|
|
250
208
|
* 5. Surface invariants — structural assertions over `surface.routes` (error schemas, descriptions, duplicates, consistency)
|
|
251
209
|
* 6. RPC/WS surface invariants — structural assertions over `surface.rpc_endpoints` + `surface.ws_endpoints` (descriptions, protocol-action spread, kind ⇔ auth)
|
|
252
210
|
* 7. Security policy — rate limiting on sensitive routes, no unexpected public mutations, method conventions
|
|
253
|
-
* 8.
|
|
254
|
-
* 9. Adversarial
|
|
255
|
-
* 10. Adversarial
|
|
256
|
-
* 11. Adversarial 404 — stub 404 handlers, validate response bodies against declared schemas
|
|
211
|
+
* 8. Adversarial auth — unauthenticated/wrong-role/correct-auth enforcement, every refusal a status and code of the route's own error map
|
|
212
|
+
* 9. Adversarial input — input body and params validation, each 400 a code of the route's own map
|
|
213
|
+
* 10. Adversarial 404 — stub 404 handlers, validate response bodies against the route's declared 404
|
|
257
214
|
*
|
|
258
215
|
* Consumer test files call this with project-specific options, then add
|
|
259
216
|
* any project-specific assertions in additional `describe` blocks.
|
|
260
217
|
*/
|
|
261
218
|
export const describe_standard_attack_surface_tests = (options) => {
|
|
262
|
-
const { build, snapshot_path, expected_public_routes, expected_api_middleware, roles, api_path_prefix = '/api/', security_policy, skip_routes } = options;
|
|
263
|
-
const error_schema_tightness = resolve_standard_error_schema_tightness(options.error_schema_tightness);
|
|
219
|
+
const { build, snapshot_path, expected_public_routes, expected_api_middleware, roles, api_path_prefix = '/api/', security_policy, skip_routes, param_values } = options;
|
|
264
220
|
const built = build();
|
|
265
221
|
const { surface } = built;
|
|
266
222
|
describe('attack surface snapshot', () => {
|
|
@@ -287,23 +243,8 @@ export const describe_standard_attack_surface_tests = (options) => {
|
|
|
287
243
|
test('security policy', () => {
|
|
288
244
|
assert_surface_security_policy(surface, security_policy);
|
|
289
245
|
});
|
|
290
|
-
test('error schema tightness', () => {
|
|
291
|
-
const entries = audit_error_schema_tightness(surface);
|
|
292
|
-
const generic = entries.filter((e) => e.specificity === 'generic');
|
|
293
|
-
const literal = entries.filter((e) => e.specificity === 'literal');
|
|
294
|
-
const enumerated = entries.filter((e) => e.specificity === 'enum');
|
|
295
|
-
console.log(`[error schema tightness] ${entries.length} total: ` +
|
|
296
|
-
`${literal.length} literal, ${enumerated.length} enum, ${generic.length} generic`);
|
|
297
|
-
if (generic.length > 0) {
|
|
298
|
-
console.log(`[error schema tightness] generic schemas:\n` +
|
|
299
|
-
generic.map((e) => ` ${e.method} ${e.route_path} → ${e.status}`).join('\n'));
|
|
300
|
-
}
|
|
301
|
-
if (error_schema_tightness) {
|
|
302
|
-
assert_error_schema_tightness(surface, error_schema_tightness);
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
246
|
});
|
|
306
|
-
describe_adversarial_auth({ build: () => built, roles, skip_routes });
|
|
307
|
-
describe_adversarial_input({ build: () => built, roles, skip_routes });
|
|
308
|
-
describe_adversarial_404({ build: () => built, roles, skip_routes });
|
|
247
|
+
describe_adversarial_auth({ build: () => built, roles, skip_routes, param_values });
|
|
248
|
+
describe_adversarial_input({ build: () => built, roles, skip_routes, param_values });
|
|
249
|
+
describe_adversarial_404({ build: () => built, roles, skip_routes, param_values });
|
|
309
250
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_apps.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/auth_apps.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth_apps.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/auth_apps.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAIN,KAAK,qBAAqB,EAC1B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,4BAA4B,CAAC;AAUpC;;GAEG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,cAI1D,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACtC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,WAAW,cAAc,EACzB,kBAAkB,qBAAqB,KACrC,IA4BF,CAAC;AAEF,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb;;;;;;;;OAQG;IACH,kBAAkB,EAAE,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;IACrD,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GACjC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,KAClB,YAsBF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,YAAY,EAAE,MAAM,SAAS,KAAG,IAwBrE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,KACpC,CAAC,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAGvD,CAAC"}
|
|
@@ -10,6 +10,7 @@ import './assert_dev_env.js';
|
|
|
10
10
|
import { Hono } from 'hono';
|
|
11
11
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
12
12
|
import { apply_route_specs } from '../http/route_spec.js';
|
|
13
|
+
import { format_route_key } from '../http/surface_query.js';
|
|
13
14
|
import { is_public_auth } from '../http/auth_shape.js';
|
|
14
15
|
import { BUILTIN_CREDENTIAL_TYPES, CREDENTIAL_TYPE_DAEMON_TOKEN, CREDENTIAL_TYPE_SESSION } from '../auth/credential_type_schema.js';
|
|
15
16
|
import { ROLE_KEEPER } from '../auth/role_schema.js';
|
|
@@ -129,5 +130,5 @@ export const select_auth_app = (apps, auth) => {
|
|
|
129
130
|
*/
|
|
130
131
|
export const create_route_skip_filter = (skip_routes) => {
|
|
131
132
|
const skip_set = new Set(skip_routes);
|
|
132
|
-
return (route) => skip_set.has(
|
|
133
|
+
return (route) => skip_set.has(format_route_key(route));
|
|
133
134
|
};
|
|
@@ -30,9 +30,9 @@ import '../assert_dev_env.js';
|
|
|
30
30
|
*
|
|
31
31
|
* @module
|
|
32
32
|
*/
|
|
33
|
-
import {
|
|
33
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
34
34
|
import { type RouteAuth } from '../../http/auth_shape.js';
|
|
35
|
-
import { RateLimitKey } from '../../
|
|
35
|
+
import { RateLimitKey } from '../../rate_limiter.js';
|
|
36
36
|
import type { ValidationSchema } from '../../schema_issues.js';
|
|
37
37
|
import type { RequestResponseActionSpec } from '../../actions/action_spec.js';
|
|
38
38
|
/**
|
|
@@ -44,61 +44,131 @@ import type { RequestResponseActionSpec } from '../../actions/action_spec.js';
|
|
|
44
44
|
* nullable rather than optional for the same reason — an unthrottled action
|
|
45
45
|
* serializes an explicit `null`, so a missing key is drift, not a default.
|
|
46
46
|
*/
|
|
47
|
-
export declare const ActionManifestEntry:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
actor:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
export declare const ActionManifestEntry: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
48
|
+
input: "object" | "void";
|
|
49
|
+
account: "optional" | "none" | "required";
|
|
50
|
+
actor: "optional" | "none" | "required";
|
|
51
|
+
roles: string[];
|
|
52
|
+
credential_types: string[];
|
|
53
|
+
method: string;
|
|
54
|
+
side_effects: boolean;
|
|
55
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
56
|
+
}, {
|
|
57
|
+
input: "object" | "void";
|
|
58
|
+
account: "optional" | "none" | "required";
|
|
59
|
+
actor: "optional" | "none" | "required";
|
|
60
|
+
roles: string[];
|
|
61
|
+
credential_types: string[];
|
|
62
|
+
method: string;
|
|
63
|
+
side_effects: boolean;
|
|
64
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
65
|
+
}, "object", {
|
|
66
|
+
/** RPC method name (`spec.method`). */
|
|
67
|
+
method: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
68
|
+
/**
|
|
69
|
+
* `'void'` when the input is a void schema (`is_void_schema`: `z.void()`
|
|
70
|
+
* or fuz_schema `s.void`, a parameterless method), else `'object'` — the
|
|
71
|
+
* Rust spine's declared `InputShape`, which its dispatcher enforces. A `z.strictObject({})` input is `'object'`.
|
|
72
|
+
*/
|
|
73
|
+
input: import("@fuzdev/fuz_schema/schema.ts").Schema<"object" | "void", "object" | "void", "one_of", readonly ["void", "object"]>;
|
|
74
|
+
/** `true` when the action declares `side_effects` (mutation; POST-only on the RPC transport). */
|
|
75
|
+
side_effects: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
76
|
+
/** The `account` auth axis. */
|
|
77
|
+
account: import("@fuzdev/fuz_schema/schema.ts").Schema<"optional" | "none" | "required", "optional" | "none" | "required", "one_of", readonly ["none", "optional", "required"]>;
|
|
78
|
+
/** The `actor` auth axis. */
|
|
79
|
+
actor: import("@fuzdev/fuz_schema/schema.ts").Schema<"optional" | "none" | "required", "optional" | "none" | "required", "one_of", readonly ["none", "optional", "required"]>;
|
|
80
|
+
/** Required roles (any-of), sorted; `[]` when the action declares no role gate. */
|
|
81
|
+
roles: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
82
|
+
/** Permitted credential channels, sorted; `[]` when ungated (any credential). */
|
|
83
|
+
credential_types: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
84
|
+
/** Per-action rate-limit class, or `null` when the action declares none. */
|
|
85
|
+
rate_limit: import("@fuzdev/fuz_schema/schema.ts").Schema<"account" | "ip" | "both" | null, "account" | "ip" | "both" | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<"account" | "ip" | "both", "account" | "ip" | "both", "one_of", readonly ["ip", "account", "both"]>>>;
|
|
86
|
+
}>;
|
|
87
|
+
export type ActionManifestEntry = Infer<typeof ActionManifestEntry>;
|
|
73
88
|
/** The full action manifest — every entry, sorted by `method`. */
|
|
74
|
-
export declare const ActionManifest:
|
|
75
|
-
methods:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
rate_limit:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
export declare const ActionManifest: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
90
|
+
methods: {
|
|
91
|
+
input: "object" | "void";
|
|
92
|
+
account: "optional" | "none" | "required";
|
|
93
|
+
actor: "optional" | "none" | "required";
|
|
94
|
+
roles: string[];
|
|
95
|
+
credential_types: string[];
|
|
96
|
+
method: string;
|
|
97
|
+
side_effects: boolean;
|
|
98
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
99
|
+
}[];
|
|
100
|
+
}, {
|
|
101
|
+
methods: {
|
|
102
|
+
input: "object" | "void";
|
|
103
|
+
account: "optional" | "none" | "required";
|
|
104
|
+
actor: "optional" | "none" | "required";
|
|
105
|
+
roles: string[];
|
|
106
|
+
credential_types: string[];
|
|
107
|
+
method: string;
|
|
108
|
+
side_effects: boolean;
|
|
109
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
110
|
+
}[];
|
|
111
|
+
}, "object", {
|
|
112
|
+
methods: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
113
|
+
input: "object" | "void";
|
|
114
|
+
account: "optional" | "none" | "required";
|
|
115
|
+
actor: "optional" | "none" | "required";
|
|
116
|
+
roles: string[];
|
|
117
|
+
credential_types: string[];
|
|
118
|
+
method: string;
|
|
119
|
+
side_effects: boolean;
|
|
120
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
121
|
+
}[], {
|
|
122
|
+
input: "object" | "void";
|
|
123
|
+
account: "optional" | "none" | "required";
|
|
124
|
+
actor: "optional" | "none" | "required";
|
|
125
|
+
roles: string[];
|
|
126
|
+
credential_types: string[];
|
|
127
|
+
method: string;
|
|
128
|
+
side_effects: boolean;
|
|
129
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
130
|
+
}[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
131
|
+
input: "object" | "void";
|
|
132
|
+
account: "optional" | "none" | "required";
|
|
133
|
+
actor: "optional" | "none" | "required";
|
|
134
|
+
roles: string[];
|
|
135
|
+
credential_types: string[];
|
|
136
|
+
method: string;
|
|
137
|
+
side_effects: boolean;
|
|
138
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
139
|
+
}, {
|
|
140
|
+
input: "object" | "void";
|
|
141
|
+
account: "optional" | "none" | "required";
|
|
142
|
+
actor: "optional" | "none" | "required";
|
|
143
|
+
roles: string[];
|
|
144
|
+
credential_types: string[];
|
|
145
|
+
method: string;
|
|
146
|
+
side_effects: boolean;
|
|
147
|
+
rate_limit: "account" | "ip" | "both" | null;
|
|
148
|
+
}, "object", {
|
|
149
|
+
/** RPC method name (`spec.method`). */
|
|
150
|
+
method: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
151
|
+
/**
|
|
152
|
+
* `'void'` when the input is a void schema (`is_void_schema`: `z.void()`
|
|
153
|
+
* or fuz_schema `s.void`, a parameterless method), else `'object'` — the
|
|
154
|
+
* Rust spine's declared `InputShape`, which its dispatcher enforces. A `z.strictObject({})` input is `'object'`.
|
|
155
|
+
*/
|
|
156
|
+
input: import("@fuzdev/fuz_schema/schema.ts").Schema<"object" | "void", "object" | "void", "one_of", readonly ["void", "object"]>;
|
|
157
|
+
/** `true` when the action declares `side_effects` (mutation; POST-only on the RPC transport). */
|
|
158
|
+
side_effects: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
159
|
+
/** The `account` auth axis. */
|
|
160
|
+
account: import("@fuzdev/fuz_schema/schema.ts").Schema<"optional" | "none" | "required", "optional" | "none" | "required", "one_of", readonly ["none", "optional", "required"]>;
|
|
161
|
+
/** The `actor` auth axis. */
|
|
162
|
+
actor: import("@fuzdev/fuz_schema/schema.ts").Schema<"optional" | "none" | "required", "optional" | "none" | "required", "one_of", readonly ["none", "optional", "required"]>;
|
|
163
|
+
/** Required roles (any-of), sorted; `[]` when the action declares no role gate. */
|
|
164
|
+
roles: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
165
|
+
/** Permitted credential channels, sorted; `[]` when ungated (any credential). */
|
|
166
|
+
credential_types: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
167
|
+
/** Per-action rate-limit class, or `null` when the action declares none. */
|
|
168
|
+
rate_limit: import("@fuzdev/fuz_schema/schema.ts").Schema<"account" | "ip" | "both" | null, "account" | "ip" | "both" | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<"account" | "ip" | "both", "account" | "ip" | "both", "one_of", readonly ["ip", "account", "both"]>>>;
|
|
169
|
+
}>>;
|
|
170
|
+
}>;
|
|
171
|
+
export type ActionManifest = Infer<typeof ActionManifest>;
|
|
102
172
|
/**
|
|
103
173
|
* Normalize one spec's input shape + auth + side-effects into a manifest
|
|
104
174
|
* entry. Reads the input shape off `is_void_schema(spec.input)`, pulls the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_manifest.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/action_manifest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"action_manifest.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/action_manifest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAON,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAE9E;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;IAC/B,uCAAuC;;IAEvC;;;;OAIG;;IAEH,iGAAiG;;IAEjG,+BAA+B;;IAE/B,6BAA6B;;IAE7B,mFAAmF;;IAEnF,iFAAiF;;IAEjF,4EAA4E;;EAE3E,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEpE,kEAAkE;AAClE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAxB1B,uCAAuC;;QAEvC;;;;WAIG;;QAEH,iGAAiG;;QAEjG,+BAA+B;;QAE/B,6BAA6B;;QAE7B,mFAAmF;;QAEnF,iFAAiF;;QAEjF,4EAA4E;;;EAQ3E,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAM1D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,MAAM;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC;CACnC,KAAG,mBASF,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GACjC,OAAO,aAAa,CACnB,IAAI,CAAC,yBAAyB,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,CAAC,CAC5F,KACC,cAED,CAAC"}
|
|
@@ -30,9 +30,9 @@ import '../assert_dev_env.js';
|
|
|
30
30
|
*
|
|
31
31
|
* @module
|
|
32
32
|
*/
|
|
33
|
-
import {
|
|
33
|
+
import { array, boolean, nullable, object, one_of, string } from '@fuzdev/fuz_schema/schema.ts';
|
|
34
34
|
import { AuthAxisState } from '../../http/auth_shape.js';
|
|
35
|
-
import { RateLimitKey } from '../../
|
|
35
|
+
import { RateLimitKey } from '../../rate_limiter.js';
|
|
36
36
|
import { is_void_schema } from '../../http/schema_helpers.js';
|
|
37
37
|
/**
|
|
38
38
|
* One method's normalized RPC metadata — the cross-impl-comparable unit.
|
|
@@ -43,31 +43,31 @@ import { is_void_schema } from '../../http/schema_helpers.js';
|
|
|
43
43
|
* nullable rather than optional for the same reason — an unthrottled action
|
|
44
44
|
* serializes an explicit `null`, so a missing key is drift, not a default.
|
|
45
45
|
*/
|
|
46
|
-
export const ActionManifestEntry =
|
|
46
|
+
export const ActionManifestEntry = object({
|
|
47
47
|
/** RPC method name (`spec.method`). */
|
|
48
|
-
method:
|
|
48
|
+
method: string,
|
|
49
49
|
/**
|
|
50
50
|
* `'void'` when the input is a void schema (`is_void_schema`: `z.void()`
|
|
51
51
|
* or fuz_schema `s.void`, a parameterless method), else `'object'` — the
|
|
52
52
|
* Rust spine's declared `InputShape`, which its dispatcher enforces. A `z.strictObject({})` input is `'object'`.
|
|
53
53
|
*/
|
|
54
|
-
input:
|
|
54
|
+
input: one_of(['void', 'object']),
|
|
55
55
|
/** `true` when the action declares `side_effects` (mutation; POST-only on the RPC transport). */
|
|
56
|
-
side_effects:
|
|
56
|
+
side_effects: boolean,
|
|
57
57
|
/** The `account` auth axis. */
|
|
58
58
|
account: AuthAxisState,
|
|
59
59
|
/** The `actor` auth axis. */
|
|
60
60
|
actor: AuthAxisState,
|
|
61
61
|
/** Required roles (any-of), sorted; `[]` when the action declares no role gate. */
|
|
62
|
-
roles:
|
|
62
|
+
roles: array(string),
|
|
63
63
|
/** Permitted credential channels, sorted; `[]` when ungated (any credential). */
|
|
64
|
-
credential_types:
|
|
64
|
+
credential_types: array(string),
|
|
65
65
|
/** Per-action rate-limit class, or `null` when the action declares none. */
|
|
66
|
-
rate_limit:
|
|
66
|
+
rate_limit: nullable(RateLimitKey)
|
|
67
67
|
});
|
|
68
68
|
/** The full action manifest — every entry, sorted by `method`. */
|
|
69
|
-
export const ActionManifest =
|
|
70
|
-
methods:
|
|
69
|
+
export const ActionManifest = object({
|
|
70
|
+
methods: array(ActionManifestEntry)
|
|
71
71
|
});
|
|
72
72
|
/** Sorted copy of a readonly string list (stable cross-impl ordering). */
|
|
73
73
|
const sorted_strings = (xs) => [...(xs ?? [])].sort();
|
|
@@ -26,7 +26,7 @@ import '../assert_dev_env.js';
|
|
|
26
26
|
*
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
|
-
import type { RateLimitKey } from '../../
|
|
29
|
+
import type { RateLimitKey } from '../../rate_limiter.js';
|
|
30
30
|
import type { ActionManifest, ActionManifestEntry } from './action_manifest.js';
|
|
31
31
|
/** Structured drift entry. `where` is the named source impl ('a' or 'b'). */
|
|
32
32
|
export type ActionManifestDiff = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_manifest_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/action_manifest_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"action_manifest_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/action_manifest_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAWhF,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvF;IACA,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACxC,GACD;IACA,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACA,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CAC/B,GACD;IACA,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,kBAAkB,CAAC;IACnE,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAML;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GACjC,GAAG,cAAc,EACjB,GAAG,cAAc,KACf,KAAK,CAAC,kBAAkB,CAqC1B,CAAC;AAEF,qEAAqE;AACrE,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACxC,OAAO,aAAa,CAAC,kBAAkB,CAAC,EACxC,SAAQ,wBAA6B,KACnC,MAwCF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,GACzC,GAAG,cAAc,EACjB,GAAG,cAAc,EACjB,SAAQ,wBAA6B,KACnC,IAUF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell_crud.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/cell_crud.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cell_crud.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/cell_crud.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4E9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,YAAY,CAAC;AAyD1E,eAAO,MAAM,8BAA8B,GAC1C,SAAS,uCAAuC,KAC9C,IA4uBF,CAAC"}
|
|
@@ -54,6 +54,7 @@ import '../assert_dev_env.js';
|
|
|
54
54
|
* @module
|
|
55
55
|
*/
|
|
56
56
|
import { describe, assert } from 'vitest';
|
|
57
|
+
import { is } from '@fuzdev/fuz_schema/schema.ts';
|
|
57
58
|
import { jsonrpc_error_messages } from '../../http/jsonrpc_errors.js';
|
|
58
59
|
import { WireIssue } from '../../schema_issues.js';
|
|
59
60
|
import { CELL_KIND_LENGTH_MAX, CELL_LIST_LIMIT_MAX, CellCreateOutput, CellDeleteOutput, CellGetOutput, CellListOutput, CellUpdateOutput } from '../../auth/cell_action_specs.js';
|
|
@@ -97,7 +98,7 @@ const assert_schema_refusal = (r, label) => {
|
|
|
97
98
|
const { issues } = data;
|
|
98
99
|
assert.ok(Array.isArray(issues), `${detail} — DEV-only issues that are no array`);
|
|
99
100
|
for (const issue of issues) {
|
|
100
|
-
assert.ok(WireIssue
|
|
101
|
+
assert.ok(is(WireIssue, issue), `${detail} — a DEV-only issue that is no WireIssue`);
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
104
|
/**
|
|
@@ -97,7 +97,7 @@ export const is_ws_conformance_case = (c) => !c.request.method.startsWith('/') &
|
|
|
97
97
|
!WS_UNAVAILABLE_PRINCIPALS.has(c.request.as);
|
|
98
98
|
/**
|
|
99
99
|
* A deliberately malformed `X-Daemon-Token` value for the `invalid_daemon`
|
|
100
|
-
* principal. Fails the `DaemonToken`
|
|
100
|
+
* principal. Fails the `DaemonToken` schema (not 43 base64url chars), so
|
|
101
101
|
* the daemon-token middleware soft-fail-discards it rather than authenticating
|
|
102
102
|
* — the request falls through with no identity, surfacing
|
|
103
103
|
* `credential_type_required` on a daemon-gated action (matching the Rust
|
|
@@ -58,9 +58,9 @@ import '../assert_dev_env.js';
|
|
|
58
58
|
* @module
|
|
59
59
|
*/
|
|
60
60
|
import { describe, assert } from 'vitest';
|
|
61
|
-
import {
|
|
61
|
+
import { object } from '@fuzdev/fuz_schema/schema.ts';
|
|
62
62
|
import { fact_hash_bytes } from '@fuzdev/fuz_util/fact_hash.ts';
|
|
63
|
-
import { FactHashSchema } from '../../
|
|
63
|
+
import { FactHashSchema } from '../../primitive_schemas_fuz.js';
|
|
64
64
|
import { CellCreateOutput } from '../../auth/cell_action_specs.js';
|
|
65
65
|
import { FACT_CACHE_CONTROL, FACT_CONTENT_SECURITY_POLICY, FACT_X_CONTENT_TYPE_OPTIONS } from '../../server/fact_security_headers.js';
|
|
66
66
|
import { test_if } from './capabilities.js';
|
|
@@ -78,7 +78,7 @@ const NIL_UUID = '00000000-0000-0000-0000-000000000000';
|
|
|
78
78
|
* a TS↔Rust drift in the seeder's envelope (extra field, non-`blake3:` hash)
|
|
79
79
|
* fails here rather than silently downstream.
|
|
80
80
|
*/
|
|
81
|
-
const TestingPutFactOutput =
|
|
81
|
+
const TestingPutFactOutput = object({ hash: FactHashSchema });
|
|
82
82
|
/**
|
|
83
83
|
* Seed an embedded fact over the daemon channel via `_testing_put_fact`;
|
|
84
84
|
* returns its `blake3:` hash. A `holder` is recorded in `fact_holder` (a
|