@fuzdev/fuz_app 0.181.0 → 0.183.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 (267) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +28 -10
  3. package/dist/actions/action_rpc.d.ts +11 -1
  4. package/dist/actions/action_rpc.d.ts.map +1 -1
  5. package/dist/actions/action_rpc.js +3 -2
  6. package/dist/actions/action_types.d.ts +16 -1
  7. package/dist/actions/action_types.d.ts.map +1 -1
  8. package/dist/actions/action_types.js +1 -1
  9. package/dist/actions/notification_sender.d.ts +83 -0
  10. package/dist/actions/notification_sender.d.ts.map +1 -0
  11. package/dist/actions/notification_sender.js +85 -0
  12. package/dist/actions/perform_action.d.ts +9 -0
  13. package/dist/actions/perform_action.d.ts.map +1 -1
  14. package/dist/actions/perform_action.js +22 -13
  15. package/dist/actions/register_action_ws.d.ts +14 -0
  16. package/dist/actions/register_action_ws.d.ts.map +1 -1
  17. package/dist/actions/register_action_ws.js +3 -2
  18. package/dist/actions/ws_socket_session.d.ts +3 -0
  19. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  20. package/dist/actions/ws_socket_session.js +2 -1
  21. package/dist/auth/CLAUDE.md +113 -70
  22. package/dist/auth/account_actions.d.ts.map +1 -1
  23. package/dist/auth/account_actions.js +13 -3
  24. package/dist/auth/account_queries.d.ts +158 -16
  25. package/dist/auth/account_queries.d.ts.map +1 -1
  26. package/dist/auth/account_queries.js +189 -18
  27. package/dist/auth/account_routes.d.ts +6 -4
  28. package/dist/auth/account_routes.d.ts.map +1 -1
  29. package/dist/auth/account_routes.js +98 -92
  30. package/dist/auth/admin_actions.d.ts.map +1 -1
  31. package/dist/auth/admin_actions.js +93 -45
  32. package/dist/auth/api_token_queries.d.ts +13 -5
  33. package/dist/auth/api_token_queries.d.ts.map +1 -1
  34. package/dist/auth/api_token_queries.js +24 -9
  35. package/dist/auth/audit_emitter.d.ts +75 -84
  36. package/dist/auth/audit_emitter.d.ts.map +1 -1
  37. package/dist/auth/audit_emitter.js +83 -71
  38. package/dist/auth/audit_log_schema.d.ts +10 -5
  39. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  40. package/dist/auth/audit_log_schema.js +22 -6
  41. package/dist/auth/bearer_auth.d.ts.map +1 -1
  42. package/dist/auth/bearer_auth.js +3 -2
  43. package/dist/auth/bootstrap_account.d.ts +31 -13
  44. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_account.js +34 -15
  46. package/dist/auth/bootstrap_routes.d.ts +1 -1
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +7 -14
  49. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  50. package/dist/auth/daemon_token_middleware.js +12 -1
  51. package/dist/auth/deps.d.ts +18 -5
  52. package/dist/auth/deps.d.ts.map +1 -1
  53. package/dist/auth/deps.js +3 -2
  54. package/dist/auth/request_context.d.ts +73 -73
  55. package/dist/auth/request_context.d.ts.map +1 -1
  56. package/dist/auth/request_context.js +78 -96
  57. package/dist/auth/resolved_auth.d.ts +16 -11
  58. package/dist/auth/resolved_auth.d.ts.map +1 -1
  59. package/dist/auth/resolved_auth.js +6 -6
  60. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  61. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  62. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  63. package/dist/auth/role_grant_offer_actions.d.ts +32 -12
  64. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  65. package/dist/auth/role_grant_offer_actions.js +91 -116
  66. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  67. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  68. package/dist/auth/role_grant_offer_notifications.js +75 -22
  69. package/dist/auth/role_grant_offer_queries.d.ts +155 -18
  70. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_queries.js +262 -73
  72. package/dist/auth/role_grant_offer_schema.js +1 -1
  73. package/dist/auth/role_grant_queries.d.ts +43 -52
  74. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_queries.js +50 -74
  76. package/dist/auth/role_grant_sql.d.ts +21 -0
  77. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  78. package/dist/auth/role_grant_sql.js +21 -0
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +17 -21
  81. package/dist/auth/session_queries.d.ts +40 -16
  82. package/dist/auth/session_queries.d.ts.map +1 -1
  83. package/dist/auth/session_queries.js +68 -29
  84. package/dist/auth/signup_routes.d.ts.map +1 -1
  85. package/dist/auth/signup_routes.js +90 -38
  86. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  87. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  88. package/dist/auth/standard_rpc_actions.js +5 -6
  89. package/dist/auth/token_scope.d.ts +1 -1
  90. package/dist/auth/token_scope.js +1 -1
  91. package/dist/db/sql_columns.d.ts +1 -1
  92. package/dist/db/sql_columns.js +1 -1
  93. package/dist/http/CLAUDE.md +22 -16
  94. package/dist/http/auth_shape.d.ts +1 -1
  95. package/dist/http/db_routes.d.ts +7 -22
  96. package/dist/http/db_routes.d.ts.map +1 -1
  97. package/dist/http/db_routes.js +72 -72
  98. package/dist/http/error_schemas.d.ts +9 -21
  99. package/dist/http/error_schemas.d.ts.map +1 -1
  100. package/dist/http/error_schemas.js +14 -24
  101. package/dist/http/pending_effects.d.ts +42 -4
  102. package/dist/http/pending_effects.d.ts.map +1 -1
  103. package/dist/http/pending_effects.js +34 -4
  104. package/dist/http/route_spec.d.ts +2 -2
  105. package/dist/server/app_backend.d.ts.map +1 -1
  106. package/dist/server/app_backend.js +3 -1
  107. package/dist/server/app_server.d.ts +69 -18
  108. package/dist/server/app_server.d.ts.map +1 -1
  109. package/dist/server/app_server.js +74 -10
  110. package/dist/server/serve_fact_route.d.ts +3 -3
  111. package/dist/server/serve_fact_route.js +12 -12
  112. package/dist/testing/CLAUDE.md +259 -790
  113. package/dist/testing/adversarial_404.d.ts +6 -1
  114. package/dist/testing/adversarial_404.d.ts.map +1 -1
  115. package/dist/testing/adversarial_404.js +38 -17
  116. package/dist/testing/app_server.d.ts +20 -140
  117. package/dist/testing/app_server.d.ts.map +1 -1
  118. package/dist/testing/app_server.js +48 -125
  119. package/dist/testing/audit_drift_guard.d.ts +11 -6
  120. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  121. package/dist/testing/audit_drift_guard.js +15 -8
  122. package/dist/testing/auth_apps.js +1 -1
  123. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  124. package/dist/testing/cross_backend/account_lifecycle.js +43 -0
  125. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  126. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  127. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  128. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  129. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  130. package/dist/testing/cross_backend/capabilities.js +11 -7
  131. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  132. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  133. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  134. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  135. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/cell_relations.js +12 -11
  137. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  138. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  139. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  140. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  141. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/conformance_table.js +2 -270
  143. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  144. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  145. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  146. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  147. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  148. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  150. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  151. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  152. package/dist/testing/cross_backend/declared_skips.js +132 -0
  153. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  154. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  155. package/dist/testing/cross_backend/default_spine_surface.js +2 -6
  156. package/dist/testing/cross_backend/differential.d.ts +11 -2
  157. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/differential.js +35 -11
  159. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  160. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  162. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
  163. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/full_spine_mount.js +4 -4
  165. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  166. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  167. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  168. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  169. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  170. package/dist/testing/cross_backend/login_security.js +21 -4
  171. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  172. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  174. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  175. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  177. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  178. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  180. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  181. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  182. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  183. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
  184. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  185. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  186. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  187. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/session_cap.js +48 -16
  189. package/dist/testing/cross_backend/setup.d.ts +31 -1
  190. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/setup.js +32 -1
  192. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  193. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/spine_suites.js +454 -57
  195. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  196. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  198. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  199. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  201. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  202. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  203. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  204. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  205. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  206. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  207. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  208. package/dist/testing/cross_backend/transport_composition.js +7 -3
  209. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  210. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  211. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  212. package/dist/testing/data_exposure.d.ts.map +1 -1
  213. package/dist/testing/data_exposure.js +3 -0
  214. package/dist/testing/db.d.ts +0 -32
  215. package/dist/testing/db.d.ts.map +1 -1
  216. package/dist/testing/db.js +0 -86
  217. package/dist/testing/db_entities.d.ts +14 -0
  218. package/dist/testing/db_entities.d.ts.map +1 -1
  219. package/dist/testing/db_entities.js +17 -0
  220. package/dist/testing/db_invariant_queries.d.ts +259 -0
  221. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  222. package/dist/testing/db_invariant_queries.js +400 -0
  223. package/dist/testing/db_invariants.d.ts +106 -0
  224. package/dist/testing/db_invariants.d.ts.map +1 -0
  225. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  226. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  227. package/dist/testing/db_invariants.gen.sql.js +13 -0
  228. package/dist/testing/db_invariants.js +141 -0
  229. package/dist/testing/db_invariants.sql +152 -0
  230. package/dist/testing/describe_db.d.ts +36 -0
  231. package/dist/testing/describe_db.d.ts.map +1 -0
  232. package/dist/testing/describe_db.js +71 -0
  233. package/dist/testing/integration.d.ts +6 -9
  234. package/dist/testing/integration.d.ts.map +1 -1
  235. package/dist/testing/integration.js +9 -13
  236. package/dist/testing/integration_helpers.d.ts +1 -1
  237. package/dist/testing/integration_helpers.d.ts.map +1 -1
  238. package/dist/testing/middleware.d.ts +1 -1
  239. package/dist/testing/middleware.js +5 -5
  240. package/dist/testing/rate_limiting.d.ts +1 -1
  241. package/dist/testing/rate_limiting.d.ts.map +1 -1
  242. package/dist/testing/rate_limiting.js +3 -2
  243. package/dist/testing/resolved_auth.d.ts +3 -1
  244. package/dist/testing/resolved_auth.d.ts.map +1 -1
  245. package/dist/testing/resolved_auth.js +4 -4
  246. package/dist/testing/role_grant_helpers.d.ts +1 -1
  247. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  248. package/dist/testing/round_trip.d.ts.map +1 -1
  249. package/dist/testing/round_trip.js +3 -0
  250. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  251. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  252. package/dist/testing/rpc_attack_surface.js +69 -6
  253. package/dist/testing/rpc_round_trip.d.ts +1 -1
  254. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  255. package/dist/testing/rpc_round_trip.js +3 -0
  256. package/dist/testing/sse_round_trip.d.ts +1 -1
  257. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  258. package/dist/testing/sse_round_trip.js +13 -4
  259. package/dist/testing/stubs.d.ts +4 -2
  260. package/dist/testing/stubs.d.ts.map +1 -1
  261. package/dist/testing/stubs.js +15 -7
  262. package/dist/testing/test_app.d.ts +166 -0
  263. package/dist/testing/test_app.d.ts.map +1 -0
  264. package/dist/testing/test_app.js +124 -0
  265. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  266. package/dist/testing/ws_round_trip.js +8 -4
  267. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAkBN,KAAK,SAAS,EACd,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAoC,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAmBjF;;;;;GAKG;AACH,eAAO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  *
