@fuzdev/fuz_app 0.134.0 → 0.136.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 (118) hide show
  1. package/dist/actions/CLAUDE.md +93 -11
  2. package/dist/actions/register_action_ws.d.ts +23 -3
  3. package/dist/actions/register_action_ws.d.ts.map +1 -1
  4. package/dist/actions/register_action_ws.js +57 -37
  5. package/dist/actions/transports.d.ts +23 -0
  6. package/dist/actions/transports.d.ts.map +1 -1
  7. package/dist/actions/transports.js +23 -0
  8. package/dist/actions/transports_ws_backend.d.ts +133 -10
  9. package/dist/actions/transports_ws_backend.d.ts.map +1 -1
  10. package/dist/actions/transports_ws_backend.js +237 -34
  11. package/dist/actions/ws_endpoint_spec.d.ts +9 -0
  12. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
  13. package/dist/actions/ws_outbound_writer.d.ts +206 -0
  14. package/dist/actions/ws_outbound_writer.d.ts.map +1 -0
  15. package/dist/actions/ws_outbound_writer.js +431 -0
  16. package/dist/auth/CLAUDE.md +10 -4
  17. package/dist/auth/account_action_specs.d.ts +7 -0
  18. package/dist/auth/account_action_specs.d.ts.map +1 -1
  19. package/dist/auth/account_action_specs.js +11 -1
  20. package/dist/auth/audit_emitter.d.ts +4 -0
  21. package/dist/auth/audit_emitter.d.ts.map +1 -1
  22. package/dist/auth/audit_emitter.js +18 -2
  23. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  24. package/dist/auth/audit_log_routes.js +3 -1
  25. package/dist/auth/cell_action_specs.d.ts +10 -0
  26. package/dist/auth/cell_action_specs.d.ts.map +1 -1
  27. package/dist/auth/cell_action_specs.js +17 -3
  28. package/dist/auth/cell_actions.js +1 -1
  29. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  30. package/dist/auth/role_grant_offer_action_specs.js +7 -2
  31. package/dist/auth/role_schema.d.ts +14 -3
  32. package/dist/auth/role_schema.d.ts.map +1 -1
  33. package/dist/auth/role_schema.js +14 -2
  34. package/dist/auth/scope_kind_schema.d.ts +10 -0
  35. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  36. package/dist/auth/scope_kind_schema.js +11 -0
  37. package/dist/db/migrate.d.ts +1 -1
  38. package/dist/db/migrate.js +2 -2
  39. package/dist/env/load.d.ts +1 -1
  40. package/dist/env/load.js +1 -1
  41. package/dist/http/CLAUDE.md +2 -1
  42. package/dist/http/body_limit.d.ts +74 -0
  43. package/dist/http/body_limit.d.ts.map +1 -0
  44. package/dist/http/body_limit.js +100 -0
  45. package/dist/http/db_routes.d.ts.map +1 -1
  46. package/dist/http/db_routes.js +5 -3
  47. package/dist/http/error_schemas.d.ts +2 -0
  48. package/dist/http/error_schemas.d.ts.map +1 -1
  49. package/dist/http/error_schemas.js +2 -0
  50. package/dist/realtime/outbound_budget.d.ts +91 -0
  51. package/dist/realtime/outbound_budget.d.ts.map +1 -0
  52. package/dist/realtime/outbound_budget.js +108 -0
  53. package/dist/realtime/sse.d.ts +36 -3
  54. package/dist/realtime/sse.d.ts.map +1 -1
  55. package/dist/realtime/sse.js +58 -6
  56. package/dist/realtime/sse_constants.d.ts +12 -0
  57. package/dist/realtime/sse_constants.d.ts.map +1 -1
  58. package/dist/realtime/sse_constants.js +12 -0
  59. package/dist/server/app_server.d.ts.map +1 -1
  60. package/dist/server/app_server.js +3 -6
  61. package/dist/testing/CLAUDE.md +96 -19
  62. package/dist/testing/admin_integration.js +1 -1
  63. package/dist/testing/audit_completeness.d.ts +1 -1
  64. package/dist/testing/audit_completeness.js +1 -1
  65. package/dist/testing/audit_drift_guard.d.ts +19 -6
  66. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  67. package/dist/testing/audit_drift_guard.js +25 -9
  68. package/dist/testing/cross_backend/body_size.d.ts +18 -5
  69. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  70. package/dist/testing/cross_backend/body_size.js +233 -34
  71. package/dist/testing/cross_backend/body_size_smuggling.d.ts +0 -12
  72. package/dist/testing/cross_backend/body_size_smuggling.d.ts.map +1 -1
  73. package/dist/testing/cross_backend/body_size_smuggling.js +103 -108
  74. package/dist/testing/cross_backend/capabilities.d.ts +3 -21
  75. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  76. package/dist/testing/cross_backend/capabilities.js +1 -3
  77. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  78. package/dist/testing/cross_backend/cell_crud.js +31 -2
  79. package/dist/testing/cross_backend/conformance_case.d.ts +3 -3
  80. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  81. package/dist/testing/cross_backend/credential_header_robustness.js +18 -54
  82. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  83. package/dist/testing/cross_backend/default_backend_configs.js +2 -8
  84. package/dist/testing/cross_backend/role_grant_role_grammar.d.ts +6 -0
  85. package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -0
  86. package/dist/testing/cross_backend/role_grant_role_grammar.js +117 -0
  87. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +2 -3
  88. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +2 -3
  90. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  91. package/dist/testing/cross_backend/testing_backdoor.js +10 -4
  92. package/dist/testing/cross_backend/testing_reset_actions.d.ts +87 -2
  93. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  94. package/dist/testing/cross_backend/testing_reset_actions.js +106 -2
  95. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  96. package/dist/testing/cross_backend/token_lifetime.js +34 -1
  97. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/ts_spine_backend_config.js +8 -13
  99. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts +29 -0
  100. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -0
  101. package/dist/testing/cross_backend/ws_outbound_overflow.js +276 -0
  102. package/dist/testing/integration.js +1 -1
  103. package/dist/testing/schema_introspect.d.ts +30 -2
  104. package/dist/testing/schema_introspect.d.ts.map +1 -1
  105. package/dist/testing/schema_introspect.js +38 -7
  106. package/dist/testing/transports/raw_http.d.ts +78 -0
  107. package/dist/testing/transports/raw_http.d.ts.map +1 -0
  108. package/dist/testing/transports/raw_http.js +141 -0
  109. package/dist/testing/transports/ws_transport.d.ts +4 -2
  110. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  111. package/dist/testing/transports/ws_transport.js +2 -1
  112. package/dist/testing/ws_round_trip.d.ts +32 -2
  113. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  114. package/dist/testing/ws_round_trip.js +26 -4
  115. package/package.json +1 -1
  116. package/dist/env/resolve.d.ts +0 -163
  117. package/dist/env/resolve.d.ts.map +0 -1
  118. package/dist/env/resolve.js +0 -267
