@fuzdev/fuz_app 0.162.0 → 0.164.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/README.md +2 -1
- package/dist/actions/action_event_data.d.ts +1 -1
- 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 +3 -3
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/auth/CLAUDE.md +39 -36
- package/dist/auth/account_action_specs.d.ts +441 -115
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +47 -46
- package/dist/auth/account_route_schema.d.ts +98 -62
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +45 -45
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +54 -27
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +16 -18
- package/dist/auth/admin_action_specs.d.ts +76 -76
- package/dist/auth/admin_action_specs.js +2 -4
- package/dist/auth/admin_actions.d.ts +4 -4
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +3 -3
- package/dist/auth/all_cell_actions.d.ts +3 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token.d.ts +4 -4
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +3 -3
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +4 -5
- package/dist/auth/audit_log_schema.d.ts +46 -66
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +34 -30
- package/dist/auth/bootstrap_route_schema.d.ts +146 -52
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +33 -19
- package/dist/auth/cell_grant_action_specs.d.ts +1 -1
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_actions.d.ts +4 -4
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +1 -1
- package/dist/auth/credential_type_schema.d.ts +16 -29
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +14 -18
- package/dist/auth/daemon_token.d.ts +4 -4
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +3 -3
- package/dist/auth/daemon_token_middleware.d.ts +1 -1
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +5 -5
- package/dist/auth/grant_path_schema.d.ts +15 -29
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +13 -17
- package/dist/auth/middleware.js +4 -4
- package/dist/auth/migrations.js +1 -1
- package/dist/auth/name_schema.d.ts +7 -6
- package/dist/auth/name_schema.d.ts.map +1 -1
- package/dist/auth/name_schema.js +8 -9
- package/dist/auth/password.d.ts +15 -7
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +16 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_actions.d.ts +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +3 -3
- package/dist/auth/role_grant_offer_notifications.js +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts +2 -2
- package/dist/auth/role_grant_offer_schema.js +2 -2
- package/dist/auth/role_schema.d.ts +47 -55
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +29 -35
- package/dist/auth/scope_kind_schema.d.ts +22 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +19 -19
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +6 -6
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +7 -6
- package/dist/auth/signup_route_schema.d.ts +71 -21
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +17 -19
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.js +1 -1
- package/dist/auth/token_lifetime.d.ts +33 -9
- package/dist/auth/token_lifetime.d.ts.map +1 -1
- package/dist/auth/token_lifetime.js +8 -7
- package/dist/auth/token_scope.d.ts +99 -25
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +57 -35
- package/dist/db/CLAUDE.md +2 -1
- package/dist/db/file_fact_url.d.ts +11 -6
- package/dist/db/file_fact_url.d.ts.map +1 -1
- package/dist/db/file_fact_url.js +5 -5
- package/dist/db/schema_ready.d.ts +0 -5
- package/dist/db/schema_ready.d.ts.map +1 -1
- package/dist/db/schema_ready.js +0 -5
- package/dist/http/CLAUDE.md +104 -71
- package/dist/http/auth_shape.d.ts +48 -29
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +12 -85
- package/dist/http/body_limit.d.ts +12 -0
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +15 -0
- package/dist/http/body_limit_schema.d.ts +20 -0
- package/dist/http/body_limit_schema.d.ts.map +1 -0
- package/dist/http/body_limit_schema.js +20 -0
- package/dist/http/common_routes.d.ts +1 -1
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +11 -14
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +59 -69
- package/dist/http/dev_route_error_check.d.ts +70 -0
- package/dist/http/dev_route_error_check.d.ts.map +1 -0
- package/dist/http/dev_route_error_check.js +119 -0
- package/dist/http/error_schemas.d.ts +365 -189
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +256 -149
- package/dist/http/health_schema.d.ts +10 -6
- package/dist/http/health_schema.d.ts.map +1 -1
- package/dist/http/health_schema.js +3 -3
- package/dist/http/middleware_spec.d.ts +8 -3
- package/dist/http/middleware_spec.d.ts.map +1 -1
- package/dist/http/origin.d.ts +12 -43
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +10 -6
- package/dist/http/route_error_check.d.ts +158 -0
- package/dist/http/route_error_check.d.ts.map +1 -0
- package/dist/http/route_error_check.js +247 -0
- package/dist/http/route_errors.d.ts +80 -0
- package/dist/http/route_errors.d.ts.map +1 -0
- package/dist/http/route_errors.js +83 -0
- package/dist/http/route_spec.d.ts +33 -17
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +48 -62
- package/dist/http/schema_helpers.d.ts +0 -33
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +0 -45
- package/dist/http/surface.d.ts +19 -12
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +25 -38
- package/dist/http/surface_query.d.ts +11 -2
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +7 -1
- package/dist/primitive_schemas.d.ts +2 -19
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +2 -20
- package/dist/primitive_schemas_fuz.d.ts +39 -5
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +36 -7
- package/dist/rate_limiter.d.ts +13 -0
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +20 -2
- package/dist/schema_issues.d.ts +29 -11
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +11 -10
- package/dist/schema_meta.d.ts +8 -1
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +2 -1
- package/dist/server/app_server.d.ts +3 -1
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +24 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +8 -31
- package/dist/server/surface_route.d.ts.map +1 -1
- package/dist/server/surface_route.js +5 -6
- package/dist/server/x_accel.d.ts +12 -7
- package/dist/server/x_accel.d.ts.map +1 -1
- package/dist/server/x_accel.js +7 -9
- package/dist/testing/CLAUDE.md +55 -44
- package/dist/testing/admin_integration.d.ts +3 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +2 -2
- package/dist/testing/adversarial_404.d.ts +4 -18
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +19 -51
- package/dist/testing/adversarial_headers.d.ts +3 -4
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -6
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +18 -17
- package/dist/testing/assertions.d.ts +33 -11
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +52 -12
- package/dist/testing/attack_surface.d.ts +5 -35
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +29 -91
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +11 -11
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +2 -1
- package/dist/testing/cross_backend/conformance_table.js +1 -1
- package/dist/testing/cross_backend/default_spine_surface.d.ts +2 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/fact_serving.js +3 -3
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +39 -6
- package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_conformance.js +21 -21
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
- package/dist/testing/cross_backend/setup.d.ts +14 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +68 -48
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.d.ts +4 -4
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +16 -13
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +34 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -4
- package/dist/testing/error_coverage.d.ts +24 -34
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +46 -89
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +6 -14
- package/dist/testing/integration_helpers.d.ts +37 -9
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +86 -40
- package/dist/testing/middleware.d.ts +3 -5
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -4
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +5 -4
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +5 -3
- package/dist/testing/schema_generators.d.ts +10 -3
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +23 -11
- package/dist/testing/stubs.d.ts +10 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +15 -5
- package/dist/testing/surface_invariants.d.ts +36 -115
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +106 -269
- package/dist/testing/token_scope_fixtures.d.ts +24 -0
- package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
- package/dist/testing/token_scope_fixtures.js +49 -0
- package/dist/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +13 -12
- package/dist/ui/BootstrapForm.svelte +4 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +4 -2
- package/dist/ui/SignupForm.svelte +4 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +2 -8
- package/dist/ui/backend_probe.svelte.js +3 -3
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +1 -8
- package/dist/ui/ui_fetch.d.ts +12 -2
- package/dist/ui/ui_fetch.d.ts.map +1 -1
- package/dist/ui/ui_fetch.js +22 -4
- package/package.json +1 -1
- package/dist/auth/audit_log_schema_fuz.d.ts +0 -53
- package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
- package/dist/auth/audit_log_schema_fuz.js +0 -50
- package/dist/auth/role_schema_fuz.d.ts +0 -30
- package/dist/auth/role_schema_fuz.d.ts.map +0 -1
- package/dist/auth/role_schema_fuz.js +0 -30
- package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
- package/dist/auth/scope_kind_schema_fuz.js +0 -31
package/dist/http/surface.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
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`,
|
|
5
|
-
* `
|
|
4
|
+
* Pure schema helpers (`is_null_schema`, `schema_to_surface`, `middleware_applies`,
|
|
5
|
+
* `middleware_spec_applies`) live in `http/schema_helpers.ts`, and each route's
|
|
6
|
+
* error map (`resolve_route_error_map`) in `http/route_errors.ts`.
|
|
6
7
|
*
|
|
7
8
|
* @module
|
|
8
9
|
*/
|
|
9
10
|
import { get_schema_entries, get_schema_fields } from '@fuzdev/fuz_schema/introspect.ts';
|
|
10
11
|
import { is_schema, parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
|
-
import {
|
|
12
|
+
import { to_error_schemas } from './error_schemas.js';
|
|
13
|
+
import { schema_to_surface, middleware_spec_applies, is_null_schema, is_strict_object_schema } from './schema_helpers.js';
|
|
14
|
+
import { get_route_error_map, resolve_app_route_error_maps } from './route_errors.js';
|
|
15
|
+
import { format_route_key } from './surface_query.js';
|
|
12
16
|
import { find_schema_sensitivity } from '../sensitivity.js';
|
|
13
17
|
// --- Surface generation ---
|
|
14
|
-
/**
|
|
15
|
-
* Collect error schemas from all middleware that applies to a route path.
|
|
16
|
-
* An entry left `undefined` is absent (`strip_undefined_error_schemas`),
|
|
17
|
-
* so it leaves an earlier layer's schema for that status in place.
|
|
18
|
-
*
|
|
19
|
-
* @returns merged middleware error schemas, or `null` if none
|
|
20
|
-
*/
|
|
21
|
-
export const collect_middleware_errors = (middleware, route_path) => {
|
|
22
|
-
const errors = {};
|
|
23
|
-
for (const mw of middleware) {
|
|
24
|
-
if (mw.errors && middleware_spec_applies(mw, route_path)) {
|
|
25
|
-
Object.assign(errors, strip_undefined_error_schemas(mw.errors));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return Object.keys(errors).length > 0 ? errors : null;
|
|
29
|
-
};
|
|
30
18
|
/**
|
|
31
19
|
* Convert a `@fuzdev/fuz_schema` env schema to surface entries, one per
|
|
32
20
|
* entry in order, reading each field's `meta`: the description from its
|
|
@@ -93,6 +81,7 @@ const FUZ_SCHEMA_NOT_STRICT_INPUT_MESSAGE = 'Input schema is not a strict object
|
|
|
93
81
|
*/
|
|
94
82
|
export const generate_app_surface = (options) => {
|
|
95
83
|
const { route_specs, middleware_specs, env_schema, event_specs, rpc_endpoints, ws_endpoints } = options;
|
|
84
|
+
const route_error_maps = options.route_error_maps ?? resolve_app_route_error_maps(route_specs, middleware_specs);
|
|
96
85
|
const diagnostics = [];
|
|
97
86
|
const to_surface = create_to_surface(diagnostics);
|
|
98
87
|
// Spec-level diagnostics: check for non-strict input schemas
|
|
@@ -114,9 +103,7 @@ export const generate_app_surface = (options) => {
|
|
|
114
103
|
let mw_error_schemas = null;
|
|
115
104
|
if (m.errors) {
|
|
116
105
|
const schemas = {};
|
|
117
|
-
for (const [status, schema] of Object.entries(m.errors)) {
|
|
118
|
-
if (schema === undefined)
|
|
119
|
-
continue;
|
|
106
|
+
for (const [status, schema] of Object.entries(to_error_schemas(m.errors))) {
|
|
120
107
|
const json_schema = to_surface(schema, 'output', `middleware ${m.name} errors.${status}`);
|
|
121
108
|
if (json_schema !== null) {
|
|
122
109
|
schemas[status] = json_schema;
|
|
@@ -139,23 +126,19 @@ export const generate_app_surface = (options) => {
|
|
|
139
126
|
const applicable_middleware = middleware_specs
|
|
140
127
|
.filter((m) => middleware_spec_applies(m, r.path))
|
|
141
128
|
.map((m) => m.name);
|
|
142
|
-
const route =
|
|
143
|
-
//
|
|
144
|
-
const mw_errors = collect_middleware_errors(middleware_specs, r.path);
|
|
145
|
-
const merged_errors = merge_error_schemas(r, mw_errors);
|
|
129
|
+
const route = format_route_key(r);
|
|
130
|
+
// the route's error map: derived, middleware, and explicit, unioned
|
|
146
131
|
let error_schemas = null;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
schemas[status] = json_schema;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (Object.keys(schemas).length > 0) {
|
|
156
|
-
error_schemas = schemas;
|
|
132
|
+
const schemas = {};
|
|
133
|
+
for (const [status, schema] of Object.entries(get_route_error_map(route_error_maps, r).schemas)) {
|
|
134
|
+
const json_schema = to_surface(schema, 'output', `${route} errors.${status}`);
|
|
135
|
+
if (json_schema !== null) {
|
|
136
|
+
schemas[status] = json_schema;
|
|
157
137
|
}
|
|
158
138
|
}
|
|
139
|
+
if (Object.keys(schemas).length > 0) {
|
|
140
|
+
error_schemas = schemas;
|
|
141
|
+
}
|
|
159
142
|
return {
|
|
160
143
|
method: r.method,
|
|
161
144
|
path: r.path,
|
|
@@ -217,14 +200,18 @@ export const generate_app_surface = (options) => {
|
|
|
217
200
|
};
|
|
218
201
|
};
|
|
219
202
|
/**
|
|
220
|
-
* Create an `AppSurfaceSpec` — the surface bundled with its source specs
|
|
203
|
+
* Create an `AppSurfaceSpec` — the surface bundled with its source specs and
|
|
204
|
+
* each route's error map, built once and read by both.
|
|
221
205
|
*/
|
|
222
206
|
export const create_app_surface_spec = (options) => {
|
|
223
|
-
const
|
|
207
|
+
const route_error_maps = options.route_error_maps ??
|
|
208
|
+
resolve_app_route_error_maps(options.route_specs, options.middleware_specs);
|
|
209
|
+
const surface = generate_app_surface({ ...options, route_error_maps });
|
|
224
210
|
return {
|
|
225
211
|
surface,
|
|
226
212
|
route_specs: options.route_specs,
|
|
227
213
|
middleware_specs: options.middleware_specs,
|
|
214
|
+
route_error_maps,
|
|
228
215
|
rpc_endpoints: options.rpc_endpoints ?? [],
|
|
229
216
|
ws_endpoints: options.ws_endpoints ? [...options.ws_endpoints] : []
|
|
230
217
|
};
|
|
@@ -39,8 +39,17 @@ export declare const filter_routes_with_input: (surface: AppSurface) => Array<Ap
|
|
|
39
39
|
export declare const filter_routes_with_params: (surface: AppSurface) => Array<AppSurfaceRoute>;
|
|
40
40
|
/** Filter routes that have a non-null query schema. */
|
|
41
41
|
export declare const filter_routes_with_query: (surface: AppSurface) => Array<AppSurfaceRoute>;
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Format a route as `'METHOD /path'` (e.g. `'GET /health'`): a surface route or
|
|
44
|
+
* a route spec, its path the template. The key of a route in a map of route
|
|
45
|
+
* error maps (`resolve_app_route_error_maps`).
|
|
46
|
+
*
|
|
47
|
+
* @param route - the route's method and path template
|
|
48
|
+
*/
|
|
49
|
+
export declare const format_route_key: (route: {
|
|
50
|
+
readonly method: string;
|
|
51
|
+
readonly path: string;
|
|
52
|
+
}) => string;
|
|
44
53
|
/**
|
|
45
54
|
* Summarize route auth distribution across the surface.
|
|
46
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface_query.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface_query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAUhE,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC7B,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC3B,CAAC;AAEtD,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC3B,CAAC;AAEpD,sEAAsE;AACtE,eAAO,MAAM,oB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C9B,CAAC;AAEvD,wDAAwD;AACxD,eAAO,MAAM,yBAAyB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC9B,CAAC;AAExD,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC9B,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,KAAG,MAAyC,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,UAAU,KACjB;IACF,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CAsCd,CAAC"}
|
|
@@ -54,7 +54,13 @@ export const filter_routes_with_input = (surface) => surface.routes.filter((r) =
|
|
|
54
54
|
export const filter_routes_with_params = (surface) => surface.routes.filter((r) => r.params_schema !== null);
|
|
55
55
|
/** Filter routes that have a non-null query schema. */
|
|
56
56
|
export const filter_routes_with_query = (surface) => surface.routes.filter((r) => r.query_schema !== null);
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Format a route as `'METHOD /path'` (e.g. `'GET /health'`): a surface route or
|
|
59
|
+
* a route spec, its path the template. The key of a route in a map of route
|
|
60
|
+
* error maps (`resolve_app_route_error_maps`).
|
|
61
|
+
*
|
|
62
|
+
* @param route - the route's method and path template
|
|
63
|
+
*/
|
|
58
64
|
export const format_route_key = (route) => `${route.method} ${route.path}`;
|
|
59
65
|
/**
|
|
60
66
|
* Summarize route auth distribution across the surface.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reusable validator-schema primitives — `bounded_string`, `Username`,
|
|
3
|
-
* `
|
|
4
|
-
*
|
|
3
|
+
* `Email`, the branded `Uuid` and `Datetime` with their factories, and the
|
|
4
|
+
* hash schema `FactHashSchema`. Lives at
|
|
5
5
|
* the top level (not inside `auth/` or `http/`) because these shapes don't
|
|
6
6
|
* depend on or imply any domain — accounts hold a username and email, but
|
|
7
7
|
* invites, password resets, cells, and other surfaces all reach for the same
|
|
@@ -79,23 +79,6 @@ export declare const USERNAME_PROVIDED_LENGTH_MAX = 255;
|
|
|
79
79
|
*/
|
|
80
80
|
export declare const Username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
81
81
|
export type Username = z.infer<typeof Username>;
|
|
82
|
-
/**
|
|
83
|
-
* Username submitted for login or lookup — minimal validation for forward-compatibility if format rules change.
|
|
84
|
-
*
|
|
85
|
-
* Canonicalized via `.trim().toLowerCase()` at parse time so login's
|
|
86
|
-
* per-account rate-limit key and DB lookup see a uniform value
|
|
87
|
-
* regardless of casing or surrounding whitespace. Mirrors the storage
|
|
88
|
-
* canonicalization on `Username` so submission and storage agree.
|
|
89
|
-
*
|
|
90
|
-
* The trailing `.refine` rejects a whitespace-only identifier: `.min(1)`
|
|
91
|
-
* runs on the raw string (so `" "` passes it), and without the post-trim
|
|
92
|
-
* check the value would canonicalize to `""` and fall through to a
|
|
93
|
-
* lookup-miss 401 instead of a 400 — an empty identifier is malformed
|
|
94
|
-
* input, not a wrong credential. Keeps the Rust spine's
|
|
95
|
-
* `account_login` (which rejects empty-after-trim) in parity.
|
|
96
|
-
*/
|
|
97
|
-
export declare const UsernameProvided: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
98
|
-
export type UsernameProvided = z.infer<typeof UsernameProvided>;
|
|
99
82
|
/**
|
|
100
83
|
* Maximum email length in **bytes** — RFC 5321 §4.5.3.1.3 path-length limit
|
|
101
84
|
* (the limit is octets). `Email` bounds the UTF-8 byte length, matching the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAIlF,gEAAgE;AAChE,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,oBAAoB,KAAG,CAAC,CAAC,SA+ChE,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,6GAA6G;AAC7G,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAwC,CAAC;AAEpE,gNAAgN;AAChN,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,wDAEc,CAAC;AACpC,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"primitive_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK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AO,MAAM,WAAW,QAAO,IAAmC,CAAC;AAcnE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAEC,CAAC;AAC1E,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,qFAAqF;AACrF,eAAO,MAAM,eAAe,iIAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,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;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAEA,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reusable validator-schema primitives — `bounded_string`, `Username`,
|
|
3
|
-
* `
|
|
4
|
-
*
|
|
3
|
+
* `Email`, the branded `Uuid` and `Datetime` with their factories, and the
|
|
4
|
+
* hash schema `FactHashSchema`. Lives at
|
|
5
5
|
* the top level (not inside `auth/` or `http/`) because these shapes don't
|
|
6
6
|
* depend on or imply any domain — accounts hold a username and email, but
|
|
7
7
|
* invites, password resets, cells, and other surfaces all reach for the same
|
|
@@ -117,24 +117,6 @@ export const USERNAME_PROVIDED_LENGTH_MAX = 255;
|
|
|
117
117
|
export const Username = bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX })
|
|
118
118
|
.regex(USERNAME_REGEX)
|
|
119
119
|
.transform((s) => s.toLowerCase());
|
|
120
|
-
/**
|
|
121
|
-
* Username submitted for login or lookup — minimal validation for forward-compatibility if format rules change.
|
|
122
|
-
*
|
|
123
|
-
* Canonicalized via `.trim().toLowerCase()` at parse time so login's
|
|
124
|
-
* per-account rate-limit key and DB lookup see a uniform value
|
|
125
|
-
* regardless of casing or surrounding whitespace. Mirrors the storage
|
|
126
|
-
* canonicalization on `Username` so submission and storage agree.
|
|
127
|
-
*
|
|
128
|
-
* The trailing `.refine` rejects a whitespace-only identifier: `.min(1)`
|
|
129
|
-
* runs on the raw string (so `" "` passes it), and without the post-trim
|
|
130
|
-
* check the value would canonicalize to `""` and fall through to a
|
|
131
|
-
* lookup-miss 401 instead of a 400 — an empty identifier is malformed
|
|
132
|
-
* input, not a wrong credential. Keeps the Rust spine's
|
|
133
|
-
* `account_login` (which rejects empty-after-trim) in parity.
|
|
134
|
-
*/
|
|
135
|
-
export const UsernameProvided = bounded_string({ min: 1, max: USERNAME_PROVIDED_LENGTH_MAX })
|
|
136
|
-
.transform((s) => s.trim().toLowerCase())
|
|
137
|
-
.refine((s) => s.length > 0, { message: 'Username must not be empty after trimming whitespace' });
|
|
138
120
|
/**
|
|
139
121
|
* Maximum email length in **bytes** — RFC 5321 §4.5.3.1.3 path-length limit
|
|
140
122
|
* (the limit is octets). `Email` bounds the UTF-8 byte length, matching the
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Username`,
|
|
3
|
-
* `Email`, `Uuid`, `UuidWithDefault` (`primitive_schemas.ts`), and
|
|
3
|
+
* `Email`, `Uuid`, `UuidWithDefault`, `FactHashSchema` (`primitive_schemas.ts`), and
|
|
4
4
|
* `ActingActor` (`http/auth_shape.ts`), under the same names, for schemas
|
|
5
5
|
* written in fuz_schema; `UsernameCanonical`, the username an output carries;
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
6
|
+
* `UsernameProvided`, the username login and lookup take; `Timestamp`, a
|
|
7
|
+
* timestamp on the wire; and `Blake3Hash`, a BLAKE3 hex hash. The last four
|
|
8
|
+
* have no Zod twin.
|
|
8
9
|
*
|
|
9
10
|
* The output type is shared: the Zod `Uuid` outputs fuz_schema's
|
|
10
|
-
* `Branded<string, 'Uuid'>` too,
|
|
11
|
-
* the other's is taken.
|
|
11
|
+
* `Branded<string, 'Uuid'>` too, and both `FactHashSchema`s output fuz_util's
|
|
12
|
+
* `FactHash`, so a value parsed by either twin goes where the other's is taken.
|
|
12
13
|
*
|
|
13
14
|
* Both twins have one grammar, RFC 9562's read case-insensitively as its §4
|
|
14
15
|
* says, the max UUID included, and the Rust spine's: every input gets the same
|
|
@@ -59,6 +60,25 @@ export declare const USERNAME_CANONICAL_REGEX: RegExp;
|
|
|
59
60
|
*/
|
|
60
61
|
export declare const UsernameCanonical: PipeSchema<string, PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
61
62
|
export type UsernameCanonical = Infer<typeof UsernameCanonical>;
|
|
63
|
+
/**
|
|
64
|
+
* Username submitted for login or lookup — minimal validation, for
|
|
65
|
+
* forward-compatibility if the creation grammar changes: at least one and at
|
|
66
|
+
* most `USERNAME_PROVIDED_LENGTH_MAX` UTF-16 code units, measured before
|
|
67
|
+
* trimming, holding a character that isn't whitespace.
|
|
68
|
+
*
|
|
69
|
+
* Canonicalized to `.trim().toLowerCase()` at parse time, so login's
|
|
70
|
+
* per-account rate-limit key and its lookup see one value whatever the casing
|
|
71
|
+
* or surrounding whitespace, as `Username` canonicalizes what is stored.
|
|
72
|
+
*
|
|
73
|
+
* A whitespace-only identifier is refused, not canonicalized to `""` and left
|
|
74
|
+
* to fall through to a lookup-miss 401: an empty identifier is malformed
|
|
75
|
+
* input, not a wrong credential, and the Rust spine's `account_login` refuses
|
|
76
|
+
* it too. JS `\s` is exactly the set `trim` removes (ECMA-262's WhiteSpace and
|
|
77
|
+
* LineTerminator), so the `regex` ahead of the transform refuses what would
|
|
78
|
+
* trim to nothing.
|
|
79
|
+
*/
|
|
80
|
+
export declare const UsernameProvided: PipeSchema<string, PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
81
|
+
export type UsernameProvided = Infer<typeof UsernameProvided>;
|
|
62
82
|
/**
|
|
63
83
|
* Email validation, the twin of the Zod `Email`: `EMAIL_REGEX` and at most
|
|
64
84
|
* `EMAIL_LENGTH_MAX` UTF-8 bytes, no transform. The `max_length` ahead of the
|
|
@@ -113,6 +133,20 @@ export type UuidWithDefault = Infer<typeof UuidWithDefault>;
|
|
|
113
133
|
*/
|
|
114
134
|
export declare const Timestamp: PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
115
135
|
export type Timestamp = Infer<typeof Timestamp>;
|
|
136
|
+
/**
|
|
137
|
+
* A `blake3:`-prefixed fact hash on the wire, the twin of the Zod
|
|
138
|
+
* `FactHashSchema`: `FACT_HASH_EXACT`, its output fuz_util's `FactHash`, which
|
|
139
|
+
* `fact_hash_bytes`, `fact_hash_stream`, and `FactStore` take. The twins agree
|
|
140
|
+
* on every input, and their JSON Schema is the same `pattern`.
|
|
141
|
+
*
|
|
142
|
+
* @nodocs
|
|
143
|
+
*/
|
|
144
|
+
export declare const FactHashSchema: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "FactHash">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
145
|
+
readonly '~types'?: {
|
|
146
|
+
readonly input: string;
|
|
147
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
148
|
+
} | undefined;
|
|
149
|
+
};
|
|
116
150
|
/** A BLAKE3 hex hash's grammar: 64 lowercase hex characters (256-bit output). */
|
|
117
151
|
export declare const BLAKE3_HASH_REGEX: RegExp;
|
|
118
152
|
/** The message of a string off `BLAKE3_HASH_REGEX`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive_schemas_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas_fuz.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"primitive_schemas_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/primitive_schemas_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAUN,MAAM,EAKN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAUN,KAAK,oBAAoB,EACzB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAC1B,SAAS,oBAAoB,KAC3B,UAAU,CAAC,MAAM,EAAE,OAAO,MAAM,CAKlC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,4HAIpB,CAAC;AACF,cAAc;AACd,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAA+B,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,4HAG7B,CAAC;AACF,MAAM,M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1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@fuzdev/fuz_schema` twins of the Zod `bounded_string`, `Username`,
|
|
3
|
-
* `Email`, `Uuid`, `UuidWithDefault` (`primitive_schemas.ts`), and
|
|
3
|
+
* `Email`, `Uuid`, `UuidWithDefault`, `FactHashSchema` (`primitive_schemas.ts`), and
|
|
4
4
|
* `ActingActor` (`http/auth_shape.ts`), under the same names, for schemas
|
|
5
5
|
* written in fuz_schema; `UsernameCanonical`, the username an output carries;
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
6
|
+
* `UsernameProvided`, the username login and lookup take; `Timestamp`, a
|
|
7
|
+
* timestamp on the wire; and `Blake3Hash`, a BLAKE3 hex hash. The last four
|
|
8
|
+
* have no Zod twin.
|
|
8
9
|
*
|
|
9
10
|
* The output type is shared: the Zod `Uuid` outputs fuz_schema's
|
|
10
|
-
* `Branded<string, 'Uuid'>` too,
|
|
11
|
-
* the other's is taken.
|
|
11
|
+
* `Branded<string, 'Uuid'>` too, and both `FactHashSchema`s output fuz_util's
|
|
12
|
+
* `FactHash`, so a value parsed by either twin goes where the other's is taken.
|
|
12
13
|
*
|
|
13
14
|
* Both twins have one grammar, RFC 9562's read case-insensitively as its §4
|
|
14
15
|
* says, the max UUID included, and the Rust spine's: every input gets the same
|
|
@@ -20,8 +21,9 @@
|
|
|
20
21
|
* @module
|
|
21
22
|
*/
|
|
22
23
|
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
23
|
-
import { brand, check, iso_datetime, max_length, message, min_length, optional, pipe, regex, string, to_lower_case, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
|
|
24
|
-
import {
|
|
24
|
+
import { brand, check, iso_datetime, max_length, message, min_length, optional, pipe, regex, string, to_lower_case, transform, uuid, with_default_fn } from '@fuzdev/fuz_schema/schema.ts';
|
|
25
|
+
import { FACT_HASH_EXACT } from '@fuzdev/fuz_util/hash_schemas.ts';
|
|
26
|
+
import { create_uuid, EMAIL_LENGTH_MAX, EMAIL_LENGTH_MESSAGE, EMAIL_REGEX, is_email_within_length_max, USERNAME_LENGTH_MAX, USERNAME_LENGTH_MIN, USERNAME_PROVIDED_LENGTH_MAX, USERNAME_REGEX } from './primitive_schemas.js';
|
|
25
27
|
/**
|
|
26
28
|
* A string schema whose length is bounded in UTF-16 code units, the twin of
|
|
27
29
|
* the Zod `bounded_string`: fuz_schema's `min_length` / `max_length` read
|
|
@@ -61,6 +63,24 @@ export const USERNAME_CANONICAL_REGEX = /^[a-z][0-9a-z_-]*[0-9a-z]$/;
|
|
|
61
63
|
* username in any other case fails, where the Zod `Username` lowercased it.
|
|
62
64
|
*/
|
|
63
65
|
export const UsernameCanonical = pipe(bounded_string({ min: USERNAME_LENGTH_MIN, max: USERNAME_LENGTH_MAX }), regex(USERNAME_CANONICAL_REGEX));
|
|
66
|
+
/**
|
|
67
|
+
* Username submitted for login or lookup — minimal validation, for
|
|
68
|
+
* forward-compatibility if the creation grammar changes: at least one and at
|
|
69
|
+
* most `USERNAME_PROVIDED_LENGTH_MAX` UTF-16 code units, measured before
|
|
70
|
+
* trimming, holding a character that isn't whitespace.
|
|
71
|
+
*
|
|
72
|
+
* Canonicalized to `.trim().toLowerCase()` at parse time, so login's
|
|
73
|
+
* per-account rate-limit key and its lookup see one value whatever the casing
|
|
74
|
+
* or surrounding whitespace, as `Username` canonicalizes what is stored.
|
|
75
|
+
*
|
|
76
|
+
* A whitespace-only identifier is refused, not canonicalized to `""` and left
|
|
77
|
+
* to fall through to a lookup-miss 401: an empty identifier is malformed
|
|
78
|
+
* input, not a wrong credential, and the Rust spine's `account_login` refuses
|
|
79
|
+
* it too. JS `\s` is exactly the set `trim` removes (ECMA-262's WhiteSpace and
|
|
80
|
+
* LineTerminator), so the `regex` ahead of the transform refuses what would
|
|
81
|
+
* trim to nothing.
|
|
82
|
+
*/
|
|
83
|
+
export const UsernameProvided = pipe(bounded_string({ min: 1, max: USERNAME_PROVIDED_LENGTH_MAX }), message(regex(/\S/), 'Username must not be empty after trimming whitespace'), transform((s) => s.trim().toLowerCase()));
|
|
64
84
|
/**
|
|
65
85
|
* Email validation, the twin of the Zod `Email`: `EMAIL_REGEX` and at most
|
|
66
86
|
* `EMAIL_LENGTH_MAX` UTF-8 bytes, no transform. The `max_length` ahead of the
|
|
@@ -98,6 +118,15 @@ export const UuidWithDefault = with_default_fn(Uuid, create_uuid);
|
|
|
98
118
|
* branded, unlike the Zod `Datetime`.
|
|
99
119
|
*/
|
|
100
120
|
export const Timestamp = pipe(string, iso_datetime);
|
|
121
|
+
/**
|
|
122
|
+
* A `blake3:`-prefixed fact hash on the wire, the twin of the Zod
|
|
123
|
+
* `FactHashSchema`: `FACT_HASH_EXACT`, its output fuz_util's `FactHash`, which
|
|
124
|
+
* `fact_hash_bytes`, `fact_hash_stream`, and `FactStore` take. The twins agree
|
|
125
|
+
* on every input, and their JSON Schema is the same `pattern`.
|
|
126
|
+
*
|
|
127
|
+
* @nodocs
|
|
128
|
+
*/
|
|
129
|
+
export const FactHashSchema = brand(pipe(string, regex(FACT_HASH_EXACT)), 'FactHash');
|
|
101
130
|
/** A BLAKE3 hex hash's grammar: 64 lowercase hex characters (256-bit output). */
|
|
102
131
|
export const BLAKE3_HASH_REGEX = /^[0-9a-f]{64}$/;
|
|
103
132
|
/** The message of a string off `BLAKE3_HASH_REGEX`. */
|
package/dist/rate_limiter.d.ts
CHANGED
|
@@ -24,6 +24,19 @@
|
|
|
24
24
|
* @module
|
|
25
25
|
*/
|
|
26
26
|
import type { Context } from 'hono';
|
|
27
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
28
|
+
/**
|
|
29
|
+
* Rate limit key type — declares what a route or RPC action's rate limiter
|
|
30
|
+
* is keyed on.
|
|
31
|
+
*
|
|
32
|
+
* - `'ip'` — per-IP rate limiting (login, bootstrap, password change, signup)
|
|
33
|
+
* - `'account'` — per-account rate limiting. On REST auth routes the key is
|
|
34
|
+
* the submitted identifier (login). On RPC actions (post-auth) the key is
|
|
35
|
+
* the resolved actor id (`request_context.actor.id`) — separate namespace.
|
|
36
|
+
* - `'both'` — both keys.
|
|
37
|
+
*/
|
|
38
|
+
export declare const RateLimitKey: import("@fuzdev/fuz_schema/schema.ts").Schema<"account" | "ip" | "both", "account" | "ip" | "both", "one_of", readonly ["ip", "account", "both"]>;
|
|
39
|
+
export type RateLimitKey = Infer<typeof RateLimitKey>;
|
|
27
40
|
/**
|
|
28
41
|
* Default tracked-key cap: bounds worst-case memory under key-enumeration
|
|
29
42
|
* attacks (an attacker rotating source IPs cannot grow the backing map
|
|
@@ -1 +1 @@
|
|
|
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,CAAC;
|
|
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,CAAC;AAEpC,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAKlE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,mJAAoC,CAAC;AAC9D,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EA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GAAG,IAAI,EAClB,UAAU,uBAAuB,KAC/B,OAAO,CAAC,sBAAsB,CAGhC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,OAAO,CAAC,kBAAkB,CAAC,KAAG,WAE3E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,GAAG,OAAO,EAAE,aAAa,MAAM,KAAG,QAM9E,CAAC"}
|
package/dist/rate_limiter.js
CHANGED
|
@@ -24,8 +24,20 @@
|
|
|
24
24
|
* @module
|
|
25
25
|
*/
|
|
26
26
|
import { LruMap } from '@fuzdev/fuz_util/lru_map.ts';
|
|
27
|
-
import {
|
|
27
|
+
import { one_of } from '@fuzdev/fuz_schema/schema.ts';
|
|
28
|
+
import { REST_RATE_LIMIT_EXCEEDED } from './http/error_schemas.js';
|
|
28
29
|
import { PERIODIC_INTERVAL_MS_MAX } from './periodic.js';
|
|
30
|
+
/**
|
|
31
|
+
* Rate limit key type — declares what a route or RPC action's rate limiter
|
|
32
|
+
* is keyed on.
|
|
33
|
+
*
|
|
34
|
+
* - `'ip'` — per-IP rate limiting (login, bootstrap, password change, signup)
|
|
35
|
+
* - `'account'` — per-account rate limiting. On REST auth routes the key is
|
|
36
|
+
* the submitted identifier (login). On RPC actions (post-auth) the key is
|
|
37
|
+
* the resolved actor id (`request_context.actor.id`) — separate namespace.
|
|
38
|
+
* - `'both'` — both keys.
|
|
39
|
+
*/
|
|
40
|
+
export const RateLimitKey = one_of(['ip', 'account', 'both']);
|
|
29
41
|
/**
|
|
30
42
|
* Default tracked-key cap: bounds worst-case memory under key-enumeration
|
|
31
43
|
* attacks (an attacker rotating source IPs cannot grow the backing map
|
|
@@ -593,4 +605,10 @@ export const create_rate_limiter = (options) => {
|
|
|
593
605
|
* @param retry_after - seconds until the client should retry
|
|
594
606
|
* @returns a 429 Response
|
|
595
607
|
*/
|
|
596
|
-
export const rate_limit_exceeded_response = (c, retry_after) =>
|
|
608
|
+
export const rate_limit_exceeded_response = (c, retry_after) => {
|
|
609
|
+
const body = { error: REST_RATE_LIMIT_EXCEEDED.code, retry_after };
|
|
610
|
+
return c.json(body, {
|
|
611
|
+
status: REST_RATE_LIMIT_EXCEEDED.status,
|
|
612
|
+
headers: REST_RATE_LIMIT_EXCEEDED.headers(body)
|
|
613
|
+
});
|
|
614
|
+
};
|
package/dist/schema_issues.d.ts
CHANGED
|
@@ -131,20 +131,38 @@ export declare const format_issues: (issues: ReadonlyArray<AnyIssue>) => string;
|
|
|
131
131
|
*/
|
|
132
132
|
export declare const is_schema_validation_error: (err: unknown) => err is z.ZodError | SchemaError;
|
|
133
133
|
/**
|
|
134
|
-
* A validation issue as an error
|
|
135
|
-
* library
|
|
136
|
-
* text of the issue. `to_wire_issues` builds it
|
|
134
|
+
* A `@fuzdev/fuz_schema` `loose_object`: a validation issue as an error
|
|
135
|
+
* response carries it, for either schema library — fuz_schema's `SchemaIssue`
|
|
136
|
+
* as JSON, with `message` the text of the issue. `to_wire_issues` builds it
|
|
137
|
+
* from either library's issues.
|
|
137
138
|
*
|
|
138
139
|
* Loose: a client reads it, and a newer server may add fields.
|
|
139
140
|
*/
|
|
140
|
-
export declare const WireIssue:
|
|
141
|
-
|
|
142
|
-
path:
|
|
143
|
-
expected:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
},
|
|
147
|
-
|
|
141
|
+
export declare const WireIssue: Schema<{
|
|
142
|
+
message: string;
|
|
143
|
+
path: (string | number)[];
|
|
144
|
+
expected: string;
|
|
145
|
+
kind: string;
|
|
146
|
+
received: string;
|
|
147
|
+
} & Record<string, unknown>, {
|
|
148
|
+
message: string;
|
|
149
|
+
path: (string | number)[];
|
|
150
|
+
expected: string;
|
|
151
|
+
kind: string;
|
|
152
|
+
received: string;
|
|
153
|
+
} & Record<string, unknown>, "loose_object", {
|
|
154
|
+
/** The fuz_schema kind of the check that failed, or `unknown_key` / `missing_key`. */
|
|
155
|
+
kind: Schema<string, string, "string", undefined>;
|
|
156
|
+
/** Keys from the root value to the one that failed, outermost first. */
|
|
157
|
+
path: Schema<(string | number)[], (string | number)[], "array", Schema<string | number, string | number, "union", readonly [Schema<string, string, "string", undefined>, Schema<number, number, "number", undefined>]>>;
|
|
158
|
+
/** Describes what was expected, as fuz_schema writes it. */
|
|
159
|
+
expected: Schema<string, string, "string", undefined>;
|
|
160
|
+
/** The type of the value that failed: `'null'`, `'array'`, `'NaN'`, `'Infinity'`, `'-Infinity'`, or its `typeof`. */
|
|
161
|
+
received: Schema<string, string, "string", undefined>;
|
|
162
|
+
/** The issue as text: `format_issue` for a fuz_schema issue, Zod's own message for a Zod one. */
|
|
163
|
+
message: Schema<string, string, "string", undefined>;
|
|
164
|
+
}>;
|
|
165
|
+
export type WireIssue = Infer<typeof WireIssue>;
|
|
148
166
|
/**
|
|
149
167
|
* A failed parse's issues as `WireIssue`s, whichever library made them.
|
|
150
168
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_issues.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_issues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"schema_issues.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_issues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAON,WAAW,EAGX,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAA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od';
|
|
13
|
-
import { format_issue, is_schema, parse, SchemaError } from '@fuzdev/fuz_schema/schema.ts';
|
|
13
|
+
import { array, format_issue, is_schema, loose_object, number, parse, SchemaError, string, union } from '@fuzdev/fuz_schema/schema.ts';
|
|
14
14
|
/**
|
|
15
15
|
* Whether `value` is a Zod schema. Zod's `instanceof` reads the schema's
|
|
16
16
|
* traits, so a schema made by another copy of Zod is one too.
|
|
@@ -149,23 +149,24 @@ export const format_issues = (issues) => {
|
|
|
149
149
|
*/
|
|
150
150
|
export const is_schema_validation_error = (err) => err instanceof z.ZodError || err instanceof SchemaError;
|
|
151
151
|
/**
|
|
152
|
-
* A validation issue as an error
|
|
153
|
-
* library
|
|
154
|
-
* text of the issue. `to_wire_issues` builds it
|
|
152
|
+
* A `@fuzdev/fuz_schema` `loose_object`: a validation issue as an error
|
|
153
|
+
* response carries it, for either schema library — fuz_schema's `SchemaIssue`
|
|
154
|
+
* as JSON, with `message` the text of the issue. `to_wire_issues` builds it
|
|
155
|
+
* from either library's issues.
|
|
155
156
|
*
|
|
156
157
|
* Loose: a client reads it, and a newer server may add fields.
|
|
157
158
|
*/
|
|
158
|
-
export const WireIssue =
|
|
159
|
+
export const WireIssue = loose_object({
|
|
159
160
|
/** The fuz_schema kind of the check that failed, or `unknown_key` / `missing_key`. */
|
|
160
|
-
kind:
|
|
161
|
+
kind: string,
|
|
161
162
|
/** Keys from the root value to the one that failed, outermost first. */
|
|
162
|
-
path:
|
|
163
|
+
path: array(union([string, number])),
|
|
163
164
|
/** Describes what was expected, as fuz_schema writes it. */
|
|
164
|
-
expected:
|
|
165
|
+
expected: string,
|
|
165
166
|
/** The type of the value that failed: `'null'`, `'array'`, `'NaN'`, `'Infinity'`, `'-Infinity'`, or its `typeof`. */
|
|
166
|
-
received:
|
|
167
|
+
received: string,
|
|
167
168
|
/** The issue as text: `format_issue` for a fuz_schema issue, Zod's own message for a Zod one. */
|
|
168
|
-
message:
|
|
169
|
+
message: string
|
|
169
170
|
});
|
|
170
171
|
/**
|
|
171
172
|
* A failed parse's issues as `WireIssue`s, whichever library made them.
|
package/dist/schema_meta.d.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* `invalid_reason` and `empty_input_handler_guarded` to fuz_schema's
|
|
9
9
|
* `SchemaMeta`, so the declared refusal reason of an action input, its
|
|
10
10
|
* handler-guarded marker, and its sensitivity read the same whichever library
|
|
11
|
-
* its schema is.
|
|
11
|
+
* its schema is. It also adds JSON Schema's `readOnly` annotation, which
|
|
12
|
+
* `to_json_schema` writes onto the node.
|
|
12
13
|
*
|
|
13
14
|
* @module
|
|
14
15
|
*/
|
|
@@ -31,6 +32,12 @@ declare module '@fuzdev/fuz_schema/meta.ts' {
|
|
|
31
32
|
* (`get_meta`), so a wrapper around it drops it, as in Zod.
|
|
32
33
|
*/
|
|
33
34
|
empty_input_handler_guarded?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* JSON Schema's `readOnly` annotation, which `to_json_schema` copies onto
|
|
37
|
+
* the node: written on the role and credential-type lists of the 403
|
|
38
|
+
* bodies (`http/error_schemas.ts`).
|
|
39
|
+
*/
|
|
40
|
+
readOnly?: boolean;
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
/** Zod `.meta()` shape for fuz_app schema metadata conventions. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_meta.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_meta.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema_meta.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/schema_meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAU7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAGN,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,MAAM,oBAAoB,CAAC;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