@fuzdev/fuz_app 0.52.0 → 0.54.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 +29 -9
- package/dist/actions/action_codegen.d.ts +10 -35
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +13 -42
- package/dist/actions/action_peer.d.ts.map +1 -1
- package/dist/actions/action_peer.js +0 -9
- package/dist/actions/action_registry.d.ts +0 -4
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +4 -10
- package/dist/actions/action_rpc.d.ts +16 -0
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +41 -20
- package/dist/actions/action_spec.d.ts +54 -5
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +21 -5
- package/dist/actions/frontend_rpc_client.d.ts +1 -9
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/frontend_rpc_client.js +1 -9
- package/dist/actions/register_action_ws.d.ts +16 -0
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +41 -1
- package/dist/actions/request_tracker.svelte.d.ts +10 -15
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -1
- package/dist/actions/request_tracker.svelte.js +10 -15
- package/dist/actions/rpc_client.d.ts +0 -1
- package/dist/actions/rpc_client.d.ts.map +1 -1
- package/dist/actions/rpc_client.js +3 -17
- package/dist/actions/socket.svelte.d.ts +0 -1
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +0 -1
- package/dist/actions/transports.d.ts +4 -3
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +4 -13
- package/dist/actions/transports_ws_auth_guard.d.ts +0 -2
- package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -2
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +0 -9
- package/dist/auth/CLAUDE.md +43 -19
- package/dist/auth/account_queries.d.ts +0 -3
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +0 -3
- package/dist/auth/admin_action_specs.d.ts +5 -0
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +5 -0
- package/dist/auth/api_token_queries.d.ts +0 -1
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +0 -1
- package/dist/auth/audit_log_queries.d.ts +0 -1
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +0 -1
- package/dist/auth/audit_log_routes.d.ts +2 -2
- package/dist/auth/audit_log_routes.js +2 -2
- package/dist/auth/invite_queries.d.ts +0 -1
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +0 -1
- package/dist/auth/permit_offer_action_specs.d.ts +1 -0
- package/dist/auth/permit_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/permit_offer_action_specs.js +1 -0
- package/dist/auth/permit_offer_actions.d.ts.map +1 -1
- package/dist/auth/permit_offer_actions.js +9 -6
- package/dist/auth/permit_offer_queries.d.ts +0 -1
- package/dist/auth/permit_offer_queries.d.ts.map +1 -1
- package/dist/auth/permit_offer_queries.js +0 -1
- package/dist/auth/permit_queries.d.ts +0 -1
- package/dist/auth/permit_queries.d.ts.map +1 -1
- package/dist/auth/permit_queries.js +0 -1
- package/dist/auth/request_context.d.ts +47 -2
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +57 -2
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +14 -11
- package/dist/auth/session_lifecycle.d.ts +0 -1
- package/dist/auth/session_lifecycle.d.ts.map +1 -1
- package/dist/auth/session_lifecycle.js +0 -1
- package/dist/auth/session_middleware.d.ts +0 -4
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +0 -4
- package/dist/cli/config.d.ts +0 -3
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +0 -3
- package/dist/cli/daemon.d.ts +1 -1
- package/dist/cli/daemon.js +1 -1
- package/dist/db/create_db.d.ts +0 -1
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +0 -1
- package/dist/db/db.d.ts +0 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +0 -4
- package/dist/db/db_pg.d.ts +2 -2
- package/dist/db/db_pg.js +2 -2
- package/dist/db/db_pglite.d.ts +1 -2
- package/dist/db/db_pglite.d.ts.map +1 -1
- package/dist/db/db_pglite.js +1 -2
- package/dist/db/migrate.d.ts +0 -1
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +0 -1
- package/dist/dev/setup.d.ts +0 -3
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +0 -3
- package/dist/env/load.d.ts +0 -2
- package/dist/env/load.d.ts.map +1 -1
- package/dist/env/load.js +0 -2
- package/dist/hono_context.d.ts +2 -5
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +2 -5
- package/dist/http/common_routes.d.ts +0 -8
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +0 -8
- package/dist/http/db_routes.d.ts +0 -3
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +0 -3
- package/dist/http/error_schemas.d.ts +12 -11
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +11 -7
- package/dist/http/jsonrpc_errors.d.ts +0 -6
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +0 -6
- package/dist/http/origin.d.ts +6 -13
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +7 -14
- package/dist/http/proxy.d.ts +1 -7
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +1 -7
- package/dist/http/route_spec.d.ts +13 -35
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +10 -22
- package/dist/http/schema_helpers.d.ts +0 -4
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +0 -4
- package/dist/http/surface.d.ts +2 -12
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +1 -12
- package/dist/rate_limiter.d.ts +16 -0
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +26 -0
- package/dist/realtime/sse.d.ts +0 -1
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +0 -1
- package/dist/realtime/subscriber_registry.d.ts +0 -3
- package/dist/realtime/subscriber_registry.d.ts.map +1 -1
- package/dist/realtime/subscriber_registry.js +0 -3
- package/dist/runtime/fs.d.ts +1 -4
- package/dist/runtime/fs.d.ts.map +1 -1
- package/dist/runtime/fs.js +1 -4
- package/dist/runtime/mock.d.ts +0 -3
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +0 -3
- package/dist/server/app_server.d.ts +27 -5
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +19 -7
- package/dist/server/startup.d.ts +0 -2
- package/dist/server/startup.d.ts.map +1 -1
- package/dist/server/startup.js +0 -2
- package/dist/server/static.d.ts +0 -1
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +0 -1
- package/dist/server/validate_nginx.d.ts +0 -3
- package/dist/server/validate_nginx.d.ts.map +1 -1
- package/dist/server/validate_nginx.js +0 -3
- package/dist/testing/CLAUDE.md +1 -1
- package/dist/testing/admin_integration.d.ts +0 -1
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +3 -6
- package/dist/testing/adversarial_404.d.ts +0 -2
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +0 -2
- package/dist/testing/adversarial_headers.d.ts +0 -1
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +0 -1
- package/dist/testing/adversarial_input.d.ts +0 -2
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +0 -2
- package/dist/testing/app_server.d.ts +22 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +2 -4
- package/dist/testing/assertions.d.ts +0 -4
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +0 -4
- package/dist/testing/attack_surface.d.ts +0 -4
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +0 -4
- package/dist/testing/audit_completeness.d.ts +0 -1
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +0 -1
- package/dist/testing/auth_apps.d.ts +2 -10
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -10
- package/dist/testing/data_exposure.d.ts +0 -11
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +0 -11
- package/dist/testing/db.d.ts +0 -6
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +0 -6
- package/dist/testing/error_coverage.d.ts +0 -14
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +0 -14
- package/dist/testing/integration.d.ts +0 -1
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +0 -1
- package/dist/testing/integration_helpers.d.ts +1 -36
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +1 -43
- package/dist/testing/middleware.d.ts +0 -10
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +0 -10
- package/dist/testing/mock_fs.d.ts +0 -2
- package/dist/testing/mock_fs.d.ts.map +1 -1
- package/dist/testing/mock_fs.js +0 -2
- package/dist/testing/rate_limiting.d.ts +0 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +0 -1
- package/dist/testing/round_trip.d.ts +0 -2
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +0 -2
- package/dist/testing/rpc_attack_surface.d.ts +0 -2
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +0 -2
- package/dist/testing/rpc_helpers.d.ts +0 -6
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +0 -6
- package/dist/testing/rpc_round_trip.d.ts +0 -2
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +0 -2
- package/dist/testing/schema_generators.d.ts +0 -3
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +29 -3
- package/dist/testing/sse_round_trip.d.ts +0 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +0 -1
- package/dist/testing/standard.d.ts +0 -2
- package/dist/testing/standard.d.ts.map +1 -1
- package/dist/testing/standard.js +0 -2
- package/dist/testing/stubs.d.ts +3 -5
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +5 -5
- package/dist/testing/surface_invariants.d.ts +0 -3
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +0 -3
- package/dist/ui/CLAUDE.md +1 -1
- package/dist/ui/audit_log_state.svelte.js +1 -1
- package/dist/ui/position_helpers.d.ts +0 -3
- package/dist/ui/position_helpers.d.ts.map +1 -1
- package/dist/ui/position_helpers.js +0 -3
- package/dist/ui/sidebar_state.svelte.d.ts +1 -2
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -1
- package/dist/ui/sidebar_state.svelte.js +1 -2
- package/dist/ui/ui_fetch.d.ts +1 -7
- package/dist/ui/ui_fetch.d.ts.map +1 -1
- package/dist/ui/ui_fetch.js +1 -7
- package/dist/ui/ui_format.d.ts +2 -14
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +2 -14
- package/package.json +2 -2
package/dist/env/load.js
CHANGED
|
@@ -59,8 +59,6 @@ export const log_env_validation_error = (error, label) => {
|
|
|
59
59
|
/**
|
|
60
60
|
* Load and validate env vars against a Zod schema.
|
|
61
61
|
*
|
|
62
|
-
* Reads each key from the schema using `get_env`, then validates.
|
|
63
|
-
*
|
|
64
62
|
* @param schema - Zod object schema defining expected env vars
|
|
65
63
|
* @param get_env - function to read an env var by key
|
|
66
64
|
* @returns validated env object
|
package/dist/hono_context.d.ts
CHANGED
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
* Cross-cutting shared vocabulary — defines the Hono `ContextVariableMap`
|
|
5
5
|
* variables used by auth, http, server, and testing modules.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* In practice, this is auto-loaded by `server/app_server.ts` (side-effect import)
|
|
11
|
-
* and transitively by auth middleware modules that import `CREDENTIAL_TYPE_KEY`.
|
|
7
|
+
* Auto-loaded by `server/app_server.ts` (side-effect import) and
|
|
8
|
+
* transitively by auth middleware modules that import `CREDENTIAL_TYPE_KEY`.
|
|
12
9
|
* Consumers don't need a manual import unless bypassing the standard server assembly.
|
|
13
10
|
*
|
|
14
11
|
* @module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAE9D,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,mDAAoD,CAAC;AAElF,yDAAyD;AACzD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,OAAO,QAAQ,MAAM,CAAC;IACrB,UAAU,kBAAkB;QAC3B,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB,2FAA2F;QAC3F,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;QACvC;;;;;WAKG;QACH,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;QACvC;;;;;;WAMG;QACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC;;;;WAIG;QACH,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;KACtC;CACD"}
|
package/dist/hono_context.js
CHANGED
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
* Cross-cutting shared vocabulary — defines the Hono `ContextVariableMap`
|
|
5
5
|
* variables used by auth, http, server, and testing modules.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* In practice, this is auto-loaded by `server/app_server.ts` (side-effect import)
|
|
11
|
-
* and transitively by auth middleware modules that import `CREDENTIAL_TYPE_KEY`.
|
|
7
|
+
* Auto-loaded by `server/app_server.ts` (side-effect import) and
|
|
8
|
+
* transitively by auth middleware modules that import `CREDENTIAL_TYPE_KEY`.
|
|
12
9
|
* Consumers don't need a manual import unless bypassing the standard server assembly.
|
|
13
10
|
*
|
|
14
11
|
* @module
|
|
@@ -13,8 +13,6 @@ import type { AppSurface } from './surface.js';
|
|
|
13
13
|
*
|
|
14
14
|
* Infrastructure endpoint for uptime monitors and load balancers.
|
|
15
15
|
* Bootstrap availability is exposed via `/api/account/status` instead.
|
|
16
|
-
*
|
|
17
|
-
* @returns a single health check route spec
|
|
18
16
|
*/
|
|
19
17
|
export declare const create_health_route_spec: () => RouteSpec;
|
|
20
18
|
/** Options for the authenticated server status route. */
|
|
@@ -29,9 +27,6 @@ export interface ServerStatusOptions {
|
|
|
29
27
|
*
|
|
30
28
|
* Returns version and uptime. Unlike the public health check,
|
|
31
29
|
* this requires authentication.
|
|
32
|
-
*
|
|
33
|
-
* @param options - version and uptime source
|
|
34
|
-
* @returns route spec for `GET /api/server/status`
|
|
35
30
|
*/
|
|
36
31
|
export declare const create_server_status_route_spec: (options: ServerStatusOptions) => RouteSpec;
|
|
37
32
|
/** Options for the surface explorer route. */
|
|
@@ -44,9 +39,6 @@ export interface SurfaceRouteOptions {
|
|
|
44
39
|
*
|
|
45
40
|
* Surface data reveals API structure (routes, auth, schemas), so this
|
|
46
41
|
* requires authentication like the server status route.
|
|
47
|
-
*
|
|
48
|
-
* @param options - surface data source
|
|
49
|
-
* @returns route spec for `GET /api/surface`
|
|
50
42
|
*/
|
|
51
43
|
export declare const create_surface_route_spec: (options: SurfaceRouteOptions) => RouteSpec;
|
|
52
44
|
//# sourceMappingURL=common_routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/common_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"common_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/common_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAO,SAQ1C,CAAC;AAEH,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IACnC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,aAAa,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,mBAAmB,KAAG,SAQ7E,CAAC;AAEH,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IACnC,0CAA0C;IAC1C,OAAO,EAAE,UAAU,CAAC;CACpB;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,mBAAmB,KAAG,SAWvE,CAAC"}
|
|
@@ -12,8 +12,6 @@ import { z } from 'zod';
|
|
|
12
12
|
*
|
|
13
13
|
* Infrastructure endpoint for uptime monitors and load balancers.
|
|
14
14
|
* Bootstrap availability is exposed via `/api/account/status` instead.
|
|
15
|
-
*
|
|
16
|
-
* @returns a single health check route spec
|
|
17
15
|
*/
|
|
18
16
|
export const create_health_route_spec = () => ({
|
|
19
17
|
method: 'GET',
|
|
@@ -29,9 +27,6 @@ export const create_health_route_spec = () => ({
|
|
|
29
27
|
*
|
|
30
28
|
* Returns version and uptime. Unlike the public health check,
|
|
31
29
|
* this requires authentication.
|
|
32
|
-
*
|
|
33
|
-
* @param options - version and uptime source
|
|
34
|
-
* @returns route spec for `GET /api/server/status`
|
|
35
30
|
*/
|
|
36
31
|
export const create_server_status_route_spec = (options) => ({
|
|
37
32
|
method: 'GET',
|
|
@@ -47,9 +42,6 @@ export const create_server_status_route_spec = (options) => ({
|
|
|
47
42
|
*
|
|
48
43
|
* Surface data reveals API structure (routes, auth, schemas), so this
|
|
49
44
|
* requires authentication like the server status route.
|
|
50
|
-
*
|
|
51
|
-
* @param options - surface data source
|
|
52
|
-
* @returns route spec for `GET /api/surface`
|
|
53
45
|
*/
|
|
54
46
|
export const create_surface_route_spec = (options) => ({
|
|
55
47
|
method: 'GET',
|
package/dist/http/db_routes.d.ts
CHANGED
|
@@ -49,9 +49,6 @@ export interface DbRouteOptions {
|
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Create the db API route specs.
|
|
52
|
-
*
|
|
53
|
-
* @param options - route configuration (db_type, db_name, extra_stats)
|
|
54
|
-
* @returns route specs for database administration
|
|
55
52
|
*/
|
|
56
53
|
export declare const create_db_route_specs: (options: DbRouteOptions) => Array<RouteSpec>;
|
|
57
54
|
//# sourceMappingURL=db_routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAmB,KAAK,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAYjE;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;I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+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,cAAc,KAAG,KAAK,CAAC,SAAS,CA8N9E,CAAC"}
|
package/dist/http/db_routes.js
CHANGED
|
@@ -12,9 +12,6 @@ import { ForeignKeyError, ERROR_TABLE_NOT_FOUND, ERROR_TABLE_NO_PRIMARY_KEY, ERR
|
|
|
12
12
|
import { assert_valid_sql_identifier, VALID_SQL_IDENTIFIER } from '../db/sql_identifier.js';
|
|
13
13
|
/**
|
|
14
14
|
* Create the db API route specs.
|
|
15
|
-
*
|
|
16
|
-
* @param options - route configuration (db_type, db_name, extra_stats)
|
|
17
|
-
* @returns route specs for database administration
|
|
18
15
|
*/
|
|
19
16
|
export const create_db_route_specs = (options) => {
|
|
20
17
|
const { db_type, db_name, extra_stats, log } = options;
|
|
@@ -139,13 +139,21 @@ export type ForeignKeyError = z.infer<typeof ForeignKeyError>;
|
|
|
139
139
|
*/
|
|
140
140
|
export type RouteErrorSchemas = Partial<Record<number, z.ZodType>>;
|
|
141
141
|
/**
|
|
142
|
-
* Rate limit key type — declares what a route's rate limiter
|
|
142
|
+
* Rate limit key type — declares what a route or RPC action's rate limiter
|
|
143
|
+
* is keyed on.
|
|
143
144
|
*
|
|
144
145
|
* - `'ip'` — per-IP rate limiting (bootstrap, password change, bearer auth)
|
|
145
|
-
* - `'account'` — per-account rate limiting
|
|
146
|
-
*
|
|
146
|
+
* - `'account'` — per-account rate limiting. On REST auth routes the key is
|
|
147
|
+
* the submitted identifier (login). On RPC actions (post-auth) the key is
|
|
148
|
+
* the resolved actor id (`request_context.actor.id`) — separate namespace.
|
|
149
|
+
* - `'both'` — both keys.
|
|
147
150
|
*/
|
|
148
|
-
export
|
|
151
|
+
export declare const RateLimitKey: z.ZodEnum<{
|
|
152
|
+
account: "account";
|
|
153
|
+
ip: "ip";
|
|
154
|
+
both: "both";
|
|
155
|
+
}>;
|
|
156
|
+
export type RateLimitKey = z.infer<typeof RateLimitKey>;
|
|
149
157
|
/**
|
|
150
158
|
* Derive error schemas from a route's auth requirement, input schema, and rate limit config.
|
|
151
159
|
*
|
|
@@ -159,13 +167,6 @@ export type RateLimitKey = 'ip' | 'account' | 'both';
|
|
|
159
167
|
* - **auth: role**: 401 + 403 (with `required_role`)
|
|
160
168
|
* - **auth: keeper**: 401 + 403 (keeper-specific)
|
|
161
169
|
* - **rate_limit**: 429 (rate limit exceeded with `retry_after`)
|
|
162
|
-
*
|
|
163
|
-
* @param auth - the route's auth requirement
|
|
164
|
-
* @param has_input - whether the route has a non-null input schema
|
|
165
|
-
* @param has_params - whether the route has a params schema
|
|
166
|
-
* @param has_query - whether the route has a query schema
|
|
167
|
-
* @param rate_limit - the rate limit key type, if any
|
|
168
|
-
* @returns error schemas keyed by HTTP status code
|
|
169
170
|
*/
|
|
170
171
|
export declare const derive_error_schemas: (auth: RouteAuth, has_input: boolean, has_params?: boolean, has_query?: boolean, rate_limit?: RateLimitKey) => RouteErrorSchemas;
|
|
171
172
|
//# sourceMappingURL=error_schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/error_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI/C,0CAA0C;AAC1C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAI1E,wCAAwC;AACxC,eAAO,MAAM,6BAA6B,EAA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C,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,uFAAuF;AACvF,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,qFAAqF;AACrF,eAAO,MAAM,eAAe;;iBAE1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;;;EAAoC,CAAC;AAC9D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,WAAW,OAAO,EAClB,oBAAkB,EAClB,mBAAiB,EACjB,aAAa,YAAY,KACvB,iBA4BF,CAAC"}
|
|
@@ -132,6 +132,17 @@ export const PayloadTooLargeError = z.looseObject({
|
|
|
132
132
|
export const ForeignKeyError = z.looseObject({
|
|
133
133
|
error: z.literal(ERROR_FOREIGN_KEY_VIOLATION),
|
|
134
134
|
});
|
|
135
|
+
/**
|
|
136
|
+
* Rate limit key type — declares what a route or RPC action's rate limiter
|
|
137
|
+
* is keyed on.
|
|
138
|
+
*
|
|
139
|
+
* - `'ip'` — per-IP rate limiting (bootstrap, password change, bearer auth)
|
|
140
|
+
* - `'account'` — per-account rate limiting. On REST auth routes the key is
|
|
141
|
+
* the submitted identifier (login). On RPC actions (post-auth) the key is
|
|
142
|
+
* the resolved actor id (`request_context.actor.id`) — separate namespace.
|
|
143
|
+
* - `'both'` — both keys.
|
|
144
|
+
*/
|
|
145
|
+
export const RateLimitKey = z.enum(['ip', 'account', 'both']);
|
|
135
146
|
/**
|
|
136
147
|
* Derive error schemas from a route's auth requirement, input schema, and rate limit config.
|
|
137
148
|
*
|
|
@@ -145,13 +156,6 @@ export const ForeignKeyError = z.looseObject({
|
|
|
145
156
|
* - **auth: role**: 401 + 403 (with `required_role`)
|
|
146
157
|
* - **auth: keeper**: 401 + 403 (keeper-specific)
|
|
147
158
|
* - **rate_limit**: 429 (rate limit exceeded with `retry_after`)
|
|
148
|
-
*
|
|
149
|
-
* @param auth - the route's auth requirement
|
|
150
|
-
* @param has_input - whether the route has a non-null input schema
|
|
151
|
-
* @param has_params - whether the route has a params schema
|
|
152
|
-
* @param has_query - whether the route has a query schema
|
|
153
|
-
* @param rate_limit - the rate limit key type, if any
|
|
154
|
-
* @returns error schemas keyed by HTTP status code
|
|
155
159
|
*/
|
|
156
160
|
export const derive_error_schemas = (auth, has_input, has_params = false, has_query = false, rate_limit) => {
|
|
157
161
|
const errors = {};
|
|
@@ -98,18 +98,12 @@ export declare const HTTP_STATUS_TO_JSONRPC_ERROR_CODE: Record<number, JsonrpcEr
|
|
|
98
98
|
*
|
|
99
99
|
* Returns 500 for unrecognized codes (consumer-defined codes
|
|
100
100
|
* without a mapping default to internal server error).
|
|
101
|
-
*
|
|
102
|
-
* @param code - the JSON-RPC error code
|
|
103
|
-
* @returns the corresponding HTTP status code
|
|
104
101
|
*/
|
|
105
102
|
export declare const jsonrpc_error_code_to_http_status: (code: JsonrpcErrorCode) => number;
|
|
106
103
|
/**
|
|
107
104
|
* Map an HTTP status code to a JSON-RPC error code.
|
|
108
105
|
*
|
|
109
106
|
* Returns `internal_error` (-32603) for unrecognized status codes.
|
|
110
|
-
*
|
|
111
|
-
* @param status - the HTTP status code
|
|
112
|
-
* @returns the corresponding JSON-RPC error code
|
|
113
107
|
*/
|
|
114
108
|
export declare const http_status_to_jsonrpc_error_code: (status: number) => JsonrpcErrorCode;
|
|
115
109
|
//# sourceMappingURL=jsonrpc_errors.d.ts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EAAE,gBAAgB,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAEH,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY;CAK3F;AAWD;;;;GAIG;AACH,eAAO,MAAM,cAAc;8CAXQ,kBAAkB;kDAAlB,kBAAkB;mDAAlB,kBAAkB;iDAAlB,kBAAkB;iDAAlB,kBAAkB;kDAAlB,kBAAkB;4CAAlB,kBAAkB;4CAAlB,kBAAkB;2CAAlB,kBAAkB;mDAAlB,kBAAkB;+CAAlB,kBAAkB;sDAAlB,kBAAkB;0CAAlB,kBAAkB;iDAAlB,kBAAkB;oDAAlB,kBAAkB;CA2BqC,CAAC;AAI3F;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkBpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAMzC,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,GAAI,MAAM,gBAAgB,KAAG,MAClB,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAAI,QAAQ,MAAM,KAAG,gBACa,CAAC"}
|
|
@@ -243,17 +243,11 @@ export const HTTP_STATUS_TO_JSONRPC_ERROR_CODE = Object.fromEntries(Object.entri
|
|
|
243
243
|
*
|
|
244
244
|
* Returns 500 for unrecognized codes (consumer-defined codes
|
|
245
245
|
* without a mapping default to internal server error).
|
|
246
|
-
*
|
|
247
|
-
* @param code - the JSON-RPC error code
|
|
248
|
-
* @returns the corresponding HTTP status code
|
|
249
246
|
*/
|
|
250
247
|
export const jsonrpc_error_code_to_http_status = (code) => JSONRPC_ERROR_CODE_TO_HTTP_STATUS[code] ?? 500;
|
|
251
248
|
/**
|
|
252
249
|
* Map an HTTP status code to a JSON-RPC error code.
|
|
253
250
|
*
|
|
254
251
|
* Returns `internal_error` (-32603) for unrecognized status codes.
|
|
255
|
-
*
|
|
256
|
-
* @param status - the HTTP status code
|
|
257
|
-
* @returns the corresponding JSON-RPC error code
|
|
258
252
|
*/
|
|
259
253
|
export const http_status_to_jsonrpc_error_code = (status) => HTTP_STATUS_TO_JSONRPC_ERROR_CODE[status] ?? JSONRPC_ERROR_CODES.internal_error;
|
package/dist/http/origin.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { Handler } from 'hono';
|
|
|
28
28
|
* - `https://*.api.fuz.dev,http://127.0.0.1:*`
|
|
29
29
|
* - `http://[::1]:*,https://*.*.corp.fuz.dev:*`
|
|
30
30
|
*
|
|
31
|
-
* @throws if any individual pattern is invalid (missing protocol, partial wildcards, etc.)
|
|
31
|
+
* @throws Error if any individual pattern is invalid (missing protocol, partial wildcards, etc.)
|
|
32
32
|
*/
|
|
33
33
|
export declare const parse_allowed_origins: (env_value: string | undefined) => Array<RegExp>;
|
|
34
34
|
/**
|
|
@@ -39,19 +39,12 @@ export declare const should_allow_origin: (origin: string, allowed_patterns: Arr
|
|
|
39
39
|
/**
|
|
40
40
|
* Middleware that verifies the request source against an allowlist.
|
|
41
41
|
*
|
|
42
|
-
* Origin allowlisting (not the CSRF layer — that's `SameSite: strict` cookies)
|
|
43
|
-
* - Checks the Origin header first (if present)
|
|
44
|
-
* - Falls back to Referer header (if no Origin)
|
|
45
|
-
* - Allows requests without Origin
|
|
42
|
+
* Origin allowlisting (not the CSRF layer — that's `SameSite: strict` cookies):
|
|
43
|
+
* - Checks the `Origin` header first (if present)
|
|
44
|
+
* - Falls back to `Referer` header (if no `Origin`)
|
|
45
|
+
* - Allows requests without `Origin`/`Referer` headers (direct access, curl, etc.)
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
* - Protecting locally-running services from being called by
|
|
49
|
-
* untrusted websites as the user browses the web
|
|
50
|
-
* - Restricting which domains can make requests to your API
|
|
51
|
-
* - Preventing embedding of your service in unexpected sites
|
|
52
|
-
* - Basic source verification for locally-running services
|
|
53
|
-
*
|
|
54
|
-
* @param allowed_patterns - array of compiled regex patterns from parse_allowed_origins
|
|
47
|
+
* @param allowed_patterns - compiled regex patterns from `parse_allowed_origins`
|
|
55
48
|
*/
|
|
56
49
|
export declare const verify_request_source: (allowed_patterns: Array<RegExp>) => Handler;
|
|
57
50
|
//# sourceMappingURL=origin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/origin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAIlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,GAAG,SAAS,KAAG,KAAK,CAAC,MAAM,CAO5E,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,kBAAkB,KAAK,CAAC,MAAM,CAAC,KAAG,OACzC,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"origin.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/origin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAIlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,GAAG,SAAS,KAAG,KAAK,CAAC,MAAM,CAO5E,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,kBAAkB,KAAK,CAAC,MAAM,CAAC,KAAG,OACzC,CAAC;AAE9C;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,kBAAkB,KAAK,CAAC,MAAM,CAAC,KAAG,OA2BlC,CAAC"}
|
package/dist/http/origin.js
CHANGED
|
@@ -29,7 +29,7 @@ import { ERROR_FORBIDDEN_ORIGIN, ERROR_FORBIDDEN_REFERER } from './error_schemas
|
|
|
29
29
|
* - `https://*.api.fuz.dev,http://127.0.0.1:*`
|
|
30
30
|
* - `http://[::1]:*,https://*.*.corp.fuz.dev:*`
|
|
31
31
|
*
|
|
32
|
-
* @throws if any individual pattern is invalid (missing protocol, partial wildcards, etc.)
|
|
32
|
+
* @throws Error if any individual pattern is invalid (missing protocol, partial wildcards, etc.)
|
|
33
33
|
*/
|
|
34
34
|
export const parse_allowed_origins = (env_value) => env_value
|
|
35
35
|
? env_value
|
|
@@ -46,19 +46,12 @@ export const should_allow_origin = (origin, allowed_patterns) => allowed_pattern
|
|
|
46
46
|
/**
|
|
47
47
|
* Middleware that verifies the request source against an allowlist.
|
|
48
48
|
*
|
|
49
|
-
* Origin allowlisting (not the CSRF layer — that's `SameSite: strict` cookies)
|
|
50
|
-
* - Checks the Origin header first (if present)
|
|
51
|
-
* - Falls back to Referer header (if no Origin)
|
|
52
|
-
* - Allows requests without Origin
|
|
49
|
+
* Origin allowlisting (not the CSRF layer — that's `SameSite: strict` cookies):
|
|
50
|
+
* - Checks the `Origin` header first (if present)
|
|
51
|
+
* - Falls back to `Referer` header (if no `Origin`)
|
|
52
|
+
* - Allows requests without `Origin`/`Referer` headers (direct access, curl, etc.)
|
|
53
53
|
*
|
|
54
|
-
*
|
|
55
|
-
* - Protecting locally-running services from being called by
|
|
56
|
-
* untrusted websites as the user browses the web
|
|
57
|
-
* - Restricting which domains can make requests to your API
|
|
58
|
-
* - Preventing embedding of your service in unexpected sites
|
|
59
|
-
* - Basic source verification for locally-running services
|
|
60
|
-
*
|
|
61
|
-
* @param allowed_patterns - array of compiled regex patterns from parse_allowed_origins
|
|
54
|
+
* @param allowed_patterns - compiled regex patterns from `parse_allowed_origins`
|
|
62
55
|
*/
|
|
63
56
|
export const verify_request_source = (allowed_patterns) => (c, next) => {
|
|
64
57
|
// Check origin header (preferred, sent by browsers for CORS requests).
|
|
@@ -106,7 +99,7 @@ export const verify_request_source = (allowed_patterns) => (c, next) => {
|
|
|
106
99
|
* like `[::ffff:127.0.0.1]` will be normalized to `[::ffff:7f00:1]`. IPv6 zone
|
|
107
100
|
* identifiers (e.g., `%eth0`) are not supported.
|
|
108
101
|
*
|
|
109
|
-
* @throws if pattern format is invalid
|
|
102
|
+
* @throws Error if pattern format is invalid
|
|
110
103
|
*/
|
|
111
104
|
const origin_pattern_to_regexp = (pattern) => {
|
|
112
105
|
// Quick validation: no paths, query strings, or fragments allowed
|
package/dist/http/proxy.d.ts
CHANGED
|
@@ -18,8 +18,6 @@ import type { MiddlewareSpec } from './middleware_spec.js';
|
|
|
18
18
|
* - Lowercases for case-insensitive IPv6 comparison
|
|
19
19
|
* - Idempotent: calling twice produces the same result
|
|
20
20
|
* - Safe on non-IP strings: `normalize_ip('unknown')` returns `'unknown'`
|
|
21
|
-
*
|
|
22
|
-
* @param ip - IP address string to normalize
|
|
23
21
|
*/
|
|
24
22
|
export declare const normalize_ip: (ip: string) => string;
|
|
25
23
|
/**
|
|
@@ -53,16 +51,13 @@ export type ParsedProxy = {
|
|
|
53
51
|
* CIDR prefixes are validated against address family bounds.
|
|
54
52
|
*
|
|
55
53
|
* @param entry - IP address or CIDR notation
|
|
56
|
-
* @throws on invalid IP, invalid CIDR network, or NaN/negative/over-range prefix
|
|
54
|
+
* @throws Error on invalid IP, invalid CIDR network, or NaN/negative/over-range prefix
|
|
57
55
|
*/
|
|
58
56
|
export declare const parse_proxy_entry: (entry: string) => ParsedProxy;
|
|
59
57
|
/**
|
|
60
58
|
* Check whether `ip` matches any entry in the trusted proxy list.
|
|
61
59
|
*
|
|
62
60
|
* Normalizes `ip` before matching (lowercase, IPv4-mapped IPv6 stripped).
|
|
63
|
-
*
|
|
64
|
-
* @param ip - the IP address to check
|
|
65
|
-
* @param proxies - parsed proxy entries
|
|
66
61
|
*/
|
|
67
62
|
export declare const is_trusted_ip: (ip: string, proxies: Array<ParsedProxy>) => boolean;
|
|
68
63
|
/**
|
|
@@ -102,7 +97,6 @@ export declare const create_proxy_middleware: (options: ProxyOptions) => Middlew
|
|
|
102
97
|
* Apply before auth middleware so `client_ip` is available for rate limiting.
|
|
103
98
|
*
|
|
104
99
|
* @param options - trusted proxy configuration
|
|
105
|
-
* @throws Error if any entry in `options.trusted_proxies` is invalid (delegates to `create_proxy_middleware`)
|
|
106
100
|
*/
|
|
107
101
|
export declare const create_proxy_middleware_spec: (options: ProxyOptions) => MiddlewareSpec;
|
|
108
102
|
/**
|
package/dist/http/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,MAQzC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,sFAAsF;IACtF,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACtD,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACpB;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAC7B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,CAAC;AAElF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,WA6CjD,CAAC;AAiBF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,EAAE,SAAS,KAAK,CAAC,WAAW,CAAC,KAAG,OAqBvE,CAAC;AAQF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC7B,eAAe,MAAM,EACrB,SAAS,KAAK,CAAC,WAAW,CAAC,KACzB,MAAM,GAAG,SAiBX,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,YAAY,KAAG,iBAyC/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,YAAY,KAAG,cAInE,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,MAAyC,CAAC"}
|
package/dist/http/proxy.js
CHANGED
|
@@ -16,8 +16,6 @@ import { convertIPv4ToBinary, convertIPv6ToBinary, distinctRemoteAddr } from 'ho
|
|
|
16
16
|
* - Lowercases for case-insensitive IPv6 comparison
|
|
17
17
|
* - Idempotent: calling twice produces the same result
|
|
18
18
|
* - Safe on non-IP strings: `normalize_ip('unknown')` returns `'unknown'`
|
|
19
|
-
*
|
|
20
|
-
* @param ip - IP address string to normalize
|
|
21
19
|
*/
|
|
22
20
|
export const normalize_ip = (ip) => {
|
|
23
21
|
const lowered = ip.toLowerCase();
|
|
@@ -36,7 +34,7 @@ export const normalize_ip = (ip) => {
|
|
|
36
34
|
* CIDR prefixes are validated against address family bounds.
|
|
37
35
|
*
|
|
38
36
|
* @param entry - IP address or CIDR notation
|
|
39
|
-
* @throws on invalid IP, invalid CIDR network, or NaN/negative/over-range prefix
|
|
37
|
+
* @throws Error on invalid IP, invalid CIDR network, or NaN/negative/over-range prefix
|
|
40
38
|
*/
|
|
41
39
|
export const parse_proxy_entry = (entry) => {
|
|
42
40
|
const slash_index = entry.indexOf('/');
|
|
@@ -97,9 +95,6 @@ const cidr_contains = (ip_binary, network, prefix, total_bits) => {
|
|
|
97
95
|
* Check whether `ip` matches any entry in the trusted proxy list.
|
|
98
96
|
*
|
|
99
97
|
* Normalizes `ip` before matching (lowercase, IPv4-mapped IPv6 stripped).
|
|
100
|
-
*
|
|
101
|
-
* @param ip - the IP address to check
|
|
102
|
-
* @param proxies - parsed proxy entries
|
|
103
98
|
*/
|
|
104
99
|
export const is_trusted_ip = (ip, proxies) => {
|
|
105
100
|
const normalized = normalize_ip(ip);
|
|
@@ -227,7 +222,6 @@ export const create_proxy_middleware = (options) => {
|
|
|
227
222
|
* Apply before auth middleware so `client_ip` is available for rate limiting.
|
|
228
223
|
*
|
|
229
224
|
* @param options - trusted proxy configuration
|
|
230
|
-
* @throws Error if any entry in `options.trusted_proxies` is invalid (delegates to `create_proxy_middleware`)
|
|
231
225
|
*/
|
|
232
226
|
export const create_proxy_middleware_spec = (options) => ({
|
|
233
227
|
name: 'trusted_proxy',
|
|
@@ -46,15 +46,11 @@ export type AuthGuardResolver = (auth: RouteAuth) => Array<MiddlewareHandler>;
|
|
|
46
46
|
export type RouteMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
47
47
|
/**
|
|
48
48
|
* Per-request deps provided by the framework to route handlers.
|
|
49
|
-
*
|
|
50
|
-
* `db` is transaction-scoped for mutation routes and pool-level for reads.
|
|
51
|
-
* `background_db` is always pool-level — use it for fire-and-forget effects
|
|
52
|
-
* that must outlive the transaction.
|
|
53
49
|
*/
|
|
54
50
|
export interface RouteContext {
|
|
55
51
|
/** Transaction-scoped for mutations, pool-level for reads. */
|
|
56
52
|
db: Db;
|
|
57
|
-
/** Always pool-level — for fire-and-forget effects that outlive the transaction. */
|
|
53
|
+
/** Always pool-level — for fire-and-forget effects that must outlive the transaction. */
|
|
58
54
|
background_db: Db;
|
|
59
55
|
/** Fire-and-forget side effects — push here for post-response flushing. */
|
|
60
56
|
pending_effects: Array<Promise<void>>;
|
|
@@ -76,20 +72,14 @@ export type RouteHandler = (c: Context, route: RouteContext) => Response | Promi
|
|
|
76
72
|
export interface RouteSpec {
|
|
77
73
|
method: RouteMethod;
|
|
78
74
|
path: string;
|
|
79
|
-
/**
|
|
80
|
-
* Auth requirement for this route.
|
|
81
|
-
*
|
|
82
|
-
* `{type: 'none'}` means the route is open to all clients including non-browser
|
|
83
|
-
* callers (CLI, scripts) — no auth guards are applied.
|
|
84
|
-
*/
|
|
85
75
|
auth: RouteAuth;
|
|
86
76
|
handler: RouteHandler;
|
|
87
77
|
description: string;
|
|
88
78
|
/**
|
|
89
79
|
* URL path parameter schema. Use `z.strictObject()` with string fields matching `:param` segments.
|
|
90
80
|
*
|
|
91
|
-
*
|
|
92
|
-
* `input
|
|
81
|
+
* REST-only — actions dispatch through a single JSON-RPC endpoint and encode
|
|
82
|
+
* everything in `input`, so `params` doesn't appear on `ActionSpec`.
|
|
93
83
|
*/
|
|
94
84
|
params?: z.ZodObject;
|
|
95
85
|
/** URL query parameter schema. Use `z.strictObject()` with string fields. */
|
|
@@ -131,38 +121,30 @@ export interface RouteSpec {
|
|
|
131
121
|
/**
|
|
132
122
|
* Get validated input from the Hono context.
|
|
133
123
|
*
|
|
134
|
-
* Call
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @returns the validated request body
|
|
124
|
+
* Call after the input validation middleware has run. The type parameter
|
|
125
|
+
* should match the route's `input` schema.
|
|
138
126
|
*/
|
|
139
127
|
export declare const get_route_input: <T>(c: Context) => T;
|
|
140
128
|
/**
|
|
141
129
|
* Get validated URL path params from the Hono context.
|
|
142
130
|
*
|
|
143
|
-
* Call
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* TODO @action-system-review Make typesafe — derive `T` from the `params` schema on the
|
|
147
|
-
* route spec so the type parameter isn't manually specified.
|
|
131
|
+
* Call after the params validation middleware has run. The type parameter
|
|
132
|
+
* should match the route's `params` schema.
|
|
148
133
|
*
|
|
149
|
-
*
|
|
134
|
+
* TODO derive `T` from the route spec so the type parameter isn't manually
|
|
135
|
+
* specified — same applies to `get_route_input` / `get_route_query`.
|
|
150
136
|
*/
|
|
151
137
|
export declare const get_route_params: <T>(c: Context) => T;
|
|
152
138
|
/**
|
|
153
139
|
* Get validated URL query params from the Hono context.
|
|
154
140
|
*
|
|
155
|
-
* Call
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* @returns the validated query parameters
|
|
141
|
+
* Call after the query validation middleware has run. The type parameter
|
|
142
|
+
* should match the route's `query` schema.
|
|
159
143
|
*/
|
|
160
144
|
export declare const get_route_query: <T>(c: Context) => T;
|
|
161
145
|
/**
|
|
162
146
|
* Apply named middleware specs to a Hono app.
|
|
163
147
|
*
|
|
164
|
-
* @param app - the Hono app
|
|
165
|
-
* @param specs - middleware specs to apply
|
|
166
148
|
* @mutates `app`
|
|
167
149
|
*/
|
|
168
150
|
export declare const apply_middleware_specs: (app: Hono, specs: Array<MiddlewareSpec>) => void;
|
|
@@ -179,11 +161,8 @@ export declare const apply_middleware_specs: (app: Hono, specs: Array<Middleware
|
|
|
179
161
|
* - `background_db`: always pool-level
|
|
180
162
|
* - `pending_effects`: fire-and-forget effect queue
|
|
181
163
|
*
|
|
182
|
-
* @param app - the Hono app
|
|
183
|
-
* @param specs - route specs to apply
|
|
184
164
|
* @param resolve_auth_guards - maps `RouteAuth` to middleware — use `fuz_auth_guard_resolver` from `auth/route_guards.ts`
|
|
185
|
-
* @param
|
|
186
|
-
* @param db - database instance for transaction wrapping and `RouteContext`
|
|
165
|
+
* @param db - used for transaction wrapping and `RouteContext`
|
|
187
166
|
* @mutates `app`
|
|
188
167
|
* @throws Error if two specs share the same `method` + `path` (each combination must be unique)
|
|
189
168
|
*/
|
|
@@ -192,8 +171,7 @@ export declare const apply_route_specs: (app: Hono, specs: Array<RouteSpec>, res
|
|
|
192
171
|
* Prepend a prefix to all route spec paths.
|
|
193
172
|
*
|
|
194
173
|
* @param prefix - the path prefix (e.g. `/api/account`)
|
|
195
|
-
* @
|
|
196
|
-
* @returns new array of specs with prefixed paths
|
|
174
|
+
* @returns a new array — the input specs are not mutated
|
|
197
175
|
*/
|
|
198
176
|
export declare const prefix_route_specs: (prefix: string, specs: Array<RouteSpec>) => Array<RouteSpec>;
|
|
199
177
|
//# sourceMappingURL=route_spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAW,IAAI,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AACpE,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAKjB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAClB;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GACd;IAAC,IAAI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