@fuzdev/fuz_app 0.152.0 → 0.153.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/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/realtime/audit_log_sse.d.ts +2 -2
- package/dist/realtime/audit_log_sse.js +2 -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 +1 -1
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +6 -1
- package/dist/server/env.d.ts +8 -3
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +26 -4
- package/dist/testing/CLAUDE.md +22 -16
- 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.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 +3 -7
|
@@ -15,7 +15,8 @@ import { create_audit_emitter } from '../auth/audit_emitter.js';
|
|
|
15
15
|
import { create_realtime_closer } from '../actions/connection_closer.js';
|
|
16
16
|
import { run_migrations } from '../db/migrate.js';
|
|
17
17
|
import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
|
|
18
|
-
import { create_db } from '../db/create_db.js';
|
|
18
|
+
import { create_db, is_pg_database_url } from '../db/create_db.js';
|
|
19
|
+
import { DEFAULT_DB_AUDIT_CHECKOUT_TIMEOUT_MS } from '../db/db_pg.js';
|
|
19
20
|
/**
|
|
20
21
|
* Trivial `AuditFactory` for consumers that don't compose `on_audit_event`
|
|
21
22
|
* or `audit_log_config`. Equivalent to
|
|
@@ -33,6 +34,7 @@ export const default_audit_factory = ({ db, log }) => create_audit_emitter({ db,
|
|
|
33
34
|
*
|
|
34
35
|
* Calls `create_db` → `run_migrations` (auth namespace, then any
|
|
35
36
|
* `migration_namespaces` from options in order) → `audit_factory({db, log})`
|
|
37
|
+
* (`db` with the audit checkout bound)
|
|
36
38
|
* and bundles the result with the provided keyring and password deps and a
|
|
37
39
|
* `connection_closer` (empty until `create_app_server` adds its transports).
|
|
38
40
|
*
|
|
@@ -43,7 +45,15 @@ export const default_audit_factory = ({ db, log }) => create_audit_emitter({ db,
|
|
|
43
45
|
export const create_app_backend = async (options) => {
|
|
44
46
|
const { database_url, keyring, password, read_secure_file, delete_file, audit_factory } = options;
|
|
45
47
|
const log = options.log ?? new Logger('server');
|
|
46
|
-
const { db, close, db_type, db_name } = await create_db(database_url
|
|
48
|
+
const { db, close, db_type, db_name } = await create_db(database_url, {
|
|
49
|
+
checkout_timeout_ms: options.db_checkout_timeout_ms
|
|
50
|
+
});
|
|
51
|
+
// set but inert: fail loud rather than let an operator believe it applies
|
|
52
|
+
if (!is_pg_database_url(database_url) &&
|
|
53
|
+
(options.db_checkout_timeout_ms !== undefined ||
|
|
54
|
+
options.db_audit_checkout_timeout_ms !== undefined)) {
|
|
55
|
+
log.warn(`${db_type} has no connection pool; FUZ_DB_CHECKOUT_TIMEOUT_MS and FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS have no effect`);
|
|
56
|
+
}
|
|
47
57
|
// Everything after `create_db` can throw — `run_migrations` (its
|
|
48
58
|
// `MigrationError` kinds include the reserved-namespace refusal),
|
|
49
59
|
// `audit_factory`.
|
|
@@ -55,7 +65,10 @@ export const create_app_backend = async (options) => {
|
|
|
55
65
|
AUTH_MIGRATION_NS,
|
|
56
66
|
...(options.migration_namespaces ?? [])
|
|
57
67
|
]);
|
|
58
|
-
const audit = audit_factory({
|
|
68
|
+
const audit = audit_factory({
|
|
69
|
+
db: db.with_checkout_timeout(options.db_audit_checkout_timeout_ms ?? DEFAULT_DB_AUDIT_CHECKOUT_TIMEOUT_MS),
|
|
70
|
+
log
|
|
71
|
+
});
|
|
59
72
|
return {
|
|
60
73
|
db_type,
|
|
61
74
|
db_name,
|
|
@@ -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
|
+
};
|
|
@@ -626,7 +626,7 @@ export declare const collect_config_diagnostics: (input: ConfigDiagnosticsInput)
|
|
|
626
626
|
* to `backend.deps.connection_closer`, so the revocation handlers built from
|
|
627
627
|
* `ctx.deps` close their connections with no further wiring, and — when the
|
|
628
628
|
* server mounts either — one `create_revocation_guard` listener on that closer
|
|
629
|
-
* repeats each close on the audit row
|
|
629
|
+
* repeats each close on the audit row.
|
|
630
630
|
* The
|
|
631
631
|
* `audit_sse` field on the returned `AppServer` (and the
|
|
632
632
|
* `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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,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"}
|
|
@@ -20,6 +20,7 @@ import '../hono_context.js';
|
|
|
20
20
|
import { create_proxy_middleware_spec } from '../http/proxy.js';
|
|
21
21
|
import { create_static_middleware } from './static.js';
|
|
22
22
|
import { log_startup_summary } from './startup.js';
|
|
23
|
+
import { create_app_error_handler } from './app_error_handler.js';
|
|
23
24
|
import { create_app_surface_spec } from '../http/surface.js';
|
|
24
25
|
import { apply_middleware_specs, apply_route_specs, prefix_route_specs } from '../http/route_spec.js';
|
|
25
26
|
import { check_bootstrap_status, create_bootstrap_route_specs } from '../auth/bootstrap_routes.js';
|
|
@@ -207,7 +208,7 @@ export const collect_config_diagnostics = (input) => {
|
|
|
207
208
|
* to `backend.deps.connection_closer`, so the revocation handlers built from
|
|
208
209
|
* `ctx.deps` close their connections with no further wiring, and — when the
|
|
209
210
|
* server mounts either — one `create_revocation_guard` listener on that closer
|
|
210
|
-
* repeats each close on the audit row
|
|
211
|
+
* repeats each close on the audit row.
|
|
211
212
|
* The
|
|
212
213
|
* `audit_sse` field on the returned `AppServer` (and the
|
|
213
214
|
* `AppServerContext` passed to `create_route_specs`) is non-null in that
|
|
@@ -502,6 +503,10 @@ const assemble_app_server = async (options, releases) => {
|
|
|
502
503
|
log_startup_summary(surface_spec.surface, log, options.env_values);
|
|
503
504
|
// Hono app assembly
|
|
504
505
|
const app = new Hono();
|
|
506
|
+
// A throw that escapes every route catch — a credential leg's failed read
|
|
507
|
+
// above all — answers here: 503 for a failed pool checkout, Hono's default
|
|
508
|
+
// 500 for anything else.
|
|
509
|
+
app.onError(create_app_error_handler(log));
|
|
505
510
|
// Two-queue side-effect flush. `pending_effects` collects eager
|
|
506
511
|
// fire-and-forget promises (audit emits, api-token usage). `post_commit_effects` collects deferred thunks pushed via
|
|
507
512
|
// `emit_after_commit` (WS notifications, anything that must observe a
|
package/dist/server/env.d.ts
CHANGED
|
@@ -14,9 +14,12 @@ import { type Keyring } from '../auth/keyring.js';
|
|
|
14
14
|
/**
|
|
15
15
|
* Base Zod schema for server environment variables.
|
|
16
16
|
*
|
|
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`.
|
|
17
|
+
* Declares only what the spine reads — server config, database and its pool
|
|
18
|
+
* checkout bounds, cookie keys, allowed origins and the wildcard opt-in, and
|
|
19
|
+
* the bootstrap token path — matching the Rust spine's `BaseServerEnv`. The
|
|
20
|
+
* numeric vars parse as loosely as `PORT` (`z.coerce`, so `5e3` reads as 5000
|
|
21
|
+
* where the Rust twin refuses it); a blank or out-of-range value is refused on
|
|
22
|
+
* both. Anything else (fact storage,
|
|
20
23
|
* X-Accel delivery, public URLs) is the app's own var: extend with
|
|
21
24
|
* app-specific fields via `.extend()`.
|
|
22
25
|
*/
|
|
@@ -35,6 +38,8 @@ export declare const BaseServerEnv: z.ZodObject<{
|
|
|
35
38
|
false: "false";
|
|
36
39
|
}>>;
|
|
37
40
|
FUZ_BOOTSTRAP_TOKEN_PATH: z.ZodOptional<z.ZodString>;
|
|
41
|
+
FUZ_DB_CHECKOUT_TIMEOUT_MS: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
42
|
+
FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
38
43
|
}, z.core.$strict>;
|
|
39
44
|
export type BaseServerEnv = z.infer<typeof BaseServerEnv>;
|
|
40
45
|
/**
|
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;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAKlE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;kBAiDxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;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
|
@@ -12,12 +12,16 @@ import { z } from 'zod';
|
|
|
12
12
|
import { create_keyring } from '../auth/keyring.js';
|
|
13
13
|
import { format_allowed_origins_error, parse_allowed_origins } from '../http/origin.js';
|
|
14
14
|
import { admit_origin_wildcards } from '../http/origin_wildcard.js';
|
|
15
|
+
import { DB_CHECKOUT_TIMEOUT_MAX_MS } from '../db/db_pg.js';
|
|
15
16
|
/**
|
|
16
17
|
* Base Zod schema for server environment variables.
|
|
17
18
|
*
|
|
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`.
|
|
19
|
+
* Declares only what the spine reads — server config, database and its pool
|
|
20
|
+
* checkout bounds, cookie keys, allowed origins and the wildcard opt-in, and
|
|
21
|
+
* the bootstrap token path — matching the Rust spine's `BaseServerEnv`. The
|
|
22
|
+
* numeric vars parse as loosely as `PORT` (`z.coerce`, so `5e3` reads as 5000
|
|
23
|
+
* where the Rust twin refuses it); a blank or out-of-range value is refused on
|
|
24
|
+
* both. Anything else (fact storage,
|
|
21
25
|
* X-Accel delivery, public URLs) is the app's own var: extend with
|
|
22
26
|
* app-specific fields via `.extend()`.
|
|
23
27
|
*/
|
|
@@ -48,7 +52,25 @@ export const BaseServerEnv = z.strictObject({
|
|
|
48
52
|
FUZ_BOOTSTRAP_TOKEN_PATH: z
|
|
49
53
|
.string()
|
|
50
54
|
.optional()
|
|
51
|
-
.meta({ description: 'Path to one-shot admin bootstrap token', sensitivity: 'secret' })
|
|
55
|
+
.meta({ description: 'Path to one-shot admin bootstrap token', sensitivity: 'secret' }),
|
|
56
|
+
FUZ_DB_CHECKOUT_TIMEOUT_MS: z.coerce
|
|
57
|
+
.number()
|
|
58
|
+
.int()
|
|
59
|
+
.min(1)
|
|
60
|
+
.max(DB_CHECKOUT_TIMEOUT_MAX_MS)
|
|
61
|
+
.optional()
|
|
62
|
+
.meta({
|
|
63
|
+
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'
|
|
64
|
+
}),
|
|
65
|
+
FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS: z.coerce
|
|
66
|
+
.number()
|
|
67
|
+
.int()
|
|
68
|
+
.min(1)
|
|
69
|
+
.max(DB_CHECKOUT_TIMEOUT_MAX_MS)
|
|
70
|
+
.optional()
|
|
71
|
+
.meta({
|
|
72
|
+
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'
|
|
73
|
+
})
|
|
52
74
|
});
|
|
53
75
|
/**
|
|
54
76
|
* Validate a loaded `BaseServerEnv` and produce the artifacts needed for server init.
|
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.
|
|
@@ -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 +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,iBAAiB,EACtB,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,yBAAyB,QAAO,IAO5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAgBxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,YAAY,KAAK,CAAC,aAAa,CAAC,KAC9B,
|
|
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,iBAAiB,EACtB,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,yBAAyB,QAAO,IAO5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAgBxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,YAAY,KAAK,CAAC,aAAa,CAAC,KAC9B,qBAwCF,CAAC;AA2BF,iDAAiD;AACjD,MAAM,WAAW,+BAA+B;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,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,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;AAUpC;;GAEG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,cAI1D,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACtC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,WAAW,cAAc,EACzB,kBAAkB,qBAAqB,KACrC,IA4BF,CAAC;AAEF,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb;;;;;;;;OAQG;IACH,kBAAkB,EAAE,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;IACrD,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GACjC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,KAClB,YAsBF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,YAAY,EAAE,MAAM,SAAS,KAAG,IAwBrE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,KACpC,CAAC,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAGvD,CAAC"}
|
|
@@ -15,7 +15,7 @@ import { BUILTIN_CREDENTIAL_TYPES, CREDENTIAL_TYPE_DAEMON_TOKEN, CREDENTIAL_TYPE
|
|
|
15
15
|
import { ROLE_KEEPER } from '../auth/role_schema.js';
|
|
16
16
|
import { fuz_auth_guard_resolver } from '../auth/auth_guard_resolver.js';
|
|
17
17
|
import { REQUEST_CONTEXT_KEY, create_fuz_authorization_handler } from '../auth/request_context.js';
|
|
18
|
-
import { RESOLVED_AUTH_KEY, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
|
|
18
|
+
import { RESOLVED_AUTH_KEY, TEST_CONTEXT_PRESET, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
|
|
19
19
|
import { create_test_resolved_auth } from './resolved_auth.js';
|
|
20
20
|
import { create_stub_db } from './stubs.js';
|
|
21
21
|
import { create_test_account, create_test_actor, create_test_role_grant } from './entities.js';
|
|
@@ -46,7 +46,7 @@ export const create_test_app_from_specs = (route_specs, auth_ctx, credential_typ
|
|
|
46
46
|
account_id: auth_ctx.account.id
|
|
47
47
|
}));
|
|
48
48
|
c.set(REQUEST_CONTEXT_KEY, auth_ctx);
|
|
49
|
-
c.set(TEST_CONTEXT_PRESET_KEY,
|
|
49
|
+
c.set(TEST_CONTEXT_PRESET_KEY, TEST_CONTEXT_PRESET);
|
|
50
50
|
}
|
|
51
51
|
await next();
|
|
52
52
|
});
|
|
@@ -154,6 +154,7 @@ export type ConformanceActingBinding = z.infer<typeof ConformanceActingBinding>;
|
|
|
154
154
|
export declare const ConformanceCaseRequest: z.ZodObject<{
|
|
155
155
|
method: z.ZodString;
|
|
156
156
|
params: z.ZodOptional<z.ZodUnknown>;
|
|
157
|
+
params_json: z.ZodOptional<z.ZodString>;
|
|
157
158
|
as: z.ZodEnum<{
|
|
158
159
|
keeper: "keeper";
|
|
159
160
|
token: "token";
|
|
@@ -217,6 +218,7 @@ export declare const ConformanceCase: z.ZodObject<{
|
|
|
217
218
|
request: z.ZodObject<{
|
|
218
219
|
method: z.ZodString;
|
|
219
220
|
params: z.ZodOptional<z.ZodUnknown>;
|
|
221
|
+
params_json: z.ZodOptional<z.ZodString>;
|
|
220
222
|
as: z.ZodEnum<{
|
|
221
223
|
keeper: "keeper";
|
|
222
224
|
token: "token";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance_case.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/conformance_case.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;EAc/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,mBAAmB,CAAC;AAE7D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,MAAM,oBAAoB;;;kBAK/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAS1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -155,6 +155,14 @@ export const ConformanceCaseRequest = z.strictObject({
|
|
|
155
155
|
.unknown()
|
|
156
156
|
.optional()
|
|
157
157
|
.meta({ description: 'Request params / body. Omit for nullary methods.' }),
|
|
158
|
+
params_json: z
|
|
159
|
+
.string()
|
|
160
|
+
.optional()
|
|
161
|
+
.meta({
|
|
162
|
+
description: 'RPC params as raw JSON text, sent verbatim in place of `params` — for a ' +
|
|
163
|
+
'spelling `JSON.stringify` loses (`5.0`, `1e1`, `-0`). Exclusive with ' +
|
|
164
|
+
'`params` and `acting`; RPC methods only.'
|
|
165
|
+
}),
|
|
158
166
|
as: ConformancePrincipal,
|
|
159
167
|
acting: ConformanceActingBinding.optional().meta({
|
|
160
168
|
description: 'Bind `params.acting` at run time to the named actor (`ConformanceActingBinding`). ' +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance_table.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/conformance_table.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8C9B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOnE,OAAO,
|
|
1
|
+
{"version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,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GACjC,GAAG,eAAe,EAClB,SAAS,0BAA0B,KACjC,OAAO,CAAC,uBAAuB,CAuFjC,CAAC;AA8NF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,uBAAuB,KAAG,IAuEnF,CAAC"}
|
|
@@ -43,7 +43,7 @@ import '../assert_dev_env.js';
|
|
|
43
43
|
import { assert, describe, test } from 'vitest';
|
|
44
44
|
import { DAEMON_TOKEN_HEADER } from '../../auth/daemon_token.js';
|
|
45
45
|
import { find_auth_route, rest_auth_route_suffixes } from '../integration_helpers.js';
|
|
46
|
-
import { find_rpc_action, headers_to_record, parse_rpc_call_result, rpc_call_raw, resolve_rpc_endpoints_for_setup } from '../rpc_helpers.js';
|
|
46
|
+
import { find_rpc_action, headers_to_record, parse_rpc_call_result, rpc_call_raw, create_rpc_request_text, resolve_rpc_endpoints_for_setup } from '../rpc_helpers.js';
|
|
47
47
|
import { account_token_create_action_spec } from '../../auth/account_action_specs.js';
|
|
48
48
|
import { jsonrpc_error_code_to_http_status } from '../../http/jsonrpc_errors.js';
|
|
49
49
|
import { create_admitted_ws_transport } from '../transports/ws_transport.js';
|
|
@@ -401,10 +401,17 @@ export const send_conformance_case = async (c, options) => {
|
|
|
401
401
|
const headers = request_headers
|
|
402
402
|
? { ...request_headers, ...principal.headers }
|
|
403
403
|
: principal.headers;
|
|
404
|
+
const { params_json } = c.request;
|
|
405
|
+
if (params_json !== undefined && (c.request.params !== undefined || c.request.acting)) {
|
|
406
|
+
throw new Error(`conformance: case '${c.name}' sets params_json, so it can't also set params or acting.`);
|
|
407
|
+
}
|
|
404
408
|
const params = c.request.acting
|
|
405
409
|
? bind_acting(c, resolve_acting_binding(c, c.request.acting, fixture, principal))
|
|
406
410
|
: c.request.params;
|
|
407
411
|
if (c.request.method.startsWith('/')) {
|
|
412
|
+
if (params_json !== undefined) {
|
|
413
|
+
throw new Error(`conformance: case '${c.name}' sets params_json, which only RPC methods take.`);
|
|
414
|
+
}
|
|
408
415
|
const suffix = c.request.method;
|
|
409
416
|
if (!rest_auth_route_suffixes.includes(suffix)) {
|
|
410
417
|
throw new Error(`conformance: REST method '${c.request.method}' is not a known auth-route suffix ` +
|
|
@@ -438,7 +445,7 @@ export const send_conformance_case = async (c, options) => {
|
|
|
438
445
|
if (ws) {
|
|
439
446
|
return {
|
|
440
447
|
target: { kind: 'rpc', ...found },
|
|
441
|
-
...(await send_ws_frame(c.request.method, params, principal, ws))
|
|
448
|
+
...(await send_ws_frame(c.request.method, params, params_json, principal, ws))
|
|
442
449
|
};
|
|
443
450
|
}
|
|
444
451
|
const raw = await rpc_call_raw({
|
|
@@ -446,6 +453,7 @@ export const send_conformance_case = async (c, options) => {
|
|
|
446
453
|
path: found.path,
|
|
447
454
|
method: c.request.method,
|
|
448
455
|
params,
|
|
456
|
+
...(params_json !== undefined && { params_json }),
|
|
449
457
|
headers,
|
|
450
458
|
...(c.request.verb && { verb: c.request.verb }),
|
|
451
459
|
...(suppress_default_origin && { suppress_default_origin: true })
|
|
@@ -473,7 +481,7 @@ const CONFORMANCE_REQUEST_ID = 'test';
|
|
|
473
481
|
* (a request that revokes its own credential closes the socket after its
|
|
474
482
|
* reply).
|
|
475
483
|
*/
|
|
476
|
-
const send_ws_frame = async (method, params, principal, ws) => {
|
|
484
|
+
const send_ws_frame = async (method, params, params_json, principal, ws) => {
|
|
477
485
|
const client = await create_admitted_ws_transport({
|
|
478
486
|
base_url: ws.base_url,
|
|
479
487
|
ws_path: principal.actor_id === undefined
|
|
@@ -484,10 +492,19 @@ const send_ws_frame = async (method, params, principal, ws) => {
|
|
|
484
492
|
origin: principal.suppress_default_origin ? null : (ws.origin ?? ws.base_url)
|
|
485
493
|
});
|
|
486
494
|
try {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
495
|
+
if (params_json === undefined) {
|
|
496
|
+
const frame = {
|
|
497
|
+
jsonrpc: '2.0',
|
|
498
|
+
id: CONFORMANCE_REQUEST_ID,
|
|
499
|
+
method
|
|
500
|
+
};
|
|
501
|
+
if (params !== undefined && params !== null)
|
|
502
|
+
frame.params = params;
|
|
503
|
+
await client.send(frame);
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
await client.send_text(create_rpc_request_text(method, params_json, CONFORMANCE_REQUEST_ID));
|
|
507
|
+
}
|
|
491
508
|
const body = await client.wait_for(is_response_for(CONFORMANCE_REQUEST_ID));
|
|
492
509
|
const code = body.error?.code;
|
|
493
510
|
const status = body.error === undefined
|
|
@@ -37,6 +37,10 @@ export interface TimingEnvOptions {
|
|
|
37
37
|
readonly audit_sse_keep_alive_ms?: number;
|
|
38
38
|
/** The WS endpoints' receive timeout in ms (`WS_RECEIVE_TIMEOUT_MS_ENV`). */
|
|
39
39
|
readonly ws_receive_timeout_ms?: number;
|
|
40
|
+
/** The pool checkout bound of a request in ms (`FUZ_DB_CHECKOUT_TIMEOUT_MS`). */
|
|
41
|
+
readonly db_checkout_timeout_ms?: number;
|
|
42
|
+
/** The pool checkout bound of an audit write in ms (`FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS`). */
|
|
43
|
+
readonly db_audit_checkout_timeout_ms?: number;
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* The `extra_env` entries carrying the timing overrides, shared by the TS and
|