@fuzdev/fuz_app 0.181.0 → 0.182.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 (114) hide show
  1. package/dist/actions/CLAUDE.md +24 -6
  2. package/dist/actions/action_rpc.d.ts +11 -1
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +3 -2
  5. package/dist/actions/action_types.d.ts +16 -1
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/action_types.js +1 -1
  8. package/dist/actions/notification_sender.d.ts +83 -0
  9. package/dist/actions/notification_sender.d.ts.map +1 -0
  10. package/dist/actions/notification_sender.js +85 -0
  11. package/dist/actions/perform_action.d.ts +9 -0
  12. package/dist/actions/perform_action.d.ts.map +1 -1
  13. package/dist/actions/perform_action.js +22 -13
  14. package/dist/actions/register_action_ws.d.ts +14 -0
  15. package/dist/actions/register_action_ws.d.ts.map +1 -1
  16. package/dist/actions/register_action_ws.js +3 -2
  17. package/dist/actions/ws_socket_session.d.ts +3 -0
  18. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  19. package/dist/actions/ws_socket_session.js +2 -1
  20. package/dist/auth/CLAUDE.md +60 -41
  21. package/dist/auth/account_actions.d.ts.map +1 -1
  22. package/dist/auth/account_actions.js +13 -3
  23. package/dist/auth/account_queries.d.ts +158 -16
  24. package/dist/auth/account_queries.d.ts.map +1 -1
  25. package/dist/auth/account_queries.js +189 -18
  26. package/dist/auth/account_routes.d.ts +1 -1
  27. package/dist/auth/account_routes.d.ts.map +1 -1
  28. package/dist/auth/account_routes.js +27 -26
  29. package/dist/auth/admin_actions.d.ts.map +1 -1
  30. package/dist/auth/admin_actions.js +71 -28
  31. package/dist/auth/api_token_queries.d.ts +13 -5
  32. package/dist/auth/api_token_queries.d.ts.map +1 -1
  33. package/dist/auth/api_token_queries.js +24 -9
  34. package/dist/auth/bearer_auth.d.ts.map +1 -1
  35. package/dist/auth/bearer_auth.js +3 -2
  36. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  37. package/dist/auth/daemon_token_middleware.js +12 -1
  38. package/dist/auth/deps.d.ts +10 -0
  39. package/dist/auth/deps.d.ts.map +1 -1
  40. package/dist/auth/request_context.d.ts +73 -73
  41. package/dist/auth/request_context.d.ts.map +1 -1
  42. package/dist/auth/request_context.js +78 -96
  43. package/dist/auth/resolved_auth.d.ts +10 -5
  44. package/dist/auth/resolved_auth.d.ts.map +1 -1
  45. package/dist/auth/resolved_auth.js +2 -2
  46. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  47. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  48. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  49. package/dist/auth/role_grant_offer_actions.d.ts +7 -11
  50. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  51. package/dist/auth/role_grant_offer_actions.js +61 -93
  52. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  53. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  54. package/dist/auth/role_grant_offer_notifications.js +75 -22
  55. package/dist/auth/role_grant_offer_queries.d.ts +96 -15
  56. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  57. package/dist/auth/role_grant_offer_queries.js +185 -70
  58. package/dist/auth/role_grant_offer_schema.js +1 -1
  59. package/dist/auth/role_grant_queries.d.ts +52 -12
  60. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  61. package/dist/auth/role_grant_queries.js +75 -24
  62. package/dist/auth/role_grant_sql.d.ts +21 -0
  63. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  64. package/dist/auth/role_grant_sql.js +21 -0
  65. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  66. package/dist/auth/self_service_role_actions.js +9 -2
  67. package/dist/auth/session_queries.d.ts +34 -13
  68. package/dist/auth/session_queries.d.ts.map +1 -1
  69. package/dist/auth/session_queries.js +48 -18
  70. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  71. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  72. package/dist/auth/standard_rpc_actions.js +5 -6
  73. package/dist/auth/token_scope.d.ts +1 -1
  74. package/dist/auth/token_scope.js +1 -1
  75. package/dist/http/CLAUDE.md +7 -6
  76. package/dist/http/auth_shape.d.ts +1 -1
  77. package/dist/http/error_schemas.d.ts +9 -21
  78. package/dist/http/error_schemas.d.ts.map +1 -1
  79. package/dist/http/error_schemas.js +14 -24
  80. package/dist/http/route_spec.d.ts +2 -2
  81. package/dist/server/app_backend.d.ts.map +1 -1
  82. package/dist/server/app_backend.js +3 -1
  83. package/dist/server/app_server.d.ts +26 -16
  84. package/dist/server/app_server.d.ts.map +1 -1
  85. package/dist/server/app_server.js +17 -7
  86. package/dist/server/serve_fact_route.d.ts +3 -3
  87. package/dist/server/serve_fact_route.js +12 -12
  88. package/dist/testing/CLAUDE.md +5 -5
  89. package/dist/testing/app_server.d.ts.map +1 -1
  90. package/dist/testing/app_server.js +3 -1
  91. package/dist/testing/auth_apps.js +1 -1
  92. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  93. package/dist/testing/cross_backend/account_lifecycle.js +43 -0
  94. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  95. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  96. package/dist/testing/cross_backend/default_spine_surface.js +2 -6
  97. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
  98. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  99. package/dist/testing/cross_backend/full_spine_mount.js +4 -4
  100. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  101. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  102. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
  103. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/session_cap.js +26 -5
  105. package/dist/testing/middleware.d.ts +1 -1
  106. package/dist/testing/middleware.js +5 -5
  107. package/dist/testing/resolved_auth.d.ts +3 -1
  108. package/dist/testing/resolved_auth.d.ts.map +1 -1
  109. package/dist/testing/resolved_auth.js +4 -4
  110. package/dist/testing/stubs.d.ts.map +1 -1
  111. package/dist/testing/stubs.js +5 -2
  112. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  113. package/dist/testing/ws_round_trip.js +8 -4
  114. package/package.json +1 -1
