@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
|
@@ -54,9 +54,12 @@ import '../assert_dev_env.js';
|
|
|
54
54
|
* socket:
|
|
55
55
|
* `account_token_revoke` closes the revoked token's bearer socket and leaves
|
|
56
56
|
* a socket on the account's other token open; `admin_token_revoke_all`,
|
|
57
|
-
* `POST /
|
|
57
|
+
* `POST /password`, and `account_purge` (also gated on
|
|
58
58
|
* `capabilities.account_lifecycle`) close the account's bearer and session
|
|
59
|
-
* sockets
|
|
59
|
+
* sockets, and `POST /logout` closes only the socket of the session it ends,
|
|
60
|
+
* the account's bearer socket and a second session's socket each answering a
|
|
61
|
+
* request after it — the rows `create_account_revocations` shares with the SSE
|
|
62
|
+
* suite;
|
|
60
63
|
* and a token the per-account cap evicts (`max_tokens` further mints) has its
|
|
61
64
|
* bearer socket closed. Omit `rpc_path` to skip them
|
|
62
65
|
* (consumers without the standard account and admin actions on their RPC
|
|
@@ -97,7 +100,8 @@ import { list_audit_events } from './audit_cross_helpers.js';
|
|
|
97
100
|
import { test_if } from './capabilities.js';
|
|
98
101
|
import { cross_rpc_call, expect_output } from './cross_rpc.js';
|
|
99
102
|
import { create_account_revocations } from './revocation_drivers.js';
|
|
100
|
-
import {
|
|
103
|
+
import { login_fresh_session } from './session_login.js';
|
|
104
|
+
import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_LOGOUT_PATH, SPINE_ACCOUNT_PASSWORD_PATH } from './spine_surface_constants.js';
|
|
101
105
|
import { assert_ws_upgrade_refused, open_session_ws } from './ws_endpoint.js';
|
|
102
106
|
/** Origin guaranteed to fail the `http://localhost:*` allowlist the test backends run with. */
|
|
103
107
|
const DISALLOWED_ORIGIN = 'http://disallowed.example';
|
|
@@ -113,7 +117,7 @@ const DISALLOWED_ORIGIN = 'http://disallowed.example';
|
|
|
113
117
|
* audit row read back after `_testing_drain_effects`.
|
|
114
118
|
*/
|
|
115
119
|
export const describe_cross_process_ws_tests = (options) => {
|
|
116
|
-
const { setup_test, capabilities, base_url, ws_path, origin, rpc_path, max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES, logout_path = SPINE_ACCOUNT_LOGOUT_PATH, password_path = SPINE_ACCOUNT_PASSWORD_PATH, ws_account_roles = [] } = options;
|
|
120
|
+
const { setup_test, capabilities, base_url, ws_path, origin, rpc_path, max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES, logout_path = SPINE_ACCOUNT_LOGOUT_PATH, login_path = SPINE_ACCOUNT_LOGIN_PATH, password_path = SPINE_ACCOUNT_PASSWORD_PATH, ws_account_roles = [] } = options;
|
|
117
121
|
const max_tokens = options.max_tokens === undefined ? DEFAULT_MAX_TOKENS : options.max_tokens;
|
|
118
122
|
const open_authed = async () => {
|
|
119
123
|
const fixture = await setup_test();
|
|
@@ -377,9 +381,12 @@ export const describe_cross_process_ws_tests = (options) => {
|
|
|
377
381
|
assert.strictEqual(other.close_code, null);
|
|
378
382
|
});
|
|
379
383
|
});
|
|
380
|
-
// The
|
|
381
|
-
//
|
|
382
|
-
// session socket too.
|
|
384
|
+
// The revocations of `revocation_drivers.ts`, shared with the SSE suite.
|
|
385
|
+
// An account-wide one closes the account's connections — its bearer
|
|
386
|
+
// socket, and its session socket too. A session-scoped one (logout)
|
|
387
|
+
// closes the socket of the session it was sent on, and leaves the
|
|
388
|
+
// account's bearer socket and another session's socket open, each proven
|
|
389
|
+
// by a reply after the close.
|
|
383
390
|
// Without `rpc_path` the rows still register, as skipped cases, and never
|
|
384
391
|
// run — so the empty path is never sent.
|
|
385
392
|
const revocations = create_account_revocations({
|
|
@@ -388,7 +395,46 @@ export const describe_cross_process_ws_tests = (options) => {
|
|
|
388
395
|
logout_path,
|
|
389
396
|
password_path
|
|
390
397
|
});
|
|
391
|
-
for (const { label, slug, gate, revoke } of revocations) {
|
|
398
|
+
for (const { label, slug, gate, closes, revoke } of revocations) {
|
|
399
|
+
if (closes === 'session') {
|
|
400
|
+
test_if(capabilities.ws && gate && rpc_path !== undefined, `${label} closes only its session's socket`, async () => {
|
|
401
|
+
const fixture = await setup_test();
|
|
402
|
+
const target = await fixture.create_account({
|
|
403
|
+
username: `ws_revoke_${slug}`,
|
|
404
|
+
password_value: DEFAULT_TEST_PASSWORD,
|
|
405
|
+
roles: [...ws_account_roles]
|
|
406
|
+
});
|
|
407
|
+
// a second login, a second session of the same account on its own jar
|
|
408
|
+
const second = await login_fresh_session(fixture, {
|
|
409
|
+
login_path,
|
|
410
|
+
username: target.account.username,
|
|
411
|
+
password: DEFAULT_TEST_PASSWORD,
|
|
412
|
+
label: 'the second login'
|
|
413
|
+
});
|
|
414
|
+
await with_sockets([
|
|
415
|
+
() => open_session(target),
|
|
416
|
+
() => open_bearer(target.api_token),
|
|
417
|
+
() => create_admitted_ws_transport({
|
|
418
|
+
base_url,
|
|
419
|
+
ws_path,
|
|
420
|
+
cookies: second.cookies(),
|
|
421
|
+
origin: origin ?? base_url
|
|
422
|
+
})
|
|
423
|
+
], async (session, bearer, other_session) => {
|
|
424
|
+
await revoke(fixture, target);
|
|
425
|
+
await assert_revoked_close(session, `${label} (its session socket)`);
|
|
426
|
+
// the credentials it didn't end keep their sockets
|
|
427
|
+
for (const [what, client] of [
|
|
428
|
+
['bearer socket', bearer],
|
|
429
|
+
['other session socket', other_session]
|
|
430
|
+
]) {
|
|
431
|
+
assert.deepStrictEqual(await client.request(2, heartbeat_action_spec.method, {}), {}, `${label}: the ${what} still answers`);
|
|
432
|
+
assert.strictEqual(client.close_code, null, `${label}: the ${what} stays open`);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
392
438
|
test_if(capabilities.ws && gate && rpc_path !== undefined, `${label} closes the account's bearer and session sockets`, async () => {
|
|
393
439
|
const fixture = await setup_test();
|
|
394
440
|
const target = await fixture.create_account({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon_token_rotation.d.ts","sourceRoot":"","sources":["../../src/lib/testing/daemon_token_rotation.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CA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AAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGvF,8DAA8D;AAC9D,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,iDAAiD;AACjD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,QAAQ,CAAC,CAAC;AAE7F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC9B,SAAS,oBAAoB,EAC7B,YAAY,MAAM,EAClB,OAAO,MAAM,KACX,OAAO,CAAC,IAAI,CAId,CAAC;AAEF,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IACnC,2EAA2E;IAC3E,KAAK,EAAE,gBAAgB,CAAC;IACxB,kGAAkG;IAClG,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,GACvC,SAAS,oBAAoB,GAAG,YAAY,EAC5C,MAAM,SAAS,EACf,SAAS,0BAA0B,EACnC,KAAK,MAAM,KACT,OAAO,CAAC,mBAAmB,CAoD7B,CAAC"}
|
|
@@ -42,9 +42,8 @@ export const start_daemon_token_rotation = async (runtime, deps, options, log) =
|
|
|
42
42
|
if (last_slash > 0) {
|
|
43
43
|
await runtime.mkdir(token_path.slice(0, last_slash), { recursive: true });
|
|
44
44
|
}
|
|
45
|
-
// resolve keeper account (
|
|
46
|
-
//
|
|
47
|
-
// rotation-starts-before-bootstrap case)
|
|
45
|
+
// resolve keeper account (null pre-bootstrap; the bootstrap route sets it
|
|
46
|
+
// once its account commits, given this state on `create_app_server`)
|
|
48
47
|
const keeper_account_id = await resolve_keeper_account_id(deps);
|
|
49
48
|
// generate initial token and write to disk
|
|
50
49
|
const initial_token = generate_daemon_token();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_exposure.d.ts","sourceRoot":"","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"data_exposure.d.ts","sourceRoot":"","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA2B7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAehC,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAIvE;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,OAAO,KAAG,GAAG,CAAC,MAAM,CAmC9E,CAAC;AA0HF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yCAAyC,GACrD,gBAAgB,cAAc,EAC9B,mBAAkB,aAAa,CAAC,MAAM,CAA6B,EACnE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAOF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wCAAwC,GACpD,gBAAgB,cAAc,EAC9B,oBAAmB,aAAa,CAAC,MAAM,CAA8B,EACrE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAYF,CAAC;AAIF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IAuM/E,CAAC"}
|
|
@@ -19,6 +19,7 @@ import './assert_dev_env.js';
|
|
|
19
19
|
* @module
|
|
20
20
|
*/
|
|
21
21
|
import { describe, test, beforeAll, assert } from 'vitest';
|
|
22
|
+
import { check_db_invariants_after_all } from './db_invariants.js';
|
|
22
23
|
import { format_route_key } from '../http/surface_query.js';
|
|
23
24
|
import { ROLE_ADMIN, ROLE_KEEPER } from '../auth/role_schema.js';
|
|
24
25
|
import { create_test_request_headers } from './test_origin.js';
|
|
@@ -236,6 +237,8 @@ export const describe_data_exposure_tests = (options) => {
|
|
|
236
237
|
});
|
|
237
238
|
describe('data exposure — runtime', () => {
|
|
238
239
|
let fixture;
|
|
240
|
+
// `fixture` is unassigned until `beforeAll` runs, which the check allows for
|
|
241
|
+
check_db_invariants_after_all(() => fixture);
|
|
239
242
|
let authed_account;
|
|
240
243
|
let admin_account;
|
|
241
244
|
beforeAll(async () => {
|
package/dist/testing/db.d.ts
CHANGED
|
@@ -111,40 +111,8 @@ export declare const auth_truncate_tables: string[];
|
|
|
111
111
|
* touch audit logging don't need to truncate it.
|
|
112
112
|
*/
|
|
113
113
|
export declare const auth_integration_truncate_tables: string[];
|
|
114
|
-
/**
|
|
115
|
-
* Create a `describe_db` function bound to specific factories and truncate tables.
|
|
116
|
-
*
|
|
117
|
-
* Returns a 2-arg `(name, fn)` function that runs the test suite against each
|
|
118
|
-
* factory. Each factory gets its own `describe` block with a shared database
|
|
119
|
-
* instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
|
|
120
|
-
* Skipped factories use `describe.skip`.
|
|
121
|
-
*
|
|
122
|
-
* @param factories - one or more database factories to run suites against
|
|
123
|
-
* @param truncate_tables - tables to truncate between tests (children first for FK safety)
|
|
124
|
-
* @mutates the underlying database between tests — `beforeEach` issues
|
|
125
|
-
* `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
|
|
126
|
-
*/
|
|
127
|
-
export declare const create_describe_db: (factories: DbFactory | Array<DbFactory>, truncate_tables: Array<string>) => ((name: string, fn: (get_db: () => Db) => void) => void);
|
|
128
114
|
/**
|
|
129
115
|
* Log factory status to console.
|
|
130
116
|
*/
|
|
131
117
|
export declare const log_db_factory_status: (factories: Array<DbFactory>) => void;
|
|
132
|
-
/**
|
|
133
|
-
* Assert a `*_COLUMNS` projection const names exactly the live columns of
|
|
134
|
-
* `table` — the drift guard for an exported const (`ACCOUNT_COLUMNS`,
|
|
135
|
-
* `CELL_COLUMNS`, a consumer's own).
|
|
136
|
-
*
|
|
137
|
-
* This is the reverse of the fail-loud read: a named projection makes a
|
|
138
|
-
* *dropped* column fail loud at query time, but a column *added* to the table
|
|
139
|
-
* and not to the projection would silently vanish from every row read. Both
|
|
140
|
-
* directions are covered by the equality here. It guards one const; it can't
|
|
141
|
-
* see a table that has *no* const — for that, keep a table → const registry
|
|
142
|
-
* and assert its key set against `query_public_columns` (fuz_app's own is
|
|
143
|
-
* `src/test/db/column_projections.db.test.ts`).
|
|
144
|
-
*
|
|
145
|
-
* @param db - a bootstrapped test database
|
|
146
|
-
* @param table - the `public`-schema table the const projects
|
|
147
|
-
* @param columns - the projection const's column names
|
|
148
|
-
*/
|
|
149
|
-
export declare const assert_columns_match_live: (db: Db, table: string, columns: ReadonlyArray<string>) => Promise<void>;
|
|
150
118
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/testing/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,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GAMG;AACH,eAAO,MAAM,gCAAgC,UAAyC,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,KAAK,CAAC,SAAS,CAAC,KAAG,IAQnE,CAAC"}
|
package/dist/testing/db.js
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
/**
|
|
3
|
-
* Test database fixtures for parameterized testing.
|
|
4
|
-
*
|
|
5
|
-
* Provides factory builders for creating test databases with pglet-wasm (the
|
|
6
|
-
* in-memory default), PGlite (in-memory) and pg (PostgreSQL) drivers. Consumer
|
|
7
|
-
* projects provide their own schema initialization via `run_migrations` and
|
|
8
|
-
* compose factories into test suites.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import {create_default_db_factory, create_pg_factory} from '@fuzdev/fuz_app/testing/db.ts';
|
|
13
|
-
* import {run_migrations} from '@fuzdev/fuz_app/db/migrate.ts';
|
|
14
|
-
* import {AUTH_MIGRATION_NS} from '@fuzdev/fuz_app/auth/migrations.ts';
|
|
15
|
-
*
|
|
16
|
-
* const init_schema = async (db) => {
|
|
17
|
-
* await run_migrations(db, [AUTH_MIGRATION_NS]);
|
|
18
|
-
* };
|
|
19
|
-
* const default_factory = create_default_db_factory(init_schema);
|
|
20
|
-
* const pg_factory = create_pg_factory(init_schema, process.env.TEST_DATABASE_URL);
|
|
21
|
-
* export const db_factories = [default_factory, pg_factory];
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @module
|
|
25
|
-
*/
|
|
26
|
-
import { describe, beforeAll, beforeEach, afterAll, assert } from 'vitest';
|
|
27
2
|
import { create_pglite_db } from '../db/db_pglite.js';
|
|
28
3
|
import { create_pglet_db_driver, create_pglet_instance } from '../db/db_pglet.js';
|
|
29
|
-
import { assert_valid_sql_identifier } from '../db/sql_identifier.js';
|
|
30
4
|
import { create_pg_db, create_pg_pool, DEFAULT_DB_CHECKOUT_TIMEOUT_MS, register_pg_type_parsers } from '../db/db_pg.js';
|
|
31
|
-
import { query_public_columns } from '../db/schema_ready.js';
|
|
32
5
|
import { pg_error_code } from '../db/pg_error.js';
|
|
33
6
|
/**
|
|
34
7
|
* Reset a test database to a clean slate by dropping and recreating the `public` schema.
|
|
@@ -244,43 +217,6 @@ export const auth_truncate_tables = [
|
|
|
244
217
|
* touch audit logging don't need to truncate it.
|
|
245
218
|
*/
|
|
246
219
|
export const auth_integration_truncate_tables = [...auth_truncate_tables, 'audit_log'];
|
|
247
|
-
/**
|
|
248
|
-
* Create a `describe_db` function bound to specific factories and truncate tables.
|
|
249
|
-
*
|
|
250
|
-
* Returns a 2-arg `(name, fn)` function that runs the test suite against each
|
|
251
|
-
* factory. Each factory gets its own `describe` block with a shared database
|
|
252
|
-
* instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
|
|
253
|
-
* Skipped factories use `describe.skip`.
|
|
254
|
-
*
|
|
255
|
-
* @param factories - one or more database factories to run suites against
|
|
256
|
-
* @param truncate_tables - tables to truncate between tests (children first for FK safety)
|
|
257
|
-
* @mutates the underlying database between tests — `beforeEach` issues
|
|
258
|
-
* `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
|
|
259
|
-
*/
|
|
260
|
-
export const create_describe_db = (factories, truncate_tables) => {
|
|
261
|
-
const factory_list = Array.isArray(factories) ? factories : [factories];
|
|
262
|
-
return (name, fn) => {
|
|
263
|
-
for (const factory of factory_list) {
|
|
264
|
-
const describe_fn = factory.skip ? describe.skip : describe;
|
|
265
|
-
describe_fn(`${name} (${factory.name})`, () => {
|
|
266
|
-
let db;
|
|
267
|
-
beforeAll(async () => {
|
|
268
|
-
db = await factory.create();
|
|
269
|
-
});
|
|
270
|
-
beforeEach(async () => {
|
|
271
|
-
if (db && truncate_tables.length > 0) {
|
|
272
|
-
await db.query(`TRUNCATE ${truncate_tables.map(assert_valid_sql_identifier).join(', ')} CASCADE`);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
afterAll(async () => {
|
|
276
|
-
if (db)
|
|
277
|
-
await factory.close(db);
|
|
278
|
-
});
|
|
279
|
-
fn(() => db);
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
};
|
|
284
220
|
/**
|
|
285
221
|
* Log factory status to console.
|
|
286
222
|
*/
|
|
@@ -289,25 +225,3 @@ export const log_db_factory_status = (factories) => {
|
|
|
289
225
|
const skipped = factories.filter((f) => f.skip).map((f) => `${f.name} (${f.skip_reason})`);
|
|
290
226
|
console.log(`[db tests] drivers: ${enabled.join(', ')}${skipped.length ? ` | skipped: ${skipped.join(', ')}` : ''}`);
|
|
291
227
|
};
|
|
292
|
-
/**
|
|
293
|
-
* Assert a `*_COLUMNS` projection const names exactly the live columns of
|
|
294
|
-
* `table` — the drift guard for an exported const (`ACCOUNT_COLUMNS`,
|
|
295
|
-
* `CELL_COLUMNS`, a consumer's own).
|
|
296
|
-
*
|
|
297
|
-
* This is the reverse of the fail-loud read: a named projection makes a
|
|
298
|
-
* *dropped* column fail loud at query time, but a column *added* to the table
|
|
299
|
-
* and not to the projection would silently vanish from every row read. Both
|
|
300
|
-
* directions are covered by the equality here. It guards one const; it can't
|
|
301
|
-
* see a table that has *no* const — for that, keep a table → const registry
|
|
302
|
-
* and assert its key set against `query_public_columns` (fuz_app's own is
|
|
303
|
-
* `src/test/db/column_projections.db.test.ts`).
|
|
304
|
-
*
|
|
305
|
-
* @param db - a bootstrapped test database
|
|
306
|
-
* @param table - the `public`-schema table the const projects
|
|
307
|
-
* @param columns - the projection const's column names
|
|
308
|
-
*/
|
|
309
|
-
export const assert_columns_match_live = async (db, table, columns) => {
|
|
310
|
-
const live = await query_public_columns(db, { table });
|
|
311
|
-
assert.ok(live[table], `table "${table}" is not in the live public schema`);
|
|
312
|
-
assert.deepEqual([...columns].sort(), live[table]);
|
|
313
|
-
};
|
|
@@ -70,4 +70,18 @@ export declare const create_test_extra_actor: (db: Db, account_id: string, name:
|
|
|
70
70
|
* multi-actor tombstone state directly (no per-actor-delete RPC ships yet).
|
|
71
71
|
*/
|
|
72
72
|
export declare const soft_delete_test_actor: (db: Db, actor_id: string) => Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Insert an `auth_session` row expiring `expires_in_seconds` after the
|
|
75
|
+
* database's `NOW()` — negative for a session already expired. For tests
|
|
76
|
+
* that need a session of a given lifetime, past or future, which
|
|
77
|
+
* `query_create_session` (always a full `AUTH_SESSION_LIFETIME_MS`) can't
|
|
78
|
+
* write. The same statement as the Rust `_testing_mint_session`.
|
|
79
|
+
*
|
|
80
|
+
* @param db - the database
|
|
81
|
+
* @param token_hash - the session's id, the token's hash (`hash_session_token`)
|
|
82
|
+
* @param account_id - the account the session belongs to
|
|
83
|
+
* @param expires_in_seconds - the expiry's offset from `NOW()`, in seconds
|
|
84
|
+
* @mutates `db` — inserts one `auth_session` row
|
|
85
|
+
*/
|
|
86
|
+
export declare const create_test_session_row: (db: Db, token_hash: string, account_id: string, expires_in_seconds: number) => Promise<void>;
|
|
73
87
|
//# sourceMappingURL=db_entities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_entities.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db_entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA0B7B,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAC1C,IAAI,EAAE,EACN,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,KACnD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ClB,MAAM,MAAM,KACV,OAAO,CAAC,KAAK,CAWf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAU,IAAI,EAAE,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CACvC,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,EAAE,EACN,YAAY,MAAM,EAClB,YAAY,MAAM,EAClB,oBAAoB,MAAM,KACxB,OAAO,CAAC,IAAI,CAMd,CAAC"}
|
|
@@ -89,3 +89,20 @@ export const create_test_extra_actor = async (db, account_id, name) => {
|
|
|
89
89
|
* multi-actor tombstone state directly (no per-actor-delete RPC ships yet).
|
|
90
90
|
*/
|
|
91
91
|
export const soft_delete_test_actor = async (db, actor_id) => query_actor_soft_delete({ db }, actor_id, null);
|
|
92
|
+
/**
|
|
93
|
+
* Insert an `auth_session` row expiring `expires_in_seconds` after the
|
|
94
|
+
* database's `NOW()` — negative for a session already expired. For tests
|
|
95
|
+
* that need a session of a given lifetime, past or future, which
|
|
96
|
+
* `query_create_session` (always a full `AUTH_SESSION_LIFETIME_MS`) can't
|
|
97
|
+
* write. The same statement as the Rust `_testing_mint_session`.
|
|
98
|
+
*
|
|
99
|
+
* @param db - the database
|
|
100
|
+
* @param token_hash - the session's id, the token's hash (`hash_session_token`)
|
|
101
|
+
* @param account_id - the account the session belongs to
|
|
102
|
+
* @param expires_in_seconds - the expiry's offset from `NOW()`, in seconds
|
|
103
|
+
* @mutates `db` — inserts one `auth_session` row
|
|
104
|
+
*/
|
|
105
|
+
export const create_test_session_row = async (db, token_hash, account_id, expires_in_seconds) => {
|
|
106
|
+
await db.query(`INSERT INTO auth_session (id, account_id, expires_at)
|
|
107
|
+
VALUES ($1, $2, NOW() + ($3::double precision * INTERVAL '1 second'))`, [token_hash, account_id, expires_in_seconds]);
|
|
108
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* Database invariants of the auth schema — states no sequence of spine
|
|
4
|
+
* operations may leave behind, checked over the rows themselves.
|
|
5
|
+
*
|
|
6
|
+
* A wire-level test asserts what one request answers; these hold the
|
|
7
|
+
* database a whole test leaves, so a cascade that misses a row (a session
|
|
8
|
+
* outliving its account's tombstone, an offer still pending from a deleted
|
|
9
|
+
* grantor) fails even when no request ever reads the row. One SQL set serves
|
|
10
|
+
* both spines: schema parity keeps their DDL identical.
|
|
11
|
+
*
|
|
12
|
+
* Two kinds:
|
|
13
|
+
*
|
|
14
|
+
* - **State** — over the live rows: no credential of a tombstoned account, no
|
|
15
|
+
* pending offer or unclaimed invite with a dead party, a bootstrapped
|
|
16
|
+
* database keeps a live keeper and a live admin and an unbootstrapped one
|
|
17
|
+
* has no account, an actor's tombstone agrees with its account's, and the
|
|
18
|
+
* structural pairings the writes keep.
|
|
19
|
+
* - **History** — over `audit_log`, so an undelete can't hide a cascade that
|
|
20
|
+
* missed: no pending offer, unclaimed invite or live credential that a
|
|
21
|
+
* successful removal of its account should have ended.
|
|
22
|
+
*
|
|
23
|
+
* An invite's issuer is its `created_by` actor's account, or — once a purge's
|
|
24
|
+
* cascade has nulled `created_by` — the `account_id` of the invite's
|
|
25
|
+
* successful `invite_create` audit row (`metadata.invite_id`; both spines
|
|
26
|
+
* write it). `account_purge` counts as a removal only for invites: a purge's
|
|
27
|
+
* cascade deletes the account's offers, sessions and tokens with it, so for
|
|
28
|
+
* those a purge leaves nothing to check.
|
|
29
|
+
*
|
|
30
|
+
* **Order against a removal.** Where both spines audit the row's creation
|
|
31
|
+
* (`role_grant_offer_create` with `metadata.offer_id`, `invite_create` with
|
|
32
|
+
* `metadata.invite_id`, `token_create` with `metadata.token_id`), the
|
|
33
|
+
* removal's audit `seq` is compared with the creation row's — exact, whatever
|
|
34
|
+
* the clocks: the creation row is written under the account lock the removal
|
|
35
|
+
* takes, in the creating transaction. Otherwise (sessions, and rows written
|
|
36
|
+
* without the action, as the in-process fixture writes them) the timestamps
|
|
37
|
+
* are compared, and a removal in the same clock tick as the creation counts as
|
|
38
|
+
* after it: the database clock may tick in milliseconds (pglet), and a
|
|
39
|
+
* creation tied with the removal that should have ended it is the leak the
|
|
40
|
+
* check exists for, while the opposite order — a removal, an undelete, and a
|
|
41
|
+
* fresh creation in one tick — is not a sequence the tests drive.
|
|
42
|
+
*
|
|
43
|
+
* **The long-transaction walk.** A timestamp is its transaction's start
|
|
44
|
+
* (`created_at` defaults to `NOW()`), not when the row was written, so a
|
|
45
|
+
* timestamp comparison misflags one legal sequence: a login's transaction
|
|
46
|
+
* begins, a delete and then an undelete of its account commit, and only then
|
|
47
|
+
* does the login take the account lock, find the account live, and insert —
|
|
48
|
+
* a session minted after the undelete, its `created_at` before the delete.
|
|
49
|
+
* Nothing drives it: the login must stall between its transaction's start and
|
|
50
|
+
* the account lock while two admin actions commit, which only a test stalling
|
|
51
|
+
* the login's connection between its `BEGIN` and its lock statement could
|
|
52
|
+
* arrange, on Postgres, and none does. Sessions keep this false positive:
|
|
53
|
+
* their creation is audited by `login` (or `signup`, `bootstrap`), whose rows
|
|
54
|
+
* carry no `session_id` to order by, and adding one would change an audit
|
|
55
|
+
* shape on both spines — not taken. An API token minted by
|
|
56
|
+
* `account_token_create` is ordered by its `token_create` row, so the walk
|
|
57
|
+
* can't misflag one — nor could it reach one: that mint re-reads its
|
|
58
|
+
* authorizing session under the account lock, and a delete revokes every
|
|
59
|
+
* session. A token minted without that row (a fixture, a consumer's own mint)
|
|
60
|
+
* falls back to `created_at`.
|
|
61
|
+
*
|
|
62
|
+
* Not invariants, by design: the role grants of a tombstoned actor (kept
|
|
63
|
+
* through delete and undelete, inert while no credential authenticates) and
|
|
64
|
+
* expired credentials no sweep has removed.
|
|
65
|
+
*
|
|
66
|
+
* The whole set is one statement, `DB_INVARIANTS_SQL`, binding the role names
|
|
67
|
+
* as `$1` (keeper) and `$2` (admin). `db_invariants.gen.sql.ts` writes it to
|
|
68
|
+
* `db_invariants.sql`, which the Rust spine's `fuz_testing` embeds byte for
|
|
69
|
+
* byte: the `_testing_db_invariants` backdoor runs it on either spine, so a
|
|
70
|
+
* cross-process harness checks a database it can't reach. Each violation
|
|
71
|
+
* comes back as its invariant's name and the row as JSON text
|
|
72
|
+
* (`jsonb_build_object(...)::text`), parsed on the reading side; exclusions
|
|
73
|
+
* filter the parsed rows (`to_db_invariant_violations`).
|
|
74
|
+
*
|
|
75
|
+
* Vitest-free, so a test binary can mount the backdoor; the per-test hooks
|
|
76
|
+
* live in `db_invariants.ts`.
|
|
77
|
+
*
|
|
78
|
+
* @module
|
|
79
|
+
*/
|
|
80
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
81
|
+
import type { QueryDeps } from '../db/query_deps.js';
|
|
82
|
+
/** One invariant: its name, what it holds, and the query naming the rows that break it. */
|
|
83
|
+
export interface DbInvariant {
|
|
84
|
+
readonly name: string;
|
|
85
|
+
/** The columns `sql` selects, reported for each violating row. */
|
|
86
|
+
readonly columns: ReadonlyArray<string>;
|
|
87
|
+
/** What holds — the message a violation is reported under. */
|
|
88
|
+
readonly description: string;
|
|
89
|
+
/**
|
|
90
|
+
* Selects one row per violation, with the identity needed to debug it. May
|
|
91
|
+
* read the shared CTEs (`role_param`, `removal`, `offer_party`,
|
|
92
|
+
* `invite_issuer`, `token_issued`); the role parameters are read through
|
|
93
|
+
* `role_param`.
|
|
94
|
+
*/
|
|
95
|
+
readonly sql: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Every invariant, in report order. State invariants first, then the history
|
|
99
|
+
* ones over `audit_log`.
|
|
100
|
+
*/
|
|
101
|
+
export declare const DB_INVARIANTS: readonly [{
|
|
102
|
+
readonly name: "credential_of_tombstoned_account";
|
|
103
|
+
readonly columns: readonly ["kind", "id", "account_id"];
|
|
104
|
+
readonly description: "no session or API token belongs to a tombstoned account";
|
|
105
|
+
readonly sql: "SELECT 'auth_session' AS kind, LEFT(s.id, 12) AS id, s.account_id\n\t\t\tFROM auth_session s JOIN account ac ON ac.id = s.account_id\n\t\t\tWHERE ac.deleted_at IS NOT NULL\n\t\t\tUNION ALL\n\t\t\tSELECT 'api_token' AS kind, t.id, t.account_id\n\t\t\tFROM api_token t JOIN account ac ON ac.id = t.account_id\n\t\t\tWHERE ac.deleted_at IS NOT NULL";
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "pending_offer_with_dead_party";
|
|
108
|
+
readonly columns: readonly ["id", "from_actor_id", "from_account_id", "to_account_id", "to_actor_id", "from_actor_dead", "from_account_dead", "to_account_dead", "to_actor_dead"];
|
|
109
|
+
readonly description: "no pending role grant offer has a tombstoned grantor actor, grantor account, recipient account, or recipient actor";
|
|
110
|
+
readonly sql: "SELECT op.id, op.from_actor_id, op.from_account_id, op.to_account_id, op.to_actor_id,\n\t\t\t\tfa.deleted_at IS NOT NULL AS from_actor_dead,\n\t\t\t\tfac.deleted_at IS NOT NULL AS from_account_dead,\n\t\t\t\tta.deleted_at IS NOT NULL AS to_account_dead,\n\t\t\t\tCOALESCE(tac.deleted_at IS NOT NULL, false) AS to_actor_dead\n\t\t\tFROM offer_party op\n\t\t\tJOIN actor fa ON fa.id = op.from_actor_id\n\t\t\tJOIN account fac ON fac.id = op.from_account_id\n\t\t\tJOIN account ta ON ta.id = op.to_account_id\n\t\t\tLEFT JOIN actor tac ON tac.id = op.to_actor_id\n\t\t\tWHERE fa.deleted_at IS NOT NULL OR fac.deleted_at IS NOT NULL\n\t\t\t OR ta.deleted_at IS NOT NULL OR tac.deleted_at IS NOT NULL";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "unclaimed_invite_of_dead_issuer";
|
|
113
|
+
readonly columns: readonly ["id", "created_by", "issuer_account_id", "actor_dead", "issuer_purged"];
|
|
114
|
+
readonly description: "no unclaimed invite was issued by a tombstoned actor, or by an account tombstoned or purged";
|
|
115
|
+
readonly sql: "SELECT ii.id, ii.created_by, ii.issuer_account_id,\n\t\t\t\tii.actor_dead, ac.id IS NULL AS issuer_purged\n\t\t\tFROM invite_issuer ii\n\t\t\tLEFT JOIN account ac ON ac.id = ii.issuer_account_id\n\t\t\tWHERE ii.issuer_account_id IS NOT NULL\n\t\t\t AND (ii.actor_dead OR ac.id IS NULL OR ac.deleted_at IS NOT NULL)";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "bootstrapped_without_live_keeper";
|
|
118
|
+
readonly columns: readonly ["bootstrapped"];
|
|
119
|
+
readonly description: "a bootstrapped database keeps a live actor of a live account holding an active global keeper grant — the keeper is never removable";
|
|
120
|
+
readonly sql: `SELECT true AS bootstrapped FROM bootstrap_lock
|
|
121
|
+
\t\t\tWHERE bootstrapped AND NOT ${string}`;
|
|
122
|
+
}, {
|
|
123
|
+
readonly name: "bootstrapped_without_live_admin";
|
|
124
|
+
readonly columns: readonly ["bootstrapped"];
|
|
125
|
+
readonly description: "a bootstrapped database keeps a live actor of a live account holding an active global admin grant — bootstrap grants one and the last-admin guard keeps one";
|
|
126
|
+
readonly sql: `SELECT true AS bootstrapped FROM bootstrap_lock
|
|
127
|
+
\t\t\tWHERE bootstrapped AND NOT ${string}`;
|
|
128
|
+
}, {
|
|
129
|
+
readonly name: "account_without_bootstrap";
|
|
130
|
+
readonly columns: readonly ["account_id"];
|
|
131
|
+
readonly description: "an unbootstrapped database has no account — the bootstrap that writes the first one flips the lock in its transaction";
|
|
132
|
+
readonly sql: "SELECT ac.id AS account_id FROM account ac\n\t\t\tWHERE NOT EXISTS (SELECT 1 FROM bootstrap_lock WHERE bootstrapped)";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "actor_tombstone_disagrees_with_account";
|
|
135
|
+
readonly columns: readonly ["actor_id", "account_id", "actor_dead", "account_dead"];
|
|
136
|
+
readonly description: "an actor is tombstoned exactly when its account is — no wire path deletes one actor";
|
|
137
|
+
readonly sql: "SELECT a.id AS actor_id, a.account_id,\n\t\t\t\ta.deleted_at IS NOT NULL AS actor_dead, ac.deleted_at IS NOT NULL AS account_dead\n\t\t\tFROM actor a JOIN account ac ON ac.id = a.account_id\n\t\t\tWHERE (a.deleted_at IS NULL) <> (ac.deleted_at IS NULL)";
|
|
138
|
+
}, {
|
|
139
|
+
readonly name: "offer_to_actor_outside_to_account";
|
|
140
|
+
readonly columns: readonly ["id", "to_account_id", "to_actor_id", "to_actor_account_id"];
|
|
141
|
+
readonly description: "an offer's recipient actor belongs to its recipient account";
|
|
142
|
+
readonly sql: "SELECT o.id, o.to_account_id, o.to_actor_id, a.account_id AS to_actor_account_id\n\t\t\tFROM role_grant_offer o JOIN actor a ON a.id = o.to_actor_id\n\t\t\tWHERE a.account_id <> o.to_account_id";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "invite_claimed_by_without_claimed_at";
|
|
145
|
+
readonly columns: readonly ["id", "claimed_by"];
|
|
146
|
+
readonly description: "an invite naming its claimant records when it was claimed";
|
|
147
|
+
readonly sql: "SELECT i.id, i.claimed_by FROM invite i\n\t\t\tWHERE i.claimed_by IS NOT NULL AND i.claimed_at IS NULL";
|
|
148
|
+
}, {
|
|
149
|
+
readonly name: "pending_offer_outlived_party_removal";
|
|
150
|
+
readonly columns: readonly ["id", "from_actor_id", "from_account_id", "to_account_id"];
|
|
151
|
+
readonly description: "no pending offer is older than a successful delete of its grantor or recipient account";
|
|
152
|
+
readonly sql: `SELECT op.id, op.from_actor_id, op.from_account_id, op.to_account_id
|
|
153
|
+
\t\t\tFROM offer_party op
|
|
154
|
+
\t\t\tWHERE ${string}
|
|
155
|
+
\t\t\t OR ${string}`;
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "unclaimed_invite_outlived_issuer_removal";
|
|
158
|
+
readonly columns: readonly ["id", "created_by", "issuer_account_id"];
|
|
159
|
+
readonly description: "no unclaimed invite is older than a successful delete or purge of its issuer account";
|
|
160
|
+
readonly sql: `SELECT ii.id, ii.created_by, ii.issuer_account_id
|
|
161
|
+
\t\t\tFROM invite_issuer ii
|
|
162
|
+
\t\t\tWHERE ${string}`;
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "credential_outlived_account_removal";
|
|
165
|
+
readonly columns: readonly ["kind", "id", "account_id"];
|
|
166
|
+
readonly description: "no session or API token was created before a successful delete of its account";
|
|
167
|
+
readonly sql: `SELECT 'auth_session' AS kind, LEFT(s.id, 12) AS id, s.account_id
|
|
168
|
+
\t\t\tFROM auth_session s
|
|
169
|
+
\t\t\tWHERE ${string}
|
|
170
|
+
\t\t\tUNION ALL
|
|
171
|
+
\t\t\tSELECT 'api_token' AS kind, ti.id, ti.account_id
|
|
172
|
+
\t\t\tFROM token_issued ti
|
|
173
|
+
\t\t\tWHERE ${string}`;
|
|
174
|
+
}];
|
|
175
|
+
/** The name of one of `DB_INVARIANTS`. */
|
|
176
|
+
export type DbInvariantName = (typeof DB_INVARIANTS)[number]['name'];
|
|
177
|
+
/** The rows breaking one invariant. */
|
|
178
|
+
export interface DbInvariantViolation {
|
|
179
|
+
readonly name: DbInvariantName;
|
|
180
|
+
readonly description: string;
|
|
181
|
+
readonly rows: ReadonlyArray<Record<string, unknown>>;
|
|
182
|
+
}
|
|
183
|
+
/** The `DbInvariantExclusions` key that excludes every invariant. */
|
|
184
|
+
export declare const DB_INVARIANTS_EXCLUDE_ALL = "all";
|
|
185
|
+
/**
|
|
186
|
+
* Invariants left unchecked, each by name with the non-empty reason it can't
|
|
187
|
+
* hold for the tests at hand — rows a test writes directly, without the
|
|
188
|
+
* cascade the spine would run. A test an `xfail_until` marker tracks breaks
|
|
189
|
+
* the invariant its gap breaks while the gap is open, and the per-test check
|
|
190
|
+
* fails it whatever the marker expects: exclude that invariant on the setup
|
|
191
|
+
* the marked test uses, with the marker's tracking id in the reason.
|
|
192
|
+
*
|
|
193
|
+
* `all` turns the whole check off, with its reason, and stands alone: a cross-process backend
|
|
194
|
+
* that doesn't serve `_testing_db_invariants` must say so this way, and a
|
|
195
|
+
* setup refuses it otherwise.
|
|
196
|
+
*/
|
|
197
|
+
export type DbInvariantExclusions = Readonly<Partial<Record<DbInvariantName | typeof DB_INVARIANTS_EXCLUDE_ALL, string>>>;
|
|
198
|
+
/**
|
|
199
|
+
* Refuse an exclusion naming no invariant or carrying no reason.
|
|
200
|
+
*
|
|
201
|
+
* @param exclude - the exclusions to check
|
|
202
|
+
* @param label - names the caller in the error
|
|
203
|
+
* @throws Error naming the first unknown invariant or empty reason, or a
|
|
204
|
+
* named invariant beside `all`, which already excludes it
|
|
205
|
+
*/
|
|
206
|
+
export declare const validate_db_invariant_exclusions: (exclude: DbInvariantExclusions | undefined, label: string) => void;
|
|
207
|
+
/**
|
|
208
|
+
* Every invariant in one statement, `$1` the keeper role and `$2` the admin
|
|
209
|
+
* role: one `{invariant, row}` per violating row, `row` its columns as JSON
|
|
210
|
+
* text. What `db_invariants.sql` holds, and what `_testing_db_invariants` runs
|
|
211
|
+
* on both spines.
|
|
212
|
+
*/
|
|
213
|
+
export declare const DB_INVARIANTS_SQL: string;
|
|
214
|
+
/** One violating row: its invariant's name and its columns. */
|
|
215
|
+
export declare const DbInvariantRow: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
216
|
+
invariant: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
217
|
+
row: import("@fuzdev/fuz_schema/schema.ts").RecordSchema<import("@fuzdev/fuz_schema/schema.ts").UnknownSchema>;
|
|
218
|
+
}>;
|
|
219
|
+
export type DbInvariantRow = Infer<typeof DbInvariantRow>;
|
|
220
|
+
/** What `_testing_db_invariants` answers — every violating row, unfiltered. */
|
|
221
|
+
export declare const DbInvariantRows: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
222
|
+
rows: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
223
|
+
invariant: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
|
|
224
|
+
row: import("@fuzdev/fuz_schema/schema.ts").RecordSchema<import("@fuzdev/fuz_schema/schema.ts").UnknownSchema>;
|
|
225
|
+
}>>;
|
|
226
|
+
}>;
|
|
227
|
+
export type DbInvariantRows = Infer<typeof DbInvariantRows>;
|
|
228
|
+
/**
|
|
229
|
+
* Run `DB_INVARIANTS_SQL`, parsing each row's JSON text.
|
|
230
|
+
*
|
|
231
|
+
* @param deps - the database to read
|
|
232
|
+
* @returns every violating row, in no promised order
|
|
233
|
+
*/
|
|
234
|
+
export declare const query_db_invariant_rows: (deps: QueryDeps) => Promise<Array<DbInvariantRow>>;
|
|
235
|
+
/**
|
|
236
|
+
* Group violating rows by invariant, dropping the excluded ones.
|
|
237
|
+
*
|
|
238
|
+
* @param rows - what `query_db_invariant_rows` or `_testing_db_invariants` returned
|
|
239
|
+
* @param exclude - invariants to skip, each with its reason
|
|
240
|
+
* @returns one entry per broken invariant, in `DB_INVARIANTS` order; empty when all hold
|
|
241
|
+
* @throws Error on a row naming no invariant (a reader out of step with the statement)
|
|
242
|
+
*/
|
|
243
|
+
export declare const to_db_invariant_violations: (rows: ReadonlyArray<DbInvariantRow>, exclude?: DbInvariantExclusions) => Array<DbInvariantViolation>;
|
|
244
|
+
/**
|
|
245
|
+
* Query every invariant not excluded, returning those with violating rows.
|
|
246
|
+
*
|
|
247
|
+
* @param deps - the database to read
|
|
248
|
+
* @param exclude - invariants to skip, each with its reason
|
|
249
|
+
* @returns one entry per broken invariant, in `DB_INVARIANTS` order; empty when all hold
|
|
250
|
+
*/
|
|
251
|
+
export declare const query_db_invariant_violations: (deps: QueryDeps, exclude?: DbInvariantExclusions) => Promise<Array<DbInvariantViolation>>;
|
|
252
|
+
/**
|
|
253
|
+
* Render violations as one message, an invariant per paragraph with its rows.
|
|
254
|
+
*
|
|
255
|
+
* @param violations - what `query_db_invariant_violations` returned
|
|
256
|
+
* @param label - names the database (the backend, or the in-process leg)
|
|
257
|
+
*/
|
|
258
|
+
export declare const format_db_invariant_violations: (violations: ReadonlyArray<DbInvariantViolation>, label: string) => string;
|
|
259
|
+
//# sourceMappingURL=db_invariant_queries.d.ts.map
|
|
@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