@fuzdev/fuz_app 0.181.0 → 0.183.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 +28 -10
- package/dist/actions/action_rpc.d.ts +11 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +3 -2
- package/dist/actions/action_types.d.ts +16 -1
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +1 -1
- package/dist/actions/notification_sender.d.ts +83 -0
- package/dist/actions/notification_sender.d.ts.map +1 -0
- package/dist/actions/notification_sender.js +85 -0
- package/dist/actions/perform_action.d.ts +9 -0
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +22 -13
- package/dist/actions/register_action_ws.d.ts +14 -0
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +3 -2
- package/dist/actions/ws_socket_session.d.ts +3 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +2 -1
- package/dist/auth/CLAUDE.md +113 -70
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +13 -3
- package/dist/auth/account_queries.d.ts +158 -16
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +189 -18
- package/dist/auth/account_routes.d.ts +6 -4
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +98 -92
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +93 -45
- package/dist/auth/api_token_queries.d.ts +13 -5
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +24 -9
- 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 +10 -5
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +22 -6
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +3 -2
- package/dist/auth/bootstrap_account.d.ts +31 -13
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +34 -15
- package/dist/auth/bootstrap_routes.d.ts +1 -1
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +7 -14
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +12 -1
- package/dist/auth/deps.d.ts +18 -5
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/deps.js +3 -2
- package/dist/auth/request_context.d.ts +73 -73
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +78 -96
- package/dist/auth/resolved_auth.d.ts +16 -11
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +6 -6
- package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +2 -1
- package/dist/auth/role_grant_offer_actions.d.ts +32 -12
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +91 -116
- package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +75 -22
- package/dist/auth/role_grant_offer_queries.d.ts +155 -18
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +262 -73
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/role_grant_queries.d.ts +43 -52
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +50 -74
- package/dist/auth/role_grant_sql.d.ts +21 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -1
- package/dist/auth/role_grant_sql.js +21 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +17 -21
- package/dist/auth/session_queries.d.ts +40 -16
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +68 -29
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +90 -38
- package/dist/auth/standard_rpc_actions.d.ts +6 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +5 -6
- package/dist/auth/token_scope.d.ts +1 -1
- package/dist/auth/token_scope.js +1 -1
- package/dist/db/sql_columns.d.ts +1 -1
- package/dist/db/sql_columns.js +1 -1
- package/dist/http/CLAUDE.md +22 -16
- package/dist/http/auth_shape.d.ts +1 -1
- package/dist/http/db_routes.d.ts +7 -22
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +72 -72
- package/dist/http/error_schemas.d.ts +9 -21
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +14 -24
- package/dist/http/pending_effects.d.ts +42 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +34 -4
- package/dist/http/route_spec.d.ts +2 -2
- 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 +69 -18
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +74 -10
- package/dist/server/serve_fact_route.d.ts +3 -3
- package/dist/server/serve_fact_route.js +12 -12
- package/dist/testing/CLAUDE.md +259 -790
- 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 +20 -140
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +48 -125
- 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/auth_apps.js +1 -1
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +43 -0
- 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 +423 -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 +2 -50
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +2 -270
- 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_spine_surface.d.ts +1 -26
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -6
- package/dist/testing/cross_backend/differential.d.ts +11 -2
- 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 +3 -10
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +4 -4
- package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +151 -134
- 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_offer_notification_ws.d.ts +5 -4
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
- 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/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 +48 -16
- package/dist/testing/cross_backend/setup.d.ts +31 -1
- 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 +123 -12
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +454 -57
- 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/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
- 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/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 +6 -9
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +9 -13
- package/dist/testing/integration_helpers.d.ts +1 -1
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/middleware.d.ts +1 -1
- package/dist/testing/middleware.js +5 -5
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -2
- package/dist/testing/resolved_auth.d.ts +3 -1
- package/dist/testing/resolved_auth.d.ts.map +1 -1
- package/dist/testing/resolved_auth.js +4 -4
- 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_round_trip.d.ts +1 -1
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +3 -0
- package/dist/testing/sse_round_trip.d.ts +1 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +13 -4
- package/dist/testing/stubs.d.ts +4 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +15 -7
- package/dist/testing/test_app.d.ts +166 -0
- package/dist/testing/test_app.d.ts.map +1 -0
- package/dist/testing/test_app.js +124 -0
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +8 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws_socket_session.d.ts","sourceRoot":"","sources":["../../src/lib/actions/ws_socket_session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ws_socket_session.d.ts","sourceRoot":"","sources":["../../src/lib/actions/ws_socket_session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AASnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAsBnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAKvF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qCAAqC,MAAM,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,oCAAoC,oDACC,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AAejE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;;OAIG;IACH,EAAE,EAAE,SAAS,CAAC;IACd,uEAAuE;IACvE,aAAa,EAAE,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACvC;;;OAGG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD;;;;;OAKG;IACH,MAAM,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,EAAE,EAAE,SAAS,CAAC;IACd,2CAA2C;IAC3C,aAAa,EAAE,IAAI,CAAC;IACpB,6EAA6E;IAC7E,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAChC,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,EAAE,EAAE,EAAE,CAAC;IACP,yCAAyC;IACzC,GAAG,EAAE,UAAU,CAAC;IAChB,6DAA6D;IAC7D,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,4EAA4E;IAC5E,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3C,4FAA4F;IAC5F,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,iFAAiF;IACjF,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,4CAA4C;IAC5C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,6BAA6B,EAAE,MAAM,CAAC;IACtC,yEAAyE;IACzE,cAAc,EAAE,CAAC,CAAC,GAAG,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/E,kGAAkG;IAClG,eAAe,EAAE,CAAC,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACjF,iEAAiE;IACjE,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,2EAA2E;IAC3E,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;IAChD,oEAAoE;IACpE,mBAAmB,EAAE,kBAAkB,CAAC;IACxC,6FAA6F;IAC7F,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACrF,+EAA+E;IAC/E,cAAc,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC/B,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,cAAc,EAAE;QAAE,eAAe,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAC;IACvE;;;;OAIG;IACH,QAAQ,EAAE,YAAY,CAAC;IACvB,gGAAgG;IAChG,eAAe,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,UAAU,gBAAgB,EAC1B,SAAS,eAAe,KACtB,QA+oBF,CAAC"}
|
|
@@ -204,7 +204,7 @@ const send_error_response = (registry, connection_id, id, error) => {
|
|
|
204
204
|
* @internal
|
|
205
205
|
*/
|
|
206
206
|
export const create_ws_socket_events = (endpoint, upgrade) => {
|
|
207
|
-
const { path, db, log, registry, action_map, receive_timeout, receive_tick_interval, max_message_bytes, pre_admission_queue_max_bytes, on_socket_open, on_socket_close, action_ip_rate_limiter, action_account_rate_limiter, on_effect_error, required_roles } = endpoint;
|
|
207
|
+
const { path, db, log, registry, action_map, receive_timeout, receive_tick_interval, max_message_bytes, pre_admission_queue_max_bytes, on_socket_open, on_socket_close, action_ip_rate_limiter, action_account_rate_limiter, notification_sender, on_effect_error, required_roles } = endpoint;
|
|
208
208
|
const { client_ip, upgrade_preset, resolved, upgrade_context } = upgrade;
|
|
209
209
|
// the request context's account — `register_action_ws` holds it to the
|
|
210
210
|
// credential's before the upgrade
|
|
@@ -648,6 +648,7 @@ export const create_ws_socket_events = (endpoint, upgrade) => {
|
|
|
648
648
|
pending_effects,
|
|
649
649
|
post_commit_effects,
|
|
650
650
|
log,
|
|
651
|
+
notification_sender,
|
|
651
652
|
action_ip_rate_limiter,
|
|
652
653
|
action_account_rate_limiter
|
|
653
654
|
});
|
package/dist/auth/CLAUDE.md
CHANGED
|
@@ -16,9 +16,9 @@ documents the cross-cutting invariants that don't fit on any single symbol.
|
|
|
16
16
|
|
|
17
17
|
## AppDeps split
|
|
18
18
|
|
|
19
|
-
- **Capabilities** — `AppDeps` — stateless, injectable per env: `keyring`, `password`, `db`, `log`, `audit`, `connection_closer` (the `RealtimeCloser` every revocation handler closes live connections through — `actions/CLAUDE.md` §Connection closer).
|
|
19
|
+
- **Capabilities** — `AppDeps` — stateless, injectable per env: `keyring`, `password`, `db`, `log`, `audit`, `connection_closer` (the `RealtimeCloser` every revocation handler closes live connections through — `actions/CLAUDE.md` §Connection closer), `notification_sender` (the `RealtimeNotificationSender` the dispatchers put on every `ActionContext` — `actions/CLAUDE.md` §Notification sender).
|
|
20
20
|
- **Route caps** — `RouteFactoryDeps` — `Omit<AppDeps, 'db'>`; handlers get `db` via `RouteContext`.
|
|
21
|
-
- **Action caps** — `ActionFactoryDeps` (`auth/deps.ts`) — the `{log, audit}` shape action factories take; `RouteFactoryDeps`/`AppDeps` satisfy it structurally
|
|
21
|
+
- **Action caps** — `ActionFactoryDeps` (`auth/deps.ts`) — the `{log, audit}` shape action factories take; `RouteFactoryDeps`/`AppDeps` satisfy it structurally. The factories whose handlers end credentials or revoke roles (`create_account_actions`, `create_admin_actions`, `create_role_grant_offer_actions`, `create_self_service_role_actions`, and the standard bundle) take `RevokingActionFactoryDeps` — `ActionFactoryDeps` plus a required `connection_closer`. The two pure-read actor factories (`actor_lookup`/`actor_search`) take only `{log: Logger}`.
|
|
22
22
|
- **Parameters** — `*Options` — static startup values, per-factory.
|
|
23
23
|
- **Runtime state** — inline ref — mutable values: `bootstrap_status`, `DaemonTokenState`. NOT in deps or options.
|
|
24
24
|
|
|
@@ -38,7 +38,7 @@ over the pool so rows persist when request transactions roll back. See root
|
|
|
38
38
|
- `auth/password_argon2.ts` — `hash_password`, `verify_password`, `verify_dummy`, `argon2_password_deps`.
|
|
39
39
|
- `auth/api_token.ts` — `API_TOKEN_PREFIX` (`secret_fuz_token_`), `ApiTokenId` (the public id, `pipe(string, regex(API_TOKEN_ID_REGEX))`, a `@fuzdev/fuz_schema` schema), `hash_api_token`, `generate_api_token`, and the shape precheck `is_api_token_shaped` (`API_TOKEN_REGEX`: the prefix plus exactly `API_TOKEN_BODY_LENGTH` = 43 base64url chars).
|
|
40
40
|
- `auth/daemon_token.ts` — `DaemonToken`, `DAEMON_TOKEN_REGEX` + the shape precheck `is_daemon_token_shaped` (43 base64url chars), `DAEMON_TOKEN_HEADER` (`X-Daemon-Token`), `generate_daemon_token`, `validate_daemon_token`, `DaemonTokenState`.
|
|
41
|
-
- `auth/bootstrap_account.ts` — `bootstrap_account` (one-shot, `bootstrap_lock`-protected) + `read_bootstrap_token`, the read both it and `check_bootstrap_status` use: the secure read less one trailing LF, a token under `BOOTSTRAP_TOKEN_MIN_BYTES` (32) refused as unreadable with an error log. One transaction holds the whole bootstrap: the lock, the account and grants, the session (`create_capped_session`), and last the burn of the token (`token_store.burn_token`) — a failed burn throws out of the transaction (`BootstrapTokenBurnError`) and answers `token_file_undeletable` with nothing created; the success carries `
|
|
41
|
+
- `auth/bootstrap_account.ts` — `bootstrap_account` (one-shot, `bootstrap_lock`-protected) + `read_bootstrap_token`, the read both it and `check_bootstrap_status` use: the secure read less one trailing LF, a token under `BOOTSTRAP_TOKEN_MIN_BYTES` (32) refused as unreadable with an error log. Takes its deps (`audit` among them) and the request's context (`BootstrapAccountContext`: the pool `db`, the effect queues, `client_ip` — a `RouteContext` satisfies it). One transaction holds the whole bootstrap: the lock, the account and grants, the session (`create_capped_session`) and its `Set-Cookie` line (formatted there, as login and signup format theirs, so a refused value rolls the bootstrap back), the `bootstrap` success audit row, and last the burn of the token (`token_store.burn_token`) — a failed burn throws out of the transaction (`BootstrapTokenBurnError`) and answers `token_file_undeletable` with nothing created; the success carries `set_cookie`, the line the route sets. `BootstrapAccountCreated` is what `on_bootstrap` receives.
|
|
42
42
|
- `auth/bootstrap_token_store.ts` — `BootstrapTokenStore` (`path`, `read_token`, `burn_token`), the one seam to the token file, and `create_file_bootstrap_token_store(deps, path)` over the runtime's secure read and burn. Its read asks the secure read for a single hard link (`require_single_link`): a token file with a second link would outlive its burn under the other name, so it is refused as unreadable, at boot and on a request alike. Twin of the Rust `BootstrapTokenStore` trait, which carries no path (its availability check is handed one).
|
|
43
43
|
|
|
44
44
|
Cross-cutting notes that don't live on any single symbol:
|
|
@@ -74,18 +74,18 @@ Convention — `*_schema.ts` holds a domain's `@fuzdev/fuz_schema` schemas; `*_d
|
|
|
74
74
|
- `auth/role_grant_offer_schema.ts` — `RoleGrantOffer`, `RoleGrantOfferJson` (a `@fuzdev/fuz_schema` `object`: `role` a `RoleName`, `scope_kind` a `ScopeKindName` or `null`, so an offer row holding a name off either grammar fails it), `to_role_grant_offer_json`.
|
|
75
75
|
- `auth/role_grant_offer_ddl.ts` — `role_grant_offer` table + indexes + `ROLE_GRANT_OFFER_SCOPE_SENTINEL_UUID` / `_GLOBAL_TOKEN` + `ROLE_GRANT_OFFER_COLUMNS` and the shared `ROLE_GRANT_OFFER_WITH_GRANTOR_SELECT` CTE tail (homed here per the placement rule in `db/sql_columns.ts`).
|
|
76
76
|
- `auth/role_grant_sql.ts` — the liveness predicates every grant and offer read shares: `role_grant_active_sql(alias)` (not revoked, not expired) and `offer_pending_predicate(alias)` (every `OFFER_TERMINAL_COLUMNS` entry null), twins of the Rust spine's. The frozen partial-index DDL keeps its literal text.
|
|
77
|
-
- `auth/role_grant_offer_notifications.ts` — the WS notification specs for the consentful-grant lifecycle, their `@fuzdev/fuz_schema` params, builders, `role_grant_offer_notification_actions`, `role_grant_offer_notification_specs`, and `create_validated_notification_sender`.
|
|
77
|
+
- `auth/role_grant_offer_notifications.ts` — the WS notification specs for the consentful-grant lifecycle, their `@fuzdev/fuz_schema` params, builders, `role_grant_offer_notification_actions`, `role_grant_offer_notification_specs`, the post-commit send helpers `queue_offer_notification` / `queue_supersede_notifications` (`SupersedeAudience`, `SupersedeCause`), and `create_validated_notification_sender`.
|
|
78
78
|
|
|
79
79
|
### Queries
|
|
80
80
|
|
|
81
81
|
All take `deps: QueryDeps = {db}` first; `query_validate_api_token` adds `log` and returns a `ValidatedApiToken` — the row with `scope` parsed, refusing (returning `undefined` for) a row whose stored scope is unreadable.
|
|
82
82
|
|
|
83
|
-
- `auth/account_queries.ts` — account CRUD, actor resolution, password update with verify-write race guard, paged `query_admin_account_list
|
|
83
|
+
- `auth/account_queries.ts` — account CRUD, actor resolution, password update with verify-write race guard, paged `query_admin_account_list`, and the account-row locks every writer of an account takes first (§Row locks): `query_account_lock_verified` (login) and `query_account_lock_live` (token create), `query_account_lock_live_many` (offer and invite create), `query_account_lock_for_offer_accept`, `query_account_lock_for_revoke`, and the purge's `query_account_lock_admins_for_purge` then `query_account_lock_for_purge`.
|
|
84
84
|
- `auth/actor_lookup_queries.ts` — batched `actor` ⨝ `account` for the labels arc; active actors of active accounts only.
|
|
85
85
|
- `auth/actor_search_queries.ts` — case-insensitive prefix search on `actor.name`, scope-filtered when not admin; active actors of active accounts only.
|
|
86
|
-
- `auth/role_grant_queries.ts` — idempotent create,
|
|
87
|
-
- `auth/role_grant_offer_queries.ts` — offer create/decline/retract/list/history/sweep, atomic `query_accept_offer` with sibling supersede; error classes `RoleGrantOfferSelfTargetError` / `_AlreadyTerminalError` / `_ExpiredError` / `_NotFoundError` / `_ActorAccountMismatchError` / `_ActorMismatchError`.
|
|
88
|
-
- `auth/session_queries.ts` — server-side sessions (blake3-hashed), `create_capped_session` (the one session minter: the row, the cap's evictions, and the signed cookie value — Hono-free, so the bootstrap transaction mints through it; twin of the Rust `create_capped_session`), `query_session_revoke_by_hash_unscoped` (logout only), `query_session_enforce_limit` (transaction-required; returns the evicted sessions' ids — their token hashes — so the caller closes their connections after the commit), `query_session_cleanup_expired` (returns the swept sessions' ids for the same close — `cleanup_expired_sessions` is its caller). No touch/renewal query — `expires_at` is an absolute cap set at mint (`AUTH_SESSION_LIFETIME_MS`). `query_session_is_live(id, account_id)` is the re-read `account_token_create` runs after the account lock: the session that authorized the mint must still exist.
|
|
86
|
+
- `auth/role_grant_queries.ts` — idempotent create, scope-aware lookup, role/account predicates, `query_role_grant_revoke_for_scope` parent-scope cascade.
|
|
87
|
+
- `auth/role_grant_offer_queries.ts` — offer create/decline/retract/list/history/sweep, atomic `query_accept_offer` with sibling supersede (a recipient deleted in flight answers the dead credential's 401), the IDOR-guarded `query_revoke_role_grant` (every revoke's one supersede rule: the revokee's incoming siblings and every offer its actor made, in-tx), and the offer-row lockers `query_role_grant_offer_lock_for_account_removal` / `_for_revoke` over `offer_rows_locked_in_id_order` (`role_grant_sql.ts`; §Row locks); error classes `RoleGrantOfferSelfTargetError` / `_AlreadyTerminalError` / `_ExpiredError` / `_NotFoundError` / `_ActorAccountMismatchError` / `_ActorMismatchError`.
|
|
88
|
+
- `auth/session_queries.ts` — server-side sessions (blake3-hashed), `create_capped_session` (the one session minter: the row, the cap's evictions, and the signed cookie value — Hono-free, so the bootstrap transaction mints through it; twin of the Rust `create_capped_session`), `query_session_revoke_by_hash_unscoped` (logout only), `query_session_enforce_limit` (transaction-required; returns the evicted sessions' ids — their token hashes — so the caller closes their connections after the commit), `query_session_cleanup_expired` (returns the swept sessions' ids for the same close — `cleanup_expired_sessions` is its caller). No touch/renewal query — `expires_at` is an absolute cap set at mint (`AUTH_SESSION_LIFETIME_MS`), on the database clock: `query_create_session` writes `NOW() + INTERVAL '2592000 seconds'` (`AUTH_SESSION_LIFETIME_SQL` — elapsed seconds, as a day interval would follow DST in the session time zone), the Rust insert's statement, so it sits a whole lifetime past the row's `created_at` (a test needing another expiry, past or future, inserts through `testing/db_entities.ts`'s `create_test_session_row`). `query_session_is_live(id, account_id)` is the re-read `account_token_create` runs after the account lock: the session that authorized the mint must still exist.
|
|
89
89
|
- `auth/api_token_queries.ts` — token validation (`query_validate_api_token`, which records nothing) and the separate fire-and-forget usage record (`query_api_token_touch`, which the bearer leg runs only once the token's account is found live), `query_api_token_live_account` (the by-id, no-touch re-check read; shares the `API_TOKEN_IS_LIVE` predicate with the validate query so the two can't drift), IDOR-guarded revoke, `query_api_token_enforce_limit` (transaction-required; returns the evicted tokens' ids for the same post-commit close).
|
|
90
90
|
- `auth/invite_queries.ts` — invite create/find/claim/list/delete; `query_invite_claim_unscoped` (scoping enforced upstream by `_find_unclaimed_match_for_update`, which runs inside the signup tx with `FOR UPDATE` so find + claim are atomic).
|
|
91
91
|
- `auth/app_settings_queries.ts` — load/update for the single-row settings table.
|
|
@@ -103,8 +103,10 @@ without a `satisfies keyof Row` clause, since `AppSettings` deliberately
|
|
|
103
103
|
doesn't carry `id`). Module direction: `role_grant_offer_queries.ts` imports
|
|
104
104
|
`role_grant_queries.ts` (the accept path writes through
|
|
105
105
|
`query_create_role_grant` / `query_role_grant_by_id`) and not the reverse —
|
|
106
|
-
the
|
|
106
|
+
the scope teardown in `role_grant_queries.ts` still _writes_ offer rows, which
|
|
107
107
|
is exactly why the offer const and the shared CTE tail live in the DDL module.
|
|
108
|
+
`query_revoke_role_grant` lives with the offer queries (as in the Rust twin):
|
|
109
|
+
it takes the offer locks and both supersedes.
|
|
108
110
|
Every const is pinned to the live schema by
|
|
109
111
|
`src/test/db/column_projections.db.test.ts`. The Rust `fuz_auth` twin carries
|
|
110
112
|
the same nine consts (names and order), projected through
|
|
@@ -127,14 +129,14 @@ upstream in `auth/signup_routes.ts` via `query_invite_find_unclaimed_match_for_u
|
|
|
127
129
|
`audit_factory` callback over `create_audit_emitter`; closes over the pool +
|
|
128
130
|
its registered listeners + optional `AuditLogConfig`. Its methods:
|
|
129
131
|
|
|
130
|
-
- `emit(ctx, input)` — async, always awaited: a success row
|
|
132
|
+
- `emit(ctx, input)` — async, always awaited: a success row is written in the request's transaction (a failed INSERT rejects, and so does a success row with no transaction open); a failure row is a fire-and-forget pool write pushed to `ctx.pending_effects`; a success row's listener fan-out goes on `ctx.post_commit_effects`
|
|
131
133
|
- `emit_role_grant_target(ctx, auth, input)` — lifts `actor_id` / `account_id` / `ip` boilerplate for role-grant-shape events; `input` is an `AuditEmitRoleGrantInput`
|
|
132
|
-
- `emit_pool(input)` — awaitable pool write for code paths without a request
|
|
134
|
+
- `emit_pool(input)` — awaitable pool write for code paths without a request (ad-hoc maintenance scripts; not for success audits paired with a mutation — those write in-tx). Writes, then notifies, whatever the outcome; a success row written here counts toward `get_audit_success_outside_transaction`, which `install_audit_drift_guard` holds at zero
|
|
133
135
|
- `notify(event)` — fan out an already-written row to listeners (used by in-tx audit batches like `query_accept_offer.audit_events`)
|
|
134
136
|
- `add_listener(listener)` — listener registration, returning a remover for that registration (idempotent; the same function registered twice is two registrations, each with its own remover). Twin of Rust `fuz_auth` `AuditEmitter::add_listener` in firing order and snapshot-at-notify
|
|
135
137
|
- `listener_count()` — registered-listener count, for tests / diagnostics
|
|
136
|
-
- `drain_inflight()` —
|
|
137
|
-
- `
|
|
138
|
+
- `drain_inflight()` — waits until no pool write is in flight, writes started while waiting included. Every emitter counts them. `AppServer.close` awaits it, bounded by `shutdown_drain_timeout_ms`, before the database closes; it backs `_testing_drain_effects` (twin of Rust `AuditEmitter::drain_inflight`)
|
|
139
|
+
- `inflight_count()` — pool writes in flight now; what a shutdown that gives up at its bound reports (twin of Rust `AuditEmitter::inflight_count`)
|
|
138
140
|
|
|
139
141
|
Listeners are closure-private; they change only through `add_listener` and
|
|
140
142
|
its removers. `create_app_server` registers the audit-log SSE listener and the
|
|
@@ -147,25 +149,27 @@ the next event, and one removed mid-fan-out still hears the in-flight event
|
|
|
147
149
|
(converges with the Rust twin's cloned vec).
|
|
148
150
|
|
|
149
151
|
**Where a row is written.** `emit` is async — always `await` it. A **success**
|
|
150
|
-
row
|
|
151
|
-
with `side_effects`, a route with
|
|
152
|
-
transaction
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
row is written in the transaction of the change it reports
|
|
153
|
+
(`ctx.db.in_transaction`: an action with `side_effects`, a route with
|
|
154
|
+
`transaction: true` — `/logout`, `db_admin_row_delete` — or the transaction
|
|
155
|
+
`/login`, `/password`, signup and bootstrap open around just their writes
|
|
156
|
+
through `transaction_with_post_commit_rollback`, the row last before the
|
|
157
|
+
commit), so the change and its row commit together; a failed INSERT rejects
|
|
158
|
+
`emit` and the transaction rolls back. With no transaction open `emit` refuses
|
|
159
|
+
a success row (throws, writes nothing, and counts it for the drift guard). A
|
|
160
|
+
**failure** row is a fire-and-forget pool write, fail-open (logged, counted by
|
|
157
161
|
`get_audit_write_failures`). The Rust spine's split is the same
|
|
158
|
-
(`route_audit_emit`: `emit_in_tx` for
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
pool after its commit on both twins (TS: `emit_pool` from a post-commit
|
|
162
|
-
thunk).
|
|
162
|
+
(`route_audit_emit`: `emit_in_tx` for every success row, REST and db-admin
|
|
163
|
+
included, `emit` on the pool for failure rows). `seq` follows INSERT order,
|
|
164
|
+
not commit order.
|
|
163
165
|
|
|
164
166
|
**When listeners hear about a row.** The fan-out depends on the outcome: a
|
|
165
167
|
**failure** row is announced as soon as it is written — the attempt happened
|
|
166
168
|
whatever the transaction does; a **success** row is announced only after the
|
|
167
|
-
request's transaction commits (a thunk on `ctx.post_commit_effects
|
|
168
|
-
|
|
169
|
+
request's transaction commits (a thunk on `ctx.post_commit_effects`) and never
|
|
170
|
+
when it rolls back — a handler-owned transaction truncates the queue itself
|
|
171
|
+
(`transaction_with_post_commit_rollback`), so a handler that catches its
|
|
172
|
+
failure and answers a refusal announces nothing. The listeners act on a success row — the revocation guards
|
|
169
173
|
close connections, the audit stream broadcasts it — so announcing one before
|
|
170
174
|
its commit would close while the revoked credential still reads as valid, and
|
|
171
175
|
a rolled-back revocation would close anyway. A route that runs without a
|
|
@@ -193,13 +197,17 @@ they track the same config. Sample via `get_*`; `reset_*` are test-only.
|
|
|
193
197
|
Another counter lives with the emitter (`auth/audit_emitter.ts`,
|
|
194
198
|
`get_audit_write_failures` / `reset_audit_write_failures`): rows the bound
|
|
195
199
|
emitter's pool write failed to insert. That write is fail-open too — logged,
|
|
196
|
-
counted, the request proceeds — so the count is how a lost row is seen.
|
|
200
|
+
counted, the request proceeds — so the count is how a lost row is seen. A
|
|
201
|
+
third, `get_audit_success_outside_transaction` /
|
|
202
|
+
`reset_audit_success_outside_transaction`, counts success rows written
|
|
203
|
+
outside a transaction (`emit` with none open, which also throws, and a success
|
|
204
|
+
`emit_pool`); `install_audit_drift_guard` holds all of them at zero per test.
|
|
197
205
|
|
|
198
206
|
### Routes
|
|
199
207
|
|
|
200
208
|
- `auth/account_routes.ts` — `POST /login` / `/logout` / `/password`, `GET /api/account/status`. Constants: `DEFAULT_MAX_SESSIONS = 5`, `DEFAULT_MAX_TOKENS = 10`, `DEFAULT_LOGIN_FAIL_FLOOR_MS = 250`, `DEFAULT_LOGIN_FAIL_JITTER_MS = 25`.
|
|
201
209
|
- `auth/bootstrap_routes.ts` — `POST /bootstrap` + `check_bootstrap_status` (the boot report: the lock read first; a token file left on a bootstrapped database and an unreadable one on an open window each warn; a missing lock row reads unavailable); `BootstrapStatus` runtime ref (`{available}`); `OnBootstrap`, the post-commit callback over what was created. A failed burn answers 500 `token_file_undeletable` with the window left open; the lock race loser closes its window with no audit row and no charge.
|
|
202
|
-
- `auth/signup_routes.ts` — `POST /signup` (open or invite-gated).
|
|
210
|
+
- `auth/signup_routes.ts` — `POST /signup` (open or invite-gated). The `signup` success row is written last in the signup transaction; every unclassified failure writes a `signup` failure row with reason `internal_error` — one before the transaction began (the settings load, the hash, a refused `BEGIN`) carries neither `invite_id` nor `open_signup`, as the Rust spine's pre-transaction row. A failure row's emit that throws is logged, never answered in place of the original error.
|
|
203
211
|
- `auth/audit_log_routes.ts` — optional `GET /audit/stream` (SSE); list/history are on the RPC surface. Takes `stream: {registry, log}` (an `AuditLogSse` satisfies it). The handler admits the stream in two phases — register pending on the `SseRegistry`, re-read the credential (`revalidate_resolved_auth`) and the acting actor's role grants, admit — so a revocation racing the request opens no stream: 401 / 403 from the re-reads, or a 200 whose body is the connect comment alone when the pending registration was closed.
|
|
204
212
|
- `auth/auth_guard_resolver.ts` — `fuz_auth_guard_resolver` injected into `apply_route_specs` so the framework stays auth-agnostic. Maps each `RouteAuth` axis to a guard and is the single site every route spec traverses, so it also carries the two invariants the auth shape alone can't (a `required_scope` that isn't a well-formed capability, and one on an unrestricted route).
|
|
205
213
|
|
|
@@ -241,9 +249,10 @@ tokens (force re-auth everywhere), then clears the session cookie. Declares
|
|
|
241
249
|
`credential_types: ['session']` (see ../../../docs/security.md
|
|
242
250
|
§Credential-channel gating).
|
|
243
251
|
|
|
244
|
-
**The routes close what they revoke, after the commit.** `/
|
|
245
|
-
|
|
246
|
-
|
|
252
|
+
**The routes close what they revoke, after the commit.** `/password` queues an
|
|
253
|
+
account-wide close, `/logout` a session close for the session it ends (the
|
|
254
|
+
account's other sessions and tokens stay valid, and their connections open),
|
|
255
|
+
and `/login` a session close for each session its cap evicted (`queue_connection_close` on
|
|
247
256
|
`deps.connection_closer`). The queue runs once the route's transaction has
|
|
248
257
|
committed and is dropped if the handler throws.
|
|
249
258
|
|
|
@@ -254,9 +263,9 @@ Everything else listed under §RPC action surfaces.
|
|
|
254
263
|
### Middleware
|
|
255
264
|
|
|
256
265
|
- `auth/middleware.ts` — `create_auth_middleware_specs(deps, options)` assembles `[origin, daemon_token?, session, request_context, bearer_auth]`, the `daemon_token` layer only when given a `daemon_token_state` — the credential legs in the Rust spine's `resolve_auth_from_headers` order, daemon token → session cookie → bearer, the first that authenticates setting `ResolvedAuth` and the later ones skipping. The chain starts from a clean slate: the first leg composed — the daemon token's, else the session's (`create_request_context_middleware`'s `starts_chain`, which the stack sets `false` behind the daemon leg) — clears `RESOLVED_AUTH_KEY` on entry, so a layer mounted before the stack can't pre-set an identity every leg would skip past, and debug-logs a clear that finds one — the trace of a hand-built chain whose session leg sits behind its own earlier leg without `starts_chain: false` (the content-type refusal isn't a middleware: `apply_route_specs` checks every `POST` route, see `http/simple_request.ts`). The origin check mounts on every path (`ORIGIN_MIDDLEWARE_PATH`, `'*'`), less its `origin_carve_outs` — each a `MiddlewareCarveOut` (`{path, reason}`, copied and frozen at assembly by `freeze_origin_carve_outs`, refused by `assert_origin_carve_outs_valid` without a reason or when it overlaps the auth scope — `middleware_paths_overlap` against `AUTH_MIDDLEWARE_PATH`, which holds every credential-reading and credential-minting route — and recorded on the origin spec so the surface leaves its `403` off the carved routes); `AUTH_MIDDLEWARE_PATH` (`'/api/*'`) is where `create_app_server` mounts the rest of the stack; assembly asserts lean on it: `assert_endpoint_in_auth_scope` (an `rpc_endpoints` / `ws_endpoints` path, or the bootstrap route under `bootstrap.route_prefix`, must sit inside it — so no carve-out can reach one), `assert_credential_routes_in_auth_scope(route_specs)` (every registered route that reads a credential — `auth.account` not `'none'`, or marked `reads_credential`, as account status is — or is marked `mints_credential` — login, signup, bootstrap — must sit inside it too, so a consumer prefixing the relative account or signup specs outside `/api/` is refused), and `assert_middleware_stack_mounted(stack_specs, middleware_specs)`, run on a `transform_middleware` result against the pre-transform stack (`[host?, proxy, ...auth]`) — each stack spec, matched by its `handler` closure (not its spoofable `name`), mounted exactly once at its original path (`'*'` for the host gate, the trusted proxy and the origin check, `AUTH_MIDDLEWARE_PATH` for the rest of auth), in its original order; other specs may sit anywhere, including before the proxy and between the auth layers. The proxy is in the stack because dropping it turns every `get_client_ip` into `'unknown'`, one shared bucket for every IP-keyed limiter. The transform receives shallow copies in a fresh array, so an in-place mutation can't rewrite the originals the check reads. The check pins where those layers sit, not what added layers do — a layer you add runs with full context access. Both run in `create_test_app_surface_spec` too.
|
|
257
|
-
- `auth/request_context.ts` — `RequestContext`, `resolve_acting_actor`, `build_request_context`, predicates (`has_scoped_role`, `has_any_scoped_role` — the dispatcher's role gate and every builtin-role check read the **global** grant via `has_scoped_role(_, role, null)` / `has_any_scoped_role(_, roles, null)`), guards (`require_auth`, `require_role`, `require_credential_types`, `require_token_scope`), `token_scope_surface_denial` (the direct-call form, for surfaces that aren't route specs), `
|
|
266
|
+
- `auth/request_context.ts` — `RequestContext`, `resolve_acting_actor`, `build_request_context`, predicates (`has_scoped_role`, `has_any_scoped_role` — the dispatcher's role gate and every builtin-role check read the **global** grant via `has_scoped_role(_, role, null)` / `has_any_scoped_role(_, roles, null)`), guards (`require_auth`, `require_role`, `require_credential_types`, `require_token_scope`), `token_scope_surface_denial` (the direct-call form, for surfaces that aren't route specs), `get_public_account(route)` (the account a `reads_credential` route may read, off the route context's `credential` — `null` for a scope-narrowed token, which such a route answers as anonymous; twin of the Rust `AuthGate::public_request_context` downgrade), `RequestContextForAuth` (the request context a spec's `auth` promises its handler — the one narrowing a route handler's `route.auth` and an action handler's `ctx.auth` share), `refresh_role_grants`.
|
|
258
267
|
- `auth/session_middleware.ts` — `create_session_middleware` (reads the cookie through `read_session_cookie_value`, never a framework cookie parser; puts the clear for a cookie that is present and invalid on the context's prepared headers before the handler runs, so every response built through the context carries it once — every route result, which the spine emits there after the commit, ahead of the success's own cookie lines, and the middleware's and error handlers' answers. It never reads or rewrites a response: doing so changes framing and content type on the runtimes' own `Response` classes. What still carries no clear is what the route system doesn't build — a consumer's own middleware or raw Hono route answering with a `Response` it made or replacing the context's `Set-Cookie`, and an accepted WebSocket upgrade's placeholder — where the Rust stack's cookie-clear layer clears every non-`101`. The middleware records the clear line it wrote (`EXPECTED_FIRST_SET_COOKIE_KEY`), and in DEV an answer that doesn't lead with it is logged (`http/dev_set_cookie_check.ts`), the upgrade excepted), `get_session_cookie`. A route sets or clears the session cookie on its success result (`route_ok(value, {set_cookie})`) with `session_cookie_header` / `clear_session_cookie_header` of `auth/session_cookie.ts`; nothing in fuz_app writes a cookie on the context but the middleware's clear. Login, signup and bootstrap each mint through `create_capped_session` (`auth/session_queries.ts`) inside a transaction of their own.
|
|
259
|
-
- `auth/resolved_auth.ts` — `ResolvedAuth`, the resolved credential as one value — a union on `credential_type`, each arm carrying only its own fields: `session` (`
|
|
268
|
+
- `auth/resolved_auth.ts` — `ResolvedAuth`, the resolved credential as one value — a union on `credential_type`, each arm carrying only its own fields: `session` (`account`, `session_hash`, `credential_deadline`), `api_token` (`account`, `api_token_id`, `scope`, `credential_deadline`), `daemon_token` (`account`, `credential_deadline: null`) — `account` the row the credential leg read, which the authorization phase builds on rather than reading the account again, as the Rust `ResolvedAuth::account` does (the daemon leg reads the keeper's row per request); `get_resolved_auth(c)` (reads it off `RESOLVED_AUTH_KEY`, the one context key every auth leg writes); the accessors `resolved_auth_scope` (an API token's scope, `full` for a session or daemon token, `null` for anonymous — every token-scope gate reads it), `resolved_auth_session_hash`, and `resolved_auth_api_token_id`; and `revalidate_resolved_auth(deps, resolved)`, the no-touch re-read a long-lived connection runs once it is registered: session row / token row (by id) still live and still on the account, account not soft-deleted; a daemon token re-reads its account only. Reuses the middleware's own queries and predicates. Called by the WS socket session (`actions/ws_socket_session.ts`) and the audit SSE route between registering a connection pending and admitting it. Twin of the Rust `revalidate_resolved_auth`.
|
|
260
269
|
- `auth/credential_deadline.ts` — when a resolved credential stops authenticating, which a WebSocket or audit stream opened on it closes at (expiry writes nothing a revocation listener hears): `credential_deadline_after` (the earliest remaining lifetime, anchored to `performance.now()`), `EXPIRES_IN_MS_SQL` (a row's `expires_at - NOW()`, read on the database clock in the statement that checks it, so the session and token validation queries return `expires_in_ms`), and `schedule_credential_deadline` (a chain of timers of at most `CREDENTIAL_DEADLINE_TIMER_CAP_MS`, an hour — a 30-day session is past `setTimeout`'s ceiling — each wake-up also checking a wall-clock copy of the deadline, so a host suspend, which stops the monotonic clock, delays the close by at most one timer after the resume). The middleware sets it on `ResolvedAuth.credential_deadline`: session — the earlier of the cookie's signed expiry (`SESSION_COOKIE_EXPIRES_AT_KEY`, set by the session middleware) and the row's; bearer — the row's, none for an eternal token; daemon token — none. Twin of the Rust `ResolvedAuth::credential_deadline`.
|
|
261
270
|
- `auth/bearer_auth.ts` — soft-fail bearer middleware; reads the header through `read_bearer_token` (one line, `Bearer` in any case, one SP, an `is_api_token_shaped` value — anything else, a repeated `Authorization` line included, is no credential and costs no query), and discards the token when the request carries any `Origin` or `Referer` line, an empty one included (browser context, `is_browser_context`). The scope it sets is the one the query parsed — there is no fallback. The last credential leg: it skips before reading the header when the daemon token or a session already resolved the request, so a bearer sent beside one is never looked up and its `last_used_at` / `last_used_ip` never move. A token whose account is tombstoned is no credential either — the anonymous answer, no use recorded.
|
|
262
271
|
- `auth/daemon_token_middleware.ts` — `create_daemon_token_middleware(state, deps, log)` — the credential **consumer** only (soft-fail validation, keeper account resolution). The producer (`write_daemon_token` / `start_daemon_token_rotation`) lives in `testing/daemon_token_rotation.ts` behind the dev-env guard — no production assembly mints daemon tokens, mirroring the Rust spine's `fuz_testing`-confined producer. Soft-fails — discards the credential (pass-through, no own 401/503) on **every** non-success path: browser context (any `Origin` or `Referer` line, an empty one included), malformed/invalid token (anything `read_daemon_token` does not read: off-shape, or the header sent twice), and valid-token-but-no-keeper all `next()` through to the dispatcher's `credential_type_required` (403) gate, mirroring the bearer guard and the Rust spine's `resolve.rs`. Daemon tokens are loopback-only, so browser context never arises in practice — the discard is defense-in-depth. The first credential leg, so it clears `RESOLVED_AUTH_KEY` on entry; a valid daemon token sets the `daemon_token` arm, and the session and bearer legs after it skip, so a cookie or bearer sent beside it is never looked up — as on the Rust spine, whose resolve walk never reads the cookie (its cookie-clear layer still verifies one, to clear it when invalid — as the session middleware here does). A discarded daemon token falls through to them.
|
|
@@ -457,11 +466,14 @@ with `RequestContext.actor: null`.
|
|
|
457
466
|
without touching the Hono context. Each transport binds the same failure to
|
|
458
467
|
its wire shape: REST `c.json(body, status)`; HTTP RPC + WS fold into a
|
|
459
468
|
JSON-RPC envelope where `error.message` is the reason string and
|
|
460
|
-
`error.data: {reason, ...rest}` flattens diagnostic fields. The 500
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
469
|
+
`error.data: {reason, ...rest}` flattens diagnostic fields. The one 500
|
|
470
|
+
reason is `no_actors_on_account` (signup invariant violation: a live account
|
|
471
|
+
with no active actor). The phase builds on the account row the credential leg
|
|
472
|
+
read, so an account deleted or purged after that read runs an account-grain
|
|
473
|
+
handler on that row, as on the Rust spine. An actor-grain one finds no actor,
|
|
474
|
+
and the one read that tells the two cases apart answers a removed account
|
|
475
|
+
with the dead credential's 401 (`authentication_required`). `account_verify`
|
|
476
|
+
re-reads the account live and answers the same 401.
|
|
465
477
|
|
|
466
478
|
**Production-middleware invariant.** No production middleware on the auth
|
|
467
479
|
path populates `REQUEST_CONTEXT_KEY`; it sets only `RESOLVED_AUTH_KEY`. Test
|
|
@@ -476,6 +488,16 @@ under `SESSION_TOKEN_KEY` (`hono_context.ts`, `'auth_session_id'`) and the
|
|
|
476
488
|
session leg reads it there; `SessionOptions` carries no context key, so the two
|
|
477
489
|
cannot disagree and the token cannot land on another spine key.
|
|
478
490
|
|
|
491
|
+
### Row locks
|
|
492
|
+
|
|
493
|
+
One class order in every transaction — accounts, then offers, then grants and
|
|
494
|
+
actors — and id order within a class. Every writer of an account takes its row
|
|
495
|
+
first (two mints of one account take turns there, so the caps hold); a
|
|
496
|
+
multi-row write (credential deletes, offer cascades, the expiry sweeps) locks
|
|
497
|
+
its rows in one id-ordered statement before writing. Each lock's strength and
|
|
498
|
+
reason is on its query's TSDoc; the rule set: ../../../docs/security.md §Row
|
|
499
|
+
Locks. `lock_pins.cross.test.ts` pins them on both spines (../../test/CLAUDE.md).
|
|
500
|
+
|
|
479
501
|
### Wire timestamp shape
|
|
480
502
|
|
|
481
503
|
Every timestamp on the wire is **second-precision UTC** —
|
|
@@ -545,10 +567,16 @@ TSDoc. The pattern that spans emit sites:
|
|
|
545
567
|
`_supersede`) populate `target_actor_id` only when the offer was
|
|
546
568
|
actor-targeted at create time (`role_grant_offer.to_actor_id` set).
|
|
547
569
|
- **Account-shape events** (login, logout, signup, bootstrap, password
|
|
548
|
-
change, session/token revoke, app_settings update
|
|
570
|
+
change, session/token revoke, app_settings update) stay
|
|
549
571
|
account-grain on **both** `target_actor_id` and `actor_id` — the
|
|
550
572
|
operation is performed by the account, and a multi-actor user must be
|
|
551
573
|
able to log out without first picking an acting actor.
|
|
574
|
+
- **Invite events** carry the acting `actor_id` (the handlers are
|
|
575
|
+
actor-grain) and no target — the `invite_delete` rows an account removal
|
|
576
|
+
writes for the invites it voids too, the remover's. A delete of a missing
|
|
577
|
+
invite writes an `outcome: 'failure'` row (`reason`, `attempted_invite_id`
|
|
578
|
+
— a UUID probe key, unlike `invite_create`'s email and username refusals,
|
|
579
|
+
which write none).
|
|
552
580
|
|
|
553
581
|
### Audit event extensibility
|
|
554
582
|
|
|
@@ -601,8 +629,11 @@ account event plus one per-actor event (`delete` = soft, `purge` = hard,
|
|
|
601
629
|
"Account-removal target guards").
|
|
602
630
|
|
|
603
631
|
`role_grant_offer_supersede` carries
|
|
604
|
-
`reason: 'sibling_accepted' | 'role_grant_revoked' | 'scope_destroyed' | 'account_deleted'` (for `account_deleted`, `cause_id` is the removed account, the grantor's or the recipient's
|
|
605
|
-
plus `cause_id` pointing to the row that triggered the supersede.
|
|
632
|
+
`reason: 'sibling_accepted' | 'role_grant_revoked' | 'scope_destroyed' | 'account_deleted'` (for `account_deleted`, `cause_id` is the removed account, the grantor's or the recipient's)
|
|
633
|
+
plus `cause_id` pointing to the row that triggered the supersede. The WS
|
|
634
|
+
`role_grant_offer_supersede` notification's reason set is narrower —
|
|
635
|
+
`sibling_accepted | role_grant_revoked | account_deleted`; `scope_destroyed`
|
|
636
|
+
is an audit reason only (a consumer's own cascade writes it).
|
|
606
637
|
|
|
607
638
|
### Keeper auth shape
|
|
608
639
|
|
|
@@ -708,7 +739,7 @@ authenticate.
|
|
|
708
739
|
|
|
709
740
|
- `admin_account_list_action_spec` — read; input `{limit?, offset?, include_deleted?}`; output `{accounts, grantable_roles}`. On it and the other paged reads (`audit_log_list`, `audit_log_role_grant_history`, `role_grant_offer_history`) `limit` / `offset` declare `invalid_reason` `ERROR_LIMIT_INVALID` / `ERROR_OFFSET_INVALID` (`http/error_schemas.ts`), and `audit_log_list`'s `since_seq` / `outcome` `ERROR_SINCE_SEQ_INVALID` / `ERROR_OUTCOME_INVALID`: every refusal of the field carries it. `include_deleted` (default false) surfaces soft-deleted rows (with `account.deleted_at` set) for the admin UI's reactivation view.
|
|
710
741
|
- `account_delete_action_spec` — mutation (soft delete); self-or-admin (`{account, actor}`, handler elevates to admin when `account_id` ≠ self); the self path is session-only, handler-enforced ahead of the target guards (an API or daemon token gets the dispatcher's `ERROR_CREDENTIAL_TYPE_REQUIRED` 403 via `credential_type_required_error`), while an admin deleting another account keeps any credential; input `{account_id?}`; output `{ok, deleted}`. Tombstones account + actor(s), supersedes every pending offer the account made and every pending offer made to it (`reason: 'account_deleted'`, an audit row each), revokes sessions/tokens, deletes the unclaimed invites the account issued (an `invite_delete` row each), emits `account_delete` + per-actor `actor_delete`. Role grants are kept — inert while the account is tombstoned. Refuses a keeper-role target (`ERROR_CANNOT_DELETE_KEEPER`) or the sole active admin (`ERROR_CANNOT_DELETE_LAST_ADMIN`) — both fail-loud with a failure-audit row.
|
|
711
|
-
- `account_purge_action_spec` — mutation (hard purge); keeper-only (`credential_types: ['daemon_token']` + `roles: ['keeper']`) + `confirm: true` + WARN; input `{account_id, confirm?}`; output `{ok, purged}`. Supersedes the account
|
|
742
|
+
- `account_purge_action_spec` — mutation (hard purge); keeper-only (`credential_types: ['daemon_token']` + `roles: ['keeper']`) + `confirm: true` + WARN; input `{account_id, confirm?}`; output `{ok, purged}`. Supersedes the offers the account made and those made to it (audited and notified, as `account_delete` does), deletes the unclaimed invites it issued, revokes its sessions and tokens, then the cascading delete (its locks: §Row locks); emits `account_purge` + per-actor `actor_purge` (identity snapshot survives in metadata since `audit_log` ids carry no FK). Refuses a keeper-role target (`ERROR_CANNOT_DELETE_KEEPER`) or the sole active admin (`ERROR_CANNOT_DELETE_LAST_ADMIN`).
|
|
712
743
|
- `account_undelete_action_spec` — mutation (reactivation, inverse of soft delete); admin-only (`roles: ['admin']` — no self path, a tombstoned account can't authenticate); input `{account_id}`; output `{ok, undeleted}`. Clears the `deleted_at` tombstone on the account + its actor(s), emits `account_undelete` + per-actor `actor_undelete`. Restores the account, its actors and its role grants as they were; does not restore revoked sessions/tokens, superseded offers, or deleted invites.
|
|
713
744
|
- `admin_session_list_action_spec` — read; input `{acting?}` (an omitted input reads as `{}`); output `{sessions}`.
|
|
714
745
|
- `admin_session_revoke_all_action_spec` — mutation; input `{account_id}`; output `{ok, count}`.
|
|
@@ -735,7 +766,7 @@ API-removable — auth + daemon-token both pivot on it),
|
|
|
735
766
|
targets the sole remaining active admin (soft-deleted admins don't count; the
|
|
736
767
|
count locks its rows, so concurrent removals can't both pass), `ERROR_INVITE_ACCOUNT_EXISTS_USERNAME` /
|
|
737
768
|
`_EMAIL` / `ERROR_INVITE_DUPLICATE` on invite create, `ERROR_INVITE_NOT_FOUND`
|
|
738
|
-
on invite delete. `invite_create` empty input is rejected at the schema by a
|
|
769
|
+
on invite delete (with a failure-audit row). `invite_create` empty input is rejected at the schema by a
|
|
739
770
|
`check` and surfaces as `invalid_params` with `error.data.issues` (DEV-only `WireIssue`s).
|
|
740
771
|
|
|
741
772
|
Closure state:
|
|
@@ -795,15 +826,16 @@ the list and history inputs read an omitted input as a fresh `{}`
|
|
|
795
826
|
A global `admin` grant is guarded: the keeper account's is refused
|
|
796
827
|
(`ERROR_CANNOT_REVOKE_KEEPER_ADMIN`, 403) and so is one whose revoke would
|
|
797
828
|
leave no active admin account (`ERROR_CANNOT_REVOKE_LAST_ADMIN`, 403, under
|
|
798
|
-
the locked count `
|
|
799
|
-
which leaves the revoked grant out). Besides the
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
829
|
+
the locked count `query_count_active_accounts_with_global_role_locked`,
|
|
830
|
+
which leaves the revoked grant out — §Row locks). Besides the revokee's
|
|
831
|
+
incoming sibling offers, the revoke supersedes every pending offer the
|
|
832
|
+
revokee's actor made — the rule `query_revoke_role_grant` holds for every
|
|
833
|
+
revoke, the self-service disable's too;
|
|
834
|
+
`account_delete` / `account_purge` supersede both directions for the whole
|
|
835
|
+
account (`reason: 'account_deleted'`). Every supersede cascade returns —
|
|
836
|
+
and audits and notifies — its rows ordered by `created_at, id`; a revoke's
|
|
837
|
+
is two such runs, its incoming siblings then its outgoing offers. Who is
|
|
838
|
+
told: §WS notifications.
|
|
807
839
|
- `role_grant_assign_action_spec` — global-admin-only immediate conferral (no
|
|
808
840
|
consent step); input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?}`
|
|
809
841
|
(the pair as on offer-create); output `{ok, role_grant_id}`. The handler:
|
|
@@ -857,7 +889,7 @@ becomes a grant) refuses a `keeper` offer (`ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRAN
|
|
|
857
889
|
a scoped `admin` offer (`invalid_request` + `ERROR_ROLE_GRANT_BUILTIN_SCOPED`), and a
|
|
858
890
|
builtin offer whose grantor no longer holds an active global `admin` on an
|
|
859
891
|
active actor of an active account (`ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED`,
|
|
860
|
-
|
|
892
|
+
read under the grantor's account lock) — via
|
|
861
893
|
`RoleGrantOfferBuiltinRefusedError` (`refusal: BuiltinOfferRefusal`). Each
|
|
862
894
|
refusal leaves the offer pending and is audited as a failed
|
|
863
895
|
`role_grant_offer_accept` with `{offer_id, role, scope_id, reason}`. The
|
|
@@ -893,9 +925,19 @@ Post-commit via `emit_after_commit` (see `http/CLAUDE.md` §Pending Effects):
|
|
|
893
925
|
|
|
894
926
|
- Create — `role_grant_offer_received` → recipient.
|
|
895
927
|
- Retract — `role_grant_offer_retracted` → recipient.
|
|
896
|
-
- Accept — `role_grant_offer_accepted` → grantor
|
|
928
|
+
- Accept — `role_grant_offer_accepted` → grantor; `_supersede` per sibling → its grantor (the caller's answer lists the siblings).
|
|
897
929
|
- Decline — `role_grant_offer_declined` → grantor.
|
|
898
|
-
- Revoke (`role_grant_revoke`) — `role_grant_revoked` → revokee + `_supersede` per superseded offer (the revokee's incoming siblings and its own outgoing offers, each to its grantor
|
|
930
|
+
- Revoke (`role_grant_revoke`) — `role_grant_revoked` → revokee + `_supersede` per superseded offer (the revokee's incoming siblings and its own outgoing offers), each to its grantor and its recipient.
|
|
931
|
+
- Delete / purge (`account_delete`, `account_purge`) — `_supersede` (`account_deleted`) per superseded offer to the live party: the recipient of each offer the account made, the grantor of each offer made to it. The removed account hears nothing (its sockets close).
|
|
932
|
+
- Self-service disable — `_supersede` per superseded offer (the caller's incoming siblings and its own outgoing offers), each to its grantor and its recipient, as the admin revoke (the caller's answer lists no offers).
|
|
933
|
+
|
|
934
|
+
`queue_supersede_notifications(ctx, offers, reason, audience)` sends them in
|
|
935
|
+
the cascade's row order, grantor before recipient; the `SupersedeAudience`
|
|
936
|
+
names the `cause_id` each told party gets (a recipient told of its grantor's
|
|
937
|
+
removal gets the grantor's actor, never its account id — TSDoc on
|
|
938
|
+
`SupersedeAudience`). Their audit rows go through `emit_supersede_audits`
|
|
939
|
+
(`auth/role_grant_offer_actions.ts`), shared by both revokes and account
|
|
940
|
+
removal, as the Rust twin's.
|
|
899
941
|
|
|
900
942
|
Spec module is `auth/role_grant_offer_notifications.ts` —
|
|
901
943
|
`RemoteNotificationActionSpec`s with `@fuzdev/fuz_schema` params schemas and
|
|
@@ -910,23 +952,19 @@ notification is `role_grant_revoked`, not the admin action's
|
|
|
910
952
|
`role_grant_revoke`, so the two methods never collide. They never reach
|
|
911
953
|
dispatch: an inbound frame for one is answered `method_not_found`. They are not SSE events; `role_grant_offer_notification_specs`
|
|
912
954
|
holds them as `EventSpec`s for a consumer that broadcasts them on an SSE
|
|
913
|
-
channel of its own.
|
|
914
|
-
sender
|
|
915
|
-
|
|
916
|
-
production sends unchecked.
|
|
955
|
+
channel of its own. Handlers send through `ctx.notification_sender`
|
|
956
|
+
(`actions/CLAUDE.md` §Notification sender) with `queue_offer_notification` /
|
|
957
|
+
`queue_supersede_notifications`, each queued post-commit.
|
|
917
958
|
|
|
918
|
-
Deps: `RevokingActionFactoryDeps
|
|
959
|
+
Deps: `RevokingActionFactoryDeps`.
|
|
919
960
|
`role_grant_revoke` of a global grant queues a close of the revokee account's
|
|
920
961
|
connections gated on the role (`queue_connection_close`, `{kind: 'role'}`),
|
|
921
962
|
run after the transaction commits and independent of the audit row's
|
|
922
963
|
announcement; the revocation guard repeats it on the announced row. A scoped revoke
|
|
923
964
|
closes nothing — a role gate admits on global grants alone.
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
the payload — `revoked_by` is deliberately not in the `role_grant_revoked`
|
|
928
|
-
payload (the revokee doesn't need to learn the admin's identity). When
|
|
929
|
-
`notification_sender` is absent, WS fan-out is silently skipped.
|
|
965
|
+
Target account travels via the send argument, not the payload — `revoked_by`
|
|
966
|
+
is deliberately not in the `role_grant_revoked` payload (the revokee doesn't
|
|
967
|
+
need to learn the admin's identity).
|
|
930
968
|
|
|
931
969
|
Options: `roles?: RoleRegistry` (drives admin-grant-path lookup),
|
|
932
970
|
`default_ttl_ms?` (defaults to `ROLE_GRANT_OFFER_DEFAULT_TTL_MS` = 30 days),
|
|
@@ -980,9 +1018,9 @@ app-settings methods are always wired). Frontend mirror is
|
|
|
980
1018
|
|
|
981
1019
|
Option routing — `roles` is shared between admin + role-grant-offer;
|
|
982
1020
|
`default_ttl_ms` + `authorize` → role-grant-offer
|
|
983
|
-
only; `max_tokens` → account only. On `deps`: `
|
|
984
|
-
|
|
985
|
-
|
|
1021
|
+
only; `max_tokens` → account only. On `deps`: `connection_closer`
|
|
1022
|
+
(required) → admin, account, and role-grant-offer (the role revoke's close).
|
|
1023
|
+
The notification sender is on every action's context, not on `deps`.
|
|
986
1024
|
|
|
987
1025
|
Pair with `create_app_server`'s `rpc_endpoints` factory form
|
|
988
1026
|
`(ctx) => Array<RpcEndpointSpec>` so the combined action list gets
|
|
@@ -1015,6 +1053,11 @@ construction (`validate_self_service_eligible_roles`): a builtin role or a name
|
|
|
1015
1053
|
outside the `RoleName` grammar throws — self-toggling a builtin would hand any
|
|
1016
1054
|
account instance-wide authority.
|
|
1017
1055
|
|
|
1056
|
+
A disable revokes through `query_revoke_role_grant`, so it ends what the admin
|
|
1057
|
+
revoke ends: the caller's pending offers of the role and every offer its actor
|
|
1058
|
+
made, whatever the role, each audited (`role_grant_offer_supersede`,
|
|
1059
|
+
`role_grant_revoked`, the grant as cause) and told to both parties.
|
|
1060
|
+
|
|
1018
1061
|
Deps are `RevokingActionFactoryDeps`: a disable that revokes queues a close of
|
|
1019
1062
|
the caller's connections gated on the role (`queue_connection_close`,
|
|
1020
1063
|
`{kind: 'role'}`), after the commit and independent of the audit write.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA2BhG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0B3D,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,yBAAyB,EAC/B,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"account_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA2BhG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0B3D,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,yBAAyB,EAC/B,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,CA6NjB,CAAC"}
|
|
@@ -33,7 +33,7 @@ import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
|
|
|
33
33
|
import { ERROR_AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
|
|
34
34
|
import { queue_connection_close } from '../actions/connection_closer.js';
|
|
35
35
|
import { to_session_account } from './account_schema.js';
|
|
36
|
-
import { query_account_lock_live } from './account_queries.js';
|
|
36
|
+
import { query_account_by_id, query_account_lock_live } from './account_queries.js';
|
|
37
37
|
import { query_session_is_live, query_session_list_for_account, query_session_revoke_for_account, query_session_revoke_all_for_account } from './session_queries.js';
|
|
38
38
|
import { query_api_token_enforce_limit, query_api_token_list_for_account, query_create_api_token, query_revoke_api_token_for_account } from './api_token_queries.js';
|
|
39
39
|
import { parse_stored_token_scope, serialize_token_scope, token_scope_from_input, token_scope_label } from './token_scope.js';
|
|
@@ -56,8 +56,18 @@ import { account_verify_action_spec, account_session_list_action_spec, account_s
|
|
|
56
56
|
export const create_account_actions = (deps, options = {}) => {
|
|
57
57
|
const { max_tokens = DEFAULT_MAX_TOKENS } = options;
|
|
58
58
|
const { connection_closer } = deps;
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
// The account read again, live: the answer is the account itself, so one
|
|
60
|
+
// deleted or purged since the credential leg is the dead credential's 401,
|
|
61
|
+
// not a description of a removed account. The Rust twin reads its summary
|
|
62
|
+
// the same way.
|
|
63
|
+
const verify_handler = async (_input, ctx) => {
|
|
64
|
+
const account = await query_account_by_id(ctx, ctx.auth.account.id);
|
|
65
|
+
if (!account) {
|
|
66
|
+
throw jsonrpc_errors.unauthenticated('unauthenticated', {
|
|
67
|
+
reason: ERROR_AUTHENTICATION_REQUIRED
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return to_session_account(account);
|
|
61
71
|
};
|
|
62
72
|
const session_list_handler = async (_input, ctx) => {
|
|
63
73
|
const sessions = await query_session_list_for_account(ctx, ctx.auth.account.id);
|