@fuzdev/fuz_app 0.162.0 → 0.164.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 (280) hide show
  1. package/README.md +2 -1
  2. package/dist/actions/action_event_data.d.ts +1 -1
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +4 -0
  5. package/dist/actions/action_spec.d.ts +3 -3
  6. package/dist/actions/action_spec.d.ts.map +1 -1
  7. package/dist/auth/CLAUDE.md +39 -36
  8. package/dist/auth/account_action_specs.d.ts +441 -115
  9. package/dist/auth/account_action_specs.d.ts.map +1 -1
  10. package/dist/auth/account_action_specs.js +47 -46
  11. package/dist/auth/account_route_schema.d.ts +98 -62
  12. package/dist/auth/account_route_schema.d.ts.map +1 -1
  13. package/dist/auth/account_route_schema.js +45 -45
  14. package/dist/auth/account_routes.js +1 -1
  15. package/dist/auth/account_schema.d.ts +54 -27
  16. package/dist/auth/account_schema.d.ts.map +1 -1
  17. package/dist/auth/account_schema.js +16 -18
  18. package/dist/auth/admin_action_specs.d.ts +76 -76
  19. package/dist/auth/admin_action_specs.js +2 -4
  20. package/dist/auth/admin_actions.d.ts +4 -4
  21. package/dist/auth/admin_actions.d.ts.map +1 -1
  22. package/dist/auth/admin_actions.js +3 -3
  23. package/dist/auth/all_cell_actions.d.ts +3 -3
  24. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  25. package/dist/auth/all_cell_actions.js +1 -1
  26. package/dist/auth/api_token.d.ts +4 -4
  27. package/dist/auth/api_token.d.ts.map +1 -1
  28. package/dist/auth/api_token.js +3 -3
  29. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  30. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  31. package/dist/auth/audit_log_route_schema.js +4 -5
  32. package/dist/auth/audit_log_schema.d.ts +46 -66
  33. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  34. package/dist/auth/audit_log_schema.js +34 -30
  35. package/dist/auth/bootstrap_route_schema.d.ts +146 -52
  36. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  37. package/dist/auth/bootstrap_route_schema.js +33 -19
  38. package/dist/auth/cell_grant_action_specs.d.ts +1 -1
  39. package/dist/auth/cell_grant_action_specs.js +1 -1
  40. package/dist/auth/cell_grant_actions.d.ts +4 -4
  41. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  42. package/dist/auth/cell_grant_actions.js +1 -1
  43. package/dist/auth/credential_type_schema.d.ts +16 -29
  44. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  45. package/dist/auth/credential_type_schema.js +14 -18
  46. package/dist/auth/daemon_token.d.ts +4 -4
  47. package/dist/auth/daemon_token.d.ts.map +1 -1
  48. package/dist/auth/daemon_token.js +3 -3
  49. package/dist/auth/daemon_token_middleware.d.ts +1 -1
  50. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  51. package/dist/auth/daemon_token_middleware.js +5 -5
  52. package/dist/auth/grant_path_schema.d.ts +15 -29
  53. package/dist/auth/grant_path_schema.d.ts.map +1 -1
  54. package/dist/auth/grant_path_schema.js +13 -17
  55. package/dist/auth/middleware.js +4 -4
  56. package/dist/auth/migrations.js +1 -1
  57. package/dist/auth/name_schema.d.ts +7 -6
  58. package/dist/auth/name_schema.d.ts.map +1 -1
  59. package/dist/auth/name_schema.js +8 -9
  60. package/dist/auth/password.d.ts +15 -7
  61. package/dist/auth/password.d.ts.map +1 -1
  62. package/dist/auth/password.js +16 -9
  63. package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
  64. package/dist/auth/role_grant_offer_action_specs.js +2 -2
  65. package/dist/auth/role_grant_offer_actions.d.ts +4 -4
  66. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  67. package/dist/auth/role_grant_offer_actions.js +3 -3
  68. package/dist/auth/role_grant_offer_notifications.js +2 -2
  69. package/dist/auth/role_grant_offer_schema.d.ts +2 -2
  70. package/dist/auth/role_grant_offer_schema.js +2 -2
  71. package/dist/auth/role_schema.d.ts +47 -55
  72. package/dist/auth/role_schema.d.ts.map +1 -1
  73. package/dist/auth/role_schema.js +29 -35
  74. package/dist/auth/scope_kind_schema.d.ts +22 -26
  75. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  76. package/dist/auth/scope_kind_schema.js +19 -19
  77. package/dist/auth/self_service_role_action_specs.js +1 -1
  78. package/dist/auth/self_service_role_actions.d.ts +6 -6
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +7 -6
  81. package/dist/auth/signup_route_schema.d.ts +71 -21
  82. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  83. package/dist/auth/signup_route_schema.js +17 -19
  84. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  85. package/dist/auth/standard_rpc_actions.js +1 -1
  86. package/dist/auth/token_lifetime.d.ts +33 -9
  87. package/dist/auth/token_lifetime.d.ts.map +1 -1
  88. package/dist/auth/token_lifetime.js +8 -7
  89. package/dist/auth/token_scope.d.ts +99 -25
  90. package/dist/auth/token_scope.d.ts.map +1 -1
  91. package/dist/auth/token_scope.js +57 -35
  92. package/dist/db/CLAUDE.md +2 -1
  93. package/dist/db/file_fact_url.d.ts +11 -6
  94. package/dist/db/file_fact_url.d.ts.map +1 -1
  95. package/dist/db/file_fact_url.js +5 -5
  96. package/dist/db/schema_ready.d.ts +0 -5
  97. package/dist/db/schema_ready.d.ts.map +1 -1
  98. package/dist/db/schema_ready.js +0 -5
  99. package/dist/http/CLAUDE.md +104 -71
  100. package/dist/http/auth_shape.d.ts +48 -29
  101. package/dist/http/auth_shape.d.ts.map +1 -1
  102. package/dist/http/auth_shape.js +12 -85
  103. package/dist/http/body_limit.d.ts +12 -0
  104. package/dist/http/body_limit.d.ts.map +1 -1
  105. package/dist/http/body_limit.js +15 -0
  106. package/dist/http/body_limit_schema.d.ts +20 -0
  107. package/dist/http/body_limit_schema.d.ts.map +1 -0
  108. package/dist/http/body_limit_schema.js +20 -0
  109. package/dist/http/common_routes.d.ts +1 -1
  110. package/dist/http/common_routes.d.ts.map +1 -1
  111. package/dist/http/common_routes.js +11 -14
  112. package/dist/http/db_routes.d.ts.map +1 -1
  113. package/dist/http/db_routes.js +59 -69
  114. package/dist/http/dev_route_error_check.d.ts +70 -0
  115. package/dist/http/dev_route_error_check.d.ts.map +1 -0
  116. package/dist/http/dev_route_error_check.js +119 -0
  117. package/dist/http/error_schemas.d.ts +365 -189
  118. package/dist/http/error_schemas.d.ts.map +1 -1
  119. package/dist/http/error_schemas.js +256 -149
  120. package/dist/http/health_schema.d.ts +10 -6
  121. package/dist/http/health_schema.d.ts.map +1 -1
  122. package/dist/http/health_schema.js +3 -3
  123. package/dist/http/middleware_spec.d.ts +8 -3
  124. package/dist/http/middleware_spec.d.ts.map +1 -1
  125. package/dist/http/origin.d.ts +12 -43
  126. package/dist/http/origin.d.ts.map +1 -1
  127. package/dist/http/origin.js +10 -6
  128. package/dist/http/route_error_check.d.ts +158 -0
  129. package/dist/http/route_error_check.d.ts.map +1 -0
  130. package/dist/http/route_error_check.js +247 -0
  131. package/dist/http/route_errors.d.ts +80 -0
  132. package/dist/http/route_errors.d.ts.map +1 -0
  133. package/dist/http/route_errors.js +83 -0
  134. package/dist/http/route_spec.d.ts +33 -17
  135. package/dist/http/route_spec.d.ts.map +1 -1
  136. package/dist/http/route_spec.js +48 -62
  137. package/dist/http/schema_helpers.d.ts +0 -33
  138. package/dist/http/schema_helpers.d.ts.map +1 -1
  139. package/dist/http/schema_helpers.js +0 -45
  140. package/dist/http/surface.d.ts +19 -12
  141. package/dist/http/surface.d.ts.map +1 -1
  142. package/dist/http/surface.js +25 -38
  143. package/dist/http/surface_query.d.ts +11 -2
  144. package/dist/http/surface_query.d.ts.map +1 -1
  145. package/dist/http/surface_query.js +7 -1
  146. package/dist/primitive_schemas.d.ts +2 -19
  147. package/dist/primitive_schemas.d.ts.map +1 -1
  148. package/dist/primitive_schemas.js +2 -20
  149. package/dist/primitive_schemas_fuz.d.ts +39 -5
  150. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  151. package/dist/primitive_schemas_fuz.js +36 -7
  152. package/dist/rate_limiter.d.ts +13 -0
  153. package/dist/rate_limiter.d.ts.map +1 -1
  154. package/dist/rate_limiter.js +20 -2
  155. package/dist/schema_issues.d.ts +29 -11
  156. package/dist/schema_issues.d.ts.map +1 -1
  157. package/dist/schema_issues.js +11 -10
  158. package/dist/schema_meta.d.ts +8 -1
  159. package/dist/schema_meta.d.ts.map +1 -1
  160. package/dist/schema_meta.js +2 -1
  161. package/dist/server/app_server.d.ts +3 -1
  162. package/dist/server/app_server.d.ts.map +1 -1
  163. package/dist/server/app_server.js +24 -10
  164. package/dist/server/serve_fact_route.d.ts.map +1 -1
  165. package/dist/server/serve_fact_route.js +8 -31
  166. package/dist/server/surface_route.d.ts.map +1 -1
  167. package/dist/server/surface_route.js +5 -6
  168. package/dist/server/x_accel.d.ts +12 -7
  169. package/dist/server/x_accel.d.ts.map +1 -1
  170. package/dist/server/x_accel.js +7 -9
  171. package/dist/testing/CLAUDE.md +55 -44
  172. package/dist/testing/admin_integration.d.ts +3 -3
  173. package/dist/testing/admin_integration.d.ts.map +1 -1
  174. package/dist/testing/admin_integration.js +2 -2
  175. package/dist/testing/adversarial_404.d.ts +4 -18
  176. package/dist/testing/adversarial_404.d.ts.map +1 -1
  177. package/dist/testing/adversarial_404.js +19 -51
  178. package/dist/testing/adversarial_headers.d.ts +3 -4
  179. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  180. package/dist/testing/adversarial_headers.js +8 -6
  181. package/dist/testing/adversarial_input.d.ts.map +1 -1
  182. package/dist/testing/adversarial_input.js +18 -17
  183. package/dist/testing/assertions.d.ts +33 -11
  184. package/dist/testing/assertions.d.ts.map +1 -1
  185. package/dist/testing/assertions.js +52 -12
  186. package/dist/testing/attack_surface.d.ts +5 -35
  187. package/dist/testing/attack_surface.d.ts.map +1 -1
  188. package/dist/testing/attack_surface.js +29 -91
  189. package/dist/testing/auth_apps.d.ts.map +1 -1
  190. package/dist/testing/auth_apps.js +2 -1
  191. package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
  192. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  193. package/dist/testing/cross_backend/action_manifest.js +11 -11
  194. package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
  195. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  196. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/cell_crud.js +2 -1
  198. package/dist/testing/cross_backend/conformance_table.js +1 -1
  199. package/dist/testing/cross_backend/default_spine_surface.d.ts +2 -2
  200. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  201. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  202. package/dist/testing/cross_backend/fact_serving.js +3 -3
  203. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  204. package/dist/testing/cross_backend/identity_parity.js +39 -6
  205. package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
  206. package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
  207. package/dist/testing/cross_backend/origin_conformance.js +21 -21
  208. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
  209. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  210. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
  211. package/dist/testing/cross_backend/setup.d.ts +14 -1
  212. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  213. package/dist/testing/cross_backend/setup.js +68 -48
  214. package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
  215. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  216. package/dist/testing/cross_backend/standard.d.ts +4 -4
  217. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  218. package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
  219. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  220. package/dist/testing/cross_backend/testing_origin_check.js +16 -13
  221. package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
  222. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  224. package/dist/testing/cross_backend/token_lifetime.js +34 -1
  225. package/dist/testing/data_exposure.d.ts.map +1 -1
  226. package/dist/testing/data_exposure.js +5 -4
  227. package/dist/testing/error_coverage.d.ts +24 -34
  228. package/dist/testing/error_coverage.d.ts.map +1 -1
  229. package/dist/testing/error_coverage.js +46 -89
  230. package/dist/testing/integration.d.ts.map +1 -1
  231. package/dist/testing/integration.js +6 -14
  232. package/dist/testing/integration_helpers.d.ts +37 -9
  233. package/dist/testing/integration_helpers.d.ts.map +1 -1
  234. package/dist/testing/integration_helpers.js +86 -40
  235. package/dist/testing/middleware.d.ts +3 -5
  236. package/dist/testing/middleware.d.ts.map +1 -1
  237. package/dist/testing/middleware.js +5 -4
  238. package/dist/testing/rate_limiting.d.ts +1 -1
  239. package/dist/testing/rate_limiting.d.ts.map +1 -1
  240. package/dist/testing/rate_limiting.js +5 -4
  241. package/dist/testing/round_trip.d.ts.map +1 -1
  242. package/dist/testing/round_trip.js +5 -3
  243. package/dist/testing/schema_generators.d.ts +10 -3
  244. package/dist/testing/schema_generators.d.ts.map +1 -1
  245. package/dist/testing/schema_generators.js +23 -11
  246. package/dist/testing/stubs.d.ts +10 -1
  247. package/dist/testing/stubs.d.ts.map +1 -1
  248. package/dist/testing/stubs.js +15 -5
  249. package/dist/testing/surface_invariants.d.ts +36 -115
  250. package/dist/testing/surface_invariants.d.ts.map +1 -1
  251. package/dist/testing/surface_invariants.js +106 -269
  252. package/dist/testing/token_scope_fixtures.d.ts +24 -0
  253. package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
  254. package/dist/testing/token_scope_fixtures.js +49 -0
  255. package/dist/testing/transports/bootstrap.d.ts +1 -1
  256. package/dist/testing/transports/bootstrap.d.ts.map +1 -1
  257. package/dist/testing/transports/bootstrap.js +13 -12
  258. package/dist/ui/BootstrapForm.svelte +4 -2
  259. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
  260. package/dist/ui/CLAUDE.md +4 -2
  261. package/dist/ui/SignupForm.svelte +4 -2
  262. package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
  263. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  264. package/dist/ui/auth_state.svelte.js +2 -8
  265. package/dist/ui/backend_probe.svelte.js +3 -3
  266. package/dist/ui/table_state.svelte.d.ts.map +1 -1
  267. package/dist/ui/table_state.svelte.js +1 -8
  268. package/dist/ui/ui_fetch.d.ts +12 -2
  269. package/dist/ui/ui_fetch.d.ts.map +1 -1
  270. package/dist/ui/ui_fetch.js +22 -4
  271. package/package.json +1 -1
  272. package/dist/auth/audit_log_schema_fuz.d.ts +0 -53
  273. package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
  274. package/dist/auth/audit_log_schema_fuz.js +0 -50
  275. package/dist/auth/role_schema_fuz.d.ts +0 -30
  276. package/dist/auth/role_schema_fuz.d.ts.map +0 -1
  277. package/dist/auth/role_schema_fuz.js +0 -30
  278. package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
  279. package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
  280. package/dist/auth/scope_kind_schema_fuz.js +0 -31
