@fuzdev/fuz_app 0.152.0 → 0.154.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 (177) hide show
  1. package/dist/actions/CLAUDE.md +14 -11
  2. package/dist/actions/action_rpc.js +3 -3
  3. package/dist/actions/action_types.d.ts +3 -3
  4. package/dist/actions/broadcast_api.d.ts +0 -6
  5. package/dist/actions/broadcast_api.d.ts.map +1 -1
  6. package/dist/actions/connection_closer.d.ts +14 -15
  7. package/dist/actions/connection_closer.d.ts.map +1 -1
  8. package/dist/actions/connection_closer.js +13 -13
  9. package/dist/actions/perform_action.d.ts +5 -1
  10. package/dist/actions/perform_action.d.ts.map +1 -1
  11. package/dist/actions/perform_action.js +57 -19
  12. package/dist/actions/register_action_ws.d.ts +6 -5
  13. package/dist/actions/register_action_ws.d.ts.map +1 -1
  14. package/dist/actions/register_action_ws.js +5 -6
  15. package/dist/auth/CLAUDE.md +44 -14
  16. package/dist/auth/account_actions.d.ts +2 -2
  17. package/dist/auth/account_actions.js +6 -6
  18. package/dist/auth/account_routes.js +9 -9
  19. package/dist/auth/admin_actions.d.ts +2 -1
  20. package/dist/auth/admin_actions.d.ts.map +1 -1
  21. package/dist/auth/admin_actions.js +21 -20
  22. package/dist/auth/audit_emitter.d.ts +111 -64
  23. package/dist/auth/audit_emitter.d.ts.map +1 -1
  24. package/dist/auth/audit_emitter.js +130 -55
  25. package/dist/auth/audit_log_queries.d.ts +9 -10
  26. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  27. package/dist/auth/audit_log_queries.js +13 -10
  28. package/dist/auth/audit_log_routes.js +2 -2
  29. package/dist/auth/audit_log_schema.d.ts +6 -1
  30. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  31. package/dist/auth/bootstrap_account.d.ts +4 -3
  32. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  33. package/dist/auth/bootstrap_account.js +4 -3
  34. package/dist/auth/bootstrap_routes.js +2 -2
  35. package/dist/auth/cell_action_helpers.d.ts +3 -2
  36. package/dist/auth/cell_action_helpers.d.ts.map +1 -1
  37. package/dist/auth/cell_action_helpers.js +9 -10
  38. package/dist/auth/cell_actions.js +6 -6
  39. package/dist/auth/cell_data_schema.d.ts +5 -0
  40. package/dist/auth/cell_data_schema.d.ts.map +1 -1
  41. package/dist/auth/cell_data_schema.js +5 -0
  42. package/dist/auth/cell_field_actions.js +2 -2
  43. package/dist/auth/cell_grant_actions.js +2 -2
  44. package/dist/auth/cell_item_actions.js +3 -3
  45. package/dist/auth/deps.d.ts +12 -10
  46. package/dist/auth/deps.d.ts.map +1 -1
  47. package/dist/auth/middleware.js +1 -1
  48. package/dist/auth/request_context.d.ts +5 -10
  49. package/dist/auth/request_context.d.ts.map +1 -1
  50. package/dist/auth/request_context.js +10 -9
  51. package/dist/auth/role_grant_offer_actions.d.ts +11 -8
  52. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  53. package/dist/auth/role_grant_offer_actions.js +57 -41
  54. package/dist/auth/self_service_role_actions.d.ts +6 -5
  55. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  56. package/dist/auth/self_service_role_actions.js +17 -6
  57. package/dist/auth/session_cookie.d.ts +4 -4
  58. package/dist/auth/session_cookie.d.ts.map +1 -1
  59. package/dist/auth/session_cookie.js +0 -1
  60. package/dist/auth/session_middleware.d.ts +8 -5
  61. package/dist/auth/session_middleware.d.ts.map +1 -1
  62. package/dist/auth/session_middleware.js +10 -7
  63. package/dist/auth/signup_routes.js +6 -6
  64. package/dist/auth/standard_rpc_actions.d.ts +3 -2
  65. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  66. package/dist/auth/standard_rpc_actions.js +3 -2
  67. package/dist/db/CLAUDE.md +10 -1
  68. package/dist/db/create_db.d.ts +18 -1
  69. package/dist/db/create_db.d.ts.map +1 -1
  70. package/dist/db/create_db.js +15 -4
  71. package/dist/db/db.d.ts +27 -0
  72. package/dist/db/db.d.ts.map +1 -1
  73. package/dist/db/db.js +26 -0
  74. package/dist/db/db_checkout_error.d.ts +36 -0
  75. package/dist/db/db_checkout_error.d.ts.map +1 -0
  76. package/dist/db/db_checkout_error.js +48 -0
  77. package/dist/db/db_pg.d.ts +83 -5
  78. package/dist/db/db_pg.d.ts.map +1 -1
  79. package/dist/db/db_pg.js +119 -9
  80. package/dist/db/pg_error.d.ts +4 -0
  81. package/dist/db/pg_error.d.ts.map +1 -1
  82. package/dist/db/pg_error.js +13 -3
  83. package/dist/dev/setup.d.ts +4 -2
  84. package/dist/dev/setup.d.ts.map +1 -1
  85. package/dist/dev/setup.js +12 -5
  86. package/dist/env/env_schemas.d.ts +41 -0
  87. package/dist/env/env_schemas.d.ts.map +1 -0
  88. package/dist/env/env_schemas.js +55 -0
  89. package/dist/env/load.d.ts +23 -15
  90. package/dist/env/load.d.ts.map +1 -1
  91. package/dist/env/load.js +38 -22
  92. package/dist/hono_context.d.ts +36 -6
  93. package/dist/hono_context.d.ts.map +1 -1
  94. package/dist/hono_context.js +29 -2
  95. package/dist/http/CLAUDE.md +11 -10
  96. package/dist/http/db_routes.d.ts +7 -12
  97. package/dist/http/db_routes.d.ts.map +1 -1
  98. package/dist/http/db_routes.js +32 -17
  99. package/dist/http/error_schemas.d.ts +12 -0
  100. package/dist/http/error_schemas.d.ts.map +1 -1
  101. package/dist/http/error_schemas.js +12 -0
  102. package/dist/http/jsonrpc_errors.d.ts +10 -0
  103. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  104. package/dist/http/jsonrpc_errors.js +14 -0
  105. package/dist/http/jsonrpc_helpers.d.ts +4 -0
  106. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  107. package/dist/http/jsonrpc_helpers.js +8 -1
  108. package/dist/http/route_spec.d.ts +4 -4
  109. package/dist/http/route_spec.d.ts.map +1 -1
  110. package/dist/http/route_spec.js +20 -3
  111. package/dist/http/schema_helpers.d.ts +21 -0
  112. package/dist/http/schema_helpers.d.ts.map +1 -1
  113. package/dist/http/schema_helpers.js +38 -0
  114. package/dist/http/surface.d.ts +13 -9
  115. package/dist/http/surface.d.ts.map +1 -1
  116. package/dist/http/surface.js +22 -18
  117. package/dist/realtime/audit_log_sse.d.ts +2 -2
  118. package/dist/realtime/audit_log_sse.js +2 -2
  119. package/dist/schema_meta.d.ts +4 -2
  120. package/dist/schema_meta.d.ts.map +1 -1
  121. package/dist/schema_meta.js +4 -2
  122. package/dist/sensitivity.d.ts +34 -1
  123. package/dist/sensitivity.d.ts.map +1 -1
  124. package/dist/sensitivity.js +32 -2
  125. package/dist/server/app_backend.d.ts +25 -1
  126. package/dist/server/app_backend.d.ts.map +1 -1
  127. package/dist/server/app_backend.js +16 -3
  128. package/dist/server/app_error_handler.d.ts +30 -0
  129. package/dist/server/app_error_handler.d.ts.map +1 -0
  130. package/dist/server/app_error_handler.js +41 -0
  131. package/dist/server/app_server.d.ts +7 -6
  132. package/dist/server/app_server.d.ts.map +1 -1
  133. package/dist/server/app_server.js +6 -2
  134. package/dist/server/env.d.ts +55 -28
  135. package/dist/server/env.d.ts.map +1 -1
  136. package/dist/server/env.js +46 -29
  137. package/dist/testing/CLAUDE.md +23 -17
  138. package/dist/testing/app_server.js +2 -2
  139. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  140. package/dist/testing/audit_drift_guard.js +2 -0
  141. package/dist/testing/auth_apps.d.ts.map +1 -1
  142. package/dist/testing/auth_apps.js +2 -2
  143. package/dist/testing/cross_backend/conformance_case.d.ts +2 -0
  144. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  145. package/dist/testing/cross_backend/conformance_case.js +8 -0
  146. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  147. package/dist/testing/cross_backend/conformance_table.js +24 -7
  148. package/dist/testing/cross_backend/default_backend_configs.d.ts +4 -0
  149. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  150. package/dist/testing/cross_backend/default_backend_configs.js +7 -0
  151. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +11 -0
  152. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  153. package/dist/testing/cross_backend/testing_server_core.d.ts +1 -1
  154. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +15 -11
  155. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  156. package/dist/testing/cross_backend/ts_spine_backend_config.js +3 -12
  157. package/dist/testing/daemon_token_rotation.d.ts +4 -14
  158. package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
  159. package/dist/testing/daemon_token_rotation.js +0 -12
  160. package/dist/testing/db.d.ts.map +1 -1
  161. package/dist/testing/db.js +7 -3
  162. package/dist/testing/middleware.d.ts.map +1 -1
  163. package/dist/testing/middleware.js +2 -2
  164. package/dist/testing/rpc_helpers.d.ts +19 -0
  165. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  166. package/dist/testing/rpc_helpers.js +25 -2
  167. package/dist/testing/schema_parity.d.ts +1 -1
  168. package/dist/testing/stubs.d.ts +2 -2
  169. package/dist/testing/stubs.d.ts.map +1 -1
  170. package/dist/testing/stubs.js +2 -2
  171. package/dist/testing/surface_invariants.js +1 -1
  172. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  173. package/dist/testing/ws_round_trip.js +3 -3
  174. package/dist/zod.d.ts +9 -0
  175. package/dist/zod.d.ts.map +1 -1
  176. package/dist/zod.js +1 -1
  177. package/package.json +6 -10
