@fuzdev/fuz_app 0.169.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 (171) hide show
  1. package/dist/actions/CLAUDE.md +19 -21
  2. package/dist/actions/action_codegen.d.ts +27 -18
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +90 -90
  5. package/dist/actions/action_event.d.ts +0 -8
  6. package/dist/actions/action_event.d.ts.map +1 -1
  7. package/dist/actions/action_event.js +7 -6
  8. package/dist/actions/action_event_data.d.ts +4 -4
  9. package/dist/actions/action_rpc.d.ts +1 -1
  10. package/dist/actions/action_rpc.d.ts.map +1 -1
  11. package/dist/actions/action_rpc.js +6 -7
  12. package/dist/actions/action_spec.d.ts +8 -10
  13. package/dist/actions/action_spec.d.ts.map +1 -1
  14. package/dist/actions/action_spec.js +1 -1
  15. package/dist/actions/action_types.d.ts +4 -4
  16. package/dist/actions/action_types.d.ts.map +1 -1
  17. package/dist/actions/action_types.js +2 -2
  18. package/dist/actions/broadcast_api.d.ts +2 -2
  19. package/dist/actions/broadcast_api.js +4 -4
  20. package/dist/actions/compile_action_registry.d.ts +6 -7
  21. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  22. package/dist/actions/compile_action_registry.js +8 -9
  23. package/dist/actions/peer_ping.d.ts.map +1 -1
  24. package/dist/actions/peer_ping.js +3 -2
  25. package/dist/actions/perform_action.d.ts +6 -6
  26. package/dist/actions/perform_action.d.ts.map +1 -1
  27. package/dist/actions/perform_action.js +11 -10
  28. package/dist/actions/socket.svelte.d.ts +1 -1
  29. package/dist/actions/socket.svelte.js +2 -2
  30. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  31. package/dist/actions/ws_socket_session.js +2 -1
  32. package/dist/auth/CLAUDE.md +11 -11
  33. package/dist/auth/admin_action_specs.d.ts +24 -24
  34. package/dist/auth/audit_emitter.d.ts +6 -7
  35. package/dist/auth/audit_emitter.d.ts.map +1 -1
  36. package/dist/auth/audit_emitter.js +11 -22
  37. package/dist/auth/audit_log_ddl.d.ts +1 -1
  38. package/dist/auth/audit_log_ddl.js +1 -1
  39. package/dist/auth/audit_log_queries.d.ts +0 -13
  40. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  41. package/dist/auth/audit_log_queries.js +3 -3
  42. package/dist/auth/audit_log_schema.d.ts +14 -15
  43. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  44. package/dist/auth/audit_log_schema.js +1 -1
  45. package/dist/auth/auth_ddl.d.ts +1 -1
  46. package/dist/auth/auth_ddl.js +1 -1
  47. package/dist/auth/cell_action_specs.d.ts +54 -54
  48. package/dist/auth/cell_actions.d.ts +2 -2
  49. package/dist/auth/cell_actions.js +5 -5
  50. package/dist/auth/middleware.d.ts +6 -2
  51. package/dist/auth/middleware.d.ts.map +1 -1
  52. package/dist/auth/middleware.js +14 -2
  53. package/dist/auth/request_context.d.ts.map +1 -1
  54. package/dist/auth/request_context.js +7 -9
  55. package/dist/auth/role_grant_offer_action_specs.d.ts +6 -6
  56. package/dist/auth/role_grant_offer_ddl.d.ts +1 -1
  57. package/dist/auth/role_grant_offer_ddl.js +1 -1
  58. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  59. package/dist/auth/role_grant_offer_notifications.js +2 -3
  60. package/dist/auth/self_service_role_actions.d.ts +1 -1
  61. package/dist/auth/self_service_role_actions.js +1 -1
  62. package/dist/env/env_schemas.d.ts +1 -2
  63. package/dist/env/env_schemas.d.ts.map +1 -1
  64. package/dist/env/env_schemas.js +3 -4
  65. package/dist/http/CLAUDE.md +30 -31
  66. package/dist/http/auth_shape.d.ts +14 -32
  67. package/dist/http/auth_shape.d.ts.map +1 -1
  68. package/dist/http/auth_shape.js +14 -49
  69. package/dist/http/error_schemas.d.ts +18 -18
  70. package/dist/http/json_text.d.ts +53 -0
  71. package/dist/http/json_text.d.ts.map +1 -0
  72. package/dist/http/json_text.js +152 -0
  73. package/dist/http/jsonrpc_helpers.js +1 -1
  74. package/dist/http/route_error_check.d.ts +2 -2
  75. package/dist/http/route_error_check.d.ts.map +1 -1
  76. package/dist/http/route_error_check.js +2 -3
  77. package/dist/http/route_errors.d.ts +4 -4
  78. package/dist/http/route_errors.d.ts.map +1 -1
  79. package/dist/http/route_errors.js +0 -13
  80. package/dist/http/route_result.d.ts +2 -1
  81. package/dist/http/route_result.d.ts.map +1 -1
  82. package/dist/http/route_spec.d.ts +34 -37
  83. package/dist/http/route_spec.d.ts.map +1 -1
  84. package/dist/http/route_spec.js +31 -31
  85. package/dist/http/schema_helpers.d.ts +77 -68
  86. package/dist/http/schema_helpers.d.ts.map +1 -1
  87. package/dist/http/schema_helpers.js +54 -77
  88. package/dist/http/surface.d.ts.map +1 -1
  89. package/dist/http/surface.js +6 -8
  90. package/dist/primitive_schemas.d.ts +9 -17
  91. package/dist/primitive_schemas.d.ts.map +1 -1
  92. package/dist/primitive_schemas.js +9 -17
  93. package/dist/realtime/sse.d.ts +3 -3
  94. package/dist/realtime/sse.d.ts.map +1 -1
  95. package/dist/realtime/sse.js +2 -2
  96. package/dist/schema_issues.d.ts +39 -147
  97. package/dist/schema_issues.d.ts.map +1 -1
  98. package/dist/schema_issues.js +39 -352
  99. package/dist/schema_meta.d.ts +63 -136
  100. package/dist/schema_meta.d.ts.map +1 -1
  101. package/dist/schema_meta.js +37 -184
  102. package/dist/sensitivity.d.ts +3 -5
  103. package/dist/sensitivity.d.ts.map +1 -1
  104. package/dist/sensitivity.js +3 -5
  105. package/dist/testing/CLAUDE.md +20 -22
  106. package/dist/testing/adversarial_headers.js +2 -2
  107. package/dist/testing/adversarial_input_cases.d.ts +19 -18
  108. package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
  109. package/dist/testing/adversarial_input_cases.js +31 -46
  110. package/dist/testing/assertions.d.ts +2 -2
  111. package/dist/testing/assertions.d.ts.map +1 -1
  112. package/dist/testing/assertions.js +3 -3
  113. package/dist/testing/cross_backend/account_lifecycle.js +2 -2
  114. package/dist/testing/cross_backend/action_manifest.d.ts +10 -9
  115. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  116. package/dist/testing/cross_backend/action_manifest.js +4 -3
  117. package/dist/testing/cross_backend/cell_crud.js +1 -1
  118. package/dist/testing/cross_backend/conformance_rpc_auth.d.ts +0 -62
  119. package/dist/testing/cross_backend/conformance_rpc_auth.d.ts.map +1 -1
  120. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  121. package/dist/testing/cross_backend/conformance_table.js +3 -3
  122. package/dist/testing/cross_backend/cross_rpc.d.ts +3 -4
  123. package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
  124. package/dist/testing/cross_backend/cross_rpc.js +4 -4
  125. package/dist/testing/cross_backend/differential.js +2 -2
  126. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  127. package/dist/testing/cross_backend/identity_parity.js +16 -11
  128. package/dist/testing/cross_backend/origin_conformance.d.ts +9 -9
  129. package/dist/testing/cross_backend/query_shape.js +1 -1
  130. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  131. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  132. package/dist/testing/cross_backend/setup.d.ts +25 -3
  133. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/setup.js +4 -4
  135. package/dist/testing/cross_backend/sse_round_trip.js +2 -2
  136. package/dist/testing/cross_backend/testing_origin_check.d.ts +4 -4
  137. package/dist/testing/cross_backend/token_lifetime.js +3 -3
  138. package/dist/testing/cross_backend/wire_shapes.js +1 -1
  139. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -1
  140. package/dist/testing/cross_backend/ws_envelope.js +8 -0
  141. package/dist/testing/cross_backend/ws_round_trip.js +1 -1
  142. package/dist/testing/data_exposure.d.ts.map +1 -1
  143. package/dist/testing/data_exposure.js +1 -1
  144. package/dist/testing/integration.js +2 -2
  145. package/dist/testing/integration_helpers.d.ts.map +1 -1
  146. package/dist/testing/integration_helpers.js +2 -2
  147. package/dist/testing/middleware.d.ts.map +1 -1
  148. package/dist/testing/middleware.js +2 -2
  149. package/dist/testing/rpc_attack_surface.js +1 -1
  150. package/dist/testing/rpc_envelope_cases.d.ts +10 -3
  151. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  152. package/dist/testing/rpc_envelope_cases.js +22 -1
  153. package/dist/testing/rpc_helpers.d.ts +12 -14
  154. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  155. package/dist/testing/rpc_helpers.js +9 -10
  156. package/dist/testing/schema_generators.d.ts +67 -60
  157. package/dist/testing/schema_generators.d.ts.map +1 -1
  158. package/dist/testing/schema_generators.js +154 -159
  159. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  160. package/dist/testing/sse_round_trip.js +2 -2
  161. package/dist/testing/surface_invariants.d.ts +1 -1
  162. package/dist/testing/surface_invariants.js +1 -1
  163. package/dist/ui/form_state.svelte.d.ts +1 -1
  164. package/dist/ui/form_state.svelte.js +1 -1
  165. package/package.json +5 -7
  166. package/dist/zod.d.ts +0 -116
  167. package/dist/zod.d.ts.map +0 -1
  168. package/dist/zod.js +0 -218
  169. package/dist/zod_schemas.d.ts +0 -100
  170. package/dist/zod_schemas.d.ts.map +0 -1
  171. package/dist/zod_schemas.js +0 -157
