@fuzdev/fuz_app 0.126.0 → 0.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +37 -21
- package/dist/actions/connection_closer.d.ts +16 -4
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +20 -4
- package/dist/actions/register_action_ws.d.ts +10 -2
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +6 -3
- package/dist/actions/register_ws_endpoint.d.ts +3 -1
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +3 -1
- package/dist/auth/CLAUDE.md +13 -9
- package/dist/auth/audit_emitter.d.ts +59 -12
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +53 -15
- package/dist/auth/middleware.d.ts +30 -0
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +59 -0
- package/dist/http/CLAUDE.md +3 -3
- package/dist/http/surface.d.ts +12 -11
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +1 -15
- package/dist/rate_limiter.d.ts +19 -1
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +23 -0
- package/dist/realtime/sse_auth_guard.d.ts +3 -1
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/server/app_server.d.ts +41 -13
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +105 -50
- package/dist/testing/CLAUDE.md +51 -38
- package/dist/testing/app_server.d.ts +1 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +15 -14
- package/dist/testing/attack_surface.d.ts +1 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.d.ts +4 -2
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +14 -4
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +1 -2
- package/dist/testing/cross_backend/capabilities.d.ts +3 -1
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -34
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +1 -31
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +3 -3
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +43 -3
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +43 -3
- package/dist/testing/cross_backend/testing_backdoor.d.ts +15 -1
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +49 -5
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +27 -18
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +30 -19
- package/dist/testing/cross_backend/testing_server_core.d.ts +11 -11
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +2 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +0 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +2 -4
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts +1 -1
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.d.ts +2 -1
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +40 -4
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +4 -3
- package/dist/testing/stubs.d.ts +26 -6
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +56 -16
- package/dist/testing/ws_round_trip.d.ts +7 -31
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +0 -38
- package/package.json +1 -1
|
@@ -38,6 +38,36 @@ export declare const AUTH_MIDDLEWARE_PATH = "/api/*";
|
|
|
38
38
|
* @throws Error when `path` is outside `AUTH_MIDDLEWARE_PATH`
|
|
39
39
|
*/
|
|
40
40
|
export declare const assert_endpoint_in_auth_scope: (option: "rpc_endpoints" | "ws_endpoints", path: string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Throw unless a middleware list still mounts every spec of the stack it was
|
|
43
|
+
* built from — the trusted-proxy spec and the auth middleware — exactly once,
|
|
44
|
+
* at its original path, in its original order.
|
|
45
|
+
*
|
|
46
|
+
* `create_app_server` and `create_test_app_surface_spec` run it on the list
|
|
47
|
+
* a `transform_middleware` option returns, against the stack they handed it
|
|
48
|
+
* (`[proxy, ...auth]`). The endpoint auth-scope check
|
|
49
|
+
* (`assert_endpoint_in_auth_scope`) assumes the auth stack is mounted at
|
|
50
|
+
* `AUTH_MIDDLEWARE_PATH`, and every IP-keyed rate limiter assumes the proxy
|
|
51
|
+
* spec ran first — without it `get_client_ip` answers `'unknown'` for every
|
|
52
|
+
* caller, collapsing each limiter into one shared bucket. So a transform that
|
|
53
|
+
* moves, drops, duplicates, reorders, wraps, or replaces a stack layer is
|
|
54
|
+
* refused. Other specs may sit anywhere, including before the proxy spec and
|
|
55
|
+
* between the auth layers. The check pins where the stack's layers sit, not
|
|
56
|
+
* what added layers do — a layer you add runs with full context access.
|
|
57
|
+
*
|
|
58
|
+
* Each stack spec is matched by its `handler` — the closure its factory built
|
|
59
|
+
* — not by `name`, which any spec can carry, so a same-named replacement or a
|
|
60
|
+
* wrapped handler counts as missing. A spread copy (`{...spec}`) keeps the
|
|
61
|
+
* handler and still matches. Its path is compared with the original's, so
|
|
62
|
+
* pass specs the transform could not reach: the assemblies hand the transform
|
|
63
|
+
* shallow copies in a fresh array and keep the originals here.
|
|
64
|
+
*
|
|
65
|
+
* @param stack_specs - the stack the transform was built from, in mount order
|
|
66
|
+
* @param middleware_specs - the middleware list the transform returned
|
|
67
|
+
* @throws Error when a stack spec is missing, mounted more than once, mounted
|
|
68
|
+
* at another path, or out of order
|
|
69
|
+
*/
|
|
70
|
+
export declare const assert_middleware_stack_mounted: (stack_specs: ReadonlyArray<MiddlewareSpec>, middleware_specs: ReadonlyArray<MiddlewareSpec>) => void;
|
|
41
71
|
/**
|
|
42
72
|
* Per-factory configuration for the standard auth middleware stack.
|
|
43
73
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,6BAA6B,GACzC,QAAQ,eAAe,GAAG,cAAc,EACxC,MAAM,MAAM,KACV,IAOF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,kBAA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AC,cAAc,CAAC,CA4E/B,CAAC"}
|
package/dist/auth/middleware.js
CHANGED
|
@@ -41,6 +41,65 @@ export const assert_endpoint_in_auth_scope = (option, path) => {
|
|
|
41
41
|
`(${AUTH_MIDDLEWARE_PATH}) — it would see every caller as unauthenticated — mount it under /api/`);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Throw unless a middleware list still mounts every spec of the stack it was
|
|
46
|
+
* built from — the trusted-proxy spec and the auth middleware — exactly once,
|
|
47
|
+
* at its original path, in its original order.
|
|
48
|
+
*
|
|
49
|
+
* `create_app_server` and `create_test_app_surface_spec` run it on the list
|
|
50
|
+
* a `transform_middleware` option returns, against the stack they handed it
|
|
51
|
+
* (`[proxy, ...auth]`). The endpoint auth-scope check
|
|
52
|
+
* (`assert_endpoint_in_auth_scope`) assumes the auth stack is mounted at
|
|
53
|
+
* `AUTH_MIDDLEWARE_PATH`, and every IP-keyed rate limiter assumes the proxy
|
|
54
|
+
* spec ran first — without it `get_client_ip` answers `'unknown'` for every
|
|
55
|
+
* caller, collapsing each limiter into one shared bucket. So a transform that
|
|
56
|
+
* moves, drops, duplicates, reorders, wraps, or replaces a stack layer is
|
|
57
|
+
* refused. Other specs may sit anywhere, including before the proxy spec and
|
|
58
|
+
* between the auth layers. The check pins where the stack's layers sit, not
|
|
59
|
+
* what added layers do — a layer you add runs with full context access.
|
|
60
|
+
*
|
|
61
|
+
* Each stack spec is matched by its `handler` — the closure its factory built
|
|
62
|
+
* — not by `name`, which any spec can carry, so a same-named replacement or a
|
|
63
|
+
* wrapped handler counts as missing. A spread copy (`{...spec}`) keeps the
|
|
64
|
+
* handler and still matches. Its path is compared with the original's, so
|
|
65
|
+
* pass specs the transform could not reach: the assemblies hand the transform
|
|
66
|
+
* shallow copies in a fresh array and keep the originals here.
|
|
67
|
+
*
|
|
68
|
+
* @param stack_specs - the stack the transform was built from, in mount order
|
|
69
|
+
* @param middleware_specs - the middleware list the transform returned
|
|
70
|
+
* @throws Error when a stack spec is missing, mounted more than once, mounted
|
|
71
|
+
* at another path, or out of order
|
|
72
|
+
*/
|
|
73
|
+
export const assert_middleware_stack_mounted = (stack_specs, middleware_specs) => {
|
|
74
|
+
let previous_index = -1;
|
|
75
|
+
for (const stack_spec of stack_specs) {
|
|
76
|
+
let index = -1;
|
|
77
|
+
let count = 0;
|
|
78
|
+
for (let i = 0; i < middleware_specs.length; i++) {
|
|
79
|
+
if (middleware_specs[i].handler === stack_spec.handler) {
|
|
80
|
+
if (count === 0)
|
|
81
|
+
index = i;
|
|
82
|
+
count++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const found = count === 0
|
|
86
|
+
? 'missing'
|
|
87
|
+
: count > 1
|
|
88
|
+
? `mounted ${count} times`
|
|
89
|
+
: middleware_specs[index].path !== stack_spec.path
|
|
90
|
+
? `mounted at ${middleware_specs[index].path}`
|
|
91
|
+
: index < previous_index
|
|
92
|
+
? 'out of order'
|
|
93
|
+
: null;
|
|
94
|
+
if (found) {
|
|
95
|
+
throw new Error(`transform_middleware must keep the middleware '${stack_spec.name}' mounted once ` +
|
|
96
|
+
`at ${stack_spec.path} in its original order (${found}) — endpoint auth-scope checks ` +
|
|
97
|
+
'and client-IP rate limiting assume it; add layers around the stack, ' +
|
|
98
|
+
"don't move, drop, wrap, or replace it");
|
|
99
|
+
}
|
|
100
|
+
previous_index = index;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
44
103
|
/**
|
|
45
104
|
* Create the auth middleware stack.
|
|
46
105
|
*
|
package/dist/http/CLAUDE.md
CHANGED
|
@@ -246,12 +246,12 @@ policy invariants.
|
|
|
246
246
|
|
|
247
247
|
### Types
|
|
248
248
|
|
|
249
|
-
- `AppSurface` — JSON-serializable output (`middleware`, `routes`, `rpc_endpoints`, `env`, `events`, `diagnostics`)
|
|
250
|
-
- `AppSurfaceSpec` — the surface bundled with the **source specs** (`surface`, `route_specs`, `middleware_specs`, `rpc_endpoints`). Runtime-only — use for tests and introspection
|
|
249
|
+
- `AppSurface` — JSON-serializable output (`middleware`, `routes`, `rpc_endpoints`, `ws_endpoints`, `env`, `events`, `diagnostics`)
|
|
250
|
+
- `AppSurfaceSpec` — the surface bundled with the **source specs** (`surface`, `route_specs`, `middleware_specs`, `rpc_endpoints`, `ws_endpoints`). Runtime-only — use for tests and introspection
|
|
251
251
|
- `AppSurfaceRoute`, `AppSurfaceMiddleware`, `AppSurfaceEnv`, `AppSurfaceEvent`, `AppSurfaceRpcEndpoint`, `AppSurfaceRpcMethod` — per-entity entries
|
|
252
252
|
- `AppSurfaceDiagnostic` — `{level: 'warning' | 'info'; category; message; source?}`
|
|
253
253
|
- `RpcEndpointSpec` — `{path, actions: Array<RpcAction>}`; fed into `generate_app_surface` so RPC endpoints appear in the surface without coupling to `create_rpc_endpoint`
|
|
254
|
-
- `GenerateAppSurfaceOptions` — `{route_specs, middleware_specs, env_schema?, event_specs?, rpc_endpoints?}`
|
|
254
|
+
- `GenerateAppSurfaceOptions` — `{route_specs, middleware_specs, env_schema?, event_specs?, rpc_endpoints?, ws_endpoints?}`; `ws_endpoints` takes `ResolvedWsEndpointSpec`s (`allowed_origins` filled in by `resolve_ws_endpoints`), so the surface records the patterns the upgrade gate matches
|
|
255
255
|
|
|
256
256
|
`generate_app_surface(options)` emits a `warning` diagnostic for every
|
|
257
257
|
input schema that's not strict (unknown keys silently strip under
|
package/dist/http/surface.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { RouteAuth } from './auth_shape.js';
|
|
|
14
14
|
import type { RateLimitKey, RouteErrorSchemas } from './error_schemas.js';
|
|
15
15
|
import type { RpcAction } from '../actions/action_rpc.js';
|
|
16
16
|
import type { ActionKind } from '../actions/action_spec.js';
|
|
17
|
-
import type {
|
|
17
|
+
import type { ResolvedWsEndpointSpec } from '../actions/ws_endpoint_spec.js';
|
|
18
18
|
import type { Sensitivity } from '../sensitivity.js';
|
|
19
19
|
/** A route in the generated attack surface (JSON-serializable). */
|
|
20
20
|
export interface AppSurfaceRoute {
|
|
@@ -111,11 +111,12 @@ export interface AppSurfaceWsMethod {
|
|
|
111
111
|
export interface AppSurfaceWsEndpoint {
|
|
112
112
|
path: string;
|
|
113
113
|
/**
|
|
114
|
-
* Upgrade-time origin allowlist
|
|
115
|
-
* regex stringified via
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
114
|
+
* Upgrade-time origin allowlist — the spec's own `allowed_origins`, or the
|
|
115
|
+
* server's when it declares none — one entry per regex, stringified via
|
|
116
|
+
* `RegExp.prototype.toString()` (`'/<source>/<flags>'`). An empty array
|
|
117
|
+
* refuses every request that carries an `Origin`. Reviewers read this as the
|
|
118
|
+
* exact pattern matched at the upgrade gate, not a wildcard approximation.
|
|
119
|
+
* Reconstruct via `new RegExp(source, flags)` if needed.
|
|
119
120
|
*/
|
|
120
121
|
allowed_origins: ReadonlyArray<string>;
|
|
121
122
|
/**
|
|
@@ -161,7 +162,7 @@ export interface AppSurfaceSpec {
|
|
|
161
162
|
route_specs: Array<RouteSpec>;
|
|
162
163
|
middleware_specs: Array<MiddlewareSpec>;
|
|
163
164
|
rpc_endpoints: Array<RpcEndpointSpec>;
|
|
164
|
-
ws_endpoints: Array<
|
|
165
|
+
ws_endpoints: Array<ResolvedWsEndpointSpec>;
|
|
165
166
|
}
|
|
166
167
|
/** An RPC endpoint definition for surface generation. */
|
|
167
168
|
export interface RpcEndpointSpec {
|
|
@@ -179,11 +180,11 @@ export interface GenerateAppSurfaceOptions {
|
|
|
179
180
|
* Mounted WS endpoints (the same array `create_app_server.ws_endpoints`
|
|
180
181
|
* auto-mounts). Each entry's actions surface into
|
|
181
182
|
* `AppSurface.ws_endpoints[i].methods` for attack-surface tests +
|
|
182
|
-
* startup logging. Each
|
|
183
|
-
* `
|
|
184
|
-
*
|
|
183
|
+
* startup logging. Each carries its effective `allowed_origins` —
|
|
184
|
+
* `resolve_ws_endpoints` fills in the server's list where a spec omits
|
|
185
|
+
* it — so the surface records the exact patterns the upgrade gate matches.
|
|
185
186
|
*/
|
|
186
|
-
ws_endpoints?: ReadonlyArray<
|
|
187
|
+
ws_endpoints?: ReadonlyArray<ResolvedWsEndpointSpec>;
|
|
187
188
|
}
|
|
188
189
|
/**
|
|
189
190
|
* Collect error schemas from all middleware that applies to a route path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB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E,KAAK,CAAC,cAAc,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACvC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CACrD;AAID;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACrC,YAAY,KAAK,CAAC,cAAc,CAAC,EACjC,YAAY,MAAM,KAChB,iBAAiB,GAAG,IAQtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,SAAS,KAAG,KAAK,CAAC,aAAa,CAe9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,eAAe,CAOtF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,yBAAyB,KAAG,UAqHzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,yBAAyB,KAAG,cAS5E,CAAC"}
|
package/dist/http/surface.js
CHANGED
|
@@ -8,20 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { schema_to_surface, middleware_applies, merge_error_schemas, is_null_schema, is_strict_object_schema } from './schema_helpers.js';
|
|
11
|
-
/**
|
|
12
|
-
* Stringify a WS endpoint's origin allowlist for the surface. Throws when
|
|
13
|
-
* the spec carries none: the surface records the exact patterns the
|
|
14
|
-
* upgrade gate matches, and an omitted list means the caller never
|
|
15
|
-
* resolved the server default, not any-origin.
|
|
16
|
-
*/
|
|
17
|
-
const to_surface_allowed_origins = (ep) => {
|
|
18
|
-
if (!ep.allowed_origins) {
|
|
19
|
-
throw new Error(`generate_app_surface: ws endpoint ${ep.path} has no allowed_origins — ` +
|
|
20
|
-
"resolve the server's allowed_origins into the spec before surface generation " +
|
|
21
|
-
"(resolve_ws_endpoints, or create_test_app_surface_spec's allowed_origins option)");
|
|
22
|
-
}
|
|
23
|
-
return ep.allowed_origins.map((re) => re.toString());
|
|
24
|
-
};
|
|
25
11
|
// --- Surface generation ---
|
|
26
12
|
/**
|
|
27
13
|
* Collect error schemas from all middleware that applies to a route path.
|
|
@@ -159,7 +145,7 @@ export const generate_app_surface = (options) => {
|
|
|
159
145
|
ws_endpoints: ws_endpoints?.length
|
|
160
146
|
? ws_endpoints.map((ep) => ({
|
|
161
147
|
path: ep.path,
|
|
162
|
-
allowed_origins:
|
|
148
|
+
allowed_origins: ep.allowed_origins.map((re) => re.toString()),
|
|
163
149
|
required_roles: ep.required_roles ?? [],
|
|
164
150
|
// `local_call` specs are frontend-side helpers — registry-only
|
|
165
151
|
// on the backend, never dispatched over WS. Drop them from the
|
package/dist/rate_limiter.d.ts
CHANGED
|
@@ -88,12 +88,30 @@ export declare const default_action_account_rate_limit: RateLimiterOptions;
|
|
|
88
88
|
* A limiter passed explicitly — an instance or `null` — wins over the mode
|
|
89
89
|
* either way, so a rate-limit test enables just the limiter it pins. The
|
|
90
90
|
* disabled mode is loud: `create_app_server` adds a surface warning, which
|
|
91
|
-
* `log_startup_summary` logs at assembly
|
|
91
|
+
* `log_startup_summary` logs at assembly, and the first limiter it leaves
|
|
92
|
+
* `null` prints `RATE_LIMITERS_DISABLED_BANNER` to stderr once per module instance.
|
|
92
93
|
*
|
|
93
94
|
* Twin of the Rust spine's `fuz_auth::RateLimiterMode` (`Enforced` /
|
|
94
95
|
* `DisabledForTesting`).
|
|
95
96
|
*/
|
|
96
97
|
export type RateLimiterMode = 'enforced' | 'disabled_for_testing';
|
|
98
|
+
/**
|
|
99
|
+
* The stderr line a process prints the first time `'disabled_for_testing'`
|
|
100
|
+
* leaves a limiter `null` — the same text as the Rust spine's.
|
|
101
|
+
*/
|
|
102
|
+
export declare const RATE_LIMITERS_DISABLED_BANNER = "!!! RATE LIMITERS DISABLED \u2014 test-only mode. A production server must never print this.";
|
|
103
|
+
/**
|
|
104
|
+
* Print `RATE_LIMITERS_DISABLED_BANNER` with `console.error`, once per module instance.
|
|
105
|
+
*
|
|
106
|
+
* Deliberately on stderr as well as the surface warning, which goes through
|
|
107
|
+
* the server's logger: a deployment that reached this mode is unprotected on
|
|
108
|
+
* every password-bearing route, and that must show in its first lines of
|
|
109
|
+
* output even with the logger silenced. Once per module instance, so a module
|
|
110
|
+
* instance that assembles many in-process servers prints it once, while every spawned test
|
|
111
|
+
* binary prints it at startup — the twin of the Rust spine's
|
|
112
|
+
* `RateLimiterMode::limiter`.
|
|
113
|
+
*/
|
|
114
|
+
export declare const announce_rate_limiters_disabled: () => void;
|
|
97
115
|
/**
|
|
98
116
|
* Result of a rate limit check or record operation.
|
|
99
117
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiter.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/rate_limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAKpC;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,kBAKzC,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,gCAAgC,EAAE,kBAK9C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4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ED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,WAAW;;IACvB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAOzB,OAAO,EAAE,kBAAkB;IAcvC,8BAA8B;IAC9B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAcD;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,eAAe;IA2B7D;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,eAAe;IA0B9D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB;;;;;OAKG;IACH,OAAO,CAAC,GAAG,GAAE,MAAmB,GAAG,IAAI;IAgBvC;;;;OAIG;IACH,OAAO,IAAI,IAAI;CAMf;AAED;;;;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,QAI7E,CAAC"}
|
package/dist/rate_limiter.js
CHANGED
|
@@ -67,6 +67,29 @@ export const default_action_account_rate_limit = {
|
|
|
67
67
|
cleanup_interval_ms: 5 * 60_000,
|
|
68
68
|
max_keys: DEFAULT_RATE_LIMITER_MAX_KEYS
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* The stderr line a process prints the first time `'disabled_for_testing'`
|
|
72
|
+
* leaves a limiter `null` — the same text as the Rust spine's.
|
|
73
|
+
*/
|
|
74
|
+
export const RATE_LIMITERS_DISABLED_BANNER = '!!! RATE LIMITERS DISABLED — test-only mode. A production server must never print this.';
|
|
75
|
+
let rate_limiters_disabled_announced = false;
|
|
76
|
+
/**
|
|
77
|
+
* Print `RATE_LIMITERS_DISABLED_BANNER` with `console.error`, once per module instance.
|
|
78
|
+
*
|
|
79
|
+
* Deliberately on stderr as well as the surface warning, which goes through
|
|
80
|
+
* the server's logger: a deployment that reached this mode is unprotected on
|
|
81
|
+
* every password-bearing route, and that must show in its first lines of
|
|
82
|
+
* output even with the logger silenced. Once per module instance, so a module
|
|
83
|
+
* instance that assembles many in-process servers prints it once, while every spawned test
|
|
84
|
+
* binary prints it at startup — the twin of the Rust spine's
|
|
85
|
+
* `RateLimiterMode::limiter`.
|
|
86
|
+
*/
|
|
87
|
+
export const announce_rate_limiters_disabled = () => {
|
|
88
|
+
if (rate_limiters_disabled_announced)
|
|
89
|
+
return;
|
|
90
|
+
rate_limiters_disabled_announced = true;
|
|
91
|
+
console.error(RATE_LIMITERS_DISABLED_BANNER);
|
|
92
|
+
};
|
|
70
93
|
/**
|
|
71
94
|
* In-memory sliding window rate limiter.
|
|
72
95
|
*
|
|
@@ -164,7 +164,9 @@ export declare const create_audit_log_sse: (options: {
|
|
|
164
164
|
* Required so it can't be forgotten: without it a revoked credential's
|
|
165
165
|
* streams close only through the audit listener, which a failed audit write
|
|
166
166
|
* or a cap eviction never reaches. Pass `null` only for a registry no
|
|
167
|
-
* revocation has to reach (tests of the registry itself)
|
|
167
|
+
* revocation has to reach (tests of the registry itself), or when the
|
|
168
|
+
* caller adds `create_sse_connection_closer(registry)` itself — as
|
|
169
|
+
* `create_app_server` does, to hold the remover `add` returns.
|
|
168
170
|
*/
|
|
169
171
|
connection_closer: RealtimeCloser | null;
|
|
170
172
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse_auth_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse_auth_guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAIN,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO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ACH,eAAO,MAAM,oBAAoB,GAAI,SAAS;IAC7C,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;;OASG;IACH,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,KAAG,WAgBH,CAAC"}
|
|
@@ -100,7 +100,8 @@ export interface AppServerOptions {
|
|
|
100
100
|
* a default instance for each `*_rate_limiter` option left out,
|
|
101
101
|
* `'disabled_for_testing'` leaves each of them `null`. An explicit option
|
|
102
102
|
* (an instance or `null`) always wins over the mode. The disabled mode adds
|
|
103
|
-
* one surface warning
|
|
103
|
+
* one surface warning, and prints a stderr banner once per module instance
|
|
104
|
+
* (`announce_rate_limiters_disabled`). Never `'disabled_for_testing'` in production — see
|
|
104
105
|
* `RateLimiterMode`.
|
|
105
106
|
*/
|
|
106
107
|
rate_limiters?: RateLimiterMode;
|
|
@@ -197,9 +198,18 @@ export interface AppServerOptions {
|
|
|
197
198
|
/**
|
|
198
199
|
* Optional: transform middleware specs before applying.
|
|
199
200
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
201
|
+
* Receives shallow copies of the trusted-proxy spec followed by the auth
|
|
202
|
+
* stack, in a fresh array — mutating them leaves the originals untouched.
|
|
203
|
+
* Add layers anywhere (before the proxy spec, between it and the auth
|
|
204
|
+
* stack, between the auth layers, or after), but keep each of those specs
|
|
205
|
+
* — its `handler`, not just its `name` — mounted once at its original path
|
|
206
|
+
* (`'*'` for the proxy, `AUTH_MIDDLEWARE_PATH` for auth) in its original
|
|
207
|
+
* order: the endpoint auth-scope check (`assert_endpoint_in_auth_scope`)
|
|
208
|
+
* and client-IP rate limiting (`get_client_ip`) assume it, so assembly
|
|
209
|
+
* throws (`assert_middleware_stack_mounted`) if the transform moves, drops,
|
|
210
|
+
* duplicates, reorders, wraps, or replaces one. The check pins where those
|
|
211
|
+
* layers sit, not what added layers do — a layer you add runs with full
|
|
212
|
+
* context access.
|
|
203
213
|
*/
|
|
204
214
|
transform_middleware?: (specs: Array<MiddlewareSpec>) => Array<MiddlewareSpec>;
|
|
205
215
|
/**
|
|
@@ -320,13 +330,14 @@ export interface AppServerOptions {
|
|
|
320
330
|
* after the route specs and before `post_route_middleware` and
|
|
321
331
|
* `static_serving`, so neither runs ahead of an upgrade.
|
|
322
332
|
*
|
|
323
|
-
* Duplicate `path` values across two `WsEndpointSpec`s
|
|
324
|
-
*
|
|
333
|
+
* Duplicate `path` values across two `WsEndpointSpec`s, and a `path` a
|
|
334
|
+
* GET `RouteSpec` already claims, throw at assembly before any endpoint
|
|
335
|
+
* mounts (Hono would silently shadow them otherwise).
|
|
325
336
|
*
|
|
326
337
|
* Every mounted transport is added to `deps.connection_closer`, so
|
|
327
338
|
* the revocation handlers' post-commit closes reach its sockets —
|
|
328
339
|
* unconditionally, since those closes are what ends a revoked
|
|
329
|
-
* credential's connections.
|
|
340
|
+
* credential's connections. `AppServer.close` removes it again.
|
|
330
341
|
*
|
|
331
342
|
* Each spec's `auth_guard?` defaults to `true` — the factory
|
|
332
343
|
* registers `create_ws_auth_guard` against the mounted transport via
|
|
@@ -414,8 +425,17 @@ export interface AppServer {
|
|
|
414
425
|
* `WsEndpointSpec.transport` or added by hand, since they are registered
|
|
415
426
|
* on the backend's closer and the backend is going away; a close that
|
|
416
427
|
* throws is logged and the shutdown goes on
|
|
417
|
-
* 3.
|
|
418
|
-
*
|
|
428
|
+
* 3. release what assembly acquired, last acquired first: remove the
|
|
429
|
+
* audit listeners `create_app_server` registered on `deps.audit` (the
|
|
430
|
+
* audit-log SSE listener, the WS auth guards, each
|
|
431
|
+
* `extra_audit_handlers` entry) and the closer members it added to
|
|
432
|
+
* `deps.connection_closer` (each mounted transport, the audit stream
|
|
433
|
+
* registry), and `dispose` the rate limiters it built for omitted
|
|
434
|
+
* options — never one passed in, which its caller owns. A release that
|
|
435
|
+
* throws is logged and the rest still run. The backend's emitter and
|
|
436
|
+
* closer are left as they were before assembly, so a failed assembly
|
|
437
|
+
* can be retried on the same backend, and a backend whose `close` you
|
|
438
|
+
* own (a test harness) can host another server
|
|
419
439
|
* 4. close the database connection (`AppBackend.close`)
|
|
420
440
|
*
|
|
421
441
|
* Idempotent: a second call settles with the first one's outcome (a failed
|
|
@@ -469,14 +489,22 @@ export declare const DEFAULT_MAX_BODY_SIZE: number;
|
|
|
469
489
|
* case; consumers can call `require_audit_sse(ctx)` / `require_audit_sse(server)`
|
|
470
490
|
* to assert the invariant.
|
|
471
491
|
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
492
|
+
* Assembly acquires a few things that outlive it — the rate limiters it
|
|
493
|
+
* builds, the listeners it registers on `deps.audit`, the members it adds to
|
|
494
|
+
* `deps.connection_closer` — and records a release for each as it goes. When
|
|
495
|
+
* assembly throws, every release recorded so far runs, last acquired first
|
|
496
|
+
* (one that throws is logged and the rest still run), and the original error
|
|
497
|
+
* is rethrown: a failed assembly leaves the backend's emitter and closer as
|
|
498
|
+
* it found them and no limiter timer running. When `auth_cleanup` is set, the
|
|
499
|
+
* auth cleanup schedule starts as the last step of assembly — nothing after
|
|
500
|
+
* it can throw, so an assembly that throws leaves no schedule running.
|
|
474
501
|
*
|
|
475
502
|
* The returned `close` owns shutdown: it stops that schedule, closes every
|
|
476
|
-
* live connection on the backend's closer,
|
|
477
|
-
*
|
|
503
|
+
* live connection on the backend's closer, runs the same releases, and
|
|
504
|
+
* closes the database (`AppServer.close`).
|
|
478
505
|
*
|
|
479
506
|
* @returns assembled Hono app, backend, surface build, and bootstrap status
|
|
507
|
+
* @throws Error from any assembly step, after releasing what assembly acquired
|
|
480
508
|
*/
|
|
481
509
|
export declare const create_app_server: (options: AppServerOptions) => Promise<AppServer>;
|
|
482
510
|
//# sourceMappingURL=app_server.d.ts.map
|
|
@@ -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,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
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;AAG1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAEN,KAAK,cAAc,EAEnB,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,+BAA+B,CAAC;AAEvC,OAAO,EACN,WAAW,EAMX,KAAK,eAAe,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,EAEN,KAAK,cAAc,EAEnB,KAAK,eAAe,EACpB,MAAM,oBAAoB,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