@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
@@ -37,7 +37,7 @@
37
37
  * @module
38
38
  */
39
39
  import { type RpcAction } from '../actions/action_types.js';
40
- import { type RoleSchemaResult } from './role_schema.js';
40
+ import { type RoleRegistry } from './role_schema.js';
41
41
  import type { RevokingActionFactoryDeps } from './deps.js';
42
42
  /**
43
43
  * Validate a deployment's self-service eligible-role set at construction.
@@ -45,7 +45,7 @@ import type { RevokingActionFactoryDeps } from './deps.js';
45
45
  * Refuses a builtin role (`admin` / `keeper`) — self-toggling one would hand
46
46
  * any account instance-wide authority, so no eligible set may name it — and a
47
47
  * name outside the `RoleName` grammar. The same fail-loud-at-boot shape as
48
- * `create_role_schema`, which refuses a builtin name where only app roles
48
+ * `create_role_registry`, which refuses a builtin name where only app roles
49
49
  * belong. Twin of the Rust `validate_self_service_eligible_roles`.
50
50
  *
51
51
  * @param roles - the eligible role names
@@ -57,7 +57,7 @@ export interface SelfServiceRoleActionsOptions {
57
57
  /**
58
58
  * Optional override allowlist of role strings eligible for
59
59
  * self-service. When omitted, eligibility is derived from
60
- * `roles.role_specs` (or `builtin_role_specs_by_name` when `roles`
60
+ * `roles.role_specs` (or `builtin_role_specs` when `roles`
61
61
  * is also omitted) by selecting every role whose
62
62
  * `RoleSpec.grant_paths` includes `'self_service'`. Pass an empty
63
63
  * array to lock the surface down (every call comes back as
@@ -68,11 +68,11 @@ export interface SelfServiceRoleActionsOptions {
68
68
  */
69
69
  eligible_roles?: ReadonlyArray<string>;
70
70
  /**
71
- * Optional role schema. Drives default eligibility derivation from
71
+ * Optional role registry. Drives default eligibility derivation from
72
72
  * `RoleSpec.grant_paths` and validates the `eligible_roles` override
73
73
  * (when supplied) against the registered role set.
74
74
  */
75
- roles?: RoleSchemaResult;
75
+ roles?: RoleRegistry;
76
76
  }
77
77
  /**
78
78
  * Build the unified self-service role toggle RPC action.
@@ -81,7 +81,7 @@ export interface SelfServiceRoleActionsOptions {
81
81
  * `connection_closer`); `audit.emit` writes a success row in the request
82
82
  * transaction and a failure row via the captured pool, and a disable closes the caller's connections gated on the role
83
83
  * through `connection_closer`.
84
- * @param options - optional eligible-role override plus optional role schema for default-eligibility derivation
84
+ * @param options - optional eligible-role override plus optional role registry for default-eligibility derivation
85
85
  * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
86
86
  * @throws Error at factory time if any `eligible_roles` entry is missing from `options.roles.role_specs`
87
87
  * @throws Error at factory time if the eligible set names a builtin role or an invalid role name
@@ -1 +1 @@
1
- {"version":3,"file":"self_service_role_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/self_service_role_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGjG,OAAO,EAKN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAW3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oCAAoC,GAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAG,IAW9E,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC7C;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,yBAAyB,EAC/B,UAAS,6BAAkC,KACzC,KAAK,CAAC,SAAS,CA0JjB,CAAC"}
1
+ {"version":3,"file":"self_service_role_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/self_service_role_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAW3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oCAAoC,GAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAG,IAW9E,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC7C;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,yBAAyB,EAC/B,UAAS,6BAAkC,KACzC,KAAK,CAAC,SAAS,CA0JjB,CAAC"}
@@ -36,10 +36,11 @@
36
36
  *
37
37
  * @module
38
38
  */
39
+ import { is } from '@fuzdev/fuz_schema/schema.ts';
39
40
  import { rpc_action } from '../actions/action_types.js';
40
41
  import { queue_connection_close } from '../actions/connection_closer.js';
41
42
  import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
