@fuzdev/fuz_app 0.155.0 → 0.156.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 +27 -14
- package/dist/actions/action_codegen.d.ts +10 -3
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +52 -13
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +13 -11
- package/dist/actions/action_rpc.d.ts +4 -3
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -3
- package/dist/actions/action_spec.d.ts +102 -206
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +18 -96
- package/dist/actions/action_types.d.ts +4 -4
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/broadcast_api.js +6 -5
- package/dist/actions/compile_action_registry.d.ts +11 -6
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/compile_action_registry.js +15 -9
- package/dist/actions/perform_action.d.ts +4 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +11 -11
- package/dist/auth/CLAUDE.md +1 -1
- package/dist/auth/account_action_specs.d.ts +50 -23
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +18 -8
- package/dist/auth/account_route_schema.d.ts +10 -10
- package/dist/auth/account_schema.d.ts +21 -21
- package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
- package/dist/auth/actor_search_action_specs.d.ts +6 -6
- package/dist/auth/admin_action_specs.d.ts +98 -98
- package/dist/auth/app_settings_schema.d.ts +2 -2
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_schema.d.ts +44 -44
- package/dist/auth/auth_guard_resolver.d.ts +2 -2
- package/dist/auth/auth_guard_resolver.js +2 -2
- package/dist/auth/bootstrap_route_schema.d.ts +4 -4
- package/dist/auth/cell_action_specs.d.ts +241 -241
- package/dist/auth/cell_actions.js +3 -3
- package/dist/auth/cell_audit_action_specs.d.ts +14 -14
- package/dist/auth/cell_audit_metadata.d.ts +6 -6
- package/dist/auth/cell_field_action_specs.d.ts +38 -38
- package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
- package/dist/auth/cell_grant_action_specs.d.ts +61 -61
- package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
- package/dist/auth/cell_item_action_specs.d.ts +50 -50
- package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
- package/dist/auth/invite_schema.d.ts +6 -6
- package/dist/auth/role_grant_offer_action_specs.d.ts +120 -120
- package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
- package/dist/auth/role_grant_offer_schema.d.ts +6 -6
- package/dist/auth/self_service_role_action_specs.d.ts +2 -2
- package/dist/auth/signup_route_schema.d.ts +2 -2
- package/dist/http/CLAUDE.md +9 -8
- package/dist/http/auth_shape.d.ts +54 -17
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +104 -52
- package/dist/http/error_schemas.d.ts +6 -4
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +4 -9
- package/dist/http/jsonrpc_errors.d.ts +11 -4
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +11 -4
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +2 -1
- package/dist/http/route_spec.d.ts +3 -2
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +20 -8
- package/dist/http/schema_helpers.d.ts +24 -20
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +24 -19
- package/dist/primitive_schemas.d.ts +10 -3
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +10 -2
- package/dist/primitive_schemas_fuz.d.ts +69 -0
- package/dist/primitive_schemas_fuz.d.ts.map +1 -0
- package/dist/primitive_schemas_fuz.js +49 -0
- package/dist/realtime/sse.d.ts +3 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +4 -4
- package/dist/schema_issues.d.ts +91 -4
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +262 -1
- package/dist/schema_meta.d.ts +24 -8
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +31 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +2 -1
- package/dist/testing/CLAUDE.md +17 -11
- package/dist/testing/adversarial_input_cases.d.ts +18 -23
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +51 -46
- package/dist/testing/cross_backend/action_manifest.d.ts +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +3 -3
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +3 -8
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +5 -4
- package/dist/testing/cross_backend/cross_rpc.d.ts +4 -2
- package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
- package/dist/testing/cross_backend/cross_rpc.js +6 -4
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +3 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +8 -8
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +4 -3
- package/dist/testing/rpc_envelope_cases.d.ts +3 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +1 -1
- package/dist/testing/rpc_helpers.d.ts +12 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +18 -15
- package/dist/testing/schema_generators.d.ts +75 -40
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +273 -99
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +4 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +10 -10
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.d.ts +6 -6
- package/dist/zod.d.ts +23 -5
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +2 -2
- package/package.json +6 -6
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* numbered — "registry-time invariant N" elsewhere in the codebase refers to
|
|
8
8
|
* the `RouteAuth` cross-axis set in `http/auth_shape.ts`, a different list):
|
|
9
9
|
*
|
|
10
|
+
* - **Auth-shape cross-axis invariants** — per `assert_route_auth_invariants`
|
|
11
|
+
* in `http/auth_shape.ts`: roles imply a required actor, no accountless
|
|
12
|
+
* actor, nothing to gate on unrestricted auth (that set's invariants 1, 3,
|
|
13
|
+
* and 4). Fires for every spec with non-null auth.
|
|
10
14
|
* - **Auth-shape biconditional** — per `assert_route_auth_acting_biconditional`
|
|
11
15
|
* in `http/auth_shape.ts`: `auth.actor !== 'none' ⟺ input declares
|
|
12
16
|
* acting?: ActingActor` (that set's invariant 2). Fires for every spec with
|
|
@@ -24,11 +28,12 @@
|
|
|
24
28
|
* requires `auth.account === 'required'`; without an account on the
|
|
25
29
|
* request there is no key for the per-account bucket.
|
|
26
30
|
* - **JSON-RPC §4.2 wire validity** — `request_response` specs whose
|
|
27
|
-
* handler will reach the dispatch map must not use
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
31
|
+
* handler will reach the dispatch map must not use a null schema
|
|
32
|
+
* (`z.null()`, fuz_schema `literal(null)`) for input (the wire format
|
|
33
|
+
* forbids `"params": null`; use a void schema, `z.void()` or fuz_schema
|
|
34
|
+
* `s.void`, for parameterless methods), nor a void schema for output (a
|
|
35
|
+
* response always carries a `result`, which clients validate against
|
|
36
|
+
* `spec.output`; use a null schema for methods with nothing to return).
|
|
32
37
|
* - **Duplicate method names** — JSON-RPC keys on `method`, so every
|
|
33
38
|
* spec in the array must declare a unique `method` regardless of
|
|
34
39
|
* kind / handler presence.
|
|
@@ -57,7 +62,7 @@ export interface ActionRegistryCompileResult {
|
|
|
57
62
|
*
|
|
58
63
|
* @param actions - polymorphic action array; HTTP RPC passes `RpcAction[]` (narrower), WebSocket passes `Action[]` (kind-polymorphic — handler-less notification specs are accepted)
|
|
59
64
|
* @param ctx_label - per-spec error-message prefix, e.g. `'RPC action'` or `'WS action'`. Combined with the spec method as `${ctx_label} "${method}"`.
|
|
60
|
-
* @throws Error on biconditional violation, rate-limit/account-axis mismatch, JSON-RPC null-input or void-output, or duplicate method.
|
|
65
|
+
* @throws Error on a cross-axis invariant or biconditional violation, rate-limit/account-axis mismatch, JSON-RPC null-input or void-output, or duplicate method.
|
|
61
66
|
*/
|
|
62
67
|
export declare const compile_action_registry: (actions: ReadonlyArray<Action>, ctx_label: string) => ActionRegistryCompileResult;
|
|
63
68
|
//# sourceMappingURL=compile_action_registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile_action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/compile_action_registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compile_action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/compile_action_registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAO3D,oDAAoD;AACpD,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,aAAa,CAAC,MAAM,CAAC,EAC9B,WAAW,MAAM,KACf,2BAqDF,CAAC"}
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* numbered — "registry-time invariant N" elsewhere in the codebase refers to
|
|
8
8
|
* the `RouteAuth` cross-axis set in `http/auth_shape.ts`, a different list):
|
|
9
9
|
*
|
|
10
|
+
* - **Auth-shape cross-axis invariants** — per `assert_route_auth_invariants`
|
|
11
|
+
* in `http/auth_shape.ts`: roles imply a required actor, no accountless
|
|
12
|
+
* actor, nothing to gate on unrestricted auth (that set's invariants 1, 3,
|
|
13
|
+
* and 4). Fires for every spec with non-null auth.
|
|
10
14
|
* - **Auth-shape biconditional** — per `assert_route_auth_acting_biconditional`
|
|
11
15
|
* in `http/auth_shape.ts`: `auth.actor !== 'none' ⟺ input declares
|
|
12
16
|
* acting?: ActingActor` (that set's invariant 2). Fires for every spec with
|
|
@@ -24,11 +28,12 @@
|
|
|
24
28
|
* requires `auth.account === 'required'`; without an account on the
|
|
25
29
|
* request there is no key for the per-account bucket.
|
|
26
30
|
* - **JSON-RPC §4.2 wire validity** — `request_response` specs whose
|
|
27
|
-
* handler will reach the dispatch map must not use
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
31
|
+
* handler will reach the dispatch map must not use a null schema
|
|
32
|
+
* (`z.null()`, fuz_schema `literal(null)`) for input (the wire format
|
|
33
|
+
* forbids `"params": null`; use a void schema, `z.void()` or fuz_schema
|
|
34
|
+
* `s.void`, for parameterless methods), nor a void schema for output (a
|
|
35
|
+
* response always carries a `result`, which clients validate against
|
|
36
|
+
* `spec.output`; use a null schema for methods with nothing to return).
|
|
32
37
|
* - **Duplicate method names** — JSON-RPC keys on `method`, so every
|
|
33
38
|
* spec in the array must declare a unique `method` regardless of
|
|
34
39
|
* kind / handler presence.
|
|
@@ -40,7 +45,7 @@
|
|
|
40
45
|
*
|
|
41
46
|
* @module
|
|
42
47
|
*/
|
|
43
|
-
import { assert_route_auth_acting_biconditional } from '../http/auth_shape.js';
|
|
48
|
+
import { assert_route_auth_acting_biconditional, assert_route_auth_invariants } from '../http/auth_shape.js';
|
|
44
49
|
import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
|
|
45
50
|
/**
|
|
46
51
|
* Validate registry-time invariants and build the dispatcher's
|
|
@@ -48,7 +53,7 @@ import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
|
|
|
48
53
|
*
|
|
49
54
|
* @param actions - polymorphic action array; HTTP RPC passes `RpcAction[]` (narrower), WebSocket passes `Action[]` (kind-polymorphic — handler-less notification specs are accepted)
|
|
50
55
|
* @param ctx_label - per-spec error-message prefix, e.g. `'RPC action'` or `'WS action'`. Combined with the spec method as `${ctx_label} "${method}"`.
|
|
51
|
-
* @throws Error on biconditional violation, rate-limit/account-axis mismatch, JSON-RPC null-input or void-output, or duplicate method.
|
|
56
|
+
* @throws Error on a cross-axis invariant or biconditional violation, rate-limit/account-axis mismatch, JSON-RPC null-input or void-output, or duplicate method.
|
|
52
57
|
*/
|
|
53
58
|
export const compile_action_registry = (actions, ctx_label) => {
|
|
54
59
|
const action_map = new Map();
|
|
@@ -63,6 +68,7 @@ export const compile_action_registry = (actions, ctx_label) => {
|
|
|
63
68
|
// Auth-shape invariants apply to any spec with non-null auth (which
|
|
64
69
|
// per the spec union means `kind === 'request_response'`).
|
|
65
70
|
if (spec.auth !== null) {
|
|
71
|
+
assert_route_auth_invariants(spec.auth, ctx);
|
|
66
72
|
assert_route_auth_acting_biconditional(spec.auth, { input: spec.input }, ctx);
|
|
67
73
|
if (spec.auth.required_scope !== undefined) {
|
|
68
74
|
throw new Error(`${ctx} declares auth.required_scope: '${spec.auth.required_scope}' — that slot is for route specs only. Actions dispatch through the RPC endpoint, where a narrowed token is gated per method by the scope check in perform_action, which derives the capability from the method name. Remove the field.`);
|
|
@@ -77,10 +83,10 @@ export const compile_action_registry = (actions, ctx_label) => {
|
|
|
77
83
|
// stay registry-only and bypass JSON-RPC wire-validity checks.
|
|
78
84
|
if (spec.kind === 'request_response' && action.handler) {
|
|
79
85
|
if (is_null_schema(spec.input)) {
|
|
80
|
-
throw new Error(`${ctx} uses z.null()
|
|
86
|
+
throw new Error(`${ctx} uses a null schema for input (z.null() or fuz_schema literal(null)) — JSON-RPC 2.0 §4.2 forbids "params": null on the wire. Use a void schema (z.void() or fuz_schema s.void) for parameterless methods.`);
|
|
81
87
|
}
|
|
82
88
|
if (is_void_schema(spec.output)) {
|
|
83
|
-
throw new Error(`${ctx} uses z.void()
|
|
89
|
+
throw new Error(`${ctx} uses a void schema for output (z.void() or fuz_schema s.void) — a JSON-RPC response always carries a result, and clients validate it against spec.output, so no response could match. Use a null schema (z.null() or fuz_schema literal(null)) for methods with nothing to return.`);
|
|
84
90
|
}
|
|
85
91
|
action_map.set(spec.method, { spec, handler: action.handler });
|
|
86
92
|
}
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
* with `data.reason` `params_proto_key` (`ERROR_PARAMS_PROTO_KEY`), on
|
|
33
33
|
* every input schema, before it runs; then
|
|
34
34
|
* `spec.input` parses the params (`parse_any`, Zod or fuz_schema) with
|
|
35
|
-
*
|
|
35
|
+
* void / `?? {}` rules (`to_input_params`). A refusal is the generic
|
|
36
36
|
* `invalid params`, with `data.reason` when the first issue's field
|
|
37
37
|
* declares an `invalid_reason` (`to_invalid_params_error`) and the
|
|
38
|
-
*
|
|
38
|
+
* issues, as `WireIssue`s, under DEV only. Runs **after** the authority gates: a
|
|
39
39
|
* 400 describing the action's input shape to a caller those gates
|
|
40
40
|
* refuse would confirm the method exists and describe how to call it,
|
|
41
41
|
* to a channel that should have learned nothing. Coarse authority
|
|
@@ -170,8 +170,8 @@ export declare const perform_action: (input: PerformActionInput, deps: PerformAc
|
|
|
170
170
|
* The `invalid_params` error an input validation failure answers: the generic
|
|
171
171
|
* `invalid params` message, `data.reason` when the field the first issue lands
|
|
172
172
|
* on declares an `invalid_reason` and no issue sits on the input itself
|
|
173
|
-
* (`resolve_issues_invalid_reason`), and the
|
|
174
|
-
* only (`dev_only`). With no declared reason, production sends no `data` at
|
|
173
|
+
* (`resolve_issues_invalid_reason`), and the issues as `WireIssue`s under
|
|
174
|
+
* DEV only (`dev_only`). With no declared reason, production sends no `data` at
|
|
175
175
|
* all.
|
|
176
176
|
*
|
|
177
177
|
* @param input - the action's input schema, Zod or fuz_schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perform_action.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/perform_action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,
|
|
1
|
+
{"version":3,"file":"perform_action.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/perform_action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,OA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IAAI,gBAAgB,EACpB,QAAQ,mBAAmB,EAC3B,QAAQ,MAAM,EACd,KAAK,MAAM,KACT,sBAkBF,CAAC"}
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
* with `data.reason` `params_proto_key` (`ERROR_PARAMS_PROTO_KEY`), on
|
|
33
33
|
* every input schema, before it runs; then
|
|
34
34
|
* `spec.input` parses the params (`parse_any`, Zod or fuz_schema) with
|
|
35
|
-
*
|
|
35
|
+
* void / `?? {}` rules (`to_input_params`). A refusal is the generic
|
|
36
36
|
* `invalid params`, with `data.reason` when the first issue's field
|
|
37
37
|
* declares an `invalid_reason` (`to_invalid_params_error`) and the
|
|
38
|
-
*
|
|
38
|
+
* issues, as `WireIssue`s, under DEV only. Runs **after** the authority gates: a
|
|
39
39
|
* 400 describing the action's input shape to a caller those gates
|
|
40
40
|
* refuse would confirm the method exists and describe how to call it,
|
|
41
41
|
* to a channel that should have learned nothing. Coarse authority
|
|
@@ -65,7 +65,7 @@ import { apply_authorization_phase, has_any_scoped_role } from '../auth/request_
|
|
|
65
65
|
import { resolved_auth_scope, resolved_auth_session_hash } from '../auth/resolved_auth.js';
|
|
66
66
|
import { is_db_checkout_error } from '../db/db_checkout_error.js';
|
|
67
67
|
import { resolve_issues_invalid_reason } from '../schema_meta.js';
|
|
68
|
-
import { parse_any } from '../schema_issues.js';
|
|
68
|
+
import { parse_any, to_wire_issues } from '../schema_issues.js';
|
|
69
69
|
import { json_has_own_proto_key, to_input_params } from '../http/schema_helpers.js';
|
|
70
70
|
import { rate_limit_ip_key } from '../http/ip_canonical.js';
|
|
71
71
|
import { dispatch_with_post_commit_rollback } from '../http/pending_effects.js';
|
|
@@ -167,9 +167,9 @@ export const perform_action = async (input, deps) => {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
// step 5: validate params. JSON-RPC 2.0 §4.2 forbids `params: null`;
|
|
170
|
-
// registration sites reject
|
|
170
|
+
// registration sites reject null-schema inputs. Empty-body convention
|
|
171
171
|
// (`raw_params ?? {}`) lets all-optional-object methods omit `params`;
|
|
172
|
-
// a
|
|
172
|
+
// a void input (Zod or fuz_schema) reads every empty shape as the no-arg call — see
|
|
173
173
|
// `to_input_params`.
|
|
174
174
|
//
|
|
175
175
|
// An own `__proto__` key anywhere in object params is refused first, on
|
|
@@ -252,15 +252,15 @@ const thrown_error_result = (err, context, log) => {
|
|
|
252
252
|
log.error(context, err);
|
|
253
253
|
// Raw exception messages can leak internals (paths, SQL, secrets in a
|
|
254
254
|
// message) — surface them only in development; production falls back to
|
|
255
|
-
// the generic `internal_error` default. Same gate as the
|
|
256
|
-
return error_result(jsonrpc_error_messages.internal_error(dev_only(err instanceof Error ? err.message : undefined)));
|
|
255
|
+
// the generic `internal_error` default. Same gate as the validation-issue redaction.
|
|
256
|
+
return error_result(jsonrpc_error_messages.internal_error(dev_only(() => (err instanceof Error ? err.message : undefined))));
|
|
257
257
|
};
|
|
258
258
|
/**
|
|
259
259
|
* The `invalid_params` error an input validation failure answers: the generic
|
|
260
260
|
* `invalid params` message, `data.reason` when the field the first issue lands
|
|
261
261
|
* on declares an `invalid_reason` and no issue sits on the input itself
|
|
262
|
-
* (`resolve_issues_invalid_reason`), and the
|
|
263
|
-
* only (`dev_only`). With no declared reason, production sends no `data` at
|
|
262
|
+
* (`resolve_issues_invalid_reason`), and the issues as `WireIssue`s under
|
|
263
|
+
* DEV only (`dev_only`). With no declared reason, production sends no `data` at
|
|
264
264
|
* all.
|
|
265
265
|
*
|
|
266
266
|
* @param input - the action's input schema, Zod or fuz_schema
|
|
@@ -270,7 +270,7 @@ const thrown_error_result = (err, context, log) => {
|
|
|
270
270
|
*/
|
|
271
271
|
export const to_invalid_params_error = (input, issues, params) => {
|
|
272
272
|
const reason = resolve_issues_invalid_reason(input, issues, params);
|
|
273
|
-
const issues_data = dev_only({ issues });
|
|
273
|
+
const issues_data = dev_only(() => ({ issues: to_wire_issues(issues, params) }));
|
|
274
274
|
return jsonrpc_error_messages.invalid_params('invalid params', reason === undefined ? issues_data : { reason, ...issues_data });
|
|
275
275
|
};
|
|
276
276
|
const error_result = (error) => ({
|
|
@@ -422,7 +422,7 @@ export const serialize_action_result = (id, result, method, log) => {
|
|
|
422
422
|
catch (error) {
|
|
423
423
|
log.error(`action result is not serializable: ${method}`, error);
|
|
424
424
|
return {
|
|
425
|
-
body: JSON.stringify(create_jsonrpc_error_response(id, jsonrpc_error_messages.internal_error(dev_only(error instanceof Error ? error.message : undefined)))),
|
|
425
|
+
body: JSON.stringify(create_jsonrpc_error_response(id, jsonrpc_error_messages.internal_error(dev_only(() => (error instanceof Error ? error.message : undefined))))),
|
|
426
426
|
status: jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.internal_error)
|
|
427
427
|
};
|
|
428
428
|
}
|
package/dist/auth/CLAUDE.md
CHANGED
|
@@ -714,7 +714,7 @@ targets the sole remaining active admin (soft-deleted admins don't count; the
|
|
|
714
714
|
count locks its rows, so concurrent removals can't both pass), `ERROR_INVITE_ACCOUNT_EXISTS_USERNAME` /
|
|
715
715
|
`_EMAIL` / `ERROR_INVITE_DUPLICATE` on invite create, `ERROR_INVITE_NOT_FOUND`
|
|
716
716
|
on invite delete. `invite_create` empty input is rejected at the schema via
|
|
717
|
-
`.refine()` and surfaces as `invalid_params` with `error.data.issues
|
|
717
|
+
`.refine()` and surfaces as `invalid_params` with `error.data.issues` (DEV-only `WireIssue`s).
|
|
718
718
|
|
|
719
719
|
Closure state:
|
|
720
720
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod';
|
|
11
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
12
|
import type { RequestResponseActionSpec } from '../actions/action_spec.js';
|
|
12
13
|
/** Input for `account_verify`. No parameters — the caller is the subject. */
|
|
13
14
|
export declare const VerifyInput: z.ZodVoid;
|
|
@@ -19,7 +20,7 @@ export type SessionListInput = z.infer<typeof SessionListInput>;
|
|
|
19
20
|
export declare const SessionListOutput: z.ZodObject<{
|
|
20
21
|
sessions: z.ZodArray<z.ZodObject<{
|
|
21
22
|
id: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
|
|
22
|
-
account_id: z.
|
|
23
|
+
account_id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string>>;
|
|
23
24
|
created_at: z.ZodString;
|
|
24
25
|
expires_at: z.ZodString;
|
|
25
26
|
is_current: z.ZodBoolean;
|
|
@@ -111,7 +112,7 @@ export type TokenListInput = z.infer<typeof TokenListInput>;
|
|
|
111
112
|
export declare const TokenListOutput: z.ZodObject<{
|
|
112
113
|
tokens: z.ZodArray<z.ZodObject<{
|
|
113
114
|
id: z.ZodString;
|
|
114
|
-
account_id: z.
|
|
115
|
+
account_id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string>>;
|
|
115
116
|
name: z.ZodString;
|
|
116
117
|
expires_at: z.ZodNullable<z.ZodString>;
|
|
117
118
|
last_used_at: z.ZodNullable<z.ZodString>;
|
|
@@ -121,17 +122,33 @@ export declare const TokenListOutput: z.ZodObject<{
|
|
|
121
122
|
}, z.core.$strict>>;
|
|
122
123
|
}, z.core.$strict>;
|
|
123
124
|
export type TokenListOutput = z.infer<typeof TokenListOutput>;
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
export
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Input for `account_token_revoke`, a `@fuzdev/fuz_schema` schema. Its
|
|
127
|
+
* `token_id` is `ApiTokenId`'s check written inline, as `ApiTokenId` is Zod.
|
|
128
|
+
*/
|
|
129
|
+
export declare const TokenRevokeInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
130
|
+
token_id: string;
|
|
131
|
+
}, {
|
|
132
|
+
token_id: string;
|
|
133
|
+
}, "object", {
|
|
134
|
+
token_id: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
135
|
+
}>;
|
|
136
|
+
export type TokenRevokeInput = Infer<typeof TokenRevokeInput>;
|
|
137
|
+
/**
|
|
138
|
+
* Output for `account_token_revoke`, a `@fuzdev/fuz_schema` schema.
|
|
139
|
+
* `revoked` is `false` for IDOR misses.
|
|
140
|
+
*/
|
|
141
|
+
export declare const TokenRevokeOutput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
142
|
+
ok: true;
|
|
143
|
+
revoked: boolean;
|
|
144
|
+
}, {
|
|
145
|
+
ok: true;
|
|
146
|
+
revoked: boolean;
|
|
147
|
+
}, "object", {
|
|
148
|
+
ok: import("@fuzdev/fuz_schema/schema.ts").Schema<true, true, "literal", true>;
|
|
149
|
+
revoked: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
150
|
+
}>;
|
|
151
|
+
export type TokenRevokeOutput = Infer<typeof TokenRevokeOutput>;
|
|
135
152
|
export declare const account_verify_action_spec: {
|
|
136
153
|
method: string;
|
|
137
154
|
kind: "request_response";
|
|
@@ -143,7 +160,7 @@ export declare const account_verify_action_spec: {
|
|
|
143
160
|
side_effects: false;
|
|
144
161
|
input: z.ZodVoid;
|
|
145
162
|
output: z.ZodObject<{
|
|
146
|
-
id: z.
|
|
163
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string>>;
|
|
147
164
|
username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
148
165
|
email: z.ZodNullable<z.ZodString>;
|
|
149
166
|
email_verified: z.ZodBoolean;
|
|
@@ -165,7 +182,7 @@ export declare const account_session_list_action_spec: {
|
|
|
165
182
|
output: z.ZodObject<{
|
|
166
183
|
sessions: z.ZodArray<z.ZodObject<{
|
|
167
184
|
id: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
|
|
168
|
-
account_id: z.
|
|
185
|
+
account_id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string>>;
|
|
169
186
|
created_at: z.ZodString;
|
|
170
187
|
expires_at: z.ZodString;
|
|
171
188
|
is_current: z.ZodBoolean;
|
|
@@ -271,7 +288,7 @@ export declare const account_token_list_action_spec: {
|
|
|
271
288
|
output: z.ZodObject<{
|
|
272
289
|
tokens: z.ZodArray<z.ZodObject<{
|
|
273
290
|
id: z.ZodString;
|
|
274
|
-
account_id: z.
|
|
291
|
+
account_id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string>>;
|
|
275
292
|
name: z.ZodString;
|
|
276
293
|
expires_at: z.ZodNullable<z.ZodString>;
|
|
277
294
|
last_used_at: z.ZodNullable<z.ZodString>;
|
|
@@ -293,13 +310,23 @@ export declare const account_token_revoke_action_spec: {
|
|
|
293
310
|
credential_types: string[];
|
|
294
311
|
};
|
|
295
312
|
side_effects: true;
|
|
296
|
-
input:
|
|
297
|
-
token_id:
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
313
|
+
input: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
314
|
+
token_id: string;
|
|
315
|
+
}, {
|
|
316
|
+
token_id: string;
|
|
317
|
+
}, "object", {
|
|
318
|
+
token_id: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
319
|
+
}>;
|
|
320
|
+
output: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
321
|
+
ok: true;
|
|
322
|
+
revoked: boolean;
|
|
323
|
+
}, {
|
|
324
|
+
ok: true;
|
|
325
|
+
revoked: boolean;
|
|
326
|
+
}, "object", {
|
|
327
|
+
ok: import("@fuzdev/fuz_schema/schema.ts").Schema<true, true, "literal", true>;
|
|
328
|
+
revoked: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
329
|
+
}>;
|
|
303
330
|
async: true;
|
|
304
331
|
description: string;
|
|
305
332
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"account_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAON,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAMtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAW3E,6EAA6E;AAC7E,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE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string } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
13
|
import { bounded_string } from '../primitive_schemas.js';
|
|
12
14
|
import { TokenScopeInput } from './token_scope.js';
|
|
13
15
|
import { TokenLifetimeInput } from './token_lifetime.js';
|
|
14
16
|
import { AuthSessionJson, ClientApiTokenJson, SessionAccountJson, SessionId } from './account_schema.js';
|
|
15
|
-
import { ApiTokenId } from './api_token.js';
|
|
17
|
+
import { API_TOKEN_ID_REGEX, ApiTokenId } from './api_token.js';
|
|
16
18
|
// -- Input/output schemas ---------------------------------------------------
|
|
17
19
|
/** Input for `account_verify`. No parameters — the caller is the subject. */
|
|
18
20
|
export const VerifyInput = z.void();
|
|
@@ -107,14 +109,22 @@ export const TokenListInput = z.void();
|
|
|
107
109
|
export const TokenListOutput = z.strictObject({
|
|
108
110
|
tokens: z.array(ClientApiTokenJson)
|
|
109
111
|
});
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Input for `account_token_revoke`, a `@fuzdev/fuz_schema` schema. Its
|
|
114
|
+
* `token_id` is `ApiTokenId`'s check written inline, as `ApiTokenId` is Zod.
|
|
115
|
+
*/
|
|
116
|
+
export const TokenRevokeInput = object({
|
|
117
|
+
token_id: meta(pipe(string, regex(API_TOKEN_ID_REGEX)), {
|
|
118
|
+
description: 'Public API token id (e.g. `tok_<12 chars>`).'
|
|
119
|
+
})
|
|
113
120
|
});
|
|
114
|
-
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Output for `account_token_revoke`, a `@fuzdev/fuz_schema` schema.
|
|
123
|
+
* `revoked` is `false` for IDOR misses.
|
|
124
|
+
*/
|
|
125
|
+
export const TokenRevokeOutput = object({
|
|
126
|
+
ok: literal(true),
|
|
127
|
+
revoked: boolean
|
|
118
128
|
});
|
|
119
129
|
// -- Action specs -----------------------------------------------------------
|
|
120
130
|
export const account_verify_action_spec = {
|
|
@@ -19,24 +19,24 @@ export type AccountStatusInput = z.infer<typeof AccountStatusInput>;
|
|
|
19
19
|
/** Output for `GET /api/account/status`. */
|
|
20
20
|
export declare const AccountStatusOutput: z.ZodObject<{
|
|
21
21
|
account: z.ZodObject<{
|
|
22
|
-
id: z.
|
|
22
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
23
23
|
username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
24
24
|
email: z.ZodNullable<z.ZodString>;
|
|
25
25
|
email_verified: z.ZodBoolean;
|
|
26
26
|
created_at: z.ZodString;
|
|
27
27
|
}, z.core.$strict>;
|
|
28
28
|
actor: z.ZodNullable<z.ZodObject<{
|
|
29
|
-
id: z.
|
|
29
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
30
30
|
name: z.ZodString;
|
|
31
31
|
}, z.core.$strict>>;
|
|
32
32
|
role_grants: z.ZodArray<z.ZodObject<{
|
|
33
|
-
id: z.
|
|
33
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
34
34
|
role: z.ZodString;
|
|
35
35
|
scope_kind: z.ZodNullable<z.ZodString>;
|
|
36
|
-
scope_id: z.ZodNullable<z.
|
|
36
|
+
scope_id: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
|
|
37
37
|
created_at: z.ZodString;
|
|
38
38
|
expires_at: z.ZodNullable<z.ZodString>;
|
|
39
|
-
granted_by: z.ZodNullable<z.
|
|
39
|
+
granted_by: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
|
|
40
40
|
}, z.core.$strict>>;
|
|
41
41
|
}, z.core.$strict>;
|
|
42
42
|
export type AccountStatusOutput = z.infer<typeof AccountStatusOutput>;
|
|
@@ -116,24 +116,24 @@ export declare const account_status_route_shape: {
|
|
|
116
116
|
input: z.ZodNull;
|
|
117
117
|
output: z.ZodObject<{
|
|
118
118
|
account: z.ZodObject<{
|
|
119
|
-
id: z.
|
|
119
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
120
120
|
username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
121
121
|
email: z.ZodNullable<z.ZodString>;
|
|
122
122
|
email_verified: z.ZodBoolean;
|
|
123
123
|
created_at: z.ZodString;
|
|
124
124
|
}, z.core.$strict>;
|
|
125
125
|
actor: z.ZodNullable<z.ZodObject<{
|
|
126
|
-
id: z.
|
|
126
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
127
127
|
name: z.ZodString;
|
|
128
128
|
}, z.core.$strict>>;
|
|
129
129
|
role_grants: z.ZodArray<z.ZodObject<{
|
|
130
|
-
id: z.
|
|
130
|
+
id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
|
|
131
131
|
role: z.ZodString;
|
|
132
132
|
scope_kind: z.ZodNullable<z.ZodString>;
|
|
133
|
-
scope_id: z.ZodNullable<z.
|
|
133
|
+
scope_id: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
|
|
134
134
|
created_at: z.ZodString;
|
|
135
135
|
expires_at: z.ZodNullable<z.ZodString>;
|
|
136
|
-
granted_by: z.ZodNullable<z.
|
|
136
|
+
granted_by: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
|
|
137
137
|
}, z.core.$strict>>;
|
|
138
138
|
}, z.core.$strict>;
|
|
139
139
|
errors: {
|