@@ -57,8 +57,8 @@ Cross-cutting notes that don't live on any single symbol:
57
57
  Convention — `*_schema.ts` is Zod-only; `*_ddl.ts` holds DDL strings.
58
58
 
59
59
  - `auth/account_schema.ts` — `Account`, `Actor`, `RoleGrant`, `AuthSession`, `ApiToken` + client-safe JSON shapes. Grant predicates over wire fields: `is_role_grant_active` (not revoked, not expired) and `has_global_role(role_grants, role, now?)` (an active grant of the role with `scope_id === null` — the bare-list form of `has_scoped_role(ctx, role, null)`, used client-side by `AuthState`).
60
- - `auth/role_schema.ts` — `RoleName`, `RoleSpec`, `ROLE_KEEPER`, `ROLE_ADMIN`, `is_builtin_role`, `create_role_schema`, `builtin_role_specs_by_name`, `role_has_grant_path`, `list_roles_with_grant_path`.
61
- - `auth/scope_kind_schema.ts` — `ScopeKindName`, `create_scope_kind_schema` (open registry, no builtins).
60
+ - `auth/role_schema.ts` — `RoleName` (lowercase letters and underscores, no leading or trailing underscore, at most `ROLE_NAME_LENGTH_MAX` = 64 characters — the grammar every `role` input and every registered role holds, twin of the Rust `is_valid_role_name`), `RoleSpec`, `ROLE_KEEPER`, `ROLE_ADMIN`, `is_builtin_role`, `create_role_schema`, `builtin_role_specs_by_name`, `role_has_grant_path`, `list_roles_with_grant_path`.
61
+ - `auth/scope_kind_schema.ts` — `ScopeKindName`, `create_scope_kind_schema` (open registry, no builtins), `SCOPE_KIND_LENGTH_MAX` (64 — bounds a registered name and the `scope_kind` on `role_grant_offer_create` / `role_grant_assign`, which is copied into the row and its audit metadata).
62
62
  - `auth/credential_type_schema.ts` — `CredentialTypeName`, `CREDENTIAL_TYPE_SESSION` / `_API_TOKEN` / `_DAEMON_TOKEN`, `create_credential_type_schema`.
63
63
  - `auth/grant_path_schema.ts` — `GrantPathName`, `GRANT_PATH_ADMIN` / `_SELF_SERVICE` / `_SYSTEM` / `_BOOTSTRAP`, `create_grant_path_schema`.
64
64
  - `auth/token_lifetime.ts` — the temporal axis of a minted token: `TokenLifetimeInput` (required union on `account_token_create` — `{kind:'eternal'}` or `{kind:'ttl', days}`), `token_lifetime_to_expires_at`, `TOKEN_TTL_DAYS_MAX`. No default — `expires_at IS NULL` always means "deliberately eternal".
@@ -168,6 +168,10 @@ compile until it declares its scope. Both revocation listeners
168
168
  and `audit_unknown_event_type_failures` are process-wide, fail-open
169
169
  (write the row anyway). Independent in implementation; under the factory
170
170
  they track the same config. Sample via `get_*`; `reset_*` are test-only.
171
+ Another counter lives with the emitter (`auth/audit_emitter.ts`,
172
+ `get_audit_write_failures` / `reset_audit_write_failures`): rows the bound
173
+ emitter's pool write failed to insert. That write is fail-open too — logged,
174
+ counted, the request proceeds — so the count is how a lost row is seen.
171
175
 
172
176
  ### Routes
173
177
 
@@ -239,6 +243,8 @@ consumer's `validate_data` pass-through callback on `CellActionDeps`.
239
243
  `visibility` / `path`), the write-once capability/identity axis; a stray
240
244
  `kind` inside `data` is rejected fail-loud (`ERROR_CELL_KIND_IN_DATA`).
241
245
  - `auth/cell_action_specs.ts` — `CellVisibility` enum, `CellPath` brand,
