@fuzdev/fuz_app 0.171.0 → 0.172.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/dist/http/CLAUDE.md +2 -1
- package/dist/http/error_schemas.d.ts +3 -4
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +4 -5
- package/dist/http/host.d.ts +137 -0
- package/dist/http/host.d.ts.map +1 -0
- package/dist/http/host.js +203 -0
- package/dist/http/origin.d.ts +9 -0
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +6 -2
- package/dist/http/origin_wildcard.d.ts +20 -5
- package/dist/http/origin_wildcard.d.ts.map +1 -1
- package/dist/http/origin_wildcard.js +22 -10
- package/dist/server/app_server.d.ts +10 -0
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +14 -3
- package/dist/testing/CLAUDE.md +5 -6
- package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +2 -1
- package/dist/testing/cross_backend/origin_conformance.d.ts +62 -1
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_conformance.js +19 -3
- package/dist/testing/cross_backend/origin_conformance.json +330 -0
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -6
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -15
- package/dist/testing/cross_backend/testing_origin_check.d.ts +16 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +12 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +2 -2
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +3 -3
- package/dist/testing/stubs.d.ts +11 -4
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAIN,KAAK,WAAW,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,WAAW,EAMX,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGhF,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,c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BAAoB;IACpC,2DAA2D;IAC3D,IAAI,EAAE,eAAe,CAAC;IACtB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC,uBAAuB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IAC9D;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,GACjC,SAAS,IAAI,CAAC,gBAAgB,EAAE,uBAAuB,GAAG,eAAe,CAAC,KACxE,oBAkBF,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC,6EAA6E;IAC7E,cAAc,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC;IAC1D,2CAA2C;IAC3C,iBAAiB,EAAE,eAAe,CAAC;IACnC,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC,uBAAuB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IACnE,uFAAuF;IACvF,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACtC,OAAO,sBAAsB,KAC3B,KAAK,CAAC,oBAAoB,CA0D5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,SAAS,CAQpF,CAAC"}
|
|
@@ -31,6 +31,7 @@ import { fuz_auth_guard_resolver } from '../auth/auth_guard_resolver.js';
|
|
|
31
31
|
import { create_fuz_authorization_handler } from '../auth/request_context.js';
|
|
32
32
|
import { create_body_limit_middleware_spec } from '../http/body_limit.js';
|
|
33
33
|
import { admit_origin_wildcards, ALLOWED_ORIGINS_VAR } from '../http/origin_wildcard.js';
|
|
34
|
+
import { create_host_gate_middleware_spec } from '../http/host.js';
|
|
34
35
|
import { create_rpc_endpoint } from '../actions/action_rpc.js';
|
|
35
36
|
import { register_action_ws } from '../actions/register_action_ws.js';
|
|
36
37
|
import { resolve_ws_endpoints } from '../actions/ws_endpoint_spec.js';
|
|
@@ -271,7 +272,8 @@ const assemble_app_server = async (options, releases) => {
|
|
|
271
272
|
throw new Error('create_app_server: allowed_origins is empty — list at least one origin pattern ' +
|
|
272
273
|
'(an empty list refuses every browser request)');
|
|
273
274
|
}
|
|
274
|
-
const
|
|
275
|
+
const host_gate = options.host_gate ?? true;
|
|
276
|
+
const wildcards = admit_origin_wildcards(options.allowed_origins, options.allow_origin_wildcards ?? false, ALLOWED_ORIGINS_VAR, { host_gate });
|
|
275
277
|
if (!wildcards.ok)
|
|
276
278
|
throw new Error(`create_app_server: ${wildcards.message}`);
|
|
277
279
|
for (const { entry, warning } of wildcards.wildcards) {
|
|
@@ -309,6 +311,10 @@ const assemble_app_server = async (options, releases) => {
|
|
|
309
311
|
releases.push(deps.connection_closer.add(create_sse_connection_closer(audit_sse.registry, audit_sse.required_role)));
|
|
310
312
|
releases.push(deps.audit.add_listener(audit_sse.on_audit_event));
|
|
311
313
|
}
|
|
314
|
+
// Host gate — ahead of everything but the body cap, as on the Rust stack
|
|
315
|
+
const host_spec = host_gate
|
|
316
|
+
? create_host_gate_middleware_spec({ allowed_origins: options.allowed_origins, log })
|
|
317
|
+
: null;
|
|
312
318
|
// Proxy middleware
|
|
313
319
|
const proxy_spec = create_proxy_middleware_spec({ ...options.proxy, log });
|
|
314
320
|
// Auth middleware
|
|
@@ -318,7 +324,11 @@ const assemble_app_server = async (options, releases) => {
|
|
|
318
324
|
daemon_token_state: options.daemon_token_state,
|
|
319
325
|
origin_carve_outs: options.origin_carve_outs
|
|
320
326
|
});
|
|
321
|
-
const stack_specs = [
|
|
327
|
+
const stack_specs = [
|
|
328
|
+
...(host_spec ? [host_spec] : []),
|
|
329
|
+
proxy_spec,
|
|
330
|
+
...auth_middleware
|
|
331
|
+
];
|
|
322
332
|
let middleware_specs = stack_specs;
|
|
323
333
|
if (options.transform_middleware) {
|
|
324
334
|
// the transform gets copies in a fresh array, so mutating what it was
|
|
@@ -462,7 +472,8 @@ const assemble_app_server = async (options, releases) => {
|
|
|
462
472
|
// that took the server list was checked above)
|
|
463
473
|
if (endpoint.allowed_origins !== options.allowed_origins) {
|
|
464
474
|
const label = `ws_endpoints allowed_origins for ${endpoint.path}`;
|
|
465
|
-
|
|
475
|
+
// the host gate reads the server list, not this one
|
|
476
|
+
const endpoint_wildcards = admit_origin_wildcards(endpoint.allowed_origins, options.allow_origin_wildcards ?? false, label, { host_gate: false });
|
|
466
477
|
if (!endpoint_wildcards.ok) {
|
|
467
478
|
throw new Error(`create_app_server: ${endpoint_wildcards.message}`);
|
|
468
479
|
}
|
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -39,7 +39,7 @@ time (never runtime), where a throwing guard would break `vite build`.
|
|
|
39
39
|
- `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` matching `create_auth_middleware_specs`'s output (origin, optional daemon_token, session, request_context, bearer_auth) for surface generation without booting real auth — the same names, paths, order, and declared `errors` (`origin` declares a 403; `bearer_auth` and `daemon_token` declare none, since both soft-fail through `next()`), pinned against the real factory by `auth/middleware.mounted.test.ts`. The surface merges middleware errors into every route under the path, so a stub declaring more would widen the test surface with statuses the live server never returns. Each spec gets its own pass-through handler (not the shared `stub_mw`), so `assert_middleware_stack_mounted` tells the layers apart. See `auth/CLAUDE.md` §Middleware for the real stack.
|
|
40
40
|
- `create_stub_app_backend(options?)` — stub `AppBackend` with no database: `create_stub_app_deps()` (or `options.deps`), no migration results, a `close` that does nothing (or `options.close`). For assembling a server in tests that never reach the database.
|
|
41
41
|
- `create_stub_app_server_context(session_options)` — stub `AppServerContext` over `create_stub_app_backend()`; rate limiters null, `bootstrap_status.available: false`.
|
|
42
|
-
- `create_test_app_surface_spec(options)` — builds an `AppSurfaceSpec` mirroring `create_app_server`'s route assembly, in its order (consumer routes, then bootstrap routes, RPC endpoint routes, and `GET /api/surface`, + stub middleware + surface generation). `GET /api/surface` is listed only with `surface_route: true`, as `create_app_server` mounts it only when opted in — pass the same value to both so the surface-derived suites probe it exactly when the live server serves it. `daemon_token: true` lists the `daemon_token` layer `create_app_server` mounts when given a `daemon_token_state` (`create_test_app` always passes one, and `default_in_process_suite_options` sets it, along with `app_options.surface_route`); `testing/test_app_server.db.test.ts` pins the stub's routes (order, auth, error schemas, applicable middleware) and middleware names against `create_test_app`'s for every `surface_route` setting. Its middleware list mirrors the real one — the body limit's shape at `'*'` (`body_limit_middleware_shape` with a stub handler, left out with `max_body_size: null`), a stub `trusted_proxy` spec at `'*'`, then the stub auth stack — so every route's `applicable_middleware` starts with `body_limit`, `trusted_proxy` (a route outside `/api/*` lists `['body_limit', 'trusted_proxy', 'origin']`, since the origin check covers every path, and a route under an origin carve-out drops `origin`), as on the live server, and every route's error map carries the limit's 413 and 400 and the origin check's 403 `forbidden_origin`. `CreateTestAppSurfaceSpecOptions`: `session_options`, `create_route_specs`, `env_schema?`, `event_specs?`, `rpc_endpoints?`, `ws_endpoints?`, `allowed_origins?`, `origin_carve_outs?`, `transform_middleware?`, `bootstrap?`, `surface_route?`, `daemon_token?`, `max_body_size?`. Throws, like `create_app_server`, on an endpoint path outside `AUTH_MIDDLEWARE_PATH` (`assert_endpoint_in_auth_scope`), on a route that reads or mints a credential outside it (`assert_credential_routes_in_auth_scope`), on an origin carve-out that overlaps that scope (`assert_origin_carve_outs_valid`), and on a `transform_middleware` that moves, drops, duplicates, reorders, wraps, or replaces the stub proxy
|
|
42
|
+
- `create_test_app_surface_spec(options)` — builds an `AppSurfaceSpec` mirroring `create_app_server`'s route assembly, in its order (consumer routes, then bootstrap routes, RPC endpoint routes, and `GET /api/surface`, + stub middleware + surface generation). `GET /api/surface` is listed only with `surface_route: true`, as `create_app_server` mounts it only when opted in — pass the same value to both so the surface-derived suites probe it exactly when the live server serves it. `daemon_token: true` lists the `daemon_token` layer `create_app_server` mounts when given a `daemon_token_state` (`create_test_app` always passes one, and `default_in_process_suite_options` sets it, along with `app_options.surface_route`); `testing/test_app_server.db.test.ts` pins the stub's routes (order, auth, error schemas, applicable middleware) and middleware names against `create_test_app`'s for every `surface_route` setting. Its middleware list mirrors the real one — the body limit's shape at `'*'` (`body_limit_middleware_shape` with a stub handler, left out with `max_body_size: null`), the host gate's (`host_gate_middleware_shape`, left out with `host_gate: false`), a stub `trusted_proxy` spec at `'*'`, then the stub auth stack — so every route's `applicable_middleware` starts with `body_limit`, `host`, `trusted_proxy` (a route outside `/api/*` lists `['body_limit', 'host', 'trusted_proxy', 'origin']`, since the origin check covers every path, and a route under an origin carve-out drops `origin`), as on the live server, and every route's error map carries the limit's 413 and 400, the host gate's 403 `forbidden_host` and the origin check's 403 `forbidden_origin`. `CreateTestAppSurfaceSpecOptions`: `session_options`, `create_route_specs`, `env_schema?`, `event_specs?`, `rpc_endpoints?`, `ws_endpoints?`, `allowed_origins?`, `origin_carve_outs?`, `transform_middleware?`, `bootstrap?`, `surface_route?`, `daemon_token?`, `max_body_size?`, `host_gate?`. Throws, like `create_app_server`, on an endpoint path outside `AUTH_MIDDLEWARE_PATH` (`assert_endpoint_in_auth_scope`), on a route that reads or mints a credential outside it (`assert_credential_routes_in_auth_scope`), on an origin carve-out that overlaps that scope (`assert_origin_carve_outs_valid`), and on a `transform_middleware` that moves, drops, duplicates, reorders, wraps, or replaces the stub host gate, proxy or auth spec (`assert_middleware_stack_mounted`); the transform receives shallow copies in a fresh array, so an in-place mutation can't slip past the check. Throws on a `ws_endpoints` spec with no `allowed_origins` of its own when no `allowed_origins` option is given (there is no server list to default from). Bootstrap is opt-in (symmetric with `create_app_server` — omit to skip; pass the same value as prod to mount routes at `bootstrap.route_prefix ?? '/api/account'`). Single source of truth for attack-surface tests — track `create_app_server` wiring changes here.
|
|
43
43
|
|
|
44
44
|
Throwing stubs surface mock escape: a test that accidentally reaches into
|
|
45
45
|
stub territory breaks immediately with a label-scoped error rather than
|
|
@@ -856,8 +856,8 @@ excluded because no describe block in this suite drives it — its declared
|
|
|
856
856
|
codes would always be uncovered. Consumer-specific routes aren't exercised
|
|
857
857
|
here either — they don't count against the baseline. The declared paths are
|
|
858
858
|
the route error maps of `surface_source`, middleware included (the origin
|
|
859
|
-
check's 403, the body limit's 413 and 400, and the
|
|
860
|
-
|
|
859
|
+
check's 403, the body limit's 413 and 400, and the host gate's 403 where the
|
|
860
|
+
surface declares it), counted per (route, status, code), so
|
|
861
861
|
every error response a test asserts is recorded, and the middleware-gate group
|
|
862
862
|
probes each gate on each counted route. Override with
|
|
863
863
|
`error_coverage_min?: number` (set to `0` to skip the assertion — useful for
|
|
@@ -1407,9 +1407,8 @@ shapes. It declares `/health`, the `ACCOUNT_ROUTER_PATHS` under
|
|
|
1407
1407
|
`/api/account` (`/status`, `/login`, `/logout`, `/password` — what
|
|
1408
1408
|
`fuz_auth::account_router` mounts, so the TS-only `/verify` stays off), signup,
|
|
1409
1409
|
bootstrap as a `surface_only` shape, the daemon-token layer the consumer test
|
|
1410
|
-
binaries wire,
|
|
1411
|
-
|
|
1412
|
-
(default off), and one RPC endpoint: the standard actions (over `roles`), the
|
|
1410
|
+
binaries wire, the host gate's `host` layer unless `host_gate: false` says the
|
|
1411
|
+
server turns the gate off (default on), and one RPC endpoint: the standard actions (over `roles`), the
|
|
1413
1412
|
`extra_rpc_actions` (opt-in families built against the stub context), then the
|
|
1414
1413
|
request-response, non-protocol `domain_action_specs` minus `exclude_methods`
|
|
1415
1414
|
(methods the spec-derived suites can't drive; an entry naming no domain spec
|
|
@@ -117,7 +117,7 @@ export interface DefaultInProcessSuiteOptions {
|
|
|
117
117
|
* factory input the Tier 1 suites read at their top level
|
|
118
118
|
* (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
|
|
119
119
|
* integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
120
|
-
* (`app_options.max_body_size`) — so the call site spreads once and adds
|
|
120
|
+
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
121
121
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
122
122
|
* `db_factories`, ...).
|
|
123
123
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,MAAM,YAAY,CAAC;AAepB;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IAClE;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,kCAAkC,CAAC,EAAE,OAAO,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,qBAAqB,KAAG,SAuEjC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,CAAC,CAAC,SAAS,4BAA4B,EAC5F,SAAS,CAAC,KACR;IACF,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;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AC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,CAAC,CAAC,SAAS,4BAA4B,EAC5F,SAAS,CAAC,KACR;IACF,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CAqClC,CAAC"}
|
|
@@ -115,7 +115,7 @@ export const default_in_process_setup = (options) => async () => {
|
|
|
115
115
|
* factory input the Tier 1 suites read at their top level
|
|
116
116
|
* (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
|
|
117
117
|
* integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
118
|
-
* (`app_options.max_body_size`) — so the call site spreads once and adds
|
|
118
|
+
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
119
119
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
120
120
|
* `db_factories`, ...).
|
|
121
121
|
*
|
|
@@ -165,6 +165,7 @@ export const default_in_process_suite_options = (options) => ({
|
|
|
165
165
|
bootstrap: options.bootstrap,
|
|
166
166
|
surface_route: options.app_options?.surface_route,
|
|
167
167
|
max_body_size: options.app_options?.max_body_size,
|
|
168
|
+
host_gate: options.app_options?.host_gate,
|
|
168
169
|
origin_carve_outs: options.app_options?.origin_carve_outs,
|
|
169
170
|
// `create_test_app` always passes a `daemon_token_state`
|
|
170
171
|
daemon_token: true
|
|
@@ -105,6 +105,24 @@ export declare const OriginConformanceMatchRow: import("@fuzdev/fuz_schema/schem
|
|
|
105
105
|
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
106
106
|
}>;
|
|
107
107
|
export type OriginConformanceMatchRow = Infer<typeof OriginConformanceMatchRow>;
|
|
108
|
+
/** A host row: a valid allowlist, the request's `Host` values, and the host gate's answer. */
|
|
109
|
+
export declare const OriginConformanceHostRow: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
110
|
+
patterns: string;
|
|
111
|
+
hosts: string[];
|
|
112
|
+
allowed: boolean;
|
|
113
|
+
note?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
patterns: string;
|
|
116
|
+
hosts: string[];
|
|
117
|
+
allowed: boolean;
|
|
118
|
+
note?: string | undefined;
|
|
119
|
+
}, "object", {
|
|
120
|
+
patterns: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
121
|
+
hosts: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
122
|
+
allowed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
123
|
+
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
124
|
+
}>;
|
|
125
|
+
export type OriginConformanceHostRow = Infer<typeof OriginConformanceHostRow>;
|
|
108
126
|
/** The conformance table, a `@fuzdev/fuz_schema` `object`. */
|
|
109
127
|
export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
110
128
|
match: {
|
|
@@ -113,6 +131,12 @@ export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
113
131
|
allowed: boolean;
|
|
114
132
|
note?: string | undefined;
|
|
115
133
|
}[];
|
|
134
|
+
host: {
|
|
135
|
+
patterns: string;
|
|
136
|
+
hosts: string[];
|
|
137
|
+
allowed: boolean;
|
|
138
|
+
note?: string | undefined;
|
|
139
|
+
}[];
|
|
116
140
|
parse: ({
|
|
117
141
|
ok: true;
|
|
118
142
|
raw: string;
|
|
@@ -132,6 +156,12 @@ export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
132
156
|
allowed: boolean;
|
|
133
157
|
note?: string | undefined;
|
|
134
158
|
}[];
|
|
159
|
+
host: {
|
|
160
|
+
patterns: string;
|
|
161
|
+
hosts: string[];
|
|
162
|
+
allowed: boolean;
|
|
163
|
+
note?: string | undefined;
|
|
164
|
+
}[];
|
|
135
165
|
parse: ({
|
|
136
166
|
ok: true;
|
|
137
167
|
raw: string;
|
|
@@ -280,6 +310,37 @@ export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
280
310
|
allowed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
281
311
|
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
282
312
|
}>>>;
|
|
313
|
+
host: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<{
|
|
314
|
+
patterns: string;
|
|
315
|
+
hosts: string[];
|
|
316
|
+
allowed: boolean;
|
|
317
|
+
note?: string | undefined;
|
|
318
|
+
}[], import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
319
|
+
patterns: string;
|
|
320
|
+
hosts: string[];
|
|
321
|
+
allowed: boolean;
|
|
322
|
+
note?: string | undefined;
|
|
323
|
+
}[], {
|
|
324
|
+
patterns: string;
|
|
325
|
+
hosts: string[];
|
|
326
|
+
allowed: boolean;
|
|
327
|
+
note?: string | undefined;
|
|
328
|
+
}[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
329
|
+
patterns: string;
|
|
330
|
+
hosts: string[];
|
|
331
|
+
allowed: boolean;
|
|
332
|
+
note?: string | undefined;
|
|
333
|
+
}, {
|
|
334
|
+
patterns: string;
|
|
335
|
+
hosts: string[];
|
|
336
|
+
allowed: boolean;
|
|
337
|
+
note?: string | undefined;
|
|
338
|
+
}, "object", {
|
|
339
|
+
patterns: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
340
|
+
hosts: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
341
|
+
allowed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
342
|
+
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
343
|
+
}>>>;
|
|
283
344
|
}>;
|
|
284
345
|
export type OriginConformance = Infer<typeof OriginConformance>;
|
|
285
346
|
/** The committed table, resolved relative to this module. */
|
|
@@ -304,7 +365,7 @@ export interface OriginConformanceCheck {
|
|
|
304
365
|
* `{ok: true, allowed: true}`.
|
|
305
366
|
*
|
|
306
367
|
* @param table - the conformance table
|
|
307
|
-
* @returns one check per row
|
|
368
|
+
* @returns one check per row: parse rows, then match rows, then host rows
|
|
308
369
|
*/
|
|
309
370
|
export declare const to_origin_conformance_checks: (table: OriginConformance) => Array<OriginConformanceCheck>;
|
|
310
371
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin_conformance.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/origin_conformance.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"origin_conformance.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/origin_conformance.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA6B9B,OAAO,EAgBN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACN,wBAAwB,EAExB,KAAK,uBAAuB,EAC5B,MAAM,2BAA2B,CAAC;AAEnC,2CAA2C;AAC3C,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE1E,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF,oFAAoF;AACpF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAKpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AACH,MAAM,M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
4
|
* runs it against each backend over the wire.
|
|
5
5
|
*
|
|
6
6
|
* `origin_conformance.json` (beside this module) is the one statement of the
|
|
7
|
-
* allowlist grammar and matcher
|
|
7
|
+
* allowlist grammar and matcher, and of the host gate's check over them, both
|
|
8
|
+
* spines implement. It holds three tables:
|
|
8
9
|
*
|
|
9
10
|
* - **parse** rows — `{raw, ok: true}` or `{raw, errors: [{index?, kind}]}`:
|
|
10
11
|
* an allowlist value (as `FUZ_ALLOWED_ORIGINS` would carry it) and whether
|
|
@@ -12,6 +13,8 @@ import '../assert_dev_env.js';
|
|
|
12
13
|
* list-level refusal) and its `AllowedOriginsErrorKind`.
|
|
13
14
|
* - **match** rows — `{patterns, origin, allowed}`: a valid allowlist, one
|
|
14
15
|
* `Origin` value (`null` for none), and the request-level answer.
|
|
16
|
+
* - **host** rows — `{patterns, hosts, allowed}`: a valid allowlist, the
|
|
17
|
+
* request's `Host` values (`[]` for none), and the host gate's answer.
|
|
15
18
|
*
|
|
16
19
|
* A row may carry a `note` for the reader. The TS unit test reads the table
|
|
17
20
|
* directly; `describe_origin_conformance_cross_tests` sends every row to a
|
|
@@ -48,10 +51,18 @@ export const OriginConformanceMatchRow = object({
|
|
|
48
51
|
allowed: boolean,
|
|
49
52
|
note: optional(string)
|
|
50
53
|
});
|
|
54
|
+
/** A host row: a valid allowlist, the request's `Host` values, and the host gate's answer. */
|
|
55
|
+
export const OriginConformanceHostRow = object({
|
|
56
|
+
patterns: string,
|
|
57
|
+
hosts: array(string),
|
|
58
|
+
allowed: boolean,
|
|
59
|
+
note: optional(string)
|
|
60
|
+
});
|
|
51
61
|
/** The conformance table, a `@fuzdev/fuz_schema` `object`. */
|
|
52
62
|
export const OriginConformance = object({
|
|
53
63
|
parse: pipe(array(OriginConformanceParseRow), min_length(1)),
|
|
54
|
-
match: pipe(array(OriginConformanceMatchRow), min_length(1))
|
|
64
|
+
match: pipe(array(OriginConformanceMatchRow), min_length(1)),
|
|
65
|
+
host: pipe(array(OriginConformanceHostRow), min_length(1))
|
|
55
66
|
});
|
|
56
67
|
/** The committed table, resolved relative to this module. */
|
|
57
68
|
export const ORIGIN_CONFORMANCE_URL = new URL('./origin_conformance.json', import.meta.url);
|
|
@@ -68,7 +79,7 @@ export const load_origin_conformance = () => parse_or_throw(OriginConformance, J
|
|
|
68
79
|
* `{ok: true, allowed: true}`.
|
|
69
80
|
*
|
|
70
81
|
* @param table - the conformance table
|
|
71
|
-
* @returns one check per row
|
|
82
|
+
* @returns one check per row: parse rows, then match rows, then host rows
|
|
72
83
|
*/
|
|
73
84
|
export const to_origin_conformance_checks = (table) => [
|
|
74
85
|
...table.parse.map((row) => ({
|
|
@@ -82,6 +93,11 @@ export const to_origin_conformance_checks = (table) => [
|
|
|
82
93
|
label: `match ${JSON.stringify(row.patterns)} × ${JSON.stringify(row.origin)}`,
|
|
83
94
|
input: { patterns: row.patterns, origin: row.origin },
|
|
84
95
|
expected: { ok: true, allowed: row.allowed }
|
|
96
|
+
})),
|
|
97
|
+
...table.host.map((row) => ({
|
|
98
|
+
label: `host ${JSON.stringify(row.patterns)} × ${JSON.stringify(row.hosts)}`,
|
|
99
|
+
input: { patterns: row.patterns, origin: null, hosts: [...row.hosts] },
|
|
100
|
+
expected: { ok: true, allowed: row.allowed }
|
|
85
101
|
}))
|
|
86
102
|
];
|
|
87
103
|
/**
|