@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/http/surface.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* App surface generation — JSON-serializable attack surface from route and middleware specs.
|
|
3
3
|
*
|
|
4
|
-
* Pure schema helpers (`is_null_schema`, `schema_to_surface`, `middleware_applies`,
|
|
4
|
+
* Pure schema helpers (`is_null_schema`, `schema_to_surface`, `middleware_applies`, `middleware_spec_applies`,
|
|
5
5
|
* `merge_error_schemas`) live in `http/schema_helpers.ts`.
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
|
-
import { schema_to_surface,
|
|
10
|
+
import { schema_to_surface, middleware_spec_applies, merge_error_schemas, is_null_schema, is_strict_object_schema } from './schema_helpers.js';
|
|
11
11
|
// --- Surface generation ---
|
|
12
12
|
/**
|
|
13
13
|
* Collect error schemas from all middleware that applies to a route path.
|
|
@@ -17,7 +17,7 @@ import { schema_to_surface, middleware_applies, merge_error_schemas, is_null_sch
|
|
|
17
17
|
export const collect_middleware_errors = (middleware, route_path) => {
|
|
18
18
|
const errors = {};
|
|
19
19
|
for (const mw of middleware) {
|
|
20
|
-
if (mw.errors &&
|
|
20
|
+
if (mw.errors && middleware_spec_applies(mw, route_path)) {
|
|
21
21
|
Object.assign(errors, mw.errors);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -89,11 +89,18 @@ export const generate_app_surface = (options) => {
|
|
|
89
89
|
mw_error_schemas = schemas;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
return {
|
|
92
|
+
return {
|
|
93
|
+
name: m.name,
|
|
94
|
+
path: m.path,
|
|
95
|
+
error_schemas: mw_error_schemas,
|
|
96
|
+
...(m.carve_outs?.length && {
|
|
97
|
+
carve_outs: m.carve_outs.map(({ path, reason }) => ({ path, reason }))
|
|
98
|
+
})
|
|
99
|
+
};
|
|
93
100
|
}),
|
|
94
101
|
routes: route_specs.map((r) => {
|
|
95
102
|
const applicable_middleware = middleware_specs
|
|
96
|
-
.filter((m) =>
|
|
103
|
+
.filter((m) => middleware_spec_applies(m, r.path))
|
|
97
104
|
.map((m) => m.name);
|
|
98
105
|
// Merge auto-derived + middleware + explicit error schemas
|
|
99
106
|
const mw_errors = collect_middleware_errors(middleware_specs, r.path);
|
|
@@ -117,7 +117,16 @@ export declare const Email: z.ZodString;
|
|
|
117
117
|
export type Email = z.infer<typeof Email>;
|
|
118
118
|
/** Returns a new random (v4) `Uuid`. */
|
|
119
119
|
export declare const create_uuid: () => Uuid;
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Branded UUID schema. Accepts either case and outputs lowercase — the form
|
|
122
|
+
* Postgres renders a `uuid` in and every id the server mints — so a parsed id
|
|
123
|
+
* compares equal to the same id read back from the database. The Rust spine
|
|
124
|
+
* canonicalizes the same way.
|
|
125
|
+
*
|
|
126
|
+
* `.toLowerCase()` rather than `.transform()`: an overwrite keeps the output
|
|
127
|
+
* type and stays invisible to `z.toJSONSchema`, where a transform would leave
|
|
128
|
+
* no input schema to render.
|
|
129
|
+
*/
|
|
121
130
|
export declare const Uuid: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
|
|
122
131
|
export type Uuid = z.infer<typeof Uuid>;
|
|
123
132
|
/** `Uuid` that defaults to a fresh `create_uuid()` when the input is `undefined`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive_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AACxC,eAAO,MAAM,WAAW,QAAO,IAAmC,CAAC;AAEnE;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,8CAAuC,CAAC;AACzD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,qFAAqF;AACrF,eAAO,MAAM,eAAe,4DAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,wCAAwC;AACxC,eAAO,MAAM,QAAQ,yDAAqC,CAAC;AAC3D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,QAAO,QAAgD,CAAC;AAErF,sFAAsF;AACtF,eAAO,MAAM,WAAW,uEAAqC,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,uFAAuF;AACvF,eAAO,MAAM,UAAU,aAEuD,CAAC;AAC/E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAEA,CAAC"}
|
|
@@ -181,8 +181,17 @@ export const Email = z
|
|
|
181
181
|
});
|
|
182
182
|
/** Returns a new random (v4) `Uuid`. */
|
|
183
183
|
export const create_uuid = () => crypto.randomUUID();
|
|
184
|
-
/**
|
|
185
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Branded UUID schema. Accepts either case and outputs lowercase — the form
|
|
186
|
+
* Postgres renders a `uuid` in and every id the server mints — so a parsed id
|
|
187
|
+
* compares equal to the same id read back from the database. The Rust spine
|
|
188
|
+
* canonicalizes the same way.
|
|
189
|
+
*
|
|
190
|
+
* `.toLowerCase()` rather than `.transform()`: an overwrite keeps the output
|
|
191
|
+
* type and stays invisible to `z.toJSONSchema`, where a transform would leave
|
|
192
|
+
* no input schema to render.
|
|
193
|
+
*/
|
|
194
|
+
export const Uuid = z.uuid().toLowerCase().brand('Uuid');
|
|
186
195
|
/** `Uuid` that defaults to a fresh `create_uuid()` when the input is `undefined`. */
|
|
187
196
|
export const UuidWithDefault = Uuid.default(create_uuid);
|
|
188
197
|
/** Branded ISO 8601 datetime schema. */
|
package/dist/rate_limiter.d.ts
CHANGED
|
@@ -4,6 +4,23 @@
|
|
|
4
4
|
* Tracks failed attempts per key (typically IP address) using a sliding
|
|
5
5
|
* time window. No external dependencies — state resets on server restart.
|
|
6
6
|
*
|
|
7
|
+
* **Reserve, then settle.** A handler that checks the limiter, awaits work,
|
|
8
|
+
* and records afterwards lets every request of a concurrent burst pass the
|
|
9
|
+
* check before any of them records — a burst of any size gets through.
|
|
10
|
+
* `RateLimiter.try_reserve` closes that: it admits a request and counts it in
|
|
11
|
+
* flight in one synchronous step, and the attempt counts against the cap
|
|
12
|
+
* until its `RateLimitReservation` is settled — `record` keeps it as an
|
|
13
|
+
* attempt, `release` gives it back. Every handler whose outcome decides
|
|
14
|
+
* whether the attempt counts reserves, and releases in a `finally` so an
|
|
15
|
+
* early return or a throw never leaks an in-flight slot; `check` + `record`
|
|
16
|
+
* stays for callers that record in the same synchronous step they check.
|
|
17
|
+
*
|
|
18
|
+
* **Attempts count while in flight, whatever their outcome** — so a burst of
|
|
19
|
+
* *correct* concurrent attempts from one key is capped too. The password
|
|
20
|
+
* surfaces therefore reserve with `RateLimiter.reserve`, which waits up to
|
|
21
|
+
* `RESERVATION_WAIT_MAX_MS` for a slot when the cap is reached only by
|
|
22
|
+
* attempts in flight, and refuses at once when it is reached by recorded ones.
|
|
23
|
+
*
|
|
7
24
|
* @module
|
|
8
25
|
*/
|
|
9
26
|
import type { Context } from 'hono';
|
|
@@ -19,11 +36,19 @@ export declare const DEFAULT_RATE_LIMITER_MAX_KEYS = 100000;
|
|
|
19
36
|
* Configuration for a rate limiter instance.
|
|
20
37
|
*/
|
|
21
38
|
export interface RateLimiterOptions {
|
|
22
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Maximum allowed attempts within the window, a safe integer ≥ 0. `0`
|
|
41
|
+
* refuses every attempt — `check`, `try_reserve`, and `reserve` answer at
|
|
42
|
+
* once with the window's length as `retry_after`, tracking nothing.
|
|
43
|
+
*/
|
|
23
44
|
max_attempts: number;
|
|
24
|
-
/** Sliding window duration in milliseconds. */
|
|
45
|
+
/** Sliding window duration in milliseconds, a safe integer ≥ 0. */
|
|
25
46
|
window_ms: number;
|
|
26
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Interval for pruning stale entries, an integer from `0` to
|
|
49
|
+
* `PERIODIC_INTERVAL_MS_MAX` (`0` disables the timer) — the largest delay
|
|
50
|
+
* a timer honours; past it `setInterval` fires every millisecond.
|
|
51
|
+
*/
|
|
27
52
|
cleanup_interval_ms: number;
|
|
28
53
|
/**
|
|
29
54
|
* Maximum tracked keys. When exceeded, the least-recently-used key is
|
|
@@ -39,6 +64,8 @@ export interface RateLimiterOptions {
|
|
|
39
64
|
* can, however, drop out of the table and reset their budget — set
|
|
40
65
|
* `max_keys` high enough to fit the expected legitimate key set and
|
|
41
66
|
* this stays theoretical.
|
|
67
|
+
*
|
|
68
|
+
* A number must be a positive safe integer.
|
|
42
69
|
*/
|
|
43
70
|
max_keys?: number | null;
|
|
44
71
|
}
|
|
@@ -112,21 +139,78 @@ export declare const RATE_LIMITERS_DISABLED_BANNER = "!!! RATE LIMITERS DISABLED
|
|
|
112
139
|
* `RateLimiterMode::limiter`.
|
|
113
140
|
*/
|
|
114
141
|
export declare const announce_rate_limiters_disabled: () => void;
|
|
142
|
+
/**
|
|
143
|
+
* `retry_after` reported while a key is at its cap only because of attempts
|
|
144
|
+
* still in flight. Those settle within a request's lifetime, so the earliest
|
|
145
|
+
* moment worth retrying is the next second, not the oldest recorded attempt's
|
|
146
|
+
* expiry. Mirrors the Rust spine's `IN_FLIGHT_RETRY_AFTER_SECONDS`.
|
|
147
|
+
*/
|
|
148
|
+
export declare const IN_FLIGHT_RETRY_AFTER_SECONDS = 1;
|
|
149
|
+
/**
|
|
150
|
+
* How long a password-surface reservation (`RateLimiter.reserve`) waits for a
|
|
151
|
+
* slot when the key is at its cap only because of attempts still in flight,
|
|
152
|
+
* before answering `429`. Mirrors the Rust spine's `RESERVATION_WAIT_MAX`.
|
|
153
|
+
*
|
|
154
|
+
* Counting attempts while they are in flight caps *successful* concurrent
|
|
155
|
+
* attempts from one key too — a class behind one NAT logging in together.
|
|
156
|
+
* Those attempts settle within a request's lifetime, so a short wait turns
|
|
157
|
+
* most of those refusals into a late success, while a key at its cap on
|
|
158
|
+
* *recorded* attempts is still refused at once.
|
|
159
|
+
*/
|
|
160
|
+
export declare const RESERVATION_WAIT_MAX_MS = 5000;
|
|
115
161
|
/**
|
|
116
162
|
* Result of a rate limit check or record operation.
|
|
117
163
|
*/
|
|
118
164
|
export interface RateLimitResult {
|
|
119
165
|
/** Whether the request is allowed. */
|
|
120
166
|
allowed: boolean;
|
|
121
|
-
/** Remaining attempts before blocking. */
|
|
167
|
+
/** Remaining attempts before blocking, counting attempts still in flight. */
|
|
122
168
|
remaining: number;
|
|
123
169
|
/** Seconds until the oldest active attempt expires (0 if allowed). */
|
|
124
170
|
retry_after: number;
|
|
125
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* An attempt admitted by `RateLimiter.try_reserve` or `RateLimiter.reserve`,
|
|
174
|
+
* counted against the key's cap until settled.
|
|
175
|
+
*
|
|
176
|
+
* Settle it exactly once: `record` keeps it as an attempt (a failure, on the
|
|
177
|
+
* failure-counting surfaces), `release` gives it back. Both are idempotent and
|
|
178
|
+
* the first call wins, so a handler calls `record` where the outcome is known
|
|
179
|
+
* and `release` in a `finally`. When the key's entry was evicted or reset
|
|
180
|
+
* meanwhile, `record` still records (into the key's current entry) and
|
|
181
|
+
* `release` is a no-op. A reservation made against no limiter
|
|
182
|
+
* (`try_reserve_optional` / `reserve_optional` with `null`) is inert.
|
|
183
|
+
*/
|
|
184
|
+
export interface RateLimitReservation {
|
|
185
|
+
/**
|
|
186
|
+
* Settle as a recorded attempt.
|
|
187
|
+
*
|
|
188
|
+
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
189
|
+
*/
|
|
190
|
+
record: (now?: number) => void;
|
|
191
|
+
/** Settle without recording an attempt. */
|
|
192
|
+
release: () => void;
|
|
193
|
+
}
|
|
194
|
+
/** Result of `RateLimiter.try_reserve` and `RateLimiter.reserve`. */
|
|
195
|
+
export type RateLimitReserveResult = {
|
|
196
|
+
ok: true;
|
|
197
|
+
reservation: RateLimitReservation;
|
|
198
|
+
} | {
|
|
199
|
+
ok: false;
|
|
200
|
+
retry_after: number;
|
|
201
|
+
};
|
|
202
|
+
/** Options for `RateLimiter.reserve`. */
|
|
203
|
+
export interface RateLimitReserveOptions {
|
|
204
|
+
/** How long to wait for a slot. Default `RESERVATION_WAIT_MAX_MS`. */
|
|
205
|
+
max_wait_ms?: number;
|
|
206
|
+
/** Stops the wait (a refusal, `retry_after: IN_FLIGHT_RETRY_AFTER_SECONDS`) — pass the request's signal. */
|
|
207
|
+
signal?: AbortSignal;
|
|
208
|
+
}
|
|
126
209
|
/**
|
|
127
210
|
* In-memory sliding window rate limiter.
|
|
128
211
|
*
|
|
129
|
-
* Stores an array of timestamps per key
|
|
212
|
+
* Stores an array of timestamps per key, plus a count of attempts reserved
|
|
213
|
+
* (`try_reserve`) and not yet settled. On `check`/`record`, timestamps
|
|
130
214
|
* outside the window are pruned. `retry_after` reports seconds until the
|
|
131
215
|
* oldest active timestamp expires.
|
|
132
216
|
*
|
|
@@ -144,15 +228,32 @@ export interface RateLimitResult {
|
|
|
144
228
|
export declare class RateLimiter {
|
|
145
229
|
#private;
|
|
146
230
|
readonly options: RateLimiterOptions;
|
|
231
|
+
/**
|
|
232
|
+
* @param options - the limiter's bounds
|
|
233
|
+
* @throws {RangeError} when `max_attempts`, `window_ms`, or `cleanup_interval_ms` is not a safe integer ≥ 0, `cleanup_interval_ms` exceeds `PERIODIC_INTERVAL_MS_MAX`, or `max_keys` is neither `null` nor a positive safe integer
|
|
234
|
+
*/
|
|
147
235
|
constructor(options: RateLimiterOptions);
|
|
148
236
|
/** Number of tracked keys. */
|
|
149
237
|
get size(): number;
|
|
150
238
|
/**
|
|
151
|
-
*
|
|
239
|
+
* Keys holding a parked-waiter slot right now (see `reserve`): each slot is
|
|
240
|
+
* removed with its key's last waiter. For tests pinning that a waiter
|
|
241
|
+
* leaves nothing behind; the twin of the Rust spine's test-only
|
|
242
|
+
* `waiter_keys`.
|
|
243
|
+
*
|
|
244
|
+
* @internal
|
|
245
|
+
*/
|
|
246
|
+
get waiter_keys(): number;
|
|
247
|
+
/**
|
|
248
|
+
* Check whether `key` is allowed without recording an attempt, counting
|
|
249
|
+
* recorded attempts and reserved ones still in flight.
|
|
152
250
|
*
|
|
153
251
|
* Prunes timestamps that fell outside the window as a side effect (and
|
|
154
|
-
* removes the key entirely when none remain
|
|
155
|
-
* bounded even under read-only traffic.
|
|
252
|
+
* removes the key entirely when none remain and none are in flight), so
|
|
253
|
+
* the backing map stays bounded even under read-only traffic.
|
|
254
|
+
*
|
|
255
|
+
* A check followed by an awaited operation and then a `record` lets a
|
|
256
|
+
* concurrent burst past the cap; reserve with `try_reserve` instead.
|
|
156
257
|
*
|
|
157
258
|
* @param key - rate limit key (e.g. IP address)
|
|
158
259
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
@@ -167,6 +268,44 @@ export declare class RateLimiter {
|
|
|
167
268
|
* @mutates internal map - appends `now` to the timestamp list for `key` (after pruning expired entries)
|
|
168
269
|
*/
|
|
169
270
|
record(key: string, now?: number): RateLimitResult;
|
|
271
|
+
/**
|
|
272
|
+
* Admit an attempt for `key` and count it in flight, in one synchronous
|
|
273
|
+
* step.
|
|
274
|
+
*
|
|
275
|
+
* The attempt counts against the cap — for this request and every
|
|
276
|
+
* concurrent one — until the returned reservation is settled: recorded as
|
|
277
|
+
* an attempt, or released. So no burst of concurrent requests gets more
|
|
278
|
+
* than `max_attempts` past the limiter between them. Release in a
|
|
279
|
+
* `finally`: nothing settles a reservation for you, so one left unsettled
|
|
280
|
+
* holds its slot for the life of the process.
|
|
281
|
+
*
|
|
282
|
+
* @param key - rate limit key (e.g. IP address)
|
|
283
|
+
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
284
|
+
* @returns the reservation, or `{ok: false, retry_after}` when recorded plus in-flight attempts already reach the cap (nothing is reserved then)
|
|
285
|
+
* @mutates internal map - increments `key`'s in-flight count, creating its entry when absent
|
|
286
|
+
*/
|
|
287
|
+
try_reserve(key: string, now?: number): RateLimitReserveResult;
|
|
288
|
+
/**
|
|
289
|
+
* `try_reserve`, waiting up to `max_wait_ms` for a slot when the key is at
|
|
290
|
+
* its cap only because of attempts still in flight.
|
|
291
|
+
*
|
|
292
|
+
* Each settle (and record and reset) on the key wakes its waiters to
|
|
293
|
+
* re-decide — that key's only, so a settle costs nothing for waiters parked
|
|
294
|
+
* elsewhere: a freed slot is reserved; recorded attempts reaching the cap
|
|
295
|
+
* refuse at once with their real `retry_after`; reaching `max_wait_ms` (or
|
|
296
|
+
* `signal` aborting) refuses with `IN_FLIGHT_RETRY_AFTER_SECONDS`. At most
|
|
297
|
+
* `max_attempts` reservations wait on one key — one more is refused at
|
|
298
|
+
* once — so a flood can't park requests without bound. A waiter that
|
|
299
|
+
* leaves, by any path, leaves the key's waiter count as it found it. A
|
|
300
|
+
* waiter holds no place in a queue: each wake, every waiter re-decides, so
|
|
301
|
+
* one can lose every race for a freed slot until `max_wait_ms` refuses it.
|
|
302
|
+
*
|
|
303
|
+
* @param key - rate limit key (e.g. IP address)
|
|
304
|
+
* @param options - the wait bound and an abort signal
|
|
305
|
+
* @returns the reservation, or `{ok: false, retry_after}` as described (nothing is reserved then)
|
|
306
|
+
* @mutates internal map - increments `key`'s in-flight count on admission; counts the call in `key`'s waiters while it waits
|
|
307
|
+
*/
|
|
308
|
+
reserve(key: string, options?: RateLimitReserveOptions): Promise<RateLimitReserveResult>;
|
|
170
309
|
/**
|
|
171
310
|
* Clear all attempts for `key`.
|
|
172
311
|
*
|
|
@@ -181,8 +320,9 @@ export declare class RateLimiter {
|
|
|
181
320
|
* otherwise an attacker interleaves their own logins (or, under open signup,
|
|
182
321
|
* throwaway account creations needing no credential at all) with guesses
|
|
183
322
|
* against arbitrary victims and sprays indefinitely from one address.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
323
|
+
* The only success that records on an IP bucket is an open signup (charged
|
|
324
|
+
* like a failure); no success clears one, so with no reset each is a
|
|
325
|
+
* monotone-within-window counter that only time clears.
|
|
186
326
|
*
|
|
187
327
|
* Because they are monotone, the IP buckets are **one instance per auth
|
|
188
328
|
* surface** (`login_ip_rate_limiter`, `signup_ip_rate_limiter`,
|
|
@@ -192,11 +332,15 @@ export declare class RateLimiter {
|
|
|
192
332
|
* four routes at once — a cost that used to be masked by the reset this
|
|
193
333
|
* doc forbids.
|
|
194
334
|
*
|
|
195
|
-
*
|
|
335
|
+
* Attempts still in flight on `key` (reserved by concurrent requests) are
|
|
336
|
+
* kept: a reset forgives what was recorded, not what is still running.
|
|
337
|
+
*
|
|
338
|
+
* @mutates internal map - removes the entry for `key`, or clears its timestamps while attempts are in flight
|
|
196
339
|
*/
|
|
197
340
|
reset(key: string): void;
|
|
198
341
|
/**
|
|
199
|
-
* Remove entries whose timestamps are all outside the window
|
|
342
|
+
* Remove entries whose timestamps are all outside the window and that
|
|
343
|
+
* have no attempt in flight.
|
|
200
344
|
*
|
|
201
345
|
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
202
346
|
* @mutates internal map - prunes expired timestamps and deletes empty keys
|
|
@@ -209,6 +353,29 @@ export declare class RateLimiter {
|
|
|
209
353
|
*/
|
|
210
354
|
dispose(): void;
|
|
211
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* `RateLimiter.try_reserve` against a limiter that may be absent.
|
|
358
|
+
*
|
|
359
|
+
* An inert reservation when `limiter` is `null` (disabled) or `key` is `null`
|
|
360
|
+
* (no resolvable key — e.g. no client IP), so a handler reserves and settles
|
|
361
|
+
* the same way whether or not the surface is limited. Twin of the Rust
|
|
362
|
+
* spine's `try_reserve_optional`.
|
|
363
|
+
*
|
|
364
|
+
* @param limiter - the limiter, or `null` when disabled
|
|
365
|
+
* @param key - rate limit key, or `null` to skip
|
|
366
|
+
* @param now - current timestamp in ms (defaults to `Date.now()`)
|
|
367
|
+
*/
|
|
368
|
+
export declare const try_reserve_optional: (limiter: RateLimiter | null, key: string | null, now?: number) => RateLimitReserveResult;
|
|
369
|
+
/**
|
|
370
|
+
* `RateLimiter.reserve` against a limiter that may be absent — an inert
|
|
371
|
+
* reservation when `limiter` or `key` is `null`. Twin of the Rust spine's
|
|
372
|
+
* `reserve_optional`.
|
|
373
|
+
*
|
|
374
|
+
* @param limiter - the limiter, or `null` when disabled
|
|
375
|
+
* @param key - rate limit key, or `null` to skip
|
|
376
|
+
* @param options - the wait bound and an abort signal
|
|
377
|
+
*/
|
|
378
|
+
export declare const reserve_optional: (limiter: RateLimiter | null, key: string | null, options?: RateLimitReserveOptions) => Promise<RateLimitReserveResult>;
|
|
212
379
|
/**
|
|
213
380
|
* Create a `RateLimiter` with sensible defaults for per-IP login protection.
|
|
214
381
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/rate_limiter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/rate_limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAA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