@@ -179,13 +179,14 @@ and `FrontendActionHandlers`.
179
179
 
180
180
  ## Single JSON-RPC 2.0 endpoint (`actions/action_rpc.ts`)
181
181
 
182
- `create_rpc_endpoint({path, actions, log, action_ip_rate_limiter, action_account_rate_limiter}): RouteSpec[]`
182
+ `create_rpc_endpoint({path, actions, log, action_ip_rate_limiter, action_account_rate_limiter, notification_sender}): RouteSpec[]`
183
183
  produces **two** route specs on the same path (GET + POST) that share one
184
184
  internal dispatcher. The two limiters are required `RateLimiter | null` with
185
185
  no default — `null` is the explicit off switch — and the same holds on
186
186
  `register_action_ws`, so a hand mount can't run
187
187
  unthrottled by omission. `create_app_server` passes its own to every endpoint
188
- it mounts (../../../docs/usage.md §Rate limiters). Per-action auth lives inside the dispatcher; the outer routes
188
+ it mounts (../../../docs/usage.md §Rate limiters). `notification_sender` is
189
+ required on both the same way (§Notification sender). Per-action auth lives inside the dispatcher; the outer routes
189
190
  use `auth: {account: 'none', actor: 'none'}` and `transaction: false`.
190
191
 
191
192
  The HTTP RPC dispatcher is a thin shim around `perform_action`
@@ -247,6 +248,7 @@ interface ActionContext {
247
248
  credential_type: BuiltinCredentialType | null; // same value the credential_types gate consumed
248
249
  log: Logger;
249
250
  notify: (method, params) => void; // HTTP: DEV-mode warn + drop; WS: socket-scoped
251
+ notification_sender: NotificationSender; // every socket of an account, on every mounted registry; never null
250
252
  signal: AbortSignal; // HTTP: client-disconnect; WS: AbortSignal.any([socket_close, request_cancel])
251
253
  }
252
254
 
@@ -300,7 +302,8 @@ anonymous — the authorization phase reads its account, the post-authorization
300
302
  gates its type and scope, `ActionContext` its type and session hash),
301
303
  `client_ip`, `signal`, `notify`, optional `connection_id`, optional `preset`.
302
304
  `PerformActionDeps` carries `db` (pool-level), `pending_effects`, `log`,
303
- the two rate limiters. Audit writes are out-of-band: factories close over
305
+ the two rate limiters, and `notification_sender` — put on the context, wrapped
306
+ under DEV in `create_validated_notification_sender` once per dispatch. Audit writes are out-of-band: factories close over
304
307
  `AppDeps.audit` independently.
305
308
 
306
309
  Authorization-phase resolution failures from the auth domain come back as
@@ -594,8 +597,8 @@ Fan-out, to admitted connections only, each returning how many connections
594
597
  accepted the message: `broadcast(notification)` to every connection;
595
598
  `broadcast_filtered(message, predicate)` runs per-connection ACL predicate over
596
599
  `ConnectionIdentity`; `send_to_account` wraps `broadcast_filtered` and
597
- structurally satisfies `NotificationSender` (see `auth/CLAUDE.md` §WS
598
- notifications). A server→client request has no broadcast form; it targets one
600
+ structurally satisfies `NotificationSender` (§Notification sender; the
601
+ role-grant-offer sends: `auth/CLAUDE.md` §WS notifications). A server→client request has no broadcast form; it targets one
599
602
  connection (`request_connection`, below).
600
603
 