246
+ `CELL_KIND_LENGTH_MAX` (64 — the wire `kind` on `cell_create` and the
247
+ `cell_list` filter; the tag is copied into the cell's audit rows),
242
248
  `CellJson`, the generic verb specs (`cell_create / get / update /
243
249
  delete / list / clone / moderate`), error reasons, and `all_cell_action_specs`
244
250
  (spreads in the grant / field / item / audit registries so codegen + UI
@@ -296,7 +302,7 @@ auth, ids)`: batched strict relation-read filter. Every relation read —
296
302
  The authorizer is **pure** — the handler reads the governing root's `data`
297
303
  in-tx and hands it over as `root_data`, so a directory policy resolves
298
304
  `root.data.policy[kind]` without its own DB read (which also dodges the
299
- single-connection PGlite deadlock). `None`/omitted = open create (the default;
305
+ single-connection deadlock of the in-memory drivers). `None`/omitted = open create (the default;
300
306
  mirrors `validate_data`). `cell_moderate` is the `pending → approved | rejected`
301
307
  transition, gated on `can_manage_cell` of the **governing root** (admin / root
302
308
  owner — the author lands a 403, the anti-self-approval guard); approve flips
@@ -770,7 +776,7 @@ Options: `roles?: RoleSchemaResult` (drives admin-grant-path lookup),
770
776
  - `account_session_list_action_spec` — read; input `z.void()`; output `{sessions}`.
771
777
  - `account_session_revoke_action_spec` — mutation; input `{session_id}`; output `{ok, revoked}`.
772
778
  - `account_session_revoke_all_action_spec` — mutation; input `z.void()`; output `{ok, count}`.
773
- - `account_token_create_action_spec` — mutation; input `{name?, scope, lifetime}` (both `scope` and `lifetime` required — default-deny at mint on both axes); output `{ok, token, id, name, expires_at}`.
779
+ - `account_token_create_action_spec` — mutation; input `{name?, scope, lifetime}` (both `scope` and `lifetime` required — default-deny at mint on both axes; `name` at most `API_TOKEN_NAME_LENGTH_MAX` = 255 characters, since it is copied into the audit row); output `{ok, token, id, name, expires_at}`.
774
780
  - `account_token_list_action_spec` — read; input `z.void()`; output `{tokens}`.
775
781
  - `account_token_revoke_action_spec` — mutation; input `{token_id}`; output `{ok, revoked}`.
776
782
 
@@ -45,6 +45,13 @@ export declare const SessionRevokeAllOutput: z.ZodObject<{
45
45
  count: z.ZodNumber;
46
46
  }, z.core.$strict>;
47
47
  export type SessionRevokeAllOutput = z.infer<typeof SessionRevokeAllOutput>;
48
+ /**
49
+ * Maximum length of an API token's `name`, in UTF-16 code units (what
50
+ * `String.length` and Zod's `.max()` measure). The name is copied into the
51
+ * `token_create` audit row, so it is bounded where it enters. Same value as
52
+ * the Rust spine's `API_TOKEN_NAME_LENGTH_MAX`.
53
+ */
54
+ export declare const API_TOKEN_NAME_LENGTH_MAX = 255;
48
55
  /**
49
56
  * Input for `account_token_create`.
50
57
  *
@@ -1 +1 @@
1
- {"version":3,"file":"account_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAW3E,6EAA6E;AAC7E,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,yCAAyC;AACzC,eAAO,MAAM,iBAAiB;;;;;;;kBAE5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB;;kBAE7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,iFAAiF;AACjF,eAAO,MAAM,mBAAmB;;;kBAG9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CA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E,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB;;;kBAG5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAIlE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;CAUF,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;CAUR,CAAC;AAKtC,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;CAUV,CAAC;AAGtC,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;CAUd,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWR,CAAC;AAEtC,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;CAUN,CAAC;AAGtC,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;CAUR,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,yBAAyB,CAQrE,CAAC"}
@@ -37,6 +37,13 @@ export const SessionRevokeAllOutput = z.strictObject({
37
37
  ok: z.literal(true),
38
38
  count: z.number()
39
39
  });
40
+ /**
41
+ * Maximum length of an API token's `name`, in UTF-16 code units (what
42
+ * `String.length` and Zod's `.max()` measure). The name is copied into the
43
+ * `token_create` audit row, so it is bounded where it enters. Same value as
44
+ * the Rust spine's `API_TOKEN_NAME_LENGTH_MAX`.
45
+ */
46
+ export const API_TOKEN_NAME_LENGTH_MAX = 255;
40
47
  /**
41
48
  * Input for `account_token_create`.
42
49
  *
@@ -54,8 +61,11 @@ export const SessionRevokeAllOutput = z.strictObject({
54
61
  export const TokenCreateInput = z.strictObject({
55
62
  name: z
56
63
  .string()
64
+ .max(API_TOKEN_NAME_LENGTH_MAX)
57
65
  .default('CLI token')
58
- .meta({ description: 'Human-friendly label; shown in the token list.' }),
66
+ .meta({
67
+ description: `Human-friendly label; shown in the token list. At most ${API_TOKEN_NAME_LENGTH_MAX} characters.`
68
+ }),
59
69
  scope: TokenScopeInput.meta({
60
70
  description: "What the token may do. `{kind:'full'}` for full account authority, or " +
61
71
  "`{kind:'methods',methods:[…]}` to narrow it to named RPC methods — a " +
@@ -285,6 +285,10 @@ export interface CreateAuditEmitterOptions {
285
285
  */
286
286
  track_inflight?: boolean;
287
287
  }
288
+ /** Number of audit rows an emitter failed to write since process start. */
289
+ export declare const get_audit_write_failures: () => number;
290
+ /** Reset the counter — for tests only. */
291
+ export declare const reset_audit_write_failures: () => void;
288
292
  /**
289
293
  * Build a bound `AuditEmitter`. Typical caller is the consumer's
290
294
  * `audit_factory` callback on `CreateAppBackendOptions` —
@@ -1 +1 @@
1
- {"version":3,"file":"audit_emitter.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IAClE,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,S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C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACnE;;;OAGG;IACH,cAAc,IAAI,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;OAgBG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,MAAM,EAC1C,GAAG,EAAE,mBAAmB,EACxB,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KACnB,IAAI,CAAC;AAEV;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAC;AAEhE,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACzC,oDAAoD;IACpD,EAAE,EAAE,EAAE,CAAC;IACP,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACzD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAYD,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,QAAO,MAA8B,CAAC;AAE3E,0CAA0C;AAC1C,eAAO,MAAM,0BAA0B,QAAO,IAE7C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,yBAAyB,KAAG,YA8IzE,CAAC"}
@@ -68,6 +68,21 @@
68
68
  import { emit_after_commit } from '../http/pending_effects.js';
69
69
  import { query_audit_log } from './audit_log_queries.js';
70
70
  import { builtin_audit_log_config } from './audit_log_schema.js';
71
+ /**
72
+ * Process-wide counter for audit rows an emitter failed to write. The pool
73
+ * write behind `emit` / `emit_pool` / `emit_role_grant_target` is fail-open —
74
+ * a refused `INSERT` is logged and the request proceeds — so a lost row is
75
+ * otherwise visible only in the log. Same posture and lifetime as the drift
76
+ * counters in `auth/audit_log_queries.ts`: in-process, resets on restart, and
77
+ * asserted zero per test by `install_audit_drift_guard`.
78
+ */
79
+ let audit_write_failures = 0;
80
+ /** Number of audit rows an emitter failed to write since process start. */
81
+ export const get_audit_write_failures = () => audit_write_failures;
82
+ /** Reset the counter — for tests only. */
83
+ export const reset_audit_write_failures = () => {
84
+ audit_write_failures = 0;
85
+ };
71
86
  /**
72
87
  * Build a bound `AuditEmitter`. Typical caller is the consumer's
73
88
  * `audit_factory` callback on `CreateAppBackendOptions` —
@@ -101,13 +116,14 @@ export const create_audit_emitter = (options) => {
101
116
  }
102
117
  }
103
118
  };
104
- // The pool write. Never rejects: a failed write is logged and resolves
105
- // `null`, so there is no row to announce.
119
+ // The pool write. Never rejects: a failed write is logged, counted, and
120
+ // resolves `null`, so there is no row to announce.
106
121
  const write = async (input) => {
107
122
  try {
108
123
  return await query_audit_log({ db }, input, audit_log_config);
109
124
  }
110
125
  catch (err) {
126
+ audit_write_failures++;
111
127
  log.error('Audit log write failed:', err);
112
128
  return null;
113
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAUvD,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAU7E,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACpC,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE;QACR,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAC9C,GAAG,EAAE,MAAM,CAAC;KACZ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,oBAAoB,KAAG,KAAK,CAAC,SAAS,CAoG5F,CAAC"}
1
+ {"version":3,"file":"audit_log_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAUvD,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAU7E,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACpC,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE;QACR,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAC9C,GAAG,EAAE,MAAM,CAAC;KACZ,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,oBAAoB,KAAG,KAAK,CAAC,SAAS,CAsG5F,CAAC"}
@@ -134,7 +134,9 @@ export const create_audit_log_route_specs = (options) => {
134
134
  // left during the re-reads gets a stream that is already closed,
135
135
  // whose listener runs at once and removes the registration, so
136
136
  // `admit` refuses it rather than evicting a live stream for it.
137
- const { response, stream } = create_sse_response(c, log);
137
+ const { response, stream } = create_sse_response(c, log, {
138
+ account_id: ctx.account.id
139
+ });
138
140
  stream.on_close(pending.unsubscribe);
139
141
  admitted = registry.admit(pending, stream);
140
142
  if (!admitted) {
@@ -126,6 +126,16 @@ export declare const CELL_PATH_LENGTH_MAX = 256;
126
126
  */
127
127
  export declare const CellPath: z.core.$ZodBranded<z.ZodString, "CellPath", "out">;
128
128
  export type CellPath = z.infer<typeof CellPath>;
129
+ /**
130
+ * Maximum length of a cell `kind` on the wire, in UTF-16 code units (what
131
+ * `String.length` and Zod's `.max()` measure) — on `cell_create`, and on the
132
+ * `cell_list` filter. The cell layer imposes no grammar on `kind`; the bound
133
+ * is there because the tag is copied into every audit row the cell's
134
+ * mutations write. The same bound a cell field name carries
135
+ * (`CELL_FIELD_NAME_REGEX`), the cell layer's other machine-readable tag,
136
+ * and the same value as the Rust spine's `CELL_KIND_LENGTH_MAX`.
137
+ */
138
+ export declare const CELL_KIND_LENGTH_MAX = 64;
129
139
  /**
130
140
  * Soft cap on the size of a `cell.list` request page. Larger pages chew
131
141
  * memory both server- and client-side; combined with the visibility
@@ -1 +1 @@
1
- {"version":3,"file":"cell_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAEN,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAE3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEN,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAE3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEN,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAE1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEN,2BAA2B,EAC3B,MAAM,8BAA8B,CAAC;AAGtC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYxB,CAAC"}
@@ -132,6 +132,16 @@ export const CELL_PATH_LENGTH_MAX = 256;
132
132
  * callsite (`as CellPath`) — the runtime check still runs server-side.
133
133
  */
134
134
  export const CellPath = z.string().min(1).max(CELL_PATH_LENGTH_MAX).brand('CellPath');
135
+ /**
136
+ * Maximum length of a cell `kind` on the wire, in UTF-16 code units (what
137
+ * `String.length` and Zod's `.max()` measure) — on `cell_create`, and on the
138
+ * `cell_list` filter. The cell layer imposes no grammar on `kind`; the bound
139
+ * is there because the tag is copied into every audit row the cell's
140
+ * mutations write. The same bound a cell field name carries
141
+ * (`CELL_FIELD_NAME_REGEX`), the cell layer's other machine-readable tag,
142
+ * and the same value as the Rust spine's `CELL_KIND_LENGTH_MAX`.
143
+ */
144
+ export const CELL_KIND_LENGTH_MAX = 64;
135
145
  /**
136
146
  * Soft cap on the size of a `cell.list` request page. Larger pages chew
137
147
  * memory both server- and client-side; combined with the visibility
@@ -201,8 +211,12 @@ export const CellCreateInput = z.strictObject({
201
211
  data: CellData.meta({
202
212
  description: 'Cell content. Base fields (label / summary) typed; extras loose. A `kind` key here is rejected (`ERROR_CELL_KIND_IN_DATA`) — kind is the top-level field. Per-kind shape is sub-API.'
203
213
  }),
204
- kind: z.string().nullish().meta({
205
- description: 'Capability / identity tag, written to the top-level `cell.kind` column (not `data`). Write-once — fixed at birth, not updatable. Non-empty when present (an empty string is rejected `ERROR_CELL_KIND_EMPTY`); omit / null for a typeless cell. A creation authorizer (if mounted) gates on this.'
214
+ kind: z
215
+ .string()
216
+ .max(CELL_KIND_LENGTH_MAX)
217
+ .nullish()
218
+ .meta({
219
+ description: `Capability / identity tag, written to the top-level \`cell.kind\` column (not \`data\`). Write-once — fixed at birth, not updatable. Non-empty when present (an empty string is rejected \`ERROR_CELL_KIND_EMPTY\`) and at most ${CELL_KIND_LENGTH_MAX} characters; omit / null for a typeless cell. A creation authorizer (if mounted) gates on this.`
206
220
  }),
