@fuzdev/fuz_app 0.182.0 → 0.184.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/actions/CLAUDE.md +535 -1223
- package/dist/actions/action_codegen.d.ts +1 -1
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +3 -2
- package/dist/actions/connection_closer.d.ts +11 -9
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +11 -9
- package/dist/actions/frontend_rpc_client.d.ts +1 -1
- package/dist/actions/register_action_ws.d.ts +14 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +2 -1
- package/dist/actions/ws_socket_session.d.ts +9 -1
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +43 -19
- package/dist/auth/CLAUDE.md +430 -1024
- package/dist/auth/account_queries.d.ts +1 -1
- package/dist/auth/account_queries.js +1 -1
- package/dist/auth/account_routes.d.ts +9 -8
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +78 -75
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +32 -28
- package/dist/auth/api_token.d.ts +20 -3
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +28 -9
- package/dist/auth/api_token_queries.d.ts +2 -2
- package/dist/auth/api_token_queries.js +2 -2
- package/dist/auth/audit_emitter.d.ts +75 -84
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +83 -71
- package/dist/auth/audit_log_schema.d.ts +25 -14
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +23 -8
- package/dist/auth/auth_guard_resolver.d.ts +1 -1
- package/dist/auth/auth_guard_resolver.js +1 -1
- package/dist/auth/bearer_auth.d.ts +2 -5
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +4 -13
- package/dist/auth/bootstrap_account.d.ts +42 -26
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +36 -19
- package/dist/auth/bootstrap_routes.d.ts +20 -21
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +26 -31
- package/dist/auth/bootstrap_token_store.d.ts +3 -4
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
- package/dist/auth/bootstrap_token_store.js +1 -1
- package/dist/auth/daemon_token.d.ts +5 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.d.ts +12 -8
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +15 -21
- package/dist/auth/deps.d.ts +19 -5
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/deps.js +3 -2
- package/dist/auth/invite_queries.d.ts +51 -3
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +81 -6
- package/dist/auth/invite_schema.d.ts +2 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/middleware.d.ts +2 -3
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +3 -3
- package/dist/auth/request_context.d.ts +3 -3
- package/dist/auth/request_context.js +3 -3
- package/dist/auth/resolved_auth.d.ts +7 -7
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts +27 -3
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +42 -35
- package/dist/auth/role_grant_offer_queries.d.ts +60 -4
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +79 -5
- package/dist/auth/role_grant_queries.d.ts +3 -52
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +5 -80
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +11 -22
- package/dist/auth/session_cookie.d.ts +82 -174
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +80 -130
- package/dist/auth/session_middleware.d.ts +8 -17
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +14 -23
- package/dist/auth/session_queries.d.ts +15 -17
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +28 -20
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +93 -43
- package/dist/db/CLAUDE.md +5 -3
- package/dist/db/sql_columns.d.ts +1 -1
- package/dist/db/sql_columns.js +1 -1
- package/dist/dev/setup.d.ts +3 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +3 -1
- package/dist/http/CLAUDE.md +315 -763
- package/dist/http/db_routes.d.ts +8 -23
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +73 -73
- package/dist/http/origin.d.ts +7 -8
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +7 -8
- package/dist/http/pending_effects.d.ts +118 -6
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +114 -6
- package/dist/http/route_result.d.ts +1 -1
- package/dist/http/route_spec.d.ts +14 -11
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/realtime/sse.d.ts +4 -23
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -25
- package/dist/server/app_backend.d.ts +4 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +3 -1
- package/dist/server/app_server.d.ts +80 -16
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +113 -31
- package/dist/server/app_server_context.d.ts +1 -2
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.js +2 -2
- package/dist/testing/CLAUDE.md +265 -796
- package/dist/testing/admin_integration.d.ts +2 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +3 -3
- package/dist/testing/adversarial_404.d.ts +6 -1
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +38 -17
- package/dist/testing/app_server.d.ts +23 -148
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +53 -131
- package/dist/testing/attack_surface.d.ts +1 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/audit_completeness.d.ts +2 -3
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +1 -1
- package/dist/testing/audit_drift_guard.d.ts +11 -6
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +15 -8
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
- package/dist/testing/cross_backend/capabilities.d.ts +9 -6
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +11 -7
- package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
- package/dist/testing/cross_backend/capability_mounts.js +428 -0
- package/dist/testing/cross_backend/cell_moderate.js +2 -2
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +12 -11
- package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
- package/dist/testing/cross_backend/conformance_principal.js +283 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +7 -56
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +6 -274
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_deadline.js +2 -0
- package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
- package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
- package/dist/testing/cross_backend/db_state_diff.js +444 -0
- package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
- package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
- package/dist/testing/cross_backend/declared_skips.js +132 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
- package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +4 -9
- package/dist/testing/cross_backend/differential.d.ts +13 -5
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +35 -11
- package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +16 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +45 -4
- package/dist/testing/cross_backend/in_process_setup.d.ts +28 -19
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +156 -142
- package/dist/testing/cross_backend/login_security.d.ts +12 -0
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +21 -4
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
- package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +18 -10
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
- package/dist/testing/cross_backend/role_grant_participation.js +4 -4
- package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
- package/dist/testing/cross_backend/session_cap.d.ts +2 -2
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +22 -11
- package/dist/testing/cross_backend/setup.d.ts +32 -2
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +32 -1
- package/dist/testing/cross_backend/spine_suites.d.ts +125 -15
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +459 -62
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +123 -27
- package/dist/testing/cross_backend/standard.d.ts +2 -3
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +3 -3
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -2
- package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_credential_read.js +12 -12
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +84 -47
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +95 -63
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +2 -3
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +7 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +54 -8
- package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
- package/dist/testing/daemon_token_rotation.js +2 -3
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -0
- package/dist/testing/db.d.ts +0 -32
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +0 -86
- package/dist/testing/db_entities.d.ts +14 -0
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +17 -0
- package/dist/testing/db_invariant_queries.d.ts +259 -0
- package/dist/testing/db_invariant_queries.d.ts.map +1 -0
- package/dist/testing/db_invariant_queries.js +400 -0
- package/dist/testing/db_invariants.d.ts +106 -0
- package/dist/testing/db_invariants.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
- package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.js +13 -0
- package/dist/testing/db_invariants.js +141 -0
- package/dist/testing/db_invariants.sql +152 -0
- package/dist/testing/describe_db.d.ts +36 -0
- package/dist/testing/describe_db.d.ts.map +1 -0
- package/dist/testing/describe_db.js +71 -0
- package/dist/testing/integration.d.ts +8 -12
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -17
- package/dist/testing/integration_helpers.d.ts +1 -1
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/rate_limiting.d.ts +3 -4
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +6 -5
- package/dist/testing/role_grant_helpers.d.ts +1 -1
- package/dist/testing/role_grant_helpers.d.ts.map +1 -1
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +3 -0
- package/dist/testing/rpc_attack_surface.d.ts +8 -6
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +69 -6
- package/dist/testing/rpc_helpers.d.ts +1 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -3
- package/dist/testing/rpc_round_trip.d.ts +3 -4
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +4 -1
- package/dist/testing/sse_round_trip.d.ts +3 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +15 -6
- package/dist/testing/stubs.d.ts +9 -8
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +20 -13
- package/dist/testing/test_app.d.ts +168 -0
- package/dist/testing/test_app.d.ts.map +1 -0
- package/dist/testing/test_app.js +123 -0
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +3 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +1 -2
- package/package.json +1 -1
|
@@ -18,9 +18,8 @@ import type { BurnOutcome } from '../runtime/secure_file.js';
|
|
|
18
18
|
* the caller strips one trailing LF and compares in constant time.
|
|
19
19
|
*
|
|
20
20
|
* Twin of the Rust `BootstrapTokenStore` trait, which has no `path`: the Rust
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* log lines from here.
|
|
21
|
+
* `is_bootstrap_available` takes the path itself, while the TS one reads
|
|
22
|
+
* through this store and names the file in its log lines from here.
|
|
24
23
|
*/
|
|
25
24
|
export interface BootstrapTokenStore {
|
|
26
25
|
/** Where the token lives, named in operator log lines — never the token itself. */
|
|
@@ -49,7 +48,7 @@ export interface BootstrapTokenStore {
|
|
|
49
48
|
* burn (`burn_secure_file` — unlink, then fsync the directory). The read
|
|
50
49
|
* alone of the runtime's secure reads asks for a single link
|
|
51
50
|
* (`BOOTSTRAP_TOKEN_READ_OPTIONS`): both of bootstrap's reads, the boot check
|
|
52
|
-
* (`
|
|
51
|
+
* (`is_bootstrap_available`) and the request's, go through it. Twin of the
|
|
53
52
|
* Rust `FileBootstrapTokenStore`.
|
|
54
53
|
*
|
|
55
54
|
* @param deps - the runtime's secure read and burn (`create_node_runtime()` satisfies both)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap_token_store.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_token_store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,2BAA2B,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"bootstrap_token_store.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_token_store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,2BAA2B,CAAC;AAEhF;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IACnC,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC;;;;;;;;OAQG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CACvC;AAYD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iCAAiC,GAC7C,MAAM,gBAAgB,GAAG,gBAAgB,EACzC,MAAM,MAAM,KACV,mBAID,CAAC"}
|
|
@@ -25,7 +25,7 @@ const BOOTSTRAP_TOKEN_READ_OPTIONS = Object.freeze({
|
|
|
25
25
|
* burn (`burn_secure_file` — unlink, then fsync the directory). The read
|
|
26
26
|
* alone of the runtime's secure reads asks for a single link
|
|
27
27
|
* (`BOOTSTRAP_TOKEN_READ_OPTIONS`): both of bootstrap's reads, the boot check
|
|
28
|
-
* (`
|
|
28
|
+
* (`is_bootstrap_available`) and the request's, go through it. Twin of the
|
|
29
29
|
* Rust `FileBootstrapTokenStore`.
|
|
30
30
|
*
|
|
31
31
|
* @param deps - the runtime's secure read and burn (`create_node_runtime()` satisfies both)
|
|
@@ -38,7 +38,11 @@ export interface DaemonTokenState {
|
|
|
38
38
|
previous_token: string | null;
|
|
39
39
|
/** When the last rotation occurred. */
|
|
40
40
|
rotated_at: Date;
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The account ID of the keeper: resolved by `create_app_server` at
|
|
43
|
+
* assembly when null (`resolve_keeper_account_id`), set by the bootstrap
|
|
44
|
+
* route once its account commits, never re-read per request.
|
|
45
|
+
*/
|
|
42
46
|
keeper_account_id: string | null;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon_token.d.ts","sourceRoot":"","sources":["../../src/lib/auth/daemon_token.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAgC,KAAK,KAAK,EAAE,MAAM,8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AE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAExC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,EAAE,OAAO,gBAAgB,KAAG,OAgBjF,CAAC"}
|
|
@@ -21,9 +21,12 @@ import { type DaemonTokenState } from './daemon_token.js';
|
|
|
21
21
|
* Resolve the keeper account ID by querying for the account with an active
|
|
22
22
|
* keeper role_grant.
|
|
23
23
|
*
|
|
24
|
-
* There is exactly one keeper account (the bootstrap account).
|
|
25
|
-
* at
|
|
26
|
-
* `
|
|
24
|
+
* There is exactly one keeper account (the bootstrap account). Run once by
|
|
25
|
+
* `create_app_server` at assembly for a daemon-token state with no keeper
|
|
26
|
+
* (and by `start_daemon_token_rotation`) — the result is cached in
|
|
27
|
+
* `DaemonTokenState.keeper_account_id`, which a live bootstrap sets after its
|
|
28
|
+
* commit and nothing re-reads per request (a keeper seeded by another process
|
|
29
|
+
* needs a restart, as on the Rust spine). The acting actor is resolved
|
|
27
30
|
* per-request by the dispatcher's authorization phase (which runs
|
|
28
31
|
* `resolve_acting_actor` against this account id), so multi-actor keeper
|
|
29
32
|
* accounts surface `actor_required` if a daemon caller doesn't pass an
|
|
@@ -51,12 +54,13 @@ export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<str
|
|
|
51
54
|
* - A shaped token + `Origin` / `Referer` present: discard the credential
|
|
52
55
|
* (browser context) and pass through — daemon tokens are loopback-only and
|
|
53
56
|
* never carry an `Origin` in production, so a header-bearing request is not
|
|
54
|
-
* a legitimate daemon caller. Silent on the wire (anti-enumeration)
|
|
55
|
-
*
|
|
57
|
+
* a legitimate daemon caller. Silent on the wire (anti-enumeration), logged
|
|
58
|
+
* at debug as on the Rust spine.
|
|
56
59
|
* - Header present + invalid value (not the current/previous token): soft-fail
|
|
57
60
|
* discard (pass through, not 401) — same downstream behavior.
|
|
58
|
-
* - Header present + valid + `keeper_account_id` null (
|
|
59
|
-
*
|
|
61
|
+
* - Header present + valid + `keeper_account_id` null (pre-bootstrap — the
|
|
62
|
+
* keeper is resolved at assembly and set by the bootstrap route after its
|
|
63
|
+
* commit, never re-read per request): soft-fail discard (pass through, not 503) —
|
|
60
64
|
* mirrors the Rust spine's `resolve.rs` (`None`), so the request falls
|
|
61
65
|
* through to anonymous and a daemon-gated action returns
|
|
62
66
|
* `credential_type_required` downstream.
|
|
@@ -71,7 +75,7 @@ export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<str
|
|
|
71
75
|
* an explicit `acting` value.
|
|
72
76
|
*
|
|
73
77
|
* @param state - the daemon token runtime state
|
|
74
|
-
* @param deps - query dependencies (pool-level db for keeper
|
|
78
|
+
* @param deps - query dependencies (pool-level db for the keeper's account row)
|
|
75
79
|
* @param log - the logger instance
|
|
76
80
|
* @mutates Hono context - clears `RESOLVED_AUTH_KEY` on entry, then sets it on a valid token
|
|
77
81
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBA8EF,CAAC"}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
|
-
import { DEV } from 'esm-env';
|
|
17
16
|
import { RESOLVED_AUTH_KEY } from '../hono_context.js';
|
|
18
17
|
import { get_resolved_auth } from './resolved_auth.js';
|
|
19
18
|
import { get_header_lines } from '../http/header_lines.js';
|
|
@@ -27,9 +26,12 @@ import { DAEMON_TOKEN_HEADER, validate_daemon_token } from './daemon_token.js';
|
|
|
27
26
|
* Resolve the keeper account ID by querying for the account with an active
|
|
28
27
|
* keeper role_grant.
|
|
29
28
|
*
|
|
30
|
-
* There is exactly one keeper account (the bootstrap account).
|
|
31
|
-
* at
|
|
32
|
-
* `
|
|
29
|
+
* There is exactly one keeper account (the bootstrap account). Run once by
|
|
30
|
+
* `create_app_server` at assembly for a daemon-token state with no keeper
|
|
31
|
+
* (and by `start_daemon_token_rotation`) — the result is cached in
|
|
32
|
+
* `DaemonTokenState.keeper_account_id`, which a live bootstrap sets after its
|
|
33
|
+
* commit and nothing re-reads per request (a keeper seeded by another process
|
|
34
|
+
* needs a restart, as on the Rust spine). The acting actor is resolved
|
|
33
35
|
* per-request by the dispatcher's authorization phase (which runs
|
|
34
36
|
* `resolve_acting_actor` against this account id), so multi-actor keeper
|
|
35
37
|
* accounts surface `actor_required` if a daemon caller doesn't pass an
|
|
@@ -59,12 +61,13 @@ export const resolve_keeper_account_id = async (deps) => {
|
|
|
59
61
|
* - A shaped token + `Origin` / `Referer` present: discard the credential
|
|
60
62
|
* (browser context) and pass through — daemon tokens are loopback-only and
|
|
61
63
|
* never carry an `Origin` in production, so a header-bearing request is not
|
|
62
|
-
* a legitimate daemon caller. Silent on the wire (anti-enumeration)
|
|
63
|
-
*
|
|
64
|
+
* a legitimate daemon caller. Silent on the wire (anti-enumeration), logged
|
|
65
|
+
* at debug as on the Rust spine.
|
|
64
66
|
* - Header present + invalid value (not the current/previous token): soft-fail
|
|
65
67
|
* discard (pass through, not 401) — same downstream behavior.
|
|
66
|
-
* - Header present + valid + `keeper_account_id` null (
|
|
67
|
-
*
|
|
68
|
+
* - Header present + valid + `keeper_account_id` null (pre-bootstrap — the
|
|
69
|
+
* keeper is resolved at assembly and set by the bootstrap route after its
|
|
70
|
+
* commit, never re-read per request): soft-fail discard (pass through, not 503) —
|
|
68
71
|
* mirrors the Rust spine's `resolve.rs` (`None`), so the request falls
|
|
69
72
|
* through to anonymous and a daemon-gated action returns
|
|
70
73
|
* `credential_type_required` downstream.
|
|
@@ -79,7 +82,7 @@ export const resolve_keeper_account_id = async (deps) => {
|
|
|
79
82
|
* an explicit `acting` value.
|
|
80
83
|
*
|
|
81
84
|
* @param state - the daemon token runtime state
|
|
82
|
-
* @param deps - query dependencies (pool-level db for keeper
|
|
85
|
+
* @param deps - query dependencies (pool-level db for the keeper's account row)
|
|
83
86
|
* @param log - the logger instance
|
|
84
87
|
* @mutates Hono context - clears `RESOLVED_AUTH_KEY` on entry, then sets it on a valid token
|
|
85
88
|
*/
|
|
@@ -114,8 +117,6 @@ export const create_daemon_token_middleware = (state, deps, log) => {
|
|
|
114
117
|
// `credential_type_required` downstream rather than a hard fail.
|
|
115
118
|
if (is_browser_context(get_header_lines(c, 'origin'), get_header_lines(c, 'referer'))) {
|
|
116
119
|
log.debug('daemon token auth rejected: browser context (Origin/Referer present)');
|
|
117
|
-
if (DEV)
|
|
118
|
-
c.header('X-Fuz-Auth-Debug', 'daemon_token_discarded_browser_context');
|
|
119
120
|
await next();
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
@@ -127,16 +128,9 @@ export const create_daemon_token_middleware = (state, deps, log) => {
|
|
|
127
128
|
await next();
|
|
128
129
|
return;
|
|
129
130
|
}
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
// then POST /bootstrap). Lazily refresh from the DB on the first null hit
|
|
134
|
-
// so the post-bootstrap state lands without a separate hook.
|
|
135
|
-
if (!state.keeper_account_id) {
|
|
136
|
-
state.keeper_account_id = await resolve_keeper_account_id(deps);
|
|
137
|
-
}
|
|
138
|
-
// Valid token but no keeper configured (still pre-bootstrap after the lazy
|
|
139
|
-
// refresh) — soft-fail discard (pass through), not a 503. Mirrors the Rust
|
|
131
|
+
// Valid token but no keeper configured — soft-fail discard (pass through),
|
|
132
|
+
// not a 503. The keeper is resolved at assembly and set by the
|
|
133
|
+
// bootstrap route after its commit; never re-read here. Mirrors the Rust
|
|
140
134
|
// spine's `resolve.rs`, which returns `None` when the daemon leg can't
|
|
141
135
|
// resolve a keeper: the request falls through to the next auth leg →
|
|
142
136
|
// anonymous, so a daemon-gated action returns `credential_type_required`
|
package/dist/auth/deps.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Capabilities bundle for fuz_app backends.
|
|
3
3
|
*
|
|
4
4
|
* `AppDeps` is the central dependency injection type — injectable and swappable
|
|
5
5
|
* per environment (production vs test). Does not contain config (static values)
|
|
6
|
-
* or runtime state (mutable refs)
|
|
6
|
+
* or app runtime state (mutable refs like `bootstrap_status`); the audit emitter
|
|
7
|
+
* and the realtime fan-outs hold only their registered members.
|
|
7
8
|
*
|
|
8
9
|
* @module
|
|
9
10
|
*/
|
|
@@ -15,11 +16,14 @@ import type { Db } from '../db/db.js';
|
|
|
15
16
|
import type { AuditEmitter } from './audit_emitter.js';
|
|
16
17
|
import type { ConnectionCloser, RealtimeCloser } from '../actions/connection_closer.js';
|
|
17
18
|
import type { RealtimeNotificationSender } from '../actions/notification_sender.js';
|
|
19
|
+
import type { RequestTracker } from '../http/pending_effects.js';
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* Capabilities bundle for fuz_app backends.
|
|
20
22
|
*
|
|
21
|
-
* Injectable and swappable per environment (production vs test).
|
|
22
|
-
*
|
|
23
|
+
* Injectable and swappable per environment (production vs test). Does not
|
|
24
|
+
* contain config (static values) or app runtime state (mutable refs like
|
|
25
|
+
* `bootstrap_status`); the audit emitter and the realtime fan-outs hold only
|
|
26
|
+
* their registered members.
|
|
23
27
|
*/
|
|
24
28
|
export interface AppDeps {
|
|
25
29
|
/** HMAC-SHA256 cookie signing keyring. */
|
|
@@ -58,6 +62,16 @@ export interface AppDeps {
|
|
|
58
62
|
* WebSocket endpoint mounted it reaches no one.
|
|
59
63
|
*/
|
|
60
64
|
notification_sender: RealtimeNotificationSender;
|
|
65
|
+
/**
|
|
66
|
+
* Holds every request accepted — an HTTP request, a WS message — until
|
|
67
|
+
* its handler has returned and its effect flush settled, for the waits
|
|
68
|
+
* that must see them finish: `AppServer.close`'s shutdown drain and
|
|
69
|
+
* `_testing_drain_effects`. `create_app_backend` creates it;
|
|
70
|
+
* `create_app_server` holds its HTTP requests and every WS endpoint it
|
|
71
|
+
* mounts on it, and a WebSocket endpoint mounted by hand takes it through
|
|
72
|
+
* `register_action_ws`'s `request_tracker`.
|
|
73
|
+
*/
|
|
74
|
+
request_tracker: RequestTracker;
|
|
61
75
|
/**
|
|
62
76
|
* Optional content-addressed byte store. Present only on backends that
|
|
63
77
|
* serve binary content (facts) — minimal consumers leave it unset. The
|
package/dist/auth/deps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/lib/auth/deps.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/lib/auth/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA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AgB,CAAC;CACpC"}
|
package/dist/auth/deps.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Capabilities bundle for fuz_app backends.
|
|
3
3
|
*
|
|
4
4
|
* `AppDeps` is the central dependency injection type — injectable and swappable
|
|
5
5
|
* per environment (production vs test). Does not contain config (static values)
|
|
6
|
-
* or runtime state (mutable refs)
|
|
6
|
+
* or app runtime state (mutable refs like `bootstrap_status`); the audit emitter
|
|
7
|
+
* and the realtime fan-outs hold only their registered members.
|
|
7
8
|
*
|
|
8
9
|
* @module
|
|
9
10
|
*/
|
|
@@ -20,12 +20,60 @@ import type { Invite, CreateInviteInput, InviteWithUsernamesJson } from './invit
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const INVITE_COLUMNS: readonly ["id", "email", "username", "claimed_by", "claimed_at", "created_at", "created_by"];
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Error thrown by `query_create_invite` when an unclaimed invite already
|
|
24
|
+
* reserves the email or the username: the partial unique index
|
|
25
|
+
* `idx_invite_email_unclaimed` or `idx_invite_username_unclaimed` refused the
|
|
26
|
+
* insert (SQLSTATE `23505`), which aborts the caller's transaction. Twin of
|
|
27
|
+
* the Rust `InviteCreateError::Duplicate`.
|
|
28
|
+
*/
|
|
29
|
+
export declare class InviteDuplicateError extends Error {
|
|
30
|
+
constructor();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown by `query_create_invite` when the issuer is not an active
|
|
34
|
+
* account: its actor is missing or tombstoned, or its account soft-deleted — a
|
|
35
|
+
* delete that committed while the invite was in flight. Twin of the Rust
|
|
36
|
+
* `InviteCreateError::IssuerNotActive`.
|
|
37
|
+
*/
|
|
38
|
+
export declare class InviteIssuerNotActiveError extends Error {
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create an invite issued by the actor `input.created_by`.
|
|
24
43
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
44
|
+
* The issuer must be an active actor of a live account, checked here so every
|
|
45
|
+
* caller — the spine's `invite_create` handler and a consumer minting invites
|
|
46
|
+
* on its own path — gets the rule: an invite records no authority, so one
|
|
47
|
+
* minted for an issuer deleted mid-flight would outlive the delete that should
|
|
48
|
+
* have voided it. The issuer's account row is read under `FOR SHARE`
|
|
49
|
+
* (`query_account_lock_live_many`) before the insert: an account delete writes
|
|
50
|
+
* its tombstone first, so a delete that wrote its tombstone before the read is
|
|
51
|
+
* waited for if uncommitted and seen (the invite is refused), and one that
|
|
52
|
+
* reaches the row after it waits for this transaction to
|
|
53
|
+
* commit and then deletes the invite with the account's other unclaimed ones
|
|
54
|
+
* (`query_invite_delete_unclaimed_by_creators`). The actor's tombstone is read
|
|
55
|
+
* after the lock, so a delete waited on is seen there too.
|
|
56
|
+
*
|
|
57
|
+
* Run it inside the caller's transaction, which the lock spans — on the pool
|
|
58
|
+
* the lock ends with its statement and orders nothing. Lock order: account
|
|
59
|
+
* rows come before actor and `role_grant` rows, as the last-admin guard
|
|
60
|
+
* (`query_count_active_accounts_with_global_role_locked`) takes them (account,
|
|
61
|
+
* then actor, then grant). So take it before the transaction locks any actor
|
|
62
|
+
* or `role_grant` row — or lock the issuer's account row first yourself
|
|
63
|
+
* (`query_account_lock_live_many`), which this query then re-takes without
|
|
64
|
+
* waiting: a transaction holding a lock on the issuer's admin grant while it
|
|
65
|
+
* waits here on an account row a removal holds, while the removal's guard
|
|
66
|
+
* waits on that grant, deadlocks.
|
|
67
|
+
*
|
|
68
|
+
* Callers that pre-check for account collisions on `email` / `username` do so
|
|
69
|
+
* upstream. Twin of the Rust `query_create_invite`.
|
|
70
|
+
*
|
|
71
|
+
* @param deps - query dependencies (must be the caller's transaction)
|
|
72
|
+
* @param input - the invite fields and its issuing actor
|
|
27
73
|
* @returns the created invite
|
|
28
74
|
* @mutates `invite` table - inserts the new row
|
|
75
|
+
* @throws InviteIssuerNotActiveError if `created_by` names no actor, a tombstoned one, or one whose account is soft-deleted; nothing is inserted
|
|
76
|
+
* @throws InviteDuplicateError if an unclaimed invite with the same email or username already exists
|
|
29
77
|
*/
|
|
30
78
|
export declare const query_create_invite: (deps: QueryDeps, input: CreateInviteInput) => Promise<Invite>;
|
|
31
79
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/invite_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"invite_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/invite_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7F;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8FAQqB,CAAC;AAKjD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;;CAK9C;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;;CAKpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,OAAO,iBAAiB,KACtB,OAAO,CAAC,MAAM,CAiChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,4CAA4C,GACxD,MAAM,SAAS,EACf,OAAO,MAAM,GAAG,IAAI,EACpB,UAAU,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAgB5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,SAAS,EACf,WAAW,MAAM,EACjB,YAAY,MAAM,KAChB,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,GAChD,MAAM,SAAS,KACb,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAUxC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yCAAyC,GACrD,MAAM,SAAS,EACf,sBAAsB,aAAa,CAAC,IAAI,CAAC,KACvC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CASrB,CAAC"}
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import { assert_row } from '../db/assert_row.js';
|
|
10
|
+
import { is_pg_unique_violation } from '../db/pg_error.js';
|
|
10
11
|
import { columns_sql, iso8601_timestamp_expr, qualify_columns } from '../db/sql_columns.js';
|
|
12
|
+
import { query_account_lock_live_many } from './account_queries.js';
|
|
11
13
|
/**
|
|
12
14
|
* The full `invite` column set, named explicitly so a row read fails loud on
|
|
13
15
|
* schema drift — invite rows ride the `invite_create` / `invite_list` RPC
|
|
@@ -29,17 +31,90 @@ export const INVITE_COLUMNS = [
|
|
|
29
31
|
/** The `invite` timestamp override, by row qualifier (`''` bare, `i` for the username JOIN). */
|
|
30
32
|
const invite_expr = iso8601_timestamp_expr(INVITE_COLUMNS, ['claimed_at', 'created_at']);
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Error thrown by `query_create_invite` when an unclaimed invite already
|
|
35
|
+
* reserves the email or the username: the partial unique index
|
|
36
|
+
* `idx_invite_email_unclaimed` or `idx_invite_username_unclaimed` refused the
|
|
37
|
+
* insert (SQLSTATE `23505`), which aborts the caller's transaction. Twin of
|
|
38
|
+
* the Rust `InviteCreateError::Duplicate`.
|
|
39
|
+
*/
|
|
40
|
+
export class InviteDuplicateError extends Error {
|
|
41
|
+
constructor() {
|
|
42
|
+
super('an unclaimed invite already exists');
|
|
43
|
+
this.name = 'InviteDuplicateError';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown by `query_create_invite` when the issuer is not an active
|
|
48
|
+
* account: its actor is missing or tombstoned, or its account soft-deleted — a
|
|
49
|
+
* delete that committed while the invite was in flight. Twin of the Rust
|
|
50
|
+
* `InviteCreateError::IssuerNotActive`.
|
|
51
|
+
*/
|
|
52
|
+
export class InviteIssuerNotActiveError extends Error {
|
|
53
|
+
constructor() {
|
|
54
|
+
super('the issuer is not an active account');
|
|
55
|
+
this.name = 'InviteIssuerNotActiveError';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create an invite issued by the actor `input.created_by`.
|
|
33
60
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
61
|
+
* The issuer must be an active actor of a live account, checked here so every
|
|
62
|
+
* caller — the spine's `invite_create` handler and a consumer minting invites
|
|
63
|
+
* on its own path — gets the rule: an invite records no authority, so one
|
|
64
|
+
* minted for an issuer deleted mid-flight would outlive the delete that should
|
|
65
|
+
* have voided it. The issuer's account row is read under `FOR SHARE`
|
|
66
|
+
* (`query_account_lock_live_many`) before the insert: an account delete writes
|
|
67
|
+
* its tombstone first, so a delete that wrote its tombstone before the read is
|
|
68
|
+
* waited for if uncommitted and seen (the invite is refused), and one that
|
|
69
|
+
* reaches the row after it waits for this transaction to
|
|
70
|
+
* commit and then deletes the invite with the account's other unclaimed ones
|
|
71
|
+
* (`query_invite_delete_unclaimed_by_creators`). The actor's tombstone is read
|
|
72
|
+
* after the lock, so a delete waited on is seen there too.
|
|
73
|
+
*
|
|
74
|
+
* Run it inside the caller's transaction, which the lock spans — on the pool
|
|
75
|
+
* the lock ends with its statement and orders nothing. Lock order: account
|
|
76
|
+
* rows come before actor and `role_grant` rows, as the last-admin guard
|
|
77
|
+
* (`query_count_active_accounts_with_global_role_locked`) takes them (account,
|
|
78
|
+
* then actor, then grant). So take it before the transaction locks any actor
|
|
79
|
+
* or `role_grant` row — or lock the issuer's account row first yourself
|
|
80
|
+
* (`query_account_lock_live_many`), which this query then re-takes without
|
|
81
|
+
* waiting: a transaction holding a lock on the issuer's admin grant while it
|
|
82
|
+
* waits here on an account row a removal holds, while the removal's guard
|
|
83
|
+
* waits on that grant, deadlocks.
|
|
84
|
+
*
|
|
85
|
+
* Callers that pre-check for account collisions on `email` / `username` do so
|
|
86
|
+
* upstream. Twin of the Rust `query_create_invite`.
|
|
87
|
+
*
|
|
88
|
+
* @param deps - query dependencies (must be the caller's transaction)
|
|
89
|
+
* @param input - the invite fields and its issuing actor
|
|
36
90
|
* @returns the created invite
|
|
37
91
|
* @mutates `invite` table - inserts the new row
|
|
92
|
+
* @throws InviteIssuerNotActiveError if `created_by` names no actor, a tombstoned one, or one whose account is soft-deleted; nothing is inserted
|
|
93
|
+
* @throws InviteDuplicateError if an unclaimed invite with the same email or username already exists
|
|
38
94
|
*/
|
|
39
95
|
export const query_create_invite = async (deps, input) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
96
|
+
// An actor's account never changes, so it is read unlocked.
|
|
97
|
+
const issuer = await deps.db.query_one(`SELECT account_id FROM actor WHERE id = $1`, [input.created_by]);
|
|
98
|
+
if (!issuer ||
|
|
99
|
+
!(await query_account_lock_live_many(deps, [issuer.account_id])).has(issuer.account_id)) {
|
|
100
|
+
throw new InviteIssuerNotActiveError();
|
|
101
|
+
}
|
|
102
|
+
// After the lock, so a delete it waited on is seen.
|
|
103
|
+
const issuer_actor = await deps.db.query_one(`SELECT id FROM actor WHERE id = $1 AND deleted_at IS NULL`, [input.created_by]);
|
|
104
|
+
if (!issuer_actor) {
|
|
105
|
+
throw new InviteIssuerNotActiveError();
|
|
106
|
+
}
|
|
107
|
+
let row;
|
|
108
|
+
try {
|
|
109
|
+
row = await deps.db.query_one(`INSERT INTO invite (email, username, created_by)
|
|
110
|
+
VALUES ($1, $2, $3)
|
|
111
|
+
RETURNING ${columns_sql(INVITE_COLUMNS, invite_expr(''))}`, [input.email ?? null, input.username ?? null, input.created_by]);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (is_pg_unique_violation(err))
|
|
115
|
+
throw new InviteDuplicateError();
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
43
118
|
return assert_row(row, 'INSERT INTO invite');
|
|
44
119
|
};
|
|
45
120
|
/**
|
|
@@ -52,6 +52,7 @@ export type InviteWithUsernamesJson = Infer<typeof InviteWithUsernamesJson>;
|
|
|
52
52
|
export interface CreateInviteInput {
|
|
53
53
|
email?: Email | null;
|
|
54
54
|
username?: Username | null;
|
|
55
|
-
|
|
55
|
+
/** The issuing actor, which must be active on a live account (`query_create_invite`). */
|
|
56
|
+
created_by: Uuid;
|
|
56
57
|
}
|
|
57
58
|
//# sourceMappingURL=invite_schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite_schema.d.ts","sourceRoot":"","sources":["../../src/lib/auth/invite_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA4B,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,EAAE,KAAK,EAAgC,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnG,oCAAoC;AACpC,MAAM,WAAW,MAAM;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,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H,eAAO,MAAM,uBAAuB;;;;;;;;;;EAIlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE5E,oCAAoC;AACpC,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,yFAAyF;IACzF,UAAU,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import type { SessionOptions } from './session_cookie.js';
|
|
10
9
|
import type { AppDeps } from './deps.js';
|
|
11
10
|
import type { DaemonTokenState } from './daemon_token.js';
|
|
12
11
|
import type { MiddlewareCarveOut, MiddlewareSpec } from '../http/middleware_spec.js';
|
|
@@ -144,7 +143,7 @@ export declare const assert_middleware_stack_mounted: (stack_specs: ReadonlyArra
|
|
|
144
143
|
*/
|
|
145
144
|
export interface AuthMiddlewareOptions {
|
|
146
145
|
allowed_origins: Array<RegExp>;
|
|
147
|
-
|
|
146
|
+
session_cookie_name: string;
|
|
148
147
|
/**
|
|
149
148
|
* Path pattern for the session, request-context, bearer, and daemon-token
|
|
150
149
|
* layers (default: `AUTH_MIDDLEWARE_PATH`, `'/api/*'`). The origin check
|
|
@@ -177,7 +176,7 @@ export interface AuthMiddlewareOptions {
|
|
|
177
176
|
* non-standard paths (e.g., tx's `/tx` binary endpoint).
|
|
178
177
|
*
|
|
179
178
|
* @param deps - stateless capabilities (keyring, db)
|
|
180
|
-
* @param options - middleware configuration (allowed_origins,
|
|
179
|
+
* @param options - middleware configuration (allowed_origins, session_cookie_name, path, daemon_token_state, origin_carve_outs)
|
|
181
180
|
* @throws Error when an origin carve-out has no path or no reason, or overlaps `path`
|
|
182
181
|
* @returns the middleware spec array
|
|
183
182
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/lib/auth/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/lib/auth/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,GACzC,QAAQ,eAAe,GAAG,cAAc,GAAG,wBAAwB,EACnE,MAAM,MAAM,KACV,IAQF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sCAAsC,GAClD,aAAa,aAAa,CAAC,SAAS,CAAC,KACnC,IAcF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,8BAA8B,GAC1C,YAAY,aAAa,CAAC,kBAAkB,CAAC,EAC7C,YAAW,MAA6B,KACtC,IAkCF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACpC,YAAY,aAAa,CAAC,kBAAkB,CAAC,KAC3C,aAAa,CAAC,kBAAkB,CACkD,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,+BAA+B,GAC3C,aAAa,aAAa,CAAC,cAAc,CAAC,EAC1C,kBAAkB,aAAa,CAAC,cAAc,CAAC,KAC7C,IA+BF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACtD,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,GACxC,MAAM,OAAO,EACb,SAAS,qBAAqB,KAC5B,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAqF/B,CAAC"}
|
package/dist/auth/middleware.js
CHANGED
|
@@ -224,13 +224,13 @@ export const assert_middleware_stack_mounted = (stack_specs, middleware_specs) =
|
|
|
224
224
|
* non-standard paths (e.g., tx's `/tx` binary endpoint).
|
|
225
225
|
*
|
|
226
226
|
* @param deps - stateless capabilities (keyring, db)
|
|
227
|
-
* @param options - middleware configuration (allowed_origins,
|
|
227
|
+
* @param options - middleware configuration (allowed_origins, session_cookie_name, path, daemon_token_state, origin_carve_outs)
|
|
228
228
|
* @throws Error when an origin carve-out has no path or no reason, or overlaps `path`
|
|
229
229
|
* @returns the middleware spec array
|
|
230
230
|
*/
|
|
231
231
|
export const create_auth_middleware_specs = async (deps, options) => {
|
|
232
232
|
const { keyring, db } = deps;
|
|
233
|
-
const { allowed_origins,
|
|
233
|
+
const { allowed_origins, session_cookie_name, path = AUTH_MIDDLEWARE_PATH, daemon_token_state } = options;
|
|
234
234
|
// copied before it is checked, so what is checked is what runs
|
|
235
235
|
const origin_carve_outs = freeze_origin_carve_outs(options.origin_carve_outs ?? []);
|
|
236
236
|
assert_origin_carve_outs_valid(origin_carve_outs, path);
|
|
@@ -246,7 +246,7 @@ export const create_auth_middleware_specs = async (deps, options) => {
|
|
|
246
246
|
import('./request_context.js'),
|
|
247
247
|
import('./bearer_auth.js')
|
|
248
248
|
]);
|
|
249
|
-
const session_middleware = create_session_middleware(keyring,
|
|
249
|
+
const session_middleware = create_session_middleware(keyring, session_cookie_name);
|
|
250
250
|
// the first credential leg clears the resolved credential: the daemon
|
|
251
251
|
// token's when it is composed, else this one
|
|
252
252
|
const request_context_middleware = create_request_context_middleware(query_deps, {
|
|
@@ -489,9 +489,9 @@ export type AuthorizationResult = {
|
|
|
489
489
|
* Pure data — the function does not touch a Hono context. Each transport
|
|
490
490
|
* passes the account its credential resolved (`ResolvedAuth.account`) and
|
|
491
491
|
* binds the returned `AuthorizationResult` to its wire shape. The REST
|
|
492
|
-
* pipeline additionally writes `REQUEST_CONTEXT_KEY` on `c` for
|
|
493
|
-
* `require_role`
|
|
494
|
-
* the
|
|
492
|
+
* pipeline additionally writes `REQUEST_CONTEXT_KEY` on `c` for the
|
|
493
|
+
* downstream `require_role` middleware, which reads the resolved context off
|
|
494
|
+
* the Hono context.
|
|
495
495
|
*
|
|
496
496
|
* The account is never read here: the context is built on the credential
|
|
497
497
|
* leg's row, so a request reads its account once, as on the Rust spine,
|
|
@@ -499,9 +499,9 @@ export const build_request_context = async (deps, account, actor) => {
|
|
|
499
499
|
* Pure data — the function does not touch a Hono context. Each transport
|
|
500
500
|
* passes the account its credential resolved (`ResolvedAuth.account`) and
|
|
501
501
|
* binds the returned `AuthorizationResult` to its wire shape. The REST
|
|
502
|
-
* pipeline additionally writes `REQUEST_CONTEXT_KEY` on `c` for
|
|
503
|
-
* `require_role`
|
|
504
|
-
* the
|
|
502
|
+
* pipeline additionally writes `REQUEST_CONTEXT_KEY` on `c` for the
|
|
503
|
+
* downstream `require_role` middleware, which reads the resolved context off
|
|
504
|
+
* the Hono context.
|
|
505
505
|
*
|
|
506
506
|
* The account is never read here: the context is built on the credential
|
|
507
507
|
* leg's row, so a request reads its account once, as on the Rust spine,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Context } from 'hono';
|
|
17
17
|
import type { QueryDeps } from '../db/query_deps.js';
|
|
18
|
-
import type { Account } from './account_schema.js';
|
|
18
|
+
import type { Account, SessionId } from './account_schema.js';
|
|
19
19
|
import { type RequestContext } from './request_context.js';
|
|
20
20
|
import { type TokenScope } from './token_scope.js';
|
|
21
21
|
/** The fields every resolved credential carries. */
|
|
@@ -47,7 +47,7 @@ interface ResolvedAuthBase {
|
|
|
47
47
|
export interface ResolvedSessionAuth extends ResolvedAuthBase {
|
|
48
48
|
readonly credential_type: 'session';
|
|
49
49
|
/** Blake3 hash of the session token — the `auth_session.id`. */
|
|
50
|
-
readonly session_hash:
|
|
50
|
+
readonly session_hash: SessionId;
|
|
51
51
|
}
|
|
52
52
|
/** An `Authorization: Bearer` API token — the only credential a scope narrows. */
|
|
53
53
|
export interface ResolvedApiTokenAuth extends ResolvedAuthBase {
|
|
@@ -90,7 +90,7 @@ export declare const resolved_auth_scope: (auth: ResolvedAuth | null) => TokenSc
|
|
|
90
90
|
* @param auth - the resolved credential, or `null` for an anonymous caller
|
|
91
91
|
* @returns the `auth_session.id`, or `null`
|
|
92
92
|
*/
|
|
93
|
-
export declare const resolved_auth_session_hash: (auth: ResolvedAuth | null) =>
|
|
93
|
+
export declare const resolved_auth_session_hash: (auth: ResolvedAuth | null) => SessionId | null;
|
|
94
94
|
/**
|
|
95
95
|
* The token id of an API token credential, `null` for any other (or none).
|
|
96
96
|
*
|
|
@@ -140,10 +140,10 @@ export declare const get_resolved_auth: (c: Context) => ResolvedAuth | null;
|
|
|
140
140
|
* - **Every credential** — the account row still exists and is not
|
|
141
141
|
* soft-deleted.
|
|
142
142
|
*
|
|
143
|
-
* It re-checks the **credential**, not what a revocation chose to close:
|
|
144
|
-
* `
|
|
145
|
-
*
|
|
146
|
-
* check and is refused only if that account-wide close found its pending
|
|
143
|
+
* It re-checks the **credential**, not what a revocation chose to close: an
|
|
144
|
+
* `admin_token_revoke_all` closes every connection of the account but deletes
|
|
145
|
+
* only its API tokens, so a session's connection opening concurrently passes
|
|
146
|
+
* this check and is refused only if that account-wide close found its pending
|
|
147
147
|
* registration — the same two outcomes an already-open connection has.
|
|
148
148
|
*
|
|
149
149
|
* **No side effects.** Unlike the bearer middleware this never touches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolved_auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth/resolved_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolved_auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth/resolved_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErE,oDAAoD;AACpD,UAAU,gBAAgB;IACzB;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;OASG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED,iEAAiE;AACjE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC5D,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,gEAAgE;IAChE,QAAQ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