@fuzdev/fuz_app 0.110.1 → 0.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +15 -11
- package/dist/actions/action_rpc.d.ts +3 -3
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -6
- package/dist/actions/peer_ping.d.ts +8 -0
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +8 -0
- package/dist/actions/peer_request.d.ts +1 -1
- package/dist/actions/peer_request.js +1 -1
- package/dist/actions/perform_action.d.ts +16 -9
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +30 -21
- package/dist/actions/register_action_ws.d.ts +1 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +88 -21
- package/dist/auth/CLAUDE.md +59 -10
- package/dist/auth/account_action_specs.d.ts +0 -2
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +10 -1
- package/dist/auth/account_queries.d.ts +22 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +70 -16
- package/dist/auth/account_schema.d.ts +27 -9
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +23 -3
- package/dist/auth/actor_search_actions.d.ts +3 -3
- package/dist/auth/actor_search_actions.d.ts.map +1 -1
- package/dist/auth/actor_search_actions.js +10 -6
- package/dist/auth/admin_action_specs.d.ts +0 -2
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/api_token_queries.d.ts +9 -4
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +36 -8
- package/dist/auth/app_settings_queries.d.ts +8 -0
- package/dist/auth/app_settings_queries.d.ts.map +1 -1
- package/dist/auth/app_settings_queries.js +16 -3
- package/dist/auth/audit_log_queries.d.ts +21 -3
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +38 -7
- package/dist/auth/audit_log_schema.d.ts +0 -1
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/auth_ddl.d.ts +6 -0
- package/dist/auth/auth_ddl.d.ts.map +1 -1
- package/dist/auth/auth_ddl.js +9 -0
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +3 -8
- package/dist/auth/cell_audit_actions.d.ts.map +1 -1
- package/dist/auth/cell_audit_actions.js +1 -1
- package/dist/auth/cell_field_actions.js +1 -1
- package/dist/auth/cell_grant_actions.js +1 -1
- package/dist/auth/cell_item_actions.js +1 -1
- package/dist/auth/invite_queries.d.ts +10 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +28 -7
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +10 -0
- package/dist/auth/role_grant_offer_ddl.d.ts +34 -2
- package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_ddl.js +61 -2
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +48 -53
- package/dist/auth/role_grant_queries.d.ts +18 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +58 -18
- package/dist/auth/session_queries.d.ts +12 -3
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +26 -6
- package/dist/db/CLAUDE.md +34 -0
- package/dist/db/cell_audit_queries.d.ts.map +1 -1
- package/dist/db/cell_audit_queries.js +3 -1
- package/dist/db/cell_field_queries.d.ts +12 -3
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.js +25 -7
- package/dist/db/cell_grant_queries.d.ts +10 -2
- package/dist/db/cell_grant_queries.d.ts.map +1 -1
- package/dist/db/cell_grant_queries.js +29 -11
- package/dist/db/cell_item_queries.d.ts +13 -2
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.js +27 -7
- package/dist/db/cell_queries.d.ts +32 -3
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +57 -22
- package/dist/db/fact_queries.d.ts +7 -0
- package/dist/db/fact_queries.d.ts.map +1 -1
- package/dist/db/fact_queries.js +27 -4
- package/dist/db/schema_ready.d.ts +6 -1
- package/dist/db/schema_ready.d.ts.map +1 -1
- package/dist/db/schema_ready.js +6 -2
- package/dist/db/sql_columns.d.ts +144 -0
- package/dist/db/sql_columns.d.ts.map +1 -0
- package/dist/db/sql_columns.js +164 -0
- package/dist/db/sql_identifier.d.ts +6 -5
- package/dist/db/sql_identifier.d.ts.map +1 -1
- package/dist/db/sql_identifier.js +6 -5
- package/dist/http/CLAUDE.md +4 -2
- package/dist/http/jsonrpc_helpers.d.ts +13 -0
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +13 -0
- package/dist/http/route_spec.d.ts +2 -2
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +1 -2
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +7 -2
- package/dist/testing/CLAUDE.md +55 -28
- package/dist/testing/admin_integration.d.ts +0 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +0 -1
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +4 -1
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +5 -4
- package/dist/testing/app_server.d.ts +4 -3
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +11 -5
- package/dist/testing/attack_surface.d.ts +16 -0
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +36 -13
- package/dist/testing/audit_completeness.d.ts +0 -3
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +0 -1
- package/dist/testing/auth_apps.d.ts +9 -2
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +9 -2
- package/dist/testing/cross_backend/account_lifecycle.d.ts +5 -4
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +7 -0
- package/dist/testing/cross_backend/action_manifest.d.ts +19 -3
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +10 -4
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +9 -3
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.js +6 -0
- package/dist/testing/cross_backend/actor_lookup.d.ts +3 -2
- package/dist/testing/cross_backend/actor_lookup.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.d.ts +4 -2
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +1 -1
- package/dist/testing/cross_backend/cell_crud.d.ts +2 -2
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +10 -0
- package/dist/testing/cross_backend/cell_gated_create.d.ts +3 -3
- package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_grant_role.d.ts +2 -2
- package/dist/testing/cross_backend/cell_grant_role.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.d.ts +2 -2
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/expected_schema.json +1 -1
- package/dist/testing/cross_backend/fact_serving.d.ts +2 -2
- package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
- package/dist/testing/cross_backend/make_cross_backend_project.d.ts +17 -2
- package/dist/testing/cross_backend/make_cross_backend_project.d.ts.map +1 -1
- package/dist/testing/cross_backend/make_cross_backend_project.js +23 -3
- package/dist/testing/cross_backend/origin.d.ts +4 -2
- package/dist/testing/cross_backend/origin.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin.js +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +11 -7
- package/dist/testing/cross_backend/query_shape.d.ts +6 -5
- package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
- package/dist/testing/cross_backend/ready.d.ts +2 -2
- package/dist/testing/cross_backend/ready.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_enumeration.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_enumeration.js +7 -1
- package/dist/testing/cross_backend/setup.d.ts +26 -6
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.d.ts +5 -1
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.js +1 -5
- package/dist/testing/cross_backend/testing_backdoor.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +5 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +6 -0
- package/dist/testing/cross_backend/token_scope_surface.d.ts +2 -2
- package/dist/testing/cross_backend/token_scope_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/wire_shapes.d.ts +22 -0
- package/dist/testing/cross_backend/wire_shapes.d.ts.map +1 -0
- package/dist/testing/cross_backend/wire_shapes.js +41 -0
- package/dist/testing/data_exposure.d.ts +0 -3
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +0 -1
- package/dist/testing/db.d.ts +62 -7
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +86 -28
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +15 -2
- package/dist/testing/round_trip.d.ts +0 -3
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +0 -4
- package/dist/testing/rpc_attack_surface.js +2 -2
- package/dist/testing/rpc_round_trip.d.ts +0 -3
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +0 -1
- package/dist/testing/schema_generators.d.ts +15 -0
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +45 -11
- package/dist/testing/standard.d.ts +5 -1
- package/dist/testing/standard.d.ts.map +1 -1
- package/dist/testing/standard.js +2 -7
- package/dist/timestamp.d.ts +58 -0
- package/dist/timestamp.d.ts.map +1 -0
- package/dist/timestamp.js +57 -0
- package/dist/ui/AdminOverview.svelte +5 -10
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferHistory.svelte +3 -1
- package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.js +6 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAiB3E,+BAA+B;AAC/B,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,8CAA8C;AAC9C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AACnD,0CAA0C;AAC1C,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAIhD,sCAAsC;AACtC,eAAO,MAAM,qBAAqB;;;;;mBAoBrB,CAAC;AACd,MAAM,MAAM,qBA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;;;;;;CAUJ,CAAC;AAEtC,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;CAWP,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,yBAAyB,CAenE,CAAC"}
|
|
@@ -11,6 +11,13 @@ import { type TokenScope } from './token_scope.js';
|
|
|
11
11
|
export interface ApiTokenQueryDeps extends QueryDeps {
|
|
12
12
|
log: Logger;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The full `api_token` column set, named explicitly so a row read fails loud
|
|
16
|
+
* on schema drift (see `ACCOUNT_COLUMNS` in `auth/account_queries.ts` for the
|
|
17
|
+
* outage class; the Rust twin names columns at every token site). Keep in
|
|
18
|
+
* sync with `ApiToken` and the migration chain's end state.
|
|
19
|
+
*/
|
|
20
|
+
export declare const API_TOKEN_COLUMNS: readonly ["id", "account_id", "name", "token_hash", "expires_at", "last_used_at", "last_used_ip", "created_at", "scope"];
|
|
14
21
|
/**
|
|
15
22
|
* Store a new API token (the hash, not the raw token).
|
|
16
23
|
*
|
|
@@ -62,10 +69,8 @@ export declare const query_revoke_all_api_tokens_for_account: (deps: QueryDeps,
|
|
|
62
69
|
*/
|
|
63
70
|
export declare const query_revoke_api_token_for_account: (deps: QueryDeps, id: string, account_id: string) => Promise<boolean>;
|
|
64
71
|
/**
|
|
65
|
-
* List all tokens for an account
|
|
66
|
-
*
|
|
67
|
-
* Columns are enumerated explicitly to exclude `token_hash`.
|
|
68
|
-
* Must be updated if the `api_token` table gains new columns.
|
|
72
|
+
* List all tokens for an account, newest first — `API_TOKEN_CLIENT_COLUMNS`,
|
|
73
|
+
* so `token_hash` never rides the listing.
|
|
69
74
|
*/
|
|
70
75
|
export declare const query_api_token_list_for_account: (deps: QueryDeps, account_id: string) => Promise<Array<Omit<ApiToken, "token_hash">>>;
|
|
71
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_token_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token_queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"api_token_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/api_token_queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,KAAK,UAAU,EAAmD,MAAM,kBAAkB,CAAC;AAEpG,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IACnD,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,0HAUoB,CAAC;AAgBnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,IAAI,MAAM,EACV,YAAY,MAAM,EAClB,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,OAAO,UAAU,EACjB,aAAa,IAAI,GAAG,IAAI,KACtB,OAAO,CAAC,QAAQ,CAelB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,iBAAiB,EACvB,WAAW,MAAM,EACjB,IAAI,MAAM,GAAG,SAAS,EACtB,iBAAiB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,KAC/C,OAAO,CAAC,QAAQ,GAAG,SAAS,CAgC9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uCAAuC,GACnD,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,MAAM,CAMhB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,SAAS,EACf,IAAI,MAAM,EACV,YAAY,MAAM,KAChB,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAM7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,YAAY,MAAM,EAClB,YAAY,MAAM,KAChB,OAAO,CAAC,MAAM,CAYhB,CAAC"}
|
|
@@ -4,8 +4,38 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { assert_row } from '../db/assert_row.js';
|
|
7
|
+
import { columns_sql, iso8601_timestamp_expr, omit_columns } from '../db/sql_columns.js';
|
|
7
8
|
import { hash_api_token } from './api_token.js';
|
|
8
9
|
import { parse_stored_token_scope, serialize_token_scope } from './token_scope.js';
|
|
10
|
+
/**
|
|
11
|
+
* The full `api_token` column set, named explicitly so a row read fails loud
|
|
12
|
+
* on schema drift (see `ACCOUNT_COLUMNS` in `auth/account_queries.ts` for the
|
|
13
|
+
* outage class; the Rust twin names columns at every token site). Keep in
|
|
14
|
+
* sync with `ApiToken` and the migration chain's end state.
|
|
15
|
+
*/
|
|
16
|
+
export const API_TOKEN_COLUMNS = [
|
|
17
|
+
'id',
|
|
18
|
+
'account_id',
|
|
19
|
+
'name',
|
|
20
|
+
'token_hash',
|
|
21
|
+
'expires_at',
|
|
22
|
+
'last_used_at',
|
|
23
|
+
'last_used_ip',
|
|
24
|
+
'created_at',
|
|
25
|
+
'scope'
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* `API_TOKEN_COLUMNS` minus `token_hash` — the client-safe listing
|
|
29
|
+
* projection, derived so a new column can't land on the wire un-reviewed
|
|
30
|
+
* while the hash stays off it by construction.
|
|
31
|
+
*/
|
|
32
|
+
const API_TOKEN_CLIENT_COLUMNS = omit_columns(API_TOKEN_COLUMNS, 'token_hash');
|
|
33
|
+
/** The `api_token` timestamp override; every read here is on the bare table. */
|
|
34
|
+
const api_token_expr = iso8601_timestamp_expr(API_TOKEN_COLUMNS, [
|
|
35
|
+
'expires_at',
|
|
36
|
+
'last_used_at',
|
|
37
|
+
'created_at'
|
|
38
|
+
])('');
|
|
9
39
|
/**
|
|
10
40
|
* Store a new API token (the hash, not the raw token).
|
|
11
41
|
*
|
|
@@ -21,7 +51,7 @@ import { parse_stored_token_scope, serialize_token_scope } from './token_scope.j
|
|
|
21
51
|
export const query_create_api_token = async (deps, id, account_id, name, token_hash, scope, expires_at) => {
|
|
22
52
|
const row = await deps.db.query_one(`INSERT INTO api_token (id, account_id, name, token_hash, scope, expires_at)
|
|
23
53
|
VALUES ($1, $2, $3, $4, $5::jsonb, $6)
|
|
24
|
-
RETURNING
|
|
54
|
+
RETURNING ${columns_sql(API_TOKEN_COLUMNS, api_token_expr)}`, [
|
|
25
55
|
id,
|
|
26
56
|
account_id,
|
|
27
57
|
name,
|
|
@@ -48,7 +78,7 @@ export const query_create_api_token = async (deps, id, account_id, name, token_h
|
|
|
48
78
|
*/
|
|
49
79
|
export const query_validate_api_token = async (deps, raw_token, ip, pending_effects) => {
|
|
50
80
|
const token_hash = hash_api_token(raw_token);
|
|
51
|
-
const row = await deps.db.query_one(`SELECT
|
|
81
|
+
const row = await deps.db.query_one(`SELECT ${columns_sql(API_TOKEN_COLUMNS, api_token_expr)} FROM api_token
|
|
52
82
|
WHERE token_hash = $1
|
|
53
83
|
AND (expires_at IS NULL OR expires_at > NOW())`, [token_hash]);
|
|
54
84
|
if (!row)
|
|
@@ -102,14 +132,12 @@ export const query_revoke_api_token_for_account = async (deps, id, account_id) =
|
|
|
102
132
|
return rows.length > 0;
|
|
103
133
|
};
|
|
104
134
|
/**
|
|
105
|
-
* List all tokens for an account
|
|
106
|
-
*
|
|
107
|
-
* Columns are enumerated explicitly to exclude `token_hash`.
|
|
108
|
-
* Must be updated if the `api_token` table gains new columns.
|
|
135
|
+
* List all tokens for an account, newest first — `API_TOKEN_CLIENT_COLUMNS`,
|
|
136
|
+
* so `token_hash` never rides the listing.
|
|
109
137
|
*/
|
|
110
138
|
export const query_api_token_list_for_account = async (deps, account_id) => {
|
|
111
|
-
return deps.db.query(`SELECT
|
|
112
|
-
FROM api_token WHERE account_id = $1 ORDER BY created_at DESC`, [account_id]);
|
|
139
|
+
return deps.db.query(`SELECT ${columns_sql(API_TOKEN_CLIENT_COLUMNS, api_token_expr)}
|
|
140
|
+
FROM api_token WHERE account_id = $1 ORDER BY api_token.created_at DESC`, [account_id]);
|
|
113
141
|
};
|
|
114
142
|
/**
|
|
115
143
|
* Enforce a per-account token limit by evicting the oldest tokens.
|
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { QueryDeps } from '../db/query_deps.js';
|
|
9
9
|
import type { AppSettings, AppSettingsWithUsernameJson } from './app_settings_schema.js';
|
|
10
|
+
/**
|
|
11
|
+
* The full `app_settings` column set — the singleton `id` (always `1`) plus
|
|
12
|
+
* the settings the row type carries — drift-guarded like every other
|
|
13
|
+
* `*_COLUMNS`. Reads project `APP_SETTINGS_ROW_COLUMNS`, which omits the
|
|
14
|
+
* constant `id` since `AppSettings` doesn't carry it. Keep in sync with
|
|
15
|
+
* `AppSettings` and the `app_settings` DDL in `auth/auth_ddl.ts`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const APP_SETTINGS_COLUMNS: readonly ["id", "open_signup", "updated_at", "updated_by"];
|
|
10
18
|
/**
|
|
11
19
|
* Load the current app settings.
|
|
12
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_settings_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/app_settings_queries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"app_settings_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/app_settings_queries.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAOrD,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEzF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,4DAA6D,CAAC;AAQ/F;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,WAAW,CAQlF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,GACjD,MAAM,SAAS,KACb,OAAO,CAAC,2BAA2B,CAWrC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,SAAS,EACf,aAAa,OAAO,EACpB,UAAU,MAAM,KACd,OAAO,CAAC,WAAW,CASrB,CAAC"}
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
|
+
import { columns_sql, iso8601_timestamp_expr, omit_columns, qualify_columns } from '../db/sql_columns.js';
|
|
9
|
+
/**
|
|
10
|
+
* The full `app_settings` column set — the singleton `id` (always `1`) plus
|
|
11
|
+
* the settings the row type carries — drift-guarded like every other
|
|
12
|
+
* `*_COLUMNS`. Reads project `APP_SETTINGS_ROW_COLUMNS`, which omits the
|
|
13
|
+
* constant `id` since `AppSettings` doesn't carry it. Keep in sync with
|
|
14
|
+
* `AppSettings` and the `app_settings` DDL in `auth/auth_ddl.ts`.
|
|
15
|
+
*/
|
|
16
|
+
export const APP_SETTINGS_COLUMNS = ['id', 'open_signup', 'updated_at', 'updated_by'];
|
|
17
|
+
/** `APP_SETTINGS_COLUMNS` minus the constant singleton `id` — the `AppSettings` row projection. */
|
|
18
|
+
const APP_SETTINGS_ROW_COLUMNS = omit_columns(APP_SETTINGS_COLUMNS, 'id');
|
|
19
|
+
/** The `app_settings` timestamp override, by row qualifier (`''` bare, `s` for the username JOIN). */
|
|
20
|
+
const app_settings_expr = iso8601_timestamp_expr(APP_SETTINGS_ROW_COLUMNS, ['updated_at']);
|
|
8
21
|
/**
|
|
9
22
|
* Load the current app settings.
|
|
10
23
|
*
|
|
@@ -13,7 +26,7 @@
|
|
|
13
26
|
* @throws Error if the singleton `app_settings` row is missing (migration drift — should not occur in practice)
|
|
14
27
|
*/
|
|
15
28
|
export const query_app_settings_load = async (deps) => {
|
|
16
|
-
const row = await deps.db.query_one(`SELECT
|
|
29
|
+
const row = await deps.db.query_one(`SELECT ${columns_sql(APP_SETTINGS_ROW_COLUMNS, app_settings_expr(''))} FROM app_settings WHERE id = 1`);
|
|
17
30
|
if (!row) {
|
|
18
31
|
throw new Error('app_settings row not found — migration may not have run');
|
|
19
32
|
}
|
|
@@ -27,7 +40,7 @@ export const query_app_settings_load = async (deps) => {
|
|
|
27
40
|
* @throws Error if the singleton `app_settings` row is missing
|
|
28
41
|
*/
|
|
29
42
|
export const query_app_settings_load_with_username = async (deps) => {
|
|
30
|
-
const row = await deps.db.query_one(`SELECT
|
|
43
|
+
const row = await deps.db.query_one(`SELECT ${qualify_columns(APP_SETTINGS_ROW_COLUMNS, 's', app_settings_expr('s'))}, act.name AS updated_by_username
|
|
31
44
|
FROM app_settings s
|
|
32
45
|
LEFT JOIN actor act ON act.id = s.updated_by
|
|
33
46
|
WHERE s.id = 1`);
|
|
@@ -47,7 +60,7 @@ export const query_app_settings_load_with_username = async (deps) => {
|
|
|
47
60
|
* @throws Error if the singleton `app_settings` row is missing
|
|
48
61
|
*/
|
|
49
62
|
export const query_app_settings_update = async (deps, open_signup, actor_id) => {
|
|
50
|
-
const row = await deps.db.query_one(`UPDATE app_settings SET open_signup = $1, updated_at = NOW(), updated_by = $2 WHERE id = 1 RETURNING
|
|
63
|
+
const row = await deps.db.query_one(`UPDATE app_settings SET open_signup = $1, updated_at = NOW(), updated_by = $2 WHERE id = 1 RETURNING ${columns_sql(APP_SETTINGS_ROW_COLUMNS, app_settings_expr(''))}`, [open_signup, actor_id]);
|
|
51
64
|
if (!row) {
|
|
52
65
|
throw new Error('app_settings row not found — migration may not have run');
|
|
53
66
|
}
|
|
@@ -13,6 +13,23 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { QueryDeps } from '../db/query_deps.js';
|
|
15
15
|
import { type AuditLogConfig, type AuditLogEvent, type AuditLogInput, type AuditLogListOptions, type AuditLogEventWithUsernamesJson, type RoleGrantHistoryEventJson } from './audit_log_schema.js';
|
|
16
|
+
/**
|
|
17
|
+
* The full `audit_log` column set, named explicitly so a row read fails loud
|
|
18
|
+
* on schema drift — audit rows ride the `audit_log_list` / role-grant-history
|
|
19
|
+
* RPC responses and the SSE broadcast raw, so a `SELECT *` would silently
|
|
20
|
+
* carry a dropped or leftover column into the strict-validated wire shapes
|
|
21
|
+
* (see `ACCOUNT_COLUMNS` in `auth/account_queries.ts` for the outage class;
|
|
22
|
+
* the Rust twin names columns at every audit site). Keep in sync with
|
|
23
|
+
* `AuditLogEvent` and the migration chain's end state. Exported for the
|
|
24
|
+
* per-cell timeline read in `db/cell_audit_queries.ts`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const AUDIT_LOG_COLUMNS: readonly ["id", "seq", "event_type", "outcome", "actor_id", "account_id", "target_account_id", "target_actor_id", "ip", "created_at", "metadata"];
|
|
27
|
+
/**
|
|
28
|
+
* The `audit_log` timestamp override, by row qualifier (`''` bare, `al` for
|
|
29
|
+
* the username JOINs). Exported for the per-cell timeline read in
|
|
30
|
+
* `db/cell_audit_queries.ts`, which projects the same table.
|
|
31
|
+
*/
|
|
32
|
+
export declare const audit_log_expr: (alias: string) => import("../db/sql_columns.js").ColumnExpr;
|
|
16
33
|
/** Number of audit metadata validation failures observed since process start. */
|
|
17
34
|
export declare const get_audit_metadata_validation_failures: () => number;
|
|
18
35
|
/** Reset the counter — for tests only. */
|
|
@@ -24,9 +41,10 @@ export declare const reset_audit_unknown_event_type_failures: () => void;
|
|
|
24
41
|
/**
|
|
25
42
|
* Insert an audit log entry.
|
|
26
43
|
*
|
|
27
|
-
* `
|
|
28
|
-
* `created_at`). Validates `metadata` against
|
|
29
|
-
* unknown `event_type` and metadata mismatches
|
|
44
|
+
* Returns the full row (`AUDIT_LOG_COLUMNS`) so callers receive DB-assigned
|
|
45
|
+
* fields (`id`, `seq`, `created_at`). Validates `metadata` against
|
|
46
|
+
* `config.metadata_schemas`; unknown `event_type` and metadata mismatches
|
|
47
|
+
* log + bump their counters
|
|
30
48
|
* but write the row anyway. Consumers extend the recognized set via
|
|
31
49
|
* `create_audit_log_config({extra_events})`.
|
|
32
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"audit_log_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,mJAYyB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,cAAc,8DAA4D,CAAC;AAaxF,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,QAAO,MACvB,CAAC;AAEpC,0CAA0C;AAC1C,eAAO,MAAM,wCAAwC,QAAO,IAE3D,CAAC;AAYF,gFAAgF;AAChF,eAAO,MAAM,qCAAqC,QAAO,MACvB,CAAC;AAEnC,0CAA0C;AAC1C,eAAO,MAAM,uCAAuC,QAAO,IAE1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,eAAe,GAAU,CAAC,SAAS,MAAM,EACrD,MAAM,SAAS,EACf,OAAO,aAAa,CAAC,CAAC,CAAC,EACvB,SAAQ,cAAyC,KAC/C,OAAO,CAAC,aAAa,CAsCvB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,UAAU,mBAAmB,KAC3B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CA0C9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,GAC/C,MAAM,SAAS,EACf,UAAU,mBAAmB,KAC3B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAwD/C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uCAAuC,GACnD,MAAM,SAAS,EACf,cAA+B,EAC/B,eAAU,KACR,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAmB1C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAC1C,MAAM,SAAS,EACf,QAAQ,IAAI,KACV,OAAO,CAAC,MAAM,CAMhB,CAAC"}
|
|
@@ -12,7 +12,37 @@
|
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
14
|
import { assert_row } from '../db/assert_row.js';
|
|
15
|
+
import { columns_sql, iso8601_timestamp_expr, qualify_columns } from '../db/sql_columns.js';
|
|
15
16
|
import { AUDIT_LOG_DEFAULT_LIMIT, builtin_audit_log_config } from './audit_log_schema.js';
|
|
17
|
+
/**
|
|
18
|
+
* The full `audit_log` column set, named explicitly so a row read fails loud
|
|
19
|
+
* on schema drift — audit rows ride the `audit_log_list` / role-grant-history
|
|
20
|
+
* RPC responses and the SSE broadcast raw, so a `SELECT *` would silently
|
|
21
|
+
* carry a dropped or leftover column into the strict-validated wire shapes
|
|
22
|
+
* (see `ACCOUNT_COLUMNS` in `auth/account_queries.ts` for the outage class;
|
|
23
|
+
* the Rust twin names columns at every audit site). Keep in sync with
|
|
24
|
+
* `AuditLogEvent` and the migration chain's end state. Exported for the
|
|
25
|
+
* per-cell timeline read in `db/cell_audit_queries.ts`.
|
|
26
|
+
*/
|
|
27
|
+
export const AUDIT_LOG_COLUMNS = [
|
|
28
|
+
'id',
|
|
29
|
+
'seq',
|
|
30
|
+
'event_type',
|
|
31
|
+
'outcome',
|
|
32
|
+
'actor_id',
|
|
33
|
+
'account_id',
|
|
34
|
+
'target_account_id',
|
|
35
|
+
'target_actor_id',
|
|
36
|
+
'ip',
|
|
37
|
+
'created_at',
|
|
38
|
+
'metadata'
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* The `audit_log` timestamp override, by row qualifier (`''` bare, `al` for
|
|
42
|
+
* the username JOINs). Exported for the per-cell timeline read in
|
|
43
|
+
* `db/cell_audit_queries.ts`, which projects the same table.
|
|
44
|
+
*/
|
|
45
|
+
export const audit_log_expr = iso8601_timestamp_expr(AUDIT_LOG_COLUMNS, ['created_at']);
|
|
16
46
|
/**
|
|
17
47
|
* Process-wide counter for audit metadata validation failures. `query_audit_log`
|
|
18
48
|
* increments on `safeParse` mismatch and writes the row anyway (fail-open —
|
|
@@ -47,9 +77,10 @@ export const reset_audit_unknown_event_type_failures = () => {
|
|
|
47
77
|
/**
|
|
48
78
|
* Insert an audit log entry.
|
|
49
79
|
*
|
|
50
|
-
* `
|
|
51
|
-
* `created_at`). Validates `metadata` against
|
|
52
|
-
* unknown `event_type` and metadata mismatches
|
|
80
|
+
* Returns the full row (`AUDIT_LOG_COLUMNS`) so callers receive DB-assigned
|
|
81
|
+
* fields (`id`, `seq`, `created_at`). Validates `metadata` against
|
|
82
|
+
* `config.metadata_schemas`; unknown `event_type` and metadata mismatches
|
|
83
|
+
* log + bump their counters
|
|
53
84
|
* but write the row anyway. Consumers extend the recognized set via
|
|
54
85
|
* `create_audit_log_config({extra_events})`.
|
|
55
86
|
*
|
|
@@ -83,7 +114,7 @@ export const query_audit_log = async (deps, input, config = builtin_audit_log_co
|
|
|
83
114
|
}
|
|
84
115
|
const rows = await deps.db.query(`INSERT INTO audit_log (event_type, outcome, actor_id, account_id, target_account_id, target_actor_id, ip, metadata)
|
|
85
116
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
86
|
-
RETURNING
|
|
117
|
+
RETURNING ${columns_sql(AUDIT_LOG_COLUMNS, audit_log_expr(''))}`, [
|
|
87
118
|
input.event_type,
|
|
88
119
|
input.outcome ?? 'success',
|
|
89
120
|
input.actor_id ?? null,
|
|
@@ -131,7 +162,7 @@ export const query_audit_log_list = async (deps, options) => {
|
|
|
131
162
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
132
163
|
const limit = options?.limit ?? AUDIT_LOG_DEFAULT_LIMIT;
|
|
133
164
|
const offset = options?.offset ?? 0;
|
|
134
|
-
return deps.db.query(`SELECT
|
|
165
|
+
return deps.db.query(`SELECT ${columns_sql(AUDIT_LOG_COLUMNS, audit_log_expr(''))} FROM audit_log ${where} ORDER BY seq DESC LIMIT $${param_index++} OFFSET $${param_index}`, [...params, limit, offset]);
|
|
135
166
|
};
|
|
136
167
|
/**
|
|
137
168
|
* List audit log entries with resolved usernames, newest first.
|
|
@@ -175,7 +206,7 @@ export const query_audit_log_list_with_usernames = async (deps, options) => {
|
|
|
175
206
|
// has no actor binding (admin password reset, session revoke, etc.).
|
|
176
207
|
// Under v1 1:1 the two branches resolve to the same username; the
|
|
177
208
|
// chain is forensic future-proofing for N:1 multi-actor.
|
|
178
|
-
return deps.db.query(`SELECT al
|
|
209
|
+
return deps.db.query(`SELECT ${qualify_columns(AUDIT_LOG_COLUMNS, 'al', audit_log_expr('al'))},
|
|
179
210
|
COALESCE(origin_act_acc.username, origin_acc.username) AS username,
|
|
180
211
|
COALESCE(target_act_acc.username, target_acc.username) AS target_username
|
|
181
212
|
FROM audit_log al
|
|
@@ -199,7 +230,7 @@ export const query_audit_log_list_role_grant_history = async (deps, limit = AUDI
|
|
|
199
230
|
// Same actor-chained JOIN as `query_audit_log_list_with_usernames` —
|
|
200
231
|
// see the comment there for rationale (forensic future-proofing for
|
|
201
232
|
// N:1 multi-actor; v1 1:1 picks the same username via either branch).
|
|
202
|
-
return deps.db.query(`SELECT al
|
|
233
|
+
return deps.db.query(`SELECT ${qualify_columns(AUDIT_LOG_COLUMNS, 'al', audit_log_expr('al'))},
|
|
203
234
|
COALESCE(origin_act_acc.username, origin_acc.username) AS username,
|
|
204
235
|
COALESCE(target_act_acc.username, target_acc.username) AS target_username
|
|
205
236
|
FROM audit_log al
|
|
@@ -475,7 +475,6 @@ export declare const AdminSessionJson: z.ZodObject<{
|
|
|
475
475
|
account_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
|
|
476
476
|
created_at: z.ZodString;
|
|
477
477
|
expires_at: z.ZodString;
|
|
478
|
-
last_seen_at: z.ZodString;
|
|
479
478
|
username: z.ZodString;
|
|
480
479
|
}, z.core.$strict>;
|
|
481
480
|
export type AdminSessionJson = z.infer<typeof AdminSessionJson>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAmB9C;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,6iBA6BnB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AC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,+DAA+D;AAC/D,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;kBAGzC,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE5F,wEAAwE;AACxE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;kBAGpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;kBAE3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/auth/auth_ddl.d.ts
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* (audit table) and `auth/role_grant_offer_ddl.ts` (offer table) — DDL lives
|
|
8
8
|
* in `*_ddl.ts`, Zod schemas in `*_schema.ts`.
|
|
9
9
|
*
|
|
10
|
+
* These strings are the body of the frozen `full_auth_schema` migration —
|
|
11
|
+
* never edit them (see the `auth/migrations.ts` module doc for the
|
|
12
|
+
* silent-outage rationale). Schema changes ship as new appended migrations,
|
|
13
|
+
* so a column retired later still appears below (created by v0, dropped
|
|
14
|
+
* downstream in the chain).
|
|
15
|
+
*
|
|
10
16
|
* @module
|
|
11
17
|
*/
|
|
12
18
|
export declare const ACCOUNT_SCHEMA = "\nCREATE TABLE IF NOT EXISTS account (\n id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n username TEXT UNIQUE NOT NULL,\n email TEXT,\n email_verified BOOLEAN NOT NULL DEFAULT false,\n password_hash TEXT NOT NULL,\n created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\n created_by UUID,\n updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),\n updated_by UUID,\n deleted_at TIMESTAMPTZ,\n deleted_by UUID\n)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth_ddl.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/auth_ddl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auth_ddl.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/auth_ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,eAAO,MAAM,cAAc,6ZAazB,CAAC;AAEH,eAAO,MAAM,YAAY,0ZAUvB,CAAC;AAEH,eAAO,MAAM,WAAW,wEAC0C,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,8FACqD,CAAC;AAEzF,eAAO,MAAM,iBAAiB,2ZAU5B,CAAC;AAEH,eAAO,MAAM,kBAAkB,UAI9B,CAAC;AAKF,eAAO,MAAM,mBAAmB,0RAO9B,CAAC;AAEH,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,iUAU3B,CAAC;AAEH,eAAO,MAAM,mBAAmB,4GACsE,CAAC;AAEvG,eAAO,MAAM,yBAAyB,6FACiD,CAAC;AAExF,eAAO,MAAM,eAAe,gFAC8C,CAAC;AAE3E,eAAO,MAAM,qBAAqB,wJAIhC,CAAC;AAEH,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,yHAGP,CAAC;AAE1B,eAAO,MAAM,aAAa,6ZAUxB,CAAC;AAEH,eAAO,MAAM,cAAc,UAI1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,oMAM9B,CAAC;AAEH,eAAO,MAAM,iBAAiB,sEACkC,CAAC"}
|
package/dist/auth/auth_ddl.js
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* (audit table) and `auth/role_grant_offer_ddl.ts` (offer table) — DDL lives
|
|
8
8
|
* in `*_ddl.ts`, Zod schemas in `*_schema.ts`.
|
|
9
9
|
*
|
|
10
|
+
* These strings are the body of the frozen `full_auth_schema` migration —
|
|
11
|
+
* never edit them (see the `auth/migrations.ts` module doc for the
|
|
12
|
+
* silent-outage rationale). Schema changes ship as new appended migrations,
|
|
13
|
+
* so a column retired later still appears below (created by v0, dropped
|
|
14
|
+
* downstream in the chain).
|
|
15
|
+
*
|
|
10
16
|
* @module
|
|
11
17
|
*/
|
|
12
18
|
// `deleted_at` is the soft-delete tombstone (delete = soft, purge = hard).
|
|
@@ -64,6 +70,9 @@ export const ROLE_GRANT_INDEXES = [
|
|
|
64
70
|
`CREATE UNIQUE INDEX IF NOT EXISTS role_grant_actor_role_active_unique
|
|
65
71
|
ON role_grant (actor_id, role) WHERE revoked_at IS NULL`
|
|
66
72
|
];
|
|
73
|
+
// `last_seen_at` stays in this frozen v0 body — the appended
|
|
74
|
+
// `drop_session_last_seen_at` migration removes it later in the chain, so a
|
|
75
|
+
// fresh bootstrap and an old deployed DB converge on the same shape.
|
|
67
76
|
export const AUTH_SESSION_SCHEMA = `
|
|
68
77
|
CREATE TABLE IF NOT EXISTS auth_session (
|
|
69
78
|
id TEXT PRIMARY KEY,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAIH,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAoCN,KAAK,QAAQ,EAEb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EASN,KAAK,OAAO,EACZ,MAAM,uB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AM,YAAY,GAAI,KAAK,OAAO,KAAG,QAgB1C,CAAC;AA2BH,+CAA+C;AAC/C,eAAO,MAAM,mBAAmB,GAAI,MAAM,cAAc,KAAG,KAAK,CAAC,SAAS,CAinBzE,CAAC"}
|
|
@@ -54,11 +54,6 @@ import { filter_visible_target_ids } from './cell_relation_visibility.js';
|
|
|
54
54
|
import { to_grant_json } from './cell_grant_actions.js';
|
|
55
55
|
import { to_field_json } from './cell_field_actions.js';
|
|
56
56
|
import { to_item_json } from './cell_item_actions.js';
|
|
57
|
-
const to_iso_nullable = (value) => {
|
|
58
|
-
if (value === null)
|
|
59
|
-
return null;
|
|
60
|
-
return typeof value === 'string' ? value : value.toISOString();
|
|
61
|
-
};
|
|
62
57
|
/**
|
|
63
58
|
* Translate the `idx_cell_path_unique` violation into a clean `conflict`
|
|
64
59
|
* (409) reason. `path` is the only unique constraint a cell write can hit
|
|
@@ -92,9 +87,9 @@ export const to_cell_json = (row) => ({
|
|
|
92
87
|
moderation: row.moderation,
|
|
93
88
|
created_by: row.created_by,
|
|
94
89
|
updated_by: row.updated_by,
|
|
95
|
-
created_at:
|
|
96
|
-
updated_at:
|
|
97
|
-
deleted_at:
|
|
90
|
+
created_at: row.created_at,
|
|
91
|
+
updated_at: row.updated_at,
|
|
92
|
+
deleted_at: row.deleted_at,
|
|
98
93
|
grant_count: row.grant_count
|
|
99
94
|
});
|
|
100
95
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell_audit_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_audit_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cell_audit_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_audit_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA+B/F,eAAO,MAAM,yBAAyB,QAAO,KAAK,CAAC,SAAS,CA0B3D,CAAC"}
|
|
@@ -32,7 +32,7 @@ const to_cell_audit_event_json = (row) => ({
|
|
|
32
32
|
event_type: row.event_type,
|
|
33
33
|
outcome: row.outcome,
|
|
34
34
|
actor_id: row.actor_id,
|
|
35
|
-
created_at:
|
|
35
|
+
created_at: row.created_at
|
|
36
36
|
});
|
|
37
37
|
export const create_cell_audit_actions = () => {
|
|
38
38
|
const handler = async (input, ctx) => {
|
|
@@ -36,7 +36,7 @@ export const to_field_json = (row) => ({
|
|
|
36
36
|
source_id: row.source_id,
|
|
37
37
|
name: row.name,
|
|
38
38
|
target_id: row.target_id,
|
|
39
|
-
created_at:
|
|
39
|
+
created_at: row.created_at
|
|
40
40
|
});
|
|
41
41
|
/** Create the three `cell_field_*` RPC actions. */
|
|
42
42
|
export const create_cell_field_actions = (deps) => {
|
|
@@ -44,7 +44,7 @@ export const to_grant_json = (row) => ({
|
|
|
44
44
|
role: row.role,
|
|
45
45
|
scope_id: row.scope_id,
|
|
46
46
|
granted_by: row.granted_by,
|
|
47
|
-
created_at:
|
|
47
|
+
created_at: row.created_at
|
|
48
48
|
});
|
|
49
49
|
/**
|
|
50
50
|
* Build the audit-metadata principal envelope from a `cell_grant` row.
|
|
@@ -44,7 +44,7 @@ export const to_item_json = (row) => ({
|
|
|
44
44
|
// on ingress).
|
|
45
45
|
position: row.position,
|
|
46
46
|
child_id: row.child_id,
|
|
47
|
-
created_at:
|
|
47
|
+
created_at: row.created_at
|
|
48
48
|
});
|
|
49
49
|
const position_taken_error = () => jsonrpc_errors.invalid_params('cell_item position taken', {
|
|
50
50
|
reason: ERROR_CELL_ITEM_POSITION_TAKEN
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { QueryDeps } from '../db/query_deps.js';
|
|
10
10
|
import type { Invite, CreateInviteInput, InviteWithUsernamesJson } from './invite_schema.js';
|
|
11
|
+
/**
|
|
12
|
+
* The full `invite` column set, named explicitly so a row read fails loud on
|
|
13
|
+
* schema drift — invite rows ride the `invite_create` / `invite_list` RPC
|
|
14
|
+
* responses raw, so a `SELECT *` would silently carry a dropped or leftover
|
|
15
|
+
* column into the strict-validated wire shapes (see `ACCOUNT_COLUMNS` in
|
|
16
|
+
* `auth/account_queries.ts` for the outage class; the Rust twin names
|
|
17
|
+
* columns at every invite site). Keep in sync with `Invite` and the
|
|
18
|
+
* migration chain's end state.
|
|
19
|
+
*/
|
|
20
|
+
export declare const INVITE_COLUMNS: readonly ["id", "email", "username", "claimed_by", "claimed_at", "created_at", "created_by"];
|
|
11
21
|
/**
|
|
12
22
|
* Create a new invite.
|
|
13
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/invite_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"invite_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/invite_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7F;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,8FAQqB,CAAC;AAKjD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,OAAO,iBAAiB,KACtB,OAAO,CAAC,MAAM,CAQhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oCAAoC,GAChD,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAK5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC,GACnD,MAAM,SAAS,EACf,UAAU,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAK5B,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;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAIlF,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"}
|
|
@@ -7,6 +7,27 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import { assert_row } from '../db/assert_row.js';
|
|
10
|
+
import { columns_sql, iso8601_timestamp_expr, qualify_columns } from '../db/sql_columns.js';
|
|
11
|
+
/**
|
|
12
|
+
* The full `invite` column set, named explicitly so a row read fails loud on
|
|
13
|
+
* schema drift — invite rows ride the `invite_create` / `invite_list` RPC
|
|
14
|
+
* responses raw, so a `SELECT *` would silently carry a dropped or leftover
|
|
15
|
+
* column into the strict-validated wire shapes (see `ACCOUNT_COLUMNS` in
|
|
16
|
+
* `auth/account_queries.ts` for the outage class; the Rust twin names
|
|
17
|
+
* columns at every invite site). Keep in sync with `Invite` and the
|
|
18
|
+
* migration chain's end state.
|
|
19
|
+
*/
|
|
20
|
+
export const INVITE_COLUMNS = [
|
|
21
|
+
'id',
|
|
22
|
+
'email',
|
|
23
|
+
'username',
|
|
24
|
+
'claimed_by',
|
|
25
|
+
'claimed_at',
|
|
26
|
+
'created_at',
|
|
27
|
+
'created_by'
|
|
28
|
+
];
|
|
29
|
+
/** The `invite` timestamp override, by row qualifier (`''` bare, `i` for the username JOIN). */
|
|
30
|
+
const invite_expr = iso8601_timestamp_expr(INVITE_COLUMNS, ['claimed_at', 'created_at']);
|
|
10
31
|
/**
|
|
11
32
|
* Create a new invite.
|
|
12
33
|
*
|
|
@@ -18,20 +39,20 @@ import { assert_row } from '../db/assert_row.js';
|
|
|
18
39
|
export const query_create_invite = async (deps, input) => {
|
|
19
40
|
const row = await deps.db.query_one(`INSERT INTO invite (email, username, created_by)
|
|
20
41
|
VALUES ($1, $2, $3)
|
|
21
|
-
RETURNING
|
|
42
|
+
RETURNING ${columns_sql(INVITE_COLUMNS, invite_expr(''))}`, [input.email ?? null, input.username ?? null, input.created_by]);
|
|
22
43
|
return assert_row(row, 'INSERT INTO invite');
|
|
23
44
|
};
|
|
24
45
|
/**
|
|
25
46
|
* Find an unclaimed invite by email (case-insensitive).
|
|
26
47
|
*/
|
|
27
48
|
export const query_invite_find_unclaimed_by_email = async (deps, email) => {
|
|
28
|
-
return deps.db.query_one(`SELECT
|
|
49
|
+
return deps.db.query_one(`SELECT ${columns_sql(INVITE_COLUMNS, invite_expr(''))} FROM invite WHERE LOWER(email) = LOWER($1) AND claimed_at IS NULL`, [email]);
|
|
29
50
|
};
|
|
30
51
|
/**
|
|
31
52
|
* Find an unclaimed invite by username (case-insensitive).
|
|
32
53
|
*/
|
|
33
54
|
export const query_invite_find_unclaimed_by_username = async (deps, username) => {
|
|
34
|
-
return deps.db.query_one(`SELECT
|
|
55
|
+
return deps.db.query_one(`SELECT ${columns_sql(INVITE_COLUMNS, invite_expr(''))} FROM invite WHERE LOWER(username) = LOWER($1) AND claimed_at IS NULL`, [username]);
|
|
35
56
|
};
|
|
36
57
|
/**
|
|
37
58
|
* Find an unclaimed invite matching email and/or username, taking a
|
|
@@ -56,7 +77,7 @@ export const query_invite_find_unclaimed_by_username = async (deps, username) =>
|
|
|
56
77
|
* @returns the matching invite (locked), or `undefined`
|
|
57
78
|
*/
|
|
58
79
|
export const query_invite_find_unclaimed_match_for_update = async (deps, email, username) => {
|
|
59
|
-
return deps.db.query_one(`SELECT
|
|
80
|
+
return deps.db.query_one(`SELECT ${columns_sql(INVITE_COLUMNS, invite_expr(''))} FROM invite WHERE claimed_at IS NULL AND (
|
|
60
81
|
(email IS NOT NULL AND username IS NULL
|
|
61
82
|
AND $1::text IS NOT NULL AND LOWER(email) = LOWER($1::text))
|
|
62
83
|
OR
|
|
@@ -66,7 +87,7 @@ export const query_invite_find_unclaimed_match_for_update = async (deps, email,
|
|
|
66
87
|
(email IS NOT NULL AND username IS NOT NULL
|
|
67
88
|
AND $1::text IS NOT NULL AND LOWER(email) = LOWER($1::text)
|
|
68
89
|
AND LOWER(username) = LOWER($2))
|
|
69
|
-
) ORDER BY created_at ASC, id ASC LIMIT 1
|
|
90
|
+
) ORDER BY invite.created_at ASC, invite.id ASC LIMIT 1
|
|
70
91
|
FOR UPDATE`, [email, username]);
|
|
71
92
|
};
|
|
72
93
|
/**
|
|
@@ -99,7 +120,7 @@ export const query_invite_claim_unscoped = async (deps, invite_id, account_id) =
|
|
|
99
120
|
* List all invites, newest first.
|
|
100
121
|
*/
|
|
101
122
|
export const query_invite_list_all = async (deps) => {
|
|
102
|
-
return deps.db.query(`SELECT
|
|
123
|
+
return deps.db.query(`SELECT ${columns_sql(INVITE_COLUMNS, invite_expr(''))} FROM invite ORDER BY invite.created_at DESC`);
|
|
103
124
|
};
|
|
104
125
|
/**
|
|
105
126
|
* List all invites with resolved creator/claimer usernames, newest first.
|
|
@@ -108,7 +129,7 @@ export const query_invite_list_all = async (deps) => {
|
|
|
108
129
|
* @returns invites with `created_by_username` and `claimed_by_username`
|
|
109
130
|
*/
|
|
110
131
|
export const query_invite_list_all_with_usernames = async (deps) => {
|
|
111
|
-
return deps.db.query(`SELECT i
|
|
132
|
+
return deps.db.query(`SELECT ${qualify_columns(INVITE_COLUMNS, 'i', invite_expr('i'))},
|
|
112
133
|
act.name AS created_by_username,
|
|
113
134
|
a.username AS claimed_by_username
|
|
114
135
|
FROM invite i
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,aAAa,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,EAAE,aAAa,CAAC,MAAM,CAA8B,CAAC;AAE/F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,aAAa,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,EAAE,aAAa,CAAC,MAAM,CAA8B,CAAC;AAE/F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,SAAS,CA6K5C,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
|