42
- import { builtin_role_specs_by_name, is_builtin_role, list_roles_with_grant_path, RoleName } from './role_schema.js';
43
+ import { builtin_role_specs, is_builtin_role, list_roles_with_grant_path, RoleName } from './role_schema.js';
43
44
  import { GRANT_PATH_SELF_SERVICE } from './grant_path_schema.js';
44
45
  import { query_create_role_grant, query_revoke_role_grant } from './role_grant_queries.js';
45
46
  import { is_role_grant_active } from './account_schema.js';
@@ -51,7 +52,7 @@ import { ERROR_ROLE_NOT_SELF_SERVICE_ELIGIBLE, self_service_role_set_action_spec
51
52
  * Refuses a builtin role (`admin` / `keeper`) — self-toggling one would hand
52
53
  * any account instance-wide authority, so no eligible set may name it — and a
53
54
  * name outside the `RoleName` grammar. The same fail-loud-at-boot shape as
54
- * `create_role_schema`, which refuses a builtin name where only app roles
55
+ * `create_role_registry`, which refuses a builtin name where only app roles
55
56
  * belong. Twin of the Rust `validate_self_service_eligible_roles`.
56
57
  *
57
58
  * @param roles - the eligible role names
@@ -62,7 +63,7 @@ export const validate_self_service_eligible_roles = (roles) => {
62
63
  if (is_builtin_role(role)) {
63
64
  throw new Error(`self-service eligible role "${role}" is a builtin role — builtin roles are never self-service`);
64
65
  }
65
- if (!RoleName.safeParse(role).success) {
66
+ if (!is(RoleName, role)) {
66
67
  throw new Error(`self-service eligible role "${role}" is not a valid role name`);
67
68
  }
68
69
  }
@@ -74,13 +75,13 @@ export const validate_self_service_eligible_roles = (roles) => {
74
75
  * `connection_closer`); `audit.emit` writes a success row in the request
75
76
  * transaction and a failure row via the captured pool, and a disable closes the caller's connections gated on the role
76
77
  * through `connection_closer`.
77
- * @param options - optional eligible-role override plus optional role schema for default-eligibility derivation
78
+ * @param options - optional eligible-role override plus optional role registry for default-eligibility derivation
78
79
  * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
79
80
  * @throws Error at factory time if any `eligible_roles` entry is missing from `options.roles.role_specs`
80
81
  * @throws Error at factory time if the eligible set names a builtin role or an invalid role name
81
82
  */
82
83
  export const create_self_service_role_actions = (deps, options = {}) => {
83
- const role_specs = options.roles?.role_specs ?? builtin_role_specs_by_name;
84
+ const role_specs = options.roles?.role_specs ?? builtin_role_specs;
84
85
  const eligible = options.eligible_roles
85
86
  ? new Set(options.eligible_roles)
86
87
  : new Set(list_roles_with_grant_path(role_specs, GRANT_PATH_SELF_SERVICE));
@@ -88,7 +89,7 @@ export const create_self_service_role_actions = (deps, options = {}) => {
88
89
  if (options.eligible_roles && options.roles) {
89
90
  for (const r of eligible) {
90
91
  if (!role_specs.has(r)) {
91
- throw new Error(`create_self_service_role_actions: eligible_roles entry "${r}" is not registered in roles.role_specs — typo or missing call to create_role_schema`);
92
+ throw new Error(`create_self_service_role_actions: eligible_roles entry "${r}" is not registered in roles.role_specs — typo or missing call to create_role_registry`);
92
93
  }
93
94
  }
94
95
  }
@@ -11,33 +11,83 @@
11
11
  *
12
12
  * @module
13
13
  */
14
- import { z } from 'zod';
14
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
15
15
  import type { RouteSpec } from '../http/route_spec.js';
16
- /** Input for `POST /signup`. `email` is optional (absent or `null` = no email) and must match any referenced invite. */
17
- export declare const SignupInput: z.ZodObject<{
18
- username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
19
- password: z.ZodString;
20
- email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
- }, z.core.$strict>;
22
- export type SignupInput = z.infer<typeof SignupInput>;
23
16
  /**
24
- * Output for `POST /signup`.
17
+ * Input for `POST /signup`, a `@fuzdev/fuz_schema` schema. `email` is optional
18
+ * (absent or `null` = no email) and must match any referenced invite.
19
+ */
20
+ export declare const SignupInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
21
+ username: string;
22
+ password: string;
23
+ email?: string | null | undefined;
24
+ }, {
25
+ username: string;
26
+ password: string;
27
+ email?: string | null | undefined;
28
+ }, "object", {
29
+ username: 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>>>;
30
+ password: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
31
+ email: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null | undefined, string | null | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>>>;
32
+ }>;
33
+ export type SignupInput = Infer<typeof SignupInput>;
34
+ /**
35
+ * Output for `POST /signup`, a `@fuzdev/fuz_schema` schema.
25
36
  *
26
37
  * Session cookie is the operative side effect. The returned `account` and
27
38
  * `actor` mirror `BootstrapOutput` so cross-process per-test setup can read
28
- * the per-test identity straight off the signup response.
39
+ * the per-test identity straight off the signup response. Its `username` is
40
+ * the account row's, `UsernameCanonical`.
29
41
  */
30
- export declare const SignupOutput: z.ZodObject<{
31
- ok: z.ZodLiteral<true>;
32
- account: z.ZodObject<{
33
- id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
34
- username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
35
- }, z.core.$strict>;
36
- actor: z.ZodObject<{
37
- id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
38
- }, z.core.$strict>;
39
- }, z.core.$strict>;
40
- export type SignupOutput = z.infer<typeof SignupOutput>;
42
+ export declare const SignupOutput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
43
+ account: {
44
+ id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
45
+ username: string;
46
+ };
47
+ actor: {
48
+ id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
49
+ };
50
+ ok: true;
51
+ }, {
52
+ account: {
53
+ id: string;
54
+ username: string;
55
+ };
56
+ actor: {
57
+ id: string;
58
+ };
59
+ ok: true;
60
+ }, "object", {
61
+ ok: import("@fuzdev/fuz_schema/schema.ts").Schema<true, true, "literal", true>;
62
+ account: import("@fuzdev/fuz_schema/schema.ts").Schema<{
63
+ id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
64
+ username: string;
65
+ }, {
66
+ id: string;
67
+ username: string;
68
+ }, "object", {
69
+ id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
70
+ readonly '~types'?: {
71
+ readonly input: string;
72
+ readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
73
+ } | undefined;
74
+ };
75
+ username: 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>>>;
76
+ }>;
77
+ actor: import("@fuzdev/fuz_schema/schema.ts").Schema<{
78
+ id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
79
+ }, {
80
+ id: string;
81
+ }, "object", {
82
+ id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
83
+ readonly '~types'?: {
84
+ readonly input: string;
85
+ readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
86
+ } | undefined;
87
+ };
88
+ }>;
89
+ }>;
90
+ export type SignupOutput = Infer<typeof SignupOutput>;
41
91
  /** Option inputs that shape the signup route metadata (not its handler). */
