@fuzdev/fuz_app 0.170.0 → 0.171.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.
Files changed (39) hide show
  1. package/dist/actions/CLAUDE.md +3 -3
  2. package/dist/actions/action_codegen.d.ts +5 -3
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +11 -27
  5. package/dist/actions/action_rpc.d.ts.map +1 -1
  6. package/dist/actions/action_rpc.js +5 -6
  7. package/dist/actions/peer_ping.d.ts.map +1 -1
  8. package/dist/actions/peer_ping.js +3 -2
  9. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  10. package/dist/actions/ws_socket_session.js +2 -1
  11. package/dist/auth/middleware.d.ts +6 -2
  12. package/dist/auth/middleware.d.ts.map +1 -1
  13. package/dist/auth/middleware.js +14 -2
  14. package/dist/auth/request_context.d.ts.map +1 -1
  15. package/dist/auth/request_context.js +5 -7
  16. package/dist/http/CLAUDE.md +3 -2
  17. package/dist/http/json_text.d.ts +53 -0
  18. package/dist/http/json_text.d.ts.map +1 -0
  19. package/dist/http/json_text.js +152 -0
  20. package/dist/http/route_result.d.ts +2 -1
  21. package/dist/http/route_result.d.ts.map +1 -1
  22. package/dist/http/route_spec.d.ts +1 -1
  23. package/dist/http/route_spec.d.ts.map +1 -1
  24. package/dist/http/route_spec.js +10 -9
  25. package/dist/http/schema_helpers.d.ts +10 -9
  26. package/dist/http/schema_helpers.d.ts.map +1 -1
  27. package/dist/testing/CLAUDE.md +1 -1
  28. package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
  29. package/dist/testing/adversarial_input_cases.js +2 -4
  30. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  31. package/dist/testing/cross_backend/identity_parity.js +7 -2
  32. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -1
  33. package/dist/testing/cross_backend/ws_envelope.js +8 -0
  34. package/dist/testing/rpc_envelope_cases.d.ts +7 -0
  35. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  36. package/dist/testing/rpc_envelope_cases.js +21 -0
  37. package/dist/testing/schema_generators.d.ts.map +1 -1
  38. package/dist/testing/schema_generators.js +8 -18
  39. package/package.json +1 -1
@@ -141,7 +141,7 @@ and options on each function's TSDoc.
141
141
  - `generate_action_method_enums` — up to nine `@fuzdev/fuz_schema` `one_of` + `Infer` pairs, importing `{one_of, type Infer}` from `@fuzdev/fuz_schema/schema.ts`; a const's `def` is its method array.
142
142
  - `generate_typed_action_event_alias` — fixed-shape `TypedActionEvent<TMethod, TPhase, TStep>` alias.
143
143
  - `generate_action_specs_record` — `ActionSpecs` runtime const + type + `action_specs` array. The const is annotated with the type (`readonly` members), so a consumer's declaration emit names the type instead of writing every spec's schema types out, which past enough specs is TS7056. The type is an alias, not an interface: an alias has an implicit index signature, so `Object.values(ActionSpecs)` stays typed and `action_specs` checks each spec against `ActionSpecUnion` (over an interface it is `any[]`).
144
- - `generate_action_inputs_outputs` — `ActionInputs` + `ActionOutputs` runtime consts + interfaces, plus the `ActionCallInputs` interface, importing `Infer` and `InferInput`; a value that is no schema throws naming the method. The two sides of a call see one input schema differently, so its types split by side: `ActionInputs` is each input's output type (`Infer<typeof …>`) — the parsed value a handler, an action event (`ActionEventDatas`) or a notification receiver reads, defaults filled and transforms applied; `ActionCallInputs` is its input type (`InferInput<typeof …>`) — what a caller passes, which the call surfaces (`FrontendActionsApi`, `BackendActionsApi`) take, so a `with_default` field is optional there and required in `ActionInputs`. `ActionOutputs` is each output's output type, what a caller receives.
144
+ - `generate_action_inputs_outputs` — the `ActionInputs`, `ActionCallInputs` and `ActionOutputs` interfaces, types only (a const's inferred type would be written out whole in a declaration file, TS7056 past enough specs; the schemas are read off `ActionSpecs`), importing `Infer` and `InferInput`; a value that is no schema throws naming the method. The two sides of a call see one input schema differently, so its types split by side: `ActionInputs` is each input's output type (`Infer<typeof …>`) — the parsed value a handler, an action event (`ActionEventDatas`) or a notification receiver reads, defaults filled and transforms applied; `ActionCallInputs` is its input type (`InferInput<typeof …>`) — what a caller passes, which the call surfaces (`FrontendActionsApi`, `BackendActionsApi`) take, so a `with_default` field is optional there and required in `ActionInputs`. `ActionOutputs` is each output's output type, what a caller receives.
145
145
  - `generate_action_event_datas` — `ActionEventDatas` interface; per-spec variants.
146
146
  - `generate_frontend_action_handlers` — `FrontendActionHandlers` interface (Tier 2 only).
147
147
  - `generate_backend_actions_api` — `BackendActionsApi` interface + `broadcast_action_specs` array.
@@ -205,7 +205,7 @@ spines, and an authorized one is `invalid_params`.
205
205
 
206
206
  Shim responsibilities (per-request):
207
207
 
208
- 1. Parse envelope (POST body / GET query string); parse errors → `parse_error` 400. GET reads `method` / `id` / `params` via Hono's `c.req.query()` — first occurrence wins on a duplicated key, unknown keys are ignored, and an empty value counts as missing. This is the cross-impl contract (the Rust GET dispatch mirrors it via `fuz_http`'s `query_first`, including the id numeric-vs-string normalization), pinned by the `query_shape` cross suite.
208
+ 1. Parse envelope (POST body / GET query string, each through `parse_json_text`, `http/json_text.ts`, so JSON the Rust spine refuses is refused here too); parse errors → `parse_error` 400, a `GET` `params` that is no JSON `invalid_params`. GET reads `method` / `id` / `params` via Hono's `c.req.query()` — first occurrence wins on a duplicated key, unknown keys are ignored, and an empty value counts as missing. This is the cross-impl contract (the Rust GET dispatch mirrors it via `fuz_http`'s `query_first`, including the id numeric-vs-string normalization), pinned by the `query_shape` cross suite.
209
209
  2. Lookup method in the `compile_action_registry`-built map; unknown → `method_not_found`.
210
210
  3. GET read restriction — GET rejected for `side_effects: true` actions. Every response the GET handler writes, its refusals included, carries `Cache-Control: no-store` (`RPC_GET_CACHE_CONTROL`; a pre-handler middleware refusal, like the origin 403, does not): a read answers one caller at one moment.
211
211
  4. Build `PerformActionInput` from `get_resolved_auth(c)` + `get_client_ip` + `c.req.raw.signal`. Test-preset escape hatch reads `has_test_context_preset(c)` + `REQUEST_CONTEXT_KEY`.
@@ -868,7 +868,7 @@ the duplicate-id and overflow wire strings, and the `on_socket_open` /
868
868
  Per-message dispatch delegates to `perform_action` — the shared core that
869
869
  HTTP RPC also calls. The socket session owns only WS-specific concerns:
870
870
 
871
- - **Wire envelope parsing** — JSON.parse → batch rejection → `classify_jsonrpc_message` (`http/jsonrpc_helpers.ts`, the twin of the Rust `fuz_http::classify`, the same classifier the HTTP POST path runs) → per-arm handling: an `invalid` answers its error on its id; a `response` routes to the socket's pending peer request; a `notification` routes `cancel` and is otherwise dropped; a `request` goes on to the duplicate-id and in-flight checks and dispatch. The classifier runs the twin's order — version, then the `method` axis, then `id`, then the `JsonrpcRequest` envelope — so `{method: 'x'}` and `{jsonrpc: '1.0', method: 'x'}` answer `invalid_request` rather than being dropped as notifications; a response is the twin's shape exactly (no string `method`, a string/number `id`, exactly one of `result` / `error`), so a hybrid like `{method, id, result}` stays a dispatchable request; and `params: null`, an array `params`, or a non-string/number `id` answers `invalid_request` (-32600) on both transports rather than reaching the dispatcher as `invalid_params`. Notifications stay unvalidated (they carry no id to echo). A non-object frame answers `id: null`. POST answers a notification or a response `invalid_request` on `id: null`, as the Rust spine does.
871
+ - **Wire envelope parsing** — `parse_json_text` (`http/json_text.ts`: what the Rust spine's `serde_json` refuses is a `parse_error` here too) → batch rejection → `classify_jsonrpc_message` (`http/jsonrpc_helpers.ts`, the twin of the Rust `fuz_http::classify`, the same classifier the HTTP POST path runs) → per-arm handling: an `invalid` answers its error on its id; a `response` routes to the socket's pending peer request; a `notification` routes `cancel` and is otherwise dropped; a `request` goes on to the duplicate-id and in-flight checks and dispatch. The classifier runs the twin's order — version, then the `method` axis, then `id`, then the `JsonrpcRequest` envelope — so `{method: 'x'}` and `{jsonrpc: '1.0', method: 'x'}` answer `invalid_request` rather than being dropped as notifications; a response is the twin's shape exactly (no string `method`, a string/number `id`, exactly one of `result` / `error`), so a hybrid like `{method, id, result}` stays a dispatchable request; and `params: null`, an array `params`, or a non-string/number `id` answers `invalid_request` (-32600) on both transports rather than reaching the dispatcher as `invalid_params`. Notifications stay unvalidated (they carry no id to echo). A non-object frame answers `id: null`. POST answers a notification or a response `invalid_request` on `id: null`, as the Rust spine does.
872
872
  - **Cancel-notification interception** — `{request_id → AbortController}` map; aborts the matching pending controller before the cancel bubbles past the dispatcher
873
873
  - **Duplicate live ids refused** — a request whose id names a request still running on the socket is answered `invalid_request` with `data.reason` `ERROR_DUPLICATE_REQUEST_ID` and not dispatched; the running request keeps its controller, its cancel entry, and its reply id. An id is free again once its request is answered. Same refusal on the Rust spine
874
874
  - **In-flight ceiling** — at most `MAX_INBOUND_DISPATCHES_PER_CONNECTION` (128) requests run at once per socket (`@hono/node-ws` does not await `onMessage`, so nothing else bounds them); one more is answered `queue_overflow` (`WS_INBOUND_DISPATCH_OVERFLOW_MESSAGE`) and not dispatched, and the socket stays open and keeps reading — a reply to a server-initiated request still gets through. The duplicate check runs first; neither refusal reaches `perform_action`, so neither charges the action rate limiters. Same cap, message, and order as the Rust spine's `MAX_INBOUND_DISPATCHES_PER_CONNECTION`
@@ -198,9 +198,11 @@ export declare const generate_action_specs_record: (specs: ReadonlyArray<ActionS
198
198
  include_protocol_actions?: boolean;
199
199
  }) => string;
