@fuzdev/fuz_app 0.54.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +214 -103
- package/dist/actions/action_bridge.d.ts +8 -5
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +1 -11
- package/dist/actions/action_codegen.d.ts +32 -0
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +35 -15
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +5 -2
- package/dist/actions/action_rpc.d.ts +141 -22
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +106 -187
- package/dist/actions/action_spec.d.ts +55 -16
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +16 -11
- package/dist/actions/action_types.d.ts +28 -60
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +13 -5
- package/dist/actions/broadcast_api.d.ts +2 -2
- package/dist/actions/broadcast_api.js +2 -2
- package/dist/actions/compile_action_registry.d.ts +50 -0
- package/dist/actions/compile_action_registry.d.ts.map +1 -0
- package/dist/actions/compile_action_registry.js +69 -0
- package/dist/actions/heartbeat.d.ts +8 -4
- package/dist/actions/heartbeat.d.ts.map +1 -1
- package/dist/actions/heartbeat.js +5 -4
- package/dist/actions/perform_action.d.ts +145 -0
- package/dist/actions/perform_action.d.ts.map +1 -0
- package/dist/actions/perform_action.js +258 -0
- package/dist/actions/register_action_ws.d.ts +46 -40
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +101 -159
- package/dist/actions/register_ws_endpoint.d.ts +15 -10
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +54 -7
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +0 -4
- package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
- package/dist/actions/transports_ws_auth_guard.js +1 -1
- package/dist/actions/transports_ws_backend.d.ts +1 -1
- package/dist/actions/transports_ws_backend.js +1 -1
- package/dist/auth/CLAUDE.md +794 -410
- package/dist/auth/account_action_specs.d.ts +28 -7
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +7 -7
- package/dist/auth/account_actions.d.ts +7 -13
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +26 -35
- package/dist/auth/account_queries.d.ts +52 -16
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +87 -38
- package/dist/auth/account_routes.d.ts +9 -11
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +118 -46
- package/dist/auth/account_schema.d.ts +46 -35
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +21 -28
- package/dist/auth/admin_action_specs.d.ts +100 -32
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +64 -33
- package/dist/auth/admin_actions.d.ts +13 -19
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +37 -41
- package/dist/auth/audit_emitter.d.ts +160 -0
- package/dist/auth/audit_emitter.d.ts.map +1 -0
- package/dist/auth/audit_emitter.js +83 -0
- package/dist/auth/audit_log_queries.d.ts +17 -48
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +20 -56
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +7 -3
- package/dist/auth/audit_log_schema.d.ts +92 -32
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +75 -46
- package/dist/auth/auth_guard_resolver.d.ts +44 -0
- package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
- package/dist/auth/auth_guard_resolver.js +56 -0
- package/dist/auth/bearer_auth.d.ts +9 -7
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +13 -21
- package/dist/auth/bootstrap_account.d.ts +7 -7
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +7 -7
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +11 -10
- package/dist/auth/cleanup.d.ts +20 -26
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +33 -42
- package/dist/auth/credential_type_schema.d.ts +115 -0
- package/dist/auth/credential_type_schema.d.ts.map +1 -0
- package/dist/auth/credential_type_schema.js +127 -0
- package/dist/auth/daemon_token_middleware.d.ts +23 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -22
- package/dist/auth/ddl.d.ts +2 -2
- package/dist/auth/ddl.d.ts.map +1 -1
- package/dist/auth/ddl.js +6 -6
- package/dist/auth/deps.d.ts +7 -18
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.d.ts +117 -0
- package/dist/auth/grant_path_schema.d.ts.map +1 -0
- package/dist/auth/grant_path_schema.js +137 -0
- package/dist/auth/invite_queries.d.ts +12 -1
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +12 -1
- package/dist/auth/invite_schema.d.ts +1 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +9 -4
- package/dist/auth/migrations.d.ts +37 -14
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +79 -32
- package/dist/auth/request_context.d.ts +331 -61
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +378 -95
- package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +163 -94
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_action_specs.js +262 -0
- package/dist/auth/role_grant_offer_actions.d.ts +104 -0
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_actions.js +473 -0
- package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +90 -70
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_notifications.js +182 -0
- package/dist/auth/role_grant_offer_queries.d.ts +242 -0
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_queries.js +533 -0
- package/dist/auth/role_grant_offer_schema.d.ts +150 -0
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
- package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +60 -36
- package/dist/auth/role_grant_queries.d.ts +231 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_queries.js +320 -0
- package/dist/auth/role_schema.d.ts +150 -40
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +144 -45
- package/dist/auth/scope_kind_schema.d.ts +96 -0
- package/dist/auth/scope_kind_schema.d.ts.map +1 -0
- package/dist/auth/scope_kind_schema.js +94 -0
- package/dist/auth/self_service_role_action_specs.d.ts +6 -1
- package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
- package/dist/auth/self_service_role_action_specs.js +3 -1
- package/dist/auth/self_service_role_actions.d.ts +34 -27
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +68 -48
- package/dist/auth/session_cookie.d.ts +43 -6
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +31 -5
- package/dist/auth/session_middleware.d.ts +37 -3
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +33 -7
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +48 -19
- package/dist/auth/standard_action_specs.d.ts +2 -2
- package/dist/auth/standard_action_specs.js +4 -4
- package/dist/auth/standard_rpc_actions.d.ts +23 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +12 -12
- package/dist/db/migrate.d.ts +12 -8
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +10 -7
- package/dist/dev/setup.d.ts +2 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +9 -7
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/hono_context.d.ts +64 -5
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +38 -2
- package/dist/http/CLAUDE.md +264 -87
- package/dist/http/auth_shape.d.ts +191 -0
- package/dist/http/auth_shape.d.ts.map +1 -0
- package/dist/http/auth_shape.js +237 -0
- package/dist/http/common_routes.js +3 -3
- package/dist/http/db_routes.d.ts +4 -0
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +44 -7
- package/dist/http/error_schemas.d.ts +132 -19
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +132 -40
- package/dist/http/jsonrpc_errors.d.ts +27 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +26 -2
- package/dist/http/pending_effects.d.ts +71 -18
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +87 -18
- package/dist/http/proxy.d.ts +52 -5
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +92 -14
- package/dist/http/route_spec.d.ts +113 -41
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +130 -52
- package/dist/http/schema_helpers.d.ts +3 -2
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +9 -2
- package/dist/http/surface.d.ts +2 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +1 -2
- package/dist/http/surface_query.d.ts +39 -35
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +79 -36
- package/dist/primitive_schemas.d.ts +39 -0
- package/dist/primitive_schemas.d.ts.map +1 -0
- package/dist/primitive_schemas.js +40 -0
- package/dist/realtime/sse_auth_guard.d.ts +5 -5
- package/dist/realtime/sse_auth_guard.js +9 -9
- package/dist/runtime/mock.d.ts +1 -1
- package/dist/runtime/mock.js +1 -1
- package/dist/server/app_backend.d.ts +14 -11
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +12 -8
- package/dist/server/app_server.d.ts +7 -7
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +36 -31
- package/dist/server/validate_nginx.d.ts +1 -1
- package/dist/server/validate_nginx.js +1 -1
- package/dist/testing/CLAUDE.md +73 -55
- package/dist/testing/admin_integration.d.ts +5 -6
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +100 -96
- package/dist/testing/adversarial_headers.js +1 -1
- package/dist/testing/app_server.d.ts +11 -14
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +18 -17
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +2 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +15 -9
- package/dist/testing/audit_completeness.d.ts +2 -2
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +53 -39
- package/dist/testing/auth_apps.d.ts +5 -4
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +28 -22
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -5
- package/dist/testing/db.d.ts +1 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +4 -4
- package/dist/testing/db_entities.d.ts +22 -0
- package/dist/testing/db_entities.d.ts.map +1 -0
- package/dist/testing/db_entities.js +28 -0
- package/dist/testing/entities.d.ts +10 -8
- package/dist/testing/entities.d.ts.map +1 -1
- package/dist/testing/entities.js +22 -18
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -14
- package/dist/testing/integration_helpers.d.ts +8 -6
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +29 -23
- package/dist/testing/middleware.d.ts +15 -11
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +75 -32
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +40 -24
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -1
- package/dist/testing/rpc_round_trip.d.ts +1 -1
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +14 -13
- 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 +7 -11
- package/dist/testing/standard.d.ts +1 -1
- package/dist/testing/stubs.d.ts +25 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +43 -2
- package/dist/testing/surface_invariants.d.ts +2 -2
- package/dist/testing/ws_round_trip.d.ts +12 -13
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +24 -12
- package/dist/ui/AdminAccounts.svelte +23 -20
- package/dist/ui/AdminOverview.svelte +15 -13
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
- package/dist/ui/BootstrapForm.svelte +1 -1
- package/dist/ui/CLAUDE.md +65 -59
- package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +37 -22
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +20 -0
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
- package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
- package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
- package/dist/ui/SignupForm.svelte +1 -1
- package/dist/ui/SurfaceExplorer.svelte +35 -15
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.js +2 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +25 -18
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +28 -17
- package/dist/ui/admin_rpc_adapters.d.ts +20 -20
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +17 -17
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.js +2 -2
- package/dist/ui/audit_log_state.svelte.d.ts +7 -7
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -6
- package/dist/ui/auth_state.svelte.d.ts +3 -3
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +6 -6
- package/dist/ui/format_scope.d.ts +2 -2
- package/dist/ui/format_scope.js +2 -2
- package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +39 -31
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
- package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +25 -19
- package/dist/ui/ui_format.js +2 -2
- package/package.json +3 -3
- package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
- package/dist/auth/permit_offer_action_specs.js +0 -227
- package/dist/auth/permit_offer_actions.d.ts +0 -110
- package/dist/auth/permit_offer_actions.d.ts.map +0 -1
- package/dist/auth/permit_offer_actions.js +0 -452
- package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
- package/dist/auth/permit_offer_notifications.js +0 -182
- package/dist/auth/permit_offer_queries.d.ts +0 -183
- package/dist/auth/permit_offer_queries.d.ts.map +0 -1
- package/dist/auth/permit_offer_queries.js +0 -408
- package/dist/auth/permit_offer_schema.d.ts +0 -103
- package/dist/auth/permit_offer_schema.d.ts.map +0 -1
- package/dist/auth/permit_queries.d.ts +0 -210
- package/dist/auth/permit_queries.d.ts.map +0 -1
- package/dist/auth/permit_queries.js +0 -294
- package/dist/auth/require_keeper.d.ts +0 -20
- package/dist/auth/require_keeper.d.ts.map +0 -1
- package/dist/auth/require_keeper.js +0 -35
- package/dist/auth/route_guards.d.ts +0 -21
- package/dist/auth/route_guards.d.ts.map +0 -1
- package/dist/auth/route_guards.js +0 -32
- package/dist/auth/session_lifecycle.d.ts +0 -37
- package/dist/auth/session_lifecycle.d.ts.map +0 -1
- package/dist/auth/session_lifecycle.js +0 -29
- package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferForm.svelte.d.ts +0 -14
- package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
- package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
package/dist/testing/db.js
CHANGED
|
@@ -164,8 +164,8 @@ export const AUTH_TRUNCATE_TABLES = [
|
|
|
164
164
|
'invite',
|
|
165
165
|
'api_token',
|
|
166
166
|
'auth_session',
|
|
167
|
-
'
|
|
168
|
-
'
|
|
167
|
+
'role_grant',
|
|
168
|
+
'role_grant_offer',
|
|
169
169
|
'actor',
|
|
170
170
|
'account',
|
|
171
171
|
];
|
|
@@ -192,8 +192,8 @@ export const AUTH_DROP_TABLES = [
|
|
|
192
192
|
'audit_log',
|
|
193
193
|
'api_token',
|
|
194
194
|
'auth_session',
|
|
195
|
-
'
|
|
196
|
-
'
|
|
195
|
+
'role_grant',
|
|
196
|
+
'role_grant_offer',
|
|
197
197
|
'actor',
|
|
198
198
|
'account',
|
|
199
199
|
'bootstrap_lock',
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
2
|
+
import type { Account, Actor } from '../auth/account_schema.js';
|
|
3
|
+
import type { Db } from '../db/db.js';
|
|
4
|
+
/** The `{account, actor}` row pair returned by `create_test_account_with_actor`. */
|
|
5
|
+
export interface TestAccountWithActor {
|
|
6
|
+
account: Account;
|
|
7
|
+
actor: Actor;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create an `account` + `actor` row pair in the database for tests.
|
|
11
|
+
*
|
|
12
|
+
* Wraps `query_create_account_with_actor` with a default `password_hash`
|
|
13
|
+
* so suites that don't exercise password verification can stay terse.
|
|
14
|
+
* Replaces the per-file `create_user` / `create_test_actor` /
|
|
15
|
+
* `create_test_account` helpers that had accumulated across the auth
|
|
16
|
+
* test suite.
|
|
17
|
+
*/
|
|
18
|
+
export declare const create_test_account_with_actor: (db: Db, options: {
|
|
19
|
+
username: string;
|
|
20
|
+
password_hash?: string;
|
|
21
|
+
}) => Promise<TestAccountWithActor>;
|
|
22
|
+
//# sourceMappingURL=db_entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db_entities.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/db_entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,KAAK,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AAEpC,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,GAC1C,IAAI,EAAE,EACN,SAAS;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAC,KACjD,OAAO,CAAC,oBAAoB,CAI7B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import './assert_dev_env.js';
|
|
2
|
+
/**
|
|
3
|
+
* DB-backed entity factories for tests that need real `account` + `actor`
|
|
4
|
+
* rows in the database.
|
|
5
|
+
*
|
|
6
|
+
* Companion to `entities.ts` — that file ships in-memory factories
|
|
7
|
+
* (`create_test_account`, `create_test_actor`) for tests that mock the
|
|
8
|
+
* DB; this file ships factories that hit a real `Db` so query-level
|
|
9
|
+
* tests don't reimplement the same `query_create_account_with_actor`
|
|
10
|
+
* wrapper in every file.
|
|
11
|
+
*
|
|
12
|
+
* For full-fledged test accounts that also need an API token + signed
|
|
13
|
+
* session cookie + role_grants, use `bootstrap_test_account` from
|
|
14
|
+
* `app_server.ts` instead.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { query_create_account_with_actor } from '../auth/account_queries.js';
|
|
19
|
+
/**
|
|
20
|
+
* Create an `account` + `actor` row pair in the database for tests.
|
|
21
|
+
*
|
|
22
|
+
* Wraps `query_create_account_with_actor` with a default `password_hash`
|
|
23
|
+
* so suites that don't exercise password verification can stay terse.
|
|
24
|
+
* Replaces the per-file `create_user` / `create_test_actor` /
|
|
25
|
+
* `create_test_account` helpers that had accumulated across the auth
|
|
26
|
+
* test suite.
|
|
27
|
+
*/
|
|
28
|
+
export const create_test_account_with_actor = async (db, options) => query_create_account_with_actor({ db }, { username: options.username, password_hash: options.password_hash ?? 'hash' });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
import type { Account, Actor,
|
|
2
|
+
import type { Account, Actor, RoleGrant } from '../auth/account_schema.js';
|
|
3
3
|
import type { AuditLogEvent } from '../auth/audit_log_schema.js';
|
|
4
4
|
import type { RequestContext } from '../auth/request_context.js';
|
|
5
5
|
/** Override type for `create_test_account` — id-like fields accept plain `string`. */
|
|
@@ -18,25 +18,27 @@ export type TestActorOverrides = Partial<Omit<Actor, 'id' | 'account_id' | 'upda
|
|
|
18
18
|
};
|
|
19
19
|
/** Create a test `Actor` with sensible defaults. */
|
|
20
20
|
export declare const create_test_actor: (overrides?: TestActorOverrides) => Actor;
|
|
21
|
-
/** Override type for `
|
|
22
|
-
export type
|
|
21
|
+
/** Override type for `create_test_role_grant` — id-like fields accept plain `string`. */
|
|
22
|
+
export type TestRoleGrantOverrides = Partial<Omit<RoleGrant, 'id' | 'actor_id' | 'scope_kind' | 'scope_id' | 'revoked_by' | 'granted_by' | 'source_offer_id'>> & {
|
|
23
23
|
id?: string;
|
|
24
24
|
actor_id?: string;
|
|
25
|
+
scope_kind?: string | null;
|
|
25
26
|
scope_id?: string | null;
|
|
26
27
|
revoked_by?: string | null;
|
|
27
28
|
granted_by?: string | null;
|
|
28
29
|
source_offer_id?: string | null;
|
|
29
30
|
};
|
|
30
|
-
/** Create a test `
|
|
31
|
-
export declare const
|
|
32
|
-
/** Create a test `RequestContext` with
|
|
33
|
-
export declare const create_test_context: (
|
|
31
|
+
/** Create a test `RoleGrant` with sensible defaults. */
|
|
32
|
+
export declare const create_test_role_grant: (overrides?: TestRoleGrantOverrides) => RoleGrant;
|
|
33
|
+
/** Create a test `RequestContext` with role_grants from partial overrides. */
|
|
34
|
+
export declare const create_test_context: (role_grants?: Array<TestRoleGrantOverrides>) => RequestContext;
|
|
34
35
|
/** Override type for `create_test_audit_event` — id-like fields accept plain `string`. */
|
|
35
|
-
export type TestAuditEventOverrides = Partial<Omit<AuditLogEvent, 'id' | 'actor_id' | 'account_id' | 'target_account_id'>> & {
|
|
36
|
+
export type TestAuditEventOverrides = Partial<Omit<AuditLogEvent, 'id' | 'actor_id' | 'account_id' | 'target_account_id' | 'target_actor_id'>> & {
|
|
36
37
|
id?: string;
|
|
37
38
|
actor_id?: string | null;
|
|
38
39
|
account_id?: string | null;
|
|
39
40
|
target_account_id?: string | null;
|
|
41
|
+
target_actor_id?: string | null;
|
|
40
42
|
};
|
|
41
43
|
/** Create a test `AuditLogEvent` with sensible defaults. */
|
|
42
44
|
export declare const create_test_audit_event: (overrides?: TestAuditEventOverrides) => AuditLogEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAC,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE/D,sFAAsF;AACtF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EA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;AAC9E,eAAO,MAAM,mBAAmB,GAC/B,cAAa,KAAK,CAAC,sBAAsB,CAAQ,KAC/C,cAID,CAAC;AAEH,0FAA0F;AAC1F,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC5C,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,UAAU,GAAG,YAAY,GAAG,mBAAmB,GAAG,iBAAiB,CAAC,CAC/F,GAAG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,uBAAuB,GAAI,YAAY,uBAAuB,KAAG,aAa5E,CAAC"}
|
package/dist/testing/entities.js
CHANGED
|
@@ -22,26 +22,29 @@ export const create_test_actor = (overrides) => ({
|
|
|
22
22
|
updated_by: null,
|
|
23
23
|
...overrides,
|
|
24
24
|
});
|
|
25
|
-
/** Create a test `
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
/** Create a test `RoleGrant` with sensible defaults. */
|
|
26
|
+
export const create_test_role_grant = (overrides) => {
|
|
27
|
+
const base = {
|
|
28
|
+
id: 'role-grant-test',
|
|
29
|
+
actor_id: 'actor-test',
|
|
30
|
+
role: 'admin',
|
|
31
|
+
scope_kind: null,
|
|
32
|
+
scope_id: null,
|
|
33
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
34
|
+
expires_at: null,
|
|
35
|
+
revoked_at: null,
|
|
36
|
+
revoked_by: null,
|
|
37
|
+
revoked_reason: null,
|
|
38
|
+
granted_by: null,
|
|
39
|
+
source_offer_id: null,
|
|
40
|
+
};
|
|
41
|
+
return overrides ? { ...base, ...overrides } : base;
|
|
42
|
+
};
|
|
43
|
+
/** Create a test `RequestContext` with role_grants from partial overrides. */
|
|
44
|
+
export const create_test_context = (role_grants = [{}]) => ({
|
|
42
45
|
account: create_test_account(),
|
|
43
46
|
actor: create_test_actor(),
|
|
44
|
-
|
|
47
|
+
role_grants: role_grants.map((p) => create_test_role_grant(p)),
|
|
45
48
|
});
|
|
46
49
|
/** Create a test `AuditLogEvent` with sensible defaults. */
|
|
47
50
|
export const create_test_audit_event = (overrides) => ({
|
|
@@ -52,6 +55,7 @@ export const create_test_audit_event = (overrides) => ({
|
|
|
52
55
|
actor_id: 'actor-test',
|
|
53
56
|
account_id: 'acct-test',
|
|
54
57
|
target_account_id: null,
|
|
58
|
+
target_actor_id: null,
|
|
55
59
|
ip: '127.0.0.1',
|
|
56
60
|
created_at: '2024-01-01T00:00:00Z',
|
|
57
61
|
metadata: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAA6C,KAAK,eAAe,EAAC,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AAOjB,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAA6C,KAAK,eAAe,EAAC,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AAOjB,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAsB1B;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,EAAE,uBAAuB,CAAC;CACvC;AAsBD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mCAAmC,GAC/C,SAAS,8BAA8B,KACrC,IA87CF,CAAC"}
|
|
@@ -26,6 +26,7 @@ import { RateLimiter } from '../rate_limiter.js';
|
|
|
26
26
|
import { run_migrations } from '../db/migrate.js';
|
|
27
27
|
import { ErrorCoverageCollector, assert_error_coverage, DEFAULT_INTEGRATION_ERROR_COVERAGE, } from './error_coverage.js';
|
|
28
28
|
import { ApiError, ERROR_FORBIDDEN_ORIGIN } from '../http/error_schemas.js';
|
|
29
|
+
import { is_public_auth } from '../http/auth_shape.js';
|
|
29
30
|
import { account_verify_action_spec, account_session_list_action_spec, account_session_revoke_action_spec, account_session_revoke_all_action_spec, account_token_create_action_spec, account_token_list_action_spec, account_token_revoke_action_spec, } from '../auth/account_action_specs.js';
|
|
30
31
|
import { invite_create_action_spec } from '../auth/admin_action_specs.js';
|
|
31
32
|
/**
|
|
@@ -93,7 +94,7 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
93
94
|
// dilute the coverage percentage; admin-role routes are scoped
|
|
94
95
|
// to the admin suite instead.
|
|
95
96
|
const auth_routes = captured_route_specs.filter((s) => {
|
|
96
|
-
if (s.auth.
|
|
97
|
+
if (s.auth.roles?.includes('admin') ?? false)
|
|
97
98
|
return false;
|
|
98
99
|
const rest_suffixes = ['/login', '/logout', '/password', '/signup', '/bootstrap'];
|
|
99
100
|
if (rest_suffixes.some((suffix) => s.path.endsWith(suffix)))
|
|
@@ -645,7 +646,7 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
645
646
|
const test_app = await create_test_app(build_test_app_options(options, get_db()));
|
|
646
647
|
// admin routes are optional in the base suite — admin-specific coverage
|
|
647
648
|
// lives in describe_standard_admin_integration_tests
|
|
648
|
-
const admin_route = test_app.route_specs.find((s) => s.auth.
|
|
649
|
+
const admin_route = test_app.route_specs.find((s) => s.auth.roles?.includes('admin') ?? false);
|
|
649
650
|
if (!admin_route)
|
|
650
651
|
return;
|
|
651
652
|
const res = await test_app.app.request(admin_route.path, {
|
|
@@ -788,11 +789,9 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
788
789
|
// --- 9. Response body validation ---
|
|
789
790
|
describe('response body validation', () => {
|
|
790
791
|
// `assert_response_matches_spec` validates REST `RouteSpec` outputs.
|
|
791
|
-
//
|
|
792
|
-
// /
|
|
793
|
-
//
|
|
794
|
-
// /password) against their declared schemas. RPC output validation is
|
|
795
|
-
// covered by `describe_rpc_round_trip_tests`.
|
|
792
|
+
// Session/token CRUD lives on the RPC surface; only /login, /logout,
|
|
793
|
+
// /password remain as REST routes whose responses we exercise here.
|
|
794
|
+
// RPC output validation is covered by `describe_rpc_round_trip_tests`.
|
|
796
795
|
test('POST /login 401 response matches declared error schema', async () => {
|
|
797
796
|
const test_app = await create_test_app(build_test_app_options(options, get_db()));
|
|
798
797
|
const login_route = find_auth_route(test_app.route_specs, '/login', 'POST');
|
|
@@ -1091,12 +1090,12 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
1091
1090
|
describe('signup invite edge cases', () => {
|
|
1092
1091
|
test('signup with non-matching email cannot claim another email invite', async () => {
|
|
1093
1092
|
const test_app = await create_test_app(build_test_app_options(options, get_db()));
|
|
1094
|
-
const signup_route = test_app.route_specs.find((s) => s.method === 'POST' && s.path.endsWith('/signup') && s.auth
|
|
1093
|
+
const signup_route = test_app.route_specs.find((s) => s.method === 'POST' && s.path.endsWith('/signup') && is_public_auth(s.auth));
|
|
1095
1094
|
if (!signup_route)
|
|
1096
1095
|
return; // signup is optional
|
|
1097
|
-
// `invite_create`
|
|
1098
|
-
//
|
|
1099
|
-
//
|
|
1096
|
+
// `invite_create` lives on the RPC surface; consumers that don't
|
|
1097
|
+
// wire admin RPC actions can't exercise invites — skip the test
|
|
1098
|
+
// rather than fail.
|
|
1100
1099
|
if (!find_rpc_action(rpc_endpoints_for_setup, invite_create_action_spec.method))
|
|
1101
1100
|
return;
|
|
1102
1101
|
// Create an admin to manage invites
|
|
@@ -1137,11 +1136,11 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
1137
1136
|
test('no-invite and conflict failure responses are structurally identical', async () => {
|
|
1138
1137
|
const test_app = await create_test_app(build_test_app_options(options, get_db()));
|
|
1139
1138
|
// Find signup route (POST ending in /signup, public)
|
|
1140
|
-
const signup_route = test_app.route_specs.find((s) => s.method === 'POST' && s.path.endsWith('/signup') && s.auth
|
|
1139
|
+
const signup_route = test_app.route_specs.find((s) => s.method === 'POST' && s.path.endsWith('/signup') && is_public_auth(s.auth));
|
|
1141
1140
|
if (!signup_route)
|
|
1142
1141
|
return; // signup is optional
|
|
1143
|
-
// `invite_create`
|
|
1144
|
-
//
|
|
1142
|
+
// `invite_create` lives on the RPC surface; consumers that don't
|
|
1143
|
+
// wire admin RPC actions can't exercise invites.
|
|
1145
1144
|
if (!find_rpc_action(rpc_endpoints_for_setup, invite_create_action_spec.method))
|
|
1146
1145
|
return;
|
|
1147
1146
|
// We need admin access — create an admin account
|
|
@@ -12,10 +12,10 @@ import type { TestApp, TestAccount } from './app_server.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const find_route_spec: (specs: Array<RouteSpec>, method: string, path: string) => RouteSpec | undefined;
|
|
14
14
|
/**
|
|
15
|
-
* REST auth route suffixes
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* REST auth route suffixes on the account/bootstrap surface — the only
|
|
16
|
+
* routes still REST. `find_auth_route` rejects any other suffix at runtime;
|
|
17
|
+
* session/token CRUD, admin operations, and role_grant flows live on the RPC
|
|
18
|
+
* surface and should be reached via `rpc_call`.
|
|
19
19
|
*/
|
|
20
20
|
export declare const REST_AUTH_ROUTE_SUFFIXES: readonly ["/login", "/logout", "/password", "/verify", "/signup", "/bootstrap"];
|
|
21
21
|
export type RestAuthRouteSuffix = (typeof REST_AUTH_ROUTE_SUFFIXES)[number];
|
|
@@ -59,11 +59,13 @@ export declare const check_error_response_fields: (body: Record<string, unknown>
|
|
|
59
59
|
* Assert that an error response contains no leaky field values.
|
|
60
60
|
*
|
|
61
61
|
* Checks both field names and string values for patterns indicating
|
|
62
|
-
* stack traces, SQL, or internal paths.
|
|
62
|
+
* stack traces, SQL, or internal paths. Accepts `unknown` so callers
|
|
63
|
+
* pass response bodies / nested envelope fields directly without
|
|
64
|
+
* intermediate `as` casts; non-object bodies skip the field-name check.
|
|
63
65
|
*
|
|
64
66
|
* @param context - description for error messages
|
|
65
67
|
*/
|
|
66
|
-
export declare const assert_no_error_info_leakage: (body:
|
|
68
|
+
export declare const assert_no_error_info_leakage: (body: unknown, context: string) => void;
|
|
67
69
|
/**
|
|
68
70
|
* Assert that a 429 response includes a valid `Retry-After` header
|
|
69
71
|
* matching the JSON body's `retry_after` field.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAA8B,KAAK,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAE3F,OAAO,KAAK,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,QAAQ,MAAM,EACd,MAAM,MAAM,KACV,SAAS,GAAG,SAad,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,iFAO3B,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,QAAQ,mBAAmB,EAC3B,QAAQ,WAAW,KACjB,SAAS,GAAG,SAOd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,GACxC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,UAAU,QAAQ,KAChB,OAAO,CAAC,IAAI,CAmDd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACtC,SAAS,OAAO,EAChB,iBAAiB,cAAc,CAAC,MAAM,CAAC,KACrC,OAAO,CAAC,MAAM,CAGhB,CAAC;AAgCF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,KAAK,CAAC,MAAM,CAQvF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,GAAI,MAAM,OAAO,EAAE,SAAS,MAAM,KAAG,IAoB7E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oCAAoC,GAChD,UAAU,QAAQ,EAClB,MAAM;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,KACzB,IAUF,CAAC;AAIF,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,EAAE,aAAa,CAAC,MAAM,CAAmC,CAAC;AAEhG,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,EAAE,aAAa,CAAC,MAAM,CAAgC,CAAC;AAE9F;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,KAAG,GAAG,CAAC,MAAM,CAetE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,OAAO,EACb,WAAW,aAAa,CAAC,MAAM,CAAC,EAChC,SAAS,MAAM,KACb,IAKF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS,EACf,UAAU,OAAO,EACjB,gBAAgB,WAAW,EAC3B,eAAe,WAAW,KACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAevB,CAAC"}
|
|
@@ -6,6 +6,7 @@ import './assert_dev_env.js';
|
|
|
6
6
|
*/
|
|
7
7
|
import { assert } from 'vitest';
|
|
8
8
|
import { is_null_schema, merge_error_schemas } from '../http/schema_helpers.js';
|
|
9
|
+
import { is_public_auth } from '../http/auth_shape.js';
|
|
9
10
|
import { create_session_cookie_value } from '../auth/session_cookie.js';
|
|
10
11
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
11
12
|
/**
|
|
@@ -32,10 +33,10 @@ export const find_route_spec = (specs, method, path) => {
|
|
|
32
33
|
});
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
|
-
* REST auth route suffixes
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* REST auth route suffixes on the account/bootstrap surface — the only
|
|
37
|
+
* routes still REST. `find_auth_route` rejects any other suffix at runtime;
|
|
38
|
+
* session/token CRUD, admin operations, and role_grant flows live on the RPC
|
|
39
|
+
* surface and should be reached via `rpc_call`.
|
|
39
40
|
*/
|
|
40
41
|
export const REST_AUTH_ROUTE_SUFFIXES = [
|
|
41
42
|
'/login',
|
|
@@ -133,9 +134,9 @@ export const create_expired_test_cookie = async (keyring, session_options) => {
|
|
|
133
134
|
const KNOWN_SAFE_ERROR_FIELDS = new Set([
|
|
134
135
|
'error',
|
|
135
136
|
'issues',
|
|
136
|
-
'
|
|
137
|
+
'required_roles',
|
|
138
|
+
'required_credential_types',
|
|
137
139
|
'retry_after',
|
|
138
|
-
'credential_type',
|
|
139
140
|
'has_references',
|
|
140
141
|
'ok',
|
|
141
142
|
]);
|
|
@@ -172,16 +173,20 @@ export const check_error_response_fields = (body) => {
|
|
|
172
173
|
* Assert that an error response contains no leaky field values.
|
|
173
174
|
*
|
|
174
175
|
* Checks both field names and string values for patterns indicating
|
|
175
|
-
* stack traces, SQL, or internal paths.
|
|
176
|
+
* stack traces, SQL, or internal paths. Accepts `unknown` so callers
|
|
177
|
+
* pass response bodies / nested envelope fields directly without
|
|
178
|
+
* intermediate `as` casts; non-object bodies skip the field-name check.
|
|
176
179
|
*
|
|
177
180
|
* @param context - description for error messages
|
|
178
181
|
*/
|
|
179
182
|
export const assert_no_error_info_leakage = (body, context) => {
|
|
180
183
|
const body_str = JSON.stringify(body);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
if (body !== null && typeof body === 'object' && !Array.isArray(body)) {
|
|
185
|
+
for (const pattern of LEAKY_FIELD_PATTERNS) {
|
|
186
|
+
// check field names (not values — 'error' legitimately contains error codes)
|
|
187
|
+
for (const key of Object.keys(body)) {
|
|
188
|
+
assert.ok(!key.toLowerCase().includes(pattern), `${context}: error response field '${key}' matches leaky pattern '${pattern}'`);
|
|
189
|
+
}
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
192
|
// check for stack traces and file paths in values
|
|
@@ -250,17 +255,18 @@ export const assert_no_sensitive_fields_in_json = (body, blocklist, context) =>
|
|
|
250
255
|
* - `keeper` — the test app's daemon token
|
|
251
256
|
*/
|
|
252
257
|
export const pick_auth_headers = (spec, test_app, authed_account, admin_account) => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
258
|
+
const { auth } = spec;
|
|
259
|
+
if (is_public_auth(auth)) {
|
|
260
|
+
return { host: 'localhost', origin: 'http://localhost:5173' };
|
|
261
|
+
}
|
|
262
|
+
if (auth.credential_types?.includes('daemon_token')) {
|
|
263
|
+
return test_app.create_daemon_token_headers();
|
|
264
|
+
}
|
|
265
|
+
if (auth.roles?.length) {
|
|
266
|
+
if (auth.roles.includes(ROLE_ADMIN)) {
|
|
267
|
+
return admin_account.create_session_headers();
|
|
268
|
+
}
|
|
269
|
+
return test_app.create_session_headers();
|
|
265
270
|
}
|
|
271
|
+
return authed_account.create_session_headers();
|
|
266
272
|
};
|
|
@@ -25,10 +25,10 @@ export interface BearerAuthTestOptions {
|
|
|
25
25
|
mock_validate_result?: unknown;
|
|
26
26
|
/** What `query_account_by_id()` returns. */
|
|
27
27
|
mock_find_by_id_result?: unknown;
|
|
28
|
-
/** What `
|
|
29
|
-
|
|
30
|
-
/** What `
|
|
31
|
-
|
|
28
|
+
/** What `query_actor_by_id()` returns. */
|
|
29
|
+
mock_find_actor_by_id_result?: unknown;
|
|
30
|
+
/** What `query_role_grant_find_active_for_actor()` returns. */
|
|
31
|
+
mock_role_grants_result?: unknown;
|
|
32
32
|
/** Expected HTTP status, or `'next'` if the middleware should call `next()`. */
|
|
33
33
|
expected_status: number | 'next';
|
|
34
34
|
/** Expected `error` field in JSON response body. */
|
|
@@ -40,11 +40,13 @@ export interface BearerAuthTestOptions {
|
|
|
40
40
|
export interface BearerAuthTestCase extends BearerAuthTestOptions {
|
|
41
41
|
/** Whether the request should reach token validation or be short-circuited. */
|
|
42
42
|
validate_expectation: 'called' | 'not_called';
|
|
43
|
-
/** If true, assert `
|
|
44
|
-
|
|
43
|
+
/** If true, assert `ACCOUNT_ID_KEY` was set and `CREDENTIAL_TYPE_KEY` is `'api_token'`. */
|
|
44
|
+
assert_account_set?: boolean;
|
|
45
|
+
/** Expected `ACCOUNT_ID_KEY` value when `assert_account_set` is true. */
|
|
46
|
+
expected_account_id?: string;
|
|
45
47
|
/** If set, assert `AUTH_API_TOKEN_ID_KEY` was set to this value after a successful bearer auth. */
|
|
46
48
|
expected_api_token_id?: string;
|
|
47
|
-
/** If true, assert the pre-existing session
|
|
49
|
+
/** If true, assert the pre-existing session `ACCOUNT_ID_KEY` and credential type are preserved. */
|
|
48
50
|
assert_context_preserved?: boolean;
|
|
49
51
|
/** Optional callback for custom spy assertions on the mocks bundle. */
|
|
50
52
|
assert_mocks?: (mocks: BearerAuthMocks) => void;
|
|
@@ -53,19 +55,20 @@ export interface BearerAuthTestCase extends BearerAuthTestOptions {
|
|
|
53
55
|
export interface BearerAuthMocks {
|
|
54
56
|
mock_validate: ReturnType<typeof vi.fn>;
|
|
55
57
|
mock_find_by_id: ReturnType<typeof vi.fn>;
|
|
56
|
-
|
|
58
|
+
mock_find_actor_by_id: ReturnType<typeof vi.fn>;
|
|
59
|
+
mock_find_actors_by_account: ReturnType<typeof vi.fn>;
|
|
57
60
|
mock_find_active_for_actor: ReturnType<typeof vi.fn>;
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* Create mock dependencies for `create_bearer_auth_middleware`, configured per test case.
|
|
61
64
|
*
|
|
62
65
|
* Configures the module-level mocks for `query_validate_api_token`,
|
|
63
|
-
* `query_account_by_id`, `
|
|
66
|
+
* `query_account_by_id`, `query_actor_by_id`, and `query_role_grant_find_active_for_actor`
|
|
64
67
|
* so each test case controls return values independently.
|
|
65
68
|
*
|
|
66
69
|
* @returns mocks bundle with spy references
|
|
67
70
|
* @mutates module-level `vi.mock` registrations for `api_token_queries`,
|
|
68
|
-
* `account_queries`, and `
|
|
71
|
+
* `account_queries`, and `role_grant_queries` — each call resets and re-binds
|
|
69
72
|
* the four spies, so cases run in sequence without bleeding state.
|
|
70
73
|
*/
|
|
71
74
|
export declare const create_bearer_auth_mocks: (tc: BearerAuthTestOptions) => BearerAuthMocks;
|
|
@@ -105,7 +108,8 @@ export interface TestMiddlewareStackApp {
|
|
|
105
108
|
app: Hono;
|
|
106
109
|
mock_validate: ReturnType<typeof vi.fn>;
|
|
107
110
|
mock_find_by_id: ReturnType<typeof vi.fn>;
|
|
108
|
-
|
|
111
|
+
mock_find_actor_by_id: ReturnType<typeof vi.fn>;
|
|
112
|
+
mock_find_actors_by_account: ReturnType<typeof vi.fn>;
|
|
109
113
|
mock_find_active_for_actor: ReturnType<typeof vi.fn>;
|
|
110
114
|
}
|
|
111
115
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AAEH,OAAO,EAAC,EAAE,EAAyB,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KA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