42
92
  export interface SignupRouteShapeOptions {
43
93
  /** Whether a per-account signup rate limiter is wired — toggles `rate_limit`. */
@@ -1 +1 @@
1
- {"version":3,"file":"signup_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/signup_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,wHAAwH;AACxH,eAAO,MAAM,WAAW;;;;kBAItB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;;;kBAIvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACvC,iFAAiF;IACjF,2BAA2B,EAAE,OAAO,CAAC;CACrC;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACrC,SAAS,uBAAuB,KAC9B,IAAI,CAAC,SAAS,EAAE,SAAS,CAiB1B,CAAC"}
1
+ {"version":3,"file":"signup_route_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/signup_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAuC,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAK/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;EAItB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACvC,iFAAiF;IACjF,2BAA2B,EAAE,OAAO,CAAC;CACrC;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACrC,SAAS,uBAAuB,KAC9B,IAAI,CAAC,SAAS,EAAE,SAAS,CAW1B,CAAC"}
@@ -11,27 +11,31 @@
11
11
  *
12
12
  * @module
13
13
  */
14
- import { z } from 'zod';
15
- import { Uuid, Username, Email } from '../primitive_schemas.js';
14
+ import { literal, nullable, object, optional } from '@fuzdev/fuz_schema/schema.ts';
15
+ import { Email, Username, UsernameCanonical, Uuid } from '../primitive_schemas_fuz.js';
16
16
  import { Password } from './password.js';
17
- import { ERROR_NO_MATCHING_INVITE, ERROR_SIGNUP_CONFLICT, ERROR_INVALID_JSON_BODY, ERROR_INVALID_REQUEST_BODY } from '../http/error_schemas.js';
18
- /** Input for `POST /signup`. `email` is optional (absent or `null` = no email) and must match any referenced invite. */
19
- export const SignupInput = z.strictObject({
17
+ import { REST_NO_MATCHING_INVITE, REST_SIGNUP_CONFLICT } from '../http/error_schemas.js';
18
+ /**
19
+ * Input for `POST /signup`, a `@fuzdev/fuz_schema` schema. `email` is optional
20
+ * (absent or `null` = no email) and must match any referenced invite.
21
+ */
22
+ export const SignupInput = object({
20
23
  username: Username,
21
24
  password: Password,
22
- email: Email.nullish()
25
+ email: optional(nullable(Email))
23
26
  });
24
27
  /**
25
- * Output for `POST /signup`.
28
+ * Output for `POST /signup`, a `@fuzdev/fuz_schema` schema.
26
29
  *
27
30
  * Session cookie is the operative side effect. The returned `account` and
28
31
  * `actor` mirror `BootstrapOutput` so cross-process per-test setup can read
29
- * the per-test identity straight off the signup response.
32
+ * the per-test identity straight off the signup response. Its `username` is
33
+ * the account row's, `UsernameCanonical`.
30
34
  */
31
- export const SignupOutput = z.strictObject({
32
- ok: z.literal(true),
33
- account: z.strictObject({ id: Uuid, username: Username }),
34
- actor: z.strictObject({ id: Uuid })
35
+ export const SignupOutput = object({
36
+ ok: literal(true),
37
+ account: object({ id: Uuid, username: UsernameCanonical }),
38
+ actor: object({ id: Uuid })
35
39
  });
36
40
  /**
37
41
  * The `POST /signup` route shape minus its handler — pure hono-free data.
@@ -49,11 +53,5 @@ export const create_signup_route_shape = (options) => ({
49
53
  input: SignupInput,
50
54
  output: SignupOutput,
51
55
  rate_limit: options.signup_account_rate_limited ? 'both' : 'ip',
52
- errors: {
53
- 400: z.looseObject({
54
- error: z.enum([ERROR_INVALID_JSON_BODY, ERROR_INVALID_REQUEST_BODY])
55
- }),
56
- 403: z.looseObject({ error: z.literal(ERROR_NO_MATCHING_INVITE) }),
57
- 409: z.looseObject({ error: z.literal(ERROR_SIGNUP_CONFLICT) })
58
- }
56
+ errors: [REST_NO_MATCHING_INVITE, REST_SIGNUP_CONFLICT]
59
57
  });
@@ -56,7 +56,7 @@ export interface StandardRpcActionsDeps extends RevokingActionFactoryDeps {
56
56
  * option flows to admin + role-grant-offer.
57
57
  *
58
58
  * @param deps - `StandardRpcActionsDeps` (`log`, `audit`, `connection_closer` from `RevokingActionFactoryDeps`; optional `notification_sender` for WS fan-out)
59
- * @param options - role schema, role-grant-offer config, account config
59
+ * @param options - role registry, role-grant-offer config, account config
60
60
  * @returns RPC actions to pass as `rpc_endpoints` or spread into `create_rpc_endpoint`
61
61
  */
62
62
  export declare const create_standard_rpc_actions: (deps: StandardRpcActionsDeps, options?: StandardRpcActionsOptions) => Array<RpcAction>;
@@ -31,7 +31,7 @@ import { create_account_actions } from './account_actions.js';
31
31
  * option flows to admin + role-grant-offer.
32
32
  *
33
33
  * @param deps - `StandardRpcActionsDeps` (`log`, `audit`, `connection_closer` from `RevokingActionFactoryDeps`; optional `notification_sender` for WS fan-out)
34
- * @param options - role schema, role-grant-offer config, account config
34
+ * @param options - role registry, role-grant-offer config, account config
35
35
  * @returns RPC actions to pass as `rpc_endpoints` or spread into `create_rpc_endpoint`
36
36
  */
37
37
  export const create_standard_rpc_actions = (deps, options = {}) => [
@@ -19,7 +19,7 @@
19
19
  *
20
20
  * @module
21
21
  */
22
- import { z } from 'zod';
22
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
23
23
  /**
24
24
  * Upper bound on `ttl.days` — a sanity cap (100 years), not a policy ceiling.
25
25
  * Shared with the Rust twin so out-of-range requests 400 identically on both
@@ -27,19 +27,43 @@ import { z } from 'zod';
27
27
  */
28
28
  export declare const TOKEN_TTL_DAYS_MAX = 36500;
29
29
  /**
30
- * Caller-provided lifetime for `account_token_create`.
30
+ * Caller-provided lifetime for `account_token_create`, a `@fuzdev/fuz_schema`
31
+ * schema.
31
32
  *
32
33
  * `eternal` mints a never-expiring token (`expires_at` NULL); `ttl` bounds it
33
34
  * to `days` from mint time. `eternal` is deliberately the first variant so
34
35
  * schema-driven test generators produce it by default.
35
36
  */
36
- export declare const TokenLifetimeInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
37
- kind: z.ZodLiteral<"eternal">;
38
- }, z.core.$strict>, z.ZodObject<{
39
- kind: z.ZodLiteral<"ttl">;
40
- days: z.ZodNumber;
41
- }, z.core.$strict>], "kind">;
42
- export type TokenLifetimeInput = z.infer<typeof TokenLifetimeInput>;
37
+ export declare const TokenLifetimeInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
38
+ kind: "eternal";
39
+ } | {
40
+ kind: "ttl";
41
+ days: number;
42
+ }, {
43
+ kind: "eternal";
44
+ } | {
45
+ kind: "ttl";
46
+ days: number;
47
+ }, "variant", {
48
+ readonly key: "kind";
49
+ readonly options: readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<{
50
+ kind: "eternal";
51
+ }, {
52
+ kind: "eternal";
53
+ }, "object", {
54
+ kind: import("@fuzdev/fuz_schema/schema.ts").Schema<"eternal", "eternal", "literal", "eternal">;
55
+ }>, import("@fuzdev/fuz_schema/schema.ts").Schema<{
56
+ kind: "ttl";
57
+ days: number;
58
+ }, {
59
+ kind: "ttl";
60
+ days: number;
61
+ }, "object", {
62
+ kind: import("@fuzdev/fuz_schema/schema.ts").Schema<"ttl", "ttl", "literal", "ttl">;
63
+ days: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<number, number, "number", undefined>>;
64
+ }>];
65
+ }>;
66
+ export type TokenLifetimeInput = Infer<typeof TokenLifetimeInput>;
43
67
  /**
44
68
  * Resolve a lifetime input to the `expires_at` value the mint query stores.
45
69
  *
@@ -1 +1 @@
1
- {"version":3,"file":"token_lifetime.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/token_lifetime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;4BAM7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,UAAU,kBAAkB,EAC5B,MAAK,IAAiB,KACpB,IAAI,GAAG,IAGT,CAAC"}
1
+ {"version":3,"file":"token_lifetime.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/token_lifetime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,UAAU,kBAAkB,EAC5B,MAAK,IAAiB,KACpB,IAAI,GAAG,IAGT,CAAC"}
@@ -19,7 +19,7 @@
19
19
  *
20
20
  * @module
21
21
  */
22
- import { z } from 'zod';
22
+ import { integer, literal, max_value, min_value, number, object, pipe, variant } from '@fuzdev/fuz_schema/schema.ts';
23
23
  /**
24
24
  * Upper bound on `ttl.days` — a sanity cap (100 years), not a policy ceiling.
25
25
  * Shared with the Rust twin so out-of-range requests 400 identically on both
@@ -27,17 +27,18 @@ import { z } from 'zod';
27
27
  */
28
28
  export const TOKEN_TTL_DAYS_MAX = 36_500;
29
29
  /**
30
- * Caller-provided lifetime for `account_token_create`.
30
+ * Caller-provided lifetime for `account_token_create`, a `@fuzdev/fuz_schema`
31
+ * schema.
31
32
  *
32
33
  * `eternal` mints a never-expiring token (`expires_at` NULL); `ttl` bounds it
33
34
  * to `days` from mint time. `eternal` is deliberately the first variant so
34
35
  * schema-driven test generators produce it by default.
35
36
  */
36
- export const TokenLifetimeInput = z.discriminatedUnion('kind', [
37
- z.strictObject({ kind: z.literal('eternal') }),
38
- z.strictObject({
39
- kind: z.literal('ttl'),
40
- days: z.number().int().min(1).max(TOKEN_TTL_DAYS_MAX)
37
+ export const TokenLifetimeInput = variant('kind', [
38
+ object({ kind: literal('eternal') }),
39
+ object({
40
+ kind: literal('ttl'),
41
+ days: pipe(number, integer, min_value(1), max_value(TOKEN_TTL_DAYS_MAX))
41
42
  })
42
43
  ]);
43
44
  /**
@@ -28,16 +28,19 @@
28
28
  *
29
29
  * @module
30
30
  */
31
- import { z } from 'zod';
31
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
32
32
  /** Current `TokenScope` document version. Must match the Rust `TOKEN_SCOPE_VERSION`. */
33
33
  export declare const TOKEN_SCOPE_VERSION = 1;
34
34
  /**
35
- * Serialized-document cap. Matches the Rust `MAX_TOKEN_SCOPE_BYTES` and
35
+ * Serialized-document cap, in UTF-8 bytes of the document's compact JSON (no
36
+ * whitespace, what `JSON.stringify` writes) — never the text a driver or
37
+ * Postgres prints it as, which for `jsonb` adds a space after every `:` and
38
+ * `,`. Matches the Rust `MAX_TOKEN_SCOPE_BYTES`, which measures the same, and
36
39
  * fuz_forge's `MAX_POLICY_BYTES`.
37
40
  */
38
41
  export declare const MAX_TOKEN_SCOPE_BYTES: number;
39
42
  /**
40
- * The stored `api_token.scope` document.
43
+ * The stored `api_token.scope` document, a `@fuzdev/fuz_schema` schema.
41
44
  *
42
45
  * `grandfathered` is a fact about the *row* — the `api_token_scope` migration
43
46
  * wrote it; no minter chose it — that only the token list cares about. The
@@ -49,33 +52,95 @@ export declare const MAX_TOKEN_SCOPE_BYTES: number;
49
52
  * The discriminated union also refuses the contradiction
50
53
  * `{kind: 'full', methods: [...]}`.
51
54
  */
52
- export declare const TokenScope: z.ZodDiscriminatedUnion<[z.ZodObject<{
53
- version: z.ZodLiteral<1>;
54
- kind: z.ZodLiteral<"full">;
55
- grandfathered: z.ZodOptional<z.ZodBoolean>;
56
- }, z.core.$strict>, z.ZodObject<{
57
- version: z.ZodLiteral<1>;
58
- kind: z.ZodLiteral<"methods">;
59
- methods: z.ZodArray<z.ZodString>;
60
- grandfathered: z.ZodOptional<z.ZodBoolean>;
61
- }, z.core.$strict>], "kind">;
62
- export type TokenScope = z.infer<typeof TokenScope>;
55
+ export declare const TokenScope: import("@fuzdev/fuz_schema/schema.ts").Schema<{
56
+ version: 1;
57
+ kind: "full";
58
+ grandfathered?: boolean | undefined;
59
+ } | {
60
+ version: 1;
61
+ kind: "methods";
62
+ methods: string[];
63
+ grandfathered?: boolean | undefined;
64
+ }, {
65
+ version: 1;
66
+ kind: "full";
67
+ grandfathered?: boolean | undefined;
68
+ } | {
69
+ version: 1;
70
+ kind: "methods";
71
+ methods: string[];
72
+ grandfathered?: boolean | undefined;
73
+ }, "variant", {
74
+ readonly key: "kind";
75
+ readonly options: readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<{
76
+ version: 1;
77
+ kind: "full";
78
+ grandfathered?: boolean | undefined;
79
+ }, {
80
+ version: 1;
81
+ kind: "full";
82
+ grandfathered?: boolean | undefined;
83
+ }, "object", {
84
+ version: import("@fuzdev/fuz_schema/schema.ts").Schema<1, 1, "literal", 1>;
85
+ kind: import("@fuzdev/fuz_schema/schema.ts").Schema<"full", "full", "literal", "full">;
86
+ grandfathered: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean | undefined, boolean | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>>>;
87
+ }>, import("@fuzdev/fuz_schema/schema.ts").Schema<{
88
+ version: 1;
89
+ kind: "methods";
90
+ methods: string[];
91
+ grandfathered?: boolean | undefined;
92
+ }, {
93
+ version: 1;
94
+ kind: "methods";
95
+ methods: string[];
96
+ grandfathered?: boolean | undefined;
97
+ }, "object", {
98
+ version: import("@fuzdev/fuz_schema/schema.ts").Schema<1, 1, "literal", 1>;
99
+ kind: import("@fuzdev/fuz_schema/schema.ts").Schema<"methods", "methods", "literal", "methods">;
100
+ methods: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
101
+ grandfathered: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean | undefined, boolean | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>>>;
102
+ }>];
103
+ }>;
104
+ export type TokenScope = Infer<typeof TokenScope>;
63
105
  /**
64
106
  * The `scope` input accepted by `account_token_create` — the stored shape minus
65
- * the row-owned fields.
107
+ * the row-owned fields, a `@fuzdev/fuz_schema` schema.
66
108
  *
67
109
  * A minter cannot set `version` or `grandfathered`: the first is stamped by
68
110
  * `token_scope_full` / `token_scope_methods`, and the second is the migration's
69
111
  * mark for tokens that predate scoping. Letting a caller forge `grandfathered`
70
112
  * would turn a tracked debt into a laundered one.
71
113
  */
72
- export declare const TokenScopeInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
73
- kind: z.ZodLiteral<"full">;
74
- }, z.core.$strict>, z.ZodObject<{
75
- kind: z.ZodLiteral<"methods">;
76
- methods: z.ZodArray<z.ZodString>;
77
- }, z.core.$strict>], "kind">;
78
- export type TokenScopeInput = z.infer<typeof TokenScopeInput>;
114
+ export declare const TokenScopeInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
115
+ kind: "full";
116
+ } | {
117
+ kind: "methods";
118
+ methods: string[];
119
+ }, {
120
+ kind: "full";
121
+ } | {
122
+ kind: "methods";
123
+ methods: string[];
124
+ }, "variant", {
125
+ readonly key: "kind";
126
+ readonly options: readonly [import("@fuzdev/fuz_schema/schema.ts").Schema<{
127
+ kind: "full";
128
+ }, {
129
+ kind: "full";
130
+ }, "object", {
131
+ kind: import("@fuzdev/fuz_schema/schema.ts").Schema<"full", "full", "literal", "full">;
132
+ }>, import("@fuzdev/fuz_schema/schema.ts").Schema<{
133
+ kind: "methods";
134
+ methods: string[];
135
+ }, {
136
+ kind: "methods";
137
+ methods: string[];
138
+ }, "object", {
139
+ kind: import("@fuzdev/fuz_schema/schema.ts").Schema<"methods", "methods", "literal", "methods">;
140
+ methods: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
141
+ }>];
142
+ }>;
143
+ export type TokenScopeInput = Infer<typeof TokenScopeInput>;
79
144
  /** A deliberately-minted full-authority scope. */
80
145
  export declare const token_scope_full: () => TokenScope;
81
146
  /** A narrowed scope over `methods`. */
@@ -197,7 +262,15 @@ export declare const token_scope_denied_body: (capability: string) => {
197
262
  /** Stable label for the token list / UI. */
198
263
  export declare const token_scope_label: (scope: TokenScope) => string;
199
264
  /**
200
- * Parse a stored document, enforcing the size cap and the schema.
265
+ * Parse a stored document, enforcing the size cap and the schema. The cap is
266
+ * measured on the document's compact serialization, not on `raw`, so the
267
+ * spaced text Postgres prints a `jsonb` as reads as the document it is.
268
+ *
269
+ * A `raw` past twice the cap is refused before it is parsed. Postgres prints a
270
+ * `jsonb` as its compact form plus one space after each `:` and `,` outside
271
+ * strings, each of which is a byte of that form beside its braces, so the
272
+ * printed text of a document either spine can write is under twice the cap and
273
+ * never refused here.
201
274
  *
202
275
  * **Fail-closed**: returns `null` on an unreadable document, and every caller on
203
276
  * the enforcement path treats `null` as "refuse the credential" rather than
@@ -208,7 +281,7 @@ export declare const token_scope_label: (scope: TokenScope) => string;
208
281
  */
209
282
  export declare const parse_token_scope: (raw: string) => TokenScope | null;
210
283
  /**
211
- * Serialize for storage, enforcing the size cap.
284
+ * Serialize for storage, enforcing the size cap in UTF-8 bytes.
212
285
  *
213
286
  * Throws on an over-cap document — the mint path maps that to a 400, matching
214
287
  * the Rust side's `TokenScopeError::TooLarge`.
@@ -220,7 +293,8 @@ export declare const serialize_token_scope: (scope: TokenScope) => string;
220
293
  *
221
294
  * The DB driver may hand `scope` back already-parsed (JSONB → object) or as
222
295
  * text depending on backend, so both are normalized here rather than at each
223
- * call site. Lives here rather than beside the queries so the pure scope module
296
+ * call site, and either is held to the cap by its compact serialization, as
297
+ * the Rust spine holds the spaced `scope::text` it reads. Lives here rather than beside the queries so the pure scope module
224
298
  * owns every parse — and so mocking the query module doesn't drag this along.
225
299
  */
226
300
  export declare const parse_stored_token_scope: (value: unknown) => TokenScope | null;
@@ -1 +1 @@
1
- {"version":3,"file":"token_scope.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/token_scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAW,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU;;;;;;;;;4BAYrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;;;4BAG1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,QAAO,UAGlC,CAAC;AAEH,uCAAuC;AACvC,eAAO,MAAM,mBAAmB,GAAI,SAAS,KAAK,CAAC,MAAM,CAAC,KAAG,UAI3D,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,eAAe,KAAG,UAC8B,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,UAAU,EAAE,QAAQ,MAAM,KAAG,OACtB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,UAAU,KAAG,OAAgC,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,mGAOjB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,YACA,CAAC;AAQ3D;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,MAAM,KAAG,MAC3B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,OAEG,CAAC;AAE9D;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,YAAY,MAAM,KAChB;IAAE,KAAK,EAAE,sBAAsB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAGxD,CAAC;AAEH,4CAA4C;AAC5C,eAAO,MAAM,iBAAiB,GAAI,OAAO,UAAU,KAAG,MAGrD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,UAAU,GAAG,IAU5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,UAAU,KAAG,MAQzD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,UAAU,GAAG,IAQtE,CAAC"}
1
+ {"version":3,"file":"token_scope.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/token_scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAKtC,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAW,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,QAAO,UAGlC,CAAC;AAEH,uCAAuC;AACvC,eAAO,MAAM,mBAAmB,GAAI,SAAS,KAAK,CAAC,MAAM,CAAC,KAAG,UAI3D,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,eAAe,KAAG,UAC8B,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,UAAU,EAAE,QAAQ,MAAM,KAAG,OACtB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,UAAU,KAAG,OAAgC,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,mGAOjB,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,YACA,CAAC;AAQ3D;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,MAAM,KAAG,MAC3B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,OAEG,CAAC;AAE9D;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,YAAY,MAAM,KAChB;IAAE,KAAK,EAAE,sBAAsB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAGxD,CAAC;AAEH,4CAA4C;AAC5C,eAAO,MAAM,iBAAiB,GAAI,OAAO,UAAU,KAAG,MAGrD,CAAC;AAoBF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,UAAU,GAAG,IAU5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,UAAU,KAAG,MASzD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,UAAU,GAAG,IACc,CAAC"}