@fuzdev/fuz_app 0.182.0 → 0.184.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/README.md +2 -0
- package/dist/actions/CLAUDE.md +535 -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 +14 -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 +9 -1
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +43 -19
- package/dist/auth/CLAUDE.md +430 -1024
- package/dist/auth/account_queries.d.ts +1 -1
- package/dist/auth/account_queries.js +1 -1
- package/dist/auth/account_routes.d.ts +9 -8
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +78 -75
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +32 -28
- 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_emitter.d.ts +75 -84
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +83 -71
- package/dist/auth/audit_log_schema.d.ts +25 -14
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +23 -8
- 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 +42 -26
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +36 -19
- 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 +26 -31
- 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/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 +19 -5
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/deps.js +3 -2
- 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/resolved_auth.d.ts +7 -7
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts +27 -3
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +42 -35
- package/dist/auth/role_grant_offer_queries.d.ts +60 -4
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +79 -5
- package/dist/auth/role_grant_queries.d.ts +3 -52
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +5 -80
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +11 -22
- 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 +15 -17
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +28 -20
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +93 -43
- package/dist/db/CLAUDE.md +5 -3
- package/dist/db/sql_columns.d.ts +1 -1
- package/dist/db/sql_columns.js +1 -1
- 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 -763
- package/dist/http/db_routes.d.ts +8 -23
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +73 -73
- 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 +118 -6
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +114 -6
- package/dist/http/route_result.d.ts +1 -1
- package/dist/http/route_spec.d.ts +14 -11
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/realtime/sse.d.ts +4 -23
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -25
- 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 +80 -16
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +113 -31
- 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/testing/CLAUDE.md +265 -796
- package/dist/testing/admin_integration.d.ts +2 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +3 -3
- package/dist/testing/adversarial_404.d.ts +6 -1
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +38 -17
- package/dist/testing/app_server.d.ts +23 -148
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +53 -131
- 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/audit_drift_guard.d.ts +11 -6
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +15 -8
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
- package/dist/testing/cross_backend/capabilities.d.ts +9 -6
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +11 -7
- package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
- package/dist/testing/cross_backend/capability_mounts.js +428 -0
- package/dist/testing/cross_backend/cell_moderate.js +2 -2
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +12 -11
- package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
- package/dist/testing/cross_backend/conformance_principal.js +283 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +7 -56
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +6 -274
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_deadline.js +2 -0
- package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
- package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
- package/dist/testing/cross_backend/db_state_diff.js +444 -0
- package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
- package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
- package/dist/testing/cross_backend/declared_skips.js +132 -0
- 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 +13 -5
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +35 -11
- package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +16 -0
- 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 +28 -19
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +156 -142
- package/dist/testing/cross_backend/login_security.d.ts +12 -0
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +21 -4
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
- package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +18 -10
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
- package/dist/testing/cross_backend/role_grant_participation.js +4 -4
- package/dist/testing/cross_backend/rpc_adversarial.js +1 -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/session_cap.d.ts +2 -2
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +22 -11
- package/dist/testing/cross_backend/setup.d.ts +32 -2
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +32 -1
- package/dist/testing/cross_backend/spine_suites.d.ts +125 -15
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +459 -62
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +123 -27
- package/dist/testing/cross_backend/standard.d.ts +2 -3
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +3 -3
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -2
- 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 +84 -47
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +95 -63
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +2 -3
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +7 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +54 -8
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +2 -3
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -0
- package/dist/testing/db.d.ts +0 -32
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +0 -86
- package/dist/testing/db_entities.d.ts +14 -0
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +17 -0
- package/dist/testing/db_invariant_queries.d.ts +259 -0
- package/dist/testing/db_invariant_queries.d.ts.map +1 -0
- package/dist/testing/db_invariant_queries.js +400 -0
- package/dist/testing/db_invariants.d.ts +106 -0
- package/dist/testing/db_invariants.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
- package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.js +13 -0
- package/dist/testing/db_invariants.js +141 -0
- package/dist/testing/db_invariants.sql +152 -0
- package/dist/testing/describe_db.d.ts +36 -0
- package/dist/testing/describe_db.d.ts.map +1 -0
- package/dist/testing/describe_db.js +71 -0
- package/dist/testing/integration.d.ts +8 -12
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -17
- package/dist/testing/integration_helpers.d.ts +1 -1
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/rate_limiting.d.ts +3 -4
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +6 -5
- package/dist/testing/role_grant_helpers.d.ts +1 -1
- package/dist/testing/role_grant_helpers.d.ts.map +1 -1
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +3 -0
- package/dist/testing/rpc_attack_surface.d.ts +8 -6
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +69 -6
- 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 +3 -4
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +4 -1
- package/dist/testing/sse_round_trip.d.ts +3 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +15 -6
- package/dist/testing/stubs.d.ts +9 -8
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +20 -13
- package/dist/testing/test_app.d.ts +168 -0
- package/dist/testing/test_app.d.ts.map +1 -0
- package/dist/testing/test_app.js +123 -0
- 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
|
@@ -51,31 +51,28 @@ import '../assert_dev_env.js';
|
|
|
51
51
|
*/
|
|
52
52
|
import { assert, describe, test } from 'vitest';
|
|
53
53
|
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
54
|
-
import { DAEMON_TOKEN_HEADER, is_daemon_token_shaped } from '../../auth/daemon_token.js';
|
|
55
|
-
import { API_TOKEN_PREFIX, is_api_token_shaped } from '../../auth/api_token.js';
|
|
56
54
|
import { find_auth_route, rest_auth_route_suffixes } from '../integration_helpers.js';
|
|
57
55
|
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';
|
|
58
|
-
import { account_token_create_action_spec } from '../../auth/account_action_specs.js';
|
|
59
56
|
import { http_status_to_jsonrpc_error_code, jsonrpc_error_code_to_http_status } from '../../http/jsonrpc_errors.js';
|
|
60
57
|
import { create_admitted_ws_transport } from '../transports/ws_transport.js';
|
|
61
58
|
import { is_response_for } from '../transports/ws_client.js';
|
|
62
|
-
import {
|
|
59
|
+
import {} from './conformance_case.js';
|
|
63
60
|
import { classify_session_cookie_effect, filter_session_set_cookies, find_session_cookie_mints } from './session_cookie_effect.js';
|
|
64
|
-
import { mint_narrowed_api_token } from './narrowed_api_token.js';
|
|
65
61
|
import { xfail_until } from './xfail.js';
|
|
62
|
+
import { resolve_conformance_principal } from './conformance_principal.js';
|
|
66
63
|
/**
|
|
67
64
|
* Resolve the endpoints a conformance case's RPC method is looked up in: the
|
|
68
65
|
* declared `rpc_endpoints`, then `live_rpc_endpoints`. `find_rpc_action`
|
|
69
66
|
* takes the first match, so a declared method resolves from the declared
|
|
70
67
|
* surface even when the live mount repeats it.
|
|
71
68
|
*
|
|
72
|
-
* @param options - the declared and live endpoints, and the session
|
|
69
|
+
* @param options - the declared and live endpoints, and the session cookie name
|
|
73
70
|
* @returns the endpoints in lookup order
|
|
74
71
|
*/
|
|
75
72
|
export const resolve_conformance_rpc_endpoints = (options) => [
|
|
76
|
-
...resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.
|
|
73
|
+
...resolve_rpc_endpoints_for_setup(options.rpc_endpoints, options.session_cookie_name),
|
|
77
74
|
...(options.live_rpc_endpoints
|
|
78
|
-
? resolve_rpc_endpoints_for_setup(options.live_rpc_endpoints, options.
|
|
75
|
+
? resolve_rpc_endpoints_for_setup(options.live_rpc_endpoints, options.session_cookie_name)
|
|
79
76
|
: [])
|
|
80
77
|
];
|
|
81
78
|
/**
|
|
@@ -114,271 +111,6 @@ export const is_ws_conformance_case = (c) => !c.request.method.startsWith('/') &
|
|
|
114
111
|
!Object.values(c.expect.headers ?? {}).some((value) => value !== null) &&
|
|
115
112
|
(c.expect.set_cookie ?? 'none') === 'none' &&
|
|
116
113
|
!WS_UNAVAILABLE_PRINCIPALS.has(c.request.as);
|
|
117
|
-
/**
|
|
118
|
-
* A deliberately malformed `X-Daemon-Token` value for the `invalid_daemon`
|
|
119
|
-
* principal. Fails the `DaemonToken` schema (not 43 base64url chars), so
|
|
120
|
-
* the daemon-token middleware soft-fail-discards it rather than authenticating
|
|
121
|
-
* — the request falls through with no identity, surfacing
|
|
122
|
-
* `credential_type_required` on a daemon-gated action (matching the Rust
|
|
123
|
-
* spine's `None`). Sent over a no-Origin transport so it lands on the
|
|
124
|
-
* invalid-token path, not the browser-context discard.
|
|
125
|
-
*/
|
|
126
|
-
const INVALID_DAEMON_TOKEN_VALUE = 'not-a-valid-daemon-token';
|
|
127
|
-
/**
|
|
128
|
-
* The `wrong_daemon` principal's token: well-shaped (43 base64url characters),
|
|
129
|
-
* so it passes the shape precheck and is refused by the compare — never the
|
|
130
|
-
* server's, whose tokens are random.
|
|
131
|
-
*/
|
|
132
|
-
const WRONG_DAEMON_TOKEN_VALUE = 'A'.repeat(43);
|
|
133
|
-
/**
|
|
134
|
-
* The `unknown_bearer` principal's token: well-shaped (the prefix and 43
|
|
135
|
-
* base64url characters), so it costs the lookup no row answers.
|
|
136
|
-
*/
|
|
137
|
-
const UNKNOWN_BEARER_TOKEN_VALUE = `${API_TOKEN_PREFIX}${'A'.repeat(43)}`;
|
|
138
|
-
if (!is_daemon_token_shaped(WRONG_DAEMON_TOKEN_VALUE)) {
|
|
139
|
-
throw new Error('conformance: WRONG_DAEMON_TOKEN_VALUE must be daemon-token-shaped');
|
|
140
|
-
}
|
|
141
|
-
if (!is_api_token_shaped(UNKNOWN_BEARER_TOKEN_VALUE)) {
|
|
142
|
-
throw new Error('conformance: UNKNOWN_BEARER_TOKEN_VALUE must be api-token-shaped');
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* The keeper's session cookie with its MAC corrupted: the first character of
|
|
146
|
-
* the signature (after the last `.`) changed, so the signature keeps its
|
|
147
|
-
* shape and the keyring refuses it on the compare, not the shape check.
|
|
148
|
-
*/
|
|
149
|
-
const tamper_session_cookie = (cookie) => {
|
|
150
|
-
const dot = cookie.lastIndexOf('.');
|
|
151
|
-
const first = cookie[dot + 1];
|
|
152
|
-
if (dot === -1 || first === undefined) {
|
|
153
|
-
throw new Error(`conformance: principal 'tampered_cookie' found no signed session cookie`);
|
|
154
|
-
}
|
|
155
|
-
return `${cookie.slice(0, dot + 1)}${first === 'A' ? 'B' : 'A'}${cookie.slice(dot + 2)}`;
|
|
156
|
-
};
|
|
157
|
-
/** A dead bearer presented alone: no cookie, no `Origin`, so the token is looked up. */
|
|
158
|
-
const as_lone_bearer = (fixture, token) => ({
|
|
159
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
160
|
-
headers: { authorization: `Bearer ${token}` },
|
|
161
|
-
suppress_default_origin: true
|
|
162
|
-
});
|
|
163
|
-
/**
|
|
164
|
-
* Mint the `scoped_token` principal's narrowed bearer token over the
|
|
165
|
-
* production `account_token_create` path.
|
|
166
|
-
*
|
|
167
|
-
* Minted rather than seeded, and minted *here* rather than in a case. The
|
|
168
|
-
* seed stays `full` because `_testing_reset`'s api token backs every other
|
|
169
|
-
* bearer principal, and a case that minted its own credential would be the
|
|
170
|
-
* setup-DSL trap the case schema exists to avoid.
|
|
171
|
-
*
|
|
172
|
-
* `account_token_create` is session-only, so this runs over the keeper's
|
|
173
|
-
* session — which also makes the mint itself a live assertion that a narrowed
|
|
174
|
-
* scope is *accepted* at the mint boundary, not merely stored.
|
|
175
|
-
*/
|
|
176
|
-
const mint_scoped_token = async (fixture, resolved_rpc_endpoints) => {
|
|
177
|
-
const found = find_rpc_action(resolved_rpc_endpoints, account_token_create_action_spec.method);
|
|
178
|
-
if (!found) {
|
|
179
|
-
throw new Error(`conformance: principal 'scoped_token' needs '${account_token_create_action_spec.method}' ` +
|
|
180
|
-
`on the surface to mint its narrowed token, but the method is not registered on ` +
|
|
181
|
-
`rpc_endpoints.`);
|
|
182
|
-
}
|
|
183
|
-
return mint_narrowed_api_token({
|
|
184
|
-
app: fixture.transport,
|
|
185
|
-
rpc_path: found.path,
|
|
186
|
-
session_headers: fixture.create_session_headers(),
|
|
187
|
-
methods: [SCOPED_TOKEN_ADMITTED_METHOD],
|
|
188
|
-
name: 'conformance scoped token'
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Map a `ConformancePrincipal` onto the transport + headers it
|
|
193
|
-
* authenticates with, reading exclusively from the per-test `TestFixture`.
|
|
194
|
-
*
|
|
195
|
-
* The always-available principals resolve from fixture accessors (the dead
|
|
196
|
-
* credentials that need a server-side state — a revoked session or token, an
|
|
197
|
-
* expired token — from the fixture's `mint_*` seams); `role_holder` /
|
|
198
|
-
* `wrong_role` read a seeded `extra_accounts` entry named via
|
|
199
|
-
* `options.principals` (throws a clear setup error when unconfigured);
|
|
200
|
-
* `scoped_token` mints its narrowed credential over the production path.
|
|
201
|
-
* Also used outside the table by suites that send a principal's requests
|
|
202
|
-
* themselves (`describe_rpc_adversarial_cross_tests`).
|
|
203
|
-
*
|
|
204
|
-
* @param fixture - the per-test fixture
|
|
205
|
-
* @param as - the principal
|
|
206
|
-
* @param principals - usernames for `role_holder` / `wrong_role`
|
|
207
|
-
* @param resolved_rpc_endpoints - the endpoints `scoped_token` mints through
|
|
208
|
-
* @returns the transport and headers the principal sends with
|
|
209
|
-
*/
|
|
210
|
-
export const resolve_conformance_principal = async (fixture, as, principals, resolved_rpc_endpoints = []) => {
|
|
211
|
-
switch (as) {
|
|
212
|
-
case 'keeper':
|
|
213
|
-
// Keeper carries its session cookie via `create_session_headers`
|
|
214
|
-
// (in-process the transport is stateless; cross-process the jar
|
|
215
|
-
// also holds it — the explicit header is the same value).
|
|
216
|
-
return {
|
|
217
|
-
transport: fixture.transport,
|
|
218
|
-
headers: fixture.create_session_headers(),
|
|
219
|
-
actor_id: fixture.actor.id
|
|
220
|
-
};
|
|
221
|
-
case 'daemon':
|
|
222
|
-
// Daemon-token is a non-browser credential — empty jar + no Origin.
|
|
223
|
-
return {
|
|
224
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
225
|
-
headers: fixture.create_daemon_token_headers(),
|
|
226
|
-
suppress_default_origin: true,
|
|
227
|
-
actor_id: fixture.actor.id
|
|
228
|
-
};
|
|
229
|
-
case 'invalid_daemon':
|
|
230
|
-
// A malformed `X-Daemon-Token` carried ALONGSIDE the keeper's session
|
|
231
|
-
// cookie, over a non-browser (no-Origin) transport. The invalid daemon
|
|
232
|
-
// token is soft-fail-discarded (matching the Rust spine's `None`), so
|
|
233
|
-
// auth falls through to the session leg: the request authenticates as
|
|
234
|
-
// the keeper-via-session (clearing `require_auth`), then the daemon-gated
|
|
235
|
-
// action's credential-type gate refuses the session credential →
|
|
236
|
-
// `403 credential_type_required`. No-Origin keeps the daemon token on
|
|
237
|
-
// the invalid-token path, NOT the browser-context discard. Without the
|
|
238
|
-
// base credential this would 401 (anonymous) — the session is what makes
|
|
239
|
-
// the *credential-type* gate, not the auth gate, the refusing layer.
|
|
240
|
-
return {
|
|
241
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
242
|
-
headers: fixture.create_session_headers({
|
|
243
|
-
[DAEMON_TOKEN_HEADER]: INVALID_DAEMON_TOKEN_VALUE
|
|
244
|
-
}),
|
|
245
|
-
suppress_default_origin: true,
|
|
246
|
-
actor_id: fixture.actor.id
|
|
247
|
-
};
|
|
248
|
-
case 'daemon_browser':
|
|
249
|
-
// A VALID `X-Daemon-Token` carried in a browser context (default Origin
|
|
250
|
-
// present) ALONGSIDE the keeper's session cookie. The daemon-token
|
|
251
|
-
// middleware discards a header-bearing daemon token as browser context
|
|
252
|
-
// (mirroring the bearer guard + the Rust spine's `is_browser_context`),
|
|
253
|
-
// so the valid token is dropped and auth falls through to the session
|
|
254
|
-
// leg → keeper-via-session → a daemon-gated action refuses the session
|
|
255
|
-
// credential with `credential_type_required`. Origin is NOT suppressed —
|
|
256
|
-
// its presence is the browser-context signal under test. Unlike the
|
|
257
|
-
// `daemon` principal (no Origin → token honored → reaches the 400 confirm
|
|
258
|
-
// guard), the 403 here proves the valid token was discarded, not honored.
|
|
259
|
-
return {
|
|
260
|
-
transport: fixture.transport,
|
|
261
|
-
headers: fixture.create_session_headers(fixture.create_daemon_token_headers()),
|
|
262
|
-
actor_id: fixture.actor.id
|
|
263
|
-
};
|
|
264
|
-
case 'token':
|
|
265
|
-
// Bearer is discarded in a browser context — empty jar + no Origin.
|
|
266
|
-
return {
|
|
267
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
268
|
-
headers: fixture.create_bearer_headers(),
|
|
269
|
-
suppress_default_origin: true,
|
|
270
|
-
actor_id: fixture.actor.id
|
|
271
|
-
};
|
|
272
|
-
case 'bearer_browser':
|
|
273
|
-
// A VALID bearer api-token in a browser context (default Origin
|
|
274
|
-
// present), fresh jar so no session rides alongside. The bearer
|
|
275
|
-
// middleware discards a header-bearing token as browser context
|
|
276
|
-
// (mirroring the daemon guard + the Rust spine's `is_browser_context`),
|
|
277
|
-
// so the request arrives anonymous → an authed action 401s. Origin is
|
|
278
|
-
// NOT suppressed (its presence is the browser-context signal) — the
|
|
279
|
-
// inverse of the `token` principal, which suppresses it so the same
|
|
280
|
-
// token is honored. The 401 proves the valid token was discarded, not
|
|
281
|
-
// honored (a non-discarding leg would authenticate → 200).
|
|
282
|
-
return {
|
|
283
|
-
transport: fixture.fresh_transport(),
|
|
284
|
-
headers: fixture.create_bearer_headers()
|
|
285
|
-
};
|
|
286
|
-
case 'malformed_bearer': {
|
|
287
|
-
// The keeper's valid token minus its last character — prefixed, one char
|
|
288
|
-
// short — over the same no-Origin, empty-jar transport as `token`, so the
|
|
289
|
-
// shape precheck (not the browser-context discard) is what refuses it.
|
|
290
|
-
const valid = fixture.create_bearer_headers().authorization;
|
|
291
|
-
if (!valid)
|
|
292
|
-
throw new Error(`conformance: principal 'malformed_bearer' found no bearer header`);
|
|
293
|
-
return {
|
|
294
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
295
|
-
headers: { authorization: valid.slice(0, -1) },
|
|
296
|
-
suppress_default_origin: true
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
case 'scoped_token': {
|
|
300
|
-
// A narrowed bearer, otherwise identical to `token` — empty jar + no
|
|
301
|
-
// Origin, so the credential is honored rather than browser-discarded
|
|
302
|
-
// and the scope gate is what any denial comes from.
|
|
303
|
-
const token = await mint_scoped_token(fixture, resolved_rpc_endpoints);
|
|
304
|
-
return {
|
|
305
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
306
|
-
headers: { authorization: `Bearer ${token}` },
|
|
307
|
-
suppress_default_origin: true,
|
|
308
|
-
actor_id: fixture.actor.id
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
case 'anonymous':
|
|
312
|
-
// Fresh jar so the keeper cookie (cross-process) can't leak in.
|
|
313
|
-
return { transport: fixture.fresh_transport(), headers: {} };
|
|
314
|
-
case 'fresh_non_admin': {
|
|
315
|
-
const account = await fixture.create_account();
|
|
316
|
-
return {
|
|
317
|
-
transport: fixture.fresh_transport(),
|
|
318
|
-
headers: account.create_session_headers(),
|
|
319
|
-
actor_id: account.actor.id
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
case 'expired_session': {
|
|
323
|
-
// The keeper presented via an expired server-side session — fresh
|
|
324
|
-
// jar so only the (expired) cookie this seam returns is sent. The
|
|
325
|
-
// minted cookie payload is valid; the backdated `auth_session` row
|
|
326
|
-
// is what the DB-row expiry gate refuses.
|
|
327
|
-
const cookie = await fixture.mint_expired_session();
|
|
328
|
-
return {
|
|
329
|
-
transport: fixture.fresh_transport(),
|
|
330
|
-
headers: { cookie },
|
|
331
|
-
actor_id: fixture.actor.id
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
case 'tampered_cookie': {
|
|
335
|
-
// fresh jar, so the tampered cookie is the only one sent
|
|
336
|
-
const { cookie } = fixture.create_session_headers();
|
|
337
|
-
if (!cookie)
|
|
338
|
-
throw new Error(`conformance: principal 'tampered_cookie' found no cookie`);
|
|
339
|
-
return {
|
|
340
|
-
transport: fixture.fresh_transport(),
|
|
341
|
-
headers: { cookie: tamper_session_cookie(cookie) }
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
case 'wrong_daemon':
|
|
345
|
-
// no Origin, so the token reaches the compare, not the browser-context discard
|
|
346
|
-
return {
|
|
347
|
-
transport: fixture.fresh_transport({ origin: null }),
|
|
348
|
-
headers: { [DAEMON_TOKEN_HEADER]: WRONG_DAEMON_TOKEN_VALUE },
|
|
349
|
-
suppress_default_origin: true
|
|
350
|
-
};
|
|
351
|
-
case 'unknown_bearer':
|
|
352
|
-
return as_lone_bearer(fixture, UNKNOWN_BEARER_TOKEN_VALUE);
|
|
353
|
-
case 'revoked_session':
|
|
354
|
-
return {
|
|
355
|
-
transport: fixture.fresh_transport(),
|
|
356
|
-
headers: { cookie: await fixture.mint_revoked_session() }
|
|
357
|
-
};
|
|
358
|
-
case 'revoked_token':
|
|
359
|
-
return as_lone_bearer(fixture, await fixture.mint_revoked_token());
|
|
360
|
-
case 'expired_token':
|
|
361
|
-
return as_lone_bearer(fixture, await fixture.mint_expired_token());
|
|
362
|
-
case 'role_holder':
|
|
363
|
-
case 'wrong_role': {
|
|
364
|
-
const username = principals?.[as];
|
|
365
|
-
if (!username) {
|
|
366
|
-
throw new Error(`conformance: principal '${as}' requires options.principals.${as} naming a seeded ` +
|
|
367
|
-
`extra_accounts username (declare the account at setup via extra_accounts).`);
|
|
368
|
-
}
|
|
369
|
-
const extra = fixture.extra_accounts[username];
|
|
370
|
-
if (!extra) {
|
|
371
|
-
throw new Error(`conformance: extra_accounts['${username}'] not seeded for principal '${as}' — ` +
|
|
372
|
-
`declare it in the suite's extra_accounts option.`);
|
|
373
|
-
}
|
|
374
|
-
return {
|
|
375
|
-
transport: fixture.fresh_transport(),
|
|
376
|
-
headers: extra.create_session_headers(),
|
|
377
|
-
actor_id: extra.actor.id
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
114
|
/** Assert each expected field deep-equals the corresponding response field. */
|
|
383
115
|
const assert_fields = (actual, fields, label) => {
|
|
384
116
|
assert.ok(actual !== null && typeof actual === 'object', `${label}: expected an object to read fields from, got ${JSON.stringify(actual)}`);
|
|
@@ -688,7 +420,7 @@ const run_case = async (c, options, resolved_rpc_endpoints) => {
|
|
|
688
420
|
assert_response_headers(sent.headers, c);
|
|
689
421
|
// a frame carries no headers, so the cookie assertions are the HTTP legs'
|
|
690
422
|
if (!options.ws)
|
|
691
|
-
assert_session_cookie(sent, c, options.
|
|
423
|
+
assert_session_cookie(sent, c, options.session_cookie_name);
|
|
692
424
|
const normalized = sent.target.kind === 'rest'
|
|
693
425
|
? assert_rest_case(c, sent.target.route, sent)
|
|
694
426
|
: assert_rpc_case(c, sent.target.action, sent);
|
|
@@ -31,7 +31,7 @@ import '../assert_dev_env.js';
|
|
|
31
31
|
* spine, so this is an imperative suite (not a `conformance_table` row) — the
|
|
32
32
|
* sibling of `origin.ts` / `login_security.ts`. Cross-process only: reading the
|
|
33
33
|
* raw `Set-Cookie` attributes needs the wire response (the in-process
|
|
34
|
-
* `
|
|
34
|
+
* `parse_session_from_cookies` / `session_cookie.rs` unit tests cover each impl's cookie
|
|
35
35
|
* codec directly). Cited property: `docs/security.md` §"Session Security"
|
|
36
36
|
* (the "Cookie attributes" bullet — `HttpOnly; Secure; SameSite=Strict; Path=/`).
|
|
37
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential_deadline.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_deadline.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"credential_deadline.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_deadline.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA0D9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAkB7F,oEAAoE;AACpE,MAAM,WAAW,kCAAmC,SAAQ,gBAAgB;IAC3E,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClD;AAED;;;;GAIG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,kCAAkC,KACzC,IAkKF,CAAC"}
|
|
@@ -40,6 +40,7 @@ import '../assert_dev_env.js';
|
|
|
40
40
|
* @module
|
|
41
41
|
*/
|
|
42
42
|
import { assert, beforeAll, describe } from 'vitest';
|
|
43
|
+
import { check_db_invariants_after_all } from '../db_invariants.js';
|
|
43
44
|
import { heartbeat_action_spec } from '../../actions/heartbeat.js';
|
|
44
45
|
import { WS_CLOSE_CREDENTIAL_EXPIRED_REASON, WS_CLOSE_SESSION_REVOKED } from '../../actions/transports.js';
|
|
45
46
|
import { ROLE_ADMIN } from '../../auth/role_schema.js';
|
|
@@ -107,6 +108,7 @@ export const describe_credential_deadline_cross_tests = (options) => {
|
|
|
107
108
|
// One reset for the suite: the cases share no state past it, since each
|
|
108
109
|
// mints its own account and the seam touches only that account.
|
|
109
110
|
let suite_fixture = null;
|
|
111
|
+
check_db_invariants_after_all(() => suite_fixture);
|
|
110
112
|
beforeAll(async () => {
|
|
111
113
|
if (capabilities.ws || capabilities.sse)
|
|
112
114
|
suite_fixture = await setup_test();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../assert_dev_env.js';
|
|
2
2
|
import { type BuiltinCredentialType } from '../../auth/credential_type_schema.js';
|
|
3
|
-
import type { TestAccount } from '../
|
|
3
|
+
import type { TestAccount } from '../test_app.js';
|
|
4
4
|
import { type RawHttpResponse } from '../transports/raw_http.js';
|
|
5
5
|
import { type RawWsClient } from '../transports/ws_raw_client.js';
|
|
6
6
|
import type { CrossProcessSetupOptions, TestFixture } from './setup.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential_wire.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_wire.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,EAIN,KAAK,qBAAqB,EAC1B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"credential_wire.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/credential_wire.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import '../assert_dev_env.js';
|
|
2
|
+
import { type DifferentialDiff } from './differential_normalize.js';
|
|
3
|
+
import { type ReconstructedBootstrappedBackendHandle } from './setup.js';
|
|
4
|
+
/**
|
|
5
|
+
* The order the canonical walk visits tables in, numbering their ids: each
|
|
6
|
+
* row a later table references is numbered first. A table the database holds
|
|
7
|
+
* and this list doesn't is walked after these, by name.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DB_STATE_TABLES: ReadonlyArray<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Per table, the columns its rows sort by, compared normalized (a reference
|
|
12
|
+
* by the placeholder its row was numbered, a timestamp by rank) ahead of the
|
|
13
|
+
* whole row. `audit_log` sorts by `seq`, numerically. Each table's natural
|
|
14
|
+
* key, so rows tie only when they are alike but for an id — a tie falls back
|
|
15
|
+
* to the raw row, whose order differs per backend.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DB_STATE_SORT_KEYS: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
18
|
+
/** Where the audit sequence stood before a test. */
|
|
19
|
+
export interface DbStateMark {
|
|
20
|
+
readonly audit_seq: number;
|
|
21
|
+
}
|
|
22
|
+
/** A dump as read: per table, each column's type and the rows as JSON. */
|
|
23
|
+
export interface RawDbState {
|
|
24
|
+
/** Per table, column name to `udt_name`. */
|
|
25
|
+
readonly columns: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
26
|
+
readonly rows: Readonly<Record<string, ReadonlyArray<Record<string, unknown>>>>;
|
|
27
|
+
/** The audit sequence's value at the read less the mark's. */
|
|
28
|
+
readonly audit_seq_advance: number;
|
|
29
|
+
}
|
|
30
|
+
/** A dump normalized — what two backends' dumps are compared as. */
|
|
31
|
+
export interface DbState {
|
|
32
|
+
readonly tables: Record<string, Array<Record<string, unknown>>>;
|
|
33
|
+
readonly audit_seq_advance: number;
|
|
34
|
+
}
|
|
35
|
+
/** Reads one backend's database around a test. */
|
|
36
|
+
export interface DbStateProbe {
|
|
37
|
+
/** Where the audit sequence stands — call before the test's fixture. */
|
|
38
|
+
readonly mark: () => Promise<DbStateMark>;
|
|
39
|
+
/** Drain the backend's audit writes, then read and normalize the database. */
|
|
40
|
+
readonly read: (mark: DbStateMark) => Promise<DbState>;
|
|
41
|
+
/** Close the probe's connection. */
|
|
42
|
+
readonly close: () => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Normalize a dump (module doc). Pure; numbering restarts for every call.
|
|
46
|
+
*
|
|
47
|
+
* @param raw - the rows and column types `create_db_state_probe` read
|
|
48
|
+
* @returns the normalized state
|
|
49
|
+
*/
|
|
50
|
+
export declare const normalize_db_state: (raw: RawDbState) => DbState;
|
|
51
|
+
/**
|
|
52
|
+
* Every place two normalized states differ, under `db.`: each table's rows
|
|
53
|
+
* by position, then `db.audit_seq_advance`.
|
|
54
|
+
*
|
|
55
|
+
* @param a - one backend's state
|
|
56
|
+
* @param b - the other's
|
|
57
|
+
* @returns the differences, empty when the states are equal
|
|
58
|
+
*/
|
|
59
|
+
export declare const diff_db_states: (a: DbState, b: DbState) => Array<DifferentialDiff>;
|
|
60
|
+
/**
|
|
61
|
+
* A probe over a backend's database, read directly — the backend's
|
|
62
|
+
* `env.DATABASE_URL` must be a PostgreSQL URL the test process reaches. The
|
|
63
|
+
* read drains the backend's in-flight detached writes (audit rows; on the
|
|
64
|
+
* Rust spine also the token touch and the bootstrap write) first
|
|
65
|
+
* (`_testing_drain_effects`, on the daemon token), so a WebSocket mutation's
|
|
66
|
+
* row has landed.
|
|
67
|
+
*
|
|
68
|
+
* @param handle - the backend
|
|
69
|
+
* @returns the probe; `close` it once its reads are done
|
|
70
|
+
*/
|
|
71
|
+
export declare const create_db_state_probe: (handle: ReconstructedBootstrappedBackendHandle) => DbStateProbe;
|
|
72
|
+
//# sourceMappingURL=db_state_diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db_state_diff.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/db_state_diff.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAkF9B,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAEN,KAAK,sCAAsC,EAC3C,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,MAAM,CAmBjD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAkB9E,CAAC;AAmBF,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,8DAA8D;IAC9D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACnC;AAED,oEAAoE;AACpE,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACnC;AAED,kDAAkD;AAClD,MAAM,WAAW,YAAY;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1C,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAwGD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,UAAU,KAAG,OA8HpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,KAAG,KAAK,CAAC,gBAAgB,CAG7E,CAAC;AAWF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,GACjC,QAAQ,sCAAsC,KAC5C,YA0DF,CAAC"}
|