@@ -7,11 +7,11 @@
7
7
  *
8
8
  * @module
9
9
  */
10
- import { z } from 'zod';
11
10
  import { timingSafeEqual } from 'node:crypto';
11
+ import { message, pipe, regex, string } from '@fuzdev/fuz_schema/schema.ts';
12
12
  import { generate_random_base64url } from '../crypto.js';
13
- /** Daemon token format: 43 base64url characters (256 bits). */
14
- export const DaemonToken = z.string().regex(/^[A-Za-z0-9_-]{43}$/, 'Invalid daemon token format');
13
+ /** Daemon token format, a `@fuzdev/fuz_schema` schema: 43 base64url characters (256 bits). */
14
+ export const DaemonToken = pipe(string, message(regex(/^[A-Za-z0-9_-]{43}$/), 'Invalid daemon token format'));
15
15
  /** The `X-Daemon-Token` header name. */
16
16
  export const DAEMON_TOKEN_HEADER = 'X-Daemon-Token';
17
17
  /**
@@ -50,7 +50,7 @@ export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<str
50
50
  * 401, so downstream auth enforcement returns `credential_type_required`
51
51
  * (not a hard fail). Silent on the wire (anti-enumeration); in `DEV` only,
52
52
  * sets `X-Fuz-Auth-Debug: daemon_token_discarded_browser_context`.
53
- * - Header present + Zod-invalid (malformed): soft-fail discard (pass through,
53
+ * - Header present + malformed (fails `DaemonToken`): soft-fail discard (pass through,
54
54
  * not 401) — mirrors the bearer guard and the Rust spine's `resolve.rs`
55
55
  * (`None`). Downstream a daemon-gated action returns `credential_type_required`;
56
56
  * a public action proceeds anonymous.
@@ -1 +1 @@
1
- {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBAkFF,CAAC"}
1
+ {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAOtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBAiFF,CAAC"}
@@ -14,6 +14,7 @@
14
14
  * @module
15
15
  */