@@ -33,28 +33,9 @@
33
33
  *
34
34
  * @module
35
35
  */
36
- import { is_schema, one_of, parse } from '@fuzdev/fuz_schema/schema.ts';
36
+ import { one_of, parse } from '@fuzdev/fuz_schema/schema.ts';
37
37
  import { get_schema_entries } from '@fuzdev/fuz_schema/introspect.ts';
38
38
  import { ActingActor } from '../primitive_schemas.js';
39
- import { zod_unwrap_to_object } from '../zod.js';
40
- /**
41
- * The Zod `ActingActor` forms `input_schema_declares_acting` matches by
42
- * reference: `ZodActingActor`, registered when `zod_schemas.ts` loads, so
43
- * this module never imports Zod at runtime. A Zod input holding it has loaded
44
- * that module, so it is registered before any spec reaches the check.
45
- */
46
- const zod_acting_actors = new WeakSet();
47
- /**
48
- * Register a Zod schema as the Zod form of `ActingActor`, which
49
- * `input_schema_declares_acting` then finds by reference. `zod_schemas.ts`
50
- * registers `ZodActingActor`, its one caller.
51
- *
52
- * @param schema - the Zod `ActingActor`
53
- * @internal
54
- */
55
- export const register_zod_acting_actor = (schema) => {
56
- zod_acting_actors.add(schema);
57
- };
58
39
  /**
59
40
  * Read an `acting` selector out of an unvalidated value.
60
41
  *
@@ -75,8 +56,8 @@ export const register_zod_acting_actor = (schema) => {
75
56
  * an input schema behind it, so there a malformed selector is final (the
76
57
  * status route answers account-only).
77
58
  *
78
- * The grammar is `ActingActor`'s, which is `ZodActingActor`'s and the Rust
79
- * spine's, so every value reads as either would, the max UUID in any case
59
+ * The grammar is `ActingActor`'s, which is the Rust spine's, so every value
60
+ * reads as either would, the max UUID in any case
80
61
  * included. The id comes back lowercased. A route declaring `acting` on its
81
62
  * `query` schema doesn't read it here: that schema runs ahead of the
82
63
  * authorization phase, with the same grammar.
@@ -221,32 +202,16 @@ export const assert_route_auth_invariants = (auth, context) => {
221
202
  // + `register_action_ws`).
222
203
  /**
223
204
  * Whether a schema declares the canonical `acting?: ActingActor` field.
224
- * Reference-equality on the exported `ActingActor` schema of the input's
225
- * library — `ActingActor` (`primitive_schemas.ts`) in a fuz_schema object,
226
- * `ZodActingActor` (`zod_schemas.ts`) in a Zod one — so consumer schemas with
227
- * unrelated `acting` fields don't trip this check, nor does either form in
228
- * the other library's object.
229
- *
230
- * Peels through Zod wrappers (`optional`, `nullable`, `default`,
231
- * `transform`, `pipe`, `prefault`) via `zod_unwrap_to_object` so a spec
232
- * authored as `z.optional(z.strictObject({acting: ActingActor}))` or
233
- * `z.strictObject({acting: ActingActor}).default({})` still trips the
234
- * predicate.
235
- *
236
- * A `@fuzdev/fuz_schema` schema is read by `get_schema_entries`, which sees
237
- * through its wrappers (`optional`, `nullable`, the defaults) and a `pipe` to
238
- * the schema it starts with; a schema that isn't an object under them (a void
239
- * input, say) answers `false`.
205
+ * Reference-equality on the exported `ActingActor` (`primitive_schemas.ts`),
206
+ * so consumer schemas with unrelated `acting` fields don't trip this check.
207
+ *
208
+ * The schema is read by `get_schema_entries`, which sees through its wrappers
209
+ * (`optional`, `nullable`, the defaults) and a `pipe` to the schema it starts
210
+ * with, so `optional(object({acting: ActingActor}))` still trips the
211
+ * predicate; a schema that isn't an object under them (a void input, say)
212
+ * answers `false`.
240
213
  */
