@fuzdev/fuz_app 0.163.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 +1 -1
- package/dist/auth/account_route_schema.d.ts +3 -27
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +6 -20
- package/dist/auth/admin_action_specs.d.ts +56 -56
- 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 +18 -18
- package/dist/auth/bootstrap_route_schema.d.ts +1 -30
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +3 -8
- 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/middleware.js +4 -4
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +3 -7
- 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_fuz.d.ts +17 -3
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +13 -3
- 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 +33 -39
- package/dist/testing/admin_integration.js +1 -1
- 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/fact_serving.js +3 -3
- 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.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
- package/dist/testing/cross_backend/setup.d.ts +13 -0
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +24 -7
- 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/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 +5 -13
- 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/ui/CLAUDE.md +4 -2
- 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/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,oBAAoB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC3B,CAAC;AAEtD;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC3B,CAAC;AAsChE,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,GAAI,SAAS,UAAU,KAAG,KAAK,CAAC,eAAe,CAC9B,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
|
|
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,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 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,6 +1,6 @@
|
|
|
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
6
|
* `UsernameProvided`, the username login and lookup take; `Timestamp`, a
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* have no Zod twin.
|
|
9
9
|
*
|
|
10
10
|
* The output type is shared: the Zod `Uuid` outputs fuz_schema's
|
|
11
|
-
* `Branded<string, 'Uuid'>` too,
|
|
12
|
-
* 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.
|
|
13
13
|
*
|
|
14
14
|
* Both twins have one grammar, RFC 9562's read case-insensitively as its §4
|
|
15
15
|
* says, the max UUID included, and the Rust spine's: every input gets the same
|
|
@@ -133,6 +133,20 @@ export type UuidWithDefault = Infer<typeof UuidWithDefault>;
|
|
|
133
133
|
*/
|
|
134
134
|
export declare const Timestamp: PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
135
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
|
+
};
|
|
136
150
|
/** A BLAKE3 hex hash's grammar: 64 lowercase hex characters (256-bit output). */
|
|
137
151
|
export declare const BLAKE3_HASH_REGEX: RegExp;
|
|
138
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;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAUN,MAAM,EAKN,KAAK,KAAK,EACV,KAAK,UAAU,EACf,MAAM,8BAA8B,CAAC;
|
|
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,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,4HAI5B,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,wGAKjB,CAAC;AACF,cAAc;AACd,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;;;;;CAAmD,CAAC;AACrE,cAAc;AACd,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;GAAqC,CAAC;AAClE,cAAc;AACd,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,SAAS,wGAA6B,CAAC;AACpD,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;CAA0D,CAAC;AAEtF,iFAAiF;AACjF,eAAO,MAAM,iBAAiB,QAAmB,CAAC;AAElD,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,sDAAsD,CAAC;AAEvF;;;GAGG;AACH,eAAO,MAAM,UAAU,wGAAuE,CAAC;AAC/F,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,0HACmF,CAAC;AAEzH;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;;;;;GAAkE,CAAC;AAC3F,cAAc;AACd,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
* `UsernameProvided`, the username login and lookup take; `Timestamp`, a
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* have no Zod twin.
|
|
9
9
|
*
|
|
10
10
|
* The output type is shared: the Zod `Uuid` outputs fuz_schema's
|
|
11
|
-
* `Branded<string, 'Uuid'>` too,
|
|
12
|
-
* 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.
|
|
13
13
|
*
|
|
14
14
|
* Both twins have one grammar, RFC 9562's read case-insensitively as its §4
|
|
15
15
|
* says, the max UUID included, and the Rust spine's: every input gets the same
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
24
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';
|
|
25
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';
|
|
26
27
|
/**
|
|
27
28
|
* A string schema whose length is bounded in UTF-16 code units, the twin of
|
|
@@ -117,6 +118,15 @@ export const UuidWithDefault = with_default_fn(Uuid, create_uuid);
|
|
|
117
118
|
* branded, unlike the Zod `Datetime`.
|
|
118
119
|
*/
|
|
119
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');
|
|
120
130
|
/** A BLAKE3 hex hash's grammar: 64 lowercase hex characters (256-bit output). */
|
|
121
131
|
export const BLAKE3_HASH_REGEX = /^[0-9a-f]{64}$/;
|
|
122
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;;;;;;;;;;;;;;;;;;;;;;;;G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AAG,GAAE,MAAmB,GAAG,eAAe;IA4B9D;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,sBAAsB;IAM1E;;;;;;;;;;;;;;;;;;;OAmBG;IACG,OAAO,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,uBAA4B,GACnC,OAAO,CAAC,sBAAsB,CAAC;IA0HlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAUxB;;;;;;OAMG;IACH,OAAO,CAAC,GAAG,GAAE,MAAmB,GAAG,IAAI;IAcvC;;;;OAIG;IACH,OAAO,IAAI,IAAI;CAMf;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,WAAW,GAAG,IAAI,EAC3B,KAAK,MAAM,GAAG,IAAI,EAClB,MAAK,MAAmB,KACtB,sBAGF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,WAAW,GAAG,IAAI,EAC3B,KAAK,MAAM,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,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,CAAC,CAAC,OAAqC,CAAC;AAEhG;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAG3F;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAGnC;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,IAAI,CAAC,SAAS,MAAM,GACxE,KAAK,CAAC,CAAC,CAAC,GACR,CAAC,SAAS,CAAC,CAAC,OAAO,GAClB,CA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F;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,aAAa,CAAC,QAAQ,CAAC,KAAG,MAO/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,CAAC,CAAC,QAAQ,GAAG,WACtB,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;IACrB,sFAAsF;;IAEtF,wEAAwE;;IAExE,4DAA4D;;IAE5D,qHAAqH;;IAErH,iGAAiG;;EAEhG,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,cAAc,GAC1B,QAAQ,aAAa,CAAC,QAAQ,CAAC,EAC/B,OAAO,OAAO,KACZ,KAAK,CAAC,SAAS,CAgBjB,CAAC"}
|
package/dist/schema_issues.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import { z } from 'zod';
|
|
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;AAE5B,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,UAAU;QACnB;;;;;WAKG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;;;;WAKG;QACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;QACtC;;;;WAIG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;KACnB;CACD;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,gBAAgB,KAAG,OAIzE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,SAAS,MAAM,eAAe,EACnE,QAAQ,CAAC,CAAC,OAAO,EACjB,KAAK,IAAI,KACP,eAAe,CAAC,IAAI,CAAC,GAAG,SAM1B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,MAAM,GAAG,SACvB,CAAC;AA4D7C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,WAAW,GAAG,SACrC,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,gBAAgB,KAAG,OAMrE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GAClC,cAAc,gBAAgB,EAC9B,MAAM,aAAa,CAAC,WAAW,CAAC,KAC9B,MAAM,GAAG,SAaX,CAAC;AAoBF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,6BAA6B,GACzC,cAAc,gBAAgB,EAC9B,QAAQ,aAAa,CAAC,QAAQ,CAAC,EAC/B,OAAO,OAAO,KACZ,MAAM,GAAG,SAKX,CAAC"}
|
package/dist/schema_meta.js
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
|
*/
|
|
@@ -200,7 +200,9 @@ export interface AppServerOptions {
|
|
|
200
200
|
* (anything else throws at assembly). Omit or `undefined` to use the
|
|
201
201
|
* default (1 MiB). Pass `null` to explicitly disable body size limiting,
|
|
202
202
|
* which adds a security warning to the surface's diagnostics (logged at
|
|
203
|
-
* startup).
|
|
203
|
+
* startup). The limit is mounted as a middleware spec at `'*'` ahead of
|
|
204
|
+
* the others (`create_body_limit_middleware_spec`), so every route's
|
|
205
|
+
* error map declares its `413` and `400`; with `null` it is absent.
|
|
204
206
|
*/
|
|
205
207
|
max_body_size?: number | null;
|
|
206
208
|
/** Daemon token state for keeper auth. Omit to disable. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAIN,KAAK,WAAW,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,WAAW,EAMX,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MA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AS,gBAAgB,KAAG,OAAO,CAAC,SAAS,CAQpF,CAAC"}
|
|
@@ -21,6 +21,7 @@ import { create_static_middleware } from './static.js';
|
|
|
21
21
|
import { log_startup_summary } from './startup.js';
|
|
22
22
|
import { create_app_error_handler } from './app_error_handler.js';
|
|
23
23
|
import { create_app_surface_spec } from '../http/surface.js';
|
|
24
|
+
import { create_dev_route_error_check } from '../http/dev_route_error_check.js';
|
|
24
25
|
import { apply_middleware_specs, apply_route_specs, prefix_route_specs } from '../http/route_spec.js';
|
|
25
26
|
import { check_bootstrap_status, create_bootstrap_route_specs } from '../auth/bootstrap_routes.js';
|
|
26
27
|
import { create_surface_route_spec } from './surface_route.js';
|
|
@@ -28,7 +29,7 @@ import { flush_request_effects } from '../http/pending_effects.js';
|
|
|
28
29
|
import { assert_credential_routes_in_auth_scope, assert_endpoint_in_auth_scope, assert_middleware_stack_mounted, create_auth_middleware_specs } from '../auth/middleware.js';
|
|
29
30
|
import { fuz_auth_guard_resolver } from '../auth/auth_guard_resolver.js';
|
|
30
31
|
import { create_fuz_authorization_handler } from '../auth/request_context.js';
|
|
31
|
-
import {
|
|
32
|
+
import { create_body_limit_middleware_spec } from '../http/body_limit.js';
|
|
32
33
|
import { admit_origin_wildcards, ALLOWED_ORIGINS_VAR } from '../http/origin_wildcard.js';
|
|
33
34
|
import { create_rpc_endpoint } from '../actions/action_rpc.js';
|
|
34
35
|
import { register_action_ws } from '../actions/register_action_ws.js';
|
|
@@ -277,10 +278,11 @@ const assemble_app_server = async (options, releases) => {
|
|
|
277
278
|
log.warn(`${ALLOWED_ORIGINS_VAR}: ${warning} (origin ${entry})`);
|
|
278
279
|
}
|
|
279
280
|
// body size limit — rejects oversized payloads before auth/validation; the
|
|
280
|
-
// middleware throws on a cap that is not a safe integer 0 or more
|
|
281
|
-
|
|
281
|
+
// middleware throws on a cap that is not a safe integer 0 or more. A spec,
|
|
282
|
+
// so the surface and each route's error map declare its 413 and 400.
|
|
283
|
+
const body_limit_spec = options.max_body_size === null
|
|
282
284
|
? null
|
|
283
|
-
:
|
|
285
|
+
: create_body_limit_middleware_spec(options.max_body_size ?? DEFAULT_BODY_LIMIT_BYTES);
|
|
284
286
|
// Rate limiters — the ones built here are the server's to dispose, on
|
|
285
287
|
// close or when assembly fails.
|
|
286
288
|
const { mode: rate_limiter_mode, limiters: rate_limiters, built: built_rate_limiters } = resolve_rate_limiters(options);
|
|
@@ -471,10 +473,13 @@ const assemble_app_server = async (options, releases) => {
|
|
|
471
473
|
seen_paths.add(endpoint.path);
|
|
472
474
|
}
|
|
473
475
|
}
|
|
474
|
-
// Surface + logging
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
:
|
|
476
|
+
// Surface + logging — the body limit first, where it runs, ahead of the
|
|
477
|
+
// middleware specs
|
|
478
|
+
const surface_middleware = [
|
|
479
|
+
...(body_limit_spec ? [body_limit_spec] : []),
|
|
480
|
+
...middleware_specs,
|
|
481
|
+
...(options.post_route_middleware ?? [])
|
|
482
|
+
];
|
|
478
483
|
const all_event_specs = [
|
|
479
484
|
...(options.event_specs ?? []),
|
|
480
485
|
...(audit_sse ? audit_log_event_specs : [])
|
|
@@ -506,6 +511,15 @@ const assemble_app_server = async (options, releases) => {
|
|
|
506
511
|
// above all — answers here: 503 for a failed pool checkout, Hono's default
|
|
507
512
|
// 500 for anything else.
|
|
508
513
|
app.onError(create_app_error_handler(log));
|
|
514
|
+
// DEV only, and outermost, so it sees what every layer answers: logs a JSON
|
|
515
|
+
// error at a status its route's error map doesn't declare, or off its schema
|
|
516
|
+
const dev_route_error_check = create_dev_route_error_check({
|
|
517
|
+
route_specs,
|
|
518
|
+
route_error_maps: surface_spec.route_error_maps,
|
|
519
|
+
log
|
|
520
|
+
});
|
|
521
|
+
if (dev_route_error_check)
|
|
522
|
+
app.use('*', dev_route_error_check);
|
|
509
523
|
// Two-queue side-effect flush. `pending_effects` collects eager
|
|
510
524
|
// fire-and-forget promises (audit emits, api-token usage). `post_commit_effects` collects deferred thunks pushed via
|
|
511
525
|
// `emit_after_commit` (WS notifications, anything that must observe a
|
|
@@ -545,8 +559,8 @@ const assemble_app_server = async (options, releases) => {
|
|
|
545
559
|
app.use(logger((msg) => log.info(msg)));
|
|
546
560
|
}
|
|
547
561
|
// body size limit, built with the option checks above
|
|
548
|
-
if (
|
|
549
|
-
app
|
|
562
|
+
if (body_limit_spec) {
|
|
563
|
+
apply_middleware_specs(app, [body_limit_spec]);
|
|
550
564
|
}
|
|
551
565
|
apply_middleware_specs(app, middleware_specs);
|
|
552
566
|
const authorize = create_fuz_authorization_handler({ db: deps.db });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"serve_fact_route.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/serve_fact_route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AActD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQ5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAkBjD,MAAM,WAAW,+BAA+B;IAC/C,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACZ;AAkJD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iCAAiC,GAC7C,SAAS,+BAA+B,KACtC,SAyDF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,SA8CF,CAAC"}
|