16
16
  import { DEV } from 'esm-env';
17
+ import { is } from '@fuzdev/fuz_schema/schema.ts';
17
18
  import { RESOLVED_AUTH_KEY } from '../hono_context.js';
18
19
  import { get_resolved_auth } from './resolved_auth.js';
19
20
  import { is_browser_context } from '../http/origin.js';
@@ -55,7 +56,7 @@ export const resolve_keeper_account_id = async (deps) => {
55
56
  * 401, so downstream auth enforcement returns `credential_type_required`
56
57
  * (not a hard fail). Silent on the wire (anti-enumeration); in `DEV` only,
57
58
  * sets `X-Fuz-Auth-Debug: daemon_token_discarded_browser_context`.
58
- * - Header present + Zod-invalid (malformed): soft-fail discard (pass through,
59
+ * - Header present + malformed (fails `DaemonToken`): soft-fail discard (pass through,
59
60
  * not 401) — mirrors the bearer guard and the Rust spine's `resolve.rs`
60
61
  * (`None`). Downstream a daemon-gated action returns `credential_type_required`;
61
62
  * a public action proceeds anonymous.
@@ -108,14 +109,13 @@ export const create_daemon_token_middleware = (state, deps, log) => {
108
109
  await next();
109
110
  return;
110
111
  }
111
- // Zod-validate the token format at the I/O boundary. A malformed token is
112
+ // Validate the token format at the I/O boundary. A malformed token is
112
113
  // a soft-fail discard (pass through), not a 401 — mirroring the bearer
113
114
  // guard and the Rust spine's `resolve.rs`, which return `None` on an
114
115
  // unparseable credential. The request falls through: on a daemon-gated
115
116
  // action the dispatcher returns `credential_type_required` downstream; on
116
117
  // a public action it proceeds anonymous.
117
- const parse_result = DaemonToken.safeParse(token_header);
118
- if (!parse_result.success) {
118
+ if (!is(DaemonToken, token_header)) {
119
119
  log.debug('daemon token auth soft-fail: malformed token');
120
120
  await next();
121
121
  return;
@@ -123,7 +123,7 @@ export const create_daemon_token_middleware = (state, deps, log) => {
123
123
  // Well-formed but not the current/previous token — soft-fail discard, not
124
124
  // a 401, for the same reason: no downgrade, falls through to downstream
125
125
  // `credential_type_required` (matching the Rust spine's `None`).
126
- if (!validate_daemon_token(parse_result.data, state)) {
126
+ if (!validate_daemon_token(token_header, state)) {
127
127
  log.debug('daemon token auth soft-fail: token not found or invalid');
128
128
  await next();
129
129
  return;
@@ -24,14 +24,14 @@
24
24
  *
25
25
  * @module
26
26
  */
27
- import { z } from 'zod';
27
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
28
28
  /**
29
- * Zod schema for valid grant-path name strings: the shared name grammar
29
+ * Valid grant-path name strings: the shared name grammar
30
30
  * (`auth/name_schema.ts`), runs of lowercase letters joined by single
31
31
  * underscores, at most `NAME_LENGTH_MAX` characters.
32
32
  */
33
- export declare const GrantPathName: z.ZodString;
34
- export type GrantPathName = z.infer<typeof GrantPathName>;
33
+ export declare const GrantPathName: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
34
+ export type GrantPathName = Infer<typeof GrantPathName>;
35
35
  /** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
36
36
  export declare const GRANT_PATH_ADMIN = "admin";
37
37
  /** Self-service grant — caller toggles their own role_grant via `self_service_role_set`. */
@@ -42,14 +42,8 @@ export declare const GRANT_PATH_SYSTEM = "system";
42
42
  export declare const GRANT_PATH_BOOTSTRAP = "bootstrap";
43
43
  /** The builtin grant-path names as a const tuple. */
44
44
  export declare const BUILTIN_GRANT_PATHS: readonly ["admin", "self_service", "system", "bootstrap"];
45
- /** Zod enum for builtin grant paths only. */
46
- export declare const BuiltinGrantPath: z.ZodEnum<{
47
- admin: "admin";
48
- self_service: "self_service";
49
- system: "system";
50
- bootstrap: "bootstrap";
51
- }>;
52
- export type BuiltinGrantPath = z.infer<typeof BuiltinGrantPath>;
45
+ /** A builtin grant-path name. */
46
+ export type BuiltinGrantPath = (typeof BUILTIN_GRANT_PATHS)[number];
53
47
  /**
54
48
  * Per-grant-path metadata. `description` is admin-UI-facing copy
55
49
  * (mirrors `RoleSpec.description` and `ScopeKindMeta.description`).
@@ -64,20 +58,12 @@ export interface GrantPathMeta {
64
58
  * Typed `ReadonlyMap` for the contract — but JS Maps don't honor
65
59
  * `Object.freeze` for `.set` / `.delete` / `.clear` (they mutate
66
60
  * internal slots, not own properties), so freeze adds no runtime guard
67
- * here. Read once at startup by `create_grant_path_schema`; runtime
61
+ * here. Read once at startup by `create_grant_path_registry`; runtime
68
62
  * mutation has no effect on already-built schemas.
69
63
  */
70
64
  export declare const builtin_grant_path_meta: ReadonlyMap<string, GrantPathMeta>;
71
- /** The result of `create_grant_path_schema` — a Zod schema and metadata map. */
72
- export interface GrantPathSchemaResult {
73
- /**
74
- * Zod schema that validates grant-path name strings against the
75
- * registered set (builtins + consumer-declared). Use at I/O
76
- * boundaries (admin UIs, codegen) and as the construction-time check
77
- * inside `create_role_schema` for every `RoleSpec.grant_paths`
78
- * entry.
79
- */
80
- GrantPath: z.ZodType<string>;
65
+ /** The result of `create_grant_path_registry` — the metadata map. */
66
+ export interface GrantPathRegistry {
81
67
  /**
82
68
  * Map of every registered grant-path to its metadata. Keyed by
83
69
  * name. Read at startup by admin / codegen surfaces.
@@ -85,30 +71,30 @@ export interface GrantPathSchemaResult {
85
71
  grant_paths: ReadonlyMap<string, GrantPathMeta>;
86
72
  }
87
73
  /**
88
- * Create a grant-path schema from the builtin set plus optional
74
+ * Create a grant-path registry from the builtin set plus optional
89
75
  * consumer-declared additions.
90
76
  *
91
77
  * Builtins (`admin`, `self_service`, `system`, `bootstrap`) are always
92
78
  * present; consumer entries that collide with a builtin name throw at
93
- * construction. Pass the result into `create_role_schema`'s optional
79
+ * construction. Pass the result into `create_role_registry`'s optional
94
80
  * `grant_paths` parameter so each role's `grant_paths` entries are
95
81
  * validated against this set at construction time.
96
82
  *
97
83
  * @param consumer_paths - optional consumer-declared grant-path set with optional metadata
98
- * @returns `{GrantPath, grant_paths}` — Zod schema and metadata map
84
+ * @returns `{grant_paths}` — the metadata map
99
85
  *
100
86
  * @throws Error if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once
101
87
  *
102
88
  * @example
103
89
  * ```ts
104
90
  * // simple — builtins only
105
- * const {GrantPath, grant_paths} = create_grant_path_schema();
91
+ * const {grant_paths} = create_grant_path_registry();
106
92
  *
107
93
  * // with consumer extensions
108
- * const {GrantPath} = create_grant_path_schema({
94
+ * const {grant_paths} = create_grant_path_registry({
109
95
  * invite_only: {description: 'Granted by claiming a consumer-issued invite.'},
110
96
  * });
111
97
  * ```
112
98
  */
113
- export declare const create_grant_path_schema: (consumer_paths?: Record<string, GrantPathMeta>) => GrantPathSchemaResult;
99
+ export declare const create_grant_path_registry: (consumer_paths?: Record<string, GrantPathMeta>) => GrantPathRegistry;
114
100
  //# sourceMappingURL=grant_path_schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,aAAa,aAAmC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAI1D,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2DAKtB,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;;;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAuBrE,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,wBAAwB,GACpC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,qBA2BF,CAAC"}
1
+ {"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAI/E;;;;GAIG;AACH,eAAO,MAAM,aAAa,0MAAmC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAIxD,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2DAKtB,CAAC;AAEX,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAuBrE,CAAC;AAEH,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,0BAA0B,GACtC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,iBAwBF,CAAC"}
@@ -24,10 +24,10 @@
24
24
  *
25
25
  * @module
26
26
  */
27
- import { z } from 'zod';
27
+ import { format_issue, parse } from '@fuzdev/fuz_schema/schema.ts';
28
28
  import { create_name_schema } from './name_schema.js';
29
29
  /**
30
- * Zod schema for valid grant-path name strings: the shared name grammar
30
+ * Valid grant-path name strings: the shared name grammar
31
31
  * (`auth/name_schema.ts`), runs of lowercase letters joined by single
32
32
  * underscores, at most `NAME_LENGTH_MAX` characters.
33
33
  */
@@ -48,15 +48,13 @@ export const BUILTIN_GRANT_PATHS = [
48
48
  GRANT_PATH_SYSTEM,
49
49
  GRANT_PATH_BOOTSTRAP
50
50
  ];
51
- /** Zod enum for builtin grant paths only. */
52
- export const BuiltinGrantPath = z.enum(BUILTIN_GRANT_PATHS);
53
51
  /**
54
52
  * Builtin grant-path metadata. Not overridable by consumers.
55
53
  *
56
54
  * Typed `ReadonlyMap` for the contract — but JS Maps don't honor
57
55
  * `Object.freeze` for `.set` / `.delete` / `.clear` (they mutate
58
56
  * internal slots, not own properties), so freeze adds no runtime guard
59
- * here. Read once at startup by `create_grant_path_schema`; runtime
57
+ * here. Read once at startup by `create_grant_path_registry`; runtime
60
58
  * mutation has no effect on already-built schemas.
61
59
  */
62
60
  export const builtin_grant_path_meta = new Map([
@@ -82,38 +80,38 @@ export const builtin_grant_path_meta = new Map([
82
80
  ]
83
81
  ]);
84
82
  /**
85
- * Create a grant-path schema from the builtin set plus optional
83
+ * Create a grant-path registry from the builtin set plus optional
86
84
  * consumer-declared additions.
87
85
  *
88
86
  * Builtins (`admin`, `self_service`, `system`, `bootstrap`) are always
89
87
  * present; consumer entries that collide with a builtin name throw at
90
- * construction. Pass the result into `create_role_schema`'s optional
88
+ * construction. Pass the result into `create_role_registry`'s optional
91
89
  * `grant_paths` parameter so each role's `grant_paths` entries are
92
90
  * validated against this set at construction time.
93
91
  *
94
92
  * @param consumer_paths - optional consumer-declared grant-path set with optional metadata
95
- * @returns `{GrantPath, grant_paths}` — Zod schema and metadata map
93
+ * @returns `{grant_paths}` — the metadata map
96
94
  *
97
95
  * @throws Error if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once
98
96
  *
99
97
  * @example
100
98
  * ```ts
101
99
  * // simple — builtins only
102
- * const {GrantPath, grant_paths} = create_grant_path_schema();
100
+ * const {grant_paths} = create_grant_path_registry();
103
101
  *
104
102
  * // with consumer extensions
105
- * const {GrantPath} = create_grant_path_schema({
103
+ * const {grant_paths} = create_grant_path_registry({
106
104
  * invite_only: {description: 'Granted by claiming a consumer-issued invite.'},
107
105
  * });
108
106
  * ```
109
107
  */
110
- export const create_grant_path_schema = (consumer_paths = {}) => {
108
+ export const create_grant_path_registry = (consumer_paths = {}) => {
111
109
  const consumer_names = Object.keys(consumer_paths);
112
110
  const seen = new Set();
113
111
  for (const name of consumer_names) {
114
- const parsed = GrantPathName.safeParse(name);
115
- if (!parsed.success) {
116
- throw new Error(`Invalid grant-path name "${name}": ${parsed.error.issues[0].message}`);
112
+ const parsed = parse(GrantPathName, name);
113
+ if (!parsed.ok) {
114
+ throw new Error(`Invalid grant-path name "${name}": ${format_issue(parsed.issues[0])}`);
117
115
  }
118
116
  if (builtin_grant_path_meta.has(name)) {
119
117
  throw new Error(`Consumer grant-path "${name}" collides with builtin grant-path`);
@@ -123,11 +121,9 @@ export const create_grant_path_schema = (consumer_paths = {}) => {
123
121
  }
124
122
  seen.add(name);
125
123
  }
126
- const all_names = [...BUILTIN_GRANT_PATHS, ...consumer_names];
127
- const GrantPath = z.enum(all_names);
128
124
  const grant_paths = new Map(builtin_grant_path_meta);
129
125
  for (const name of consumer_names) {
130
126
  grant_paths.set(name, consumer_paths[name]);
131
127
  }
132
- return { GrantPath, grant_paths };
128
+ return { grant_paths };
133
129
  };
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import { ApiError } from '../http/error_schemas.js';
9
+ import { REST_FORBIDDEN_ORIGIN } from '../http/error_schemas.js';
10
10
  import { middleware_applies, middleware_paths_overlap } from '../http/schema_helpers.js';
11
11
  /**
12
12
  * The Hono path pattern the origin check mounts on — every path. A request to
@@ -246,7 +246,7 @@ export const create_auth_middleware_specs = async (deps, options) => {
246
246
  name: 'origin',
247
247
  path: ORIGIN_MIDDLEWARE_PATH,
248
248
  handler: verify_request_source(allowed_origins, origin_carve_outs),
249
- errors: { 403: ApiError },
249
+ errors: [REST_FORBIDDEN_ORIGIN],
250
250
  ...(origin_carve_outs.length > 0 && { carve_outs: origin_carve_outs })
251
251
  };
252
252
  let daemon_token_spec = null;
@@ -261,7 +261,7 @@ export const create_auth_middleware_specs = async (deps, options) => {
261
261
  // session and bearer legs, then the dispatcher's credential gate
262
262
  // (matching the Rust spine's `None`). The layer returns no error
263
263
  // response of its own.
264
- errors: {}
264
+ errors: []
265
265
  };
266
266
  }
267
267
  const specs = [
@@ -280,7 +280,7 @@ export const create_auth_middleware_specs = async (deps, options) => {
280
280
  // happens downstream — the RPC dispatcher's pre-authorization /
281
281
  // post-authorization auth gates, or `require_auth` / `require_role` on
282
282
  // REST — producing consistent JSON-RPC or route-level errors.
283
- errors: {}
283
+ errors: []
284
284
  }
285
285
  ];
286
286
  return specs;
@@ -69,7 +69,7 @@ const AUTH_MIGRATION_NAMESPACE = 'fuz_auth';
69
69
  * partial unique index is scoped by
70
70
  * `(to_account, role, scope_kind, scope, from_actor)` so multiple
71
71
  * grantors may coexist. `scope_kind` is informative-only in v1
72
- * (registry-membership validation against `create_scope_kind_schema`);
72
+ * (registry-membership validation against `create_scope_kind_registry`);
73
73
  * v2 may add INSERT-time `(role, scope_kind)` enforcement.
74
74
  */
75
75
  const AUTH_MIGRATIONS = [
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * @module
15
15
  */
16
- import type { z } from 'zod';
16
+ import { type PipeSchema, type string } from '@fuzdev/fuz_schema/schema.ts';
17
17
  /**
18
18
  * The longest name the grammar admits, in UTF-16 code units (what
19
19
  * `String.length` measures; for a name on `NAME_REGEX` they are its
@@ -51,13 +51,14 @@ export declare const format_name_length_message: (label: string) => string;
51
51
  */
52
52
  export declare const format_name_pattern_message: (label: string) => string;
53
53
  /**
54
- * A Zod schema for a name of one domain: `bounded_string` at
55
- * `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
56
- * string both too long and off the grammar gets both issues, the length one
57
- * first.
54
+ * A `@fuzdev/fuz_schema` schema for a name of one domain: `bounded_string`
55
+ * at `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
56
+ * string both too long and off the grammar gets the one length issue, as the
57
+ * `pipe` stops at its first failing step; a value that is no string gets
58
+ * fuz_schema's message. Its JSON Schema is `maxLength` and `pattern`.
58
59
  *
59
60
  * @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
60
61
  * @returns the name schema
61
62
  */
62
- export declare const create_name_schema: (label: string) => z.ZodString;
63
+ export declare const create_name_schema: (label: string) => PipeSchema<string, PipeSchema<string, typeof string>>;
63
64
  //# sourceMappingURL=name_schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"name_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/name_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAyB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OACW,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,KAAG,MACI,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,MACuD,CAAC;AAEpH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,CAAC,CAAC,SAII,CAAC"}
1
+ {"version":3,"file":"name_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/name_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAIlG;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAyB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OACW,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,KAAG,MACI,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,MACuD,CAAC;AAEpH;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC9B,OAAO,MAAM,KACX,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,MAAM,CAAC,CAIrD,CAAC"}
@@ -13,7 +13,8 @@
13
13
  *
14
14
  * @module
15
15
  */
16
- import { bounded_string } from '../primitive_schemas.js';
16
+ import { message, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
17
+ import { bounded_string } from '../primitive_schemas_fuz.js';
17
18
  /**
18
19
  * The longest name the grammar admits, in UTF-16 code units (what
19
20
  * `String.length` measures; for a name on `NAME_REGEX` they are its
@@ -51,15 +52,13 @@ export const format_name_length_message = (label) => `${label} names must be at
51
52
  */
52
53
  export const format_name_pattern_message = (label) => `${label} names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores`;
53
54
  /**
54
- * A Zod schema for a name of one domain: `bounded_string` at
55
- * `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
56
- * string both too long and off the grammar gets both issues, the length one
57
- * first.
55
+ * A `@fuzdev/fuz_schema` schema for a name of one domain: `bounded_string`
56
+ * at `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
57
+ * string both too long and off the grammar gets the one length issue, as the
58
+ * `pipe` stops at its first failing step; a value that is no string gets
59
+ * fuz_schema's message. Its JSON Schema is `maxLength` and `pattern`.
58
60
  *
59
61
  * @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
60
62
  * @returns the name schema
61
63
  */
62
- export const create_name_schema = (label) => bounded_string({
63
- max: NAME_LENGTH_MAX,
64
- max_message: format_name_length_message(label)
65
- }).regex(NAME_REGEX, format_name_pattern_message(label));
64
+ export const create_name_schema = (label) => pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: format_name_length_message(label) }), message(regex(NAME_REGEX), format_name_pattern_message(label)));
@@ -6,17 +6,25 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import { z } from 'zod';
9
+ import type { Infer } from '@fuzdev/fuz_schema/schema.ts';
10
10
  /** Minimum password length, in UTF-16 code units (OWASP recommendation). */
11
11
  export declare const PASSWORD_LENGTH_MIN = 12;
12
12
  /** Maximum password length, in UTF-16 code units. Caps hashing cost to prevent DoS via oversized passwords. */
13
13
  export declare const PASSWORD_LENGTH_MAX = 300;
14
- /** Password for account creation or password change — enforces current length policy. Also usable for client-side UX validation. */
15
- export declare const Password: z.ZodString;
16
- export type Password = z.infer<typeof Password>;
17
- /** Password submitted for login or verification — minimal validation for forward-compatibility if length requirements change. */
18
- export declare const PasswordProvided: z.ZodString;
19
- export type PasswordProvided = z.infer<typeof PasswordProvided>;
14
+ /**
15
+ * Password for account creation or password change — enforces current length
16
+ * policy. Also usable for client-side UX validation. A `@fuzdev/fuz_schema`
17
+ * schema.
18
+ */
19
+ export declare const Password: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
20
+ export type Password = Infer<typeof Password>;
21
+ /**
22
+ * Password submitted for login or verification — minimal validation for
23
+ * forward-compatibility if length requirements change. A `@fuzdev/fuz_schema`
24
+ * schema.
25
+ */
26
+ export declare const PasswordProvided: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
27
+ export type PasswordProvided = Infer<typeof PasswordProvided>;
20
28
  /**
21
29
  * Injectable password hashing dependencies.
22
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"password.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/password.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,+GAA+G;AAC/G,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,oIAAoI;AACpI,eAAO,MAAM,QAAQ,aAGa,CAAC;AACnC,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,iIAAiI;AACjI,eAAO,MAAM,gBAAgB,aAE3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAChC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/E,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD"}
1
+ {"version":3,"file":"password.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/password.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAI1D,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,+GAA+G;AAC/G,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,+IAKpB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,+IAE3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAChC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/E,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD"}
@@ -6,18 +6,25 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import { z } from 'zod';
10
- import { bounded_string } from '../primitive_schemas.js';
9
+ import { meta } from '@fuzdev/fuz_schema/meta.ts';
10
+ import { bounded_string } from '../primitive_schemas_fuz.js';
11
11
  /** Minimum password length, in UTF-16 code units (OWASP recommendation). */
12
12
  export const PASSWORD_LENGTH_MIN = 12;
13
13
  /** Maximum password length, in UTF-16 code units. Caps hashing cost to prevent DoS via oversized passwords. */
14
14
  export const PASSWORD_LENGTH_MAX = 300;
15
- /** Password for account creation or password change — enforces current length policy. Also usable for client-side UX validation. */
16
- export const Password = bounded_string({
17
- min: PASSWORD_LENGTH_MIN,
18
- max: PASSWORD_LENGTH_MAX
19
- }).meta({ sensitivity: 'secret' });
20
- /** Password submitted for login or verification — minimal validation for forward-compatibility if length requirements change. */
21
- export const PasswordProvided = bounded_string({ min: 1, max: PASSWORD_LENGTH_MAX }).meta({
15
+ /**
16
+ * Password for account creation or password change — enforces current length
17
+ * policy. Also usable for client-side UX validation. A `@fuzdev/fuz_schema`
18
+ * schema.
19
+ */
20
+ export const Password = meta(bounded_string({ min: PASSWORD_LENGTH_MIN, max: PASSWORD_LENGTH_MAX }), {
21
+ sensitivity: 'secret'
22
+ });
23
+ /**
24
+ * Password submitted for login or verification — minimal validation for
25
+ * forward-compatibility if length requirements change. A `@fuzdev/fuz_schema`
26
+ * schema.
27
+ */
28
+ export const PasswordProvided = meta(bounded_string({ min: 1, max: PASSWORD_LENGTH_MAX }), {
22
29
  sensitivity: 'secret'
23
30
  });
@@ -2416,7 +2416,7 @@ export declare const role_grant_revoke_action_spec: {
2416
2416
  }>;
2417
2417
  async: true;
2418
2418
  description: string;
2419
- error_reasons: ("role_not_web_grantable" | "role_grant_not_found" | "cannot_revoke_keeper_admin" | "cannot_revoke_last_admin")[];
2419
+ error_reasons: ("cannot_revoke_keeper_admin" | "cannot_revoke_last_admin" | "role_grant_not_found" | "role_not_web_grantable")[];
2420
2420
  rate_limit: "account";
2421
2421
  };
2422
2422
  /**
@@ -2500,7 +2500,7 @@ export declare const role_grant_assign_action_spec: {
2500
2500
  }>;
2501
2501
  async: true;
2502
2502
  description: string;
2503
- error_reasons: ("insufficient_permissions" | "role_not_web_grantable" | "role_grant_offer_not_authorized" | "role_grant_offer_actor_account_mismatch" | "role_grant_builtin_scoped")[];
2503
+ error_reasons: ("insufficient_permissions" | "role_grant_offer_not_authorized" | "role_grant_offer_actor_account_mismatch" | "role_grant_builtin_scoped" | "role_not_web_grantable")[];
2504
2504
  rate_limit: "account";
2505
2505
  };
2506
2506
  /**
@@ -26,8 +26,8 @@ import { array, check, integer, literal, max_value, message, min_value, nullable
26
26
  import { ActingActor, Uuid, bounded_string } from '../primitive_schemas_fuz.js';
27
27
  import { ERROR_INSUFFICIENT_PERMISSIONS, ERROR_LIMIT_INVALID, ERROR_OFFSET_INVALID, ERROR_ROLE_GRANT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
28
28
  import { NAME_LENGTH_MAX } from './name_schema.js';
29
- import { RoleName } from './role_schema_fuz.js';
30
- import { ScopeKindName } from './scope_kind_schema_fuz.js';
29
+ import { RoleName } from './role_schema.js';
30
+ import { ScopeKindName } from './scope_kind_schema.js';
31
31
  import { ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX, RoleGrantOfferJson } from './role_grant_offer_schema.js';
32
32
  import { ROLE_GRANT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
33
33
  /** Error reason — caller tried to offer themselves a role_grant. */
@@ -58,7 +58,7 @@
58
58
  */
59
59
  import type { Logger } from '@fuzdev/fuz_util/log.ts';
60
60
  import { type ActionContext, type RpcAction } from '../actions/action_types.js';
61
- import { type RoleSchemaResult } from './role_schema.js';
61
+ import { type RoleRegistry } from './role_schema.js';
62
62
  import { type RequestContext } from './request_context.js';
63
63
  import type { RevokingActionFactoryDeps } from './deps.js';
64
64
  import { type NotificationSender } from './role_grant_offer_notifications.js';
@@ -92,12 +92,12 @@ export type RoleGrantOfferCreateAuthorize = (auth: RequestContext, input: {
92
92
  /** Options for `create_role_grant_offer_actions`. */
93
93
  export interface RoleGrantOfferActionOptions {
94
94
  /**
95
- * Role schema result from `create_role_schema()`. Defaults to builtin roles only.
95
+ * Role registry from `create_role_registry()`. Defaults to builtin roles only.
96
96
  * Drives the grantability gate: a role is offerable / revocable through
97
97
  * this surface only when its `RoleSpec.grant_paths` includes `'admin'`
98
98
  * (the `GRANT_PATH_ADMIN` constant).
99
99
  */
100
- roles?: RoleSchemaResult;
100
+ roles?: RoleRegistry;
101
101
  /** TTL applied to newly-created offers. Defaults to `ROLE_GRANT_OFFER_DEFAULT_TTL_MS`. */
102
102
  default_ttl_ms?: number;
103
103
  /**
@@ -116,7 +116,7 @@ export interface RoleGrantOfferActionOptions {
116
116
  * `role_grant_revoke` and the immediate `role_grant_assign`.
117
117
  *
118
118
  * @param deps - `RevokingActionFactoryDeps` (`log`, `audit`, and the `connection_closer` a revoked global grant closes the revokee's role-gated connections through) plus optional `notification_sender` for WS fan-out — when absent, WS fan-out is silently skipped (DB-only side effects still happen). Consumers wiring `ConnectionRegistry` assign its instance directly (the registry's `send_to_account` signature accepts the broader `JsonrpcMessageFromServerToClient`, which is contravariantly compatible)
119
- * @param options - role schema, default TTL, authorization override
119
+ * @param options - role registry, default TTL, authorization override
120
120
  * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
121
121
  */
122
122
  export declare const create_role_grant_offer_actions: (deps: RevokingActionFactoryDeps & {
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_offer_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAMN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAgC1B,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAQN,KAAK,kBAAkB,EACvB,MAAM,qCAAqC,CAAC;AA4C7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAC3C,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE;IACN,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,EACD,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EACrB,GAAG,EAAE,aAAa,KACd,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC1C;AA6CD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,yBAAyB,GAAG;IACjC,mBAAmB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAChD,EACD,UAAS,2BAAgC,KACvC,KAAK,CAAC,SAAS,CAutBjB,CAAC"}
1
+ {"version":3,"file":"role_grant_offer_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAMN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAgC1B,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAQN,KAAK,kBAAkB,EACvB,MAAM,qCAAqC,CAAC;AA4C7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAC3C,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE;IACN,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,EACD,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EACrB,GAAG,EAAE,aAAa,KACd,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC1C;AA6CD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,yBAAyB,GAAG;IACjC,mBAAmB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAChD,EACD,UAAS,2BAAgC,KACvC,KAAK,CAAC,SAAS,CAutBjB,CAAC"}
@@ -60,7 +60,7 @@ import { rpc_action } from '../actions/action_types.js';
60
60
  import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
61
61
  import { emit_after_commit } from '../http/pending_effects.js';
62
62
  import { queue_connection_close } from '../actions/connection_closer.js';
63
- import { builtin_role_specs_by_name, is_builtin_role, ROLE_ADMIN, ROLE_KEEPER, role_has_grant_path } from './role_schema.js';
63
+ import { builtin_role_specs, is_builtin_role, ROLE_ADMIN, ROLE_KEEPER, role_has_grant_path } from './role_schema.js';
64
64
  import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
65
65
  import { ROLE_GRANT_OFFER_DEFAULT_TTL_MS, to_role_grant_offer_json } from './role_grant_offer_schema.js';
66
66
  import { query_role_grant_offer_create, query_role_grant_offer_decline, query_role_grant_offer_retract, query_role_grant_offer_list, query_role_grant_offer_history_for_account, query_accept_offer, RoleGrantOfferActorAccountMismatchError, RoleGrantOfferActorMismatchError, RoleGrantOfferAlreadyTerminalError, RoleGrantOfferBuiltinRefusedError, RoleGrantOfferExpiredError, RoleGrantOfferNotFoundError, RoleGrantOfferSelfTargetError, query_role_grant_offer_supersede_outgoing } from './role_grant_offer_queries.js';
@@ -110,7 +110,7 @@ const default_authorize = async (auth, _input, _deps, _ctx) => {
110
110
  * `role_grant_revoke` and the immediate `role_grant_assign`.
111
111
  *
112
112
  * @param deps - `RevokingActionFactoryDeps` (`log`, `audit`, and the `connection_closer` a revoked global grant closes the revokee's role-gated connections through) plus optional `notification_sender` for WS fan-out — when absent, WS fan-out is silently skipped (DB-only side effects still happen). Consumers wiring `ConnectionRegistry` assign its instance directly (the registry's `send_to_account` signature accepts the broader `JsonrpcMessageFromServerToClient`, which is contravariantly compatible)
113
- * @param options - role schema, default TTL, authorization override
113
+ * @param options - role registry, default TTL, authorization override
114
114
  * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
115
115
  */
116
116
  export const create_role_grant_offer_actions = (deps, options = {}) => {
@@ -120,7 +120,7 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
120
120
  const notification_sender = deps.notification_sender
121
121
  ? create_validated_notification_sender(deps.notification_sender, log)
122
122
  : null;
123
- const role_specs = options.roles?.role_specs ?? builtin_role_specs_by_name;
123
+ const role_specs = options.roles?.role_specs ?? builtin_role_specs;
124
124
  const default_ttl_ms = options.default_ttl_ms ?? ROLE_GRANT_OFFER_DEFAULT_TTL_MS;
125
125
  const authorize = options.authorize ?? default_authorize;
126
126
  // Every denial path (admin-grant-path gate, scoped builtin, builtin without a
@@ -42,8 +42,8 @@ import { Uuid as UuidSchema, bounded_string } from '../primitive_schemas_fuz.js'
42
42
  import { create_action_event_spec } from '../actions/action_bridge.js';
43
43
  import { create_jsonrpc_notification } from '../http/jsonrpc_helpers.js';
44
44
  import { parse_any } from '../schema_issues.js';
45
- import { RoleName } from './role_schema_fuz.js';
46
- import { ScopeKindName } from './scope_kind_schema_fuz.js';
45
+ import { RoleName } from './role_schema.js';
46
+ import { ScopeKindName } from './scope_kind_schema.js';
47
47
  import { RoleGrantOfferJson } from './role_grant_offer_schema.js';
48
48
  import { ROLE_GRANT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
49
49
  // -- Method constants -------------------------------------------------------
@@ -40,7 +40,7 @@ export interface RoleGrantOffer {
40
40
  * Machine-readable kind tag for the polymorphic `scope_id`. Paired-null
41
41
  * with `scope_id` per the `role_grant_offer_scope_kind_paired` CHECK: both
42
42
  * null (global) or both non-null (scoped). Consumer-declared via
43
- * `create_scope_kind_schema(...)`; v1 keeps validation registry-membership
43
+ * `create_scope_kind_registry(...)`; v1 keeps validation registry-membership
44
44
  * only, with no INSERT-time `(role, scope_kind)` enforcement.
45
45
  */
46
46
  scope_kind: string | null;
@@ -102,7 +102,7 @@ export interface CreateRoleGrantOfferInput {
102
102
  /**
103
103
  * Machine-readable kind for the `scope_id`. Required iff `scope_id` is
104
104
  * set; must be null when `scope_id` is null (DB-level CHECK rejects the
105
- * mismatch). Consumer-declared via `create_scope_kind_schema(...)`.
105
+ * mismatch). Consumer-declared via `create_scope_kind_registry(...)`.
106
106
  */
107
107
  scope_kind?: string | null;
108
108
  scope_id?: Uuid | null;
@@ -14,8 +14,8 @@
14
14
  import { meta } from '@fuzdev/fuz_schema/meta.ts';
15
15
  import { nullable, object } from '@fuzdev/fuz_schema/schema.ts';
16
16
  import { Timestamp, Uuid as UuidSchema, bounded_string } from '../primitive_schemas_fuz.js';
17
- import { RoleName } from './role_schema_fuz.js';
18
- import { ScopeKindName } from './scope_kind_schema_fuz.js';
17
+ import { RoleName } from './role_schema.js';
18
+ import { ScopeKindName } from './scope_kind_schema.js';
19
19
  /** Maximum length of the optional message attached to an offer, and of a decline reason, in UTF-16 code units. */
20
20
  export const ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX = 500;
21
21
  /** Default TTL for a newly created offer — 30 days. Matches GitHub org-invite expiry. */