@fuzdev/fuz_app 0.51.0 → 0.52.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.
- package/dist/actions/CLAUDE.md +14 -1
- package/dist/actions/action_bridge.d.ts +3 -1
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +3 -1
- package/dist/actions/action_codegen.d.ts +18 -8
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +18 -8
- package/dist/actions/action_event.d.ts +44 -1
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +44 -1
- package/dist/actions/action_event_helpers.d.ts +26 -0
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +26 -1
- package/dist/actions/action_peer.d.ts +17 -0
- package/dist/actions/action_peer.d.ts.map +1 -1
- package/dist/actions/action_peer.js +8 -0
- package/dist/actions/action_registry.d.ts +1 -1
- package/dist/actions/action_registry.js +1 -1
- package/dist/actions/action_rpc.d.ts +4 -0
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -0
- package/dist/actions/action_spec.d.ts +22 -2
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +16 -2
- package/dist/actions/register_action_ws.d.ts +3 -0
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +3 -0
- package/dist/actions/register_ws_endpoint.d.ts +3 -0
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +3 -0
- package/dist/actions/request_tracker.svelte.d.ts +14 -1
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -1
- package/dist/actions/request_tracker.svelte.js +14 -1
- package/dist/actions/socket.svelte.d.ts +35 -15
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +33 -13
- package/dist/actions/transports.d.ts +12 -3
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +16 -7
- package/dist/actions/transports_http.d.ts +7 -0
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +7 -0
- package/dist/actions/transports_ws.d.ts +13 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +13 -0
- package/dist/actions/transports_ws_auth_guard.d.ts +6 -2
- package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
- package/dist/actions/transports_ws_auth_guard.js +6 -2
- package/dist/actions/transports_ws_backend.d.ts +14 -1
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +14 -1
- package/dist/auth/CLAUDE.md +40 -4
- package/dist/auth/account_queries.d.ts +10 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +10 -0
- package/dist/auth/admin_actions.d.ts +1 -0
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +1 -0
- package/dist/auth/api_token_queries.d.ts +7 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +7 -0
- package/dist/auth/app_settings_queries.d.ts +4 -0
- package/dist/auth/app_settings_queries.d.ts.map +1 -1
- package/dist/auth/app_settings_queries.js +4 -0
- package/dist/auth/audit_log_queries.d.ts +6 -0
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +6 -0
- package/dist/auth/audit_log_schema.d.ts +2 -0
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +134 -55
- package/dist/auth/bearer_auth.d.ts +2 -0
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +2 -0
- package/dist/auth/bootstrap_account.d.ts +3 -0
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +3 -0
- package/dist/auth/cleanup.d.ts +6 -0
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -0
- package/dist/auth/daemon_token_middleware.d.ts +4 -0
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +4 -0
- package/dist/auth/invite_queries.d.ts +4 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +4 -0
- package/dist/auth/permit_offer_action_specs.d.ts +5 -0
- package/dist/auth/permit_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/permit_offer_action_specs.js +10 -0
- package/dist/auth/permit_offer_queries.d.ts +19 -0
- package/dist/auth/permit_offer_queries.d.ts.map +1 -1
- package/dist/auth/permit_offer_queries.js +19 -0
- package/dist/auth/permit_queries.d.ts +8 -0
- package/dist/auth/permit_queries.d.ts.map +1 -1
- package/dist/auth/permit_queries.js +8 -0
- package/dist/auth/request_context.d.ts +1 -0
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +1 -0
- package/dist/auth/role_schema.d.ts +2 -0
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +2 -0
- package/dist/auth/self_service_role_actions.d.ts +1 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +1 -0
- package/dist/auth/session_lifecycle.d.ts +3 -0
- package/dist/auth/session_lifecycle.d.ts.map +1 -1
- package/dist/auth/session_lifecycle.js +3 -0
- package/dist/auth/session_middleware.d.ts +5 -0
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +5 -0
- package/dist/auth/session_queries.d.ts +9 -0
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +9 -0
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -0
- package/dist/cli/daemon.d.ts +6 -1
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +6 -1
- package/dist/db/assert_row.d.ts +2 -1
- package/dist/db/assert_row.d.ts.map +1 -1
- package/dist/db/assert_row.js +2 -1
- package/dist/db/create_db.d.ts +3 -0
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +3 -0
- package/dist/db/db.d.ts +19 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +18 -3
- package/dist/db/db_pg.d.ts +2 -1
- package/dist/db/db_pg.d.ts.map +1 -1
- package/dist/db/db_pg.js +5 -3
- package/dist/db/db_pglite.d.ts +3 -2
- package/dist/db/db_pglite.d.ts.map +1 -1
- package/dist/db/db_pglite.js +3 -2
- package/dist/db/migrate.d.ts +8 -4
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +6 -2
- package/dist/db/sql_identifier.d.ts +2 -1
- package/dist/db/sql_identifier.d.ts.map +1 -1
- package/dist/db/sql_identifier.js +2 -1
- package/dist/db/status.d.ts +4 -1
- package/dist/db/status.d.ts.map +1 -1
- package/dist/db/status.js +5 -2
- package/dist/dev/setup.d.ts +18 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +18 -2
- package/dist/env/dotenv.d.ts +2 -1
- package/dist/env/dotenv.d.ts.map +1 -1
- package/dist/env/dotenv.js +2 -1
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/env/resolve.d.ts +1 -1
- package/dist/env/resolve.js +1 -1
- package/dist/env/update_env_variable.d.ts +2 -0
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +2 -0
- package/dist/http/pending_effects.d.ts +4 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +4 -0
- package/dist/http/proxy.d.ts +3 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/route_spec.d.ts +1 -0
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +7 -0
- package/dist/rate_limiter.d.ts +14 -1
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +14 -1
- package/dist/realtime/sse.d.ts +7 -1
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +3 -1
- package/dist/realtime/sse_auth_guard.d.ts +21 -21
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.js +24 -24
- package/dist/realtime/subscriber_registry.d.ts +4 -2
- package/dist/realtime/subscriber_registry.d.ts.map +1 -1
- package/dist/realtime/subscriber_registry.js +4 -2
- package/dist/runtime/fs.d.ts +5 -0
- package/dist/runtime/fs.d.ts.map +1 -1
- package/dist/runtime/fs.js +5 -0
- package/dist/runtime/mock.d.ts +6 -0
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +6 -0
- package/dist/server/app_backend.d.ts +1 -0
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -0
- package/dist/server/app_server.d.ts +4 -0
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +4 -0
- package/dist/server/validate_nginx.d.ts +3 -0
- package/dist/server/validate_nginx.d.ts.map +1 -1
- package/dist/testing/admin_integration.d.ts +5 -0
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +5 -0
- package/dist/testing/adversarial_headers.d.ts +5 -3
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +5 -3
- package/dist/testing/adversarial_input.d.ts +4 -0
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +4 -0
- package/dist/testing/app_server.d.ts +3 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +11 -0
- package/dist/testing/assertions.d.ts +23 -7
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +23 -7
- package/dist/testing/audit_completeness.d.ts +4 -0
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -0
- package/dist/testing/auth_apps.d.ts +3 -0
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +3 -0
- package/dist/testing/db.d.ts +9 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +9 -1
- package/dist/testing/error_coverage.d.ts +9 -0
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +9 -0
- package/dist/testing/integration.d.ts +4 -0
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +4 -0
- package/dist/testing/integration_helpers.d.ts +10 -4
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +10 -4
- package/dist/testing/middleware.d.ts +5 -0
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -0
- package/dist/testing/rate_limiting.d.ts +3 -0
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -0
- package/dist/testing/rpc_helpers.d.ts +21 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +21 -8
- package/dist/testing/schema_generators.d.ts +7 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +7 -2
- package/dist/testing/sse_round_trip.d.ts +3 -0
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +3 -0
- package/dist/testing/stubs.d.ts +7 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +7 -0
- package/dist/testing/surface_invariants.d.ts +14 -0
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +14 -0
- package/dist/testing/ws_round_trip.d.ts +13 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/ui/AccountSessions.svelte +9 -0
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +10 -0
- package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAuditLog.svelte +10 -0
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +9 -0
- package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
- package/dist/ui/AdminOverview.svelte +10 -0
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminPermitHistory.svelte +9 -0
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSessions.svelte +10 -0
- package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSettings.svelte +9 -0
- package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSurface.svelte +9 -0
- package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
- package/dist/ui/AppShell.svelte +24 -0
- package/dist/ui/AppShell.svelte.d.ts +23 -0
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/BootstrapForm.svelte +17 -0
- package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/ColumnLayout.svelte +11 -0
- package/dist/ui/ColumnLayout.svelte.d.ts +10 -0
- package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -1
- package/dist/ui/Datatable.svelte +18 -0
- package/dist/ui/Datatable.svelte.d.ts +17 -0
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/LoginForm.svelte +18 -0
- package/dist/ui/LoginForm.svelte.d.ts +9 -0
- package/dist/ui/LoginForm.svelte.d.ts.map +1 -1
- package/dist/ui/LogoutButton.svelte +9 -0
- package/dist/ui/LogoutButton.svelte.d.ts +8 -0
- package/dist/ui/LogoutButton.svelte.d.ts.map +1 -1
- package/dist/ui/MenuLink.svelte +10 -0
- package/dist/ui/MenuLink.svelte.d.ts +9 -0
- package/dist/ui/MenuLink.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +9 -0
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +16 -0
- package/dist/ui/SignupForm.svelte.d.ts +4 -0
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +9 -0
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +6 -1
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -1
- package/dist/ui/auth_state.svelte.d.ts +16 -4
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +16 -4
- package/dist/ui/form_state.svelte.d.ts +9 -0
- package/dist/ui/form_state.svelte.d.ts.map +1 -1
- package/dist/ui/form_state.svelte.js +9 -0
- package/dist/ui/loadable.svelte.d.ts +6 -1
- package/dist/ui/loadable.svelte.d.ts.map +1 -1
- package/dist/ui/loadable.svelte.js +6 -1
- package/dist/ui/permit_offers_state.svelte.d.ts +2 -0
- package/dist/ui/permit_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/permit_offers_state.svelte.js +2 -0
- package/dist/ui/popover.svelte.d.ts +17 -4
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +17 -4
- package/dist/ui/position_helpers.d.ts +1 -0
- package/dist/ui/position_helpers.d.ts.map +1 -1
- package/dist/ui/position_helpers.js +1 -0
- package/dist/ui/sidebar_state.svelte.d.ts +22 -9
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -1
- package/dist/ui/sidebar_state.svelte.js +17 -2
- package/dist/ui/table_state.svelte.d.ts +14 -0
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +14 -0
- package/package.json +1 -1
package/dist/dev/setup.js
CHANGED
|
@@ -37,6 +37,7 @@ export const parse_db_name = (url) => {
|
|
|
37
37
|
*
|
|
38
38
|
* @param deps - command execution capability
|
|
39
39
|
* @returns a random 32-byte base64-encoded key
|
|
40
|
+
* @throws Error if `openssl rand` fails or is unavailable
|
|
40
41
|
*/
|
|
41
42
|
export const generate_random_key = async (deps) => {
|
|
42
43
|
const result = await deps.run_command('openssl', ['rand', '-base64', '32']);
|
|
@@ -78,6 +79,8 @@ export const read_env_var = async (deps, env_path, name) => {
|
|
|
78
79
|
* @param example_path - path to the example template
|
|
79
80
|
* @param options - extra replacements, permissions, logger
|
|
80
81
|
* @returns result indicating whether the file was created or updated
|
|
82
|
+
* @mutates filesystem - writes `env_path` (creating from `example_path` if missing) and optionally chmods to `0o600`
|
|
83
|
+
* @throws Error if `example_path` cannot be read when `env_path` is missing, or if a generator / write fails
|
|
81
84
|
*/
|
|
82
85
|
export const setup_env_file = async (deps, env_path, example_path, options) => {
|
|
83
86
|
const log = options?.log ?? default_setup_logger;
|
|
@@ -136,6 +139,8 @@ export const setup_env_file = async (deps, env_path, example_path, options) => {
|
|
|
136
139
|
* @param app_name - application name (used for default state directory)
|
|
137
140
|
* @param options - state_dir override, permissions, logger
|
|
138
141
|
* @returns result indicating whether a token was created
|
|
142
|
+
* @mutates filesystem - creates state directory and writes the token file (optionally chmods to `0o700` / `0o600`)
|
|
143
|
+
* @throws Error if `mkdir`, key generation, or `write_text_file` fails
|
|
139
144
|
*/
|
|
140
145
|
export const setup_bootstrap_token = async (deps, app_name, options) => {
|
|
141
146
|
const log = options?.log ?? default_setup_logger;
|
|
@@ -169,6 +174,8 @@ export const setup_bootstrap_token = async (deps, app_name, options) => {
|
|
|
169
174
|
* @param app_name - application name
|
|
170
175
|
* @param options - state_dir override, permissions, logger
|
|
171
176
|
* @returns result from creating the new token
|
|
177
|
+
* @mutates filesystem - removes the existing token file (if any) then writes a fresh one
|
|
178
|
+
* @throws Error if `remove` or the underlying `setup_bootstrap_token` call fails
|
|
172
179
|
*/
|
|
173
180
|
export const reset_bootstrap_token = async (deps, app_name, options) => {
|
|
174
181
|
const log = options?.log ?? default_setup_logger;
|
|
@@ -191,10 +198,14 @@ export const reset_bootstrap_token = async (deps, app_name, options) => {
|
|
|
191
198
|
/**
|
|
192
199
|
* Create a PostgreSQL database if `createdb` is available.
|
|
193
200
|
*
|
|
201
|
+
* Does not throw — returns the underlying command result so callers can
|
|
202
|
+
* decide how to react to a missing `createdb` or an "already exists" failure.
|
|
203
|
+
*
|
|
194
204
|
* @param deps - command execution capability
|
|
195
205
|
* @param db_name - database name to create
|
|
196
206
|
* @param options - logger
|
|
197
207
|
* @returns the command result
|
|
208
|
+
* @mutates external database - invokes `createdb` to create `db_name` when available
|
|
198
209
|
*/
|
|
199
210
|
export const create_database = async (deps, db_name, options) => {
|
|
200
211
|
const log = options?.log ?? default_setup_logger;
|
|
@@ -220,9 +231,11 @@ export const create_database = async (deps, db_name, options) => {
|
|
|
220
231
|
* For empty/missing URLs: skips.
|
|
221
232
|
*
|
|
222
233
|
* @param deps - command and file capabilities
|
|
223
|
-
* @param database_url - the DATABASE_URL value
|
|
224
|
-
* @param options - pglite_data_dir
|
|
234
|
+
* @param database_url - the `DATABASE_URL` value
|
|
235
|
+
* @param options - `pglite_data_dir`, logger
|
|
225
236
|
* @returns result describing what happened
|
|
237
|
+
* @mutates external database - drops and recreates the PostgreSQL database, or removes the PGlite data directory
|
|
238
|
+
* @mutates filesystem - removes `options.pglite_data_dir` recursively for PGlite URLs
|
|
226
239
|
*/
|
|
227
240
|
export const reset_database = async (deps, database_url, options) => {
|
|
228
241
|
const log = options?.log ?? default_setup_logger;
|
|
@@ -273,6 +286,9 @@ export const reset_database = async (deps, database_url, options) => {
|
|
|
273
286
|
* updates an existing password (rerun would silently rotate it).
|
|
274
287
|
*
|
|
275
288
|
* Intended for `scripts/dev_setup.ts` — do not call in production.
|
|
289
|
+
*
|
|
290
|
+
* @mutates database - inserts an account/actor pair when missing and grants any requested role permits
|
|
291
|
+
* @throws Error if an existing account is found without an associated actor row
|
|
276
292
|
*/
|
|
277
293
|
export const seed_dev_account = async (deps, input, options) => {
|
|
278
294
|
const log = options?.log ?? default_setup_logger;
|
package/dist/env/dotenv.d.ts
CHANGED
|
@@ -36,7 +36,8 @@ export declare const parse_dotenv: (content: string) => Record<string, string>;
|
|
|
36
36
|
*
|
|
37
37
|
* @param runtime - runtime with `read_text_file` capability
|
|
38
38
|
* @param path - path to env file
|
|
39
|
-
* @returns parsed env record, or null if file doesn't exist
|
|
39
|
+
* @returns parsed env record, or `null` if file doesn't exist
|
|
40
|
+
* @throws Error if reading fails for any reason other than `ENOENT` / `NotFound`
|
|
40
41
|
*/
|
|
41
42
|
export declare const load_env_file: (runtime: Pick<FsReadDeps, "read_text_file">, path: string) => Promise<Record<string, string> | null>;
|
|
42
43
|
//# sourceMappingURL=dotenv.d.ts.map
|
package/dist/env/dotenv.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotenv.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/dotenv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AAGH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAkCnE,CAAC;AAiEF
|
|
1
|
+
{"version":3,"file":"dotenv.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/dotenv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AAGH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAkCnE,CAAC;AAiEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACzB,SAAS,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAC3C,MAAM,MAAM,KACV,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CASvC,CAAC"}
|
package/dist/env/dotenv.js
CHANGED
|
@@ -135,7 +135,8 @@ const unescape_double_quoted = (s) => {
|
|
|
135
135
|
*
|
|
136
136
|
* @param runtime - runtime with `read_text_file` capability
|
|
137
137
|
* @param path - path to env file
|
|
138
|
-
* @returns parsed env record, or null if file doesn't exist
|
|
138
|
+
* @returns parsed env record, or `null` if file doesn't exist
|
|
139
|
+
* @throws Error if reading fails for any reason other than `ENOENT` / `NotFound`
|
|
139
140
|
*/
|
|
140
141
|
export const load_env_file = async (runtime, path) => {
|
|
141
142
|
try {
|
package/dist/env/load.d.ts
CHANGED
|
@@ -42,11 +42,11 @@ export declare const log_env_validation_error: (error: EnvValidationError, label
|
|
|
42
42
|
* Load and validate env vars against a Zod schema.
|
|
43
43
|
*
|
|
44
44
|
* Reads each key from the schema using `get_env`, then validates.
|
|
45
|
-
* Throws `EnvValidationError` on failure.
|
|
46
45
|
*
|
|
47
46
|
* @param schema - Zod object schema defining expected env vars
|
|
48
47
|
* @param get_env - function to read an env var by key
|
|
49
48
|
* @returns validated env object
|
|
49
|
+
* @throws EnvValidationError if Zod validation fails
|
|
50
50
|
*/
|
|
51
51
|
export declare const load_env: <T extends z.ZodObject>(schema: T, get_env: (key: string) => string | undefined) => z.infer<T>;
|
|
52
52
|
//# sourceMappingURL=load.d.ts.map
|
package/dist/env/load.js
CHANGED
|
@@ -60,11 +60,11 @@ export const log_env_validation_error = (error, label) => {
|
|
|
60
60
|
* Load and validate env vars against a Zod schema.
|
|
61
61
|
*
|
|
62
62
|
* Reads each key from the schema using `get_env`, then validates.
|
|
63
|
-
* Throws `EnvValidationError` on failure.
|
|
64
63
|
*
|
|
65
64
|
* @param schema - Zod object schema defining expected env vars
|
|
66
65
|
* @param get_env - function to read an env var by key
|
|
67
66
|
* @returns validated env object
|
|
67
|
+
* @throws EnvValidationError if Zod validation fails
|
|
68
68
|
*/
|
|
69
69
|
export const load_env = (schema, get_env) => {
|
|
70
70
|
const raw = {};
|
package/dist/env/resolve.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare const resolve_env_vars_in_object: <T extends Record<string, unkno
|
|
|
56
56
|
* @param value - string with `$$VAR$$` references
|
|
57
57
|
* @param context - description for error message (e.g., `"target.host"`)
|
|
58
58
|
* @returns resolved string
|
|
59
|
-
* @throws
|
|
59
|
+
* @throws Error if any referenced env var is missing or empty
|
|
60
60
|
*/
|
|
61
61
|
export declare const resolve_env_vars_required: (runtime: Pick<EnvDeps, "env_get">, value: string, context: string) => string;
|
|
62
62
|
/**
|
package/dist/env/resolve.js
CHANGED
|
@@ -85,7 +85,7 @@ export const resolve_env_vars_in_object = (runtime, obj) => {
|
|
|
85
85
|
* @param value - string with `$$VAR$$` references
|
|
86
86
|
* @param context - description for error message (e.g., `"target.host"`)
|
|
87
87
|
* @returns resolved string
|
|
88
|
-
* @throws
|
|
88
|
+
* @throws Error if any referenced env var is missing or empty
|
|
89
89
|
*/
|
|
90
90
|
export const resolve_env_vars_required = (runtime, value, context) => {
|
|
91
91
|
const missing = [];
|
|
@@ -31,6 +31,8 @@ export interface UpdateEnvVariableOptions {
|
|
|
31
31
|
* @param key - the environment variable name (e.g., `'SOME_CONFIGURATION_KEY'`)
|
|
32
32
|
* @param value - the new value for the environment variable
|
|
33
33
|
* @param options - file path and optional read/write overrides
|
|
34
|
+
* @mutates filesystem - writes the updated content back to `options.env_file_path`
|
|
35
|
+
* @throws Error if the file read fails for any reason other than `ENOENT`, or if the write fails
|
|
34
36
|
*/
|
|
35
37
|
export declare const update_env_variable: (key: string, value: string, options: UpdateEnvVariableOptions) => Promise<void>;
|
|
36
38
|
//# sourceMappingURL=update_env_variable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update_env_variable.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/update_env_variable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,oFAAoF;IACpF,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChF;AAED
|
|
1
|
+
{"version":3,"file":"update_env_variable.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/env/update_env_variable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,oFAAoF;IACpF,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,GAC/B,KAAK,MAAM,EACX,OAAO,MAAM,EACb,SAAS,wBAAwB,KAC/B,OAAO,CAAC,IAAI,CAmDd,CAAC"}
|
|
@@ -22,6 +22,8 @@ import { resolve } from 'node:path';
|
|
|
22
22
|
* @param key - the environment variable name (e.g., `'SOME_CONFIGURATION_KEY'`)
|
|
23
23
|
* @param value - the new value for the environment variable
|
|
24
24
|
* @param options - file path and optional read/write overrides
|
|
25
|
+
* @mutates filesystem - writes the updated content back to `options.env_file_path`
|
|
26
|
+
* @throws Error if the file read fails for any reason other than `ENOENT`, or if the write fails
|
|
25
27
|
*/
|
|
26
28
|
export const update_env_variable = async (key, value, options) => {
|
|
27
29
|
const { env_file_path, read_file = readFile, write_file = writeFile } = options;
|
|
@@ -24,6 +24,10 @@ export interface PendingEffectsContext {
|
|
|
24
24
|
* Exceptions thrown by `fn` are caught and logged via `ctx.log.error`, so one
|
|
25
25
|
* failed send cannot corrupt the already-committed response or starve other
|
|
26
26
|
* queued effects in the same tick.
|
|
27
|
+
*
|
|
28
|
+
* @param ctx - context carrying `log` and the `pending_effects` queue
|
|
29
|
+
* @param fn - synchronous side effect to run after commit
|
|
30
|
+
* @mutates `ctx.pending_effects` - appends a never-rejecting promise wrapping `fn`
|
|
27
31
|
*/
|
|
28
32
|
export declare const emit_after_commit: (ctx: PendingEffectsContext, fn: () => void) => void;
|
|
29
33
|
//# sourceMappingURL=pending_effects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending_effects.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/pending_effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACtC;AAED
|
|
1
|
+
{"version":3,"file":"pending_effects.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/pending_effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACtC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,qBAAqB,EAAE,IAAI,MAAM,IAAI,KAAG,IAU9E,CAAC"}
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
* Exceptions thrown by `fn` are caught and logged via `ctx.log.error`, so one
|
|
19
19
|
* failed send cannot corrupt the already-committed response or starve other
|
|
20
20
|
* queued effects in the same tick.
|
|
21
|
+
*
|
|
22
|
+
* @param ctx - context carrying `log` and the `pending_effects` queue
|
|
23
|
+
* @param fn - synchronous side effect to run after commit
|
|
24
|
+
* @mutates `ctx.pending_effects` - appends a never-rejecting promise wrapping `fn`
|
|
21
25
|
*/
|
|
22
26
|
export const emit_after_commit = (ctx, fn) => {
|
|
23
27
|
ctx.pending_effects.push(Promise.resolve().then(() => {
|
package/dist/http/proxy.d.ts
CHANGED
|
@@ -92,6 +92,8 @@ export declare const resolve_client_ip: (forwarded_for: string, proxies: Array<P
|
|
|
92
92
|
* right-to-left, strip trusted entries, use first untrusted entry.
|
|
93
93
|
*
|
|
94
94
|
* @param options - trusted proxy configuration
|
|
95
|
+
* @mutates `c.var.client_ip` - set to the resolved (or `'unknown'`) client IP per request
|
|
96
|
+
* @throws Error if any entry in `options.trusted_proxies` is invalid (parsed eagerly via `parse_proxy_entry`)
|
|
95
97
|
*/
|
|
96
98
|
export declare const create_proxy_middleware: (options: ProxyOptions) => MiddlewareHandler;
|
|
97
99
|
/**
|
|
@@ -100,6 +102,7 @@ export declare const create_proxy_middleware: (options: ProxyOptions) => Middlew
|
|
|
100
102
|
* Apply before auth middleware so `client_ip` is available for rate limiting.
|
|
101
103
|
*
|
|
102
104
|
* @param options - trusted proxy configuration
|
|
105
|
+
* @throws Error if any entry in `options.trusted_proxies` is invalid (delegates to `create_proxy_middleware`)
|
|
103
106
|
*/
|
|
104
107
|
export declare const create_proxy_middleware_spec: (options: ProxyOptions) => MiddlewareSpec;
|
|
105
108
|
/**
|
package/dist/http/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,MAQzC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,sFAAsF;IACtF,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACtD,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACpB;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAC7B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,CAAC;AAElF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,WA6CjD,CAAC;AAiBF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,EAAE,SAAS,KAAK,CAAC,WAAW,CAAC,KAAG,OAqBvE,CAAC;AAQF;;;;;;;;;;;GAWG;A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eAAO,MAAM,iBAAiB,GAC7B,eAAe,MAAM,EACrB,SAAS,KAAK,CAAC,WAAW,CAAC,KACzB,MAAM,GAAG,SAiBX,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,YAAY,KAAG,iBAyC/D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,YAAY,KAAG,cAInE,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,MAAyC,CAAC"}
|
package/dist/http/proxy.js
CHANGED
|
@@ -176,6 +176,8 @@ export const resolve_client_ip = (forwarded_for, proxies) => {
|
|
|
176
176
|
* right-to-left, strip trusted entries, use first untrusted entry.
|
|
177
177
|
*
|
|
178
178
|
* @param options - trusted proxy configuration
|
|
179
|
+
* @mutates `c.var.client_ip` - set to the resolved (or `'unknown'`) client IP per request
|
|
180
|
+
* @throws Error if any entry in `options.trusted_proxies` is invalid (parsed eagerly via `parse_proxy_entry`)
|
|
179
181
|
*/
|
|
180
182
|
export const create_proxy_middleware = (options) => {
|
|
181
183
|
const parsed_proxies = options.trusted_proxies.map(parse_proxy_entry);
|
|
@@ -225,6 +227,7 @@ export const create_proxy_middleware = (options) => {
|
|
|
225
227
|
* Apply before auth middleware so `client_ip` is available for rate limiting.
|
|
226
228
|
*
|
|
227
229
|
* @param options - trusted proxy configuration
|
|
230
|
+
* @throws Error if any entry in `options.trusted_proxies` is invalid (delegates to `create_proxy_middleware`)
|
|
228
231
|
*/
|
|
229
232
|
export const create_proxy_middleware_spec = (options) => ({
|
|
230
233
|
name: 'trusted_proxy',
|
|
@@ -185,6 +185,7 @@ export declare const apply_middleware_specs: (app: Hono, specs: Array<Middleware
|
|
|
185
185
|
* @param log - the logger instance
|
|
186
186
|
* @param db - database instance for transaction wrapping and `RouteContext`
|
|
187
187
|
* @mutates `app`
|
|
188
|
+
* @throws Error if two specs share the same `method` + `path` (each combination must be unique)
|
|
188
189
|
*/
|
|
189
190
|
export declare const apply_route_specs: (app: Hono, specs: Array<RouteSpec>, resolve_auth_guards: AuthGuardResolver, log: Logger, db: Db) => void;
|
|
190
191
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAW,IAAI,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AACpE,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAKjB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAClB;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GACd;IAAC,IAAI,EAAE,eAAe,CAAA;CAAC,GACvB;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAC5B;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAC,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAE9E,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B,8DAA8D;IAC9D,EAAE,EAAE,EAAE,CAAC;IACP,oFAAo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ACJ,IAsCF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,SAAS,CAK3F,CAAC"}
|
package/dist/http/route_spec.js
CHANGED
|
@@ -60,6 +60,8 @@ export const get_route_query = (c) => {
|
|
|
60
60
|
* and for null-input routes (no body expected). For other routes with input
|
|
61
61
|
* schemas, returns a middleware that parses and validates the JSON body,
|
|
62
62
|
* storing the result on the context as `validated_input`.
|
|
63
|
+
*
|
|
64
|
+
* @mutates `c.var.validated_input` - set to the parsed and validated body on success
|
|
63
65
|
*/
|
|
64
66
|
const create_input_validation = (input_schema, method) => {
|
|
65
67
|
if (method === 'GET')
|
|
@@ -92,6 +94,8 @@ const create_input_validation = (input_schema, method) => {
|
|
|
92
94
|
* Returns an empty array when no params schema is defined.
|
|
93
95
|
* For routes with params schemas, returns a middleware that validates
|
|
94
96
|
* `c.req.param()` against the schema, storing the result on the context as `validated_params`.
|
|
97
|
+
*
|
|
98
|
+
* @mutates `c.var.validated_params` - set to the parsed and validated path params on success
|
|
95
99
|
*/
|
|
96
100
|
const create_params_validation = (params_schema) => {
|
|
97
101
|
if (!params_schema)
|
|
@@ -113,6 +117,8 @@ const create_params_validation = (params_schema) => {
|
|
|
113
117
|
* Returns an empty array when no query schema is defined.
|
|
114
118
|
* For routes with query schemas, returns a middleware that validates
|
|
115
119
|
* `c.req.query()` against the schema, storing the result on the context as `validated_query`.
|
|
120
|
+
*
|
|
121
|
+
* @mutates `c.var.validated_query` - set to the parsed and validated query params on success
|
|
116
122
|
*/
|
|
117
123
|
const create_query_validation = (query_schema) => {
|
|
118
124
|
if (!query_schema)
|
|
@@ -238,6 +244,7 @@ const wrap_error_catch = (handler, log) => {
|
|
|
238
244
|
* @param log - the logger instance
|
|
239
245
|
* @param db - database instance for transaction wrapping and `RouteContext`
|
|
240
246
|
* @mutates `app`
|
|
247
|
+
* @throws Error if two specs share the same `method` + `path` (each combination must be unique)
|
|
241
248
|
*/
|
|
242
249
|
export const apply_route_specs = (app, specs, resolve_auth_guards, log, db) => {
|
|
243
250
|
const registered = new Set();
|
package/dist/rate_limiter.d.ts
CHANGED
|
@@ -83,8 +83,13 @@ export declare class RateLimiter {
|
|
|
83
83
|
/**
|
|
84
84
|
* Check whether `key` is allowed without recording an attempt.
|
|
85
85
|
*
|
|
86
|
+
* Prunes timestamps that fell outside the window as a side effect (and
|
|
87
|
+
* removes the key entirely when none remain), so the backing map stays
|
|
88
|
+
* bounded even under read-only traffic.
|
|
89
|
+
*
|
|
86
90
|
* @param key - rate limit key (e.g. IP address)
|
|
87
91
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
92
|
+
* @mutates internal map - prunes expired timestamps for `key`
|
|
88
93
|
*/
|
|
89
94
|
check(key: string, now?: number): RateLimitResult;
|
|
90
95
|
/**
|
|
@@ -92,19 +97,27 @@ export declare class RateLimiter {
|
|
|
92
97
|
*
|
|
93
98
|
* @param key - rate limit key (e.g. IP address)
|
|
94
99
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
100
|
+
* @mutates internal map - appends `now` to the timestamp list for `key` (after pruning expired entries)
|
|
95
101
|
*/
|
|
96
102
|
record(key: string, now?: number): RateLimitResult;
|
|
97
103
|
/**
|
|
98
104
|
* Clear all attempts for `key` (e.g. after successful login).
|
|
105
|
+
*
|
|
106
|
+
* @mutates internal map - removes the entry for `key`
|
|
99
107
|
*/
|
|
100
108
|
reset(key: string): void;
|
|
101
109
|
/**
|
|
102
110
|
* Remove entries whose timestamps are all outside the window.
|
|
103
111
|
*
|
|
104
112
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
113
|
+
* @mutates internal map - prunes expired timestamps and deletes empty keys
|
|
105
114
|
*/
|
|
106
115
|
cleanup(now?: number): void;
|
|
107
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Stop the cleanup timer. Safe to call multiple times.
|
|
118
|
+
*
|
|
119
|
+
* @mutates timer - clears the cleanup `setInterval` and nulls the handle
|
|
120
|
+
*/
|
|
108
121
|
dispose(): void;
|
|
109
122
|
}
|
|
110
123
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/rate_limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAKlC;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,iFAAiF;AACjF,eAAO,MAAM,2BAA2B,EAAE,kBAKzC,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,gCAAgC,EAAE,kBAK9C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW;;IACvB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAOzB,OAAO,EAAE,kBAAkB;IAcvC,8BAA8B;IAC9B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED
|
|
1
|
+
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/rate_limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAA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mB,GAAI,UAAU,OAAO,CAAC,kBAAkB,CAAC,KAAG,WAE3E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,GAAG,OAAO,EAAE,aAAa,MAAM,KAAG,QAI7E,CAAC"}
|
package/dist/rate_limiter.js
CHANGED
|
@@ -71,8 +71,13 @@ export class RateLimiter {
|
|
|
71
71
|
/**
|
|
72
72
|
* Check whether `key` is allowed without recording an attempt.
|
|
73
73
|
*
|
|
74
|
+
* Prunes timestamps that fell outside the window as a side effect (and
|
|
75
|
+
* removes the key entirely when none remain), so the backing map stays
|
|
76
|
+
* bounded even under read-only traffic.
|
|
77
|
+
*
|
|
74
78
|
* @param key - rate limit key (e.g. IP address)
|
|
75
79
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
80
|
+
* @mutates internal map - prunes expired timestamps for `key`
|
|
76
81
|
*/
|
|
77
82
|
check(key, now = Date.now()) {
|
|
78
83
|
const { max_attempts, window_ms } = this.options;
|
|
@@ -102,6 +107,7 @@ export class RateLimiter {
|
|
|
102
107
|
*
|
|
103
108
|
* @param key - rate limit key (e.g. IP address)
|
|
104
109
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
110
|
+
* @mutates internal map - appends `now` to the timestamp list for `key` (after pruning expired entries)
|
|
105
111
|
*/
|
|
106
112
|
record(key, now = Date.now()) {
|
|
107
113
|
const { max_attempts, window_ms } = this.options;
|
|
@@ -128,6 +134,8 @@ export class RateLimiter {
|
|
|
128
134
|
}
|
|
129
135
|
/**
|
|
130
136
|
* Clear all attempts for `key` (e.g. after successful login).
|
|
137
|
+
*
|
|
138
|
+
* @mutates internal map - removes the entry for `key`
|
|
131
139
|
*/
|
|
132
140
|
reset(key) {
|
|
133
141
|
this.#attempts.delete(key);
|
|
@@ -136,6 +144,7 @@ export class RateLimiter {
|
|
|
136
144
|
* Remove entries whose timestamps are all outside the window.
|
|
137
145
|
*
|
|
138
146
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
147
|
+
* @mutates internal map - prunes expired timestamps and deletes empty keys
|
|
139
148
|
*/
|
|
140
149
|
cleanup(now = Date.now()) {
|
|
141
150
|
const cutoff = now - this.options.window_ms;
|
|
@@ -153,7 +162,11 @@ export class RateLimiter {
|
|
|
153
162
|
}
|
|
154
163
|
}
|
|
155
164
|
}
|
|
156
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Stop the cleanup timer. Safe to call multiple times.
|
|
167
|
+
*
|
|
168
|
+
* @mutates timer - clears the cleanup `setInterval` and nulls the handle
|
|
169
|
+
*/
|
|
157
170
|
dispose() {
|
|
158
171
|
if (this.#cleanup_timer !== null) {
|
|
159
172
|
clearInterval(this.#cleanup_timer);
|
package/dist/realtime/sse.d.ts
CHANGED
|
@@ -47,7 +47,8 @@ export interface SseNotification {
|
|
|
47
47
|
* Hono's HTML callback resolution — keeps the same `data: JSON\n\n` format.
|
|
48
48
|
*
|
|
49
49
|
* @param c - Hono context
|
|
50
|
-
* @
|
|
50
|
+
* @param log - logger for serialization and `on_close` listener errors
|
|
51
|
+
* @returns object with the streaming `Response` and an `SseStream` controller
|
|
51
52
|
*/
|
|
52
53
|
export declare const create_sse_response: <T = unknown>(c: Context, log: Logger) => {
|
|
53
54
|
response: Response;
|
|
@@ -57,9 +58,13 @@ export declare const create_sse_response: <T = unknown>(c: Context, log: Logger)
|
|
|
57
58
|
export declare const SSE_CONNECTED_COMMENT = ": connected\n\n";
|
|
58
59
|
/** Spec for a push event — declares params schema, description, and channel. */
|
|
59
60
|
export interface EventSpec {
|
|
61
|
+
/** Event method name, used as the JSON-RPC notification `method`. */
|
|
60
62
|
method: string;
|
|
63
|
+
/** Zod schema for the notification `params` payload. */
|
|
61
64
|
params: z.ZodType;
|
|
65
|
+
/** Human-readable description for surface output and docs. */
|
|
62
66
|
description: string;
|
|
67
|
+
/** Channel this event broadcasts on. Omit for cross-channel events. */
|
|
63
68
|
channel?: string;
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
@@ -70,6 +75,7 @@ export interface EventSpec {
|
|
|
70
75
|
*
|
|
71
76
|
* @param broadcaster - duck-typed broadcaster (e.g. `SubscriberRegistry`)
|
|
72
77
|
* @param event_specs - event specs to validate against
|
|
78
|
+
* @param log - logger used to emit DEV warnings on unknown methods or param mismatches
|
|
73
79
|
* @returns validated broadcaster wrapper (passthrough in production)
|
|
74
80
|
*/
|
|
75
81
|
export declare const create_validated_broadcaster: <T extends SseNotification>(broadcaster: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACrC,mDAAmD;IACnD,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,wBAAwB;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,+FAA+F;IAC/F,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC/B,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,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,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAAC,EAC5D,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,KAAK,MAAM,KACT;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAmBhD,CAAC"}
|
package/dist/realtime/sse.js
CHANGED
|
@@ -21,7 +21,8 @@ import { DEV } from 'esm-env';
|
|
|
21
21
|
* Hono's HTML callback resolution — keeps the same `data: JSON\n\n` format.
|
|
22
22
|
*
|
|
23
23
|
* @param c - Hono context
|
|
24
|
-
* @
|
|
24
|
+
* @param log - logger for serialization and `on_close` listener errors
|
|
25
|
+
* @returns object with the streaming `Response` and an `SseStream` controller
|
|
25
26
|
*/
|
|
26
27
|
export const create_sse_response = (c, log) => {
|
|
27
28
|
const { promise, resolve } = Promise.withResolvers();
|
|
@@ -84,6 +85,7 @@ export const SSE_CONNECTED_COMMENT = `: connected\n\n`;
|
|
|
84
85
|
*
|
|
85
86
|
* @param broadcaster - duck-typed broadcaster (e.g. `SubscriberRegistry`)
|
|
86
87
|
* @param event_specs - event specs to validate against
|
|
88
|
+
* @param log - logger used to emit DEV warnings on unknown methods or param mismatches
|
|
87
89
|
* @returns validated broadcaster wrapper (passthrough in production)
|
|
88
90
|
*/
|
|
89
91
|
export const create_validated_broadcaster = (broadcaster, event_specs, log) => {
|
|
@@ -63,6 +63,24 @@ export interface AuditLogSse {
|
|
|
63
63
|
/** The underlying registry — exposed for subscriber count monitoring. */
|
|
64
64
|
registry: SubscriberRegistry<SseNotification>;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* SSE event specs for audit log events.
|
|
68
|
+
*
|
|
69
|
+
* One spec per `AUDIT_EVENT_TYPES` entry, all sharing the `AuditLogEventJson` params schema.
|
|
70
|
+
* Pass to `create_app_server`'s `event_specs` for surface generation and DEV validation.
|
|
71
|
+
*/
|
|
72
|
+
export declare const AUDIT_LOG_EVENT_SPECS: Array<EventSpec>;
|
|
73
|
+
/**
|
|
74
|
+
* Default max concurrent SSE subscribers per session scope for the audit log.
|
|
75
|
+
*
|
|
76
|
+
* The audit log SSE subscribes with `scope = session_hash` and
|
|
77
|
+
* `groups = [account_id]`. Only `scope` is capped — so this limits tabs
|
|
78
|
+
* per session. An account's total streams across all sessions is bounded
|
|
79
|
+
* transitively by `max_sessions × AUDIT_LOG_SSE_MAX_PER_SCOPE`. 10 tabs
|
|
80
|
+
* per session is a comfortable ceiling for normal use; consumers raising
|
|
81
|
+
* it above ~50 should consider server-side connection limits.
|
|
82
|
+
*/
|
|
83
|
+
export declare const AUDIT_LOG_SSE_MAX_PER_SCOPE = 10;
|
|
66
84
|
/**
|
|
67
85
|
* Create a complete audit log SSE setup with broadcasting and auth guard.
|
|
68
86
|
*
|
|
@@ -70,6 +88,9 @@ export interface AuditLogSse {
|
|
|
70
88
|
* call into a single object. The result satisfies `AuditLogRouteOptions['stream']`
|
|
71
89
|
* and provides the `on_audit_event` callback for `CreateAppBackendOptions`.
|
|
72
90
|
*
|
|
91
|
+
* @param options - factory options
|
|
92
|
+
* @returns audit log SSE setup (stream options + `on_audit_event` + registry)
|
|
93
|
+
*
|
|
73
94
|
* @example
|
|
74
95
|
* ```ts
|
|
75
96
|
* const audit_sse = create_audit_log_sse({log});
|
|
@@ -83,28 +104,7 @@ export interface AuditLogSse {
|
|
|
83
104
|
* // In create_app_server options:
|
|
84
105
|
* event_specs: AUDIT_LOG_EVENT_SPECS,
|
|
85
106
|
* ```
|
|
86
|
-
*
|
|
87
|
-
* @param options - factory options
|
|
88
|
-
* @returns audit log SSE setup (stream options + on_audit_event + registry)
|
|
89
|
-
*/
|
|
90
|
-
/**
|
|
91
|
-
* SSE event specs for audit log events.
|
|
92
|
-
*
|
|
93
|
-
* One spec per `AUDIT_EVENT_TYPES` entry, all sharing the `AuditLogEventJson` params schema.
|
|
94
|
-
* Pass to `create_app_server`'s `event_specs` for surface generation and DEV validation.
|
|
95
|
-
*/
|
|
96
|
-
export declare const AUDIT_LOG_EVENT_SPECS: Array<EventSpec>;
|
|
97
|
-
/**
|
|
98
|
-
* Default max concurrent SSE subscribers per session scope for the audit log.
|
|
99
|
-
*
|
|
100
|
-
* The audit log SSE subscribes with `scope = session_hash` and
|
|
101
|
-
* `groups = [account_id]`. Only `scope` is capped — so this limits tabs
|
|
102
|
-
* per session. An account's total streams across all sessions is bounded
|
|
103
|
-
* transitively by `max_sessions × AUDIT_LOG_SSE_MAX_PER_SCOPE`. 10 tabs
|
|
104
|
-
* per session is a comfortable ceiling for normal use; consumers raising
|
|
105
|
-
* it above ~50 should consider server-side connection limits.
|
|
106
107
|
*/
|
|
107
|
-
export declare const AUDIT_LOG_SSE_MAX_PER_SCOPE = 10;
|
|
108
108
|
export declare const create_audit_log_sse: (options: {
|
|
109
109
|
/** Role required to access the SSE endpoint. Default `'admin'`. */
|
|
110
110
|
role?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse_auth_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse_auth_guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAE,KAAK,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AACnF,OAAO,KAAK,EAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAEpE,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAKrD,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EACtC,UAAU,kBAAkB,CA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KAAK,IAAI,CA6CjC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,8FAA8F;IAC9F,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,MAAM,IAAI,CAAC;IAC1F,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IACZ,kGAAkG;IAClG,cAAc,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,yEAAyE;IACzE,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CAC9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,SAAS,CAOlD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS;IAC7C,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,KAAG,WAgBH,CAAC"}
|
|
@@ -92,30 +92,6 @@ export const create_sse_auth_guard = (registry, required_role, log) => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
};
|
|
95
|
-
/**
|
|
96
|
-
* Create a complete audit log SSE setup with broadcasting and auth guard.
|
|
97
|
-
*
|
|
98
|
-
* Combines `SubscriberRegistry`, `create_sse_auth_guard`, and the broadcast
|
|
99
|
-
* call into a single object. The result satisfies `AuditLogRouteOptions['stream']`
|
|
100
|
-
* and provides the `on_audit_event` callback for `CreateAppBackendOptions`.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* const audit_sse = create_audit_log_sse({log});
|
|
105
|
-
*
|
|
106
|
-
* // In create_app_backend options:
|
|
107
|
-
* on_audit_event: audit_sse.on_audit_event,
|
|
108
|
-
*
|
|
109
|
-
* // In create_route_specs:
|
|
110
|
-
* create_audit_log_route_specs({stream: audit_sse});
|
|
111
|
-
*
|
|
112
|
-
* // In create_app_server options:
|
|
113
|
-
* event_specs: AUDIT_LOG_EVENT_SPECS,
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* @param options - factory options
|
|
117
|
-
* @returns audit log SSE setup (stream options + on_audit_event + registry)
|
|
118
|
-
*/
|
|
119
95
|
/**
|
|
120
96
|
* SSE event specs for audit log events.
|
|
121
97
|
*
|
|
@@ -139,6 +115,30 @@ export const AUDIT_LOG_EVENT_SPECS = AUDIT_EVENT_TYPES.map((event_type) => ({
|
|
|
139
115
|
* it above ~50 should consider server-side connection limits.
|
|
140
116
|
*/
|
|
141
117
|
export const AUDIT_LOG_SSE_MAX_PER_SCOPE = 10;
|
|
118
|
+
/**
|
|
119
|
+
* Create a complete audit log SSE setup with broadcasting and auth guard.
|
|
120
|
+
*
|
|
121
|
+
* Combines `SubscriberRegistry`, `create_sse_auth_guard`, and the broadcast
|
|
122
|
+
* call into a single object. The result satisfies `AuditLogRouteOptions['stream']`
|
|
123
|
+
* and provides the `on_audit_event` callback for `CreateAppBackendOptions`.
|
|
124
|
+
*
|
|
125
|
+
* @param options - factory options
|
|
126
|
+
* @returns audit log SSE setup (stream options + `on_audit_event` + registry)
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const audit_sse = create_audit_log_sse({log});
|
|
131
|
+
*
|
|
132
|
+
* // In create_app_backend options:
|
|
133
|
+
* on_audit_event: audit_sse.on_audit_event,
|
|
134
|
+
*
|
|
135
|
+
* // In create_route_specs:
|
|
136
|
+
* create_audit_log_route_specs({stream: audit_sse});
|
|
137
|
+
*
|
|
138
|
+
* // In create_app_server options:
|
|
139
|
+
* event_specs: AUDIT_LOG_EVENT_SPECS,
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
142
|
export const create_audit_log_sse = (options) => {
|
|
143
143
|
const role = options.role ?? 'admin';
|
|
144
144
|
const max_per_scope = options.max_per_scope === undefined ? AUDIT_LOG_SSE_MAX_PER_SCOPE : options.max_per_scope;
|
|
@@ -101,8 +101,9 @@ export declare class SubscriberRegistry<T> {
|
|
|
101
101
|
* Add a subscriber.
|
|
102
102
|
*
|
|
103
103
|
* @param stream - SSE stream to send data to
|
|
104
|
-
* @param options - channel filter and identity slots (scope + groups)
|
|
104
|
+
* @param options - channel filter and identity slots (`scope` + `groups`)
|
|
105
105
|
* @returns unsubscribe function
|
|
106
|
+
* @mutates registry - adds the new subscriber; closes oldest matching subscribers when `max_per_scope` is exceeded
|
|
106
107
|
*/
|
|
107
108
|
subscribe(stream: SseStream<T>, options?: SubscribeOptions): () => void;
|
|
108
109
|
/**
|
|
@@ -122,8 +123,9 @@ export declare class SubscriberRegistry<T> {
|
|
|
122
123
|
* Use for auth revocation — when a user's permissions change, close their
|
|
123
124
|
* SSE connections so they must reconnect and re-authenticate.
|
|
124
125
|
*
|
|
125
|
-
* @param identity - the identity key to match (checked against scope and groups)
|
|
126
|
+
* @param identity - the identity key to match (checked against `scope` and `groups`)
|
|
126
127
|
* @returns the number of subscribers closed
|
|
128
|
+
* @mutates registry - removes matching subscribers and closes their streams
|
|
127
129
|
*/
|
|
128
130
|
close_by_identity(identity: string): number;
|
|
129
131
|
}
|