@fuzdev/fuz_app 0.32.0 → 0.34.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/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +6 -1
- package/dist/testing/CLAUDE.md +26 -10
- package/dist/testing/admin_integration.d.ts +21 -9
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +152 -148
- package/dist/testing/app_server.d.ts +10 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/audit_completeness.d.ts +8 -4
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +40 -45
- package/dist/testing/integration.d.ts +16 -6
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +202 -129
- package/dist/testing/rate_limiting.d.ts +13 -4
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +9 -3
- package/dist/testing/rpc_helpers.d.ts +29 -0
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +20 -0
- package/dist/testing/rpc_round_trip.d.ts +16 -5
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +11 -5
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +25 -1
- package/dist/testing/sse_round_trip.d.ts +13 -5
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +11 -5
- package/dist/testing/standard.d.ts +7 -2
- package/dist/testing/standard.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,O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I,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CA6PtF,CAAC"}
|
|
@@ -163,7 +163,12 @@ export const create_rpc_endpoint = (options) => {
|
|
|
163
163
|
return c.json(error, jsonrpc_error_code_to_http_status(auth_error.code));
|
|
164
164
|
}
|
|
165
165
|
// step 4: validate params
|
|
166
|
-
|
|
166
|
+
// Missing `params` on the envelope maps to `null` for `z.null()` input
|
|
167
|
+
// schemas and `{}` for object inputs — matches HTTP's "empty body = empty
|
|
168
|
+
// object" convention so callers of all-optional-object RPC methods can
|
|
169
|
+
// omit `params` on the wire (JSON-RPC envelope still serializes without
|
|
170
|
+
// a `params` field; no protocol-level change).
|
|
171
|
+
const params = raw_params ?? (is_null_schema(action.spec.input) ? null : {});
|
|
167
172
|
const parse_result = action.spec.input.safeParse(params);
|
|
168
173
|
if (!parse_result.success) {
|
|
169
174
|
const error = jsonrpc_error_response(id, jsonrpc_error_messages.invalid_params('invalid params', {
|
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -538,13 +538,25 @@ lifecycle (via `permit_offer_create` + `permit_revoke` RPC flows —
|
|
|
538
538
|
**not** REST; see `../auth/CLAUDE.md` for `permit_offer_action_specs.ts` + `permit_offer_actions.ts`), session / token management, audit log reads (RPC),
|
|
539
539
|
admin-to-admin isolation, error coverage, response schema validation.
|
|
540
540
|
|
|
541
|
-
Required options: `{session_options, create_route_specs, roles: RoleSchemaResult, rpc_endpoints:
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
541
|
+
Required options: `{session_options, create_route_specs, roles: RoleSchemaResult, rpc_endpoints: RpcEndpointsSuiteOption, admin_prefix?, app_options?, db_factories?}`.
|
|
542
|
+
|
|
543
|
+
`rpc_endpoints` is `Array<RpcEndpointSpec> | ((ctx: AppServerContext) => Array<RpcEndpointSpec>)` —
|
|
544
|
+
the same `RpcEndpointsSuiteOption` union every DB-backed suite accepts
|
|
545
|
+
(`integration`, `admin_integration`, `audit_completeness`, `rate_limiting`,
|
|
546
|
+
`rpc_round_trip`, `sse_round_trip`). Prefer the factory form: it forwards
|
|
547
|
+
raw to `app_options.rpc_endpoints` so `create_app_server` resolves it per-test
|
|
548
|
+
with the real ctx — the only way action handlers can close over
|
|
549
|
+
`ctx.deps` / `ctx.app_settings` (e.g. `create_admin_rpc_actions(ctx.deps,
|
|
550
|
+
{app_settings: ctx.app_settings})`). Factory must return the same endpoint
|
|
551
|
+
`path` regardless of ctx — `resolve_rpc_endpoints_for_setup` invokes it
|
|
552
|
+
once with a stub ctx for path lookup and `create_app_server` invokes it
|
|
553
|
+
again per-test for live dispatch.
|
|
554
|
+
|
|
555
|
+
**Hard-fails via `require_rpc_endpoint_path`** at setup time when
|
|
556
|
+
`rpc_endpoints` is empty — admin permit grant/revoke plus session/token
|
|
557
|
+
revoke-all plus audit-log list/history are all RPC-only since the
|
|
558
|
+
2026-04-22 migration. A confusing test failure mid-suite is worse than a
|
|
559
|
+
clear setup error.
|
|
548
560
|
|
|
549
561
|
Error-coverage scope is narrowed to the REST suffixes still on the
|
|
550
562
|
admin surface (`/sessions`, `/audit-log/stream`); the RPC surface is
|
|
@@ -569,9 +581,11 @@ provide the filesystem token state; covered separately in
|
|
|
569
581
|
|
|
570
582
|
Convenience wrapper: always runs `describe_standard_integration_tests`;
|
|
571
583
|
runs `describe_standard_admin_integration_tests` only when `roles` is
|
|
572
|
-
provided. `rpc_endpoints` is a required field on
|
|
573
|
-
— the admin suite's requirement is enforced at the
|
|
574
|
-
missing `rpc_endpoints` is a compile error rather than a
|
|
584
|
+
provided. `rpc_endpoints: RpcEndpointsSuiteOption` is a required field on
|
|
585
|
+
`StandardTestOptions` — the admin suite's requirement is enforced at the
|
|
586
|
+
type level, so a missing `rpc_endpoints` is a compile error rather than a
|
|
587
|
+
runtime throw. Round-trips the union through unchanged so consumers can
|
|
588
|
+
pass either an eager array or the factory form.
|
|
575
589
|
|
|
576
590
|
## RPC helpers
|
|
577
591
|
|
|
@@ -613,6 +627,8 @@ Registry lookups:
|
|
|
613
627
|
- `find_rpc_action(rpc_endpoints, method)` — endpoint path + `RpcAction` source.
|
|
614
628
|
- `find_rpc_method(rpc_endpoints, method)` — surface-shape lookup over `AppSurfaceRpcEndpoint[]` (generated by `generate_app_surface`).
|
|
615
629
|
- `require_rpc_endpoint_path(rpc_endpoints)` — returns the single endpoint path; throws descriptively on zero or multiple endpoints. Used by the admin/audit suites to hard-fail at setup.
|
|
630
|
+
- `RpcEndpointsSuiteOption` — union `Array<RpcEndpointSpec> | ((ctx: AppServerContext) => Array<RpcEndpointSpec>)` accepted by every DB-backed suite's `rpc_endpoints` field.
|
|
631
|
+
- `resolve_rpc_endpoints_for_setup(rpc_endpoints, session_options)` — resolves the union to an array for setup-time inspection (path lookup, `find_rpc_action` presence checks). Factory form is invoked once with a stub `AppServerContext`; the produced actions are discarded because `create_app_server` invokes the factory a second time per-test with its real ctx. Safe when the factory is pure wrt endpoint `path` and action `spec.method` list.
|
|
616
632
|
|
|
617
633
|
### `rpc_attack_surface.ts` — `describe_rpc_attack_surface_tests`
|
|
618
634
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
2
|
import type { SessionOptions } from '../auth/session_cookie.js';
|
|
3
|
-
import type { AppServerContext
|
|
3
|
+
import type { AppServerContext } from '../server/app_server.js';
|
|
4
4
|
import type { RouteSpec } from '../http/route_spec.js';
|
|
5
5
|
import { type RoleSchemaResult } from '../auth/role_schema.js';
|
|
6
|
+
import { type SuiteAppOptions } from './app_server.js';
|
|
6
7
|
import { type DbFactory } from './db.js';
|
|
7
|
-
import type
|
|
8
|
+
import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
|
|
8
9
|
/**
|
|
9
10
|
* Configuration for `describe_standard_admin_integration_tests`.
|
|
10
11
|
*/
|
|
@@ -18,17 +19,26 @@ export interface StandardAdminIntegrationTestOptions {
|
|
|
18
19
|
/**
|
|
19
20
|
* RPC endpoint specs — the source `RpcAction` arrays. Required; permit
|
|
20
21
|
* grant/revoke are RPC-only and the suite hard-fails without them.
|
|
22
|
+
*
|
|
23
|
+
* Accepts either an array (eager) or a factory
|
|
24
|
+
* `(ctx: AppServerContext) => Array<RpcEndpointSpec>` — the factory form
|
|
25
|
+
* is required when action handlers must close over the per-test
|
|
26
|
+
* `ctx.app_settings` / `ctx.deps` (e.g. the canonical
|
|
27
|
+
* `create_admin_rpc_actions(ctx.deps, {app_settings: ctx.app_settings})`
|
|
28
|
+
* pattern). The factory must return the same endpoint `path` regardless
|
|
29
|
+
* of ctx — it is invoked once at setup with a stub ctx for path lookup
|
|
30
|
+
* and again per-test by `create_app_server` for live dispatch.
|
|
21
31
|
*/
|
|
22
|
-
rpc_endpoints:
|
|
32
|
+
rpc_endpoints: RpcEndpointsSuiteOption;
|
|
23
33
|
/**
|
|
24
34
|
* Path prefix where admin routes are mounted (e.g., `'/api/admin'`).
|
|
25
|
-
* Used by the
|
|
26
|
-
* avoiding app-specific admin-gated routes that may use
|
|
27
|
-
* Default `'/api/admin'`.
|
|
35
|
+
* Used by the 401/403 error-coverage probe to scope to fuz_app admin
|
|
36
|
+
* routes only, avoiding app-specific admin-gated routes that may use
|
|
37
|
+
* stub deps. Default `'/api/admin'`.
|
|
28
38
|
*/
|
|
29
39
|
admin_prefix?: string;
|
|
30
40
|
/** Optional overrides for `AppServerOptions`. */
|
|
31
|
-
app_options?:
|
|
41
|
+
app_options?: SuiteAppOptions;
|
|
32
42
|
/**
|
|
33
43
|
* Database factories to run tests against. Default: pglite only.
|
|
34
44
|
* Pass consumer factories (e.g. `[pglite_factory, pg_factory]`) to also test against PostgreSQL.
|
|
@@ -39,8 +49,10 @@ export interface StandardAdminIntegrationTestOptions {
|
|
|
39
49
|
* Standard admin integration test suite for fuz_app admin routes.
|
|
40
50
|
*
|
|
41
51
|
* Exercises account listing, permit grant/revoke (via RPC), session
|
|
42
|
-
* management, token management, audit log
|
|
43
|
-
* and
|
|
52
|
+
* management, token management, audit log reads, admin-to-admin
|
|
53
|
+
* isolation, and 401/403 error-coverage on the admin REST surface.
|
|
54
|
+
* Output-schema conformance is not in scope — see the module docstring
|
|
55
|
+
* for the suites that cover it.
|
|
44
56
|
*
|
|
45
57
|
* @param options - session config, route factory, role schema, RPC endpoints
|
|
46
58
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"admin_integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA+B7B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAA0B,KAAK,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAA6C,KAAK,eAAe,EAAC,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AASjB,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAqB1B;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,4GAA4G;IAC5G,KAAK,EAAE,gBAAgB,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAChC;AAgCD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,mCAAmC,KAC1C,IAu0BF,CAAC"}
|