72
72
  * A scope other than `none` marks an event whose success invalidates a live
73
- * connection's credential or access: `logout`, `password_change`,
73
+ * connection's credential or access: `password_change`,
74
74
  * `session_revoke_all`, `token_revoke_all`, `account_delete`, and
75
- * `account_purge` are account-wide, `session_revoke` and `token_revoke` name
76
- * the one credential they ended, and `role_grant_revoke` names the lost role.
75
+ * `account_purge` are account-wide, `session_revoke`, `logout` and
76
+ * `token_revoke` name the one credential they ended, and `role_grant_revoke`
77
+ * names the lost role.
77
78
  * Granting access revokes nothing, and neither does an event about a subject
78
79
  * other than a connection's identity.
79
80
  *
@@ -82,7 +83,7 @@ export const AUDIT_EVENT_TYPES = Object.freeze([
82
83
  */
83
84
  export const audit_event_revocation_scopes = Object.freeze({
84
85
  login: 'none',
85
- logout: 'account',
86
+ logout: 'session',
86
87
  bootstrap: 'none',
87
88
  signup: 'none',
88
89
  password_change: 'account',
@@ -185,7 +186,11 @@ export const audit_metadata_schemas = Object.freeze({
185
186
  login: nullable(loose_object({
186
187
  username: meta(string, { description: 'Username submitted with the login attempt.' })
187
188
  })),
188
- logout: literal(null),
189
+ logout: loose_object({
190
+ session_id: meta(SessionId, {
191
+ description: 'Blake3 hash identifying the session row the logout ended.'
192
+ })
193
+ }),
189
194
  bootstrap: nullable(loose_object({
190
195
  error: meta(string, { description: 'Error message for a failed bootstrap attempt.' })
191
196
  })),
@@ -373,8 +378,19 @@ export const audit_metadata_schemas = Object.freeze({
373
378
  email: meta(nullable(string), { description: 'Invited email address; null when not set.' }),
374
379
  username: meta(nullable(string), { description: 'Invited username; null when not set.' })
375
380
  }),
381
+ // A delete of an id naming no unclaimed invite writes an `outcome=failure`
382
+ // row with no `invite_id`: `reason` carries the failure category and
383
+ // `attempted_invite_id` the probed id.
376
384
  invite_delete: loose_object({
377
- invite_id: meta(Uuid, { description: 'Id of the deleted invite.' })
385
+ invite_id: meta(optional(Uuid), {
386
+ description: 'Id of the deleted invite. Omitted on `outcome=failure`.'
387
+ }),
388
+ reason: meta(optional(string), {
389
+ description: 'Failure category. Set only on `outcome=failure`.'
390
+ }),
391
+ attempted_invite_id: meta(optional(Uuid), {
392
+ description: 'Probed invite id when no unclaimed invite matched. Set only on `outcome=failure`.'
393
+ })
378
394
  }),
379
395
  // Account/actor deletion snapshots identity into metadata so the
380
396
  // identity behind a now-orphaned audit id survives a purge (the
@@ -1 +1 @@
1
- {"version":3,"file":"bearer_auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bearer_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,6BAA6B,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,iBAyE5E,CAAC"}
1
+ {"version":3,"file":"bearer_auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bearer_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,6BAA6B,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,iBA0E5E,CAAC"}
@@ -108,7 +108,8 @@ export const create_bearer_auth_middleware = (deps, log) => {
108
108
  }
109
109
  // a tombstoned account authenticates nothing — its token resolves as no
110
110
  // credential, the anonymous caller, as on the Rust spine
111
- if (!(await query_account_by_id(deps, api_token.account_id))) {
111
+ const account = await query_account_by_id(deps, api_token.account_id);
112
+ if (!account) {
112
113
  log.debug('bearer auth soft-fail: account not found or deleted');
113
114
  await next();
114
115
  return;
@@ -122,7 +123,7 @@ export const create_bearer_auth_middleware = (deps, log) => {
122
123
  c.var.pending_effects?.push(touch);
123
124
  c.set(RESOLVED_AUTH_KEY, {
124
125
  credential_type: 'api_token',
125
- account_id: api_token.account_id,
126
+ account,
126
127
  api_token_id: api_token.id,
127
128
  // Parsed by the query, which refuses a token whose stored scope is
128
129
  // unreadable — there is no default to fall back to.
@@ -13,10 +13,11 @@ import type { Logger } from '@fuzdev/fuz_util/log.ts';
13
13
  import type { PasswordHashDeps } from './password.js';
14
14
  import { ERROR_INVALID_TOKEN, ERROR_ALREADY_BOOTSTRAPPED, ERROR_TOKEN_FILE_MISSING, ERROR_TOKEN_FILE_UNDELETABLE } from '../http/error_schemas.js';
15
15
  import type { Account, Actor, RoleGrant } from './account_schema.js';
16
- import type { Db } from '../db/db.js';
16
+ import { type RequestEffectsContext } from '../http/pending_effects.js';
17
+ import type { AuditEmitter } from './audit_emitter.js';
17
18
  import type { BootstrapTokenStore } from './bootstrap_token_store.js';
18
19
  import type { Keyring } from './keyring.js';
19
- import type { SessionOptions } from './session_cookie.js';
20
+ import { type SessionOptions } from './session_cookie.js';
20
21
  /** Input for the bootstrap account creation. */
21
22
  export interface BootstrapAccountInput {
22
23
  username: string;
@@ -35,11 +36,11 @@ export interface BootstrapAccountCreated {
35
36
  export interface BootstrapAccountSuccess extends BootstrapAccountCreated {
36
37
  ok: true;
37
38
  /**
38
- * The signed cookie value of the session minted in the bootstrap
39
- * transaction, for the caller to set on its response — it exists only
40
- * because the transaction committed.
39
+ * The `Set-Cookie` line of the session minted in the bootstrap
40
+ * transaction, formatted inside it, for the caller to set on its
41
+ * response — it exists only because the transaction committed.
41
42
  */
42
- session_cookie_value: string;
43
+ set_cookie: string;
43
44
  }
44
45
  /** Bootstrap failure result. */
45
46
  export type BootstrapAccountFailure = {
@@ -65,7 +66,8 @@ export type BootstrapAccountResult = BootstrapAccountSuccess | BootstrapAccountF
65
66
  * Dependencies for `bootstrap_account`.
66
67
  */
67
68
  export interface BootstrapAccountDeps {
68
- db: Db;
69
+ /** Writes the `bootstrap` success row in the bootstrap transaction. */
70
+ audit: Pick<AuditEmitter, 'emit'>;
69
71
  /**
70
72
  * The one-shot token: read through the hardened secret read (a symlinked,
71
73
  * non-regular, group/other-readable, multiply-linked, or oversized file is
@@ -80,6 +82,16 @@ export interface BootstrapAccountDeps {
80
82
  /** Structured logger instance. */
81
83
  log: Logger;
82
84
  }
85
+ /**
86
+ * The request `bootstrap_account` runs for: its pool-level `db` (the bootstrap
87
+ * opens its own transaction), its side-effect queues (the success row's
88
+ * listener fan-out is queued post-commit), and the client IP its audit row
89
+ * records. A `RouteContext` satisfies it.
90
+ */
91
+ export interface BootstrapAccountContext extends RequestEffectsContext {
92
+ /** Resolved client IP from the trusted-proxy middleware — `'unknown'` if not resolved. */
93
+ client_ip: string;
94
+ }
83
95
  /** Static options for `bootstrap_account`. */
84
96
  export interface BootstrapAccountOptions {
85
97
  /** Session cookie configuration for the session the bootstrap mints. */
@@ -119,27 +131,33 @@ export declare const read_bootstrap_token: (deps: Pick<BootstrapAccountDeps, "to
119
131
  * the race loser, `already_bootstrapped`, nothing burned); create the
120
132
  * account + actor; grant keeper and admin (no expiry, `granted_by =
121
133
  * null`); mint the session through the capped minter login uses (the cap
122
- * evicts nothing on a new account); then burn the token file, last, just
134
+ * evicts nothing on a new account) and format its `Set-Cookie` line; write
135
+ * the `bootstrap` success audit row; then burn the token file, last, just
123
136
  * before the commit
124
137
  *
125
138
  * The burn comes after the lock, so only the lock winner burns (its row lock
126
139
  * is held across the unlink, so a concurrent attempt waits on its UPDATE);
127
140
  * after the inserts, so a failed insert spends nothing; last, so the window
128
- * between a burn and a failed commit is one round trip. A burn that fails
141
+ * between a burn and a failed commit is one round trip. The audit row is
142
+ * written before the burn, so a refused row rolls the bootstrap back with the
143
+ * token unburned and the window open, as a failed insert does; its listener
144
+ * fan-out is discarded with any rollback. A burn that fails
129
145
  * rolls everything back and answers `token_file_undeletable`: nothing was
130
146
  * created and the token is still valid, so the operator fixes the directory
131
147
  * and retries. A commit that fails after the burn is logged as an error — the
132
148
  * token is gone and a new one must be written. Twin of the Rust
133
149
  * `bootstrap_handler`.
134
150
  *
135
- * @param deps - database, token store, password hashing, keyring, and logger
151
+ * @param deps - token store, password hashing, keyring, audit emitter, and logger
152
+ * @param ctx - the request's pool `db`, side-effect queues, and client IP
136
153
  * @param provided_token - the bootstrap token from the user
137
154
  * @param input - username and password
138
155
  * @param options - the session cookie configuration
139
- * @returns the created account, actor, role_grants, and session cookie value — or a bootstrap failure
156
+ * @returns the created account, actor, role_grants, and the session's `Set-Cookie` line — or a bootstrap failure
140
157
  * @mutates `bootstrap_lock` row - flips `bootstrapped` to `true` atomically
141
- * @mutates `account` / `actor` / `role_grant` / `auth_session` tables - inserts the bootstrap account, actor, keeper + admin role_grants, and session
158
+ * @mutates `account` / `actor` / `role_grant` / `auth_session` / `audit_log` tables - inserts the bootstrap account, actor, keeper + admin role_grants, session, and success row
159
+ * @mutates `ctx.post_commit_effects` - appends the success row's listener fan-out, discarded on rollback
142
160
  * @mutates filesystem - burns the bootstrap token file inside the transaction
143
161
  */
144
- export declare const bootstrap_account: (deps: BootstrapAccountDeps, provided_token: string, input: BootstrapAccountInput, options: BootstrapAccountOptions) => Promise<BootstrapAccountResult>;
162
+ export declare const bootstrap_account: (deps: BootstrapAccountDeps, ctx: BootstrapAccountContext, provided_token: string, input: BootstrapAccountInput, options: BootstrapAccountOptions) => Promise<BootstrapAccountResult>;
145
163
  //# sourceMappingURL=bootstrap_account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap_account.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_account.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,MAAM,EA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ACtB,OAAO,qBAAqB,EAC5B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,sBAAsB,CAsHhC,CAAC"}
@@ -15,6 +15,8 @@ import { ERROR_INVALID_TOKEN, ERROR_ALREADY_BOOTSTRAPPED, ERROR_TOKEN_FILE_MISSI
15
15
  import { ROLE_ADMIN, ROLE_KEEPER } from './role_schema.js';
16
16
  import { query_create_account_with_actor } from './account_queries.js';
17
17
  import { query_create_role_grant } from './role_grant_queries.js';
18
+ import { transaction_with_post_commit_rollback } from '../http/pending_effects.js';
19
+ import { session_cookie_header } from './session_cookie.js';
18
20
  import { create_capped_session } from './session_queries.js';
19
21
  import { DEFAULT_MAX_SESSIONS } from './account_route_schema.js';
20
22
  /**
@@ -78,30 +80,36 @@ export const read_bootstrap_token = async (deps) => {
78
80
  * the race loser, `already_bootstrapped`, nothing burned); create the
79
81
  * account + actor; grant keeper and admin (no expiry, `granted_by =
80
82
  * null`); mint the session through the capped minter login uses (the cap
81
- * evicts nothing on a new account); then burn the token file, last, just
83
+ * evicts nothing on a new account) and format its `Set-Cookie` line; write
84
+ * the `bootstrap` success audit row; then burn the token file, last, just
82
85
  * before the commit
83
86
  *
84
87
  * The burn comes after the lock, so only the lock winner burns (its row lock
85
88
  * is held across the unlink, so a concurrent attempt waits on its UPDATE);
86
89
  * after the inserts, so a failed insert spends nothing; last, so the window
87
- * between a burn and a failed commit is one round trip. A burn that fails
90
+ * between a burn and a failed commit is one round trip. The audit row is
91
+ * written before the burn, so a refused row rolls the bootstrap back with the
92
+ * token unburned and the window open, as a failed insert does; its listener
93
+ * fan-out is discarded with any rollback. A burn that fails
88
94
  * rolls everything back and answers `token_file_undeletable`: nothing was
89
95
  * created and the token is still valid, so the operator fixes the directory
90
96
  * and retries. A commit that fails after the burn is logged as an error — the
91
97
  * token is gone and a new one must be written. Twin of the Rust
92
98
  * `bootstrap_handler`.
93
99
  *
94
- * @param deps - database, token store, password hashing, keyring, and logger
100
+ * @param deps - token store, password hashing, keyring, audit emitter, and logger
101
+ * @param ctx - the request's pool `db`, side-effect queues, and client IP
95
102
  * @param provided_token - the bootstrap token from the user
96
103
  * @param input - username and password
97
104
  * @param options - the session cookie configuration
98
- * @returns the created account, actor, role_grants, and session cookie value — or a bootstrap failure
105
+ * @returns the created account, actor, role_grants, and the session's `Set-Cookie` line — or a bootstrap failure
99
106
  * @mutates `bootstrap_lock` row - flips `bootstrapped` to `true` atomically
100
- * @mutates `account` / `actor` / `role_grant` / `auth_session` tables - inserts the bootstrap account, actor, keeper + admin role_grants, and session
107
+ * @mutates `account` / `actor` / `role_grant` / `auth_session` / `audit_log` tables - inserts the bootstrap account, actor, keeper + admin role_grants, session, and success row
108
+ * @mutates `ctx.post_commit_effects` - appends the success row's listener fan-out, discarded on rollback
101
109
  * @mutates filesystem - burns the bootstrap token file inside the transaction
102
110
  */
103
- export const bootstrap_account = async (deps, provided_token, input, options) => {
104
- const { db, token_store, password, keyring, log } = deps;
111
+ export const bootstrap_account = async (deps, ctx, provided_token, input, options) => {
112
+ const { token_store, password, keyring, audit, log } = deps;
105
113
  // 1. Read and verify token (non-destructive, before transaction). The
106
114
  // secure read fails loud on a symlink / non-regular file / permissive mode /
107
115
  // second hard link / oversized file, and the read refuses a token under the minimum length —
@@ -128,23 +136,22 @@ export const bootstrap_account = async (deps, provided_token, input, options) =>
128
136
  let burned = false;
129
137
  let tx_result;
130
138
  try {
131
- tx_result = await db.transaction(async (tx) => {
132
- const lock_rows = await tx.query('UPDATE bootstrap_lock SET bootstrapped = true WHERE id = 1 AND bootstrapped = false RETURNING id');
139
+ tx_result = await transaction_with_post_commit_rollback(ctx, async (tx_ctx) => {
140
+ const lock_rows = await tx_ctx.db.query('UPDATE bootstrap_lock SET bootstrapped = true WHERE id = 1 AND bootstrapped = false RETURNING id');
133
141
  if (lock_rows.length === 0) {
134
142
  return { ok: false, error: ERROR_ALREADY_BOOTSTRAPPED, status: 403 };
135
143
  }
136
- const tx_deps = { db: tx };
137
- const { account, actor } = await query_create_account_with_actor(tx_deps, {
144
+ const { account, actor } = await query_create_account_with_actor(tx_ctx, {
138
145
  username: input.username,
139
146
  password_hash
140
147
  });
141
- const keeper_role_grant = await query_create_role_grant(tx_deps, {
148
+ const keeper_role_grant = await query_create_role_grant(tx_ctx, {
142
149
  actor_id: actor.id,
143
150
  role: ROLE_KEEPER,
144
151
  granted_by: null,
145
152
  expires_at: null
146
153
  });
147
- const admin_role_grant = await query_create_role_grant(tx_deps, {
154
+ const admin_role_grant = await query_create_role_grant(tx_ctx, {
148
155
  actor_id: actor.id,
149
156
  role: ROLE_ADMIN,
150
157
  granted_by: null,
@@ -155,11 +162,23 @@ export const bootstrap_account = async (deps, provided_token, input, options) =>
155
162
  // creation, not of the login route.
156
163
  const { cookie_value } = await create_capped_session({
157
164
  keyring,
158
- deps: tx_deps,
165
+ deps: tx_ctx,
159
166
  account_id: account.id,
160
167
  session_options: options.session_options,
161
168
  max_sessions: DEFAULT_MAX_SESSIONS
162
169
  });
170
+ // formatted here, as login and signup format theirs: a value the
171
+ // formatter refuses rolls the bootstrap back with the token unburned
172
+ const set_cookie = session_cookie_header(cookie_value, options.session_options);
173
+ // The success row, in the transaction and ahead of the burn: a refused
174
+ // INSERT rolls the bootstrap back with the token unburned and the
175
+ // window open, as a failed insert above does.
176
+ await audit.emit(tx_ctx, {
177
+ event_type: 'bootstrap',
178
+ actor_id: actor.id,
179
+ account_id: account.id,
180
+ ip: ctx.client_ip
181
+ });
163
182
  // the burn, last before the commit
164
183
  let outcome;
165
184
  try {
@@ -177,7 +196,7 @@ export const bootstrap_account = async (deps, provided_token, input, options) =>
177
196
  account,
178
197
  actor,
179
198
  role_grants: { keeper: keeper_role_grant, admin: admin_role_grant },
180
- session_cookie_value: cookie_value
199
+ set_cookie
181
200
  };
182
201
  });
183
202
  }
@@ -7,7 +7,7 @@
7
7
  * @module
8
8
  */
9
9
  import type { Logger } from '@fuzdev/fuz_util/log.ts';
10
- import { type SessionOptions } from './session_cookie.js';
10
+ import type { SessionOptions } from './session_cookie.js';
11
11
  import { type BootstrapAccountCreated } from './bootstrap_account.js';
12
12
  import type { BootstrapTokenStore } from './bootstrap_token_store.js';
13
13
  import type { Db } from '../db/db.js';
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAYlD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,0EAA0E;IAC1E,gBAAgB,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACxC,mDAAmD;IACnD,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;;;;;;;;;OAWG;IACH,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;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H,MAAM,WAAW,qBAAqB;IACrC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,0EAA0E;IAC1E,gBAAgB,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACxC,mDAAmD;IACnD,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;;;;;;;;;OAWG;IACH,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,+EAA+E;IAC/E,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,wBAAwB,EAC9B,SAAS;IAAE,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAAE,KAClD,OAAO,CAAC,eAAe,CA0CzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,MAAM,gBAAgB,EACtB,SAAS,qBAAqB,KAC5B,KAAK,CAAC,SAAS,CA4HjB,CAAC"}
@@ -7,7 +7,6 @@
7
7
  * @module
8
8
  */
9
9
  import { to_error_message } from '@fuzdev/fuz_util/error.ts';
10
- import { session_cookie_header } from './session_cookie.js';
11
10
  import { bootstrap_account, read_bootstrap_token } from './bootstrap_account.js';
12
11
  import { bootstrap_route_shape } from './bootstrap_route_schema.js';
13
12
  import { attach_route_handler } from '../http/route_spec.js';
@@ -117,14 +116,15 @@ export const create_bootstrap_route_specs = (deps, options) => {
117
116
  try {
118
117
  const input = route.input;
119
118
  // `transaction: false` makes `route.db` the pool. `bootstrap_account`
120
- // manages its own transaction internally.
119
+ // manages its own transaction internally, and writes the success
120
+ // row in it.
121
121
  const result = await bootstrap_account({
122
- db: route.db,
123
122
  token_store,
124
123
  password: deps.password,
125
124
  keyring: deps.keyring,
125
+ audit: deps.audit,
126
126
  log: deps.log
127
- }, input.token, input, { session_options });
127
+ }, route, input.token, input, { session_options });
128
128
  if (!result.ok) {
129
129
  // The lock-race loser — the window open here, the lock already
130
130
  // flipped in the database. Close the window so the next caller
@@ -166,10 +166,9 @@ export const create_bootstrap_route_specs = (deps, options) => {
166
166
  // most `max_attempts - 1` residual entries survive — and they sit
167
167
  // on this route's own limiter, not login's.
168
168
  bootstrap_status.available = false;
169
- // the session was minted in the transaction; its cookie rides the
170
- // success
171
- const set_cookie = session_cookie_header(result.session_cookie_value, session_options);
172
- const { account, actor, role_grants } = result;
169
+ // the session was minted, and its cookie line formatted, in the
170
+ // transaction; the line rides the success
171
+ const { account, actor, role_grants, set_cookie } = result;
173
172
  if (on_bootstrap) {
174
173
  try {
175
174
  await on_bootstrap({ account, actor, role_grants });
@@ -178,12 +177,6 @@ export const create_bootstrap_route_specs = (deps, options) => {
178
177
  deps.log.error(`on_bootstrap callback failed: ${to_error_message(err)}`);
179
178
  }
180
179
  }
181
- await deps.audit.emit(route, {
182
- event_type: 'bootstrap',
183
- actor_id: actor.id,
184
- account_id: account.id,
185
- ip: route.client_ip
186
- });
187
180
  return route_ok({
188
181
  ok: true,
189
182
  account: { id: account.id, username: account.username },
@@ -1 +1 @@
1
- {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"","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;AAGrD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBA4EF,CAAC"}
1
+ {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"","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;AAQtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBAsFF,CAAC"}
@@ -19,6 +19,7 @@ import { get_resolved_auth } from './resolved_auth.js';
19
19
  import { get_header_lines } from '../http/header_lines.js';
20
20
  import { is_browser_context } from '../http/request_headers.js';
21
21
  import { query_role_grant_find_account_id_for_role } from './role_grant_queries.js';
22
+ import { query_account_by_id } from './account_queries.js';
22
23
  import { ROLE_KEEPER } from './role_schema.js';
23
24
  import { read_daemon_token } from './credential_headers.js';
24
25
  import { DAEMON_TOKEN_HEADER, validate_daemon_token } from './daemon_token.js';
@@ -145,12 +146,22 @@ export const create_daemon_token_middleware = (state, deps, log) => {
145
146
  await next();
146
147
  return;
147
148
  }
149
+ // The keeper's row, read per request as every credential leg reads its
150
+ // account, so the authorization phase builds on it. A keeper account
151
+ // gone or tombstoned (no API path removes it) authenticates nothing —
152
+ // as the Rust spine's daemon leg.
153
+ const account = await query_account_by_id(deps, state.keeper_account_id);
154
+ if (!account) {
155
+ log.warn('daemon token auth soft-fail: keeper account not found');
156
+ await next();
157
+ return;
158
+ }
148
159
  // Full authority (`resolved_auth_scope`): singular, filesystem-proved,
149
160
  // keeper-bound — no minting step at which a narrowing could have been
150
161
  // chosen. No row, no expiry.
151
162
  c.set(RESOLVED_AUTH_KEY, {
152
163
  credential_type: 'daemon_token',
153
- account_id: state.keeper_account_id,
164
+ account,
154
165
  credential_deadline: null
155
166
  });
156
167
  await next();
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Stateless capabilities bundle for fuz_app backends.
2
+ * Capabilities bundle for fuz_app backends.
3
3
  *
4
4
  * `AppDeps` is the central dependency injection type — injectable and swappable
5
5
  * per environment (production vs test). Does not contain config (static values)
6
- * or runtime state (mutable refs).
6
+ * or app runtime state (mutable refs like `bootstrap_status`); the audit emitter
7
+ * and the realtime fan-outs hold only their registered members.
7
8
  *
8
9
  * @module
9
10
  */
@@ -14,11 +15,14 @@ import type { PasswordHashDeps } from './password.js';
14
15
  import type { Db } from '../db/db.js';
15
16
  import type { AuditEmitter } from './audit_emitter.js';
16
17
  import type { ConnectionCloser, RealtimeCloser } from '../actions/connection_closer.js';
18
+ import type { RealtimeNotificationSender } from '../actions/notification_sender.js';
17
19
  /**
18
- * Stateless capabilities bundle for fuz_app backends.
20
+ * Capabilities bundle for fuz_app backends.
19
21
  *
20
- * Injectable and swappable per environment (production vs test).
21
- * Does not contain config (static values) or runtime state (mutable refs).
22
+ * Injectable and swappable per environment (production vs test). Does not
23
+ * contain config (static values) or app runtime state (mutable refs like
24
+ * `bootstrap_status`); the audit emitter and the realtime fan-outs hold only
25
+ * their registered members.
22
26
  */
23
27
  export interface AppDeps {
24
28
  /** HMAC-SHA256 cookie signing keyring. */
@@ -48,6 +52,15 @@ export interface AppDeps {
48
52
  * option of `register_action_ws` / `create_audit_log_sse`.
49
53
  */
50
54
  connection_closer: RealtimeCloser;
55
+ /**
56
+ * Sends server-initiated notifications to an account's live WebSocket
57
+ * connections. The action dispatchers put it on every handler context
58
+ * (`ActionContext.notification_sender`), so it must reach every
59
+ * WebSocket registry of the backend: `create_app_backend` creates it
60
+ * empty, and `create_app_server` adds each registry it mounts. With no
61
+ * WebSocket endpoint mounted it reaches no one.
62
+ */
63
+ notification_sender: RealtimeNotificationSender;
51
64
  /**
52
65
  * Optional content-addressed byte store. Present only on backends that
53
66
  * serve binary content (facts) — minimal consumers leave it unset. The
@@ -1 +1 @@
1
- {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/lib/auth/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACvB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,yBAAyB;IACzB,EAAE,EAAE,EAAE,CAAC;IACP,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;OAOG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;;;;;;;OAQG;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AC;IACZ;;;;;;;OAOG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;;;;;;;OAQG;IACH,iBAAiB,EAAE,cAAc,CAAC;IAClC;;;;;;;OAOG;IACH,mBAAmB,EAAE,0BAA0B,CAAC;IAChD;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IACjC,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,KAAK,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IACnE;;;;;;OAMG;IACH,iBAAiB,EAAE,gBAAgB,CAAC;CACpC"}
package/dist/auth/deps.js CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Stateless capabilities bundle for fuz_app backends.
2
+ * Capabilities bundle for fuz_app backends.
3
3
  *
4
4
  * `AppDeps` is the central dependency injection type — injectable and swappable
5
5
  * per environment (production vs test). Does not contain config (static values)
6
- * or runtime state (mutable refs).
6
+ * or app runtime state (mutable refs like `bootstrap_status`); the audit emitter
7
+ * and the realtime fan-outs hold only their registered members.
7
8
  *
8
9
  * @module
9
10
  */