@fuzdev/fuz_app 0.169.0 → 0.171.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 +19 -21
- package/dist/actions/action_codegen.d.ts +27 -18
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +90 -90
- package/dist/actions/action_event.d.ts +0 -8
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -6
- package/dist/actions/action_event_data.d.ts +4 -4
- package/dist/actions/action_rpc.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +6 -7
- package/dist/actions/action_spec.d.ts +8 -10
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +1 -1
- 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 +2 -2
- package/dist/actions/broadcast_api.js +4 -4
- package/dist/actions/compile_action_registry.d.ts +6 -7
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/compile_action_registry.js +8 -9
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +3 -2
- package/dist/actions/perform_action.d.ts +6 -6
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +11 -10
- package/dist/actions/socket.svelte.d.ts +1 -1
- package/dist/actions/socket.svelte.js +2 -2
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +2 -1
- package/dist/auth/CLAUDE.md +11 -11
- package/dist/auth/admin_action_specs.d.ts +24 -24
- package/dist/auth/audit_emitter.d.ts +6 -7
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +11 -22
- package/dist/auth/audit_log_ddl.d.ts +1 -1
- package/dist/auth/audit_log_ddl.js +1 -1
- package/dist/auth/audit_log_queries.d.ts +0 -13
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +3 -3
- package/dist/auth/audit_log_schema.d.ts +14 -15
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +1 -1
- package/dist/auth/auth_ddl.d.ts +1 -1
- package/dist/auth/auth_ddl.js +1 -1
- package/dist/auth/cell_action_specs.d.ts +54 -54
- package/dist/auth/cell_actions.d.ts +2 -2
- package/dist/auth/cell_actions.js +5 -5
- package/dist/auth/middleware.d.ts +6 -2
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +14 -2
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +7 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +6 -6
- package/dist/auth/role_grant_offer_ddl.d.ts +1 -1
- package/dist/auth/role_grant_offer_ddl.js +1 -1
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +2 -3
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/env/env_schemas.d.ts +1 -2
- package/dist/env/env_schemas.d.ts.map +1 -1
- package/dist/env/env_schemas.js +3 -4
- package/dist/http/CLAUDE.md +30 -31
- package/dist/http/auth_shape.d.ts +14 -32
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +14 -49
- package/dist/http/error_schemas.d.ts +18 -18
- package/dist/http/json_text.d.ts +53 -0
- package/dist/http/json_text.d.ts.map +1 -0
- package/dist/http/json_text.js +152 -0
- package/dist/http/jsonrpc_helpers.js +1 -1
- package/dist/http/route_error_check.d.ts +2 -2
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +2 -3
- package/dist/http/route_errors.d.ts +4 -4
- package/dist/http/route_errors.d.ts.map +1 -1
- package/dist/http/route_errors.js +0 -13
- package/dist/http/route_result.d.ts +2 -1
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_spec.d.ts +34 -37
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +31 -31
- package/dist/http/schema_helpers.d.ts +77 -68
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +54 -77
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +6 -8
- package/dist/primitive_schemas.d.ts +9 -17
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +9 -17
- package/dist/realtime/sse.d.ts +3 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +2 -2
- package/dist/schema_issues.d.ts +39 -147
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +39 -352
- package/dist/schema_meta.d.ts +63 -136
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +37 -184
- package/dist/sensitivity.d.ts +3 -5
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -5
- package/dist/testing/CLAUDE.md +20 -22
- package/dist/testing/adversarial_headers.js +2 -2
- package/dist/testing/adversarial_input_cases.d.ts +19 -18
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +31 -46
- package/dist/testing/assertions.d.ts +2 -2
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +3 -3
- package/dist/testing/cross_backend/account_lifecycle.js +2 -2
- package/dist/testing/cross_backend/action_manifest.d.ts +10 -9
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +4 -3
- package/dist/testing/cross_backend/cell_crud.js +1 -1
- package/dist/testing/cross_backend/conformance_rpc_auth.d.ts +0 -62
- package/dist/testing/cross_backend/conformance_rpc_auth.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +3 -3
- package/dist/testing/cross_backend/cross_rpc.d.ts +3 -4
- package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
- package/dist/testing/cross_backend/cross_rpc.js +4 -4
- package/dist/testing/cross_backend/differential.js +2 -2
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +16 -11
- package/dist/testing/cross_backend/origin_conformance.d.ts +9 -9
- package/dist/testing/cross_backend/query_shape.js +1 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/setup.d.ts +25 -3
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +4 -4
- package/dist/testing/cross_backend/sse_round_trip.js +2 -2
- package/dist/testing/cross_backend/testing_origin_check.d.ts +4 -4
- package/dist/testing/cross_backend/token_lifetime.js +3 -3
- package/dist/testing/cross_backend/wire_shapes.js +1 -1
- package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.js +8 -0
- package/dist/testing/cross_backend/ws_round_trip.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +1 -1
- package/dist/testing/integration.js +2 -2
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -2
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +2 -2
- package/dist/testing/rpc_attack_surface.js +1 -1
- package/dist/testing/rpc_envelope_cases.d.ts +10 -3
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +22 -1
- package/dist/testing/rpc_helpers.d.ts +12 -14
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +9 -10
- package/dist/testing/schema_generators.d.ts +67 -60
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +154 -159
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/surface_invariants.d.ts +1 -1
- package/dist/testing/surface_invariants.js +1 -1
- package/dist/ui/form_state.svelte.d.ts +1 -1
- package/dist/ui/form_state.svelte.js +1 -1
- package/package.json +5 -7
- package/dist/zod.d.ts +0 -116
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -218
- package/dist/zod_schemas.d.ts +0 -100
- package/dist/zod_schemas.d.ts.map +0 -1
- package/dist/zod_schemas.js +0 -157
|
@@ -5,7 +5,7 @@ import '../assert_dev_env.js';
|
|
|
5
5
|
* A field can carry the right value on both backends and still be a parity
|
|
6
6
|
* defect if the two serialize it differently — a millisecond
|
|
7
7
|
* `2026-05-17T12:34:56.789Z` and a second-precision `2026-05-17T12:34:56Z`
|
|
8
|
-
* both parse as the same instant, so a
|
|
8
|
+
* both parse as the same instant, so a `Timestamp` check and an
|
|
9
9
|
* `assert.ok(value)` pass on either. These helpers pin the bytes.
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws_envelope.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_envelope.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8C9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AACzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ws_envelope.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_envelope.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8C9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AACzD,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAe1E,4DAA4D;AAC5D,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IACnE,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;CAC3C;AA+ED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,0BAA0B,KAAG,IAoFtF,CAAC"}
|
|
@@ -43,6 +43,7 @@ import { is_response_for } from '../transports/ws_client.js';
|
|
|
43
43
|
import { test_if } from './capabilities.js';
|
|
44
44
|
import { open_session_ws } from './ws_endpoint.js';
|
|
45
45
|
import { create_holding_peer_ping_responder } from './ws_inbound_dispatch.js';
|
|
46
|
+
import { SERDE_REFUSED_PARAMS_JSON } from '../rpc_envelope_cases.js';
|
|
46
47
|
const JSONRPC_VERSION = '2.0';
|
|
47
48
|
const PARSE_ERROR = -32700;
|
|
48
49
|
const INVALID_REQUEST = -32600;
|
|
@@ -72,6 +73,13 @@ const REFUSED_FRAME_CASES = [
|
|
|
72
73
|
frame: { text: '{"jsonrpc": "2.0", "id": 1,' },
|
|
73
74
|
code: PARSE_ERROR
|
|
74
75
|
},
|
|
76
|
+
...SERDE_REFUSED_PARAMS_JSON.map(([label, params_json]) => ({
|
|
77
|
+
name: `a frame holding ${label}`,
|
|
78
|
+
frame: {
|
|
79
|
+
text: `{"jsonrpc":"2.0","id":1,"method":"${HEARTBEAT_METHOD}","params":${params_json}}`
|
|
80
|
+
},
|
|
81
|
+
code: PARSE_ERROR
|
|
82
|
+
})),
|
|
75
83
|
{ name: 'a scalar frame', frame: { json: 5 }, code: INVALID_REQUEST },
|
|
76
84
|
{ name: 'a bare string frame', frame: { json: HEARTBEAT_METHOD }, code: INVALID_REQUEST },
|
|
77
85
|
{
|
|
@@ -184,7 +184,7 @@ export const describe_cross_process_ws_tests = (options) => {
|
|
|
184
184
|
client.destroy();
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
|
-
// `heartbeat` is parameterless on both spines (`
|
|
187
|
+
// `heartbeat` is parameterless on both spines (`s.void` /
|
|
188
188
|
// `require_void_params`): the empty shapes are the no-arg call, and a
|
|
189
189
|
// declared param is `invalid_params`, not ignored.
|
|
190
190
|
test_if(capabilities.ws, 'heartbeat admits only the parameterless shapes', async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_exposure.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"data_exposure.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAyB7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAahC,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAIvE;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,OAAO,KAAG,GAAG,CAAC,MAAM,CAmC9E,CAAC;AA0HF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yCAAyC,GACrD,gBAAgB,cAAc,EAC9B,mBAAkB,aAAa,CAAC,MAAM,CAA6B,EACnE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAOF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wCAAwC,GACpD,gBAAgB,cAAc,EAC9B,oBAAmB,aAAa,CAAC,MAAM,CAA8B,EACrE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAYF,CAAC;AAIF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IAiM/E,CAAC"}
|
|
@@ -120,7 +120,7 @@ const collect_output_schema_entries = (surface_source) => {
|
|
|
120
120
|
elevated: endpoint_elevated
|
|
121
121
|
};
|
|
122
122
|
if (spec.kind === 'remote_notification') {
|
|
123
|
-
// its `output` is `
|
|
123
|
+
// its `output` is `s.void`: the payload is its params
|
|
124
124
|
entries.push(params_entry);
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
@@ -268,7 +268,7 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
268
268
|
assert.strictEqual(wrong_pw_body.error, no_user_body.error, 'Error codes must be identical');
|
|
269
269
|
});
|
|
270
270
|
// Wire-shape gate: the successful `POST /login` body must strict-parse
|
|
271
|
-
// against `LoginOutput` (`{ok: true}`).
|
|
271
|
+
// against `LoginOutput` (`{ok: true}`). A strict `object` rejects any
|
|
272
272
|
// extra field, so a backend leaking `username` / `account_id` (the
|
|
273
273
|
// Rust spine's old shape) fails here on either impl.
|
|
274
274
|
test('successful login body strict-parses against LoginOutput', async () => {
|
|
@@ -296,7 +296,7 @@ export const describe_standard_integration_tests = (options) => {
|
|
|
296
296
|
// Wire-shape gate: the authenticated `GET /api/account/status` body
|
|
297
297
|
// must strict-parse against `AccountStatusOutput` — the full shape
|
|
298
298
|
// `{account: SessionAccountJson, actor: ActorSummaryJson | null,
|
|
299
|
-
// role_grants: RoleGrantSummaryJson[]}`.
|
|
299
|
+
// role_grants: RoleGrantSummaryJson[]}`. A strict `object` rejects any
|
|
300
300
|
// extra or missing field on `account` / `actor` / each role_grant, so
|
|
301
301
|
// a backend returning the old narrow shape (Rust's `{account:{id,
|
|
302
302
|
// username}, role_grants:[{role}]}`) fails here on either impl. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAW7B,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAyBnD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,QAAQ,MAAM,EACd,MAAM,MAAM,KACV,SAAS,GAAG,SAcd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,iFAO3B,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,QAAQ,mBAAmB,EAC3B,QAAQ,WAAW,KACjB,SAAS,G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AAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxF;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEtF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,SAAS,KAAG,aAKrD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,WAAW,aAAa,EACxB,QAAQ,oBAAoB,EAC5B,gBAAgB,WAAW,EAC3B,eAAe,WAAW,KACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAavB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS,EACf,QAAQ,oBAAoB,EAC5B,gBAAgB,WAAW,EAC3B,eAAe,WAAW,KACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CACoE,CAAC;AAE7F;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GACzC,WAAW,aAAa,EACxB,cAAc,OAAO,KACnB,OAAiD,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,MAAM,EAAE,QAAQ,OAAO,KAAG,OACQ,CAAC"}
|
|
@@ -5,13 +5,13 @@ import './assert_dev_env.js';
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { assert } from 'vitest';
|
|
8
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
8
9
|
import { is_null_schema } from '../http/schema_helpers.js';
|
|
9
10
|
import { get_route_error_map } from '../http/route_errors.js';
|
|
10
11
|
import { is_public_auth } from '../http/auth_shape.js';
|
|
11
12
|
import { ERROR_AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
|
|
12
13
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
13
14
|
import { create_test_request_headers } from './test_origin.js';
|
|
14
|
-
import { parse_any } from '../schema_issues.js';
|
|
15
15
|
import { decode_route_path, find_mounted_route, is_json_response, to_mounted_routes } from '../http/route_error_check.js';
|
|
16
16
|
import { assert_error_response_declared } from './assertions.js';
|
|
17
17
|
/** Each spec list's compiled routes, so a list is compiled once. */
|
|
@@ -145,7 +145,7 @@ export const assert_response_matches_spec = async (route_specs, method, path, re
|
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
if (response.ok) {
|
|
148
|
-
const result =
|
|
148
|
+
const result = parse(spec.output, body);
|
|
149
149
|
if (!result.ok) {
|
|
150
150
|
throw new Error(`Output schema mismatch for ${method} ${path} (${response.status}): ${JSON.stringify(result.issues)}`);
|
|
151
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,EAAE,EAA0B,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,EAAE,EAA0B,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAqB5B,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAOtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAoB7D,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACrC,wBAAwB;IACx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,CAAC;IACtD,0BAA0B,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;CACrD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC,GAC5C,UAAU,0BAA0B,KAClC,sBA4DF,CAAC"}
|
|
@@ -16,6 +16,7 @@ import './assert_dev_env.js';
|
|
|
16
16
|
import { vi, test, assert, describe } from 'vitest';
|
|
17
17
|
import { Hono } from 'hono';
|
|
18
18
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
19
|
+
import { parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
19
20
|
import { create_bearer_auth_middleware } from '../auth/bearer_auth.js';
|
|
20
21
|
import { AUTH_MIDDLEWARE_PATH, ORIGIN_MIDDLEWARE_PATH } from '../auth/middleware.js';
|
|
21
22
|
import { query_validate_api_token } from '../auth/api_token_queries.js';
|
|
@@ -28,7 +29,6 @@ import { REQUEST_CONTEXT_KEY } from '../auth/request_context.js';
|
|
|
28
29
|
import { RESOLVED_AUTH_KEY, TEST_CONTEXT_PRESET, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
|
|
29
30
|
import { get_resolved_auth } from '../auth/resolved_auth.js';
|
|
30
31
|
import { create_test_resolved_auth } from './resolved_auth.js';
|
|
31
|
-
import { parse_any } from '../schema_issues.js';
|
|
32
32
|
// Mock the query modules so test cases can control return values.
|
|
33
33
|
// vi.mock() is hoisted by vitest, so these run before any imports resolve.
|
|
34
34
|
vi.mock('../auth/api_token_queries.js', () => ({
|
|
@@ -177,7 +177,7 @@ export const describe_bearer_auth_cases = (suite_name, cases) => {
|
|
|
177
177
|
if (tc.expected_error) {
|
|
178
178
|
assert.strictEqual(body.error, tc.expected_error.code);
|
|
179
179
|
assert.strictEqual(res.status, tc.expected_error.status);
|
|
180
|
-
const parsed =
|
|
180
|
+
const parsed = parse(tc.expected_error.schema, body);
|
|
181
181
|
assert.ok(parsed.ok, `error body fails its schema: ${JSON.stringify(body)}`);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
@@ -221,7 +221,7 @@ const describe_rpc_adversarial_params = (options) => {
|
|
|
221
221
|
continue;
|
|
222
222
|
describe(endpoint.path, () => {
|
|
223
223
|
for (const method of methods_with_input) {
|
|
224
|
-
// look up the source RpcAction for the
|
|
224
|
+
// look up the source RpcAction for the input schema
|
|
225
225
|
const action = find_rpc_action(rpc_endpoint_specs, endpoint.path, method.name);
|
|
226
226
|
if (!action) {
|
|
227
227
|
test(`${method.name} — missing RpcAction source spec`, () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
+
import type { AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
2
3
|
import type { AppSurfaceRpcEndpoint, AppSurfaceRpcMethod } from '../http/surface.js';
|
|
3
4
|
import type { JsonrpcErrorCode, JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
4
|
-
import type { ValidationSchema } from '../schema_issues.js';
|
|
5
5
|
import { type InputTestCase, type InputTestCaseOptions } from './adversarial_input_cases.js';
|
|
6
6
|
/** The request id every envelope case sends where it sends one. */
|
|
7
7
|
export declare const RPC_ENVELOPE_PROBE_ID = "envelope_probe";
|
|
@@ -48,6 +48,13 @@ export interface RpcEnvelopeCaseOptions {
|
|
|
48
48
|
* what a `GET` `?params=` can carry that no input schema admits.
|
|
49
49
|
*/
|
|
50
50
|
export declare const RPC_NON_OBJECT_PARAMS: ReadonlyArray<string>;
|
|
51
|
+
/**
|
|
52
|
+
* JSON object texts holding what `serde_json` refuses and `JSON.parse`
|
|
53
|
+
* accepts — an escaped lone surrogate, a number out of `f64` range, nesting
|
|
54
|
+
* 128 deep — each with a label. Both spines refuse them as invalid JSON
|
|
55
|
+
* (`parse_json_text`, `@fuzdev/fuz_app/http/json_text.ts`).
|
|
56
|
+
*/
|
|
57
|
+
export declare const SERDE_REFUSED_PARAMS_JSON: ReadonlyArray<readonly [label: string, json: string]>;
|
|
51
58
|
/** The `data.reason` the dispatchers answer a `GET` of a `side_effects` method with. */
|
|
52
59
|
export declare const rpc_get_side_effects_reason: (method: string) => string;
|
|
53
60
|
/**
|
|
@@ -104,11 +111,11 @@ export declare const assert_rpc_envelope_refusal: (status: number, body: unknown
|
|
|
104
111
|
* (`invalid_request`) before params validation runs, and the envelope cases
|
|
105
112
|
* cover it. Every case returned owes 400 `invalid_params`.
|
|
106
113
|
*
|
|
107
|
-
* @param input - the method's input schema
|
|
114
|
+
* @param input - the method's input schema
|
|
108
115
|
* @param options - a valid base `params` to seed the cases (`InputTestCaseOptions.base`),
|
|
109
116
|
* and the method name for error messages
|
|
110
117
|
* @returns the cases, each a `params` object
|
|
111
118
|
* @throws Error if the base `params`, seeded or generated, fails the input schema
|
|
112
119
|
*/
|
|
113
|
-
export declare const generate_rpc_params_test_cases: (input:
|
|
120
|
+
export declare const generate_rpc_params_test_cases: (input: AnySchema, options?: InputTestCaseOptions) => Array<InputTestCase>;
|
|
114
121
|
//# sourceMappingURL=rpc_envelope_cases.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_envelope_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_envelope_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc_envelope_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_envelope_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAe7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK7E,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,MAAM,8BAA8B,CAAC;AAItC,mEAAmE;AACnE,eAAO,M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AO,MAAM,yBAAyB,GACrC,UAAU,qBAAqB,EAC/B,UAAS,sBAA2B,KAClC,KAAK,CAAC,eAAe,CAwLvB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,eAAe,MAAM,EACrB,GAAG,eAAe,EAClB,UAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KAClC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAUgD,CAAC;AAEpF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACvC,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,GAAG,eAAe,KAChB,IAUF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,SAAS,EAChB,UAAU,oBAAoB,KAC5B,KAAK,CAAC,aAAa,CAGpB,CAAC"}
|
|
@@ -26,6 +26,21 @@ export const RPC_ENVELOPE_PROBE_ID = 'envelope_probe';
|
|
|
26
26
|
* what a `GET` `?params=` can carry that no input schema admits.
|
|
27
27
|
*/
|
|
28
28
|
export const RPC_NON_OBJECT_PARAMS = ['42', '[1]', '"x"', 'true'];
|
|
29
|
+
const BACKSLASH = String.fromCharCode(92);
|
|
30
|
+
/**
|
|
31
|
+
* JSON object texts holding what `serde_json` refuses and `JSON.parse`
|
|
32
|
+
* accepts — an escaped lone surrogate, a number out of `f64` range, nesting
|
|
33
|
+
* 128 deep — each with a label. Both spines refuse them as invalid JSON
|
|
34
|
+
* (`parse_json_text`, `@fuzdev/fuz_app/http/json_text.ts`).
|
|
35
|
+
*/
|
|
36
|
+
export const SERDE_REFUSED_PARAMS_JSON = [
|
|
37
|
+
['a lone surrogate escape', `{"x":"${BACKSLASH}ud800"}`],
|
|
38
|
+
['a lone surrogate escape in a key', `{"${BACKSLASH}udc00":1}`],
|
|
39
|
+
['a number out of f64 range', '{"x":1e400}'],
|
|
40
|
+
['nesting 128 deep', `{"x":${'['.repeat(127)}${']'.repeat(127)}}`],
|
|
41
|
+
// `JSON.parse` keeps the last key, so only reading the text sees the first
|
|
42
|
+
['a lone surrogate escape under a duplicated key', `{"x":"${BACKSLASH}ud800","x":1}`]
|
|
43
|
+
];
|
|
29
44
|
/** The `data.reason` the dispatchers answer a `GET` of a `side_effects` method with. */
|
|
30
45
|
export const rpc_get_side_effects_reason = (method) => `method '${method}' has side effects and must use POST`;
|
|
31
46
|
/**
|
|
@@ -77,6 +92,12 @@ export const create_rpc_envelope_cases = (endpoint, options = {}) => {
|
|
|
77
92
|
id: null,
|
|
78
93
|
reason: null
|
|
79
94
|
});
|
|
95
|
+
// what `serde_json` refuses and `JSON.parse` accepts: refused as invalid
|
|
96
|
+
// JSON on both spines (`parse_json_text`), in `params` and in the GET query
|
|
97
|
+
for (const [label, params_json] of SERDE_REFUSED_PARAMS_JSON) {
|
|
98
|
+
post(`${label} in the body → parse_error`, `{"jsonrpc":"2.0","id":${JSON.stringify(id)},"method":${JSON.stringify(m)},"params":${params_json}}`, { status: 400, code: JSONRPC_ERROR_CODES.parse_error, id: null, reason: null });
|
|
99
|
+
get(`GET ${label} in params → invalid_params`, `?method=${q(m)}&id=${id}¶ms=${q(params_json)}`, { status: 400, code: JSONRPC_ERROR_CODES.invalid_params, id, reason: null });
|
|
100
|
+
}
|
|
80
101
|
post('wrong jsonrpc version → invalid_request', JSON.stringify({ jsonrpc: '1.0', id, method: m }), { ...invalid_request, id, reason: null });
|
|
81
102
|
post('missing jsonrpc field → invalid_request', JSON.stringify({ id, method: m }), {
|
|
82
103
|
...invalid_request,
|
|
@@ -237,7 +258,7 @@ export const assert_rpc_envelope_refusal = (status, body, c) => {
|
|
|
237
258
|
* (`invalid_request`) before params validation runs, and the envelope cases
|
|
238
259
|
* cover it. Every case returned owes 400 `invalid_params`.
|
|
239
260
|
*
|
|
240
|
-
* @param input - the method's input schema
|
|
261
|
+
* @param input - the method's input schema
|
|
241
262
|
* @param options - a valid base `params` to seed the cases (`InputTestCaseOptions.base`),
|
|
242
263
|
* and the method name for error messages
|
|
243
264
|
* @returns the cases, each a `params` object
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import './assert_dev_env.js';
|
|
2
|
-
import type
|
|
3
|
-
import { type Schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
2
|
+
import { type Schema, type Infer, type AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
4
3
|
import { type JsonrpcErrorCode } from '../http/jsonrpc.js';
|
|
5
4
|
import type { RequestResponseActionSpec } from '../actions/action_spec.js';
|
|
6
5
|
import type { RpcAction } from '../actions/action_types.js';
|
|
7
6
|
import type { AppSurfaceRpcEndpoint, AppSurfaceRpcMethod, RpcEndpointSpec } from '../http/surface.js';
|
|
8
7
|
import type { AppServerContext } from '../server/app_server_context.js';
|
|
9
8
|
import type { SessionOptions } from '../auth/session_cookie.js';
|
|
10
|
-
import { type ValidationOutput, type ValidationSchema } from '../schema_issues.js';
|
|
11
9
|
/**
|
|
12
10
|
* Union accepted by the suite-level `rpc_endpoints` option — eager array or
|
|
13
11
|
* a factory that takes an `AppServerContext` and returns endpoint specs. The
|
|
@@ -48,7 +46,7 @@ export declare const resolve_rpc_endpoints_for_setup: (rpc_endpoints: RpcEndpoin
|
|
|
48
46
|
* @param params - params (omit for parameterless methods; `null` is also
|
|
49
47
|
* stripped for ergonomic call sites — JSON-RPC 2.0 §4.2
|
|
50
48
|
* forbids `"params": null` on the wire, and `create_rpc_endpoint`
|
|
51
|
-
* rejects `
|
|
49
|
+
* rejects `literal(null)` action input schemas at registration).
|
|
52
50
|
* Tests that need to construct a literal `"params": null`
|
|
53
51
|
* envelope (e.g. asserting envelope-level rejection) should
|
|
54
52
|
* build the body inline rather than route through this helper.
|
|
@@ -93,9 +91,9 @@ export declare const assert_jsonrpc_error_response: (body: unknown, expected_cod
|
|
|
93
91
|
* is provided, also validates the `result` field against the declared
|
|
94
92
|
* output schema — matching the REST round-trip's `assert_response_matches_spec`.
|
|
95
93
|
*
|
|
96
|
-
* @param output_schema - optional
|
|
94
|
+
* @param output_schema - optional schema to validate the `result` field against
|
|
97
95
|
*/
|
|
98
|
-
export declare const assert_jsonrpc_success_response: (body: unknown, output_schema?:
|
|
96
|
+
export declare const assert_jsonrpc_success_response: (body: unknown, output_schema?: AnySchema) => void;
|
|
99
97
|
/**
|
|
100
98
|
* Minimal transport surface — the duck type `Hono.request` already satisfies.
|
|
101
99
|
* Extracted so test setups that want an in-process / WS / mock path can plug
|
|
@@ -153,7 +151,7 @@ export interface RpcCallArgs {
|
|
|
153
151
|
method: string;
|
|
154
152
|
/**
|
|
155
153
|
* Params for the call. Omit (or pass `undefined`) for parameterless
|
|
156
|
-
* (`
|
|
154
|
+
* (`s.void`) methods — the helper drops `params` from the envelope
|
|
157
155
|
* either way. See `create_rpc_post_init` for the null-stripping
|
|
158
156
|
* affordance and JSON-RPC 2.0 §4.2's prohibition on `params: null`.
|
|
159
157
|
*/
|
|
@@ -240,7 +238,7 @@ export type RpcCallResultForSpec<TSpec extends RequestResponseActionSpec> = {
|
|
|
240
238
|
ok: true;
|
|
241
239
|
status: number;
|
|
242
240
|
headers: Record<string, string>;
|
|
243
|
-
result:
|
|
241
|
+
result: Infer<TSpec['output']>;
|
|
244
242
|
} | {
|
|
245
243
|
ok: false;
|
|
246
244
|
status: number;
|
|
@@ -256,12 +254,12 @@ export type RpcCallForSpecArgs<TSpec extends RequestResponseActionSpec> = Omit<R
|
|
|
256
254
|
/** Action spec whose `method` drives the envelope and whose `input`/`output` types pin params + result. */
|
|
257
255
|
spec: TSpec;
|
|
258
256
|
/** Params, typed against `spec.input`. */
|
|
259
|
-
params:
|
|
257
|
+
params: Infer<TSpec['input']>;
|
|
260
258
|
};
|
|
261
259
|
/**
|
|
262
260
|
* Typed wrapper over `rpc_call` — binds `params` and the success `result` to
|
|
263
|
-
* the output types of `spec.input` and `spec.output` (`
|
|
264
|
-
* the generic
|
|
261
|
+
* the output types of `spec.input` and `spec.output` (`Infer`) via
|
|
262
|
+
* the generic.
|
|
265
263
|
*
|
|
266
264
|
* Success results are validated at runtime against `spec.output` (same
|
|
267
265
|
* contract as `rpc_call_typed`); a mismatch throws. Error responses come
|
|
@@ -281,10 +279,10 @@ export declare const rpc_call_for_spec: <TSpec extends RequestResponseActionSpec
|
|
|
281
279
|
* assert on specific error shapes.
|
|
282
280
|
*
|
|
283
281
|
* @throws Error if the response is a JSON-RPC error, if `rpc_call` throws
|
|
284
|
-
* on an envelope violation, or if the result fails `output_schema` (
|
|
285
|
-
*
|
|
282
|
+
* on an envelope violation, or if the result fails `output_schema` (parsed with
|
|
283
|
+
* `parse`).
|
|
286
284
|
*/
|
|
287
|
-
export declare const rpc_call_typed: <T>(args: RpcCallArgs, output_schema:
|
|
285
|
+
export declare const rpc_call_typed: <T>(args: RpcCallArgs, output_schema: Schema<T, any>) => Promise<T>;
|
|
288
286
|
/**
|
|
289
287
|
* Find the `RpcAction` for a method within a set of RPC endpoint specs.
|
|
290
288
|
* Returns both the endpoint path and the matched action. `undefined` when
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"rpc_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rpc_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,EAAa,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAElG,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EACX,qBAA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,yBAAyB,GACrC,eAAe,aAAa,CAAC,eAAe,CAAC,KAC3C,MAcF,CAAC"}
|
|
@@ -13,7 +13,6 @@ import { is, parse } from '@fuzdev/fuz_schema/schema.ts';
|
|
|
13
13
|
import { JSONRPC_VERSION, JsonrpcErrorResponse, JsonrpcResponse } from '../http/jsonrpc.js';
|
|
14
14
|
import { create_stub_app_server_context } from './stubs.js';
|
|
15
15
|
import { TEST_ORIGIN } from './test_origin.js';
|
|
16
|
-
import { parse_any } from '../schema_issues.js';
|
|
17
16
|
/**
|
|
18
17
|
* Resolve a suite's `rpc_endpoints` option to an array for setup-time
|
|
19
18
|
* inspection (path lookup, action presence checks).
|
|
@@ -62,7 +61,7 @@ export const resolve_rpc_endpoints_for_setup = (rpc_endpoints, session_options)
|
|
|
62
61
|
* @param params - params (omit for parameterless methods; `null` is also
|
|
63
62
|
* stripped for ergonomic call sites — JSON-RPC 2.0 §4.2
|
|
64
63
|
* forbids `"params": null` on the wire, and `create_rpc_endpoint`
|
|
65
|
-
* rejects `
|
|
64
|
+
* rejects `literal(null)` action input schemas at registration).
|
|
66
65
|
* Tests that need to construct a literal `"params": null`
|
|
67
66
|
* envelope (e.g. asserting envelope-level rejection) should
|
|
68
67
|
* build the body inline rather than route through this helper.
|
|
@@ -131,13 +130,13 @@ export const assert_jsonrpc_error_response = (body, expected_code) => {
|
|
|
131
130
|
* is provided, also validates the `result` field against the declared
|
|
132
131
|
* output schema — matching the REST round-trip's `assert_response_matches_spec`.
|
|
133
132
|
*
|
|
134
|
-
* @param output_schema - optional
|
|
133
|
+
* @param output_schema - optional schema to validate the `result` field against
|
|
135
134
|
*/
|
|
136
135
|
export const assert_jsonrpc_success_response = (body, output_schema) => {
|
|
137
136
|
const result = parse(JsonrpcResponse, body);
|
|
138
137
|
assert.ok(result.ok, `not a valid JSON-RPC success response: ${JSON.stringify(body)}`);
|
|
139
138
|
if (output_schema) {
|
|
140
|
-
const output_result =
|
|
139
|
+
const output_result = parse(output_schema, result.value.result);
|
|
141
140
|
if (!output_result.ok) {
|
|
142
141
|
assert.fail(`JSON-RPC result does not match output schema: ${JSON.stringify(output_result.issues)}`);
|
|
143
142
|
}
|
|
@@ -278,8 +277,8 @@ export const rpc_call = async (args) => parse_rpc_call_result(await rpc_call_raw
|
|
|
278
277
|
export const rpc_call_non_browser = (args) => rpc_call({ ...args, suppress_default_origin: true });
|
|
279
278
|
/**
|
|
280
279
|
* Typed wrapper over `rpc_call` — binds `params` and the success `result` to
|
|
281
|
-
* the output types of `spec.input` and `spec.output` (`
|
|
282
|
-
* the generic
|
|
280
|
+
* the output types of `spec.input` and `spec.output` (`Infer`) via
|
|
281
|
+
* the generic.
|
|
283
282
|
*
|
|
284
283
|
* Success results are validated at runtime against `spec.output` (same
|
|
285
284
|
* contract as `rpc_call_typed`); a mismatch throws. Error responses come
|
|
@@ -297,7 +296,7 @@ export const rpc_call_for_spec = async (args) => {
|
|
|
297
296
|
if (!res.ok) {
|
|
298
297
|
return res;
|
|
299
298
|
}
|
|
300
|
-
const parsed =
|
|
299
|
+
const parsed = parse(spec.output, res.result);
|
|
301
300
|
if (!parsed.ok) {
|
|
302
301
|
throw new Error(`rpc_call_for_spec(${spec.method}) result did not match spec.output: ${JSON.stringify(parsed.issues)}`);
|
|
303
302
|
}
|
|
@@ -315,15 +314,15 @@ export const rpc_call_for_spec = async (args) => {
|
|
|
315
314
|
* assert on specific error shapes.
|
|
316
315
|
*
|
|
317
316
|
* @throws Error if the response is a JSON-RPC error, if `rpc_call` throws
|
|
318
|
-
* on an envelope violation, or if the result fails `output_schema` (
|
|
319
|
-
*
|
|
317
|
+
* on an envelope violation, or if the result fails `output_schema` (parsed with
|
|
318
|
+
* `parse`).
|
|
320
319
|
*/
|
|
321
320
|
export const rpc_call_typed = async (args, output_schema) => {
|
|
322
321
|
const res = await rpc_call(args);
|
|
323
322
|
if (!res.ok) {
|
|
324
323
|
throw new Error(`rpc_call_typed(${args.method}) returned error: code=${res.error.code} message=${res.error.message} data=${JSON.stringify(res.error.data)}`);
|
|
325
324
|
}
|
|
326
|
-
const parsed =
|
|
325
|
+
const parsed = parse(output_schema, res.result);
|
|
327
326
|
if (!parsed.ok) {
|
|
328
327
|
throw new Error(`rpc_call_typed(${args.method}) result did not match output schema: ${JSON.stringify(parsed.issues)}`);
|
|
329
328
|
}
|