241
- export const input_schema_declares_acting = (schema) => {
242
- if (is_schema(schema))
243
- return get_schema_entries(schema)?.acting === ActingActor;
244
- const obj = zod_unwrap_to_object(schema);
245
- if (!obj)
246
- return false;
247
- const acting = obj.shape.acting;
248
- return acting !== undefined && zod_acting_actors.has(acting);
249
- };
214
+ export const input_schema_declares_acting = (schema) => get_schema_entries(schema)?.acting === ActingActor;
250
215
  /**
251
216
  * Registry-time biconditional check: `auth.actor !== 'none' ⟺ some
252
217
  * supplied slot declares acting?: ActingActor`. Throws on violation.
@@ -274,7 +239,7 @@ export const assert_route_auth_acting_biconditional = (auth, slots, context) =>
274
239
  return;
275
240
  const slot_phrase = slots.query !== undefined ? 'input or query schema' : 'input schema';
276
241
  if (wants_actor) {
277
- throw new Error(`${context}: auth.actor === '${auth.actor}' requires the ${slot_phrase} to declare 'acting?: ActingActor' (or ZodActingActor in a Zod schema) (registry-time invariant 2)`);
242
+ throw new Error(`${context}: auth.actor === '${auth.actor}' requires the ${slot_phrase} to declare 'acting?: ActingActor' (registry-time invariant 2)`);
278
243
  }
279
- throw new Error(`${context}: ${slot_phrase} declares 'acting?: ActingActor' (or ZodActingActor) but auth.actor === 'none' (registry-time invariant 2)`);
244
+ throw new Error(`${context}: ${slot_phrase} declares 'acting?: ActingActor' but auth.actor === 'none' (registry-time invariant 2)`);
280
245
  };
@@ -280,40 +280,40 @@ export declare const to_error_schemas: (defs: Iterable<RestErrorDef>) => ErrorSc
280
280
  export declare const REST_INVALID_REQUEST_BODY: RestErrorDef<400, "invalid_request_body", {
281
281
  readonly issues: Schema<({
282
282
  kind: string;
283
- message: string;
284
283
  path: (string | number)[];
285
284
  expected: string;
286
285
  received: string;
286
+ message: string;
287
287
  } & Record<string, unknown>)[] | undefined, ({
288
288
  kind: string;
289
- message: string;
290
289
  path: (string | number)[];
291
290
  expected: string;
292
291
  received: string;
292
+ message: string;
293
293
  } & Record<string, unknown>)[] | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<Schema<({
294
294
  kind: string;
295
- message: string;
296
295
  path: (string | number)[];
297
296
  expected: string;
298
297
  received: string;
298
+ message: string;
299
299
  } & Record<string, unknown>)[], ({
300
300
  kind: string;
301
- message: string;
302
301
  path: (string | number)[];
303
302
  expected: string;
304
303
  received: string;
304
+ message: string;
305
305
  } & Record<string, unknown>)[], "array", Schema<{
306
306
  kind: string;
307
- message: string;
308
307
  path: (string | number)[];
309
308
  expected: string;
310
309
  received: string;
310
+ message: string;
311
311
  } & Record<string, unknown>, {
312
312
  kind: string;
313
- message: string;
314
313
  path: (string | number)[];
315
314
  expected: string;
316
315
  received: string;
316
+ message: string;
317
317
  } & Record<string, unknown>, "loose_object", {
318
318
  kind: Schema<string, string, "string", undefined>;
319
319
  path: Schema<(string | number)[], (string | number)[], "array", Schema<string | number, string | number, "union", readonly [Schema<string, string, "string", undefined>, Schema<number, number, "number", undefined>]>>;
@@ -326,40 +326,40 @@ export declare const REST_INVALID_JSON_BODY: RestErrorDef<400, "invalid_json_bod
326
326
  export declare const REST_INVALID_ROUTE_PARAMS: RestErrorDef<400, "invalid_route_params", {
327
327
  readonly issues: Schema<({
328
328
  kind: string;
329
- message: string;
330
329
  path: (string | number)[];
331
330
  expected: string;
332
331
  received: string;
332
+ message: string;
333
333
  } & Record<string, unknown>)[] | undefined, ({
334
334
  kind: string;
335
- message: string;
336
335
  path: (string | number)[];
337
336
  expected: string;
338
337
  received: string;
338
+ message: string;
339
339
  } & Record<string, unknown>)[] | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<Schema<({
340
340
  kind: string;
341
- message: string;
342
341
  path: (string | number)[];
343
342
  expected: string;
344
343
  received: string;
344
+ message: string;
345
345
  } & Record<string, unknown>)[], ({
346
346
  kind: string;
347
- message: string;
348
347
  path: (string | number)[];
349
348
  expected: string;
350
349
  received: string;
350
+ message: string;
351
351
  } & Record<string, unknown>)[], "array", Schema<{
352
352
  kind: string;
353
- message: string;
354
353
  path: (string | number)[];
355
354
  expected: string;
356
355
  received: string;
356
+ message: string;
357
357
  } & Record<string, unknown>, {
358
358
  kind: string;
359
- message: string;
360
359
  path: (string | number)[];
361
360
  expected: string;
362
361
  received: string;
362
+ message: string;
363
363
  } & Record<string, unknown>, "loose_object", {
364
364
  kind: Schema<string, string, "string", undefined>;
365
365
  path: Schema<(string | number)[], (string | number)[], "array", Schema<string | number, string | number, "union", readonly [Schema<string, string, "string", undefined>, Schema<number, number, "number", undefined>]>>;
@@ -371,40 +371,40 @@ export declare const REST_INVALID_ROUTE_PARAMS: RestErrorDef<400, "invalid_route
371
371
  export declare const REST_INVALID_QUERY_PARAMS: RestErrorDef<400, "invalid_query_params", {
372
372
  readonly issues: Schema<({
373
373
  kind: string;
374
- message: string;
375
374
  path: (string | number)[];
376
375
  expected: string;
377
376
  received: string;
377
+ message: string;
378
378
  } & Record<string, unknown>)[] | undefined, ({
379
379
  kind: string;
380
- message: string;
381
380
  path: (string | number)[];
382
381
  expected: string;
383
382
  received: string;
383
+ message: string;
384
384
  } & Record<string, unknown>)[] | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<Schema<({
385
385
  kind: string;
386
- message: string;
387
386
  path: (string | number)[];
388
387
  expected: string;
389
388
  received: string;
389
+ message: string;
390
390
  } & Record<string, unknown>)[], ({
391
391
  kind: string;
392
- message: string;
393
392
  path: (string | number)[];
394
393
  expected: string;
395
394
  received: string;
395
+ message: string;
396
396
  } & Record<string, unknown>)[], "array", Schema<{
397
397
  kind: string;
398
- message: string;
399
398
  path: (string | number)[];
400
399
  expected: string;
401
400
  received: string;
401
+ message: string;
402
402
  } & Record<string, unknown>, {
403
403
  kind: string;
404
- message: string;
405
404
  path: (string | number)[];
406
405
  expected: string;
407
406
  received: string;
407
+ message: string;
408
408
  } & Record<string, unknown>, "loose_object", {
409
409
  kind: Schema<string, string, "string", undefined>;
410
410
  path: Schema<(string | number)[], (string | number)[], "array", Schema<string | number, string | number, "union", readonly [Schema<string, string, "string", undefined>, Schema<number, number, "number", undefined>]>>;
@@ -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
+ };
@@ -183,7 +183,7 @@ export const classify_jsonrpc_message = (json) => {
183
183
  id,
184
184
  error: jsonrpc_error_messages.invalid_request(dev_only(() => {
185
185
  const parsed = parse(JsonrpcRequest, frame);
186
- return { issues: parsed.ok ? [] : to_wire_issues(parsed.issues, frame) };
186
+ return { issues: parsed.ok ? [] : to_wire_issues(parsed.issues) };
187
187
  }))
188
188
  };
189
189
  };
@@ -23,9 +23,9 @@
23
23
  *
24
24
  * @module
25
25
  */