200
200
  /**
201
- * Emit `ActionInputs` + `ActionOutputs` runtime consts and matching
202
- * interfaces, plus the `ActionCallInputs` interface. The runtime consts
203
- * reference `specs.{method}_action_spec.input` / `.output`.
201
+ * Emit the `ActionInputs`, `ActionCallInputs` and `ActionOutputs`
202
+ * interfaces, each member a type over `specs.{method}_action_spec.input` /
203
+ * `.output`. Types only: the schemas are read off the specs themselves
204
+ * (`ActionSpecs`), and a type reference stays a reference in a declaration
205
+ * file, where an unannotated const's inferred type is written out whole.
204
206
  *
205
207
  * The two sides of a call see different types for one input schema, so the
206
208
  * interfaces split by side:
@@ -1 +1 @@
1
- {"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,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A8BG;AACH,eAAO,MAAM,4BAA4B,GACxC,OAAO,aAAa,CAAC,eAAe,CAAC,EACrC,SAAS,aAAa,EACtB,UAAU;IACT,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,MAAM,CAAC;IACjD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC,KACC,MA2CF,CAAC;AAMF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,0BAA0B,GACtC,SAAS,aAAa,CAAC,UAAU,CAAC,EAClC,SAAS,aAAa,KACpB;IACF,YAAY,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CAiC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B,KAAG,MAYH,CAAC"}
@@ -650,9 +650,11 @@ ${type_lines}
650
650
  export const action_specs: Array<ActionSpecUnion> = Object.values(ActionSpecs);`;
651
651
  };
652
652
  /**
653
- * Emit `ActionInputs` + `ActionOutputs` runtime consts and matching
654
- * interfaces, plus the `ActionCallInputs` interface. The runtime consts
655
- * reference `specs.{method}_action_spec.input` / `.output`.
653
+ * Emit the `ActionInputs`, `ActionCallInputs` and `ActionOutputs`
654
+ * interfaces, each member a type over `specs.{method}_action_spec.input` /
655
+ * `.output`. Types only: the schemas are read off the specs themselves
656
+ * (`ActionSpecs`), and a type reference stays a reference in a declaration
657
+ * file, where an unannotated const's inferred type is written out whole.
656
658
  *
657
659
  * The two sides of a call see different types for one input schema, so the
658
660
  * interfaces split by side:
@@ -683,11 +685,9 @@ export const generate_action_inputs_outputs = (specs, imports, options) => {
683
685
  // Empty spec list — emit minimal valid output and skip the `Infer` /
684
686
  // `* as specs` imports that would have nothing to reference.
685
687
  return `/**
686
- * Action parameter schemas indexed by method name.
687
- * These represent the input data for each action,
688
- * e.g. JSON-RPC request/notification params and local call arguments.
688
+ * Action inputs indexed by method name, as parsed: each input schema's output
689
+ * type, e.g. JSON-RPC request/notification params and local call arguments.
689
690
  */
690
- export const ActionInputs = {} as const;
691
691
  export interface ActionInputs {}
692
692
 
693
693
  /**
@@ -697,11 +697,9 @@ export interface ActionInputs {}
697
697
  export interface ActionCallInputs {}
698
698
 
699
699
  /**
700
- * Action result schemas indexed by method name.
701
- * These represent the output data for each action,
700
+ * Action outputs indexed by method name: each output schema's output type,
702
701
  * e.g. JSON-RPC response results and local call return values.
703
702
  */
704
- export const ActionOutputs = {} as const;
705
703
  export interface ActionOutputs {}`;
706
704
  }
707
705
  for (const s of filtered) {
@@ -710,29 +708,19 @@ export interface ActionOutputs {}`;
710
708
  }
711
709
  imports.add_types('@fuzdev/fuz_schema/schema.ts', 'Infer', 'InferInput');
712
710
  const qualify = resolve_spec_qualifier(imports, options);
713
- const inputs_value = filtered
714
- .map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)}.input,`)
715
- .join('\n');
716
711
  const inputs_type = filtered
717
712
  .map((s) => `\t${to_action_property_key(s.method)}: Infer<typeof ${qualify(s)}.input>;`)
718
713
  .join('\n');
719
714
  const call_inputs_type = filtered
720
715
  .map((s) => `\t${to_action_property_key(s.method)}: InferInput<typeof ${qualify(s)}.input>;`)
721
716
  .join('\n');
722
- const outputs_value = filtered
723
- .map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)}.output,`)
724
- .join('\n');
725
717
  const outputs_type = filtered
726
718
  .map((s) => `\t${to_action_property_key(s.method)}: Infer<typeof ${qualify(s)}.output>;`)
727
719
  .join('\n');
728
720
  return `/**
729
- * Action parameter schemas indexed by method name.
730
- * These represent the input data for each action,
731
- * e.g. JSON-RPC request/notification params and local call arguments.
721
+ * Action inputs indexed by method name, as parsed: each input schema's output
722
+ * type, e.g. JSON-RPC request/notification params and local call arguments.
732
723
  */
733
- export const ActionInputs = {
734
- ${inputs_value}
735
- } as const;
736
724
  export interface ActionInputs {
737
725
  ${inputs_type}
738
726
  }
@@ -746,13 +734,9 @@ ${call_inputs_type}
746
734
  }
747
735
 
748
736
  /**
749
- * Action result schemas indexed by method name.
750
- * These represent the output data for each action,
737
+ * Action outputs indexed by method name: each output schema's output type,
751
738
  * e.g. JSON-RPC response results and local call return values.
752
739
  */
753
- export const ActionOutputs = {
754
- ${outputs_value}
755
- } as const;
756
740
  export interface ActionOutputs {
757
741
  ${outputs_type}
758
742
  }`;
@@ -1 +1 @@
1
- {"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiBxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAoOtF,CAAC"}
1
+ {"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiBxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAmOtF,CAAC"}
@@ -25,6 +25,7 @@ import { compile_action_registry } from './compile_action_registry.js';
25
25
  import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
26
26
  import { classify_jsonrpc_message, create_jsonrpc_error_response } from '../http/jsonrpc_helpers.js';
27
27
  import { perform_action, serialize_action_result } from './perform_action.js';
28
+ import { parse_json_text, read_json_body } from '../http/json_text.js';
28
29
  /**
29
30
  * The `Cache-Control` every response of the RPC endpoint's `GET` route carries
30
31
  * — a read is per caller and per moment, so nothing may store it.
@@ -153,14 +154,12 @@ export const create_rpc_endpoint = (options) => {
153
154
  // POST handler — parse JSON-RPC envelope from body
154
155
  const post_handler = async (c, route) => {
155
156
  // step 1: parse envelope
156
- let body;
157
- try {
158
- body = await c.req.json();
159
- }
160
- catch {
157
+ const read = await read_json_body(c.req);
158
+ if (!read.ok) {
161
159
  const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.parse_error());
162
160
  return envelope_response(c, error, 400);
163
161
  }
162
+ const body = read.value;
164
163
  // the classifier the WS path runs; HTTP issues no server-initiated
165
164
  // requests and has no notification semantics, so a response or a
166
165
  // notification answers `invalid_request` on `id: null`, as on the Rust spine
@@ -205,7 +204,7 @@ export const create_rpc_endpoint = (options) => {
205
204
  let params;
206
205
  if (params_raw !== undefined) {
207
206
  try {
208
- params = JSON.parse(params_raw);
207
+ params = parse_json_text(params_raw);
209
208
  }
210
209
  catch {
211
210
  const error = create_jsonrpc_error_response(id, jsonrpc_error_messages.invalid_params('params query parameter is not valid JSON'));
@@ -1 +1 @@
1
- {"version":3,"file":"peer_ping.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/peer_ping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGlE,+EAA+E;AAC/E,eAAO,MAAM,gBAAg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AO,eAAe,EACtB,KAAK,aAAa,KAChB,OAAO,CAAC,YAAY,CAsCtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,OAAO,KAAG,YAGrD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAG9B,CAAC"}
@@ -74,8 +74,9 @@ export const PingActionInput = with_default(object({
74
74
  // optional, so an empty invocation is valid (server-issued nonce, default
75
75
  // timeout). The server reads absent `params` as `{}` before the schema; the
76
76
  // client's pre-send parse of `app.api['peer/ping']()` reaches the default.
77
- // One shared `{}`, which nothing writes to
78
- {});
77
+ // `with_default` hands out one shared value, so it is frozen: a write to
78
+ // it throws rather than leaking into every later call
79
+ Object.freeze({}));
79
80
  /** Params of the server→client `peer/ping` request frame. Twin of the Rust `PingRequest`. */
