@fuzdev/fuz_app 0.183.0 → 0.185.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 +538 -1223
- package/dist/actions/action_codegen.d.ts +1 -1
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +3 -2
- package/dist/actions/connection_closer.d.ts +11 -9
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +11 -9
- package/dist/actions/frontend_rpc_client.d.ts +1 -1
- package/dist/actions/register_action_ws.d.ts +21 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +2 -1
- package/dist/actions/ws_socket_session.d.ts +25 -4
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +81 -25
- package/dist/auth/CLAUDE.md +433 -1048
- package/dist/auth/account_queries.d.ts +1 -1
- package/dist/auth/account_queries.js +1 -1
- package/dist/auth/account_routes.d.ts +4 -5
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +8 -10
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +10 -11
- package/dist/auth/api_token.d.ts +20 -3
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +28 -9
- package/dist/auth/api_token_queries.d.ts +2 -2
- package/dist/auth/api_token_queries.js +2 -2
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +3 -2
- package/dist/auth/audit_log_schema.d.ts +15 -9
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -2
- package/dist/auth/auth_guard_resolver.d.ts +1 -1
- package/dist/auth/auth_guard_resolver.js +1 -1
- package/dist/auth/bearer_auth.d.ts +2 -5
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +4 -13
- package/dist/auth/bootstrap_account.d.ts +13 -15
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +9 -11
- package/dist/auth/bootstrap_routes.d.ts +20 -21
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +21 -19
- package/dist/auth/bootstrap_token_store.d.ts +3 -4
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
- package/dist/auth/bootstrap_token_store.js +1 -1
- package/dist/auth/cleanup.d.ts +34 -3
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +11 -3
- package/dist/auth/daemon_token.d.ts +5 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.d.ts +12 -8
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +15 -21
- package/dist/auth/deps.d.ts +11 -0
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +51 -3
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +81 -6
- package/dist/auth/invite_schema.d.ts +2 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/middleware.d.ts +2 -3
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +3 -3
- package/dist/auth/request_context.d.ts +3 -3
- package/dist/auth/request_context.js +3 -3
- package/dist/auth/role_grant_offer_actions.d.ts +2 -2
- package/dist/auth/role_grant_offer_actions.js +2 -2
- package/dist/auth/session_cookie.d.ts +82 -174
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +80 -130
- package/dist/auth/session_middleware.d.ts +8 -17
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +14 -23
- package/dist/auth/session_queries.d.ts +9 -14
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +8 -9
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +4 -6
- package/dist/db/CLAUDE.md +5 -3
- package/dist/dev/setup.d.ts +3 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +3 -1
- package/dist/http/CLAUDE.md +315 -768
- package/dist/http/db_routes.d.ts +1 -1
- package/dist/http/db_routes.js +1 -1
- package/dist/http/origin.d.ts +7 -8
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +7 -8
- package/dist/http/pending_effects.d.ts +82 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +82 -4
- package/dist/http/route_result.d.ts +1 -1
- package/dist/http/route_spec.d.ts +17 -14
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/realtime/audit_log_sse.d.ts +1 -1
- package/dist/realtime/sse.d.ts +6 -25
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -25
- package/dist/realtime/sse_constants.d.ts +1 -1
- package/dist/realtime/sse_constants.js +1 -1
- package/dist/server/app_backend.d.ts +4 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +3 -1
- package/dist/server/app_server.d.ts +87 -76
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +111 -91
- package/dist/server/app_server_context.d.ts +1 -2
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.js +2 -2
- package/dist/server/shutdown_drain.d.ts +69 -0
- package/dist/server/shutdown_drain.d.ts.map +1 -0
- package/dist/server/shutdown_drain.js +77 -0
- package/dist/testing/CLAUDE.md +89 -57
- package/dist/testing/admin_integration.d.ts +4 -5
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +39 -23
- package/dist/testing/app_server.d.ts +3 -8
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +10 -9
- package/dist/testing/attack_surface.d.ts +1 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/audit_completeness.d.ts +2 -3
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +1 -1
- package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
- package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/bootstrap_backend.js +5 -1
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -1
- package/dist/testing/cross_backend/capability_mounts.js +16 -11
- package/dist/testing/cross_backend/conformance_table.d.ts +5 -6
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +4 -4
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
- package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
- package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +4 -9
- package/dist/testing/cross_backend/differential.d.ts +2 -3
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +1 -1
- package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +45 -4
- package/dist/testing/cross_backend/in_process_setup.d.ts +7 -8
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +10 -13
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
- package/dist/testing/cross_backend/setup.d.ts +1 -1
- package/dist/testing/cross_backend/spawn_backend.d.ts +14 -0
- package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
- package/dist/testing/cross_backend/spawn_backend.js +56 -8
- package/dist/testing/cross_backend/spine_suites.d.ts +18 -16
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +38 -18
- package/dist/testing/cross_backend/standard.d.ts +19 -84
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +8 -23
- package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
- package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard_auth.js +28 -0
- package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
- package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
- package/dist/testing/cross_backend/standard_bundle.js +43 -0
- package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_credential_read.js +12 -12
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +46 -30
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +52 -31
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +22 -7
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +2 -3
- package/dist/testing/error_coverage.d.ts +5 -0
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +2 -1
- package/dist/testing/integration.d.ts +6 -23
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +53 -83
- package/dist/testing/integration_helpers.d.ts +16 -0
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +29 -1
- package/dist/testing/middleware_gate_probes.d.ts +55 -1
- package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
- package/dist/testing/middleware_gate_probes.js +69 -3
- package/dist/testing/rate_limiting.d.ts +2 -3
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -3
- package/dist/testing/rpc_helpers.d.ts +1 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -3
- package/dist/testing/rpc_round_trip.d.ts +2 -3
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +1 -1
- package/dist/testing/sse_round_trip.d.ts +2 -3
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +5 -6
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -8
- package/dist/testing/test_app.d.ts +8 -5
- package/dist/testing/test_app.d.ts.map +1 -1
- package/dist/testing/test_app.js +7 -7
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +3 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +1 -2
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* One call wiring the standard suites that run against a spawned backend —
|
|
4
|
+
* the ones whose option shape is `{setup_test, surface_source, capabilities, ...}`
|
|
5
|
+
* and whose bodies fire requests through `fixture.transport` rather than
|
|
6
|
+
* touching the in-process `Backend`, for a consumer wiring them outside
|
|
7
|
+
* `describe_spine_cross_suites`, which registers the two halves apart:
|
|
8
|
+
*
|
|
9
|
+
* - `describe_standard_auth_cross_tests` (`standard_auth.ts`) —
|
|
10
|
+
* `describe_standard_integration_tests`, and
|
|
11
|
+
* `describe_standard_admin_integration_tests` when the consumer supplies a
|
|
12
|
+
* `RoleRegistry`
|
|
13
|
+
* - `describe_standard_cross_tests` (`standard.ts`) —
|
|
14
|
+
* `describe_middleware_gate_tests`, `describe_round_trip_validation`,
|
|
15
|
+
* `describe_rpc_round_trip_tests` and `describe_data_exposure_tests`
|
|
16
|
+
*
|
|
17
|
+
* **Suites omitted** — the ones that don't survive a process boundary,
|
|
18
|
+
* documented here so per-consumer files don't have to repeat the
|
|
19
|
+
* bookkeeping:
|
|
20
|
+
*
|
|
21
|
+
* - `describe_rate_limiting_tests` — builds a fresh `TestApp` per test to
|
|
22
|
+
* inject tight per-test rate-limiter overrides. That path requires
|
|
23
|
+
* in-process construction of `Backend` + rate limiter; the spawned
|
|
24
|
+
* binary has neither knob nor restart-per-test budget.
|
|
25
|
+
* - `describe_audit_completeness_tests` — reaches into FK-structural
|
|
26
|
+
* introspection that only the in-process backend exposes. Wire-level
|
|
27
|
+
* audit observability lives in the consumer's own audit `.cross.test.ts`
|
|
28
|
+
* driving `audit_log_list` / `audit_log_role_grant_history`.
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import { type StandardCrossTestOptions } from './standard.js';
|
|
33
|
+
import { type StandardAuthCrossTestOptions } from './standard_auth.js';
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for `describe_standard_cross_process_tests`: both halves'
|
|
36
|
+
* options — the in-process suites' shared options minus their
|
|
37
|
+
* in-process-only knobs (`create_route_specs`, `rate_limiting_app_options`).
|
|
38
|
+
*/
|
|
39
|
+
export interface StandardCrossProcessTestOptions extends StandardAuthCrossTestOptions, StandardCrossTestOptions {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run the cross-process standard test bundle — the auth suites (integration,
|
|
43
|
+
* admin when `roles` is provided), then the middleware-gate probes, round
|
|
44
|
+
* trip, RPC round trip and data exposure. See the module doc for the suites
|
|
45
|
+
* omitted and why.
|
|
46
|
+
*/
|
|
47
|
+
export declare const describe_standard_cross_process_tests: (options: StandardCrossProcessTestOptions) => void;
|
|
48
|
+
//# sourceMappingURL=standard_bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard_bundle.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/standard_bundle.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAiC,KAAK,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAEN,KAAK,4BAA4B,EACjC,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,+BAChB,SAAQ,4BAA4B,EAAE,wBAAwB;CAAG;AAElE;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC,GACjD,SAAS,+BAA+B,KACtC,IAGF,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* One call wiring the standard suites that run against a spawned backend —
|
|
4
|
+
* the ones whose option shape is `{setup_test, surface_source, capabilities, ...}`
|
|
5
|
+
* and whose bodies fire requests through `fixture.transport` rather than
|
|
6
|
+
* touching the in-process `Backend`, for a consumer wiring them outside
|
|
7
|
+
* `describe_spine_cross_suites`, which registers the two halves apart:
|
|
8
|
+
*
|
|
9
|
+
* - `describe_standard_auth_cross_tests` (`standard_auth.ts`) —
|
|
10
|
+
* `describe_standard_integration_tests`, and
|
|
11
|
+
* `describe_standard_admin_integration_tests` when the consumer supplies a
|
|
12
|
+
* `RoleRegistry`
|
|
13
|
+
* - `describe_standard_cross_tests` (`standard.ts`) —
|
|
14
|
+
* `describe_middleware_gate_tests`, `describe_round_trip_validation`,
|
|
15
|
+
* `describe_rpc_round_trip_tests` and `describe_data_exposure_tests`
|
|
16
|
+
*
|
|
17
|
+
* **Suites omitted** — the ones that don't survive a process boundary,
|
|
18
|
+
* documented here so per-consumer files don't have to repeat the
|
|
19
|
+
* bookkeeping:
|
|
20
|
+
*
|
|
21
|
+
* - `describe_rate_limiting_tests` — builds a fresh `TestApp` per test to
|
|
22
|
+
* inject tight per-test rate-limiter overrides. That path requires
|
|
23
|
+
* in-process construction of `Backend` + rate limiter; the spawned
|
|
24
|
+
* binary has neither knob nor restart-per-test budget.
|
|
25
|
+
* - `describe_audit_completeness_tests` — reaches into FK-structural
|
|
26
|
+
* introspection that only the in-process backend exposes. Wire-level
|
|
27
|
+
* audit observability lives in the consumer's own audit `.cross.test.ts`
|
|
28
|
+
* driving `audit_log_list` / `audit_log_role_grant_history`.
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import { describe_standard_cross_tests } from './standard.js';
|
|
33
|
+
import { describe_standard_auth_cross_tests } from './standard_auth.js';
|
|
34
|
+
/**
|
|
35
|
+
* Run the cross-process standard test bundle — the auth suites (integration,
|
|
36
|
+
* admin when `roles` is provided), then the middleware-gate probes, round
|
|
37
|
+
* trip, RPC round trip and data exposure. See the module doc for the suites
|
|
38
|
+
* omitted and why.
|
|
39
|
+
*/
|
|
40
|
+
export const describe_standard_cross_process_tests = (options) => {
|
|
41
|
+
describe_standard_auth_cross_tests(options);
|
|
42
|
+
describe_standard_cross_tests(options);
|
|
43
|
+
};
|
|
@@ -14,7 +14,6 @@ import '../assert_dev_env.js';
|
|
|
14
14
|
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
15
|
import { type RpcAction } from '../../actions/action_types.js';
|
|
16
16
|
import type { Keyring } from '../../auth/keyring.js';
|
|
17
|
-
import { type SessionOptions } from '../../auth/session_cookie.js';
|
|
18
17
|
/**
|
|
19
18
|
* The `data.reason` of every refusal `_testing_credential_read` gives its
|
|
20
19
|
* `lines`: a value that is no list of strings, a list or a line over its cap
|
|
@@ -48,12 +47,12 @@ export declare const TestingCredentialReadInput: import("@fuzdev/fuz_schema/sche
|
|
|
48
47
|
}>;
|
|
49
48
|
export type TestingCredentialReadInput = Infer<typeof TestingCredentialReadInput>;
|
|
50
49
|
/**
|
|
51
|
-
* What a request's `Cookie` lines hold of the session cookie — the
|
|
52
|
-
*
|
|
53
|
-
* lowercase.
|
|
50
|
+
* What a request's `Cookie` lines hold of the session cookie — the `kind` of
|
|
51
|
+
* a `SessionCookieRead` (`parse_session_from_cookies`), the wire form of the
|
|
52
|
+
* Rust spine's `fuz_auth::SessionCookieRead`, its variants in lowercase.
|
|
54
53
|
*/
|
|
55
|
-
export declare const
|
|
56
|
-
export type
|
|
54
|
+
export declare const SessionCookieReadKind: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["absent", "invalid", "valid"]>;
|
|
55
|
+
export type SessionCookieReadKind = Infer<typeof SessionCookieReadKind>;
|
|
57
56
|
/**
|
|
58
57
|
* Output of `_testing_credential_read`, a `@fuzdev/fuz_schema` `object`: how
|
|
59
58
|
* each credential leg reads the lines, before any database work.
|
|
@@ -76,8 +75,8 @@ export type TestingCredentialReadOutput = Infer<typeof TestingCredentialReadOutp
|
|
|
76
75
|
export interface TestingCredentialReadDeps {
|
|
77
76
|
/** The server's cookie keyring. */
|
|
78
77
|
readonly keyring: Keyring;
|
|
79
|
-
/** The server's session
|
|
80
|
-
readonly
|
|
78
|
+
/** The server's session cookie name. */
|
|
79
|
+
readonly session_cookie_name: string;
|
|
81
80
|
}
|
|
82
81
|
/**
|
|
83
82
|
* Split `Name: value` lines into the per-name lines the credential readers
|
|
@@ -93,13 +92,13 @@ export declare const parse_testing_header_lines: (lines: ReadonlyArray<string>)
|
|
|
93
92
|
/**
|
|
94
93
|
* Answer one `_testing_credential_read` input: read each credential out of
|
|
95
94
|
* the lines with the readers the auth middleware legs call
|
|
96
|
-
* (`
|
|
95
|
+
* (`parse_session_from_cookies`,
|
|
97
96
|
* `read_bearer_token`, `read_daemon_token`). The action handler and the
|
|
98
97
|
* conformance table's unit test both call this, so the table checks the same
|
|
99
98
|
* functions the wire serves.
|
|
100
99
|
*
|
|
101
100
|
* @param input - the header lines
|
|
102
|
-
* @param deps - the keyring
|
|
101
|
+
* @param deps - the keyring the cookie is verified with, and its name
|
|
103
102
|
* @returns the reading the Rust twin returns for the same lines
|
|
104
103
|
* @throws ThrownJsonrpcError `invalid_params` for a line `parse_testing_header_lines` refuses
|
|
105
104
|
*/
|
|
@@ -159,7 +158,7 @@ export declare const testing_credential_read_action_spec: {
|
|
|
159
158
|
/**
|
|
160
159
|
* Build the standalone `_testing_credential_read` action (see the spec doc).
|
|
161
160
|
*
|
|
162
|
-
* @param deps - the server's keyring and session
|
|
161
|
+
* @param deps - the server's keyring and session cookie name
|
|
163
162
|
*/
|
|
164
163
|
export declare const create_testing_credential_read_action: (deps: TestingCredentialReadDeps) => RpcAction;
|
|
165
164
|
//# sourceMappingURL=testing_credential_read.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing_credential_read.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_credential_read.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;GAWG;AAEH,OAAO,EAQN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"testing_credential_read.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_credential_read.ts"],"names":[],"mappings":"AAAA,OAAO,s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,MAAM,yBAAyB,KAC7B,OAAO,CAAC,2BAA2B,CAYrC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;QA9I/C;;;;;;WAMG;;;;QAwBH;;;;;WAKG;;QAEH,gFAAgF;;QAEhF,mFAAmF;;;;;;CAoHtC,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,GAAI,MAAM,yBAAyB,KAAG,SAGtF,CAAC"}
|
|
@@ -14,9 +14,9 @@ import '../assert_dev_env.js';
|
|
|
14
14
|
import { array, max_length, nullable, object, one_of, pipe, string } from '@fuzdev/fuz_schema/schema.ts';
|
|
15
15
|
import { meta } from '@fuzdev/fuz_schema/meta.ts';
|
|
16
16
|
import { rpc_action } from '../../actions/action_types.js';
|
|
17
|
-
import { read_bearer_token, read_daemon_token
|
|
17
|
+
import { read_bearer_token, read_daemon_token } from '../../auth/credential_headers.js';
|
|
18
18
|
import { DAEMON_TOKEN_HEADER } from '../../auth/daemon_token.js';
|
|
19
|
-
import {
|
|
19
|
+
import { parse_session_from_cookies } from '../../auth/session_cookie.js';
|
|
20
20
|
import { trim_optional_whitespace } from '../../http/header_lines.js';
|
|
21
21
|
import { jsonrpc_errors } from '../../http/jsonrpc_errors.js';
|
|
22
22
|
import { bounded_string } from '../../primitive_schemas.js';
|
|
@@ -53,11 +53,11 @@ export const TestingCredentialReadInput = object({
|
|
|
53
53
|
lines: meta(pipe(array(bounded_string({ max: TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX })), max_length(TESTING_CREDENTIAL_READ_LINES_MAX)), { invalid_reason: ERROR_TESTING_CREDENTIAL_READ_LINE })
|
|
54
54
|
});
|
|
55
55
|
/**
|
|
56
|
-
* What a request's `Cookie` lines hold of the session cookie — the
|
|
57
|
-
*
|
|
58
|
-
* lowercase.
|
|
56
|
+
* What a request's `Cookie` lines hold of the session cookie — the `kind` of
|
|
57
|
+
* a `SessionCookieRead` (`parse_session_from_cookies`), the wire form of the
|
|
58
|
+
* Rust spine's `fuz_auth::SessionCookieRead`, its variants in lowercase.
|
|
59
59
|
*/
|
|
60
|
-
export const
|
|
60
|
+
export const SessionCookieReadKind = one_of(['absent', 'invalid', 'valid']);
|
|
61
61
|
/**
|
|
62
62
|
* Output of `_testing_credential_read`, a `@fuzdev/fuz_schema` `object`: how
|
|
63
63
|
* each credential leg reads the lines, before any database work.
|
|
@@ -69,7 +69,7 @@ export const TestingCredentialReadOutput = object({
|
|
|
69
69
|
* the server's keyring and its signed expiry is ahead. Says nothing about
|
|
70
70
|
* the `auth_session` row.
|
|
71
71
|
*/
|
|
72
|
-
session_cookie:
|
|
72
|
+
session_cookie: SessionCookieReadKind,
|
|
73
73
|
/** The API token the bearer leg would look up, or `null` when it reads none. */
|
|
74
74
|
bearer_token: nullable(string),
|
|
75
75
|
/** The daemon token the daemon leg would compare, or `null` when it reads none. */
|
|
@@ -120,21 +120,21 @@ export const parse_testing_header_lines = (lines) => {
|
|
|
120
120
|
/**
|
|
121
121
|
* Answer one `_testing_credential_read` input: read each credential out of
|
|
122
122
|
* the lines with the readers the auth middleware legs call
|
|
123
|
-
* (`
|
|
123
|
+
* (`parse_session_from_cookies`,
|
|
124
124
|
* `read_bearer_token`, `read_daemon_token`). The action handler and the
|
|
125
125
|
* conformance table's unit test both call this, so the table checks the same
|
|
126
126
|
* functions the wire serves.
|
|
127
127
|
*
|
|
128
128
|
* @param input - the header lines
|
|
129
|
-
* @param deps - the keyring
|
|
129
|
+
* @param deps - the keyring the cookie is verified with, and its name
|
|
130
130
|
* @returns the reading the Rust twin returns for the same lines
|
|
131
131
|
* @throws ThrownJsonrpcError `invalid_params` for a line `parse_testing_header_lines` refuses
|
|
132
132
|
*/
|
|
133
133
|
export const run_testing_credential_read = async (input, deps) => {
|
|
134
134
|
const header = parse_testing_header_lines(input.lines);
|
|
135
|
-
const session = await
|
|
135
|
+
const session = await parse_session_from_cookies(header('cookie'), deps.keyring, deps.session_cookie_name);
|
|
136
136
|
return {
|
|
137
|
-
session_cookie: session.
|
|
137
|
+
session_cookie: session.kind,
|
|
138
138
|
bearer_token: read_bearer_token(header('authorization')),
|
|
139
139
|
daemon_token: read_daemon_token(header(DAEMON_TOKEN_HEADER.toLowerCase()))
|
|
140
140
|
};
|
|
@@ -170,6 +170,6 @@ export const testing_credential_read_action_spec = {
|
|
|
170
170
|
/**
|
|
171
171
|
* Build the standalone `_testing_credential_read` action (see the spec doc).
|
|
172
172
|
*
|
|
173
|
-
* @param deps - the server's keyring and session
|
|
173
|
+
* @param deps - the server's keyring and session cookie name
|
|
174
174
|
*/
|
|
175
175
|
export const create_testing_credential_read_action = (deps) => rpc_action(testing_credential_read_action_spec, (input) => run_testing_credential_read(input, deps));
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import '../assert_dev_env.js';
|
|
2
2
|
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
3
3
|
import { type RpcAction } from '../../actions/action_types.js';
|
|
4
|
+
import { type RequestTracker } from '../../http/pending_effects.js';
|
|
4
5
|
import type { RoomRegistry } from '../../actions/room_registry.js';
|
|
5
6
|
import type { AppDeps } from '../../auth/deps.js';
|
|
6
7
|
import type { AuditEmitter } from '../../auth/audit_emitter.js';
|
|
7
|
-
import type { SessionOptions } from '../../auth/session_cookie.js';
|
|
8
8
|
import type { DaemonTokenState } from '../../auth/daemon_token.js';
|
|
9
9
|
import type { Db } from '../../db/db.js';
|
|
10
|
+
/**
|
|
11
|
+
* Restamps a seeded account's session at the wall clock, run right after the
|
|
12
|
+
* account is seeded. The reset seeds every account in one transaction, where
|
|
13
|
+
* `NOW()` is one instant, so the seeded sessions would tie on `created_at` and
|
|
14
|
+
* a list ordered by it (`admin_session_list`) would break the tie by the
|
|
15
|
+
* random session hash — a different order per run and per spine. Stamped in
|
|
16
|
+
* seed order, they list the same on both. The Rust reset runs this statement
|
|
17
|
+
* byte for byte (`fuz_testing::testing_reset`); the actor twin is
|
|
18
|
+
* `create_test_extra_actor`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const RESET_SESSION_CLOCK_STAMP_SQL = "UPDATE auth_session SET created_at = clock_timestamp() WHERE account_id = $1";
|
|
10
21
|
/**
|
|
11
22
|
* The `_testing_reset` action spec.
|
|
12
23
|
*
|
|
@@ -91,26 +102,30 @@ export declare const testing_reset_action_spec: {
|
|
|
91
102
|
readonly description: "Test-binary only — wipe auth tables, re-bootstrap a fresh keeper (+ optional extras), fire the domain-state reset.";
|
|
92
103
|
};
|
|
93
104
|
/**
|
|
94
|
-
* `_testing_drain_effects` — await in-flight fire-and-forget
|
|
105
|
+
* `_testing_drain_effects` — await in-flight fire-and-forget work so a
|
|
95
106
|
* following `audit_log_list` or database read is authoritative. The
|
|
96
107
|
* deterministic barrier the cross-backend conformance suite uses in place of
|
|
97
108
|
* a poll/sleep before asserting on audit rows.
|
|
98
109
|
*
|
|
99
|
-
* The handler
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
110
|
+
* The handler waits, repeating until both are empty, for the effect flushes
|
|
111
|
+
* on `AppDeps.request_tracker` (`RequestTracker.drain_flushes`: each
|
|
112
|
+
* request's eager `pending_effects` — the bearer leg's token touch among
|
|
113
|
+
* them — and its post-commit thunks) and for the pool writes of
|
|
114
|
+
* `AppDeps.audit` (`AuditEmitter.drain_inflight`) — a thunk can start an
|
|
115
|
+
* audit write, and a write's listener fan-out runs in a thunk. It matters
|
|
116
|
+
* whatever the transport: both test binaries settle an **HTTP** answer's
|
|
117
|
+
* effects before it responds (the TS binary through
|
|
118
|
+
* `await_pending_effects: true`, the Rust stub through its
|
|
104
119
|
* `await_background_writes_layer`), but a **WS** mutation is answered
|
|
105
120
|
* before its effects flush (reply-then-close for a self-revocation), so its
|
|
106
|
-
* audit write can still be
|
|
107
|
-
* Rust spine
|
|
121
|
+
* audit write or post-commit effect can still be running when the caller
|
|
122
|
+
* reads the reply. The Rust spine awaits the same work on its one tracker,
|
|
123
|
+
* `BackgroundWrites`.
|
|
108
124
|
*
|
|
109
|
-
* Covered: every `emit` that
|
|
110
|
-
* started while it waits.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* its audit writes, so its drain awaits that too.
|
|
125
|
+
* Covered: every flush and `emit` that started before the drain was
|
|
126
|
+
* dispatched, and any started while it waits. Not a handler still running —
|
|
127
|
+
* the drain's own request is one, and its flush starts only after it answers
|
|
128
|
+
* — nor work that starts after the drain resolves.
|
|
114
129
|
*
|
|
115
130
|
* `auth` gates on the daemon-token credential, matching `_testing_reset`.
|
|
116
131
|
*/
|
|
@@ -147,7 +162,7 @@ export declare const testing_drain_effects_action_spec: {
|
|
|
147
162
|
* The minted `auth_session` row's `expires_at` is backdated while the
|
|
148
163
|
* returned cookie's own signed payload stays valid (future). Cross-process
|
|
149
164
|
* auth resolution therefore passes the
|
|
150
|
-
* cookie-payload gate (`
|
|
165
|
+
* cookie-payload gate (`parse_session_from_cookies`) and is refused by the authoritative
|
|
151
166
|
* DB-row gate (`query_session_get_valid` — `WHERE expires_at > NOW()`) —
|
|
152
167
|
* the gate the in-process payload-expiry tests never reach and the one that
|
|
153
168
|
* structurally needs a server-side mint (the cross-process driver has no
|
|
@@ -181,16 +196,23 @@ export declare const testing_mint_session_action_spec: {
|
|
|
181
196
|
readonly async: true;
|
|
182
197
|
readonly description: string;
|
|
183
198
|
};
|
|
199
|
+
/** What `_testing_drain_effects` waits on — `AppDeps` satisfies it. */
|
|
200
|
+
export interface TestingDrainEffectsDeps {
|
|
201
|
+
/** The backend's request tracker, whose effect flushes the action awaits. */
|
|
202
|
+
request_tracker: Pick<RequestTracker, 'drain_flushes' | 'flush_count'>;
|
|
203
|
+
/** The backend's emitter, whose in-flight pool writes the action awaits. */
|
|
204
|
+
audit: Pick<AuditEmitter, 'drain_inflight' | 'inflight_count'>;
|
|
205
|
+
}
|
|
184
206
|
/**
|
|
185
|
-
* Build the standalone `_testing_drain_effects` action over
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* `{ok: true}`.
|
|
207
|
+
* Build the standalone `_testing_drain_effects` action over the backend's
|
|
208
|
+
* deps — the tracker its requests are held on and the emitter its handlers
|
|
209
|
+
* emit through. Mount it on any test endpoint whose suite asserts on audit
|
|
210
|
+
* rows or effects (the spine binary bundles it via `create_testing_actions`;
|
|
211
|
+
* in-process suites mount it directly). Answers `{ok: true}`.
|
|
190
212
|
*
|
|
191
|
-
* @param
|
|
213
|
+
* @param deps - the backend's `request_tracker` and `audit`
|
|
192
214
|
*/
|
|
193
|
-
export declare const create_testing_drain_effects_action: (
|
|
215
|
+
export declare const create_testing_drain_effects_action: (deps: TestingDrainEffectsDeps) => RpcAction;
|
|
194
216
|
/**
|
|
195
217
|
* `_testing_put_fact` — seed an **embedded** fact (`fact.bytes`) for the
|
|
196
218
|
* cross-process fact-serving suite, which drives over real HTTP and has no
|
|
@@ -676,13 +698,6 @@ export declare const testing_action_manifest_action_spec: {
|
|
|
676
698
|
export declare const create_testing_action_manifest_action: (mounted: ReadonlyArray<RpcAction>, ws_only?: ReadonlyArray<RpcAction>) => RpcAction;
|
|
677
699
|
/** Options for `create_testing_actions`. */
|
|
678
700
|
export interface CreateTestingActionsOptions {
|
|
679
|
-
/**
|
|
680
|
-
* Session cookie options — the reset action uses these when signing
|
|
681
|
-
* the fresh keeper's (and any extra accounts') session cookies.
|
|
682
|
-
* Pass the same `SessionOptions` the live `create_app_server` call
|
|
683
|
-
* was wired with.
|
|
684
|
-
*/
|
|
685
|
-
readonly session_options: SessionOptions<string>;
|
|
686
701
|
/**
|
|
687
702
|
* Daemon-token runtime state — the reset action points
|
|
688
703
|
* `state.keeper_account_id` at the freshly seeded keeper once its
|
|
@@ -716,7 +731,8 @@ export interface CreateTestingActionsOptions {
|
|
|
716
731
|
*
|
|
717
732
|
* Returns the bundled `_testing_*` actions (module doc). The test binary
|
|
718
733
|
* calls this at server-assembly time and registers the result on its
|
|
719
|
-
* dispatcher. `_testing_drain_effects` drains `deps.
|
|
734
|
+
* dispatcher. `_testing_drain_effects` drains `deps.request_tracker` and
|
|
735
|
+
* `deps.audit`.
|
|
720
736
|
*
|
|
721
737
|
* The reset action's table-wipe list mirrors
|
|
722
738
|
* `auth_integration_truncate_tables` from `testing/db.ts` — the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqF9B,OAAO,EAcN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqF9B,OAAO,EAcN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AA0BzC;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,iFACqC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;QAiBpC;;;;;;;;WAQG;;;;;;;;;;;;;;;QAMH,4E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;;;;;;;;;;;;;;;CAaF,CAAC;AAkB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qCAAqC,GACjD,SAAS,aAAa,CAAC,SAAS,CAAC,EACjC,UAAS,aAAa,CAAC,SAAS,CAAM,KACpC,SASF,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,2BAA2B;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;IAC9C;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,OAAO,EACb,SAAS,2BAA2B,KAClC,KAAK,CAAC,SAAS,CAwJjB,CAAC"}
|
|
@@ -4,7 +4,7 @@ import '../assert_dev_env.js';
|
|
|
4
4
|
*
|
|
5
5
|
* The daemon-token-authed actions bundled by `create_testing_actions`:
|
|
6
6
|
* **`_testing_reset`** (DB wipe + keeper re-seed), **`_testing_drain_effects`**
|
|
7
|
-
* (
|
|
7
|
+
* (effects barrier), **`_testing_mint_session`** (forge an
|
|
8
8
|
* expired-by-construction server-side session for the expiry conformance
|
|
9
9
|
* cases), **`_testing_put_fact`** (seed an embedded fact for the fact-serving
|
|
10
10
|
* suite), **`_testing_schema_snapshot`** (introspect the live schema for
|
|
@@ -105,6 +105,17 @@ const SeededAccountShape = object({
|
|
|
105
105
|
api_token: string,
|
|
106
106
|
session_cookie: string
|
|
107
107
|
});
|
|
108
|
+
/**
|
|
109
|
+
* Restamps a seeded account's session at the wall clock, run right after the
|
|
110
|
+
* account is seeded. The reset seeds every account in one transaction, where
|
|
111
|
+
* `NOW()` is one instant, so the seeded sessions would tie on `created_at` and
|
|
112
|
+
* a list ordered by it (`admin_session_list`) would break the tie by the
|
|
113
|
+
* random session hash — a different order per run and per spine. Stamped in
|
|
114
|
+
* seed order, they list the same on both. The Rust reset runs this statement
|
|
115
|
+
* byte for byte (`fuz_testing::testing_reset`); the actor twin is
|
|
116
|
+
* `create_test_extra_actor`.
|
|
117
|
+
*/
|
|
118
|
+
export const RESET_SESSION_CLOCK_STAMP_SQL = 'UPDATE auth_session SET created_at = clock_timestamp() WHERE account_id = $1';
|
|
108
119
|
/**
|
|
109
120
|
* The `_testing_reset` action spec.
|
|
110
121
|
*
|
|
@@ -164,26 +175,30 @@ export const testing_reset_action_spec = {
|
|
|
164
175
|
description: 'Test-binary only — wipe auth tables, re-bootstrap a fresh keeper (+ optional extras), fire the domain-state reset.'
|
|
165
176
|
};
|
|
166
177
|
/**
|
|
167
|
-
* `_testing_drain_effects` — await in-flight fire-and-forget
|
|
178
|
+
* `_testing_drain_effects` — await in-flight fire-and-forget work so a
|
|
168
179
|
* following `audit_log_list` or database read is authoritative. The
|
|
169
180
|
* deterministic barrier the cross-backend conformance suite uses in place of
|
|
170
181
|
* a poll/sleep before asserting on audit rows.
|
|
171
182
|
*
|
|
172
|
-
* The handler
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
183
|
+
* The handler waits, repeating until both are empty, for the effect flushes
|
|
184
|
+
* on `AppDeps.request_tracker` (`RequestTracker.drain_flushes`: each
|
|
185
|
+
* request's eager `pending_effects` — the bearer leg's token touch among
|
|
186
|
+
* them — and its post-commit thunks) and for the pool writes of
|
|
187
|
+
* `AppDeps.audit` (`AuditEmitter.drain_inflight`) — a thunk can start an
|
|
188
|
+
* audit write, and a write's listener fan-out runs in a thunk. It matters
|
|
189
|
+
* whatever the transport: both test binaries settle an **HTTP** answer's
|
|
190
|
+
* effects before it responds (the TS binary through
|
|
191
|
+
* `await_pending_effects: true`, the Rust stub through its
|
|
177
192
|
* `await_background_writes_layer`), but a **WS** mutation is answered
|
|
178
193
|
* before its effects flush (reply-then-close for a self-revocation), so its
|
|
179
|
-
* audit write can still be
|
|
180
|
-
* Rust spine
|
|
194
|
+
* audit write or post-commit effect can still be running when the caller
|
|
195
|
+
* reads the reply. The Rust spine awaits the same work on its one tracker,
|
|
196
|
+
* `BackgroundWrites`.
|
|
181
197
|
*
|
|
182
|
-
* Covered: every `emit` that
|
|
183
|
-
* started while it waits.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* its audit writes, so its drain awaits that too.
|
|
198
|
+
* Covered: every flush and `emit` that started before the drain was
|
|
199
|
+
* dispatched, and any started while it waits. Not a handler still running —
|
|
200
|
+
* the drain's own request is one, and its flush starts only after it answers
|
|
201
|
+
* — nor work that starts after the drain resolves.
|
|
187
202
|
*
|
|
188
203
|
* `auth` gates on the daemon-token credential, matching `_testing_reset`.
|
|
189
204
|
*/
|
|
@@ -214,7 +229,7 @@ export const testing_drain_effects_action_spec = {
|
|
|
214
229
|
* The minted `auth_session` row's `expires_at` is backdated while the
|
|
215
230
|
* returned cookie's own signed payload stays valid (future). Cross-process
|
|
216
231
|
* auth resolution therefore passes the
|
|
217
|
-
* cookie-payload gate (`
|
|
232
|
+
* cookie-payload gate (`parse_session_from_cookies`) and is refused by the authoritative
|
|
218
233
|
* DB-row gate (`query_session_get_valid` — `WHERE expires_at > NOW()`) —
|
|
219
234
|
* the gate the in-process payload-expiry tests never reach and the one that
|
|
220
235
|
* structurally needs a server-side mint (the cross-process driver has no
|
|
@@ -248,16 +263,22 @@ export const testing_mint_session_action_spec = {
|
|
|
248
263
|
'signed cookie value (exercises the authoritative server-side DB-row expiry gate).'
|
|
249
264
|
};
|
|
250
265
|
/**
|
|
251
|
-
* Build the standalone `_testing_drain_effects` action over
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* `{ok: true}`.
|
|
266
|
+
* Build the standalone `_testing_drain_effects` action over the backend's
|
|
267
|
+
* deps — the tracker its requests are held on and the emitter its handlers
|
|
268
|
+
* emit through. Mount it on any test endpoint whose suite asserts on audit
|
|
269
|
+
* rows or effects (the spine binary bundles it via `create_testing_actions`;
|
|
270
|
+
* in-process suites mount it directly). Answers `{ok: true}`.
|
|
256
271
|
*
|
|
257
|
-
* @param
|
|
272
|
+
* @param deps - the backend's `request_tracker` and `audit`
|
|
258
273
|
*/
|
|
259
|
-
export const create_testing_drain_effects_action = (
|
|
260
|
-
|
|
274
|
+
export const create_testing_drain_effects_action = (deps) => rpc_action(testing_drain_effects_action_spec, async () => {
|
|
275
|
+
const { request_tracker, audit } = deps;
|
|
276
|
+
// until both are empty: a flush's post-commit thunk can start an audit
|
|
277
|
+
// write, and a flush that starts meanwhile is waited for too
|
|
278
|
+
do {
|
|
279
|
+
await request_tracker.drain_flushes();
|
|
280
|
+
await audit.drain_inflight();
|
|
281
|
+
} while (request_tracker.flush_count() > 0 || audit.inflight_count() > 0);
|
|
261
282
|
return { ok: true };
|
|
262
283
|
});
|
|
263
284
|
/**
|
|
@@ -699,7 +720,8 @@ export const create_testing_action_manifest_action = (mounted, ws_only = []) =>
|
|
|
699
720
|
*
|
|
700
721
|
* Returns the bundled `_testing_*` actions (module doc). The test binary
|
|
701
722
|
* calls this at server-assembly time and registers the result on its
|
|
702
|
-
* dispatcher. `_testing_drain_effects` drains `deps.
|
|
723
|
+
* dispatcher. `_testing_drain_effects` drains `deps.request_tracker` and
|
|
724
|
+
* `deps.audit`.
|
|
703
725
|
*
|
|
704
726
|
* The reset action's table-wipe list mirrors
|
|
705
727
|
* `auth_integration_truncate_tables` from `testing/db.ts` — the
|
|
@@ -709,7 +731,7 @@ export const create_testing_action_manifest_action = (mounted, ws_only = []) =>
|
|
|
709
731
|
* without updating this handler fails CI.
|
|
710
732
|
*/
|
|
711
733
|
export const create_testing_actions = (deps, options) => {
|
|
712
|
-
const {
|
|
734
|
+
const { daemon_token_state, reset_state } = options;
|
|
713
735
|
const log = deps.log;
|
|
714
736
|
return [
|
|
715
737
|
rpc_action(testing_reset_action_spec, async (input, ctx) => {
|
|
@@ -767,15 +789,15 @@ export const create_testing_actions = (deps, options) => {
|
|
|
767
789
|
const keeper = await create_test_account_with_credentials({
|
|
768
790
|
db: ctx.db,
|
|
769
791
|
keyring: deps.keyring,
|
|
770
|
-
session_options,
|
|
771
792
|
password: deps.password,
|
|
772
793
|
password_value: DEFAULT_TEST_PASSWORD,
|
|
773
794
|
roles: [...new Set([...DEFAULT_TEST_KEEPER_ROLES, ...(input.extra_keeper_roles ?? [])])]
|
|
774
795
|
});
|
|
796
|
+
await ctx.db.query(RESET_SESSION_CLOCK_STAMP_SQL, [keeper.account.id]);
|
|
775
797
|
// 6. Refresh the daemon-token cache so subsequent daemon-token
|
|
776
798
|
// requests resolve to the freshly seeded keeper. The
|
|
777
|
-
// middleware
|
|
778
|
-
//
|
|
799
|
+
// middleware never re-reads the keeper, so the reset sets it —
|
|
800
|
+
// after the commit, queued as
|
|
779
801
|
// soon as the keeper exists, so a reset that rolls back after it
|
|
780
802
|
// (a failing extra seed, a failed COMMIT) leaves the cache on the
|
|
781
803
|
// keeper still in the database rather than one that never
|
|
@@ -792,12 +814,12 @@ export const create_testing_actions = (deps, options) => {
|
|
|
792
814
|
const seeded = await create_test_account_with_credentials({
|
|
793
815
|
db: ctx.db,
|
|
794
816
|
keyring: deps.keyring,
|
|
795
|
-
session_options,
|
|
796
817
|
password: deps.password,
|
|
797
818
|
username: spec.username,
|
|
798
819
|
password_value: spec.password_value ?? DEFAULT_TEST_PASSWORD,
|
|
799
820
|
roles: spec.roles
|
|
800
821
|
});
|
|
822
|
+
await ctx.db.query(RESET_SESSION_CLOCK_STAMP_SQL, [seeded.account.id]);
|
|
801
823
|
extras.push(seeded);
|
|
802
824
|
}
|
|
803
825
|
// 8. Seed any additional keeper actors. Same bootstrap-cradle
|
|
@@ -819,7 +841,6 @@ export const create_testing_actions = (deps, options) => {
|
|
|
819
841
|
const { session_cookie } = await mint_test_session({
|
|
820
842
|
db: ctx.db,
|
|
821
843
|
keyring: deps.keyring,
|
|
822
|
-
session_options,
|
|
823
844
|
account_id: input.account_id,
|
|
824
845
|
expires_in_seconds: input.expires_in_seconds
|
|
825
846
|
});
|
|
@@ -842,7 +863,7 @@ export const create_testing_actions = (deps, options) => {
|
|
|
842
863
|
}
|
|
843
864
|
return { hash };
|
|
844
865
|
}),
|
|
845
|
-
create_testing_drain_effects_action(deps
|
|
866
|
+
create_testing_drain_effects_action(deps),
|
|
846
867
|
create_testing_flood_notifications_action(),
|
|
847
868
|
create_testing_schema_snapshot_action(),
|
|
848
869
|
create_testing_migration_tracker_action(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,
|
|
1
|
+
{"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,oBAoE7C,CAAC"}
|
|
@@ -78,11 +78,12 @@ export const create_bun_testing_adapter = () => {
|
|
|
78
78
|
//
|
|
79
79
|
// So initiate a force-close (`true` drops active connections, no
|
|
80
80
|
// drain) but DON'T await it: awaiting hangs `start_testing_server`'s
|
|
81
|
-
// shutdown forever —
|
|
82
|
-
//
|
|
81
|
+
// shutdown forever — the core's exit never runs, and the spawning
|
|
82
|
+
// harness blocks on a child that never exits (observed as a
|
|
83
83
|
// multi-minute hang needing SIGKILL). The force-close still tears the
|
|
84
|
-
// live sockets down; the
|
|
85
|
-
//
|
|
84
|
+
// live sockets down; the exit the core fires once `built.close()`
|
|
85
|
+
// returns (`0`, or `1` when it gave up) does the real teardown. Node
|
|
86
|
+
// doesn't need this — its
|
|
86
87
|
// `close()` resolves normally. The `.catch` guards a
|
|
87
88
|
// future Bun that rejects rather than hangs; if a future Bun resolves
|
|
88
89
|
// the promise after a server-initiated close, revert to
|