26
+ import { type SchemaIssue } from '@fuzdev/fuz_schema/schema.ts';
26
27
  import { type RestErrorDef } from './error_schemas.js';
27
28
  import type { RouteErrorMap } from './route_errors.js';
28
- import { type AnyIssue } from '../schema_issues.js';
29
29
  /**
30
30
  * The errors any route can answer with and none declares: the catch layer's
31
31
  * 500 `internal_error` for a generic throw, and a failed pool checkout's 503
@@ -56,7 +56,7 @@ export type RouteErrorCheck = {
56
56
  } | {
57
57
  ok: false;
58
58
  kind: 'schema_mismatch';
59
- issues: Array<AnyIssue>;
59
+ issues: Array<SchemaIssue>;
60
60
  };
61
61
  /**
62
62
  * Check a JSON error body against its route's error map.
@@ -1 +1 @@
1
- {"version":3,"file":"route_error_check.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_error_check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,YAAY,CAG9D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,OAAwB,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,QAAQ,KAAG,OACsB,CAAC;AAE7E,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GACxB;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GACxC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;CAAE,CAAC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,i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;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACjE,CAAC,EAED,QAAQ,aAAa,CAAC,MAAM,CAAC,EAC7B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,KAC5B,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAKpB,CAAC;AAEL;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EACnC,QAAQ,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EACtC,QAAQ,MAAM,EACd,MAAM,MAAM,KACV,CAAC,GAAG,SAMN,CAAC"}
@@ -23,10 +23,9 @@
23
23
  *
24
24
  * @module
25
25
  */