80
81
  export const PingRequestParams = object({
81
82
  nonce: pipe(number, safe_integer)
@@ -1 +1 @@
1
- {"version":3,"file":"ws_socket_session.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/ws_socket_session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAyB,KAAK,kBAAkB,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M,CAAC;IACtC,yEAAyE;IACzE,cAAc,EAAE,CAAC,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/E,kGAAkG;IAClG,eAAe,EAAE,CAAC,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACjF,iEAAiE;IACjE,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,2EAA2E;IAC3E,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,6FAA6F;IAC7F,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACrF,+EAA+E;IAC/E,cAAc,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC/B,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,cAAc,EAAE;QAAE,eAAe,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAC;IACvE;;;;OAIG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB,gGAAgG;IAChG,eAAe,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,UAAU,gBAAgB,EAC1B,SAAS,eAAe,KACtB,QA6oBF,CAAC"}
@@ -118,6 +118,7 @@ import { cancel_action_spec, CancelNotificationParams } from './cancel.js';
118
118
  import { WS_CLOSE_CONNECTION_UNREGISTERED_REASON, WS_CLOSE_GOING_AWAY, WS_CLOSE_INTERNAL_ERROR, WS_CLOSE_INTERNAL_ERROR_REASON, WS_CLOSE_MESSAGE_TOO_BIG, WS_CLOSE_MESSAGE_TOO_BIG_REASON, WS_CLOSE_PERMISSION_REVOKED, WS_CLOSE_PERMISSION_REVOKED_REASON, WS_CLOSE_POLICY_VIOLATION, WS_CLOSE_PRE_ADMISSION_OVERFLOW_REASON, WS_CLOSE_CREDENTIAL_EXPIRED_REASON, WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT, WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT_REASON, WS_CLOSE_SESSION_REVOKED, WS_CLOSE_SOCKET_OPEN_FAILED_REASON, WS_CLOSE_SESSION_REVOKED_REASON, utf8_length, utf8_length_over } from './transports.js';
119
119
  import { audit_unmatched_peer_response } from './peer_request.js';
120
120
  import { perform_action, serialize_action_result } from './perform_action.js';
121
+ import { parse_json_text } from '../http/json_text.js';
121
122
  /**
122
123
  * Max inbound frames one socket may have queued while it is still opening —
123
124
  * between the handshake and the end of the credential re-check plus
@@ -501,7 +502,7 @@ export const create_ws_socket_events = (endpoint, upgrade) => {
501
502
  const send_error = (id, error) => send_error_response(registry, connection_id, id, error);
502
503
  let json;
503
504
  try {
504
- json = JSON.parse(String(data));
505
+ json = parse_json_text(String(data));
505
506
  }
506
507
  catch (error) {
507
508
  log.error('JSON parse error:', error);
@@ -75,7 +75,11 @@ export declare const assert_credential_routes_in_auth_scope: (route_specs: Reado
75
75
  /**
76
76
  * Throw unless every origin carve-out names a path and a reason, and stays
77
77
  * off the auth middleware's scope: a path that starts with `/` (a Hono pattern
78
- * like `/hooks/*` or `/health`), a non-blank reason — a carve-out is an
78
+ * like `/hooks/*` or `/health`) and is no route template — a carve-out matches
79
+ * a request path exactly or by a trailing `/*` prefix (`middleware_applies`),
80
+ * so a `:param`, a `{pattern}`, or an inner `*` would match only its own
81
+ * literal text at runtime while the surface reads it as the template — a
82
+ * non-blank reason — a carve-out is an
79
83
  * argument someone wrote down, never an empty placeholder — and a pattern that
80
84
  * matches nothing under `auth_path` (`middleware_paths_overlap`).
81
85
  *
@@ -93,7 +97,7 @@ export declare const assert_credential_routes_in_auth_scope: (route_specs: Reado
93
97
  *
94
98
  * @param carve_outs - the carve-outs to check
95
99
  * @param auth_path - the auth middleware's path pattern (default `AUTH_MIDDLEWARE_PATH`)
96
- * @throws Error naming the first carve-out with no path, no reason, or a pattern overlapping `auth_path`
100
+ * @throws Error naming the first carve-out with no path, a route template, no reason, or a pattern overlapping `auth_path`
97
101
  */
98
102
  export declare const assert_origin_carve_outs_valid: (carve_outs: ReadonlyArray<MiddlewareCarveOut>, auth_path?: string) => void;
99
103
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,GACzC,QAAQ,eAAe,GAAG,cAAc,GAAG,wBAAwB,EACnE,MAAM,MAAM,KACV,IAQF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sCAAsC,GAClD,aAAa,aAAa,CAAC,SAAS,CAAC,KACnC,IAcF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,8BAA8B,GAC1C,YAAY,aAAa,CAAC,kBAAkB,CAAC,EAC7C,YAAW,MAA6B,KACtC,IAsBF,CAAC;AAEF;;;;;;;GAOG;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export const assert_credential_routes_in_auth_scope = (route_specs) => {
92
92
  /**
93
93
  * Throw unless every origin carve-out names a path and a reason, and stays
94
94
  * off the auth middleware's scope: a path that starts with `/` (a Hono pattern
95
- * like `/hooks/*` or `/health`), a non-blank reason — a carve-out is an
95
+ * like `/hooks/*` or `/health`) and is no route template — a carve-out matches
96
+ * a request path exactly or by a trailing `/*` prefix (`middleware_applies`),
97
+ * so a `:param`, a `{pattern}`, or an inner `*` would match only its own
98
+ * literal text at runtime while the surface reads it as the template — a
99
+ * non-blank reason — a carve-out is an
96
100
  * argument someone wrote down, never an empty placeholder — and a pattern that
97
101
  * matches nothing under `auth_path` (`middleware_paths_overlap`).
98
102
  *
@@ -110,7 +114,7 @@ export const assert_credential_routes_in_auth_scope = (route_specs) => {
110
114
  *
111
115
  * @param carve_outs - the carve-outs to check
112
116
  * @param auth_path - the auth middleware's path pattern (default `AUTH_MIDDLEWARE_PATH`)
113
- * @throws Error naming the first carve-out with no path, no reason, or a pattern overlapping `auth_path`
117
+ * @throws Error naming the first carve-out with no path, a route template, no reason, or a pattern overlapping `auth_path`
114
118
  */
115
119
  export const assert_origin_carve_outs_valid = (carve_outs, auth_path = AUTH_MIDDLEWARE_PATH) => {
116
120
  for (const carve_out of carve_outs) {
@@ -118,6 +122,14 @@ export const assert_origin_carve_outs_valid = (carve_outs, auth_path = AUTH_MIDD
118
122
  throw new Error(`origin carve-out path ${JSON.stringify(carve_out.path)} must start with / ` +
119
123
  '(a Hono pattern like /hooks/* or /health)');
120
124
  }
125
+ const wildcard_at = carve_out.path.indexOf('*');
126
+ if (/[:{]/.test(carve_out.path) ||
127
+ (wildcard_at !== -1 &&
128
+ !(wildcard_at === carve_out.path.length - 1 && carve_out.path.endsWith('/*')))) {
129
+ throw new Error(`origin carve-out ${carve_out.path} is a route template — a carve-out matches a ` +
130
+ 'request path exactly or by a trailing /* prefix, so a :param, {pattern} or inner * ' +
131
+ 'would match only its own literal text; carve out the literal path or its /* prefix');
132
+ }
121
133
  if (carve_out.reason.trim() === '') {
122
134
  throw new Error(`origin carve-out ${carve_out.path} needs a reason — say why the paths are safe ` +
123
135
  'without the origin check');
@@ -1 +1 @@
1
- {"version":3,"file":"request_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/request_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAerD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAA6C,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElG,OAAO,EAIN,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACtB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,OAAO,KAAG,cAAc,GAAG,IAEjE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAAI,GAAG,OAAO,KAAG,cAQpD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IAC1D,KAAK,EAAE,KAAK,CA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0B,CAAA;CAAE,GAC5C;IAAE,KAAK,EAAE,OAAO,sBAAsB,CAAA;CAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,mBAAmB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,eAAe,EAAE,cAAc,GAAG,IAAI,CAAA;CAAE,GACpD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,IAAI,EAAE,wBAAwB,CAAA;CAAE,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,SAAS,EACf,YAAY,MAAM,GAAG,IAAI,EACzB,MAAM,SAAS,EACf,cAAc,MAAM,GAAG,SAAS,KAC9B,OAAO,CAAC,mBAAmB,CAwC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,uBAAuB,GACnC,GAAG,OAAO,EACV,MAAM,SAAS,EACf,MAAM,SAAS,EACf,QAAQ,MAAM,GAAG,SAAS,KACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAYzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,SAAS,KACb,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAO5D,CAAC"}
@@ -47,6 +47,7 @@ import { is_route_scope_capability, token_scope_admits_non_rpc, token_scope_deni
47
47
  import { is_public_auth, needs_actor, parse_acting } from '../http/auth_shape.js';
48
48
  import { is_null_schema } from '../http/schema_helpers.js';
49
49
  import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_CREDENTIAL_TYPE_REQUIRED, ERROR_ACTOR_REQUIRED, ERROR_ACTOR_NOT_ON_ACCOUNT, ERROR_NO_ACTORS_ON_ACCOUNT, ERROR_ACCOUNT_VANISHED } from '../http/error_schemas.js';
50
+ import { read_json_body } from '../http/json_text.js';
50
51
  /** Hono context variable name for the request context. */
51
52
  export const REQUEST_CONTEXT_KEY = 'request_context';
52
53
  /**
@@ -675,14 +676,11 @@ const read_route_acting = async (c, spec) => {
675
676
  return validated_query.acting;
676
677
  if (spec.method === 'GET' || is_null_schema(spec.input))
677
678
  return undefined;
678
- let body;
679
- try {
680
- body = await c.req.json();
681
- }
682
- catch {
683
- // Malformed body — input validation answers with the 400.
679
+ const read = await read_json_body(c.req);
680
+ // Malformed body — input validation answers with the 400.
681
+ if (!read.ok)
684
682
  return undefined;
685
- }
683
+ const body = read.value;
686
684
  if (typeof body !== 'object' || body === null)
687
685
  return undefined;
688
686
  return parse_acting(body.acting);
@@ -22,6 +22,7 @@ effects, see ../../../docs/architecture.md.
22
22
  - `http/route_error_check.ts` — `check_route_error` (whether an error response is one its route's map declares, the rule the DEV error check and `assert_response_matches_spec` share; `ALWAYS_ACCEPTED_ERRORS`, `is_error_status`, `format_route_error_check`) `is_json_response`, and the test helpers' hono-free route lookup (`split_route_template` and `parse_route_param`, a template read segment by segment as Hono's `getPattern` reads it; `compile_route_path`; `compile_route_param_pattern`, a `{re}` grouped and anchored as `compile_route_path` reads it — Hono's RegExpRouter reading, stricter than TrieRouter's ungrouped `^re$`; `decode_route_path`, a path as Hono's router decodes it; `to_mounted_routes`; `find_mounted_route`), whose reading `resolve_valid_path` also fills params by. Hono-free and `esm-env`-free.
23
23
  - `http/dev_route_error_check.ts` — `create_dev_route_error_check({route_specs, route_error_maps, log})`: the DEV-only outer error check, `null` outside DEV; `create_route_lookup`, its lookup by Hono's own router.
24
24
  - `http/schema_helpers.ts` — shared schema introspection (null/void/strict/surface/middleware-applies), and `to_void_params` / `to_input_params` / `json_has_own_proto_key` / `safe_parse_dropping_unknown_keys`.
25
+ - `http/json_text.ts` — `parse_json_text`: JSON text read as the Rust spine's `serde_json` reads it, refusing what `JSON.parse` accepts and serde refuses (an escaped lone surrogate in a string or key, a number out of `f64` range, nesting `JSON_DEPTH_LIMIT` (128) deep); one linear scan of the text after `JSON.parse` accepts it (`is_serde_json_text`), so a refused value under a duplicated key is seen and the cost stays a few milliseconds a MiB. `read_json_body(c.req)` reads a request body through it once per request (the authorization phase's `acting` read and input validation share it), as text, never `c.req.json()`. Every body and frame parse runs it: route input, the RPC POST body and `GET` `params`, WS frames. Hono-free, imports nothing.
25
26
  - `http/middleware_spec.ts` — `MiddlewareSpec` interface.
26
27
  - `http/body_limit.ts` — `create_body_limit_middleware(max_size)`: the `413` body cap `create_app_server` mounts, as `create_body_limit_middleware_spec(max_size)`, a `MiddlewareSpec` at `'*'` ahead of the other middleware, absent with `max_body_size: null`. Its hono-free shape, `body_limit_middleware_shape` (`http/body_limit_schema.ts`), declares its `413` `payload_too_large` and `400` `invalid_content_length`, so every route's error map carries both; `create_test_app_surface_spec` lists the same shape with a stub handler. Refuses on `Content-Length` without reading `c.req.raw.body` and answers `Connection: close` — `413` past the cap, `400` `ERROR_INVALID_CONTENT_LENGTH` when the value is not a plain run of ASCII digits (a length the cap cannot read, which Hono's `bodyLimit` would pass uncounted) — else falls through to Hono's `bodyLimit` (no `Content-Length`, or one beside `Transfer-Encoding`), which reads the body into memory up to the cap before the next middleware runs, so its `413` — no `Connection: close` — also precedes origin and auth. After the header `413` Node and Bun close at once (the header is what makes them — Bun 1.4.3 is the tested floor, an older Bun kept the connection and served the next request) and Deno closes once the declared body has arrived (../../../docs/security.md §Body Size Limiting).
27
28
  - `http/surface.ts` — `AppSurface`, `AppSurfaceSpec`, `generate_app_surface`, diagnostics.
@@ -162,7 +163,7 @@ wrapper). See `auth/signup_routes.ts`.
162
163
  3. **Pre-authorization auth guards** — every gate that reads only what the auth middleware set, in coarse-to-fine order: `require_auth` (401 `ERROR_AUTHENTICATION_REQUIRED`) when `auth.account === 'required'` or `auth.actor === 'required'`; `require_credential_types(types)` (403 `ERROR_CREDENTIAL_TYPE_REQUIRED` with `required_credential_types: ReadonlyArray<string>`) when `auth.credential_types?.length`; `require_token_scope(capability)` (403 `ERROR_TOKEN_SCOPE_REQUIRED` with `required_scope`, the token-scope refusal) when `auth.required_scope` names a capability. All fire before any body parsing — so a caller they refuse never sees route-shape information from input parse failures — and before actor resolution, so a wrong channel costs no DB work and never learns account state (e.g. that the account is multi-actor). The `AuthGuardResolver` (e.g. `fuz_auth_guard_resolver` from `auth/auth_guard_resolver.ts`) returns this set as `pre_authorization: Array<MiddlewareHandler>`.
163
164
  4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation, 500 `ERROR_ACCOUNT_VANISHED` on torn account/actor reads after a successful resolve). Public routes (`account: 'none' && actor: 'none'`) skip this phase entirely.
164
165
  5. **Post-authorization auth guards** — `require_role(roles)` (403 `ERROR_INSUFFICIENT_PERMISSIONS` with `required_roles: ReadonlyArray<string>`) when `auth.roles?.length`. The only gate in this phase, because it is the only one that reads `REQUEST_CONTEXT_KEY` (populated by step 4) rather than the auth middleware's own context vars. Multi-role specs admit any-of via `has_any_scoped_role(ctx, roles, null)`.
165
- 6. **Input validation** — JSON body parsed + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on GET and on a null input (`is_null_schema`: `literal(null)`). The validated input lands on `c.var.validated_input`.
166
+ 6. **Input validation** — JSON body parsed (`read_json_body`) + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON, or JSON the Rust spine refuses — `parse_json_text`) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on GET and on a null input (`is_null_schema`: `literal(null)`). The validated input lands on `c.var.validated_input`.
166
167
  7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`; its result becomes the response (`to_route_response`)
167
168
  8. **Error catch** — catches a thrown JSON-RPC error (`ThrownJsonrpcError`, recognized by brand through `to_thrown_jsonrpc_error`, so one from a second fuz_app copy maps too; a foreign error class carrying a JSON-RPC `code` falls to the generic path) → maps to HTTP status + the flat REST error body (`{error: <reason>, message?, ...rest_data}`); catches generic `Error` → 500 `{error: 'internal_error', message?}` (message only in DEV). The reason string comes from `err.data.reason` when set (consumer-supplied canonical reason override) or from `jsonrpc_error_code_to_name(err.code)` (e.g. `-32003 → 'not_found'`). The flat shape matches what middleware and direct handlers emit — REST callers see one envelope across every emit site, while the JSON-RPC dispatcher keeps its own `{jsonrpc, id, error: {code, message, data}}` envelope on the RPC mount.
168
169
  9. **DEV-only output validation** — a 2xx JSON body against `spec.output` (see below); error responses are the outer DEV error check's
@@ -327,7 +328,7 @@ Key helpers:
327
328
  - `safe_parse_dropping_unknown_keys(schema, value)` — the forward-compatible read of a remote-authored payload, returning `parse`'s `{ok, value}` / `{ok: false, issues}`: while every issue is an unknown key (`unknown_key_targets`), strips them from a copy and reparses — after the first parse that reports unknown keys, one schema-guided pass deletes every key a strict `object` doesn't name anywhere the schema reaches (entries, array items, record values, the `variant` option), as a parse reports at most a hundred issues; a key under a `union` is never stripped (the union fails as one issue of its own), and a later `pipe` stage is stripped only as reported — until nothing is left to strip, capped at `UNKNOWN_KEY_PASSES_MAX` passes (the last failure returned past it); any other issue still fails. Used for response `result`s (`ActionEvent`) and peer replies (`peer/ping`); matches serde's ignore-unknown-fields default on the Rust spine
328
329
  - `is_strict_object_schema(schema)` — detects an `object` (not `strip_object` / `loose_object`); a `pipe` is read through to its first schema when no stage is a `transform` (so a refined `object` reads strict)
329
330
  - `schema_to_surface(schema, {io?, source?, on_unrepresentable?}?)` — throws first on a value that is no schema (`assert_validation_schema`, naming `source`, so an assembled app's slot holding none fails boot as registration would refuse it, not as an unwritable JSON Schema); a schema → JSON Schema (`to_json_schema`), on the side `io` names (`'output'` by default), with `$schema` and `default` keys stripped recursively (defaults may be non-deterministic; `$schema` is snapshot noise). `null` for a null or void schema. A part JSON Schema can't say (an output-side transform, a `check`) is left out or written as `{}` (`unrepresentable: 'any'`) and reported to `on_unrepresentable`; a schema with nothing describable (`{}` from a schema other than `unknown`) or one the emitter refuses outright throws, prefixed with `source` — so a root-level transform output fails server assembly. It never answers `null` for a failure, which would read as "no input" and drop the schema from every suite that reads the surface
330
- - `SchemaFieldInfo` — one field of an object schema (`name`, `base_type`, `required`, `has_default`, `nullable`), what the testing generators' `to_object_schema_view` produces
331
+ - `SchemaFieldInfo` — one field of an object schema (`name`, `base_type` — a `SchemaFieldBaseType`, the innermost fuz_schema kind —, `required`, `has_default`, `nullable`), what the testing generators' `to_object_schema_view` produces
331
332
  - `middleware_applies(mw_path, route_path)` — Hono pattern matching: `'*'`, exact, `'/api/*'` prefix (handles `prefix.slice(0, -1)` so `/api/*` also matches the bare `/api`)
332
333
  - `middleware_carves_out(spec, route_path)` — one of the layer's `carve_outs` applies to the route; the carve-out half of `middleware_spec_applies`, which `assert_full_middleware_stack` reads to relax a carved-out route's expected stack
333
334
  - `middleware_spec_applies(spec, route_path)` — the layer runs on the route: its `path` applies and none of its `carve_outs` does; what the route error map takes middleware definitions by
@@ -0,0 +1,53 @@
1
+ /**
2
+ * JSON text read as the Rust spine's `serde_json` reads it.
3
+ *
4
+ * `JSON.parse` accepts three things `serde_json` refuses: an escaped lone
5
+ * surrogate (`"\ud800"`, in a string or a key), a number out of `f64` range
6
+ * (`1e400`, which `JSON.parse` reads as `Infinity`), and nesting 128 deep or
7
+ * more. Accepted, they don't survive storage: a lone surrogate is written to a
8
+ * text column as U+FFFD and refused by a `jsonb` one, and `Infinity`
9
+ * serializes as `null`. `parse_json_text` refuses all three, so a request body
10
+ * or frame gets the same verdict on both spines (`invalid_json_body` for a
11
+ * REST body, `parse_error` for a JSON-RPC body or frame, `invalid_params` for
12
+ * `GET /rpc`'s `params`).
13
+ *
14
+ * The check is one linear pass over the text after `JSON.parse` accepts it
15
+ * (`is_serde_json_text`): a few milliseconds a MiB, whatever the text holds.
16
+ *
17
+ * @module
18
+ */
19
+ /** The nesting depth `serde_json` refuses: a value nested this deep or deeper fails. */
20
+ export declare const JSON_DEPTH_LIMIT = 128;
21
+ /**
22
+ * Parses JSON text as `JSON.parse` does, refusing what `serde_json` refuses:
23
+ * an escaped lone surrogate, a number out of `f64` range, and nesting
24
+ * `JSON_DEPTH_LIMIT` deep or more.
25
+ *
26
+ * @param text - the JSON text
27
+ * @returns the parsed value
28
+ * @throws SyntaxError when `JSON.parse` throws or the text has one of the three
29
+ */
30
+ export declare const parse_json_text: (text: string) => unknown;
31
+ /** A request body read as JSON by `read_json_body`: the value, or a refusal. */
32
+ export type JsonBodyResult = {
33
+ ok: true;
34
+ value: unknown;
35
+ } | {
36
+ ok: false;
37
+ };
38
+ /** The request a body is read from: Hono's `c.req`, structurally, so this module stays hono-free. */
39
+ export interface JsonBodyRequest {
40
+ raw: Request;
41
+ text: () => Promise<string>;
42
+ }
43
+ /**
44
+ * Reads a request body as JSON text through `parse_json_text`, once per
45
+ * request: the authorization phase's `acting` read and input validation share
46
+ * the one parse. Reads the body with `c.req.text()`, as `parse_json_text`
47
+ * reads the text and not a parsed value.
48
+ *
49
+ * @param req - the request, Hono's `c.req`
50
+ * @returns the parsed body, or `{ok: false}` when it isn't JSON text `parse_json_text` accepts
51
+ */
52
+ export declare const read_json_body: (req: JsonBodyRequest) => Promise<JsonBodyResult>;
53
+ //# sourceMappingURL=json_text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json_text.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/json_text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAwFpC;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,OAM9C,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAE1E,qGAAqG;AACrG,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5B;AAID;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,eAAe,KAAG,OAAO,CAAC,cAAc,CAgB3E,CAAC"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * JSON text read as the Rust spine's `serde_json` reads it.
3
+ *
4
+ * `JSON.parse` accepts three things `serde_json` refuses: an escaped lone
5
+ * surrogate (`"\ud800"`, in a string or a key), a number out of `f64` range
6
+ * (`1e400`, which `JSON.parse` reads as `Infinity`), and nesting 128 deep or
7
+ * more. Accepted, they don't survive storage: a lone surrogate is written to a
8
+ * text column as U+FFFD and refused by a `jsonb` one, and `Infinity`
9
+ * serializes as `null`. `parse_json_text` refuses all three, so a request body
10
+ * or frame gets the same verdict on both spines (`invalid_json_body` for a
11
+ * REST body, `parse_error` for a JSON-RPC body or frame, `invalid_params` for
12
+ * `GET /rpc`'s `params`).
13
+ *
14
+ * The check is one linear pass over the text after `JSON.parse` accepts it
15
+ * (`is_serde_json_text`): a few milliseconds a MiB, whatever the text holds.
16
+ *
17
+ * @module
18
+ */
19
+ /** The nesting depth `serde_json` refuses: a value nested this deep or deeper fails. */
20
+ export const JSON_DEPTH_LIMIT = 128;
21
+ /**
22
+ * The digits a number's mantissa (or exponent, `NUMBER_EXPONENT_DIGITS_CHECKED`)
23
+ * reaches before it can be out of `f64` range: with an exponent of two digits
24
+ * at most, a mantissa needs more than 200 digits to pass `f64::MAX`. A number
25
+ * this long is read with `Number` to see.
26
+ */
27
+ const NUMBER_MANTISSA_DIGITS_CHECKED = 200;
28
+ const NUMBER_EXPONENT_DIGITS_CHECKED = 3;
29
+ const hex4 = (text, at) => parseInt(text.slice(at, at + 4), 16);
30
+ const is_high_surrogate = (u) => u >= 0xd800 && u <= 0xdbff;
31
+ const is_low_surrogate = (u) => u >= 0xdc00 && u <= 0xdfff;
32
+ /**
33
+ * Whether `text`, which `JSON.parse` accepted, holds nothing `serde_json`
34
+ * refuses — one pass over the text, so its cost is linear whatever it holds:
35
+ *
36
+ * - every `\u` escape of a surrogate is a high one followed at once by a low
37
+ * one's escape, in a string or a key
38
+ * - nesting stays under `JSON_DEPTH_LIMIT`, counted outside strings
39
+ * - a number long enough to leave `f64` range is finite as `Number` reads it
40
+ *
41
+ * The text, not the parsed value, is what is read: `JSON.parse` keeps the last
42
+ * of two duplicate keys, so a refused value under the first would never be seen,
43
+ * where `serde_json` refuses it as it reads.
44
+ */
45
+ const is_serde_json_text = (text) => {
46
+ let depth = 0;
47
+ const length = text.length;
48
+ for (let i = 0; i < length; i++) {
49
+ const c = text.charCodeAt(i);
50
+ if (c === 0x22) {
51
+ // a string: the text is valid JSON, so every escape is well formed
52
+ for (i++;; i++) {
53
+ const d = text.charCodeAt(i);
54
+ if (d === 0x22)
55
+ break;
56
+ if (d !== 0x5c)
57
+ continue;
58
+ i++;
59
+ if (text.charCodeAt(i) !== 0x75)
60
+ continue;
61
+ const unit = hex4(text, i + 1);
62
+ i += 4;
63
+ if (is_low_surrogate(unit))
64
+ return false;
65
+ if (!is_high_surrogate(unit))
66
+ continue;
67
+ if (text.charCodeAt(i + 1) !== 0x5c ||
68
+ text.charCodeAt(i + 2) !== 0x75 ||
69
+ !is_low_surrogate(hex4(text, i + 3))) {
70
+ return false;
71
+ }
72
+ i += 6;
73
+ }
74
+ }
75
+ else if (c === 0x5b || c === 0x7b) {
76
+ if (++depth >= JSON_DEPTH_LIMIT)
77
+ return false;
78
+ }
79
+ else if (c === 0x5d || c === 0x7d) {
80
+ depth--;
81
+ }
82
+ else if (c === 0x2d || (c >= 0x30 && c <= 0x39)) {
83
+ const start = i;
84
+ let mantissa_digits = 0;
85
+ let exponent_digits = 0;
86
+ let in_exponent = false;
87
+ for (; i < length; i++) {
88
+ const d = text.charCodeAt(i);
89
+ if (d >= 0x30 && d <= 0x39) {
90
+ if (in_exponent)
91
+ exponent_digits++;
92
+ else
93
+ mantissa_digits++;
94
+ }
95
+ else if (d === 0x65 || d === 0x45) {
96
+ in_exponent = true;
97
+ }
98
+ else if (d !== 0x2d && d !== 0x2b && d !== 0x2e) {
99
+ break;
100
+ }
101
+ }
102
+ if ((mantissa_digits >= NUMBER_MANTISSA_DIGITS_CHECKED ||
103
+ exponent_digits >= NUMBER_EXPONENT_DIGITS_CHECKED) &&
104
+ !Number.isFinite(Number(text.slice(start, i)))) {
105
+ return false;
106
+ }
107
+ i--;
108
+ }
109
+ }
110
+ return true;
111
+ };
112
+ /**
113
+ * Parses JSON text as `JSON.parse` does, refusing what `serde_json` refuses:
114
+ * an escaped lone surrogate, a number out of `f64` range, and nesting
115
+ * `JSON_DEPTH_LIMIT` deep or more.
116
+ *
117
+ * @param text - the JSON text
118
+ * @returns the parsed value
119
+ * @throws SyntaxError when `JSON.parse` throws or the text has one of the three
120
+ */
121
+ export const parse_json_text = (text) => {
122
+ const value = JSON.parse(text);
123
+ if (!is_serde_json_text(text)) {
124
+ throw new SyntaxError('JSON text has a value the Rust spine refuses');
125
+ }
126
+ return value;
127
+ };
128
+ const json_body_cache = new WeakMap();
129
+ /**
130
+ * Reads a request body as JSON text through `parse_json_text`, once per
131
+ * request: the authorization phase's `acting` read and input validation share
132
+ * the one parse. Reads the body with `c.req.text()`, as `parse_json_text`
133
+ * reads the text and not a parsed value.
134
+ *
135
+ * @param req - the request, Hono's `c.req`
136
+ * @returns the parsed body, or `{ok: false}` when it isn't JSON text `parse_json_text` accepts
137
+ */
138
+ export const read_json_body = (req) => {
139
+ let result = json_body_cache.get(req.raw);
140
+ if (!result) {
141
+ result = req.text().then((text) => {
142
+ try {
143
+ return { ok: true, value: parse_json_text(text) };
144
+ }
145
+ catch {
146
+ return { ok: false };
147
+ }
148
+ }, () => ({ ok: false }));
149
+ json_body_cache.set(req.raw, result);
150
+ }
151
+ return result;
152
+ };
@@ -35,7 +35,8 @@ export interface RouteFail<TStatus extends number, TCode extends string, TBody>
35
35
  readonly status: TStatus;
36
36
  readonly code: TCode;
37
37
  readonly body: TBody;
38
- readonly def: RestErrorDef;
38
+ /** The definition the failure was made from, at the same status and code. */
39
+ readonly def: RestErrorDef<TStatus, TCode>;
39
40
  }
40
41
  /** A response the handler built itself, answered as it is (`route_raw`). */
41
42
  export interface RouteRaw {
@@ -1 +1 @@
1
- {"version":3,"file":"route_result.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wEAAwE;AACxE,MAAM,WAAW,OAAO,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CAClB;AAED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,CAAC,OAAO,CAAC,CAAC,GACrC,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,GACtC,KAAK,CAAC;AAEV;;;;;;;GAOG;AAGH,eAAO,MAAM,QAAQ,GAAI,KAAK,CAAC,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,CAAC,CAA0B,CAAC;AAEnG;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,IAAI,SAAS,YAAY,EACnD,KAAK,IAAI,EACT,GAAG,QAAQ,eAAe,CAAC,IAAI,CAAC,KAC9B,WAAW,CAAC,IAAI,CAOgB,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,QAAQ,EACnD,UAAU,SAAS,GAClB,CAAC,SAAS,SAAS,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC,KAC/E,QAAqC,CAAC"}
@@ -329,7 +329,7 @@ export declare const attach_route_handler: <TErrors extends ReadonlyArray<RestEr
329
329
  *
330
330
  * @param c - the Hono context
331
331
  * @param result - the handler's result
332
- * @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value, a failure without its status or definition, a raw result without a response, `undefined` or `null`
332
+ * @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value or with a function or symbol for one, a failure without its status or definition, a raw result without a response, `undefined` or `null`
333
333
  */
334
334
  export declare const to_route_response: (c: Context, result: RouteResult) => Response;
335
335
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"route_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAW,IAAI,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAGtE,OAAO,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;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,iBAAiB,GAC7B,KAAK,IAAI,EACT,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,qBAAqB,iBAAiB,EACtC,KAAK,MAAM,EACX,IAAI,EAAE,EACN,YAAY,oBAAoB,KAC9B,IA+EF,CAAC;AAkCF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,SAAS,CAK3F,CAAC"}
@@ -29,6 +29,7 @@ import { is_json_response } from './route_error_check.js';
29
29
  import { dispatch_with_post_commit_rollback } from './pending_effects.js';
30
30
  import { assert_route_auth_acting_biconditional, assert_route_auth_invariants } from './auth_shape.js';
31
31
  import { assert_validation_schema, to_wire_issues } from '../schema_issues.js';
32
+ import { read_json_body } from './json_text.js';
32
33
  /**
33
34
  * Define a route: its handler is checked against the route's `output`,
34
35
  * `errors`, `auth`, and `rate_limit` (`TypedRouteHandler`), and the spec is
@@ -69,15 +70,18 @@ export const attach_route_handler = (shape, handler) => ({ ...shape, handler });
69
70
  *
70
71
  * @param c - the Hono context
71
72
  * @param result - the handler's result
72
- * @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value, a failure without its status or definition, a raw result without a response, `undefined` or `null`
73
+ * @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value or with a function or symbol for one, a failure without its status or definition, a raw result without a response, `undefined` or `null`
73
74
  */
74
75
  export const to_route_response = (c, result) => {
75
76
  // each branch checks the field it reads, so a malformed or nullish result
76
77
  // falls through to the throw — a `Response` has its own `ok` and `status`,
77
- // but no `value` or `def`
78
+ // but no `value` or `def`. A function or symbol value is no JSON value:
79
+ // `JSON.stringify` writes nothing for it, which would answer an empty 200
78
80
  if (result?.ok === true) {
79
- if (result.value !== undefined)
81
+ const type = typeof result.value;
82
+ if (type !== 'undefined' && type !== 'function' && type !== 'symbol') {
80
83
  return c.json(result.value);
84
+ }
81
85
  }
82
86
  else if (result?.ok === 'raw') {
83
87
  if (result.response instanceof Response)
@@ -141,13 +145,10 @@ const create_input_validation = (input_schema, method) => {
141
145
  if (is_null_schema(input_schema))
142
146
  return [];
143
147
  const validate = async (c, next) => {
144
- let body;
145
- try {
146
- body = await c.req.json();
147
- }
148
- catch {
148
+ const read = await read_json_body(c.req);
149
+ if (!read.ok)
149
150
  return c.json({ error: ERROR_INVALID_JSON_BODY }, 400);
150
- }
151
+ const body = read.value;
151
152
  if (typeof body !== 'object' || body === null || Array.isArray(body)) {
152
153
  return c.json({ error: ERROR_INVALID_JSON_BODY }, 400);
153
154
  }
@@ -7,7 +7,14 @@
7
7
  *
8
8
  * @module
9
9
  */
10
- import { type AnySchema, type Infer, type SchemaResult } from '@fuzdev/fuz_schema/schema.ts';
10
+ import { type AnySchema, type Infer, type SchemaKind, type SchemaResult } from '@fuzdev/fuz_schema/schema.ts';
11
+ /**
12
+ * The kind the testing generators switch on: the innermost layer's
13
+ * `@fuzdev/fuz_schema` kind, with an object schema of any strictness as
14
+ * `'object'`, and a `literal(null)` and a `literal(undefined)` (`s.void`) as
15
+ * `'null'` and `'void'`.
16
+ */
17
+ export type SchemaFieldBaseType = Exclude<SchemaKind, 'loose_object' | 'strip_object' | 'object_with_rest'> | 'null' | 'void';
11
18
  /**
12
19
  * What the testing generators read of one field of an object schema
13
20
  * (`to_object_schema_view`, `testing/schema_generators.ts`).
@@ -15,14 +22,8 @@ import { type AnySchema, type Infer, type SchemaResult } from '@fuzdev/fuz_schem
15
22
  export interface SchemaFieldInfo {
16
23
  /** The field's key. */
17
24
  name: string;
18
- /**
19
- * The innermost kind's name: `'string'`, `'number'`, `'boolean'`,
20
- * `'array'`, `'literal'`, and so on, with an object of any strictness as
21
- * `'object'`, a `literal(null)` as `'null'`, a `literal(undefined)`
22
- * (`s.void`) as `'void'`, a `one_of` as `'enum'`, and a `variant` as
23
- * `'union'`.
24
- */
25
- base_type: string;
25
+ /** The innermost layer's kind, `SchemaFieldBaseType`. */
26
+ base_type: SchemaFieldBaseType;
26
27
  /** Whether the key must be present: no `optional` layer. */
27
28
  required: boolean;
28
29
  /** Whether the parse fills the key in when it is missing. */
@@ -1 +1 @@
1
- {"version":3,"file":"schema_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/schema_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAS,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAMpG;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,KAAG,OACF,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,KAAG,OACG,CAAC;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,OAAO,KAAG,OAUpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,EAAE,YAAY,OAAO,KAAG,OACA,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,OAavD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,gCAAgC,GAAI,CAAC,SAAS,SAAS,EACnE,QAAQ,CAAC,EACT,O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AA;KAAE,CAAC,GAAG,IAAI,CAAC;CACtE,EACD,YAAY,MAAM,KAChB,OAAgG,CAAC"}
@@ -502,7 +502,7 @@ Support functions:
502
502
  Walks `@fuzdev/fuz_schema` schemas to generate valid values for
503
503
  adversarial/round-trip tests. A value that is no schema throws, naming it.
504
504
 
505
- - `to_object_schema_view(schema, label)` → `ObjectSchemaView` — the fields (`SchemaFieldInfo[]`, from `http/schema_helpers.ts`) of an object schema through its wrappers, each `base_type` its innermost kind (an object of any strictness reads `'object'`, `literal(null)` `'null'`, `literal(undefined)` `'void'`, `one_of` `'enum'`, `variant` `'union'`), and each field's schema, throwing on a schema that is no object schema. `to_body_input(input_schema, label)` is the body generators' gate: `null` for a void or null input, else the object view, and a throw for any other input — no body is never silently what an unbuildable input yields.
505
+ - `to_object_schema_view(schema, label)` → `ObjectSchemaView` — the fields (`SchemaFieldInfo[]`, from `http/schema_helpers.ts`) of an object schema through its wrappers, each `base_type` its innermost fuz_schema kind (`SchemaFieldBaseType`: an object of any strictness reads `'object'`, `literal(null)` `'null'`, `literal(undefined)` `'void'`), and each field's schema, throwing on a schema that is no object schema. `to_body_input(input_schema, label)` is the body generators' gate: `null` for a void or null input, else the object view, and a throw for any other input — no body is never silently what an unbuildable input yields.
506
506
 
507
507
  - `to_field_json_schema(field_schema)` — the field's JSON Schema rendered with `io: 'input'`, so a field piped through a `transform` (`Username`) yields its input-side bounds and pattern instead of throwing; a `nullable` field's one non-null `anyOf` branch (or one non-null `type` of a `type` array) is returned. It renders with `unrepresentable: 'any'`, so it is never `null`: a part JSON Schema can't say (a `check`) is left out or `{}` and the bounds around it still read; it throws on a schema the emitter refuses even then. A pipe yields its input stage only, and a `check` never appears (a code-point length bound generates nothing). Every JSON Schema read in the generators goes through it.
508
508
  - `detect_format(field_schema)` — `detect_json_schema_format` over `to_field_json_schema`: the `format`, `'pattern'` for a regex, or `null`.
@@ -1 +1 @@
1
- {"version":3,"file":"adversarial_input_cases.d.ts","sourceRoot":"../src/lib/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AAc,CAoBzF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAI,cAAc,SAAS,KAAG,KAAK,CAAC,aAAa,CAkCtF,CAAC"}
1
+ {"version":3,"file":"adversarial_input_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/adversarial_input_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAuErE,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,0BAA0B,GAAG,OAAO,uBAAuB,CAAC;CACnF;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAID,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACpC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,yBAAyB,GACrC,cAAc,SAAS,EACvB,UAAU,oBAAoB,KAC5B,KAAK,CAAC,aAAa,CAyMrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,cAAc,SAAS,EACvB,WAAW,aAAa,KACtB,MAAM,GAAG,SAG+C,CAAC;AAmC5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,eAAe,SAAS,KAAG,KAAK,CAAC,cAAc,CAoBzF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAI,cAAc,SAAS,KAAG,KAAK,CAAC,aAAa,CAkCtF,CAAC"}
@@ -24,8 +24,6 @@ const accepts = (schema, value) => parse(schema, value).ok;
24
24
  const wrong_type_for = (base_type) => {
25
25
  switch (base_type) {
26
26
  case 'string':
27
- case 'uuid':
28
- case 'email':
29
27
  return { label: 'number instead of string', value: 42 };
30
28
  case 'number':
31
29
  return { label: 'string instead of number', value: 'not_a_number' };
@@ -35,7 +33,7 @@ const wrong_type_for = (base_type) => {
35
33
  return { label: 'string instead of array', value: 'not_an_array' };
36
34
  case 'object':
37
35
  return { label: 'string instead of object', value: 'not_an_object' };
38
- case 'enum':
36
+ case 'one_of':
39
37
  return { label: 'number instead of enum', value: 42 };
40
38
  default:
41
39
  return null;
@@ -210,7 +208,7 @@ export const generate_input_test_cases = (input_schema, options) => {
210
208
  }
211
209
  // string length boundaries — `x`s are one UTF-16 unit and one code point
212
210
  // each, so the over-`maxLength` string is over in either count
213
- if (field.base_type === 'string' || field.base_type === 'uuid' || field.base_type === 'email') {
211
+ if (field.base_type === 'string') {
214
212
  if (typeof json.minLength === 'number' && json.minLength > 0) {
215
213
  push_field_case(`empty string: ${field.name}`, '', 'value');
216
214
  }
@@ -1 +1 @@
1
- {"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA0H9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAyB5C,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAsKD,eAAO,MAAM,oCAAoC,GAChD,SAAS,8BAA8B,KACrC,IAygBF,CAAC"}
1
+ {"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA0H9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA0B5C,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAsKD,eAAO,MAAM,oCAAoC,GAChD,SAAS,8BAA8B,KACrC,IA6gBF,CAAC"}
@@ -112,6 +112,7 @@ import { BOOTSTRAP_TOKEN_LENGTH_MAX } from '../../auth/bootstrap_route_schema.js
112
112
  import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
113
113
  import { test_if } from './capabilities.js';
114
114
  import { SPINE_ACCOUNT_BOOTSTRAP_PATH, SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_PASSWORD_PATH, SPINE_ACCOUNT_SIGNUP_PATH } from './spine_surface_constants.js';
115
+ import { SERDE_REFUSED_PARAMS_JSON } from '../rpc_envelope_cases.js';
115
116
  /**
116
117
  * The flat-REST `{error}` reason each terminal login/signup status carries on
117
118
  * every spine — the assertion target that turns a status-only check into a
@@ -594,10 +595,14 @@ export const describe_identity_parity_cross_tests = (options) => {
594
595
  // Bootstrap parses ahead of its window check (so the 400 holds after
595
596
  // bootstrap completed); the password change parses only after its
596
597
  // credential and session-only gates, so it needs a session, and an
597
- // anonymous caller still hears 401.
598
+ // anonymous caller still hears 401. A body `serde_json` refuses (a lone
599
+ // surrogate escape, a number out of `f64` range, nesting 128 deep) is
600
+ // invalid JSON on both.
598
601
  const MALFORMED_BODIES = [
599
602
  ['{', 'unparseable'],
600
- ['[]', 'a non-object array']
603
+ ['[]', 'a non-object array'],
604
+ // what the Rust spine's `serde_json` refuses and `JSON.parse` accepts
605
+ ...SERDE_REFUSED_PARAMS_JSON.map(([label, json]) => [json, label])
601
606
  ];
602
607
  const assert_invalid_json_body = (got, label) => {
603
608
  assert.strictEqual(got.status, 400, `${label} — status: ${got.text}`);
@@ -1 +1 @@
1
- {"version":3,"file":"ws_envelope.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_envelope.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8C9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AACzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAc1E,4DAA4D;AAC5D,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IACnE,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC3C;AAwED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,0BAA0B,KAAG,IAoFtF,CAAC"}
1
+ {"version":3,"file":"ws_envelope.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_envelope.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8C9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AACzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAe1E,4DAA4D;AAC5D,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IACnE,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC3C;AA+ED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,0BAA0B,KAAG,IAoFtF,CAAC"}
@@ -43,6 +43,7 @@ import { is_response_for } from '../transports/ws_client.js';
43
43
  import { test_if } from './capabilities.js';
44
44
  import { open_session_ws } from './ws_endpoint.js';
45
45
  import { create_holding_peer_ping_responder } from './ws_inbound_dispatch.js';
46
+ import { SERDE_REFUSED_PARAMS_JSON } from '../rpc_envelope_cases.js';
46
47
  const JSONRPC_VERSION = '2.0';
47
48
  const PARSE_ERROR = -32700;
48
49
  const INVALID_REQUEST = -32600;
@@ -72,6 +73,13 @@ const REFUSED_FRAME_CASES = [
72
73
  frame: { text: '{"jsonrpc": "2.0", "id": 1,' },
73
74
  code: PARSE_ERROR
74
75
  },
76
+ ...SERDE_REFUSED_PARAMS_JSON.map(([label, params_json]) => ({
77
+ name: `a frame holding ${label}`,
78
+ frame: {
79
+ text: `{"jsonrpc":"2.0","id":1,"method":"${HEARTBEAT_METHOD}","params":${params_json}}`
80
+ },
81
+ code: PARSE_ERROR
82
+ })),
75
83
  { name: 'a scalar frame', frame: { json: 5 }, code: INVALID_REQUEST },
76
84
  { name: 'a bare string frame', frame: { json: HEARTBEAT_METHOD }, code: INVALID_REQUEST },
77
85
  {
@@ -48,6 +48,13 @@ export interface RpcEnvelopeCaseOptions {
48
48
  * what a `GET` `?params=` can carry that no input schema admits.
49
49
  */
50
50
  export declare const RPC_NON_OBJECT_PARAMS: ReadonlyArray<string>;
51
+ /**
52
+ * JSON object texts holding what `serde_json` refuses and `JSON.parse`
53
+ * accepts — an escaped lone surrogate, a number out of `f64` range, nesting
54
+ * 128 deep — each with a label. Both spines refuse them as invalid JSON
55
+ * (`parse_json_text`, `@fuzdev/fuz_app/http/json_text.ts`).
56
+ */
57
+ export declare const SERDE_REFUSED_PARAMS_JSON: ReadonlyArray<readonly [label: string, json: string]>;
51
58
  /** The `data.reason` the dispatchers answer a `GET` of a `side_effects` method with. */
52
59
  export declare const rpc_get_side_effects_reason: (method: string) => string;
53
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"rpc_envelope_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_envelope_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAe7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK7E,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,MAAM,8BAA8B,CAAC;AAItC,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;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AS,EAChB,UAAU,oBAAoB,KAC5B,KAAK,CAAC,aAAa,CAGpB,CAAC"}
@@ -26,6 +26,21 @@ export const RPC_ENVELOPE_PROBE_ID = 'envelope_probe';
26
26
  * what a `GET` `?params=` can carry that no input schema admits.
27
27
  */
28
28
  export const RPC_NON_OBJECT_PARAMS = ['42', '[1]', '"x"', 'true'];
29
+ const BACKSLASH = String.fromCharCode(92);
30
+ /**
31
+ * JSON object texts holding what `serde_json` refuses and `JSON.parse`
32
+ * accepts — an escaped lone surrogate, a number out of `f64` range, nesting
33
+ * 128 deep — each with a label. Both spines refuse them as invalid JSON
34
+ * (`parse_json_text`, `@fuzdev/fuz_app/http/json_text.ts`).
35
+ */
36
+ export const SERDE_REFUSED_PARAMS_JSON = [
37
+ ['a lone surrogate escape', `{"x":"${BACKSLASH}ud800"}`],
38
+ ['a lone surrogate escape in a key', `{"${BACKSLASH}udc00":1}`],
39
+ ['a number out of f64 range', '{"x":1e400}'],
40
+ ['nesting 128 deep', `{"x":${'['.repeat(127)}${']'.repeat(127)}}`],
41
+ // `JSON.parse` keeps the last key, so only reading the text sees the first
42
+ ['a lone surrogate escape under a duplicated key', `{"x":"${BACKSLASH}ud800","x":1}`]
43
+ ];
29
44
  /** The `data.reason` the dispatchers answer a `GET` of a `side_effects` method with. */
30
45
  export const rpc_get_side_effects_reason = (method) => `method '${method}' has side effects and must use POST`;
31
46
  /**
@@ -77,6 +92,12 @@ export const create_rpc_envelope_cases = (endpoint, options = {}) => {
77
92
  id: null,
78
93
  reason: null
79
94
  });
95
+ // what `serde_json` refuses and `JSON.parse` accepts: refused as invalid
96
+ // JSON on both spines (`parse_json_text`), in `params` and in the GET query
97
+ for (const [label, params_json] of SERDE_REFUSED_PARAMS_JSON) {
98
+ post(`${label} in the body → parse_error`, `{"jsonrpc":"2.0","id":${JSON.stringify(id)},"method":${JSON.stringify(m)},"params":${params_json}}`, { status: 400, code: JSONRPC_ERROR_CODES.parse_error, id: null, reason: null });
99
+ get(`GET ${label} in params → invalid_params`, `?method=${q(m)}&id=${id}&params=${q(params_json)}`, { status: 400, code: JSONRPC_ERROR_CODES.invalid_params, id, reason: null });
100
+ }
80
101
  post('wrong jsonrpc version → invalid_request', JSON.stringify({ jsonrpc: '1.0', id, method: m }), { ...invalid_request, id, reason: null });
81
102
  post('missing jsonrpc field → invalid_request', JSON.stringify({ id, method: m }), {
82
103
  ...invalid_request,
@@ -1 +1 @@
1
- {"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;GAUG;AAEH,OAAO,EAEN,KAAK,SAAS,EAEd,KAAK,YAAY,EACjB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAkC,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AASjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAgBpF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,GAAG,IAWlF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,cAAc,SAAS,KAAG,MAAM,GAAG,IACH,CAAC;AA8H/D,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAChC,wCAAwC;IACxC,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC/B,+EAA+E;IAC/E,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;CACtD;AAuBD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,EAAE,OAAO,MAAM,KAAG,gBAQxE,CAAC;AA4EF;;;;;;GAMG;AACH,eAAO,MAAM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CAAC,KAC7C,MA+DF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC/B,cAAc,SAAS,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAW5B,CAAC"}
@@ -197,10 +197,10 @@ const schema_layers = (schema) => {
197
197
  return layers;
198
198
  };
199
199
  /**
200
- * The type name the generators switch on (`SchemaFieldInfo.base_type`): the
201
- * schema's innermost layer's kind, with an object schema of any strictness
202
- * `'object'`, a `literal(null)` `'null'`, a `literal(undefined)` (`s.void`)
203
- * `'void'`, a `one_of` `'enum'`, and a `variant` `'union'`.
200
+ * The kind the generators switch on (`SchemaFieldInfo.base_type`,
201
+ * `SchemaFieldBaseType`): the schema's innermost layer's kind, with an object
202
+ * schema of any strictness `'object'`, and a `literal(null)` and a
203
+ * `literal(undefined)` (`s.void`) `'null'` and `'void'`.
204
204
  */
205
205
  const to_base_type = (schema) => {
206
206
  const base = unwrap_schema(schema);
@@ -212,10 +212,6 @@ const to_base_type = (schema) => {
212
212
  return 'object';
213
213
  case 'literal':
214
214
  return base.def === null ? 'null' : base.def === undefined ? 'void' : 'literal';
215
- case 'one_of':
216
- return 'enum';
217
- case 'variant':
218
- return 'union';
219
215
  default:
220
216
  return base.kind;
221
217
  }
@@ -342,10 +338,6 @@ const to_literal_values = (field_schema) => {
342
338
  export const generate_valid_value = (field, field_schema) => {
343
339
  const format = detect_format(field_schema);
344
340
  switch (field.base_type) {
345
- case 'uuid':
346
- return '00000000-0000-0000-0000-000000000000';
347
- case 'email':
348
- return 'test@example.com';
349
341
  case 'string':
350
342
  if (format === 'uuid')
351
343
  return '00000000-0000-0000-0000-000000000000';
@@ -394,11 +386,11 @@ export const generate_valid_value = (field, field_schema) => {
394
386
  case 'null':
395
387
  return null;
396
388
  case 'void':
397
- case 'undefined':
398
389
  return undefined;
399
390
  case 'record':
400
391
  return {};
401
- case 'union': {
392
+ case 'union':
393
+ case 'variant': {
402
394
  // Pick the first variant and recurse. Picking the first option is a
403
395
  // pragmatic default; consumers needing a specific branch can pass
404
396
  // an override via the relevant test helper.
@@ -415,7 +407,7 @@ export const generate_valid_value = (field, field_schema) => {
415
407
  const values = to_literal_values(field_schema);
416
408
  return values.length > 0 ? values[0] : 'test_value';
417
409
  }
418
- case 'enum': {
410
+ case 'one_of': {
419
411
  const values = to_literal_values(field_schema);
420
412
  return values.length > 0 ? values[0] : 'test';
421
413
  }
@@ -593,7 +585,7 @@ const to_numeric_bounds = (schema) => {
593
585
  */
594
586
  export const generate_valid_string_param = (field, field_schema) => {
595
587
  const candidates = [];
596
- if (field.base_type === 'uuid' || detect_format(field_schema) === 'uuid') {
588
+ if (detect_format(field_schema) === 'uuid') {
597
589
  candidates.push(NIL_UUID);
598
590
  }
599
591
  candidates.push('test_value');
@@ -705,8 +697,6 @@ export const resolve_valid_path = (path, params_schema, param_values) => {
705
697
  return fallback;
706
698
  if (accepts(field_schema, `test_${name}`))
707
699
  return fallback;
708
- if (to_base_type(field_schema) === 'uuid')
709
- return NIL_UUID;
710
700
  const format = detect_format(field_schema);
711
701
  if (format === 'uuid')
712
702
  return NIL_UUID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.170.0",
3
+ "version": "0.171.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",