207
221
  visibility: CellVisibility.optional().meta({
208
222
  description: "Access-control tag. Top-level column (not in `data`). Default `'private'` when omitted."
@@ -306,7 +320,7 @@ export const CellListInput = z
306
320
  .max(CELL_LIST_LIMIT_MAX)
307
321
  .optional()
308
322
  .meta({ description: 'Batch-fetch by id. Visibility predicate still applies.' }),
309
- kind: z.string().optional().meta({
323
+ kind: z.string().max(CELL_KIND_LENGTH_MAX).optional().meta({
310
324
  description: 'Match `cell.kind = ?`. An empty string matches nothing — no cell carries an empty kind.'
311
325
  }),
312
326
  visibility: CellVisibility.optional().meta({
@@ -165,7 +165,7 @@ export const create_cell_actions = (deps) => {
165
165
  // **in-tx** (only when an authorizer is mounted), reusing the parent row
166
166
  // when the parent *is* the root, else one read by `root_id` — so the
167
167
  // authorizer stays pure + the read rides the handler's connection (no
168
- // separate-handle deadlock on the single-connection PGlite).
168
+ // separate-handle deadlock on the single-connection in-memory drivers).
169
169
  const parent_id = input.parent_id ?? null;
170
170
  let root_id = null;
171
171
  let root_data = null;
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_offer_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAc3E,oEAAoE;AACpE,eAAO,MAAM,kCAAkC,EAAG,8BAAuC,CAAC;AAC1F,kEAAkE;AAClE,eAAO,MAAM,+BAA+B,EAAG,2BAAoC,CAAC;AAC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oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWZ,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;CAaL,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBL,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,KAAK,CAAC,yBAAyB,CAS9E,CAAC"}
@@ -24,6 +24,7 @@ import { z } from 'zod';
24
24
  import { Uuid } from '@fuzdev/fuz_util/id.ts';
25
25
  import { ERROR_INSUFFICIENT_PERMISSIONS, ERROR_ROLE_GRANT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
26
26
  import { RoleName } from './role_schema.js';
27
+ import { SCOPE_KIND_LENGTH_MAX } from './scope_kind_schema.js';
27
28
  import { ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX, RoleGrantOfferJson } from './role_grant_offer_schema.js';
28
29
  import { ROLE_GRANT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
29
30
  import { ActingActor } from '../http/auth_shape.js';
@@ -63,8 +64,12 @@ export const is_grant_scope_paired = (input) => (input.scope_kind == null) === (
63
64
  /** The message a half-scoped grant input fails with — the grant inputs' refine, and the UI's pre-RPC guard. */
64
65
  export const GRANT_SCOPE_PAIRED_MESSAGE = "'scope_kind' and 'scope_id' must be given together (both for a scoped grant, neither for a global one)";
65
66
  /** The `scope_kind` field both grant inputs share, paired with `scope_id`. */
66
- const GrantScopeKind = z.string().nullish().meta({
67
- description: 'Machine-readable kind tag for `scope_id` — paired-null with `scope_id` (both null for global, both non-null for scoped). Required iff `scope_id` is set.'
67
+ const GrantScopeKind = z
68
+ .string()
69
+ .max(SCOPE_KIND_LENGTH_MAX)
70
+ .nullish()
71
+ .meta({
72
+ description: `Machine-readable kind tag for \`scope_id\` — paired-null with \`scope_id\` (both null for global, both non-null for scoped). Required iff \`scope_id\` is set. At most ${SCOPE_KIND_LENGTH_MAX} characters.`
68
73
  });
69
74
  // -- Input/output schemas ---------------------------------------------------
70
75
  /**
@@ -24,7 +24,17 @@ import { z } from 'zod';
24
24
  import { type CredentialTypeSchemaResult } from './credential_type_schema.js';
25
25
  import { type GrantPathSchemaResult } from './grant_path_schema.js';
26
26
  import type { ScopeKindSchemaResult } from './scope_kind_schema.js';
27
- /** Valid role name: lowercase letters and underscores, no leading/trailing underscore. */
27
+ /**
28
+ * The longest role name `RoleName` admits, in characters. A role string is
29
+ * caller-chosen text until it passes the grammar, and the grant verbs record
30
+ * the role they refuse in a failure audit row, so the grammar bounds its
31
+ * length too. Same value as the Rust spine's `ROLE_NAME_LENGTH_MAX`.
32
+ */
33
+ export declare const ROLE_NAME_LENGTH_MAX = 64;
34
+ /**
35
+ * Valid role name: lowercase letters and underscores, no leading/trailing
36
+ * underscore, at most `ROLE_NAME_LENGTH_MAX` characters.
37
+ */
28
38
  export declare const RoleName: z.ZodString;
29
39
  export type RoleName = z.infer<typeof RoleName>;
30
40
  /** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
@@ -78,7 +88,7 @@ export declare const is_builtin_role: (name: string) => name is BuiltinRole;
78
88
  * `builtin_role_specs_by_name`.
79
89
  */
80
90
  export interface RoleSpec {
81
- /** Unique role name. Must match `RoleName` regex; collisions with builtins throw. */
91
+ /** Unique role name. Must match `RoleName` — its regex and length cap; collisions with builtins throw. */
82
92
  name: string;
83
93
  /** Admin-UI-facing copy describing the role's intent. */
84
94
  description?: string;
@@ -146,7 +156,8 @@ export interface RoleSchemaResult {
146
156
  *
147
157
  * Construction-time guards (all fire on misconfiguration):
148
158
  *
149
- * 1. Every `consumer_roles[i].name` matches `RoleName` regex.
159
+ * 1. Every `consumer_roles[i].name` matches `RoleName` — its regex and its
160
+ * `ROLE_NAME_LENGTH_MAX` length cap.
150
161
  * 2. No two consumer roles share a name.
151
162
  * 3. No consumer role collides with a builtin (`keeper` / `admin`).
152
163
  * 4. When `options.credential_types` is supplied, every entry in
@@ -1 +1 @@
1
- {"version":3,"file":"role_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGN,KAAK,qBAAqB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,aAKnB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAIhD,sFAAsF;AACtF,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,iEAAiE;AACjE,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC,+CAA+C;AAC/C,eAAO,MAAM,aAAa,8BAAqC,CAAC;AAEhE,yCAAyC;AACzC,eAAO,MAAM,WAAW;;;EAAwB,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,IAAI,IAAI,WACX,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,QAAQ;IACxB,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAClD;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,aAAa,CAAC,MAA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AAE,QAAQ,CAuBnE,CAAC;AAEH,iGAAiG;AACjG,MAAM,WAAW,uBAAuB;IACvC,uGAAuG;IACvG,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,+FAA+F;IAC/F,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,oFAAoF;IACpF,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAChC,0GAA0G;IAC1G,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,yEAAyE;IACzE,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC1C;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,kBAAkB,GAC9B,gBAAgB,aAAa,CAAC,QAAQ,CAAC,EACvC,UAAS,uBAA4B,KACnC,gBA2CF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC/B,YAAY,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzC,MAAM,MAAM,EACZ,YAAY,MAAM,KAChB,OAGF,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,GACtC,YAAY,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzC,YAAY,MAAM,KAChB,KAAK,CAAC,MAAM,CAMd,CAAC"}
@@ -23,9 +23,20 @@
23
23
  import { z } from 'zod';
24
24
  import { CREDENTIAL_TYPE_DAEMON_TOKEN } from './credential_type_schema.js';
25
25
  import { GRANT_PATH_ADMIN, GRANT_PATH_BOOTSTRAP } from './grant_path_schema.js';
26
- /** Valid role name: lowercase letters and underscores, no leading/trailing underscore. */
26
+ /**
27
+ * The longest role name `RoleName` admits, in characters. A role string is
28
+ * caller-chosen text until it passes the grammar, and the grant verbs record
29
+ * the role they refuse in a failure audit row, so the grammar bounds its
30
+ * length too. Same value as the Rust spine's `ROLE_NAME_LENGTH_MAX`.
31
+ */
32
+ export const ROLE_NAME_LENGTH_MAX = 64;
33
+ /**
34
+ * Valid role name: lowercase letters and underscores, no leading/trailing
35
+ * underscore, at most `ROLE_NAME_LENGTH_MAX` characters.
36
+ */
27
37
  export const RoleName = z
28
38
  .string()
39
+ .max(ROLE_NAME_LENGTH_MAX, `Role names must be at most ${ROLE_NAME_LENGTH_MAX} characters`)
29
40
  .regex(/^[a-z][a-z_]*[a-z]$|^[a-z]$/, 'Role names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
30
41
  // Builtin roles — provided by fuz_app, always available.
31
42
  /** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
@@ -99,7 +110,8 @@ const validate_registry_membership = (role_name, field, values, registry) => {
99
110
  *
100
111
  * Construction-time guards (all fire on misconfiguration):
101
112
  *
102
- * 1. Every `consumer_roles[i].name` matches `RoleName` regex.
113
+ * 1. Every `consumer_roles[i].name` matches `RoleName` — its regex and its
114
+ * `ROLE_NAME_LENGTH_MAX` length cap.
103
115
  * 2. No two consumer roles share a name.
104
116
  * 3. No consumer role collides with a builtin (`keeper` / `admin`).
105
117
  * 4. When `options.credential_types` is supplied, every entry in
@@ -37,6 +37,16 @@ import { z } from 'zod';
37
37
  * `'GLOBAL'` token.
38
38
  */
39
39
  export declare const SCOPE_KIND_NAME_REGEX: RegExp;
40
+ /**
41
+ * Maximum length of a `scope_kind`, in UTF-16 code units (what
42
+ * `String.length` and Zod's `.max()` measure). Bounds the tag where it enters
43
+ * — the grant inputs (`role_grant_offer_create`, `role_grant_assign`) copy it
44
+ * into the row and its audit metadata — and a registered name, so no
45
+ * registry declares a kind the grant inputs would refuse. Same value as
46
+ * `ROLE_NAME_LENGTH_MAX`, whose grammar the name mirrors, and as the Rust
47
+ * spine's `SCOPE_KIND_LENGTH_MAX`.
48
+ */
49
+ export declare const SCOPE_KIND_LENGTH_MAX = 64;
40
50
  /** Zod schema for valid scope-kind name strings. */
41
51
  export declare const ScopeKindName: z.ZodString;
42
52
  export type ScopeKindName = z.infer<typeof ScopeKindName>;
@@ -1 +1 @@
1
- {"version":3,"file":"scope_kind_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAgC,CAAC;AAEnE,oDAAoD;AACpD,eAAO,MAAM,aAAa,aAKxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,wBAAwB,GACpC,gBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAC3C,qBAwBF,CAAC"}
1
+ {"version":3,"file":"scope_kind_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAgC,CAAC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,oDAAoD;AACpD,eAAO,MAAM,aAAa,aASxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,wBAAwB,GACpC,gBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAC3C,qBAwBF,CAAC"}
@@ -37,9 +37,20 @@ import { z } from 'zod';
37
37
  * `'GLOBAL'` token.
38
38
  */
39
39
  export const SCOPE_KIND_NAME_REGEX = /^[a-z][a-z_]*[a-z]$|^[a-z]$/;
40
+ /**
41
+ * Maximum length of a `scope_kind`, in UTF-16 code units (what
42
+ * `String.length` and Zod's `.max()` measure). Bounds the tag where it enters
43
+ * — the grant inputs (`role_grant_offer_create`, `role_grant_assign`) copy it
44
+ * into the row and its audit metadata — and a registered name, so no
45
+ * registry declares a kind the grant inputs would refuse. Same value as
46
+ * `ROLE_NAME_LENGTH_MAX`, whose grammar the name mirrors, and as the Rust
47
+ * spine's `SCOPE_KIND_LENGTH_MAX`.
48
+ */
49
+ export const SCOPE_KIND_LENGTH_MAX = 64;
40
50
  /** Zod schema for valid scope-kind name strings. */
41
51
  export const ScopeKindName = z
42
52
  .string()
53
+ .max(SCOPE_KIND_LENGTH_MAX, `Scope-kind names must be at most ${SCOPE_KIND_LENGTH_MAX} characters`)
43
54
  .regex(SCOPE_KIND_NAME_REGEX, 'Scope-kind names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
44
55
  /**
45
56
  * Create a scope-kind schema from a consumer-declared registry.
@@ -50,7 +50,7 @@
50
50
  * tx atomicity + the `(namespace, name)` PK on `schema_version`: the
51
51
  * loser's INSERT hits a PK violation, the chain-tx rolls back, and the
52
52
  * next boot reads the committed state and proceeds cleanly. Environments
53
- * without `pg_advisory_lock` (some PGlite versions) silently fall through.
53
+ * without `pg_advisory_lock` (pglet) silently fall through.
54
54
  *
55
55
  * @module
56
56
  */
@@ -50,7 +50,7 @@
50
50
  * tx atomicity + the `(namespace, name)` PK on `schema_version`: the
51
51
  * loser's INSERT hits a PK violation, the chain-tx rolls back, and the
52
52
  * next boot reads the committed state and proceeds cleanly. Environments
53
- * without `pg_advisory_lock` (some PGlite versions) silently fall through.
53
+ * without `pg_advisory_lock` (pglet) silently fall through.
54
54
  *
55
55
  * @module
56
56
  */
@@ -99,7 +99,7 @@ const namespace_lock_key = (namespace) => {
99
99
  * Run `fn` with the namespace's advisory lock held.
100
100
  *
101
101
  * Acquire / release are best-effort and silently fall through in
102
- * environments without `pg_advisory_lock` (some PGlite versions). The
102
+ * environments without `pg_advisory_lock` (pglet). The
103
103
  * `finally` ensures release on any throw from `fn`.
104
104
  */
105
105
  const with_namespace_lock = async (db, namespace, fn) => {
@@ -35,7 +35,7 @@ export declare class EnvValidationError extends Error {
35
35
  * `error.all_undefined` before calling this.
36
36
  *
37
37
  * @param error - the env validation error
38
- * @param label - optional prefix for log lines (e.g., 'zap daemon', 'env')
38
+ * @param label - optional prefix for log lines (e.g., 'server', 'env')
39
39
  */
40
40
  export declare const log_env_validation_error: (error: EnvValidationError, label?: string) => void;
41
41
  /**
package/dist/env/load.js CHANGED
@@ -42,7 +42,7 @@ export class EnvValidationError extends Error {
42
42
  * `error.all_undefined` before calling this.
43
43
  *
44
44
  * @param error - the env validation error
45
- * @param label - optional prefix for log lines (e.g., 'zap daemon', 'env')
45
+ * @param label - optional prefix for log lines (e.g., 'server', 'env')
46
46
  */
47
47
  export const log_env_validation_error = (error, label) => {
48
48
  const prefix = label ? `[${label}] ` : '';
@@ -19,6 +19,7 @@ effects, see ../../../docs/architecture.md.
19
19
  - `http/error_schemas.ts` — `ERROR_*` constants, standard error shapes, `derive_error_schemas`.
20
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`.
21
21
  - `http/middleware_spec.ts` — `MiddlewareSpec` interface.
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).
22
23
  - `http/surface.ts` — `AppSurface`, `AppSurfaceSpec`, `generate_app_surface`, diagnostics.
23
24
  - `http/surface_query.ts` — pure filters/groupings over `AppSurface`.
24
25
  - `http/proxy.ts` — trusted-proxy middleware, CIDR parsing, rightmost-first XFF resolution. Pulls `hono/utils/ipaddr` for CIDR matching.
@@ -207,7 +208,7 @@ confirmation.
207
208
  ### `ERROR_*` constants by category
208
209
 
209
210
  - **Validation**: `ERROR_INVALID_REQUEST_BODY`, `ERROR_INVALID_JSON_BODY`, `ERROR_INVALID_ROUTE_PARAMS`, `ERROR_INVALID_QUERY_PARAMS`
210
- - **Auth**: `ERROR_AUTHENTICATION_REQUIRED`, `ERROR_INSUFFICIENT_PERMISSIONS`, `ERROR_CREDENTIAL_TYPE_REQUIRED`, `ERROR_RATE_LIMIT_EXCEEDED`, `ERROR_INVALID_CREDENTIALS`, `ERROR_PAYLOAD_TOO_LARGE`
211
+ - **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`
211
212
  - **Origin + bearer**: `ERROR_FORBIDDEN_ORIGIN`, `ERROR_INVALID_TOKEN`, `ERROR_ACCOUNT_NOT_FOUND`
212
213
  - **Keeper/daemon**: `ERROR_KEEPER_ACCOUNT_NOT_FOUND`
213
214
  - **Bootstrap**: `ERROR_ALREADY_BOOTSTRAPPED`, `ERROR_TOKEN_FILE_MISSING`
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Request body size limit — rejects an oversized body with `413`, and a
3
+ * `Content-Length` it cannot read with `400`, before auth and validation.
4
+ *
5
+ * Wraps Hono's `bodyLimit` with a header-first check:
6
+ *
7
+ * - A `Content-Length` that is not a plain run of ASCII digits (`abc`, `-1`,
8
+ * `+5`, `1e9`, `0x1F4`, empty, or a combined `5, 500`) is refused with `400`
9
+ * `{error: 'invalid_content_length'}`. A cap cannot be applied to a length
10
+ * that does not parse, and `bodyLimit` passes such a request on uncounted.
11
+ * The runtimes' HTTP parsers answer their own bodiless `400` to most of
12
+ * these before the application sees them, so this branch is defense in
13
+ * depth where they do and the refusal where they do not: Node's refuses
14
+ * them all; Deno and Bun hand over a repeated equal header as one combined
15
+ * value (`50, 50`) and refuse the rest (observed on Node 24.14.1, Deno
16
+ * 2.8.3, Bun 1.4.3). The Rust spine's parser (hyper) refuses a malformed
17
+ * value and differing repeats, and accepts an equal repeat as the one
18
+ * value.
19
+ * - A request whose `Content-Length` exceeds the cap is refused with `413`
20
+ * `{error: 'payload_too_large'}`, whatever its method. A digit run of any
21
+ * length compares as a number, so one too long to represent exactly is over
22
+ * the cap, never unreadable. Over a socket that branch is reached on Node
23
+ * and Deno, whose parsers hand over any length below 2^64 and refuse a
24
+ * longer one with their own `400`. `Bun.serve` hands none over: with its
25
+ * default options it answers a length past 128 MiB with its own `413`, and
26
+ * one of 2^63 - 1 or more with its own `400` (observed on Node 24.14.1,
27
+ * Deno 2.8.3, Bun 1.4.3).
28
+ * - Both refusals answer on the header alone — without touching
29
+ * `c.req.raw.body` — and carry `Connection: close`.
30
+ * - A request with a well-formed `Content-Length` beside `Transfer-Encoding`,
31
+ * or with no `Content-Length`, falls through to `bodyLimit`, which measures
32
+ * the bytes that arrive: with `Transfer-Encoding` the declared length does
33
+ * not frame the body. `bodyLimit` reads the body into memory, up to the
34
+ * cap, **before** the next middleware runs, so that `413` — sent once more
35
+ * than the cap has been read, with no `Connection: close` — also comes
36
+ * ahead of the origin check, auth and the handler. The Rust spine counts
37
+ * such a body as its handler reads it instead, so there a refusal made on
38
+ * the headers answers first; which status an over-cap body with no declared
39
+ * length gets when another refusal also applies is implementation-defined
40
+ * across the two (`docs/security.md` §"Body Size Limiting").
41
+ * The Node, Deno and Bun parsers refuse a request carrying both headers
42
+ * with their own `400`; hyper accepts one, drops its `Content-Length`,
43
+ * frames the body as chunked, and closes the connection after the response.
44
+ * - A well-formed `Content-Length` within the cap is trusted to frame the
45
+ * body, as the runtime's HTTP parser enforces.
46
+ *
47
+ * What the connection does after the header `413` is the runtime's
48
+ * (`docs/security.md` §"Body Size Limiting"):
49
+ *
50
+ * - **Node** (`@hono/node-server`) closes at once, the body unread. The
51
+ * `Connection: close` header is what does it: without one the adapter
52
+ * holds the connection for a drain window and then closes or, the body
53
+ * untouched and arriving within the window, reads it off and serves the
54
+ * next request.
55
+ * - **Deno** closes once the whole declared body has arrived and holds the
56
+ * connection open while a client withholds it; a request pipelined behind
57
+ * the body is not served. Neither the header nor what the handler does with
58
+ * the body changes that (observed on Deno 2.8.3).
59
+ * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.3
60
+ * is the tested floor: an older Bun kept the connection after the `413` and
61
+ * served the next request (correctly framed), so run Bun at the floor or
62
+ * later.
63
+ *
64
+ * @module
65
+ */
66
+ import type { MiddlewareHandler } from 'hono';
67
+ /**
68
+ * Create the body size limit middleware.
69
+ *
70
+ * @param max_size - the largest accepted body, in bytes
71
+ * @returns middleware answering `413` `{error: 'payload_too_large'}` past the cap and `400` `{error: 'invalid_content_length'}` to a `Content-Length` that is not a run of digits
72
+ */
73
+ export declare const create_body_limit_middleware: (max_size: number) => MiddlewareHandler;
74
+ //# sourceMappingURL=body_limit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body_limit.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/body_limit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAQ9C;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,MAAM,KAAG,iBAwB/D,CAAC"}