@fuzdev/fuz_app 0.152.0 → 0.154.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 +14 -11
- package/dist/actions/action_rpc.js +3 -3
- package/dist/actions/action_types.d.ts +3 -3
- package/dist/actions/broadcast_api.d.ts +0 -6
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +14 -15
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +13 -13
- package/dist/actions/perform_action.d.ts +5 -1
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +57 -19
- package/dist/actions/register_action_ws.d.ts +6 -5
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +5 -6
- package/dist/auth/CLAUDE.md +44 -14
- package/dist/auth/account_actions.d.ts +2 -2
- package/dist/auth/account_actions.js +6 -6
- package/dist/auth/account_routes.js +9 -9
- package/dist/auth/admin_actions.d.ts +2 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +21 -20
- package/dist/auth/audit_emitter.d.ts +111 -64
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +130 -55
- package/dist/auth/audit_log_queries.d.ts +9 -10
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +13 -10
- package/dist/auth/audit_log_routes.js +2 -2
- package/dist/auth/audit_log_schema.d.ts +6 -1
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.d.ts +4 -3
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +4 -3
- package/dist/auth/bootstrap_routes.js +2 -2
- package/dist/auth/cell_action_helpers.d.ts +3 -2
- package/dist/auth/cell_action_helpers.d.ts.map +1 -1
- package/dist/auth/cell_action_helpers.js +9 -10
- package/dist/auth/cell_actions.js +6 -6
- package/dist/auth/cell_data_schema.d.ts +5 -0
- package/dist/auth/cell_data_schema.d.ts.map +1 -1
- package/dist/auth/cell_data_schema.js +5 -0
- package/dist/auth/cell_field_actions.js +2 -2
- package/dist/auth/cell_grant_actions.js +2 -2
- package/dist/auth/cell_item_actions.js +3 -3
- package/dist/auth/deps.d.ts +12 -10
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/middleware.js +1 -1
- package/dist/auth/request_context.d.ts +5 -10
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +10 -9
- package/dist/auth/role_grant_offer_actions.d.ts +11 -8
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +57 -41
- package/dist/auth/self_service_role_actions.d.ts +6 -5
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +17 -6
- package/dist/auth/session_cookie.d.ts +4 -4
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +0 -1
- package/dist/auth/session_middleware.d.ts +8 -5
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +10 -7
- package/dist/auth/signup_routes.js +6 -6
- package/dist/auth/standard_rpc_actions.d.ts +3 -2
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +3 -2
- package/dist/db/CLAUDE.md +10 -1
- package/dist/db/create_db.d.ts +18 -1
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +15 -4
- package/dist/db/db.d.ts +27 -0
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +26 -0
- package/dist/db/db_checkout_error.d.ts +36 -0
- package/dist/db/db_checkout_error.d.ts.map +1 -0
- package/dist/db/db_checkout_error.js +48 -0
- package/dist/db/db_pg.d.ts +83 -5
- package/dist/db/db_pg.d.ts.map +1 -1
- package/dist/db/db_pg.js +119 -9
- package/dist/db/pg_error.d.ts +4 -0
- package/dist/db/pg_error.d.ts.map +1 -1
- package/dist/db/pg_error.js +13 -3
- package/dist/dev/setup.d.ts +4 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +12 -5
- package/dist/env/env_schemas.d.ts +41 -0
- package/dist/env/env_schemas.d.ts.map +1 -0
- package/dist/env/env_schemas.js +55 -0
- package/dist/env/load.d.ts +23 -15
- package/dist/env/load.d.ts.map +1 -1
- package/dist/env/load.js +38 -22
- package/dist/hono_context.d.ts +36 -6
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +29 -2
- package/dist/http/CLAUDE.md +11 -10
- package/dist/http/db_routes.d.ts +7 -12
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +32 -17
- package/dist/http/error_schemas.d.ts +12 -0
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +12 -0
- package/dist/http/jsonrpc_errors.d.ts +10 -0
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +14 -0
- package/dist/http/jsonrpc_helpers.d.ts +4 -0
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +8 -1
- package/dist/http/route_spec.d.ts +4 -4
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +20 -3
- package/dist/http/schema_helpers.d.ts +21 -0
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +38 -0
- package/dist/http/surface.d.ts +13 -9
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +22 -18
- package/dist/realtime/audit_log_sse.d.ts +2 -2
- package/dist/realtime/audit_log_sse.js +2 -2
- package/dist/schema_meta.d.ts +4 -2
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +4 -2
- package/dist/sensitivity.d.ts +34 -1
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +32 -2
- package/dist/server/app_backend.d.ts +25 -1
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +16 -3
- package/dist/server/app_error_handler.d.ts +30 -0
- package/dist/server/app_error_handler.d.ts.map +1 -0
- package/dist/server/app_error_handler.js +41 -0
- package/dist/server/app_server.d.ts +7 -6
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +6 -2
- package/dist/server/env.d.ts +55 -28
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +46 -29
- package/dist/testing/CLAUDE.md +23 -17
- package/dist/testing/app_server.js +2 -2
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +2 -0
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -2
- package/dist/testing/cross_backend/conformance_case.d.ts +2 -0
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_case.js +8 -0
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +24 -7
- package/dist/testing/cross_backend/default_backend_configs.d.ts +4 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +7 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +11 -0
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.d.ts +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +15 -11
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +3 -12
- package/dist/testing/daemon_token_rotation.d.ts +4 -14
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +0 -12
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +7 -3
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +2 -2
- package/dist/testing/rpc_helpers.d.ts +19 -0
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +25 -2
- package/dist/testing/schema_parity.d.ts +1 -1
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +2 -2
- package/dist/testing/surface_invariants.js +1 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +3 -3
- package/dist/zod.d.ts +9 -0
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +1 -1
- package/package.json +6 -10
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The assembled app's `onError` — what a throw that escapes every route catch
|
|
3
|
+
* answers.
|
|
4
|
+
*
|
|
5
|
+
* Route handlers and the RPC dispatcher map their own throws
|
|
6
|
+
* (`http/route_spec.ts`, `actions/perform_action.ts`); what reaches here is a
|
|
7
|
+
* throw from middleware — above all the credential legs, whose failed read
|
|
8
|
+
* ends the request rather than reading as anonymous. Two answers:
|
|
9
|
+
*
|
|
10
|
+
* - a failed pool checkout (`DbCheckoutError`) is the database unavailable:
|
|
11
|
+
* 503 `{"error": "service_unavailable"}`, the Rust spine's
|
|
12
|
+
* `fuz_http::db_unavailable_response` (and its `CredentialReadFault` of the
|
|
13
|
+
* checkout kind);
|
|
14
|
+
* - anything else is Hono's default error handler, reproduced byte for byte —
|
|
15
|
+
* an `HTTPException`'s own response, else 500 `text/plain; charset=UTF-8`
|
|
16
|
+
* `Internal Server Error`, the body the Rust `CredentialReadFault` of the
|
|
17
|
+
* query kind answers with.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { ErrorHandler } from 'hono';
|
|
22
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
23
|
+
/**
|
|
24
|
+
* Build the app's `onError` handler (module doc).
|
|
25
|
+
*
|
|
26
|
+
* @param log - receives each failed checkout and each unhandled error
|
|
27
|
+
* @returns the handler `create_app_server` registers with `app.onError`
|
|
28
|
+
*/
|
|
29
|
+
export declare const create_app_error_handler: (log: Logger) => ErrorHandler;
|
|
30
|
+
//# sourceMappingURL=app_error_handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app_error_handler.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_error_handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAKtD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,KAAK,MAAM,KAAG,YAad,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The assembled app's `onError` — what a throw that escapes every route catch
|
|
3
|
+
* answers.
|
|
4
|
+
*
|
|
5
|
+
* Route handlers and the RPC dispatcher map their own throws
|
|
6
|
+
* (`http/route_spec.ts`, `actions/perform_action.ts`); what reaches here is a
|
|
7
|
+
* throw from middleware — above all the credential legs, whose failed read
|
|
8
|
+
* ends the request rather than reading as anonymous. Two answers:
|
|
9
|
+
*
|
|
10
|
+
* - a failed pool checkout (`DbCheckoutError`) is the database unavailable:
|
|
11
|
+
* 503 `{"error": "service_unavailable"}`, the Rust spine's
|
|
12
|
+
* `fuz_http::db_unavailable_response` (and its `CredentialReadFault` of the
|
|
13
|
+
* checkout kind);
|
|
14
|
+
* - anything else is Hono's default error handler, reproduced byte for byte —
|
|
15
|
+
* an `HTTPException`'s own response, else 500 `text/plain; charset=UTF-8`
|
|
16
|
+
* `Internal Server Error`, the body the Rust `CredentialReadFault` of the
|
|
17
|
+
* query kind answers with.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { is_db_checkout_error } from '../db/db_checkout_error.js';
|
|
22
|
+
import { ERROR_SERVICE_UNAVAILABLE } from '../http/error_schemas.js';
|
|
23
|
+
/**
|
|
24
|
+
* Build the app's `onError` handler (module doc).
|
|
25
|
+
*
|
|
26
|
+
* @param log - receives each failed checkout and each unhandled error
|
|
27
|
+
* @returns the handler `create_app_server` registers with `app.onError`
|
|
28
|
+
*/
|
|
29
|
+
export const create_app_error_handler = (log) => (err, c) => {
|
|
30
|
+
if (is_db_checkout_error(err)) {
|
|
31
|
+
log.error('pool checkout failed:', err);
|
|
32
|
+
return c.json({ error: ERROR_SERVICE_UNAVAILABLE }, 503);
|
|
33
|
+
}
|
|
34
|
+
// Hono's default handler (`hono-base.js` `errorHandler`), byte for byte
|
|
35
|
+
if ('getResponse' in err) {
|
|
36
|
+
const res = err.getResponse();
|
|
37
|
+
return c.newResponse(res.body, res);
|
|
38
|
+
}
|
|
39
|
+
log.error('unhandled error:', err);
|
|
40
|
+
return c.text('Internal Server Error', 500);
|
|
41
|
+
};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { Hono, type Context } from 'hono';
|
|
11
11
|
import type { UpgradeWebSocket } from 'hono/ws';
|
|
12
|
-
import {
|
|
12
|
+
import type { AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
13
13
|
import { type SessionOptions, type SessionCookieOptions } from '../auth/session_cookie.js';
|
|
14
14
|
import type { BootstrapAccountSuccess } from '../auth/bootstrap_account.js';
|
|
15
15
|
import type { EventSpec } from '../realtime/sse.js';
|
|
@@ -383,11 +383,12 @@ export interface AppServerOptions {
|
|
|
383
383
|
*/
|
|
384
384
|
ws_endpoints?: ReadonlyArray<WsEndpointSpec> | ((context: AppServerContext) => ReadonlyArray<WsEndpointSpec>);
|
|
385
385
|
/**
|
|
386
|
-
* Env schema for surface generation
|
|
387
|
-
* pass an extended schema
|
|
388
|
-
* when the consumer
|
|
386
|
+
* Env schema for surface generation, a `@fuzdev/fuz_schema` object
|
|
387
|
+
* schema. Defaults to `BaseServerEnv` — pass an extended schema
|
|
388
|
+
* (typically `object({...BaseServerEnv.def, ...})`) when the consumer
|
|
389
|
+
* adds app-specific env vars.
|
|
389
390
|
*/
|
|
390
|
-
env_schema?:
|
|
391
|
+
env_schema?: AnySchema;
|
|
391
392
|
/** Middleware applied after routes, before static serving. Included in surface. */
|
|
392
393
|
post_route_middleware?: Array<MiddlewareSpec>;
|
|
393
394
|
/** Static file serving. Omit if not serving static files. */
|
|
@@ -626,7 +627,7 @@ export declare const collect_config_diagnostics: (input: ConfigDiagnosticsInput)
|
|
|
626
627
|
* to `backend.deps.connection_closer`, so the revocation handlers built from
|
|
627
628
|
* `ctx.deps` close their connections with no further wiring, and — when the
|
|
628
629
|
* server mounts either — one `create_revocation_guard` listener on that closer
|
|
629
|
-
* repeats each close on the audit row
|
|
630
|
+
* repeats each close on the audit row.
|
|
630
631
|
* The
|
|
631
632
|
* `audit_sse` field on the returned `AppServer` (and the
|
|
632
633
|
* `AppServerContext` passed to `create_route_specs`) is non-null in that
|
|
@@ -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,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,
|
|
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,EAA0B,MAAM,MAAM,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK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AAC;IAC1D,2CAA2C;IAC3C,iBAAiB,EAAE,eAAe,CAAC;IACnC,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC,uBAAuB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IACnE,uFAAuF;IACvF,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACtC,OAAO,sBAAsB,KAC3B,KAAK,CAAC,oBAAoB,CA0D5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,SAAS,CAQpF,CAAC"}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { Hono } from 'hono';
|
|
11
11
|
import { logger } from 'hono/logger';
|
|
12
|
-
import { z } from 'zod';
|
|
13
12
|
import { session_cookie_options } from '../auth/session_cookie.js';
|
|
14
13
|
import { create_audit_log_sse, create_sse_connection_closer, audit_log_event_specs } from '../realtime/audit_log_sse.js';
|
|
15
14
|
import { BaseServerEnv } from './env.js';
|
|
@@ -20,6 +19,7 @@ import '../hono_context.js';
|
|
|
20
19
|
import { create_proxy_middleware_spec } from '../http/proxy.js';
|
|
21
20
|
import { create_static_middleware } from './static.js';
|
|
22
21
|
import { log_startup_summary } from './startup.js';
|
|
22
|
+
import { create_app_error_handler } from './app_error_handler.js';
|
|
23
23
|
import { create_app_surface_spec } from '../http/surface.js';
|
|
24
24
|
import { apply_middleware_specs, apply_route_specs, prefix_route_specs } from '../http/route_spec.js';
|
|
25
25
|
import { check_bootstrap_status, create_bootstrap_route_specs } from '../auth/bootstrap_routes.js';
|
|
@@ -207,7 +207,7 @@ export const collect_config_diagnostics = (input) => {
|
|
|
207
207
|
* to `backend.deps.connection_closer`, so the revocation handlers built from
|
|
208
208
|
* `ctx.deps` close their connections with no further wiring, and — when the
|
|
209
209
|
* server mounts either — one `create_revocation_guard` listener on that closer
|
|
210
|
-
* repeats each close on the audit row
|
|
210
|
+
* repeats each close on the audit row.
|
|
211
211
|
* The
|
|
212
212
|
* `audit_sse` field on the returned `AppServer` (and the
|
|
213
213
|
* `AppServerContext` passed to `create_route_specs`) is non-null in that
|
|
@@ -502,6 +502,10 @@ const assemble_app_server = async (options, releases) => {
|
|
|
502
502
|
log_startup_summary(surface_spec.surface, log, options.env_values);
|
|
503
503
|
// Hono app assembly
|
|
504
504
|
const app = new Hono();
|
|
505
|
+
// A throw that escapes every route catch — a credential leg's failed read
|
|
506
|
+
// above all — answers here: 503 for a failed pool checkout, Hono's default
|
|
507
|
+
// 500 for anything else.
|
|
508
|
+
app.onError(create_app_error_handler(log));
|
|
505
509
|
// Two-queue side-effect flush. `pending_effects` collects eager
|
|
506
510
|
// fire-and-forget promises (audit emits, api-token usage). `post_commit_effects` collects deferred thunks pushed via
|
|
507
511
|
// `emit_after_commit` (WS notifications, anything that must observe a
|
package/dist/server/env.d.ts
CHANGED
|
@@ -1,42 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base server environment schema and validation.
|
|
3
3
|
*
|
|
4
|
-
* Provides `BaseServerEnv` — a shared
|
|
5
|
-
* that apps can use directly or extend with
|
|
4
|
+
* Provides `BaseServerEnv` — a shared `@fuzdev/fuz_schema` object schema for
|
|
5
|
+
* common server env vars that apps can use directly or extend with
|
|
6
|
+
* app-specific fields.
|
|
6
7
|
*
|
|
7
|
-
* Generic env loading lives in `env/load.ts
|
|
8
|
+
* Generic env loading lives in `env/load.ts`, and the value schemas
|
|
9
|
+
* (`env_integer`, `EnvStringbool`) in `env/env_schemas.ts`.
|
|
8
10
|
*
|
|
9
11
|
* @module
|
|
10
12
|
*/
|
|
11
|
-
import {
|
|
13
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
12
14
|
import type { Result } from '@fuzdev/fuz_util/result.ts';
|
|
13
15
|
import { type Keyring } from '../auth/keyring.js';
|
|
16
|
+
import '../sensitivity.js';
|
|
14
17
|
/**
|
|
15
|
-
* Base
|
|
18
|
+
* Base schema for server environment variables, a strict `object`.
|
|
16
19
|
*
|
|
17
|
-
* Declares only what the spine reads — server config, database
|
|
18
|
-
* allowed origins and the wildcard opt-in, and
|
|
19
|
-
* matching the Rust spine's `BaseServerEnv`.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* Declares only what the spine reads — server config, database and its pool
|
|
21
|
+
* checkout bounds, cookie keys, allowed origins and the wildcard opt-in, and
|
|
22
|
+
* the bootstrap token path — matching the Rust spine's `BaseServerEnv`. The
|
|
23
|
+
* numeric vars read as the Rust twin reads them (`env_integer`: trimmed,
|
|
24
|
+
* then decimal digits after at most one `+`, so `5e3` and a blank value are
|
|
25
|
+
* refused on both, as is one out of range). Anything else (fact storage, X-Accel delivery, public
|
|
26
|
+
* URLs) is the app's own var: extend by spreading `def` into a new `object`,
|
|
27
|
+
* `object({...BaseServerEnv.def, MY_VAR: ...})`.
|
|
28
|
+
*
|
|
29
|
+
* Each field's description and `sensitivity` are `meta`, read by
|
|
30
|
+
* `env_schema_to_surface`.
|
|
22
31
|
*/
|
|
23
|
-
export declare const BaseServerEnv:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
export declare const BaseServerEnv: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
33
|
+
SECRET_FUZ_COOKIE_KEYS: string;
|
|
34
|
+
FUZ_ALLOWED_ORIGINS: string;
|
|
35
|
+
NODE_ENV: "development" | "production";
|
|
36
|
+
PORT: number;
|
|
37
|
+
HOST: string;
|
|
38
|
+
DATABASE_URL: string;
|
|
39
|
+
FUZ_ALLOW_ORIGIN_WILDCARDS?: "true" | "false" | undefined;
|
|
40
|
+
FUZ_BOOTSTRAP_TOKEN_PATH?: string | undefined;
|
|
41
|
+
FUZ_DB_CHECKOUT_TIMEOUT_MS?: number | undefined;
|
|
42
|
+
FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS?: number | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
SECRET_FUZ_COOKIE_KEYS: string;
|
|
45
|
+
FUZ_ALLOWED_ORIGINS: string;
|
|
46
|
+
NODE_ENV: "development" | "production";
|
|
47
|
+
DATABASE_URL: string;
|
|
48
|
+
FUZ_ALLOW_ORIGIN_WILDCARDS?: "true" | "false" | undefined;
|
|
49
|
+
PORT?: string | undefined;
|
|
50
|
+
HOST?: string | undefined;
|
|
51
|
+
FUZ_BOOTSTRAP_TOKEN_PATH?: string | undefined;
|
|
52
|
+
FUZ_DB_CHECKOUT_TIMEOUT_MS?: string | undefined;
|
|
53
|
+
FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS?: string | undefined;
|
|
54
|
+
}, "object", {
|
|
55
|
+
NODE_ENV: import("@fuzdev/fuz_schema/schema.ts").Schema<"development" | "production", "development" | "production", "one_of", readonly ["development", "production"]>;
|
|
56
|
+
PORT: import("@fuzdev/fuz_schema/schema.ts").Schema<number, string | undefined, "with_default", import("@fuzdev/fuz_schema/schema.ts").SchemaDefaultDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
57
|
+
HOST: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string | undefined, "with_default", import("@fuzdev/fuz_schema/schema.ts").SchemaDefaultDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
58
|
+
DATABASE_URL: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
59
|
+
SECRET_FUZ_COOKIE_KEYS: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
60
|
+
FUZ_ALLOWED_ORIGINS: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
61
|
+
FUZ_ALLOW_ORIGIN_WILDCARDS: import("@fuzdev/fuz_schema/schema.ts").Schema<"true" | "false" | undefined, "true" | "false" | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<"true" | "false", "true" | "false", "one_of", readonly ["true", "false"]>>>;
|
|
62
|
+
FUZ_BOOTSTRAP_TOKEN_PATH: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
63
|
+
FUZ_DB_CHECKOUT_TIMEOUT_MS: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
64
|
+
FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS: import("@fuzdev/fuz_schema/schema.ts").Schema<number | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
65
|
+
}>;
|
|
66
|
+
export type BaseServerEnv = Infer<typeof BaseServerEnv>;
|
|
40
67
|
/**
|
|
41
68
|
* Validated server env config — the artifacts `create_app_server()` needs.
|
|
42
69
|
*/
|
|
@@ -67,7 +94,7 @@ export interface ServerEnvValidationError {
|
|
|
67
94
|
* bootstrap token path extraction.
|
|
68
95
|
* Returns a Result so callers handle errors their own way (exit, logging, etc).
|
|
69
96
|
*
|
|
70
|
-
* @param env - a loaded and
|
|
97
|
+
* @param env - a loaded and validated `BaseServerEnv`
|
|
71
98
|
* @returns `{ok: true, keyring, allowed_origins, allow_origin_wildcards, bootstrap_token_path}`
|
|
72
99
|
* or `{ok: false, field, errors}`
|
|
73
100
|
*/
|
package/dist/server/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/env.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EASN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAMlE,OAAO,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,wBAAwB,GAAG,qBAAqB,CAAC;IACxD,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAC/B,KAAK,aAAa,KAChB,MAAM,CAAC,kBAAkB,EAAE,wBAAwB,CA2BrD,CAAC"}
|
package/dist/server/env.js
CHANGED
|
@@ -1,54 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base server environment schema and validation.
|
|
3
3
|
*
|
|
4
|
-
* Provides `BaseServerEnv` — a shared
|
|
5
|
-
* that apps can use directly or extend with
|
|
4
|
+
* Provides `BaseServerEnv` — a shared `@fuzdev/fuz_schema` object schema for
|
|
5
|
+
* common server env vars that apps can use directly or extend with
|
|
6
|
+
* app-specific fields.
|
|
6
7
|
*
|
|
7
|
-
* Generic env loading lives in `env/load.ts
|
|
8
|
+
* Generic env loading lives in `env/load.ts`, and the value schemas
|
|
9
|
+
* (`env_integer`, `EnvStringbool`) in `env/env_schemas.ts`.
|
|
8
10
|
*
|
|
9
11
|
* @module
|
|
10
12
|
*/
|
|
11
|
-
import {
|
|
13
|
+
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
14
|
+
import { message, min_length, object, one_of, optional, pipe, string, with_default } from '@fuzdev/fuz_schema/schema.ts';
|
|
12
15
|
import { create_keyring } from '../auth/keyring.js';
|
|
13
16
|
import { format_allowed_origins_error, parse_allowed_origins } from '../http/origin.js';
|
|
14
17
|
import { admit_origin_wildcards } from '../http/origin_wildcard.js';
|
|
18
|
+
import { DB_CHECKOUT_TIMEOUT_MAX_MS } from '../db/db_pg.js';
|
|
19
|
+
import { env_integer } from '../env/env_schemas.js';
|
|
20
|
+
// declares `sensitivity` on fuz_schema's `SchemaMeta`, for the fields here and consumers'
|
|
21
|
+
import '../sensitivity.js';
|
|
15
22
|
/**
|
|
16
|
-
* Base
|
|
23
|
+
* Base schema for server environment variables, a strict `object`.
|
|
17
24
|
*
|
|
18
|
-
* Declares only what the spine reads — server config, database
|
|
19
|
-
* allowed origins and the wildcard opt-in, and
|
|
20
|
-
* matching the Rust spine's `BaseServerEnv`.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* Declares only what the spine reads — server config, database and its pool
|
|
26
|
+
* checkout bounds, cookie keys, allowed origins and the wildcard opt-in, and
|
|
27
|
+
* the bootstrap token path — matching the Rust spine's `BaseServerEnv`. The
|
|
28
|
+
* numeric vars read as the Rust twin reads them (`env_integer`: trimmed,
|
|
29
|
+
* then decimal digits after at most one `+`, so `5e3` and a blank value are
|
|
30
|
+
* refused on both, as is one out of range). Anything else (fact storage, X-Accel delivery, public
|
|
31
|
+
* URLs) is the app's own var: extend by spreading `def` into a new `object`,
|
|
32
|
+
* `object({...BaseServerEnv.def, MY_VAR: ...})`.
|
|
33
|
+
*
|
|
34
|
+
* Each field's description and `sensitivity` are `meta`, read by
|
|
35
|
+
* `env_schema_to_surface`.
|
|
23
36
|
*/
|
|
24
|
-
export const BaseServerEnv =
|
|
25
|
-
NODE_ENV:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
HOST: z.string().default('localhost').meta({ description: 'HTTP server bind address' }),
|
|
34
|
-
DATABASE_URL: z.string().min(1).meta({
|
|
37
|
+
export const BaseServerEnv = object({
|
|
38
|
+
NODE_ENV: meta(one_of(['development', 'production']), {
|
|
39
|
+
description: 'Runtime environment mode'
|
|
40
|
+
}),
|
|
41
|
+
PORT: meta(with_default(env_integer({ min: 1, max: 65535 }), 4040), {
|
|
42
|
+
description: 'HTTP server port'
|
|
43
|
+
}),
|
|
44
|
+
HOST: meta(with_default(string, 'localhost'), { description: 'HTTP server bind address' }),
|
|
45
|
+
DATABASE_URL: meta(pipe(string, min_length(1)), {
|
|
35
46
|
description: 'Database URL (postgres://, file://, or memory://)',
|
|
36
47
|
sensitivity: 'secret'
|
|
37
48
|
}),
|
|
38
|
-
SECRET_FUZ_COOKIE_KEYS:
|
|
49
|
+
SECRET_FUZ_COOKIE_KEYS: meta(pipe(string, min_length(32)), {
|
|
39
50
|
description: 'Cookie signing keys, separated by __ for rotation',
|
|
40
51
|
sensitivity: 'secret'
|
|
41
52
|
}),
|
|
42
|
-
FUZ_ALLOWED_ORIGINS:
|
|
53
|
+
FUZ_ALLOWED_ORIGINS: meta(pipe(string, message(min_length(1), 'FUZ_ALLOWED_ORIGINS is required')), {
|
|
43
54
|
description: 'Comma-separated origin patterns for API verification'
|
|
44
55
|
}),
|
|
45
|
-
FUZ_ALLOW_ORIGIN_WILDCARDS:
|
|
56
|
+
FUZ_ALLOW_ORIGIN_WILDCARDS: meta(optional(one_of(['true', 'false'])), {
|
|
46
57
|
description: 'Exactly `true` lets a wildcard FUZ_ALLOWED_ORIGINS entry (`:*`, a `*` label) boot, warned of on every boot; unset or `false` refuses one'
|
|
47
58
|
}),
|
|
48
|
-
FUZ_BOOTSTRAP_TOKEN_PATH:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
FUZ_BOOTSTRAP_TOKEN_PATH: meta(optional(string), {
|
|
60
|
+
description: 'Path to one-shot admin bootstrap token',
|
|
61
|
+
sensitivity: 'secret'
|
|
62
|
+
}),
|
|
63
|
+
FUZ_DB_CHECKOUT_TIMEOUT_MS: meta(optional(env_integer({ min: 1, max: DB_CHECKOUT_TIMEOUT_MAX_MS })), {
|
|
64
|
+
description: 'Bound on the pool checkouts a request makes, in ms (default 5000); a failed checkout answers 503. Audit writes use FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS instead, including the failed-login row a request waits on. Postgres only — PGlite and pglet have no pool'
|
|
65
|
+
}),
|
|
66
|
+
FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS: meta(optional(env_integer({ min: 1, max: DB_CHECKOUT_TIMEOUT_MAX_MS })), {
|
|
67
|
+
description: 'Bound on the checkout behind each audit pool write, in ms (default 30000); a failed login waits on its row, so up to this bound. Postgres only'
|
|
68
|
+
})
|
|
52
69
|
});
|
|
53
70
|
/**
|
|
54
71
|
* Validate a loaded `BaseServerEnv` and produce the artifacts needed for server init.
|
|
@@ -60,7 +77,7 @@ export const BaseServerEnv = z.strictObject({
|
|
|
60
77
|
* bootstrap token path extraction.
|
|
61
78
|
* Returns a Result so callers handle errors their own way (exit, logging, etc).
|
|
62
79
|
*
|
|
63
|
-
* @param env - a loaded and
|
|
80
|
+
* @param env - a loaded and validated `BaseServerEnv`
|
|
64
81
|
* @returns `{ok: true, keyring, allowed_origins, allow_origin_wildcards, bootstrap_token_path}`
|
|
65
82
|
* or `{ok: false, field, errors}`
|
|
66
83
|
*/
|
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -14,6 +14,7 @@ testing-patterns. This file is a reference index for the helpers themselves.
|
|
|
14
14
|
## Production guard — always the first import
|
|
15
15
|
|
|
16
16
|
Every runtime-reachable module here starts with `import './assert_dev_env.ts';`
|
|
17
|
+
(`import '../assert_dev_env.ts';` from a subdirectory, and so on by depth)
|
|
17
18
|
— reads `DEV` from `esm-env` and throws if false, preventing production-bundle
|
|
18
19
|
inclusion. Make this the first line in new modules. Enforced by
|
|
19
20
|
`src/test/testing/assert_dev_env_coverage.test.ts`, which fails if any module
|
|
@@ -32,7 +33,7 @@ time (never runtime), where a throwing guard would break `vite build`.
|
|
|
32
33
|
- `stub_handler()` — fresh `Response('stub')`.
|
|
33
34
|
- `stub_mw` — pass-through middleware (`async (_c, next) => next()`).
|
|
34
35
|
- `create_stub_app_deps()` — factory: fresh `AppDeps` with no-op keyring/password/`delete_file`, a `read_secure_file` that throws ENOENT (the no-token-file state), a `create_noop_stub` DB, silent `Logger`, no-op `audit`, an empty `connection_closer`.
|
|
35
|
-
- `create_test_audit_emitter()` — no-op `AuditEmitter`; `emit` / `emit_role_grant_target`
|
|
36
|
+
- `create_test_audit_emitter()` — no-op `AuditEmitter`; `emit` / `emit_role_grant_target` / `emit_pool` resolve immediately, `notify` no-op, `add_listener` throws (use `create_recording_audit_emitter` for a listener-accepting emitter), `listener_count` returns 0, `drain_inflight` resolves immediately, `is_tracking_inflight` returns `false`.
|
|
36
37
|
- `create_stub_audit_sse()` — no-op `AuditLogSse` for surface-test wiring without booting real SSE. `on_audit_event` no-op (nothing is broadcast); `required_role` is `admin`; `registry` is a fresh `SseRegistry` (live `.count` / `.close_*` for registry-state tests, isolated per call). For real SSE plumbing build via `create_audit_log_sse` against `create_test_app`.
|
|
37
38
|
- `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` matching `create_auth_middleware_specs`'s output (origin, optional daemon_token, session, request_context, bearer_auth) for surface generation without booting real auth — the same names, paths, order, and declared `errors` (`origin` declares a 403; `bearer_auth` and `daemon_token` declare none, since both soft-fail through `next()`), pinned against the real factory by `auth/middleware.mounted.test.ts`. The surface merges middleware errors into every route under the path, so a stub declaring more would widen the test surface with statuses the live server never returns. Each spec gets its own pass-through handler (not the shared `stub_mw`), so `assert_middleware_stack_mounted` tells the layers apart. See `auth/CLAUDE.md` §Middleware for the real stack.
|
|
38
39
|
- `create_stub_app_backend(options?)` — stub `AppBackend` with no database: `create_stub_app_deps()` (or `options.deps`), no migration results, a `close` that does nothing (or `options.close`). For assembling a server in tests that never reach the database.
|
|
@@ -195,7 +196,7 @@ Types:
|
|
|
195
196
|
`create_test_app` hard-codes the test-friendly `AppServerOptions`:
|
|
196
197
|
`allowed_origins` exactly `TEST_ORIGIN` (built by
|
|
197
198
|
`parse_allowed_origins`, as `create_app_server` requires), stub proxy pinned to `127.0.0.1`,
|
|
198
|
-
`env_schema:
|
|
199
|
+
`env_schema: object({})` (fuz_schema), `rate_limiters: 'disabled_for_testing'` (every
|
|
199
200
|
rate limiter `null` — a limiter passed through `app_options` wins over the
|
|
200
201
|
mode, so a rate-limit test enables just the one it pins; the mode's stderr
|
|
201
202
|
banner prints once per module instance — once per test file in an isolated
|
|
@@ -220,12 +221,12 @@ the WASM caching in `db.ts` is where the real savings are.
|
|
|
220
221
|
Pre-built Hono apps at each auth level (public / authed / keeper / per-role)
|
|
221
222
|
for attack-surface testing. No middleware stack — a single `/*` middleware
|
|
222
223
|
injects the `ResolvedAuth` (`RESOLVED_AUTH_KEY`, credential type default
|
|
223
|
-
`'session'`) + `REQUEST_CONTEXT_KEY` plus the `TEST_CONTEXT_PRESET_KEY` flag (so the
|
|
224
|
+
`'session'`) + `REQUEST_CONTEXT_KEY` plus the `TEST_CONTEXT_PRESET_KEY` flag, set to the `TEST_CONTEXT_PRESET` symbol (so the
|
|
224
225
|
dispatcher's authorization phase trusts the pre-baked context and skips its
|
|
225
226
|
DB-backed actor resolution), then hands off to `apply_route_specs` with
|
|
226
227
|
`fuz_auth_guard_resolver` + `create_fuz_authorization_handler`. Production
|
|
227
|
-
middleware never sets `TEST_CONTEXT_PRESET_KEY`,
|
|
228
|
-
test-only by construction.
|
|
228
|
+
middleware never sets `TEST_CONTEXT_PRESET_KEY`, and only the symbol counts
|
|
229
|
+
(`has_test_context_preset`), so the escape hatch is test-only by construction.
|
|
229
230
|
|
|
230
231
|
- `create_test_request_context(role?)` — minimal `RequestContext`: one account, one actor, one role_grant for `role` (or none).
|
|
231
232
|
- `create_test_app_from_specs(specs, auth_ctx?, credential_type?)` — Hono app with pre-set context + `apply_route_specs`. `credential_type` defaults to `'session'` when an auth context is supplied — override for `'daemon_token'` / `'api_token'` tests.
|
|
@@ -426,7 +427,7 @@ RPC / WS structural invariants (options-free, apply over `surface.rpc_endpoints`
|
|
|
426
427
|
|
|
427
428
|
* `assert_rpc_method_descriptions_present` — every RPC method on every endpoint has a non-empty `description`.
|
|
428
429
|
* `assert_ws_method_descriptions_present` — every WS method on every endpoint has a non-empty `description`.
|
|
429
|
-
* `assert_ws_endpoints_include_protocol_actions` — every WS endpoint includes `heartbeat` + `cancel` + `peer/ping` (the `protocol_actions` spread from `actions/protocol.
|
|
430
|
+
* `assert_ws_endpoints_include_protocol_actions` — every WS endpoint includes `heartbeat` + `cancel` + `peer/ping` (the `protocol_actions` spread from `actions/protocol.ts`).
|
|
430
431
|
* `assert_ws_notifications_have_null_auth` — WS method `kind === 'remote_notification' ⟺ auth === null`; guards against drift between spec union and surface emitter.
|
|
431
432
|
* `assert_no_testing_methods` — no `_testing_*` backdoor action (`TESTING_METHOD_PREFIX`) appears as an RPC or WS method on the declared surface. The test-binary actions are live-mounted only; this guards against a future wiring change folding `create_testing_actions(...)` into the surface-generating registry.
|
|
432
433
|
|
|
@@ -930,6 +931,7 @@ Request builders:
|
|
|
930
931
|
|
|
931
932
|
- `create_rpc_post_init(method, params?, id?)` — `RequestInit` with JSON-RPC envelope body. `params === undefined || params === null` → envelope has no `params` field (JSON-RPC doesn't accept `"params": null`).
|
|
932
933
|
- `create_rpc_get_url(endpoint_path, method, params?, id?)` — GET URL with `?method=&id=¶ms=<JSON>`.
|
|
934
|
+
- `create_rpc_request_text(method, params_json, id?)` — the request envelope as text with `params_json` spliced in verbatim as `params`, for a spelling `JSON.stringify` loses (`5.0`, `-0`).
|
|
933
935
|
|
|
934
936
|
Response assertions:
|
|
935
937
|
|
|
@@ -942,7 +944,7 @@ One-shot transport:
|
|
|
942
944
|
- `http_transport(app)` — adapter for anything with a `request()` method.
|
|
943
945
|
- `RpcCallResult` — discriminated `{ok: true, status, headers, result}` / `{ok: false, status, headers, error: {code, message, data?}}`. `headers` is the lowercased-key response-header snapshot so callers can assert header-level properties (e.g. the conformance runner's no-fingerprint invariant).
|
|
944
946
|
- `headers_to_record(headers)` — snapshot a `Headers` into a lowercased-key `Record<string, string>` (multi-value collapses to the comma-joined form; `Set-Cookie` excluded). Used by `rpc_call` and the conformance table's REST branch to thread response headers through for assertions.
|
|
945
|
-
- `RpcCallArgs` — `{app, path, method, params?, headers?, id?, verb?}`. `verb` defaults to `'POST'`; use `'GET'` for `side_effects: false` methods.
|
|
947
|
+
- `RpcCallArgs` — `{app, path, method, params?, params_json?, headers?, id?, verb?}`. `verb` defaults to `'POST'`; use `'GET'` for `side_effects: false` methods. `params_json` sends raw JSON text in place of `params` (exclusive with it) on either verb.
|
|
946
948
|
- `rpc_call_raw(args)` — the same request as `rpc_call`, the response unparsed: `RpcCallRawResult` `{status, headers, body}` with the whole envelope. `parse_rpc_call_result(raw, method)` turns it into an `RpcCallResult`; `rpc_call` is the two composed.
|
|
947
949
|
- `rpc_call(args)` — merges `RPC_CALL_DEFAULT_HEADERS` (`host: 'localhost'`, `origin: TEST_ORIGIN`, `Content-Type: 'application/json'`) under caller headers. Envelope-shape violations throw; JSON-RPC errors return `{ok: false, error}` so callers assert on `error.code` / `error.data.reason`.
|
|
948
950
|
- `rpc_call_typed<T>(args, output_schema)` — parses the success `result` through the schema; throws on envelope failure, error response, or schema mismatch. Use `rpc_call` when the test needs to assert on error shapes.
|
|
@@ -993,7 +995,7 @@ Shared conventions (`.db.test.ts` suffix, `isolate: false` semantics,
|
|
|
993
995
|
points:
|
|
994
996
|
|
|
995
997
|
- **`await_pending_effects: true`** is set by `create_test_app`. Fire-and-forget effects (audit logs, api-token usage tracking, WS fan-out via `emit_after_commit`) resolve before the response returns, so tests can assert on side effects inline without manual flushing.
|
|
996
|
-
- **Deep-path imports only.** Import from the canonical module (`testing/db.
|
|
998
|
+
- **Deep-path imports only.** Import from the canonical module (`testing/db.ts`, `testing/rpc_helpers.ts`, etc.); fuz_app's `dist/` ships no barrel.
|
|
997
999
|
- **DI via small `*Deps` interfaces.** Stub factories accept the same narrow `*Deps` contracts production code uses — never `Pick<GodType, ...>`. New helpers needing env/fs/logger take `EnvDeps` / `FsReadDeps` / `Logger` from `runtime/deps.ts` or `@fuzdev/fuz_util/log.ts`.
|
|
998
1000
|
- **Keep the shared echo routes in sync with public surface.** When middleware or public API gains a new context variable, header, or field, update the echo in `middleware.ts` (`create_bearer_auth_test_app`, `create_test_middleware_stack_app`) alongside the assertions in `src/test/auth/*.test.ts`. Drift surfaces as a missed assertion, not a test failure.
|
|
999
1001
|
|
|
@@ -1369,7 +1371,7 @@ conformance cases assert _expected behavior_ — the security negatives
|
|
|
1369
1371
|
wire-shape check passes green on even when behavior is wrong.
|
|
1370
1372
|
|
|
1371
1373
|
- `conformance_case.ts` — `ConformanceCase` Zod schema:
|
|
1372
|
-
`{name, request: {method, params?, as, acting?, verb?}, expect: {status,
|
|
1374
|
+
`{name, request: {method, params?, params_json?, as, acting?, verb?}, expect: {status,
|
|
1373
1375
|
error_reason?, fields?, headers?, equivalence_group?}, note?, xfail?}`. A case is **data** — `method`
|
|
1374
1376
|
resolves its `input`/`output` from the live registry (RPC) or `RouteSpec`
|
|
1375
1377
|
(the 6 REST auth routes), so the case never carries a schema. `as` is the
|
|
@@ -2151,8 +2153,8 @@ are `src/test/auth/cell_crud_parity.db.test.ts`
|
|
|
2151
2153
|
`create_sse_frame_reader`. Built-in `fetch` + `TextDecoder` — no dep.
|
|
2152
2154
|
- `surface_source: AppSurfaceSpec` — the same shape both in-process and
|
|
2153
2155
|
cross-process tests pass. Constructed in TS via
|
|
2154
|
-
`create_test_app_surface_spec` (or a consumer's equivalent
|
|
2155
|
-
|
|
2156
|
+
`create_test_app_surface_spec` (or a consumer's equivalent) — same
|
|
2157
|
+
builder both modes use. The
|
|
2156
2158
|
cross-process-ness lives in `setup_test: default_cross_process_setup(handle)`
|
|
2157
2159
|
— the `FetchTransport`, not the schema source. The on-disk
|
|
2158
2160
|
`*_attack_surface.json` snapshot is an observability artifact for human
|
|
@@ -2804,10 +2806,14 @@ through `timing_env` (`default_backend_configs.ts`), which sets
|
|
|
2804
2806
|
integer of ms up to 2³¹ − 1 and refuse to boot on anything else; unset keeps
|
|
2805
2807
|
the defaults (`SSE_KEEP_ALIVE_INTERVAL_MS`, `DEFAULT_WS_RECEIVE_TIMEOUT`).
|
|
2806
2808
|
fuz_app's `cross_backend_timing` project shortens both, so its suites watch
|
|
2807
|
-
each spine's timers fire within seconds.
|
|
2809
|
+
each spine's timers fire within seconds. `db_checkout_timeout_ms` and
|
|
2810
|
+
`db_audit_checkout_timeout_ms` set the production pool checkout bounds
|
|
2811
|
+
(`FUZ_DB_CHECKOUT_TIMEOUT_MS`, `FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS`) the same
|
|
2812
|
+
way; the timing project boots both spines with them shortened.
|
|
2808
2813
|
Cross-process only; fuz_app's own wiring is
|
|
2809
|
-
`src/test/cross_backend/sse_keep_alive.cross.test.ts
|
|
2810
|
-
`src/test/cross_backend/ws_receive_timeout.cross.test.ts
|
|
2814
|
+
`src/test/cross_backend/sse_keep_alive.cross.test.ts`,
|
|
2815
|
+
`src/test/cross_backend/ws_receive_timeout.cross.test.ts` and
|
|
2816
|
+
`src/test/cross_backend/db_checkout_timeout.cross.test.ts`, under the
|
|
2811
2817
|
`cross_backend_timing` project.
|
|
2812
2818
|
|
|
2813
2819
|
### Role-gated participation parity — `cross_backend/role_grant_participation.ts`
|
|
@@ -2903,8 +2909,8 @@ re-roll the serve / daemon-info / WS-attach / drain boilerplate:
|
|
|
2903
2909
|
- `testing/cross_backend/testing_server_core.ts` — `start_testing_server({adapter, daemon_name, host, port, app_version?, build_app})`. Owns the runtime-neutral orchestration: open-host refusal, stale-daemon check, daemon-info write, `serve`, post-serve WS attach, graceful shutdown. Domain-free — the app is the caller's `build_app(context: BuildTestingAppContext): Promise<BuiltTestingApp>` seam (`{app, close}`). WebSocket endpoints mount through `create_app_server`'s `ws_endpoints` on every runtime: the build calls `context.prepare_websocket({max_message_bytes?})`, which asks the adapter for a `PreparedWebsocket` (`{create_upgrade_websocket: (app) => UpgradeWebSocket, attach_to_server?}`) and returns its factory, to pass as `create_upgrade_websocket`; the core runs each `attach_to_server` once `serve` returns (Node's `injectWebSocket`). Shutdown starts the listener's `shutdown` (stop accepting), runs `close` — which must end live WebSockets, as `AppServer.close` does — then awaits the drain, since open sockets would otherwise hold it. Exports the `TestingServerAdapter` (`prepare_websocket: (options?: PrepareWebsocketOptions) => PreparedWebsocket`) / `ServeHandle` / `PreparedWebsocket` / `PrepareWebsocketOptions` / `BuildTestingAppContext` interfaces.
|
|
2904
2910
|
- `testing/daemon_info.ts` — the `~/.{name}/run/daemon.json` plumbing the core's stale-daemon check and daemon-info write use: `DaemonInfo` (a strict `@fuzdev/fuz_schema` object), `get_app_dir`, `get_daemon_info_path`, `write_daemon_info` (atomic), `read_daemon_info`, `is_daemon_running` (`kill -0`).
|
|
2905
2911
|
- `testing/cross_backend/testing_server_node.ts` — `create_node_testing_adapter()` (`@hono/node-server` + `@hono/node-ws`). Optional peer deps (like `ws`); only test binaries import them. Its factory sets the `ws` server's `maxPayload` to twice `max_message_bytes` (default `DEFAULT_WS_MAX_MESSAGE_BYTES`) — `@hono/node-ws` takes no option for it, and `ws`'s own default is 100 MiB — so a grossly oversized message is refused at the frame layer (`WS_CLOSE_MESSAGE_TOO_BIG` with no reason) before it is buffered whole, while one just over the limit reaches the per-message check, which sends `WS_CLOSE_MESSAGE_TOO_BIG_REASON` as every other backend does. Bun's adapter sets the same multiple as its frame cap (see below); Deno takes no frame cap and keeps the per-message check alone.
|
|
2906
|
-
- `testing/cross_backend/testing_server_deno.ts` — `create_deno_testing_adapter()` (`Deno.serve` + `@hono/deno`, an optional peer dep; `Deno` declared locally so it typechecks under the Node toolchain).
|
|
2907
|
-
- `testing/cross_backend/testing_server_bun.ts` — `create_bun_testing_adapter()` (`Bun.serve` + `@hono/bun`'s module-level `getConnInfo`, `upgradeWebSocket`, and `websocket`; `Bun.serve` declared locally so it typechecks under the Node toolchain). Needs the optional `@hono/bun` peer dep (the counterpart to Node's `@hono/node-server` + `@hono/node-ws`; `Bun.serve` is built in)
|
|
2912
|
+
- `testing/cross_backend/testing_server_deno.ts` — `create_deno_testing_adapter()` (`Deno.serve` + `@hono/deno`, an optional peer dep; `Deno` declared locally so it typechecks under the Node toolchain).
|
|
2913
|
+
- `testing/cross_backend/testing_server_bun.ts` — `create_bun_testing_adapter()` (`Bun.serve` + `@hono/bun`'s module-level `getConnInfo`, `upgradeWebSocket`, and `websocket`; `Bun.serve` declared locally so it typechecks under the Node toolchain). Needs the optional `@hono/bun` peer dep (the counterpart to Node's `@hono/node-server` + `@hono/node-ws`; `Bun.serve` is built in). Reuses `create_node_runtime` (Bun implements the `node:fs`/`node:process` surface). WS is module-level + stateless (like Deno) — the `websocket` handler is threaded into `serve`, where `Bun.serve` wants it, so no post-serve attach. It carries `maxPayloadLength` at twice `max_message_bytes` rather than Bun's 16 MiB default: past its cap Bun drops the socket without a close frame (1006), so the headroom leaves a message just over the limit to the per-message check (`WS_CLOSE_MESSAGE_TOO_BIG`, as on Node), while a grossly oversized one is refused before Bun buffers it whole.
|
|
2908
2914
|
- `testing/cross_backend/default_spine_surface.ts` — the canonical no-domain spine surface (account/admin/audit/signup + bootstrap): `spine_session_options`, `spine_roles`, `create_spine_route_specs`, `spine_rpc_endpoints`, `create_spine_surface_spec`. This is the **declared** surface — the `create_standard_rpc_actions` bundle the spec-derived suites auto-enumerate. It passes `daemon_token: true` (both spine binaries mount the daemon-token layer) and leaves `GET /api/surface` at its default, off — the TS spine binary does too, and the Rust `testing_spine_stub` serves none. Shared by the spine_stub cross test, the TS cross tests, and the binary.
|
|
2909
2915
|
- `testing/cross_backend/full_spine_mount.ts` — `build_full_spine_rpc_actions(deps, options)` — the **full** live RPC mount: the declared bundle **plus** the off-declared-surface families the binary live-mounts (`_testing_*` backdoors, the cell verb set, the opt-in `actor_lookup` / `actor_search` resolvers). `build_full_spine_mount(deps, options)` builds it once for both of the binary's endpoints, returning `FullSpineMount` (`{rpc_actions, ws_actions}`): the WS list is `protocol_actions` plus every RPC action not already among them, twinning the Rust `testing_spine_stub`, which serves one registry on RPC and WS (the one difference is `cancel` — a registered protocol action on TS, owned by the read loop on Rust). Single-sources the mount so the binary and the `spine_method_coverage` reconciliation test build the same list. `create_spine_live_rpc_endpoints()` wraps the list, built on stub deps, as one endpoint at `SPINE_RPC_PATH` — the `live_rpc_endpoints` value the conformance table, the differential and the auth-row generator resolve off-surface methods from (no handler built there runs).
|
|
2910
2916
|
- `testing/cross_backend/ts_spine_backend_config.ts` — `ts_spine_node_backend_config()` / `ts_spine_deno_backend_config()` / `ts_spine_bun_backend_config()` presets (in-memory pglet, no external infra), the TS analog of `rust_spine_stub_backend_config()`.
|
|
@@ -2970,7 +2976,7 @@ real HTTP). A thin
|
|
|
2970
2976
|
scenario→task→report adapter over `@fuzdev/fuz_util`'s benchmark library
|
|
2971
2977
|
(`Benchmark`, `benchmark_stats_compare`, `benchmark_format_markdown`) —
|
|
2972
2978
|
no stats engine reinvented. fuz_app ships the primitive; consumers wire
|
|
2973
|
-
scenarios + the run
|
|
2979
|
+
scenarios + the run.
|
|
2974
2980
|
fuz_app also ships its **own** `npm run benchmark:cross-impl`
|
|
2975
2981
|
(`src/benchmarks/cross_impl.bench.ts`) on the back of its TS spine binary —
|
|
2976
2982
|
ts-node + ts-deno + ts-bun (+ the Rust `spine_stub` when `FUZ_TESTING_RUST_SPINE_STUB_BIN`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
import {
|
|
2
|
+
import { object } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
3
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
4
4
|
import { DEFAULT_TEST_PASSWORD } from './test_credentials.js';
|
|
5
5
|
import { ROLE_KEEPER } from '../auth/role_schema.js';
|
|
@@ -280,7 +280,7 @@ export const create_loopback_app_server_options = () => {
|
|
|
280
280
|
return {
|
|
281
281
|
allowed_origins: parsed.origins,
|
|
282
282
|
proxy: { trusted_proxies: ['127.0.0.1'], get_connection_ip: () => '127.0.0.1' },
|
|
283
|
-
env_schema:
|
|
283
|
+
env_schema: object({})
|
|
284
284
|
};
|
|
285
285
|
};
|
|
286
286
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_drift_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/audit_drift_guard.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAW7B,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGN,KAAK,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AAO,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,2BAA2B,GACvC,OAAO,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC,EACrE,UAAU,+BAA+B,KACvC,IAcF,CAAC"}
|
|
@@ -91,6 +91,7 @@ export const create_recording_audit_emitter = (calls_ref) => {
|
|
|
91
91
|
const emitter = {
|
|
92
92
|
emit: (_ctx, input) => {
|
|
93
93
|
calls.push(input);
|
|
94
|
+
return Promise.resolve();
|
|
94
95
|
},
|
|
95
96
|
emit_role_grant_target: (ctx, auth, input) => {
|
|
96
97
|
calls.push({
|
|
@@ -103,6 +104,7 @@ export const create_recording_audit_emitter = (calls_ref) => {
|
|
|
103
104
|
ip: ctx.client_ip,
|
|
104
105
|
metadata: input.metadata
|
|
105
106
|
});
|
|
107
|
+
return Promise.resolve();
|
|
106
108
|
},
|
|
107
109
|
emit_pool: (input) => {
|
|
108
110
|
calls.push(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_apps.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/auth_apps.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAIN,KAAK,qBAAqB,EAC1B,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth_apps.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/auth_apps.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AAEH,OAAO,EAAE,I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