package/dist/env/load.js CHANGED
@@ -1,43 +1,45 @@
1
1
  /**
2
- * Generic environment loading from Zod schemas.
2
+ * Generic environment loading from `@fuzdev/fuz_schema` object schemas.
3
3
  *
4
- * Provides `load_env` which iterates Zod schema keys, gets env values, and validates.
5
- * Apps handle error messages themselves (they're always app-specific).
4
+ * Provides `load_env`, which reads each key of an object schema with a
5
+ * getter and validates the values. Apps handle error messages themselves
6
+ * (they're always app-specific).
6
7
  *
7
8
  * @module
8
9
  */
9
- import { z } from 'zod';
10
+ import { get_schema_entries } from '@fuzdev/fuz_schema/introspect.ts';
11
+ import { format_issue, parse } from '@fuzdev/fuz_schema/schema.ts';
10
12
  /**
11
13
  * Error thrown when environment validation fails.
12
14
  *
13
15
  * Contains structured information for apps to format their own error messages.
14
16
  */
15
17
  export class EnvValidationError extends Error {
16
- /** The raw env values that were read. */
18
+ /** The raw env values that were read, every key of the schema, unset ones as `undefined`. */
17
19
  raw;
18
- /** The Zod validation error. */
19
- zod_error;
20
+ /** The validation issues, which hold no env value, only the keys in their paths. */
21
+ issues;
20
22
  /** True if every env var was undefined (nothing loaded). */
21
23
  all_undefined;
22
- constructor(raw, zod_error) {
24
+ constructor(raw, issues) {
23
25
  super('Environment validation failed');
24
26
  this.raw = raw;
25
- this.zod_error = zod_error;
27
+ this.issues = issues;
26
28
  this.all_undefined = Object.values(raw).every((v) => v === undefined);
27
29
  }
28
30
  /**
29
- * Format Zod validation issues as human-readable strings.
31
+ * Format the validation issues as human-readable strings.
30
32
  *
31
- * @returns array of formatted issue strings like `"PORT: Expected number"`
33
+ * @returns array of formatted issue strings like `"PORT: expected decimal digits, received string"`
32
34
  */
33
35
  format_issues() {
34
- return this.zod_error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
36
+ return this.issues.map(format_issue);
35
37
  }
36
38
  }
37
39
  /**
38
40
  * Log formatted env validation issues to stderr.
39
41
  *
40
- * Handles the common case: labels each Zod issue with an optional prefix.
42
+ * Handles the common case: labels each issue with an optional prefix.
41
43
  * Callers who want app-specific "getting started" instructions should check
42
44
  * `error.all_undefined` before calling this.
43
45
  *
@@ -57,21 +59,35 @@ export const log_env_validation_error = (error, label) => {
57
59
  }
58
60
  };
59
61
  /**
60
- * Load and validate env vars against a Zod schema.
62
+ * Load and validate env vars against a `@fuzdev/fuz_schema` object schema.
61
63
  *
62
- * @param schema - Zod object schema defining expected env vars
64
+ * Reads every key of the schema's entries with `get_env`. An unset var is
65
+ * left out of the object parsed, not given as `undefined`, so it reads as a
66
+ * missing key: a `pipe` that starts with an `optional` runs none of its
67
+ * steps for it, as it would for an absent key of any object. `raw` still
68
+ * lists it, as `undefined`.
69
+ *
70
+ * @param schema - an object schema (`object`, `strip_object`, ..., under any wrappers) of the expected env vars
63
71
  * @param get_env - function to read an env var by key
64
72
  * @returns validated env object
65
- * @throws EnvValidationError if Zod validation fails
73
+ * @throws TypeError if `schema` is not an object schema
74
+ * @throws EnvValidationError if validation fails
66
75
  */
67
76
  export const load_env = (schema, get_env) => {
77
+ const entries = get_schema_entries(schema);
78
+ if (!entries)
79
+ throw new TypeError(`load_env requires an object schema, got '${schema.kind}'`);
68
80
  const raw = {};
69
- for (const key of Object.keys(schema.shape)) {
70
- raw[key] = get_env(key);
81
+ const present = {};
82
+ for (const key in entries) {
83
+ const value = get_env(key);
84
+ raw[key] = value;
85
+ if (value !== undefined)
86
+ present[key] = value;
71
87
  }
72
- const result = schema.safeParse(raw);
73
- if (!result.success) {
74
- throw new EnvValidationError(raw, result.error);
88
+ const result = parse(schema, present);
89
+ if (!result.ok) {
90
+ throw new EnvValidationError(raw, result.issues);
75
91
  }
76
- return result.data;
92
+ return result.value;
77
93
  };
@@ -10,6 +10,7 @@
10
10
  *
11
11
  * @module
12
12
  */
13
+ import type { Context } from 'hono';
13
14
  import type { RequestContext } from './auth/request_context.js';
14
15
  import type { ResolvedAuth } from './auth/resolved_auth.js';
15
16
  /**
@@ -22,6 +23,16 @@ import type { ResolvedAuth } from './auth/resolved_auth.js';
22
23
  * (read as `null`) for an unauthenticated request.
23
24
  */
24
25
  export declare const RESOLVED_AUTH_KEY = "resolved_auth";
26
+ /**
27
+ * Hono context variable name for the session token — set by the session
28
+ * middleware (`create_session_middleware`) to the token a verified, unexpired
29
+ * session cookie carries, `null` otherwise, and read by the session leg of the
30
+ * auth middleware (`create_request_context_middleware`), which hashes it to
31
+ * find the `auth_session` row. Fixed rather than configurable: the session
32
+ * middleware and the session leg must agree on it, and no other spine key may
33
+ * share it.
34
+ */
35
+ export declare const SESSION_TOKEN_KEY = "auth_session_id";
25
36
  /**
26
37
  * Hono context variable name for the session cookie's signed expiry, in
27
38
  * seconds since the Unix epoch — set by the session middleware on a cookie
@@ -34,19 +45,37 @@ export declare const SESSION_COOKIE_EXPIRES_AT_KEY = "auth_session_cookie_expire
34
45
  *
35
46
  * Test harnesses (`create_test_app_from_specs`, `create_fake_hono_context`,
36
47
  * the WS round-trip `connect()` helper, plus per-test middleware that
37
- * pre-populates `REQUEST_CONTEXT_KEY`) set this to `true` so
48
+ * pre-populates `REQUEST_CONTEXT_KEY`) set it to `TEST_CONTEXT_PRESET` so
38
49
  * `apply_authorization_phase` skips its DB-backed actor resolution and
39
50
  * trusts the supplied `RequestContext`. Production middleware never sets
40
51
  * this key — only test code does. The flag is the explicit escape hatch
41
52
  * that replaced the implicit "is `REQUEST_CONTEXT_KEY` already set?" probe,
42
53
  * so that future production code consulting `REQUEST_CONTEXT_KEY` cannot
43
- * silently bypass the live build.
54
+ * silently bypass the live build. Read it with `has_test_context_preset`.
44
55
  */
45
56
  export declare const TEST_CONTEXT_PRESET_KEY = "test_context_preset";
57
+ /**
58
+ * The one value that sets the test-harness preset (`TEST_CONTEXT_PRESET_KEY`).
59
+ * A symbol, so only code that imports it can set the flag: a string, a
60
+ * `true`, or any other value a misconfiguration or a request could put under
61
+ * the key reads as unset. Testing only — no module outside `testing/` writes
62
+ * it.
63
+ */
64
+ export declare const TEST_CONTEXT_PRESET: unique symbol;
65
+ /**
66
+ * Whether a test harness pre-baked this request's context — the key holds
67
+ * `TEST_CONTEXT_PRESET` itself. The skip every transport makes of the live
68
+ * authorization phase and the admission re-reads.
69
+ *
70
+ * @param c - the Hono context
71
+ * @returns `true` only when the key holds the `TEST_CONTEXT_PRESET` symbol
72
+ */
73
+ export declare const has_test_context_preset: (c: Context) => boolean;
46
74
  declare module 'hono' {
47
75
  interface ContextVariableMap {
48
76
  /** Resolved client IP, set by the trusted proxy middleware. */
49
77
  client_ip: string;
78
+ /** The session token (`SESSION_TOKEN_KEY`), set by the session middleware. */
50
79
  auth_session_id: string | null;
51
80
  request_context: RequestContext | null;
52
81
  validated_input: unknown;
@@ -84,11 +113,12 @@ declare module 'hono' {
84
113
  */
85
114
  post_commit_effects: Array<() => void | Promise<void>>;
86
115
  /**
87
- * Set to `true` by test harnesses that pre-populate `request_context`
88
- * to bypass the dispatcher's DB-backed actor resolution. Read by
89
- * `apply_authorization_phase`. Production middleware never sets this.
116
+ * Set to `TEST_CONTEXT_PRESET` by test harnesses that pre-populate
117
+ * `request_context` to bypass the dispatcher's DB-backed actor
118
+ * resolution. Read with `has_test_context_preset`. Production
119
+ * middleware never sets this.
90
120
  */
91
- test_context_preset: boolean;
121
+ test_context_preset: typeof TEST_CONTEXT_PRESET;
92
122
  }
93
123
  }
94
124
  //# sourceMappingURL=hono_context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D,OAAO,QAAQ,MAAM,CAAC;IACrB,UAAU,kBAAkB;QAC3B,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,aAAa,EAAE,YAAY,GAAG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;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,aAAa,EAAE,YAAY,GAAG,IAAI,CAAC;QACnC,2FAA2F;QAC3F,8BAA8B,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9C;;;;;;;WAOG;QACH,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC;;;;;;;;;;;;WAYG;QACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD;;;;;WAKG;QACH,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;KAChD;CACD"}
@@ -20,6 +20,16 @@
20
20
  * (read as `null`) for an unauthenticated request.
21
21
  */
22
22
  export const RESOLVED_AUTH_KEY = 'resolved_auth';
23
+ /**
24
+ * Hono context variable name for the session token — set by the session
25
+ * middleware (`create_session_middleware`) to the token a verified, unexpired
26
+ * session cookie carries, `null` otherwise, and read by the session leg of the
27
+ * auth middleware (`create_request_context_middleware`), which hashes it to
28
+ * find the `auth_session` row. Fixed rather than configurable: the session
29
+ * middleware and the session leg must agree on it, and no other spine key may
30
+ * share it.
31
+ */
32
+ export const SESSION_TOKEN_KEY = 'auth_session_id';
23
33
  /**
24
34
  * Hono context variable name for the session cookie's signed expiry, in
25
35
  * seconds since the Unix epoch — set by the session middleware on a cookie
@@ -32,12 +42,29 @@ export const SESSION_COOKIE_EXPIRES_AT_KEY = 'auth_session_cookie_expires_at';
32
42
  *
33
43
  * Test harnesses (`create_test_app_from_specs`, `create_fake_hono_context`,
34
44
  * the WS round-trip `connect()` helper, plus per-test middleware that
35
- * pre-populates `REQUEST_CONTEXT_KEY`) set this to `true` so
45
+ * pre-populates `REQUEST_CONTEXT_KEY`) set it to `TEST_CONTEXT_PRESET` so
36
46
  * `apply_authorization_phase` skips its DB-backed actor resolution and
37
47
  * trusts the supplied `RequestContext`. Production middleware never sets
38
48
  * this key — only test code does. The flag is the explicit escape hatch
39
49
  * that replaced the implicit "is `REQUEST_CONTEXT_KEY` already set?" probe,
40
50
  * so that future production code consulting `REQUEST_CONTEXT_KEY` cannot
41
- * silently bypass the live build.
51
+ * silently bypass the live build. Read it with `has_test_context_preset`.
42
52
  */
43
53
  export const TEST_CONTEXT_PRESET_KEY = 'test_context_preset';
54
+ /**
55
+ * The one value that sets the test-harness preset (`TEST_CONTEXT_PRESET_KEY`).
56
+ * A symbol, so only code that imports it can set the flag: a string, a
57
+ * `true`, or any other value a misconfiguration or a request could put under
58
+ * the key reads as unset. Testing only — no module outside `testing/` writes
59
+ * it.
60
+ */
61
+ export const TEST_CONTEXT_PRESET = Symbol('test_context_preset');
62
+ /**
63
+ * Whether a test harness pre-baked this request's context — the key holds
64
+ * `TEST_CONTEXT_PRESET` itself. The skip every transport makes of the live
65
+ * authorization phase and the admission re-reads.
66
+ *
67
+ * @param c - the Hono context
68
+ * @returns `true` only when the key holds the `TEST_CONTEXT_PRESET` symbol
69
+ */
70
+ export const has_test_context_preset = (c) => c.get(TEST_CONTEXT_PRESET_KEY) === TEST_CONTEXT_PRESET;
@@ -17,7 +17,7 @@ effects, see ../../../docs/architecture.md.
17
17
  - `http/route_spec.ts` — `RouteSpec` + `apply_route_specs`, validation pipeline, transactions.
18
18
  - `http/auth_shape.ts` — canonical `RouteAuth` Zod schema + cross-axis invariants + predicates.
19
19
  - `http/error_schemas.ts` — `ERROR_*` constants, standard error shapes, `derive_error_schemas`.
20
- - `http/schema_helpers.ts` — shared Zod introspection (null/void/strict/surface/merge/middleware-applies) + `to_void_params` / `to_input_params` / `safe_parse_dropping_unknown_keys`.
20
+ - `http/schema_helpers.ts` — shared Zod introspection (null/void/strict/surface/merge/middleware-applies) + `to_void_params` / `to_input_params` / `json_has_own_proto_key` / `safe_parse_dropping_unknown_keys`.
21
21
  - `http/middleware_spec.ts` — `MiddlewareSpec` interface.
22
22
  - `http/body_limit.ts` — `create_body_limit_middleware(max_size)`: the `413` body cap `create_app_server` mounts. 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. Mounted with `app.use`, not as a `MiddlewareSpec`, so neither status appears in a route's merged error schemas. 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).
23
23
  - `http/surface.ts` — `AppSurface`, `AppSurfaceSpec`, `generate_app_surface`, diagnostics.
@@ -78,11 +78,11 @@ interface RouteContext {
78
78
  - **`route.pending_effects`** — direct push for eager fire-and-forget pool writes (audit, api-token usage tracking).
79
79
  - **`route.post_commit_effects`** — do not push directly; reach for `emit_after_commit` from `http/pending_effects.ts`. The helper pushes a thunk that the flush middleware invokes after the handler returns, closing the microtask-ordering window that an eager `Promise.resolve().then(fn)` leaves open inside the wrapping `db.transaction`.
80
80
 
81
- Pool-level fire-and-forget writes (audit logs, etc.) run through the bound
82
- `AppDeps.audit` capability — see `auth/CLAUDE.md` §AppDeps split. Handlers
83
- that need rollback-resilient writes call `deps.audit.emit(route, input)`,
84
- which captures the pool inside the bound emitter so the row lands even
85
- when the handler's transaction rolls back.
81
+ Audit rows run through the bound `AppDeps.audit` capability — see
82
+ `auth/CLAUDE.md` §Audit emitter. `await deps.audit.emit(route, input)` writes
83
+ a success row in the route's transaction when one is open and a failure row
84
+ via the pool captured inside the bound emitter, so a refused attempt's row
85
+ lands even when the handler's transaction rolls back.
86
86
 
87
87
  ### Declarative transactions
88
88
 
@@ -211,7 +211,7 @@ confirmation.
211
211
 
212
212
  ### `ERROR_*` constants by category
213
213
 
214
- - **Validation**: `ERROR_INVALID_REQUEST_BODY`, `ERROR_INVALID_JSON_BODY`, `ERROR_INVALID_ROUTE_PARAMS`, `ERROR_INVALID_QUERY_PARAMS`
214
+ - **Validation**: `ERROR_INVALID_REQUEST_BODY`, `ERROR_INVALID_JSON_BODY`, `ERROR_INVALID_ROUTE_PARAMS`, `ERROR_INVALID_QUERY_PARAMS`, `ERROR_PARAMS_PROTO_KEY` (RPC params)
215
215
  - **Auth**: `ERROR_AUTHENTICATION_REQUIRED`, `ERROR_INSUFFICIENT_PERMISSIONS`, `ERROR_CREDENTIAL_TYPE_REQUIRED`, `ERROR_RATE_LIMIT_EXCEEDED`, `ERROR_INVALID_CREDENTIALS`, `ERROR_PAYLOAD_TOO_LARGE`, `ERROR_INVALID_CONTENT_LENGTH`
216
216
  - **Origin + bearer**: `ERROR_FORBIDDEN_ORIGIN`, `ERROR_INVALID_TOKEN`, `ERROR_ACCOUNT_NOT_FOUND`
217
217
  - **Keeper/daemon**: `ERROR_KEEPER_ACCOUNT_NOT_FOUND`
@@ -237,6 +237,7 @@ Key helpers:
237
237
  - `is_void_schema(schema)` — `instanceof z.ZodVoid`; a `z.void()` input declares a parameterless RPC method
238
238
  - `to_void_params(raw_params)` — reads absent, `null`, and `{}` params of a `z.void()` input as the no-arg call (`undefined`), passing any other shape through for `z.void()` to refuse — the twin of the Rust spine's `require_void_params`
239
239
  - `to_input_params(input, raw_params)` — the one params normalizer every receiving end runs before `input.safeParse`: `to_void_params` for a `z.void()` input, else absent/`null` → `{}`; used by both the server dispatch core (`perform_action`) and the peer receive path (`ActionDispatcher`)
240
+ - `json_has_own_proto_key(value)` — whether any object in a parsed JSON value has an own `__proto__` key, by an iterative walk (no recursion — `JSON.parse` nests deeper than the call stack); the dispatcher refuses such params with `ERROR_PARAMS_PROTO_KEY`. Twin of the Rust `fuz_http::json_has_own_proto_key`
240
241
  - `safe_parse_dropping_unknown_keys(schema, value)` — the forward-compatible read of a remote-authored payload: when every issue is an unrecognized key, strips those keys from a copy and reparses; 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
241
242
  - `is_strict_object_schema(schema)` — detects `z.strictObject()` by checking `schema.def.catchall instanceof z.ZodNever`
242
243
  - `schema_to_surface(schema)` — Zod → JSON Schema, with `$schema` and `default` keys stripped recursively (defaults may be non-deterministic; `$schema` is snapshot noise)
@@ -459,7 +460,7 @@ which holds a declaration to the same rules.
459
460
  - Builders in `http/jsonrpc_helpers.ts`: `create_jsonrpc_request`, `create_jsonrpc_notification`, `create_jsonrpc_response`, `create_jsonrpc_error_response`, `create_jsonrpc_error_response_from_thrown` (preserves code/message/data on a thrown JSON-RPC error, via `to_thrown_jsonrpc_error`; plain `Error` → `internal_error` with `{stack}` in DEV)
460
461
  - Type guards: `is_jsonrpc_request_id` (rejects NaN/Infinity), `is_jsonrpc_object`, `is_jsonrpc_request` / `_notification` / `_response` / `_error_response`
461
462
  - Converters: `to_jsonrpc_message_id`, `to_jsonrpc_params` (normalizes primitives to `{value}`)
462
- - Classifier: `classify_jsonrpc_message(json)` → `ClassifiedJsonrpcMessage` (`request` / `notification` / `response` / `invalid`, the last carrying the error and the id to answer it on), twin of the Rust `fuz_http::classify` in order and answers. The WS frame handler and the HTTP POST handler switch on it, each keeping its transport's arms: WS refuses batches before it, routes `cancel` and peer responses, and checks duplicate ids and the in-flight ceiling after; POST answers a notification or a response `invalid_request` on `id: null`. Only a refused request envelope carries data — the schema's issues, DEV-only.
463
+ - Classifier: `classify_jsonrpc_message(json)` → `ClassifiedJsonrpcMessage` (`request` / `notification` / `response` / `invalid`, the last carrying the error and the id to answer it on), twin of the Rust `fuz_http::classify` in order and answers. The WS frame handler and the HTTP POST handler switch on it, each keeping its transport's arms: WS refuses batches before it, routes `cancel` and peer responses, and checks duplicate ids and the in-flight ceiling after; POST answers a notification or a response `invalid_request` on `id: null`. Only a refused request envelope carries data — the schema's issues, DEV-only. A `request` carries the frame as parsed, validated but not rebuilt, so an own `__proto__` key in `params` reaches the dispatcher, which refuses it (`ERROR_PARAMS_PROTO_KEY`) as on GET and the Rust spine (a Zod-rebuilt copy drops it).
463
464
 
464
465
  Handlers can `throw jsonrpc_errors.*` — `apply_route_specs`' error-catch
465
466
  layer converts to the flat REST body (`{error: <reason>, message?, ...rest_data}`)
@@ -608,8 +609,8 @@ instead of discovering the refusal — `ui/table_state.svelte.ts` gates on
608
609
  exclusion must not masquerade as one.
609
610
 
610
611
  **Every successful row delete is audited.** The `DELETE` handler defers a
611
- `deps.audit` emit through `emit_after_commit`, so the pool-routed row lands
612
- iff the delete's transaction commits — the success-only trail can't claim a
612
+ `deps.audit.emit_pool` call through `emit_after_commit`, so the pool-routed
613
+ row lands iff the delete's transaction commits — the success-only trail can't claim a
613
614
  delete that failed at COMMIT (the Rust twin commits before emitting for the
614
615
  same reason). Account-grain attribution (the browser's gate is account-grain,
615
616
  so no actor is claimed), metadata `{table, pk_column, id}`. Refusals emit
@@ -99,19 +99,14 @@ export declare const NON_DELETABLE_TABLES: ReadonlyArray<string>;
99
99
  */
100
100
  export interface DbRouteDeps {
101
101
  /**
102
- * Pool-routed fire-and-forget audit emit. The row-`DELETE` handler defers
103
- * the call via `emit_after_commit`, so the success-only trail row can
104
- * never claim a delete whose transaction failed at COMMIT — the pool
105
- * routing means the write itself never rides the request transaction.
106
- * The context carries both of the request's side-effect queues: the write
107
- * goes on `pending_effects`, the row's listener fan-out on
108
- * `post_commit_effects`.
102
+ * Awaitable pool audit write. The row-`DELETE` handler calls it from an
103
+ * `emit_after_commit` thunk, so the success-only trail row can never
104
+ * claim a delete whose transaction failed at COMMIT, and the row is
105
+ * written on the pool because the request transaction has ended by then.
106
+ * The flush awaits the returned promise.
109
107
  */
110
108
  audit: {
111
- emit: (ctx: {
112
- pending_effects: Array<Promise<void>>;
113
- post_commit_effects: Array<() => void | Promise<void>>;
114
- }, input: {
109
+ emit_pool: (input: {
115
110
  event_type: 'db_admin_row_delete';
116
111
  account_id: Uuid | null;
117
112
  ip: string;
@@ -120,7 +115,7 @@ export interface DbRouteDeps {
120
115
  pk_column: string;
121
116
  id: string;
122
117
  };
123
- }) => void;
118
+ }) => Promise<void>;
124
119
  };
125
120
  }
126
121
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"db_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAqC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiBpF;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAKrD,CA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MAAM,CAAC;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAC;SAC3D,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AA2CD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,WAAW,EACjB,SAAS,cAAc,KACrB,KAAK,CAAC,SAAS,CA4YjB,CAAC"}
@@ -375,6 +375,15 @@ export const create_db_route_specs = (deps, options) => {
375
375
  return c.json({ error: ERROR_TABLE_NO_PRIMARY_KEY }, 400);
376
376
  }
377
377
  const pk_column = pk_columns[0];
378
+ // The refusals below answer from a failed DELETE, which on PostgreSQL
379
+ // aborts the route's transaction — its COMMIT would come back as a
380
+ // ROLLBACK, which the pg driver throws on (`db/db_pg.ts`). A savepoint
381
+ // keeps the refusal's failure out of the transaction. Guarded because
382
+ // a consumer may run the route with `transaction: false`, and
383
+ // `SAVEPOINT` outside a transaction block is an error.
384
+ const savepoint = route.db.in_transaction;
385
+ if (savepoint)
386
+ await route.db.query('SAVEPOINT db_admin_row_delete');
378
387
  try {
379
388
  // Typed PK compare, twinning the Rust spine: `$1` travels as an
380
389
  // untyped text-format parameter, so PG infers the PK column's
@@ -397,19 +406,19 @@ export const create_db_route_specs = (deps, options) => {
397
406
  // delete through this endpoint is audited. Deferred via
398
407
  // `emit_after_commit` so the pool-routed row can never claim a
399
408
  // delete whose transaction failed at COMMIT — the Rust twin
400
- // commits before emitting for the same reason. Account-grain
409
+ // commits before emitting for the same reason. The request
410
+ // transaction has ended by then, so the row goes through
411
+ // `emit_pool`, not the transaction-routing `emit`. Account-grain
401
412
  // attribution — the browser is a raw storage surface, so no actor
402
413
  // is claimed.
403
414
  const account_id = c.var.request_context?.account.id ?? null;
404
415
  const ip = get_client_ip(c);
405
- emit_after_commit(route, () => {
406
- deps.audit.emit(route, {
407
- event_type: 'db_admin_row_delete',
408
- account_id,
409
- ip,
410
- metadata: { table: name, pk_column, id: deleted_id }
411
- });
412
- });
416
+ emit_after_commit(route, () => deps.audit.emit_pool({
417
+ event_type: 'db_admin_row_delete',
418
+ account_id,
419
+ ip,
420
+ metadata: { table: name, pk_column, id: deleted_id }
421
+ }));
413
422
  return c.json({ success: true });
414
423
  }
415
424
  catch (err) {
@@ -420,21 +429,27 @@ export const create_db_route_specs = (deps, options) => {
420
429
  // NUL byte, rejected by the server encoding whatever the PK
421
430
  // type) — so no row can match; answer with the same masked 404
422
431
  // as a typed miss.
423
- if (code === '22P02' || code === '22003' || code === '22021') {
424
- return c.json({ error: ERROR_ROW_NOT_FOUND }, 404);
425
- }
432
+ const uncoercible = code === '22P02' || code === '22003' || code === '22021';
426
433
  // 23503 foreign_key_violation / 23001 restrict_violation — the
427
434
  // same referencing-row refusal. Which one depends on the
428
435
  // constraint: `ON DELETE RESTRICT` raises 23001 on PG 18, PGlite
429
436
  // and pglet (23503 on PG ≤17), and `NO ACTION` — the default,
430
437
  // when the constraint names no action — raises 23503 on all of
431
438
  // them.
432
- if (code === '23503' || code === '23001') {
433
- const pg_err = err;
434
- log?.warn('Foreign key violation:', pg_err.detail, pg_err.constraint);
435
- return c.json({ error: ERROR_FOREIGN_KEY_VIOLATION }, 409);
439
+ const referenced = code === '23503' || code === '23001';
440
+ // anything else fails the request, and the route's transaction
441
+ // rolls back whole
442
+ if (!uncoercible && !referenced)
443
+ throw err;
444
+ // the refusal answers normally, so the transaction must commit
445
+ if (savepoint)
446
+ await route.db.query('ROLLBACK TO SAVEPOINT db_admin_row_delete');
447
+ if (uncoercible) {
448
+ return c.json({ error: ERROR_ROW_NOT_FOUND }, 404);
436
449
  }
437
- throw err;
450
+ const pg_err = err;
451
+ log?.warn('Foreign key violation:', pg_err.detail, pg_err.constraint);
452
+ return c.json({ error: ERROR_FOREIGN_KEY_VIOLATION }, 409);
438
453
  }
439
454
  }
440
455
  }
@@ -21,6 +21,12 @@ export declare const ERROR_INVALID_JSON_BODY: "invalid_json_body";
21
21
  export declare const ERROR_INVALID_ROUTE_PARAMS: "invalid_route_params";
22
22
  /** URL query params failed Zod validation. */
23
23
  export declare const ERROR_INVALID_QUERY_PARAMS: "invalid_query_params";
24
+ /**
25
+ * An RPC call's `params` hold an own `__proto__` key, at any depth — refused
26
+ * by the dispatcher (`invalid_params`) before the input schema runs. See
27
+ * `json_has_own_proto_key`.
28
+ */
29
+ export declare const ERROR_PARAMS_PROTO_KEY: "params_proto_key";
24
30
  /** No valid session or bearer token. */
25
31
  export declare const ERROR_AUTHENTICATION_REQUIRED: "authentication_required";
26
32
  /** Authenticated but missing required role. */
@@ -53,6 +59,12 @@ export declare const ERROR_RATE_LIMIT_EXCEEDED: "rate_limit_exceeded";
53
59
  export declare const ERROR_INVALID_CREDENTIALS: "invalid_credentials";
54
60
  /** Request body exceeds the maximum allowed size. */
55
61
  export declare const ERROR_PAYLOAD_TOO_LARGE: "payload_too_large";
62
+ /**
63
+ * A pool checkout failed — the database is unavailable (503). The flat REST
64
+ * reason of the JSON-RPC `service_unavailable` a `DbCheckoutError` maps to;
65
+ * the Rust spine's `fuz_http::SERVICE_UNAVAILABLE_REASON`.
66
+ */
67
+ export declare const ERROR_SERVICE_UNAVAILABLE: "service_unavailable";
56
68
  /** Request `Content-Length` header is not a plain run of ASCII digits. */
57
69
  export declare const ERROR_INVALID_CONTENT_LENGTH: "invalid_content_length";
58
70
  /** Request origin not in allowlist. */
@@ -1 +1 @@
1
- {"version":3,"file":"error_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/error_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI9D,0CAA0C;AAC1C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAI1E,wCAAwC;AACxC,eAAO,MAAM,6BAA6B,EAAG,yBAAkC,CAAC;AAEhF,+CAA+C;AAC/C,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAElF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,yCAAyC;AACzC,eAAO,MAAM,yBAAyB,EAAG,qBAA8B,CAAC;AAExE,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,EAAG,qBAA8B,CAAC;AAExE,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAEpE,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,EAAG,wBAAiC,CAAC;AAI9E,uCAAuC;AACvC,eAAO,MAAM,sBAAsB,EAAG,kBAA2B,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAElF,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,EAAG,eAAwB,CAAC;AAE5D,0CAA0C;AAC1C,eAAO,MAAM,u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AAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,eAAO,MAAM,sBAAsB;;iBAEjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;;;EAAoC,CAAC;AAC9D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,yBAAyB;IACzC,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,oBAAoB,GAAI,6EAOlC,yBAAyB,KAAG,iBA8C9B,CAAC"}
@@ -22,6 +22,12 @@ export const ERROR_INVALID_JSON_BODY = 'invalid_json_body';
22
22
  export const ERROR_INVALID_ROUTE_PARAMS = 'invalid_route_params';
23
23
  /** URL query params failed Zod validation. */
24
24
  export const ERROR_INVALID_QUERY_PARAMS = 'invalid_query_params';
25
+ /**
26
+ * An RPC call's `params` hold an own `__proto__` key, at any depth — refused
27
+ * by the dispatcher (`invalid_params`) before the input schema runs. See
28
+ * `json_has_own_proto_key`.
29
+ */
30
+ export const ERROR_PARAMS_PROTO_KEY = 'params_proto_key';
25
31
  // --- Core: Authentication & authorization (auto-derived by auth middleware) ---
26
32
  /** No valid session or bearer token. */
27
33
  export const ERROR_AUTHENTICATION_REQUIRED = 'authentication_required';
@@ -55,6 +61,12 @@ export const ERROR_RATE_LIMIT_EXCEEDED = 'rate_limit_exceeded';
55
61
  export const ERROR_INVALID_CREDENTIALS = 'invalid_credentials';
56
62
  /** Request body exceeds the maximum allowed size. */
57
63
  export const ERROR_PAYLOAD_TOO_LARGE = 'payload_too_large';
64
+ /**
65
+ * A pool checkout failed — the database is unavailable (503). The flat REST
66
+ * reason of the JSON-RPC `service_unavailable` a `DbCheckoutError` maps to;
67
+ * the Rust spine's `fuz_http::SERVICE_UNAVAILABLE_REASON`.
68
+ */
69
+ export const ERROR_SERVICE_UNAVAILABLE = 'service_unavailable';
58
70
  /** Request `Content-Length` header is not a plain run of ASCII digits. */
59
71
  export const ERROR_INVALID_CONTENT_LENGTH = 'invalid_content_length';
60
72
  // --- Origin & bearer token verification ---
@@ -67,6 +67,11 @@ export declare const dev_only: <T>(value: T) => T | undefined;
67
67
  * Frozen so tests must compose new objects rather than monkey-patch.
68
68
  */
69
69
  export declare const jsonrpc_error_messages: Readonly<Record<JsonrpcErrorName, (...args: Array<any>) => JsonrpcErrorObject>>;
70
+ /**
71
+ * The message every failed pool checkout answers with, on both spines — the
72
+ * Rust `fuz_http::DB_UNAVAILABLE_MESSAGE`.
73
+ */
74
+ export declare const DB_UNAVAILABLE_MESSAGE = "database unavailable";
70
75
  /**
71
76
  * Error class carrying a JSON-RPC error code — thrown by handlers, read by
72
77
  * `to_thrown_jsonrpc_error`, and mapped to HTTP status + JSON-RPC error response.
@@ -87,6 +92,11 @@ export declare class ThrownJsonrpcError extends Error {
87
92
  * (another library's RPC error), or a `ThrownJsonrpcError` whose `code` was
88
93
  * cast outside the JSON-RPC set — so each caller masks it.
89
94
  *
95
+ * A failed pool checkout (`DbCheckoutError`, `db/db_checkout_error.ts`) is
96
+ * the database unavailable: `service_unavailable` with
97
+ * `DB_UNAVAILABLE_MESSAGE` and no `data` (HTTP 503), the Rust spine's
98
+ * `fuz_http::db_unavailable`.
99
+ *
90
100
  * The one thrown → wire conversion: the REST catch layer
91
101
  * (`apply_route_specs`), the RPC dispatch core (`perform_action`),
92
102
  * `create_jsonrpc_error_response_from_thrown`, the frontend HTTP and
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EASN,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,MAAM,cAAc,CAAC;AAEtB,0CAA0C;AAC1C,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AAErD,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GACzB,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,UAAU,GACV,kBAAkB,GAClB,cAAc,GACd,qBAAqB,GACrB,SAAS,GACT,gBAAgB,GAChB,mBAAmB,CAAC;AAEvB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EA4C1B,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CAAC,GAAG,SAAsC,CAAC;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAmG7B,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC;AAUt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22
  import { JSONRPC_PARSE_ERROR, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_INVALID_PARAMS, JSONRPC_INTERNAL_ERROR, JSONRPC_SERVER_ERROR_START, JSONRPC_SERVER_ERROR_END, is_jsonrpc_error_code } from './jsonrpc.js';
22
23
  /** Default message for unknown errors. */
23
24
  export const UNKNOWN_ERROR_MESSAGE = 'unknown error';
@@ -184,6 +185,11 @@ export const jsonrpc_error_messages = Object.freeze({
184
185
  data
185
186
  })
186
187
  });
188
+ /**
189
+ * The message every failed pool checkout answers with, on both spines — the
190
+ * Rust `fuz_http::DB_UNAVAILABLE_MESSAGE`.
191
+ */
192
+ export const DB_UNAVAILABLE_MESSAGE = 'database unavailable';
187
193
  /**
188
194
  * Realm-global brand on `ThrownJsonrpcError.prototype`. `Symbol.for` makes
189
195
  * every copy of this module that one process resolves mint the same key, so
@@ -216,6 +222,11 @@ Object.defineProperty(ThrownJsonrpcError.prototype, THROWN_JSONRPC_ERROR_BRAND,
216
222
  * (another library's RPC error), or a `ThrownJsonrpcError` whose `code` was
217
223
  * cast outside the JSON-RPC set — so each caller masks it.
218
224
  *
225
+ * A failed pool checkout (`DbCheckoutError`, `db/db_checkout_error.ts`) is
226
+ * the database unavailable: `service_unavailable` with
227
+ * `DB_UNAVAILABLE_MESSAGE` and no `data` (HTTP 503), the Rust spine's
228
+ * `fuz_http::db_unavailable`.
229
+ *
219
230
  * The one thrown → wire conversion: the REST catch layer
220
231
  * (`apply_route_specs`), the RPC dispatch core (`perform_action`),
221
232
  * `create_jsonrpc_error_response_from_thrown`, the frontend HTTP and
@@ -229,6 +240,9 @@ Object.defineProperty(ThrownJsonrpcError.prototype, THROWN_JSONRPC_ERROR_BRAND,
229
240
  export const to_thrown_jsonrpc_error = (err) => {
230
241
  if (!(err instanceof Error))
231
242
  return null;
243
+ if (is_db_checkout_error(err)) {
244
+ return { code: JSONRPC_ERROR_CODES.service_unavailable, message: DB_UNAVAILABLE_MESSAGE };
245
+ }
232
246
  const { code, data, [THROWN_JSONRPC_ERROR_BRAND]: brand } = err;
233
247
  if (brand !== true || !is_jsonrpc_error_code(code))
234
248
  return null;
@@ -94,6 +94,10 @@ export type ClassifiedJsonrpcMessage = {
94
94
  * `method` as absent — so `{id, method: 123, result}` is a response on both
95
95
  * sides. The `result` / `error` exclusive-or refuses a frame carrying both.
96
96
  *
97
+ * A `request` carries the frame as given — validated, never re-built — so
98
+ * `params` reaches the action's input schema with every own key the client
99
+ * sent, `__proto__` included, as on the GET path and the Rust twin.
100
+ *
97
101
  * Every `invalid` is `invalid_request`. Its `id` is the frame's own when the
98
102
  * frame is an object carrying a string or number one, else `null` — a
99
103
  * non-object frame (an array included) has none. A refused request envelope
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACN,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,eAAe,EACf,MAAM,cAAc,CAAC;AAUtB,0CAA0C;AAC1C,eAAO,MAAM,sBAAsB,GAClC,QAAQ,aAAa,EACrB,QAAQ,oBAAoB,GAAG,SAAS,EACxC,IAAI,gBAAgB,KAClB,cAUF,CAAC;AAEF,mDAAmD;AACnD,eAAO,MAAM,uBAAuB,GACnC,IAAI,gBAAgB,EACpB,QAAQ,aAAa,KACnB,eAID,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,2BAA2B,GACvC,QAAQ,aAAa,EACrB,QAAQ,yBAAyB,GAAG,SAAS,KAC3C,mBASF,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,6BAA6B,GACzC,IAAI,oBAAo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