26
- import { is } from '@fuzdev/fuz_schema/schema.ts';
26
+ import { is, parse } from '@fuzdev/fuz_schema/schema.ts';
27
27
  import { REST_INTERNAL_ERROR, REST_SERVICE_UNAVAILABLE } from './error_schemas.js';
28
28
  import { is_jsonrpc_error_response } from './jsonrpc_helpers.js';
29
- import { parse_any } from '../schema_issues.js';
30
29
  /**
31
30
  * The errors any route can answer with and none declares: the catch layer's
32
31
  * 500 `internal_error` for a generic throw, and a failed pool checkout's 503
@@ -71,7 +70,7 @@ export const check_route_error = (errors, status, body, jsonrpc) => {
71
70
  const schema = errors.schemas[status];
72
71
  if (!schema)
73
72
  return { ok: false, kind: 'undeclared_status' };
74
- const result = parse_any(schema, body);
73
+ const result = parse(schema, body);
75
74
  return result.ok ? { ok: true } : { ok: false, kind: 'schema_mismatch', issues: result.issues };
76
75
  };
77
76
  /**
@@ -11,12 +11,12 @@
11
11
  *
12
12
  * @module
13
13
  */
14
+ import type { AnySchema } from '@fuzdev/fuz_schema/schema.ts';
14
15
  import type { RouteAuth } from './auth_shape.js';