601
604
  Server→client request/response (ActionPeer): `request_connection(connection_id,
@@ -759,6 +762,20 @@ identifiers, and an outcome outside the enum is no revocation. Reacting to them
759
762
  another user's connection by guessing a session hash or token id. Twin of the
760
763
  Rust spine's `register_revocation_guard`.
761
764
 
765
+ ## Notification sender (`actions/notification_sender.ts`)
766
+
767
+ `NotificationSender` (`send_to_account(account_id, message): number`, which a
768
+ `ConnectionRegistry` satisfies) is what a handler sends through, as
769
+ `ctx.notification_sender` on every `ActionContext`, so no factory takes one.
770
+ `AppDeps.notification_sender` is the backend's `RealtimeNotificationSender`,
771
+ one fan-out over every WS registry (twin of the Rust
772
+ `backend.notification_sender()`); `create_app_server` adds each registry it
773
+ mounts and removes it on `close` or a failed assembly. Both dispatchers
774
+ require it; a hand mount passes `backend.deps.notification_sender` (or
775
+ `noop_notification_sender`) and adds its own registry
776
+ (../../../docs/usage.md §WebSocket Endpoint). Membership and failure rules:
777
+ TSDoc. The role-grant-offer sends: `auth/CLAUDE.md` §WS notifications.
778
+
762
779
  ## WebSocket endpoints
763
780
 
764
781
  ### `create_app_server.ws_endpoints` — canonical mount surface
@@ -768,7 +785,8 @@ of `WsEndpointSpec` or a factory
768
785
  `(ctx: AppServerContext) => ReadonlyArray<WsEndpointSpec>`; factory form
769
786
  runs after server context is assembled so action lists can depend on
770
787
  `ctx.deps` / `ctx.action_*_rate_limiter`. Each entry is auto-mounted via
771
- `register_action_ws` against the assembled Hono app.
788
+ `register_action_ws` against the assembled Hono app, and its registry added to
789
+ `deps.notification_sender` and `deps.connection_closer`.
772
790
 
773
791
  `upgrade_websocket: UpgradeWebSocket` is the Hono runtime adapter's
774
792
  module-level helper — `upgradeWebSocket` from `@hono/bun`, or from
@@ -16,6 +16,7 @@ import type { Logger } from '@fuzdev/fuz_util/log.ts';
16
16
  import type { RpcAction } from './action_types.js';
17
17
  import { type RouteSpec } from '../http/route_spec.js';
18
18
  import type { RateLimiter } from '../rate_limiter.js';
19
+ import type { NotificationSender } from './notification_sender.js';
19
20
  /**
20
21
  * The `Cache-Control` every answer of the RPC endpoint's `GET` route carries
21
22
  * — a read is per caller and per moment, so nothing may store it. Declared as
@@ -56,6 +57,15 @@ export interface CreateRpcEndpointOptions {
56
57
  * Share one instance with the WebSocket action dispatcher.
57
58
  */
58
59
  action_account_rate_limiter: RateLimiter | null;
60
+ /**
61
+ * What every handler's `ctx.notification_sender` sends through. Required,
62
+ * with no default, like the limiters: a sender left out would drop every
63
+ * notification silently. `create_app_server` passes the backend's
64
+ * (`AppDeps.notification_sender`), which reaches the WebSocket registries
65
+ * it mounts; a hand mount with no live connection to reach passes
66
+ * `noop_notification_sender`.
67
+ */
68
+ notification_sender: NotificationSender;
59
69
  }
60
70
  /**
61
71
  * Single JSON-RPC 2.0 endpoint — the canonical RPC transport binding.
@@ -96,7 +106,7 @@ export interface CreateRpcEndpointOptions {
96
106
  * middleware's scope (`assert_credential_routes_in_auth_scope`) whether it
97
107
  * arrives as `rpc_endpoints` or through `create_route_specs`.
98
108
  *
99
- * @param options - endpoint path, actions, logger, and the two action rate limiters
109
+ * @param options - endpoint path, actions, logger, the two action rate limiters, and the notification sender
100
110
  * @returns route specs (GET + POST) ready for `apply_route_specs`
101
111
  * @throws Error if two actions share the same `spec.method` (registration-time
102
112
  * duplicate detection); also throws if any action's `spec.input` is a null
@@ -1 +1 @@
1
- {"version":3,"file":"action_rpc.d.ts","sourceRoot":"","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAaxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAE3E,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAgOtF,CAAC"}
1
+ {"version":3,"file":"action_rpc.d.ts","sourceRoot":"","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAaxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAE3E,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD;;;;;;;OAOG;IACH,mBAAmB,EAAE,kBAAkB,CAAC;CACxC;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAkOtF,CAAC"}
@@ -83,7 +83,7 @@ const envelope_response = (envelope, status) => route_raw({ status, headers: JSO
83
83
  * middleware's scope (`assert_credential_routes_in_auth_scope`) whether it
84
84
  * arrives as `rpc_endpoints` or through `create_route_specs`.
85
85
  *
86
- * @param options - endpoint path, actions, logger, and the two action rate limiters
86
+ * @param options - endpoint path, actions, logger, the two action rate limiters, and the notification sender
87
87
  * @returns route specs (GET + POST) ready for `apply_route_specs`
88
88
  * @throws Error if two actions share the same `spec.method` (registration-time
89
89
  * duplicate detection); also throws if any action's `spec.input` is a null
@@ -92,7 +92,7 @@ const envelope_response = (envelope, status) => route_raw({ status, headers: JSO
92
92
  * or its `spec.output` is a void schema.
93
93
  */
94
94
  export const create_rpc_endpoint = (options) => {
95
- const { path: endpoint_path, actions, log, action_ip_rate_limiter, action_account_rate_limiter } = options;
95
+ const { path: endpoint_path, actions, log, action_ip_rate_limiter, action_account_rate_limiter, notification_sender } = options;
96
96
  const { action_map } = compile_action_registry(actions, 'RPC action');
97
97
  /**
98
98
  * HTTP-shape dispatch shim — the GET/POST entry points share this:
@@ -143,6 +143,7 @@ export const create_rpc_endpoint = (options) => {
143
143
  pending_effects: route.pending_effects,
144
144
  post_commit_effects: route.post_commit_effects,
145
145
  log,
146
+ notification_sender,
146
147
  action_ip_rate_limiter,
147
148
  action_account_rate_limiter
148
149
  });
@@ -27,6 +27,7 @@ import type { BuiltinCredentialType } from '../auth/credential_type_schema.js';
27
27
  import type { Db } from '../db/db.js';
28
28
  import type { JsonrpcRequestId } from '../http/jsonrpc.js';
29
29
  import type { RequestClient } from './peer_request.js';
30
+ import type { NotificationSender } from './notification_sender.js';
30
31
  /**
31
32
  * A spec paired with its optional handler — the composable unit passed to
32
33
  * `register_action_ws` and `create_rpc_client`. The server uses both
@@ -133,6 +134,20 @@ export interface ActionContext {
133
134
  * the notification method this handler is expected to emit.
134
135
  */
135
136
  notify: (method: string, params: unknown) => void;
137
+ /**
138
+ * Sends a server-initiated notification to every live WebSocket connection
139
+ * of any account, from a handler on either transport — unlike `notify`,
140
+ * which reaches only the originating connection. The dispatcher supplies
141
+ * the backend's sender (`AppDeps.notification_sender`), which reaches
142
+ * every WebSocket registry the server mounts, so a send from an HTTP RPC
143
+ * handler reaches the account's sockets; with no WebSocket endpoint
144
+ * mounted it reaches no one. Queue sends after the commit
145
+ * (`emit_after_commit`, or `queue_offer_notification` for the role-grant
146
+ * notifications), never inline. Under DEV each role_grant_offer
147
+ * notification's params are checked against its spec
148
+ * (`create_validated_notification_sender`).
149
+ */
150
+ notification_sender: NotificationSender;
136
151
  /**
137
152
  * AbortSignal that fires when the originating request is cancelled
138
153
  * (client disconnect on HTTP, socket close or per-request cancel
@@ -232,7 +247,7 @@ export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = HandlerFor
232
247
  * runtime guarantee without a manual narrowing call.
233
248
  *
234
249
  * Fits fuz_app's factory-closure pattern (handlers close over
235
- * `grantable_roles`, `app_settings` ref, `notification_sender`, etc.).
250
+ * `grantable_roles`, `connection_closer`, etc.).
236
251
  * zzz uses a different shape — a codegen-keyed `Record<Method, Handler>`
237
252
  * map typed via generated `ActionInputs`/`ActionOutputs` — which works when
238
253
  * handlers are pure (no closure state) and specs are codegen-enumerated.
@@ -1 +1 @@
1
- {"version":3,"file":"action_types.d.ts","sourceRoot":"","sources":["../../src/lib/actions/action_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EACX,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBA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I,KAAK,SAAS,yBAAyB,EACjE,MAAM,KAAK,EACX,SAAS,cAAc,CAAC,KAAK,CAAC,KAC5B,SAGD,CAAC"}
@@ -37,7 +37,7 @@
37
37
  * runtime guarantee without a manual narrowing call.
38
38
  *
39
39
  * Fits fuz_app's factory-closure pattern (handlers close over
40
- * `grantable_roles`, `app_settings` ref, `notification_sender`, etc.).
40
+ * `grantable_roles`, `connection_closer`, etc.).
41
41
  * zzz uses a different shape — a codegen-keyed `Record<Method, Handler>`
42
42
  * map typed via generated `ActionInputs`/`ActionOutputs` — which works when
43
43
  * handlers are pure (no closure state) and specs are codegen-enumerated.
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Pushing a server-initiated JSON-RPC notification to an account's live
3
+ * WebSocket connections.
4
+ *
5
+ * **Why the handler context carries it.** A notification carries a domain
6
+ * payload (an offer, a revoked grant) that only the handler holds, so the
7
+ * handler builds the message and queues the send after its commit
8
+ * (`queue_offer_notification` in `auth/role_grant_offer_notifications.ts`).
9
+ * `perform_action` puts the sender on every `ActionContext`, so no action
10
+ * factory takes one and none can be wired with the wrong one: an offer
11
+ * created over HTTP RPC must reach the recipient's sockets on the WebSocket
12
+ * registry, which a sender bound to any other registry would miss silently.
13
+ *
14
+ * **Why a fan-out.** `create_app_backend` puts one
15
+ * `RealtimeNotificationSender` on `AppDeps.notification_sender`, and
16
+ * `create_app_server` adds every WebSocket connection registry it mounts.
17
+ * The registries are created at mount, after the RPC and WebSocket action
18
+ * factories run, so a sender read at send time is the only one that reaches
19
+ * them. A server mounting no WebSocket endpoint holds an empty fan-out, and
20
+ * its sends reach no one.
21
+ *
22
+ * Twin of the Rust spine's `NotificationSender` and `NoopNotificationSender`;
23
+ * the Rust backend serves one connection registry on every endpoint, which
24
+ * the fan-out stands in for.
25
+ *
26
+ * @module
27
+ */
28
+ import type { Uuid } from '../primitive_schemas.js';
29
+ import type { JsonrpcNotification } from '../http/jsonrpc.js';
30
+ /**
31
+ * Send a JSON-RPC notification to every admitted socket bound to an account.
32
+ *
33
+ * `ConnectionRegistry` satisfies this structurally — its `send_to_account`
34
+ * accepts the broader `JsonrpcMessageFromServerToClient`. The interface
35
+ * stays narrow so handlers don't couple to the concrete registry and tests
36
+ * can capture sends with no WebSocket machinery.
37
+ *
38
+ * Returns how many sockets accepted the notification — bookkeeping, not a
39
+ * delivery receipt; `0` means the account has no live socket.
40
+ */
41
+ export interface NotificationSender {
42
+ send_to_account: (account_id: Uuid, message: JsonrpcNotification) => number;
43
+ }
44
+ /**
45
+ * A `NotificationSender` that sends nothing — for a hand-mounted dispatcher
46
+ * whose actions have no live connection to reach.
47
+ */
48
+ export declare const noop_notification_sender: NotificationSender;
49
+ /**
50
+ * One `NotificationSender` over every WebSocket connection registry of a
51
+ * backend.
52
+ *
53
+ * Each send reaches every member and returns the sum, so an account with
54
+ * sockets on two registries hears the notification on each. A member that
55
+ * throws does not stop the others: every member is called, then the first
56
+ * error is thrown for the caller (the post-commit flush) to log.
57
+ */
58
+ export interface RealtimeNotificationSender extends NotificationSender {
59
+ /**
60
+ * Add a registry's sender, returning a remover for this addition.
61
+ *
62
+ * Membership is by reference: a sender added twice — two endpoints sharing
63
+ * one registry — is one member, and every send reaches it once, so no
64
+ * socket hears a notification twice. Each `add` is counted, and its
65
+ * remover releases only that count: the sender stays a member until every
66
+ * addition is removed. Calling a remover again is a no-op.
67
+ *
68
+ * @param sender - the registry's sender
69
+ * @returns a remover for this addition, idempotent
70
+ */
71
+ add: (sender: NotificationSender) => () => void;
72
+ /** Count of distinct members — introspection for tests and diagnostics. */
73
+ member_count: () => number;
74
+ }
75
+ /**
76
+ * Create an empty `RealtimeNotificationSender`.
77
+ *
78
+ * `create_app_backend` creates the one on `AppDeps.notification_sender`, and
79
+ * `create_app_server` adds each WebSocket connection registry it mounts,
80
+ * removing them when its assembly fails or the server closes.
81
+ */
82
+ export declare const create_realtime_notification_sender: () => RealtimeNotificationSender;
83
+ //# sourceMappingURL=notification_sender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification_sender.d.ts","sourceRoot":"","sources":["../../src/lib/actions/notification_sender.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IAClC,eAAe,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAmB,KAAK,MAAM,CAAC;CAC5E;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAErC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACrE;;;;;;;;;;;OAWG;IACH,GAAG,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,MAAM,IAAI,CAAC;IAChD,2EAA2E;IAC3E,YAAY,EAAE,MAAM,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,QAAO,0BAqCtD,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Pushing a server-initiated JSON-RPC notification to an account's live
3
+ * WebSocket connections.
4
+ *
5
+ * **Why the handler context carries it.** A notification carries a domain
6
+ * payload (an offer, a revoked grant) that only the handler holds, so the
7
+ * handler builds the message and queues the send after its commit
8
+ * (`queue_offer_notification` in `auth/role_grant_offer_notifications.ts`).
9
+ * `perform_action` puts the sender on every `ActionContext`, so no action
10
+ * factory takes one and none can be wired with the wrong one: an offer
11
+ * created over HTTP RPC must reach the recipient's sockets on the WebSocket
12
+ * registry, which a sender bound to any other registry would miss silently.
13
+ *
14
+ * **Why a fan-out.** `create_app_backend` puts one
15
+ * `RealtimeNotificationSender` on `AppDeps.notification_sender`, and
16
+ * `create_app_server` adds every WebSocket connection registry it mounts.
17
+ * The registries are created at mount, after the RPC and WebSocket action
18
+ * factories run, so a sender read at send time is the only one that reaches
19
+ * them. A server mounting no WebSocket endpoint holds an empty fan-out, and
20
+ * its sends reach no one.
21
+ *
22
+ * Twin of the Rust spine's `NotificationSender` and `NoopNotificationSender`;
23
+ * the Rust backend serves one connection registry on every endpoint, which
24
+ * the fan-out stands in for.
25
+ *
26
+ * @module
27
+ */
28
+ /**
29
+ * A `NotificationSender` that sends nothing — for a hand-mounted dispatcher
30
+ * whose actions have no live connection to reach.
31
+ */
32
+ export const noop_notification_sender = Object.freeze({
33
+ send_to_account: () => 0
34
+ });
35
+ /**
36
+ * Create an empty `RealtimeNotificationSender`.
37
+ *
38
+ * `create_app_backend` creates the one on `AppDeps.notification_sender`, and
39
+ * `create_app_server` adds each WebSocket connection registry it mounts,
40
+ * removing them when its assembly fails or the server closes.
41
+ */
42
+ export const create_realtime_notification_sender = () => {
43
+ // member → how many additions hold it; iteration order is first addition
44
+ const members = new Map();
45
+ return Object.freeze({
46
+ add: (sender) => {
47
+ members.set(sender, (members.get(sender) ?? 0) + 1);
48
+ let removed = false;
49
+ return () => {
50
+ if (removed)
51
+ return;
52
+ removed = true;
53
+ const count = members.get(sender);
54
+ if (count === undefined)
55
+ return;
56
+ if (count <= 1)
57
+ members.delete(sender);
58
+ else
59
+ members.set(sender, count - 1);
60
+ };
61
+ },
62
+ member_count: () => members.size,
63
+ send_to_account: (account_id, message) => {
64
+ let count = 0;
65
+ let failed = false;
66
+ let first_error;
67
+ for (const member of members.keys()) {
68
+ try {
69
+ count += member.send_to_account(account_id, message);
70
+ }
71
+ catch (error) {
72
+ // keep going — one registry's failure must not keep the
73
+ // notification from the account's sockets on another
74
+ if (!failed) {
75
+ failed = true;
76
+ first_error = error;
77
+ }
78
+ }
79
+ }
80
+ if (failed)
81
+ throw first_error;
82
+ return count;
83
+ }
84
+ });
85
+ };
@@ -71,6 +71,7 @@ import { type JsonrpcRequestId, type JsonrpcErrorObject } from '../http/jsonrpc.
71
71
  import type { RateLimiter } from '../rate_limiter.js';
72
72
  import type { RpcAction } from './action_types.js';
73
73
  import type { RequestClient } from './peer_request.js';
74
+ import type { NotificationSender } from './notification_sender.js';
74
75
  /**
75
76
  * Per-call inputs to `perform_action`. Each transport assembles this from
76
77
  * its wire envelope + connection identity.
@@ -138,6 +139,14 @@ export interface PerformActionDeps {
138
139
  post_commit_effects: Array<() => void | Promise<void>>;
139
140
  /** Logger threaded into `ActionContext.log`. */
140
141
  log: Logger;
142
+ /**
143
+ * Threaded into `ActionContext.notification_sender` — the backend's one
144
+ * sender on both transports, so a send from an HTTP handler reaches the
145
+ * WebSocket registries. Under DEV the handler gets it wrapped in
146
+ * `create_validated_notification_sender`, so every send site is checked
147
+ * as DEV output validation checks every result.
148
+ */
149
+ notification_sender: NotificationSender;
141
150
  /** Per-IP limiter (shared across transports). `null` disables. */
142
151
  action_ip_rate_limiter: RateLimiter | null;
143
152
  /** Per-account limiter (shared across transports). `null` disables. */
@@ -1 +1 @@
1
- {"version":3,"file":"perform_action.d.ts","sourceRoot":"","sources":["../../src/lib/actions/perform_action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAS,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAOtC,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAGvB,MAAM,oBAAoB,CAAC;AAkB5B,OAAO,KAAK,EAAE,WAAW,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 -76,6 +76,7 @@ import { create_jsonrpc_error_response, create_jsonrpc_response } from '../http/
76
76
  import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, http_status_to_jsonrpc_error_code, JSONRPC_ERROR_CODES, dev_only, to_thrown_jsonrpc_error } from '../http/jsonrpc_errors.js';
77
77
  import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_CREDENTIAL_TYPE_REQUIRED, ERROR_PARAMS_NUL, ERROR_PARAMS_PROTO_KEY, ERROR_TOKEN_SCOPE_REQUIRED } from '../http/error_schemas.js';
78
78
  import { is_public_auth, needs_actor, parse_acting } from '../http/auth_shape.js';
79
+ import { create_validated_notification_sender } from '../auth/role_grant_offer_notifications.js';
79
80
  import { token_scope_admits_method, token_scope_method_capability } from '../auth/token_scope.js';
80
81
  /**
81
82
  * The shared dispatch core. Pure data — no Hono context, no socket. Each
@@ -89,12 +90,12 @@ import { token_scope_admits_method, token_scope_method_capability } from '../aut
89
90
  */
90
91
  export const perform_action = async (input, deps) => {
91
92
  const { action, raw_params, request_id: id, credential, client_ip, signal, notify, connection_id, request_client, preset } = input;
92
- const { db, pending_effects, post_commit_effects, log, action_ip_rate_limiter, action_account_rate_limiter } = deps;
93
+ const { db, pending_effects, post_commit_effects, log, notification_sender, action_ip_rate_limiter, action_account_rate_limiter } = deps;
93
94
  const { spec, handler } = action;
94
95
  const action_auth = spec.auth;
95
- const account_id = credential?.account_id ?? null;
96
+ const account = credential?.account ?? null;
96
97
  // step 1: pre-authorization auth — 401 short-circuit.
97
- const pre = check_action_auth_pre_authorization(action_auth, account_id);
98
+ const pre = check_action_auth_pre_authorization(action_auth, account?.id ?? null);
98
99
  if (pre)
99
100
  return error_result(pre);
100
101
  // step 2: authorization phase. `acting` reads off the raw params rather
@@ -114,12 +115,16 @@ export const perform_action = async (input, deps) => {
114
115
  // dispatcher does.
115
116
  let result;
116
117
  try {
117
- result = await apply_authorization_phase({ db }, account_id, action_auth, read_acting(action_auth, raw_params));
118
+ result = await apply_authorization_phase({ db }, account, action_auth, read_acting(action_auth, raw_params));
118
119
  }
119
120
  catch (err) {
120
121
  return thrown_error_result(err, `authorization phase error: ${spec.method}`, log);
121
122
  }
122
123
  if (!result.ok) {
124
+ // an account removed since its credential was read: the dead
125
+ // credential's 401, as the pre-authorization gate answers it
126
+ if (result.status === 401)
127
+ return error_result(unauthenticated_error());
123
128
  const { error: reason, ...rest } = result.body;
124
129
  const code = http_status_to_jsonrpc_error_code(result.status);
125
130
  return {
@@ -212,6 +217,7 @@ export const perform_action = async (input, deps) => {
212
217
  session_hash: resolved_auth_session_hash(credential),
213
218
  log,
214
219
  notify,
220
+ notification_sender: create_validated_notification_sender(notification_sender, log),
215
221
  signal
216
222
  };
217
223
  const output = await handler(validated_input, action_context);
@@ -321,18 +327,21 @@ const read_acting = (auth, raw_params) => {
321
327
  */
322
328
  const check_action_auth_pre_authorization = (auth, account_id) => {
323
329
  if (auth.account === 'required' || auth.actor === 'required') {
324
- if (account_id == null) {
325
- // Carry the reason on `error.data.reason` (symmetric with the 403
326
- // credential / role gates) so a 401 can be asserted on reason, not
327
- // just status. The reason is generic — it leaks nothing about
328
- // whether a credential was present or what the route demanded.
329
- return jsonrpc_error_messages.unauthenticated('unauthenticated', {
330
- reason: ERROR_AUTHENTICATION_REQUIRED
331
- });
332
- }
330
+ if (account_id == null)
331
+ return unauthenticated_error();
333
332
  }
334
333
  return null;
335
334
  };
335
+ /**
336
+ * The dead or missing credential's 401. Carries the reason on
337
+ * `error.data.reason` (symmetric with the 403 credential / role gates) so a
338
+ * 401 can be asserted on reason, not just status. The reason is generic — it
339
+ * leaks nothing about whether a credential was present or what the route
340
+ * demanded.
341
+ */
342
+ const unauthenticated_error = () => jsonrpc_error_messages.unauthenticated('unauthenticated', {
343
+ reason: ERROR_AUTHENTICATION_REQUIRED
344
+ });
336
345
  /**
337
346
  * The credential-type 403 — one builder, so the dispatcher's gate below and a
338
347
  * handler that gates a credential channel on its input (`account_delete`'s
@@ -65,6 +65,7 @@ import { type Logger as LoggerType } from '@fuzdev/fuz_util/log.ts';
65
65
  import type { RoleName } from '../auth/role_schema.js';
66
66
  import type { EffectErrorContext } from '../http/pending_effects.js';
67
67
  import type { RateLimiter } from '../rate_limiter.js';
68
+ import type { NotificationSender } from './notification_sender.js';
68
69
  import type { Db } from '../db/db.js';
69
70
  import { type Action } from './action_types.js';
70
71
  import type { RealtimeCloser } from './connection_closer.js';
@@ -252,6 +253,19 @@ export interface RegisterActionWsOptions {
252
253
  * dispatcher.
253
254
  */
254
255
  action_account_rate_limiter: RateLimiter | null;
256
+ /**
257
+ * What every handler's `ctx.notification_sender` sends through — the
258
+ * backend's (`AppDeps.notification_sender`), the one `create_app_server`
259
+ * passes, so a frame's action notifies sockets on every registry the
260
+ * backend mounts, not just this endpoint's. Required, with no default: a
261
+ * sender left out would drop every notification silently. Unlike
262
+ * `connection_closer`, it is only sent through: this endpoint's registry
263
+ * joins the backend's sender when `create_app_server` adds it, so a hand
264
+ * mount over that sender adds the returned registry itself
265
+ * (`RealtimeNotificationSender.add`). A harness with one registry passes
266
+ * that registry; `noop_notification_sender` sends nothing.
267
+ */
268
+ notification_sender: NotificationSender;
255
269
  /**
256
270
  * Called when an eager pending effect of a frame's action rejects, after
257
271
  * the rejection is logged — the WS half of `create_app_server`'s
@@ -1 +1 @@
1
- {"version":3,"file":"register_action_ws.d.ts","sourceRoot":"","sources":["../../src/lib/actions/register_action_ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAS5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,w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cAAc,GAAG,IAAI,CAAC;IACzC;;;;;;;;OAQG;IACH,2BAA2B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;OAMG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD;;;;;;;;;;;OAWG;IACH,mBAAmB,EAAE,kBAAkB,CAAC;IACxC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACxE;AAED,sCAAsC;AACtC,MAAM,WAAW,sBAAsB;IACtC,wEAAwE;IACxE,QAAQ,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,uBAAuB,KAAG,sBAuLrE,CAAC"}
@@ -153,7 +153,7 @@ export const register_action_ws = (options) => {
153
153
  throw new Error(`register_action_ws: outbound_queue_bytes configures the registry created for ${options.path}, ` +
154
154
  'but a registry was supplied — set the budget on that ConnectionRegistry instead');
155
155
  }
156
- const { path, app, upgradeWebSocket, actions, db, receive_timeout = DEFAULT_WS_RECEIVE_TIMEOUT, allowed_origins, max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES, log = new Logger('[ws]'), on_socket_open, on_socket_close, action_ip_rate_limiter, action_account_rate_limiter, on_effect_error, required_roles = [] } = options;
156
+ const { path, app, upgradeWebSocket, actions, db, receive_timeout = DEFAULT_WS_RECEIVE_TIMEOUT, allowed_origins, max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES, log = new Logger('[ws]'), on_socket_open, on_socket_close, action_ip_rate_limiter, action_account_rate_limiter, notification_sender, on_effect_error, required_roles = [] } = options;
157
157
  const registry = options.registry ??
158
158
  new ConnectionRegistry({
159
159
  max_connections_per_account: options.max_connections_per_account,
@@ -202,6 +202,7 @@ export const register_action_ws = (options) => {
202
202
  on_socket_close,
203
203
  action_ip_rate_limiter,
204
204
  action_account_rate_limiter,
205
+ notification_sender,
205
206
  on_effect_error,
206
207
  required_roles
207
208
  };
@@ -249,7 +250,7 @@ export const register_action_ws = (options) => {
249
250
  if (resolved === null) {
250
251
  throw new Error(`register_action_ws: no resolved credential for the upgrade on ${path} — is the auth middleware wired?`);
251
252
  }
252
- if (resolved.account_id !== upgrade_context.account.id) {
253
+ if (resolved.account.id !== upgrade_context.account.id) {
253
254
  throw new Error(`register_action_ws: the credential and the request context name different accounts for the upgrade on ${path}`);
254
255
  }
255
256
  // Test escape hatch — captured once at upgrade. perform_action
@@ -115,6 +115,7 @@ import type { RoleName } from '../auth/role_schema.js';
115
115
  import { type ResolvedAuth } from '../auth/resolved_auth.js';
116
116
  import { type EffectErrorContext } from '../http/pending_effects.js';
117
117
  import type { RateLimiter } from '../rate_limiter.js';
118
+ import type { NotificationSender } from './notification_sender.js';
118
119
  import type { Db } from '../db/db.js';
119
120
  import type { RpcAction } from './action_types.js';
120
121
  import type { ConnectionRegistry, ConnectionIdentity } from './connection_registry.js';
@@ -279,6 +280,8 @@ export interface WsSocketEndpoint {
279
280
  action_ip_rate_limiter: RateLimiter | null;
280
281
  /** Per-account action rate limiter; `null` turns the account check off. */
281
282
  action_account_rate_limiter: RateLimiter | null;
283
+ /** What every handler's `ctx.notification_sender` sends through. */
284
+ notification_sender: NotificationSender;
282
285
  /** Called when an eager pending effect of a frame's action rejects; `undefined` for none. */
283
286
  on_effect_error: ((error: unknown, context: EffectErrorContext) => void) | undefined;
284
287
  /** Roles the endpoint's upgrade is gated on; empty for an ungated endpoint. */
@@ -1 +1 @@
1
- {"version":3,"file":"ws_socket_session.d.ts","sourceRoot":"","sources":["../../src/lib/actions/ws_socket_session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAStD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAsBnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0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,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACjF,iEAAiE;IACjE,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,2EAA2E;IAC3E,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,oEAAoE;IACpE,mBAAmB,EAAE,kBAAkB,CAAC;IACxC,6FAA6F;IAC7F,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACrF,+EAA+E;IAC/E,cAAc,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC/B,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,cAAc,EAAE;QAAE,eAAe,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAC;IACvE;;;;OAIG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB,gGAAgG;IAChG,eAAe,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,UAAU,gBAAgB,EAC1B,SAAS,eAAe,KACtB,QA+oBF,CAAC"}
@@ -204,7 +204,7 @@ const send_error_response = (registry, connection_id, id, error) => {
204
204
  * @internal
205
205
  */
206
206
  export const create_ws_socket_events = (endpoint, upgrade) => {
207
- const { path, db, log, registry, action_map, receive_timeout, receive_tick_interval, max_message_bytes, pre_admission_queue_max_bytes, on_socket_open, on_socket_close, action_ip_rate_limiter, action_account_rate_limiter, on_effect_error, required_roles } = endpoint;
207
+ const { path, db, log, registry, action_map, receive_timeout, receive_tick_interval, max_message_bytes, pre_admission_queue_max_bytes, on_socket_open, on_socket_close, action_ip_rate_limiter, action_account_rate_limiter, notification_sender, on_effect_error, required_roles } = endpoint;
208
208
  const { client_ip, upgrade_preset, resolved, upgrade_context } = upgrade;
209
209
  // the request context's account — `register_action_ws` holds it to the
210
210
  // credential's before the upgrade
@@ -648,6 +648,7 @@ export const create_ws_socket_events = (endpoint, upgrade) => {
648
648
  pending_effects,
649
649
  post_commit_effects,
650
650
  log,
651
+ notification_sender,
651
652
  action_ip_rate_limiter,
652
653
  action_account_rate_limiter
653
654
  });