@fuzdev/fuz_app 0.140.0 → 0.142.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 +72 -22
- package/dist/actions/action_rpc.d.ts +5 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +9 -1
- package/dist/actions/connection_closer.d.ts +44 -4
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +33 -3
- package/dist/actions/perform_action.d.ts +10 -0
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +23 -9
- package/dist/actions/register_action_ws.d.ts +42 -6
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +87 -19
- package/dist/actions/register_ws_endpoint.d.ts +15 -6
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +10 -4
- package/dist/actions/socket.svelte.d.ts +19 -4
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +31 -4
- package/dist/actions/transports.d.ts +30 -1
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +30 -1
- package/dist/actions/transports_ws_auth_guard.d.ts +13 -6
- package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
- package/dist/actions/transports_ws_auth_guard.js +24 -10
- package/dist/actions/transports_ws_backend.d.ts +51 -5
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +62 -9
- package/dist/actions/ws_endpoint_spec.d.ts +11 -10
- package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
- package/dist/auth/CLAUDE.md +44 -22
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +12 -1
- package/dist/auth/account_route_schema.d.ts +1 -0
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +12 -0
- package/dist/auth/account_routes.d.ts +7 -2
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +240 -187
- package/dist/auth/admin_action_specs.d.ts +6 -1
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +6 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +14 -2
- package/dist/auth/api_token.d.ts +20 -0
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +21 -1
- package/dist/auth/api_token_queries.d.ts +22 -4
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +11 -6
- package/dist/auth/audit_log_routes.d.ts +10 -0
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +20 -0
- package/dist/auth/audit_log_schema.d.ts +30 -5
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +30 -0
- package/dist/auth/bearer_auth.d.ts +4 -2
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +19 -8
- package/dist/auth/bootstrap_route_schema.d.ts +1 -0
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +1 -0
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +85 -76
- package/dist/auth/cell_action_specs.d.ts +7 -3
- package/dist/auth/cell_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_action_specs.js +9 -5
- package/dist/auth/cell_actions.d.ts +3 -3
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +67 -38
- package/dist/auth/cell_authorize.d.ts +69 -8
- package/dist/auth/cell_authorize.d.ts.map +1 -1
- package/dist/auth/cell_authorize.js +89 -9
- package/dist/auth/cell_field_action_specs.d.ts +5 -4
- package/dist/auth/cell_field_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_field_action_specs.js +7 -7
- package/dist/auth/cell_field_actions.d.ts +7 -5
- package/dist/auth/cell_field_actions.d.ts.map +1 -1
- package/dist/auth/cell_field_actions.js +24 -22
- package/dist/auth/cell_grant_action_specs.d.ts +6 -0
- package/dist/auth/cell_grant_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_grant_action_specs.js +6 -0
- package/dist/auth/cell_grant_actions.d.ts +3 -1
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +16 -2
- package/dist/auth/cell_item_action_specs.d.ts +5 -4
- package/dist/auth/cell_item_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_item_action_specs.js +7 -7
- package/dist/auth/cell_item_actions.d.ts +6 -5
- package/dist/auth/cell_item_actions.d.ts.map +1 -1
- package/dist/auth/cell_item_actions.js +23 -22
- package/dist/auth/cell_relation_list_limit.d.ts +20 -0
- package/dist/auth/cell_relation_list_limit.d.ts.map +1 -0
- package/dist/auth/cell_relation_list_limit.js +27 -0
- package/dist/auth/cell_relation_visibility.d.ts +4 -3
- package/dist/auth/cell_relation_visibility.d.ts.map +1 -1
- package/dist/auth/cell_relation_visibility.js +6 -5
- package/dist/auth/cell_steward.d.ts +45 -0
- package/dist/auth/cell_steward.d.ts.map +1 -0
- package/dist/auth/cell_steward.js +53 -0
- package/dist/auth/cleanup.d.ts +9 -9
- package/dist/auth/cleanup.js +9 -9
- package/dist/auth/credential_deadline.d.ts +95 -0
- package/dist/auth/credential_deadline.d.ts.map +1 -0
- package/dist/auth/credential_deadline.js +139 -0
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +4 -1
- package/dist/auth/middleware.d.ts +90 -12
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +115 -16
- package/dist/auth/request_context.d.ts +8 -2
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +20 -4
- package/dist/auth/resolved_auth.d.ts +13 -2
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +5 -4
- package/dist/auth/role_grant_offer_action_specs.d.ts +5 -0
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +6 -1
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +23 -16
- package/dist/auth/role_grant_offer_queries.d.ts +8 -6
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +16 -8
- package/dist/auth/session_cookie.d.ts +4 -0
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +3 -2
- package/dist/auth/session_middleware.d.ts +1 -1
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +4 -1
- package/dist/auth/session_queries.d.ts +19 -2
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +8 -2
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +1 -0
- package/dist/auth/signup_routes.d.ts +4 -3
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +157 -134
- package/dist/auth/token_scope.d.ts +7 -1
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +8 -2
- package/dist/db/CLAUDE.md +32 -19
- package/dist/db/cell_ddl.d.ts +1 -2
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +1 -2
- package/dist/db/cell_field_queries.d.ts +20 -18
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.js +28 -22
- package/dist/db/cell_item_queries.d.ts +20 -14
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.js +28 -18
- package/dist/db/cell_moderation.d.ts +67 -0
- package/dist/db/cell_moderation.d.ts.map +1 -0
- package/dist/db/cell_moderation.js +66 -0
- package/dist/db/cell_queries.d.ts +44 -14
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +68 -45
- package/dist/db/cell_view_sql.d.ts +102 -0
- package/dist/db/cell_view_sql.d.ts.map +1 -0
- package/dist/db/cell_view_sql.js +112 -0
- package/dist/db/db_pg.d.ts +1 -1
- package/dist/db/db_pg.js +1 -1
- package/dist/hono_context.d.ts +23 -0
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +19 -0
- package/dist/http/CLAUDE.md +41 -15
- package/dist/http/auth_shape.d.ts +5 -2
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +5 -2
- package/dist/http/ip_canonical.d.ts +30 -3
- package/dist/http/ip_canonical.d.ts.map +1 -1
- package/dist/http/ip_canonical.js +50 -3
- package/dist/http/middleware_spec.d.ts +16 -0
- package/dist/http/middleware_spec.d.ts.map +1 -1
- package/dist/http/origin.d.ts +113 -18
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +247 -127
- package/dist/http/route_spec.d.ts +21 -0
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/schema_helpers.d.ts +22 -0
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +24 -0
- package/dist/http/surface.d.ts +6 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +12 -5
- package/dist/primitive_schemas.d.ts +10 -1
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +11 -2
- package/dist/rate_limiter.d.ts +179 -12
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +352 -42
- package/dist/realtime/sse_auth_guard.d.ts +22 -6
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.js +31 -12
- package/dist/realtime/subscriber_registry.d.ts +10 -1
- package/dist/realtime/subscriber_registry.d.ts.map +1 -1
- package/dist/realtime/subscriber_registry.js +10 -1
- package/dist/server/app_server.d.ts +20 -7
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +8 -3
- package/dist/server/env.d.ts +2 -1
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +7 -17
- package/dist/server/serve_fact_route.d.ts +8 -4
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +16 -6
- package/dist/testing/CLAUDE.md +164 -25
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +13 -6
- package/dist/testing/connection_closer_helpers.d.ts +6 -1
- package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
- package/dist/testing/connection_closer_helpers.js +4 -0
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +37 -2
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +14 -65
- package/dist/testing/cross_backend/capabilities.d.ts +26 -2
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +9 -3
- package/dist/testing/cross_backend/cell_gated_create.d.ts +38 -0
- package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_gated_create.js +401 -5
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +145 -2
- package/dist/testing/cross_backend/conformance_case.d.ts +11 -3
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +6 -0
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +20 -19
- package/dist/testing/cross_backend/credential_deadline.d.ts +25 -0
- package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_deadline.js +185 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +13 -2
- package/dist/testing/cross_backend/expected_schema.json +0 -1
- package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +7 -1
- package/dist/testing/cross_backend/login_security.d.ts +16 -0
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +154 -0
- package/dist/testing/cross_backend/narrowed_api_token.d.ts +23 -0
- package/dist/testing/cross_backend/narrowed_api_token.d.ts.map +1 -0
- package/dist/testing/cross_backend/narrowed_api_token.js +40 -0
- package/dist/testing/cross_backend/origin.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin.js +6 -26
- package/dist/testing/cross_backend/origin_conformance.d.ts +152 -0
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/origin_conformance.js +136 -0
- package/dist/testing/cross_backend/origin_conformance.json +1679 -0
- package/dist/testing/cross_backend/origin_scope.d.ts +16 -0
- package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -0
- package/dist/testing/cross_backend/origin_scope.js +140 -0
- package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
- package/dist/testing/cross_backend/query_shape.js +24 -2
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +35 -0
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -0
- package/dist/testing/cross_backend/role_grant_cross_helpers.js +64 -0
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +8 -0
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +44 -33
- package/dist/testing/cross_backend/role_grant_participation.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_participation.js +64 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +6 -4
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +20 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +23 -1
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +20 -7
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +180 -5
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +154 -5
- package/dist/testing/cross_backend/token_scope_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_scope_surface.js +25 -21
- package/dist/testing/cross_backend/transport_composition.d.ts +60 -0
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -0
- package/dist/testing/cross_backend/transport_composition.js +364 -0
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +21 -6
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_action_rate_limit.js +21 -1
- package/dist/testing/cross_backend/ws_role_gated.d.ts +38 -0
- package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -0
- package/dist/testing/cross_backend/ws_role_gated.js +142 -0
- package/dist/testing/entities.d.ts +23 -0
- package/dist/testing/entities.d.ts.map +1 -1
- package/dist/testing/entities.js +37 -0
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +3 -1
- package/dist/testing/middleware.d.ts +10 -0
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +31 -7
- package/dist/testing/schema_introspect.js +1 -1
- package/dist/testing/schema_parity.d.ts +4 -3
- package/dist/testing/schema_parity.d.ts.map +1 -1
- package/dist/testing/schema_parity.js +4 -3
- package/dist/testing/schema_ready_fixture.d.ts +2 -4
- package/dist/testing/schema_ready_fixture.d.ts.map +1 -1
- package/dist/testing/schema_ready_fixture.js +2 -4
- package/dist/testing/stubs.d.ts +16 -3
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +20 -7
- package/dist/testing/surface_invariants.js +2 -2
- package/dist/ui/auth_state.svelte.d.ts +10 -0
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +22 -4
- package/package.json +1 -1
- package/dist/db/cell_history_ddl.d.ts +0 -38
- package/dist/db/cell_history_ddl.d.ts.map +0 -1
- package/dist/db/cell_history_ddl.js +0 -61
package/dist/testing/stubs.js
CHANGED
|
@@ -19,8 +19,9 @@ import { create_app_surface_spec } from '../http/surface.js';
|
|
|
19
19
|
import { resolve_ws_endpoints } from '../actions/ws_endpoint_spec.js';
|
|
20
20
|
import { AUDIT_LOG_SSE_MAX_PER_SCOPE } from '../realtime/sse_auth_guard.js';
|
|
21
21
|
import { SubscriberRegistry } from '../realtime/subscriber_registry.js';
|
|
22
|
+
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
22
23
|
import { BaseServerEnv } from '../server/env.js';
|
|
23
|
-
import { AUTH_MIDDLEWARE_PATH, assert_endpoint_in_auth_scope, assert_middleware_stack_mounted } from '../auth/middleware.js';
|
|
24
|
+
import { AUTH_MIDDLEWARE_PATH, ORIGIN_MIDDLEWARE_PATH, assert_credential_routes_in_auth_scope, assert_endpoint_in_auth_scope, assert_middleware_stack_mounted, assert_origin_carve_outs_valid, freeze_origin_carve_outs } from '../auth/middleware.js';
|
|
24
25
|
/**
|
|
25
26
|
* Create a Proxy that throws descriptive errors on any property access or method call.
|
|
26
27
|
*
|
|
@@ -133,7 +134,8 @@ export const create_stub_audit_sse = () => {
|
|
|
133
134
|
return {
|
|
134
135
|
log: new Logger('test:audit_sse', { level: 'off' }),
|
|
135
136
|
on_audit_event: () => { },
|
|
136
|
-
registry
|
|
137
|
+
registry,
|
|
138
|
+
required_role: ROLE_ADMIN
|
|
137
139
|
};
|
|
138
140
|
};
|
|
139
141
|
/**
|
|
@@ -177,12 +179,15 @@ const create_stub_mw = () => async (_c, next) => next();
|
|
|
177
179
|
* `assert_middleware_stack_mounted` can tell the layers apart by identity.
|
|
178
180
|
*/
|
|
179
181
|
export const create_stub_api_middleware = (options) => {
|
|
182
|
+
const origin_carve_outs = freeze_origin_carve_outs(options?.origin_carve_outs ?? []);
|
|
183
|
+
assert_origin_carve_outs_valid(origin_carve_outs);
|
|
180
184
|
const specs = [
|
|
181
185
|
{
|
|
182
186
|
name: 'origin',
|
|
183
|
-
path:
|
|
187
|
+
path: ORIGIN_MIDDLEWARE_PATH,
|
|
184
188
|
handler: create_stub_mw(),
|
|
185
|
-
errors: { 403: ApiError }
|
|
189
|
+
errors: { 403: ApiError },
|
|
190
|
+
...(origin_carve_outs.length > 0 && { carve_outs: origin_carve_outs })
|
|
186
191
|
},
|
|
187
192
|
{ name: 'session', path: AUTH_MIDDLEWARE_PATH, handler: create_stub_mw() },
|
|
188
193
|
{ name: 'request_context', path: AUTH_MIDDLEWARE_PATH, handler: create_stub_mw() },
|
|
@@ -258,7 +263,9 @@ const to_self_resolved_ws_endpoint = (endpoint) => {
|
|
|
258
263
|
* `GET /api/surface` (with `surface_route: true`), then surface
|
|
259
264
|
* generation — including its
|
|
260
265
|
* refusal of an `rpc_endpoints` or `ws_endpoints` path outside the auth
|
|
261
|
-
* middleware's scope (`assert_endpoint_in_auth_scope`)
|
|
266
|
+
* middleware's scope (`assert_endpoint_in_auth_scope`), of a route that
|
|
267
|
+
* reads or mints a credential outside it
|
|
268
|
+
* (`assert_credential_routes_in_auth_scope`), and of a
|
|
262
269
|
* `transform_middleware` that doesn't keep the proxy and auth stack mounted
|
|
263
270
|
* (`assert_middleware_stack_mounted`). The middleware list mirrors the real
|
|
264
271
|
* one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack (with
|
|
@@ -268,7 +275,8 @@ const to_self_resolved_ws_endpoint = (endpoint) => {
|
|
|
268
275
|
*
|
|
269
276
|
* @param options - surface spec options
|
|
270
277
|
* @returns the surface spec for the standard suites
|
|
271
|
-
* @throws Error when an endpoint path
|
|
278
|
+
* @throws Error when an endpoint path, or a route that reads or mints a
|
|
279
|
+
* credential, is outside `AUTH_MIDDLEWARE_PATH`, a
|
|
272
280
|
* `ws_endpoints` spec declares no `allowed_origins` and no `allowed_origins`
|
|
273
281
|
* option is given, or `transform_middleware` moves, drops, duplicates,
|
|
274
282
|
* reorders, wraps, or replaces the stub proxy spec or a stub auth spec
|
|
@@ -339,10 +347,15 @@ export const create_test_app_surface_spec = (options) => {
|
|
|
339
347
|
...rpc_route_specs,
|
|
340
348
|
...surface_route_specs
|
|
341
349
|
];
|
|
350
|
+
// refused like `create_app_server` refuses it
|
|
351
|
+
assert_credential_routes_in_auth_scope(route_specs);
|
|
342
352
|
// mirrors `create_app_server`'s `[proxy_spec, ...auth_middleware]`
|
|
343
353
|
const stack_specs = [
|
|
344
354
|
{ name: 'trusted_proxy', path: '*', handler: create_stub_mw() },
|
|
345
|
-
...create_stub_api_middleware({
|
|
355
|
+
...create_stub_api_middleware({
|
|
356
|
+
include_daemon_token: options.daemon_token,
|
|
357
|
+
origin_carve_outs: options.origin_carve_outs
|
|
358
|
+
})
|
|
346
359
|
];
|
|
347
360
|
let middleware_specs = stack_specs;
|
|
348
361
|
if (options.transform_middleware) {
|
|
@@ -17,7 +17,7 @@ import './assert_dev_env.js';
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import { assert } from 'vitest';
|
|
20
|
-
import {
|
|
20
|
+
import { middleware_spec_applies } from '../http/schema_helpers.js';
|
|
21
21
|
import { filter_protected_routes, filter_role_routes, filter_keeper_routes, filter_credential_gated_routes, filter_routes_with_input, filter_routes_with_params, filter_routes_with_query, filter_public_routes, format_route_key } from '../http/surface_query.js';
|
|
22
22
|
import { PROTOCOL_ACTION_METHODS } from '../actions/action_codegen.js';
|
|
23
23
|
// --- Structural invariants ---
|
|
@@ -100,7 +100,7 @@ export const assert_middleware_errors_propagated = (surface) => {
|
|
|
100
100
|
const middleware_with_errors = surface.middleware.filter((m) => m.error_schemas !== null);
|
|
101
101
|
for (const route of surface.routes) {
|
|
102
102
|
for (const mw of middleware_with_errors) {
|
|
103
|
-
if (!
|
|
103
|
+
if (!middleware_spec_applies(mw, route.path))
|
|
104
104
|
continue;
|
|
105
105
|
for (const status of Object.keys(mw.error_schemas)) {
|
|
106
106
|
assert.ok(route.error_schemas && status in route.error_schemas, `${format_route_key(route)} missing status ${status} from middleware '${mw.name}'`);
|
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
* @module
|
|
33
33
|
*/
|
|
34
34
|
import { type ActorSummaryJson, type RoleGrantSummaryJson, type SessionAccount } from '../auth/account_schema.js';
|
|
35
|
+
/**
|
|
36
|
+
* The message a `429` shows, from its `retry_after` (seconds).
|
|
37
|
+
*
|
|
38
|
+
* A short wait reads as one — the spines answer `retry_after: 1` when the cap
|
|
39
|
+
* is held only by attempts still in flight — rather than rounding up to a
|
|
40
|
+
* minute; a missing value reads as a minute.
|
|
41
|
+
*
|
|
42
|
+
* @param retry_after - the response's `retry_after`, when it carried one
|
|
43
|
+
*/
|
|
44
|
+
export declare const format_rate_limit_message: (retry_after: unknown) => string;
|
|
35
45
|
/**
|
|
36
46
|
* Svelte context for `AuthState`.
|
|
37
47
|
* Use `auth_state_context.set(state)` in the provider and `auth_state_context.get()` to access.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/auth_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,MAAM,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;CAA8B,CAAC;AAE9D,qBAAa,SAAS;IACrB,SAAS,UAAqB;IAC9B,QAAQ,UAAqB;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAoB;IAC/C,OAAO,EAAE,cAAc,GAAG,IAAI,CAAoB;IAClD,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAoB;IAClD,WAAW,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAkB;IAC1D;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAEtD;IACF;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAExC;IACF,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAA+C;IAEzE,gEAAgE;IAChE,eAAe,UAAqB;IAEpC;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAItC;;;;;;;;OAQG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BpC;;;;;;;OAOG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"auth_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/auth_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,MAAM,2BAA2B,CAAC;AAGnC;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GAAI,aAAa,OAAO,KAAG,MAShE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;CAA8B,CAAC;AAE9D,qBAAa,SAAS;IACrB,SAAS,UAAqB;IAC9B,QAAQ,UAAqB;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAoB;IAC/C,OAAO,EAAE,cAAc,GAAG,IAAI,CAAoB;IAClD,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAoB;IAClD,WAAW,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAkB;IAC1D;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAEtD;IACF;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAExC;IACF,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAA+C;IAEzE,gEAAgE;IAChE,eAAe,UAAqB;IAEpC;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAItC;;;;;;;;OAQG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BpC;;;;;;;OAOG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuCjE;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiCpF;;;;;;;OAOG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA2ClF;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAe7B"}
|
|
@@ -36,6 +36,26 @@ import { create_context } from '@fuzdev/fuz_ui/context_helpers.ts';
|
|
|
36
36
|
import { ui_fetch } from './ui_fetch.js';
|
|
37
37
|
import { is_role_grant_active } from '../auth/account_schema.js';
|
|
38
38
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
39
|
+
/**
|
|
40
|
+
* The message a `429` shows, from its `retry_after` (seconds).
|
|
41
|
+
*
|
|
42
|
+
* A short wait reads as one — the spines answer `retry_after: 1` when the cap
|
|
43
|
+
* is held only by attempts still in flight — rather than rounding up to a
|
|
44
|
+
* minute; a missing value reads as a minute.
|
|
45
|
+
*
|
|
46
|
+
* @param retry_after - the response's `retry_after`, when it carried one
|
|
47
|
+
*/
|
|
48
|
+
export const format_rate_limit_message = (retry_after) => {
|
|
49
|
+
const seconds = typeof retry_after === 'number' && retry_after > 0 ? retry_after : 60;
|
|
50
|
+
if (seconds <= 5)
|
|
51
|
+
return 'Too many attempts. Try again in a moment.';
|
|
52
|
+
if (seconds < 60) {
|
|
53
|
+
const whole = Math.ceil(seconds);
|
|
54
|
+
return `Too many attempts. Try again in ${whole} second${whole === 1 ? '' : 's'}.`;
|
|
55
|
+
}
|
|
56
|
+
const minutes = Math.ceil(seconds / 60);
|
|
57
|
+
return `Too many attempts. Try again in ${minutes} minute${minutes === 1 ? '' : 's'}.`;
|
|
58
|
+
};
|
|
39
59
|
/**
|
|
40
60
|
* Svelte context for `AuthState`.
|
|
41
61
|
* Use `auth_state_context.set(state)` in the provider and `auth_state_context.get()` to access.
|
|
@@ -145,8 +165,7 @@ export class AuthState {
|
|
|
145
165
|
if (response.status === 429) {
|
|
146
166
|
try {
|
|
147
167
|
const data = await response.json();
|
|
148
|
-
|
|
149
|
-
this.verify_error = `Too many attempts. Try again in ${minutes} minute${minutes === 1 ? '' : 's'}.`;
|
|
168
|
+
this.verify_error = format_rate_limit_message(data.retry_after);
|
|
150
169
|
}
|
|
151
170
|
catch {
|
|
152
171
|
this.verify_error = 'Too many attempts. Try again later.';
|
|
@@ -234,8 +253,7 @@ export class AuthState {
|
|
|
234
253
|
if (response.status === 429) {
|
|
235
254
|
try {
|
|
236
255
|
const data = await response.json();
|
|
237
|
-
|
|
238
|
-
this.verify_error = `Too many attempts. Try again in ${minutes} minute${minutes === 1 ? '' : 's'}.`;
|
|
256
|
+
this.verify_error = format_rate_limit_message(data.retry_after);
|
|
239
257
|
}
|
|
240
258
|
catch {
|
|
241
259
|
this.verify_error = 'Too many attempts. Try again later.';
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cell history PG schema (schema only).
|
|
3
|
-
*
|
|
4
|
-
* Lightweight references to cell state snapshots. Heavy data (serialized
|
|
5
|
-
* cell bytes) lives in the fact store; `fact_hash` points there. The
|
|
6
|
-
* snapshot lifecycle (when to serialize, hash, store, and record) is
|
|
7
|
-
* deferred to a future iteration — this only stages the table so
|
|
8
|
-
* downstream code can target a stable schema. The table ships
|
|
9
|
-
* present-but-unwritten.
|
|
10
|
-
*
|
|
11
|
-
* `fact_hash` is intentionally **not** a foreign key to `fact(hash)` —
|
|
12
|
-
* snapshots may be evicted by GC policy while history rows remain as audit
|
|
13
|
-
* traces, and federation may target facts on another instance.
|
|
14
|
-
*
|
|
15
|
-
* Depends on `CELL_MIGRATION_NS` (FK on `cell.id`).
|
|
16
|
-
*
|
|
17
|
-
* @module
|
|
18
|
-
*/
|
|
19
|
-
import type { Migration, MigrationNamespace } from './migrate.js';
|
|
20
|
-
/** `cell_history` table — append-only log of cell snapshot references. */
|
|
21
|
-
export declare const CELL_HISTORY_SCHEMA = "\nCREATE TABLE IF NOT EXISTS cell_history (\n\tid BIGSERIAL PRIMARY KEY,\n\tcell_id UUID NOT NULL REFERENCES cell(id) ON DELETE CASCADE,\n\tfact_hash TEXT NOT NULL,\n\taction_id UUID,\n\tcreated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()\n)";
|
|
22
|
-
/**
|
|
23
|
-
* Cell-history indexes.
|
|
24
|
-
*
|
|
25
|
-
* - `idx_cell_history_cell`: per-cell timeline reads (newest first).
|
|
26
|
-
* - `idx_cell_history_fact`: fact → cells reverse lookup for GC liveness
|
|
27
|
-
* and provenance queries.
|
|
28
|
-
*/
|
|
29
|
-
export declare const CELL_HISTORY_INDEXES: Array<string>;
|
|
30
|
-
/** Tables created by `CELL_HISTORY_MIGRATION_NS`, in drop order. */
|
|
31
|
-
export declare const CELL_HISTORY_DROP_TABLES: readonly ["cell_history"];
|
|
32
|
-
/** Cell-history migrations. */
|
|
33
|
-
export declare const CELL_HISTORY_MIGRATIONS: Array<Migration>;
|
|
34
|
-
/** Namespace identifier for cell-history migrations. */
|
|
35
|
-
export declare const CELL_HISTORY_MIGRATION_NAMESPACE = "fuz_cell_history";
|
|
36
|
-
/** Migration namespace consumed by `run_migrations`. */
|
|
37
|
-
export declare const CELL_HISTORY_MIGRATION_NS: MigrationNamespace;
|
|
38
|
-
//# sourceMappingURL=cell_history_ddl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cell_history_ddl.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/cell_history_ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElE,0EAA0E;AAC1E,eAAO,MAAM,mBAAmB,gPAO9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,MAAM,CAK9C,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,2BAA4B,CAAC;AAElE,+BAA+B;AAC/B,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,SAAS,CAUpD,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,gCAAgC,qBAAqB,CAAC;AAEnE,wDAAwD;AACxD,eAAO,MAAM,yBAAyB,EAAE,kBAGvC,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cell history PG schema (schema only).
|
|
3
|
-
*
|
|
4
|
-
* Lightweight references to cell state snapshots. Heavy data (serialized
|
|
5
|
-
* cell bytes) lives in the fact store; `fact_hash` points there. The
|
|
6
|
-
* snapshot lifecycle (when to serialize, hash, store, and record) is
|
|
7
|
-
* deferred to a future iteration — this only stages the table so
|
|
8
|
-
* downstream code can target a stable schema. The table ships
|
|
9
|
-
* present-but-unwritten.
|
|
10
|
-
*
|
|
11
|
-
* `fact_hash` is intentionally **not** a foreign key to `fact(hash)` —
|
|
12
|
-
* snapshots may be evicted by GC policy while history rows remain as audit
|
|
13
|
-
* traces, and federation may target facts on another instance.
|
|
14
|
-
*
|
|
15
|
-
* Depends on `CELL_MIGRATION_NS` (FK on `cell.id`).
|
|
16
|
-
*
|
|
17
|
-
* @module
|
|
18
|
-
*/
|
|
19
|
-
/** `cell_history` table — append-only log of cell snapshot references. */
|
|
20
|
-
export const CELL_HISTORY_SCHEMA = `
|
|
21
|
-
CREATE TABLE IF NOT EXISTS cell_history (
|
|
22
|
-
id BIGSERIAL PRIMARY KEY,
|
|
23
|
-
cell_id UUID NOT NULL REFERENCES cell(id) ON DELETE CASCADE,
|
|
24
|
-
fact_hash TEXT NOT NULL,
|
|
25
|
-
action_id UUID,
|
|
26
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
27
|
-
)`;
|
|
28
|
-
/**
|
|
29
|
-
* Cell-history indexes.
|
|
30
|
-
*
|
|
31
|
-
* - `idx_cell_history_cell`: per-cell timeline reads (newest first).
|
|
32
|
-
* - `idx_cell_history_fact`: fact → cells reverse lookup for GC liveness
|
|
33
|
-
* and provenance queries.
|
|
34
|
-
*/
|
|
35
|
-
export const CELL_HISTORY_INDEXES = [
|
|
36
|
-
`CREATE INDEX IF NOT EXISTS idx_cell_history_cell
|
|
37
|
-
ON cell_history(cell_id, created_at DESC)`,
|
|
38
|
-
`CREATE INDEX IF NOT EXISTS idx_cell_history_fact
|
|
39
|
-
ON cell_history(fact_hash)`
|
|
40
|
-
];
|
|
41
|
-
/** Tables created by `CELL_HISTORY_MIGRATION_NS`, in drop order. */
|
|
42
|
-
export const CELL_HISTORY_DROP_TABLES = ['cell_history'];
|
|
43
|
-
/** Cell-history migrations. */
|
|
44
|
-
export const CELL_HISTORY_MIGRATIONS = [
|
|
45
|
-
{
|
|
46
|
-
name: 'full_cell_history_schema',
|
|
47
|
-
up: async (db) => {
|
|
48
|
-
await db.query(CELL_HISTORY_SCHEMA);
|
|
49
|
-
for (const sql of CELL_HISTORY_INDEXES) {
|
|
50
|
-
await db.query(sql);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
/** Namespace identifier for cell-history migrations. */
|
|
56
|
-
export const CELL_HISTORY_MIGRATION_NAMESPACE = 'fuz_cell_history';
|
|
57
|
-
/** Migration namespace consumed by `run_migrations`. */
|
|
58
|
-
export const CELL_HISTORY_MIGRATION_NS = {
|
|
59
|
-
namespace: CELL_HISTORY_MIGRATION_NAMESPACE,
|
|
60
|
-
migrations: CELL_HISTORY_MIGRATIONS
|
|
61
|
-
};
|