15
16
  import type { RouteMethod } from './route_spec.js';
16
17
  import { type ErrorSchemas, type RestErrorDef } from './error_schemas.js';
17
18
  import type { MiddlewareSpec } from './middleware_spec.js';
18
19
  import type { RateLimitKey } from '../rate_limiter.js';
19
- import type { ValidationSchema } from '../schema_issues.js';
20
20
  /**
21
21
  * A route's error map: every error definition the route can answer with, and
22
22
  * the status map they group into. Built by `resolve_route_error_map`, and read by
@@ -38,9 +38,9 @@ export interface RouteErrorMapSpec {
38
38
  readonly method: RouteMethod;
39
39
  readonly path: string;
40
40
  readonly auth: RouteAuth;
41
- readonly input: ValidationSchema;
42
- readonly params?: ValidationSchema;
43
- readonly query?: ValidationSchema;
41
+ readonly input: AnySchema;
42
+ readonly params?: AnySchema;
43
+ readonly query?: AnySchema;
44
44
  readonly rate_limit?: RateLimitKey;
45
45
  readonly errors?: ReadonlyArray<RestErrorDef>;
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"route_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC3C,gGAAgG;IAChG,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;CAC/B;AAED,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,MAAM,EAAE,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G,CAAC,MAAM,EAAE,aAAa,CAM3B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC/B,kBAAkB,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI,GAAG,SAAS,EACvE,MAAM,iBAAiB,KACrB,aAQF,CAAC"}
@@ -1,16 +1,3 @@
1
- /**
2
- * A route's error map: every error definition it can answer with — derived
3
- * from its slots (`derive_route_errors`), declared by each middleware layer
4
- * that runs on it, and its own `errors` — and the status map they group into.
5
- *
6
- * Built once per app (`resolve_app_route_error_maps`, carried as
7
- * `AppSurfaceSpec.route_error_maps`) and read by every reader of a route's
8
- * declared errors: the surface, the DEV error check, the test helpers, error
9
- * coverage, and the attack-surface suite. The maps are keyed `METHOD path`
10
- * (`format_route_key`).
11
- *
12
- * @module
13
- */
14
1
  import { dedupe_rest_errors, derive_route_errors, to_error_schemas } from './error_schemas.js';
15
2
  import { is_null_schema, middleware_spec_applies } from './schema_helpers.js';
16
3
  import { format_route_key } from './surface_query.js';
@@ -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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