@fuzdev/fuz_app 0.170.0 → 0.172.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 +3 -3
- package/dist/actions/action_codegen.d.ts +5 -3
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +11 -27
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +5 -6
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +3 -2
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +2 -1
- 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 +5 -7
- package/dist/http/CLAUDE.md +5 -3
- package/dist/http/error_schemas.d.ts +3 -4
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +4 -5
- package/dist/http/host.d.ts +137 -0
- package/dist/http/host.d.ts.map +1 -0
- package/dist/http/host.js +203 -0
- 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/origin.d.ts +9 -0
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +6 -2
- package/dist/http/origin_wildcard.d.ts +20 -5
- package/dist/http/origin_wildcard.d.ts.map +1 -1
- package/dist/http/origin_wildcard.js +22 -10
- 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 +1 -1
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +10 -9
- package/dist/http/schema_helpers.d.ts +10 -9
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/server/app_server.d.ts +10 -0
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +14 -3
- package/dist/testing/CLAUDE.md +6 -7
- package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
- package/dist/testing/adversarial_input_cases.js +2 -4
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +7 -2
- package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +2 -1
- package/dist/testing/cross_backend/origin_conformance.d.ts +62 -1
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_conformance.js +19 -3
- package/dist/testing/cross_backend/origin_conformance.json +330 -0
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -6
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -15
- package/dist/testing/cross_backend/testing_origin_check.d.ts +16 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +12 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +2 -2
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +3 -3
- 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/rpc_envelope_cases.d.ts +7 -0
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +21 -0
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +8 -18
- package/dist/testing/stubs.d.ts +11 -4
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -5
- package/package.json +1 -1
|
@@ -50,16 +50,18 @@ export const origin_wildcard_kind = (pattern) => {
|
|
|
50
50
|
return any_port ? { kind: 'port' } : null;
|
|
51
51
|
return any_port ? { kind: 'host_and_port', host } : { kind: 'host', host };
|
|
52
52
|
};
|
|
53
|
+
/** The host gate on, as `create_app_server` mounts it by default. */
|
|
54
|
+
export const ORIGIN_WILDCARD_OPTIONS_DEFAULT = { host_gate: true };
|
|
53
55
|
/**
|
|
54
56
|
* What a wildcard in `pattern` admits — the text `admit_origin_wildcards`
|
|
55
|
-
* warns or refuses with; `null` for an exact entry. The
|
|
56
|
-
* `
|
|
57
|
-
* `OriginWildcardOptions::DEFAULT`.
|
|
57
|
+
* warns or refuses with; `null` for an exact entry. The Rust
|
|
58
|
+
* `origin_wildcard_warning` text word for word, with no notes.
|
|
58
59
|
*
|
|
59
60
|
* @param pattern - a parsed allowlist entry
|
|
61
|
+
* @param options - whether the server mounts the host gate
|
|
60
62
|
* @returns the text, or `null`
|
|
61
63
|
*/
|
|
62
|
-
export const origin_wildcard_warning = (pattern) => {
|
|
64
|
+
export const origin_wildcard_warning = (pattern, options = ORIGIN_WILDCARD_OPTIONS_DEFAULT) => {
|
|
63
65
|
const wildcard = origin_wildcard_kind(pattern);
|
|
64
66
|
if (wildcard === null)
|
|
65
67
|
return null;
|
|
@@ -87,10 +89,19 @@ export const origin_wildcard_warning = (pattern) => {
|
|
|
87
89
|
hosts = `ANY host of that shape (no label of \`${host}\` is fixed: ${every})`;
|
|
88
90
|
}
|
|
89
91
|
const ports = pattern.port === 'any' ? 'ANY port on ' : pattern.port === 'exact' ? 'that port on ' : '';
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const sentences = [
|
|
93
|
+
`${kind}: a page served from ${ports}${hosts} is an allowed origin. The server trusts ` +
|
|
94
|
+
'every such page: one that is same-site with the host you log in at carries the ' +
|
|
95
|
+
'session cookie, and with it can call the API and open the WebSocket.'
|
|
96
|
+
];
|
|
97
|
+
if (options.host_gate) {
|
|
98
|
+
sentences.push(host_wildcard === null
|
|
99
|
+
? `The \`Host\` check answers to ${host} at any port too.`
|
|
100
|
+
: 'The `Host` check answers to the same hosts, on either scheme, so a page that ' +
|
|
101
|
+
're-points a matching domain at this machine (DNS rebinding) passes it.');
|
|
102
|
+
}
|
|
103
|
+
sentences.push('Name exact origins unless every such page is trusted');
|
|
104
|
+
return sentences.join(' ');
|
|
94
105
|
};
|
|
95
106
|
/**
|
|
96
107
|
* Admit `origins`' wildcard entries when `allowed`, returning what each admits
|
|
@@ -105,11 +116,12 @@ export const origin_wildcard_warning = (pattern) => {
|
|
|
105
116
|
* @param allowed - whether the operator opted in (`FUZ_ALLOW_ORIGIN_WILDCARDS=true`)
|
|
106
117
|
* @param origins_var - what the list is called in the refusal: the env var it
|
|
107
118
|
* was read from, or the option that carried it
|
|
119
|
+
* @param options - whether the server mounts the host gate, which the text names
|
|
108
120
|
* @returns the wildcard entries admitted, or the refusal — naming each
|
|
109
121
|
* unclassifiable matcher, or else each wildcard entry, what it admits, and
|
|
110
122
|
* the flag (the Rust spine's boot error, word for word)
|
|
111
123
|
*/
|
|
112
|
-
export const admit_origin_wildcards = (origins, allowed, origins_var = ALLOWED_ORIGINS_VAR) => {
|
|
124
|
+
export const admit_origin_wildcards = (origins, allowed, origins_var = ALLOWED_ORIGINS_VAR, options = ORIGIN_WILDCARD_OPTIONS_DEFAULT) => {
|
|
113
125
|
const wildcards = [];
|
|
114
126
|
const unparsed = [];
|
|
115
127
|
for (const regexp of origins) {
|
|
@@ -118,7 +130,7 @@ export const admit_origin_wildcards = (origins, allowed, origins_var = ALLOWED_O
|
|
|
118
130
|
unparsed.push(regexp);
|
|
119
131
|
continue;
|
|
120
132
|
}
|
|
121
|
-
const warning = origin_wildcard_warning(pattern);
|
|
133
|
+
const warning = origin_wildcard_warning(pattern, options);
|
|
122
134
|
if (warning)
|
|
123
135
|
wildcards.push({ entry: pattern.entry, warning });
|
|
124
136
|
}
|
|
@@ -35,7 +35,8 @@ export interface RouteFail<TStatus extends number, TCode extends string, TBody>
|
|
|
35
35
|
readonly status: TStatus;
|
|
36
36
|
readonly code: TCode;
|
|
37
37
|
readonly body: TBody;
|
|
38
|
-
|
|
38
|
+
/** The definition the failure was made from, at the same status and code. */
|
|
39
|
+
readonly def: RestErrorDef<TStatus, TCode>;
|
|
39
40
|
}
|
|
40
41
|
/** A response the handler built itself, answered as it is (`route_raw`). */
|
|
41
42
|
export interface RouteRaw {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_result.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wEAAwE;AACxE,MAAM,WAAW,OAAO,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS,CAAC,OAAO,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,KAAK;IAC7E,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"route_result.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,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EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,CAAC,CAA0B,CAAC;AAEnG;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,IAAI,SAAS,YAAY,EACnD,KAAK,IAAI,EACT,GAAG,QAAQ,eAAe,CAAC,IAAI,CAAC,KAC9B,WAAW,CAAC,IAAI,CAOgB,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,QAAQ,EACnD,UAAU,SAAS,GAClB,CAAC,SAAS,SAAS,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,KAAK,GAAG,OAAO,CAAC,KAC/E,QAAqC,CAAC"}
|
|
@@ -329,7 +329,7 @@ export declare const attach_route_handler: <TErrors extends ReadonlyArray<RestEr
|
|
|
329
329
|
*
|
|
330
330
|
* @param c - the Hono context
|
|
331
331
|
* @param result - the handler's result
|
|
332
|
-
* @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value, a failure without its status or definition, a raw result without a response, `undefined` or `null`
|
|
332
|
+
* @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value or with a function or symbol for one, a failure without its status or definition, a raw result without a response, `undefined` or `null`
|
|
333
333
|
*/
|
|
334
334
|
export declare const to_route_response: (c: Context, result: RouteResult) => Response;
|
|
335
335
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAW,IAAI,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAGtE,OAAO,EAEN,KAAK,SAAS,EAEd,KAAK,UAAU,EACf,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,M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AC,CAAC;AACvF,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC;AAK7D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AACtF,wBAAgB,eAAe,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC;AA2K5D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,IAAI,EAAE,OAAO,KAAK,CAAC,cAAc,CAAC,KAAG,IAIhF,CAAC;AAsGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,iBAAiB,GAC7B,KAAK,IAAI,EACT,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,qBAAqB,iBAAiB,EACtC,KAAK,MAAM,EACX,IAAI,EAAE,EACN,YAAY,oBAAoB,KAC9B,IA+EF,CAAC;AAkCF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,SAAS,CAK3F,CAAC"}
|
package/dist/http/route_spec.js
CHANGED
|
@@ -29,6 +29,7 @@ import { is_json_response } from './route_error_check.js';
|
|
|
29
29
|
import { dispatch_with_post_commit_rollback } from './pending_effects.js';
|
|
30
30
|
import { assert_route_auth_acting_biconditional, assert_route_auth_invariants } from './auth_shape.js';
|
|
31
31
|
import { assert_validation_schema, to_wire_issues } from '../schema_issues.js';
|
|
32
|
+
import { read_json_body } from './json_text.js';
|
|
32
33
|
/**
|
|
33
34
|
* Define a route: its handler is checked against the route's `output`,
|
|
34
35
|
* `errors`, `auth`, and `rate_limit` (`TypedRouteHandler`), and the spec is
|
|
@@ -69,15 +70,18 @@ export const attach_route_handler = (shape, handler) => ({ ...shape, handler });
|
|
|
69
70
|
*
|
|
70
71
|
* @param c - the Hono context
|
|
71
72
|
* @param result - the handler's result
|
|
72
|
-
* @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value, a failure without its status or definition, a raw result without a response, `undefined` or `null`
|
|
73
|
+
* @throws TypeError when `result` is not a result `route_ok`, `route_fail`, or `route_raw` made: a `Response`, a success without a value or with a function or symbol for one, a failure without its status or definition, a raw result without a response, `undefined` or `null`
|
|
73
74
|
*/
|
|
74
75
|
export const to_route_response = (c, result) => {
|
|
75
76
|
// each branch checks the field it reads, so a malformed or nullish result
|
|
76
77
|
// falls through to the throw — a `Response` has its own `ok` and `status`,
|
|
77
|
-
// but no `value` or `def
|
|
78
|
+
// but no `value` or `def`. A function or symbol value is no JSON value:
|
|
79
|
+
// `JSON.stringify` writes nothing for it, which would answer an empty 200
|
|
78
80
|
if (result?.ok === true) {
|
|
79
|
-
|
|
81
|
+
const type = typeof result.value;
|
|
82
|
+
if (type !== 'undefined' && type !== 'function' && type !== 'symbol') {
|
|
80
83
|
return c.json(result.value);
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
else if (result?.ok === 'raw') {
|
|
83
87
|
if (result.response instanceof Response)
|
|
@@ -141,13 +145,10 @@ const create_input_validation = (input_schema, method) => {
|
|
|
141
145
|
if (is_null_schema(input_schema))
|
|
142
146
|
return [];
|
|
143
147
|
const validate = async (c, next) => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
body = await c.req.json();
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
148
|
+
const read = await read_json_body(c.req);
|
|
149
|
+
if (!read.ok)
|
|
149
150
|
return c.json({ error: ERROR_INVALID_JSON_BODY }, 400);
|
|
150
|
-
|
|
151
|
+
const body = read.value;
|
|
151
152
|
if (typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
152
153
|
return c.json({ error: ERROR_INVALID_JSON_BODY }, 400);
|
|
153
154
|
}
|
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import { type AnySchema, type Infer, type SchemaResult } from '@fuzdev/fuz_schema/schema.ts';
|
|
10
|
+
import { type AnySchema, type Infer, type SchemaKind, type SchemaResult } from '@fuzdev/fuz_schema/schema.ts';
|
|
11
|
+
/**
|
|
12
|
+
* The kind the testing generators switch on: the innermost layer's
|
|
13
|
+
* `@fuzdev/fuz_schema` kind, with an object schema of any strictness as
|
|
14
|
+
* `'object'`, and a `literal(null)` and a `literal(undefined)` (`s.void`) as
|
|
15
|
+
* `'null'` and `'void'`.
|
|
16
|
+
*/
|
|
17
|
+
export type SchemaFieldBaseType = Exclude<SchemaKind, 'loose_object' | 'strip_object' | 'object_with_rest'> | 'null' | 'void';
|
|
11
18
|
/**
|
|
12
19
|
* What the testing generators read of one field of an object schema
|
|
13
20
|
* (`to_object_schema_view`, `testing/schema_generators.ts`).
|
|
@@ -15,14 +22,8 @@ import { type AnySchema, type Infer, type SchemaResult } from '@fuzdev/fuz_schem
|
|
|
15
22
|
export interface SchemaFieldInfo {
|
|
16
23
|
/** The field's key. */
|
|
17
24
|
name: string;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
* `'array'`, `'literal'`, and so on, with an object of any strictness as
|
|
21
|
-
* `'object'`, a `literal(null)` as `'null'`, a `literal(undefined)`
|
|
22
|
-
* (`s.void`) as `'void'`, a `one_of` as `'enum'`, and a `variant` as
|
|
23
|
-
* `'union'`.
|
|
24
|
-
*/
|
|
25
|
-
base_type: string;
|
|
25
|
+
/** The innermost layer's kind, `SchemaFieldBaseType`. */
|
|
26
|
+
base_type: SchemaFieldBaseType;
|
|
26
27
|
/** Whether the key must be present: no `optional` layer. */
|
|
27
28
|
required: boolean;
|
|
28
29
|
/** Whether the parse fills the key in when it is missing. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/schema_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"schema_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/schema_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,MAAM,8BAA8B,CAAC;AAMtC;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC9B,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,GAAG,kBAAkB,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7F;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,SAAS,EAAE,mBAAmB,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,KAAG,OACF,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,KAAG,OACG,CAAC;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,OAAO,KAAG,OAUpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,EAAE,YAAY,OAAO,KAAG,OACA,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,OAavD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CACtE,EACD,YAAY,MAAM,KAChB,OAAgG,CAAC"}
|
|
@@ -98,6 +98,16 @@ export interface AppServerOptions {
|
|
|
98
98
|
* on any other matcher, flag or not. Defaults to `false`.
|
|
99
99
|
*/
|
|
100
100
|
allow_origin_wildcards?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Mount the `Host` check (`http/host.ts`), the DNS-rebinding gate, on every
|
|
103
|
+
* path ahead of the origin check: a request whose `Host` is neither a
|
|
104
|
+
* loopback name nor a host `allowed_origins` names is refused `403`
|
|
105
|
+
* `forbidden_host`, and logged at `warn` (rate-limited). Defaults to `true`;
|
|
106
|
+
* `false` is for a server reached by names its allowlist doesn't hold, which
|
|
107
|
+
* then accepts the rebinding exposure. Twin of the Rust spine's
|
|
108
|
+
* `StackOptions::host_gate`.
|
|
109
|
+
*/
|
|
110
|
+
host_gate?: boolean;
|
|
101
111
|
/**
|
|
102
112
|
* Paths the origin check skips, each with its reason. The check covers
|
|
103
113
|
* every path by default (`ORIGIN_MIDDLEWARE_PATH`) — a request with no
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE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,CAAC,uBAAuB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;IACnE,uFAAuF;IACvF,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACtC,OAAO,sBAAsB,KAC3B,KAAK,CAAC,oBAAoB,CA0D5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,SAAS,CAQpF,CAAC"}
|
|
@@ -31,6 +31,7 @@ import { fuz_auth_guard_resolver } from '../auth/auth_guard_resolver.js';
|
|
|
31
31
|
import { create_fuz_authorization_handler } from '../auth/request_context.js';
|
|
32
32
|
import { create_body_limit_middleware_spec } from '../http/body_limit.js';
|
|
33
33
|
import { admit_origin_wildcards, ALLOWED_ORIGINS_VAR } from '../http/origin_wildcard.js';
|
|
34
|
+
import { create_host_gate_middleware_spec } from '../http/host.js';
|
|
34
35
|
import { create_rpc_endpoint } from '../actions/action_rpc.js';
|
|
35
36
|
import { register_action_ws } from '../actions/register_action_ws.js';
|
|
36
37
|
import { resolve_ws_endpoints } from '../actions/ws_endpoint_spec.js';
|
|
@@ -271,7 +272,8 @@ const assemble_app_server = async (options, releases) => {
|
|
|
271
272
|
throw new Error('create_app_server: allowed_origins is empty — list at least one origin pattern ' +
|
|
272
273
|
'(an empty list refuses every browser request)');
|
|
273
274
|
}
|
|
274
|
-
const
|
|
275
|
+
const host_gate = options.host_gate ?? true;
|
|
276
|
+
const wildcards = admit_origin_wildcards(options.allowed_origins, options.allow_origin_wildcards ?? false, ALLOWED_ORIGINS_VAR, { host_gate });
|
|
275
277
|
if (!wildcards.ok)
|
|
276
278
|
throw new Error(`create_app_server: ${wildcards.message}`);
|
|
277
279
|
for (const { entry, warning } of wildcards.wildcards) {
|
|
@@ -309,6 +311,10 @@ const assemble_app_server = async (options, releases) => {
|
|
|
309
311
|
releases.push(deps.connection_closer.add(create_sse_connection_closer(audit_sse.registry, audit_sse.required_role)));
|
|
310
312
|
releases.push(deps.audit.add_listener(audit_sse.on_audit_event));
|
|
311
313
|
}
|
|
314
|
+
// Host gate — ahead of everything but the body cap, as on the Rust stack
|
|
315
|
+
const host_spec = host_gate
|
|
316
|
+
? create_host_gate_middleware_spec({ allowed_origins: options.allowed_origins, log })
|
|
317
|
+
: null;
|
|
312
318
|
// Proxy middleware
|
|
313
319
|
const proxy_spec = create_proxy_middleware_spec({ ...options.proxy, log });
|
|
314
320
|
// Auth middleware
|
|
@@ -318,7 +324,11 @@ const assemble_app_server = async (options, releases) => {
|
|
|
318
324
|
daemon_token_state: options.daemon_token_state,
|
|
319
325
|
origin_carve_outs: options.origin_carve_outs
|
|
320
326
|
});
|
|
321
|
-
const stack_specs = [
|
|
327
|
+
const stack_specs = [
|
|
328
|
+
...(host_spec ? [host_spec] : []),
|
|
329
|
+
proxy_spec,
|
|
330
|
+
...auth_middleware
|
|
331
|
+
];
|
|
322
332
|
let middleware_specs = stack_specs;
|
|
323
333
|
if (options.transform_middleware) {
|
|
324
334
|
// the transform gets copies in a fresh array, so mutating what it was
|
|
@@ -462,7 +472,8 @@ const assemble_app_server = async (options, releases) => {
|
|
|
462
472
|
// that took the server list was checked above)
|
|
463
473
|
if (endpoint.allowed_origins !== options.allowed_origins) {
|
|
464
474
|
const label = `ws_endpoints allowed_origins for ${endpoint.path}`;
|
|
465
|
-
|
|
475
|
+
// the host gate reads the server list, not this one
|
|
476
|
+
const endpoint_wildcards = admit_origin_wildcards(endpoint.allowed_origins, options.allow_origin_wildcards ?? false, label, { host_gate: false });
|
|
466
477
|
if (!endpoint_wildcards.ok) {
|
|
467
478
|
throw new Error(`create_app_server: ${endpoint_wildcards.message}`);
|
|
468
479
|
}
|
package/dist/testing/CLAUDE.md
CHANGED
|
@@ -39,7 +39,7 @@ time (never runtime), where a throwing guard would break `vite build`.
|
|
|
39
39
|
- `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` matching `create_auth_middleware_specs`'s output (origin, optional daemon_token, session, request_context, bearer_auth) for surface generation without booting real auth — the same names, paths, order, and declared `errors` (`origin` declares a 403; `bearer_auth` and `daemon_token` declare none, since both soft-fail through `next()`), pinned against the real factory by `auth/middleware.mounted.test.ts`. The surface merges middleware errors into every route under the path, so a stub declaring more would widen the test surface with statuses the live server never returns. Each spec gets its own pass-through handler (not the shared `stub_mw`), so `assert_middleware_stack_mounted` tells the layers apart. See `auth/CLAUDE.md` §Middleware for the real stack.
|
|
40
40
|
- `create_stub_app_backend(options?)` — stub `AppBackend` with no database: `create_stub_app_deps()` (or `options.deps`), no migration results, a `close` that does nothing (or `options.close`). For assembling a server in tests that never reach the database.
|
|
41
41
|
- `create_stub_app_server_context(session_options)` — stub `AppServerContext` over `create_stub_app_backend()`; rate limiters null, `bootstrap_status.available: false`.
|
|
42
|
-
- `create_test_app_surface_spec(options)` — builds an `AppSurfaceSpec` mirroring `create_app_server`'s route assembly, in its order (consumer routes, then bootstrap routes, RPC endpoint routes, and `GET /api/surface`, + stub middleware + surface generation). `GET /api/surface` is listed only with `surface_route: true`, as `create_app_server` mounts it only when opted in — pass the same value to both so the surface-derived suites probe it exactly when the live server serves it. `daemon_token: true` lists the `daemon_token` layer `create_app_server` mounts when given a `daemon_token_state` (`create_test_app` always passes one, and `default_in_process_suite_options` sets it, along with `app_options.surface_route`); `testing/test_app_server.db.test.ts` pins the stub's routes (order, auth, error schemas, applicable middleware) and middleware names against `create_test_app`'s for every `surface_route` setting. Its middleware list mirrors the real one — the body limit's shape at `'*'` (`body_limit_middleware_shape` with a stub handler, left out with `max_body_size: null`), a stub `trusted_proxy` spec at `'*'`, then the stub auth stack — so every route's `applicable_middleware` starts with `body_limit`, `trusted_proxy` (a route outside `/api/*` lists `['body_limit', 'trusted_proxy', 'origin']`, since the origin check covers every path, and a route under an origin carve-out drops `origin`), as on the live server, and every route's error map carries the limit's 413 and 400 and the origin check's 403 `forbidden_origin`. `CreateTestAppSurfaceSpecOptions`: `session_options`, `create_route_specs`, `env_schema?`, `event_specs?`, `rpc_endpoints?`, `ws_endpoints?`, `allowed_origins?`, `origin_carve_outs?`, `transform_middleware?`, `bootstrap?`, `surface_route?`, `daemon_token?`, `max_body_size?`. Throws, like `create_app_server`, on an endpoint path outside `AUTH_MIDDLEWARE_PATH` (`assert_endpoint_in_auth_scope`), on a route that reads or mints a credential outside it (`assert_credential_routes_in_auth_scope`), on an origin carve-out that overlaps that scope (`assert_origin_carve_outs_valid`), and on a `transform_middleware` that moves, drops, duplicates, reorders, wraps, or replaces the stub proxy
|
|
42
|
+
- `create_test_app_surface_spec(options)` — builds an `AppSurfaceSpec` mirroring `create_app_server`'s route assembly, in its order (consumer routes, then bootstrap routes, RPC endpoint routes, and `GET /api/surface`, + stub middleware + surface generation). `GET /api/surface` is listed only with `surface_route: true`, as `create_app_server` mounts it only when opted in — pass the same value to both so the surface-derived suites probe it exactly when the live server serves it. `daemon_token: true` lists the `daemon_token` layer `create_app_server` mounts when given a `daemon_token_state` (`create_test_app` always passes one, and `default_in_process_suite_options` sets it, along with `app_options.surface_route`); `testing/test_app_server.db.test.ts` pins the stub's routes (order, auth, error schemas, applicable middleware) and middleware names against `create_test_app`'s for every `surface_route` setting. Its middleware list mirrors the real one — the body limit's shape at `'*'` (`body_limit_middleware_shape` with a stub handler, left out with `max_body_size: null`), the host gate's (`host_gate_middleware_shape`, left out with `host_gate: false`), a stub `trusted_proxy` spec at `'*'`, then the stub auth stack — so every route's `applicable_middleware` starts with `body_limit`, `host`, `trusted_proxy` (a route outside `/api/*` lists `['body_limit', 'host', 'trusted_proxy', 'origin']`, since the origin check covers every path, and a route under an origin carve-out drops `origin`), as on the live server, and every route's error map carries the limit's 413 and 400, the host gate's 403 `forbidden_host` and the origin check's 403 `forbidden_origin`. `CreateTestAppSurfaceSpecOptions`: `session_options`, `create_route_specs`, `env_schema?`, `event_specs?`, `rpc_endpoints?`, `ws_endpoints?`, `allowed_origins?`, `origin_carve_outs?`, `transform_middleware?`, `bootstrap?`, `surface_route?`, `daemon_token?`, `max_body_size?`, `host_gate?`. Throws, like `create_app_server`, on an endpoint path outside `AUTH_MIDDLEWARE_PATH` (`assert_endpoint_in_auth_scope`), on a route that reads or mints a credential outside it (`assert_credential_routes_in_auth_scope`), on an origin carve-out that overlaps that scope (`assert_origin_carve_outs_valid`), and on a `transform_middleware` that moves, drops, duplicates, reorders, wraps, or replaces the stub host gate, proxy or auth spec (`assert_middleware_stack_mounted`); the transform receives shallow copies in a fresh array, so an in-place mutation can't slip past the check. Throws on a `ws_endpoints` spec with no `allowed_origins` of its own when no `allowed_origins` option is given (there is no server list to default from). Bootstrap is opt-in (symmetric with `create_app_server` — omit to skip; pass the same value as prod to mount routes at `bootstrap.route_prefix ?? '/api/account'`). Single source of truth for attack-surface tests — track `create_app_server` wiring changes here.
|
|
43
43
|
|
|
44
44
|
Throwing stubs surface mock escape: a test that accidentally reaches into
|
|
45
45
|
stub territory breaks immediately with a label-scoped error rather than
|
|
@@ -502,7 +502,7 @@ Support functions:
|
|
|
502
502
|
Walks `@fuzdev/fuz_schema` schemas to generate valid values for
|
|
503
503
|
adversarial/round-trip tests. A value that is no schema throws, naming it.
|
|
504
504
|
|
|
505
|
-
- `to_object_schema_view(schema, label)` → `ObjectSchemaView` — the fields (`SchemaFieldInfo[]`, from `http/schema_helpers.ts`) of an object schema through its wrappers, each `base_type` its innermost kind (an object of any strictness reads `'object'`, `literal(null)` `'null'`, `literal(undefined)` `'void'
|
|
505
|
+
- `to_object_schema_view(schema, label)` → `ObjectSchemaView` — the fields (`SchemaFieldInfo[]`, from `http/schema_helpers.ts`) of an object schema through its wrappers, each `base_type` its innermost fuz_schema kind (`SchemaFieldBaseType`: an object of any strictness reads `'object'`, `literal(null)` `'null'`, `literal(undefined)` `'void'`), and each field's schema, throwing on a schema that is no object schema. `to_body_input(input_schema, label)` is the body generators' gate: `null` for a void or null input, else the object view, and a throw for any other input — no body is never silently what an unbuildable input yields.
|
|
506
506
|
|
|
507
507
|
- `to_field_json_schema(field_schema)` — the field's JSON Schema rendered with `io: 'input'`, so a field piped through a `transform` (`Username`) yields its input-side bounds and pattern instead of throwing; a `nullable` field's one non-null `anyOf` branch (or one non-null `type` of a `type` array) is returned. It renders with `unrepresentable: 'any'`, so it is never `null`: a part JSON Schema can't say (a `check`) is left out or `{}` and the bounds around it still read; it throws on a schema the emitter refuses even then. A pipe yields its input stage only, and a `check` never appears (a code-point length bound generates nothing). Every JSON Schema read in the generators goes through it.
|
|
508
508
|
- `detect_format(field_schema)` — `detect_json_schema_format` over `to_field_json_schema`: the `format`, `'pattern'` for a regex, or `null`.
|
|
@@ -856,8 +856,8 @@ excluded because no describe block in this suite drives it — its declared
|
|
|
856
856
|
codes would always be uncovered. Consumer-specific routes aren't exercised
|
|
857
857
|
here either — they don't count against the baseline. The declared paths are
|
|
858
858
|
the route error maps of `surface_source`, middleware included (the origin
|
|
859
|
-
check's 403, the body limit's 413 and 400, and the
|
|
860
|
-
|
|
859
|
+
check's 403, the body limit's 413 and 400, and the host gate's 403 where the
|
|
860
|
+
surface declares it), counted per (route, status, code), so
|
|
861
861
|
every error response a test asserts is recorded, and the middleware-gate group
|
|
862
862
|
probes each gate on each counted route. Override with
|
|
863
863
|
`error_coverage_min?: number` (set to `0` to skip the assertion — useful for
|
|
@@ -1407,9 +1407,8 @@ shapes. It declares `/health`, the `ACCOUNT_ROUTER_PATHS` under
|
|
|
1407
1407
|
`/api/account` (`/status`, `/login`, `/logout`, `/password` — what
|
|
1408
1408
|
`fuz_auth::account_router` mounts, so the TS-only `/verify` stays off), signup,
|
|
1409
1409
|
bootstrap as a `surface_only` shape, the daemon-token layer the consumer test
|
|
1410
|
-
binaries wire,
|
|
1411
|
-
|
|
1412
|
-
(default off), and one RPC endpoint: the standard actions (over `roles`), the
|
|
1410
|
+
binaries wire, the host gate's `host` layer unless `host_gate: false` says the
|
|
1411
|
+
server turns the gate off (default on), and one RPC endpoint: the standard actions (over `roles`), the
|
|
1413
1412
|
`extra_rpc_actions` (opt-in families built against the stub context), then the
|
|
1414
1413
|
request-response, non-protocol `domain_action_specs` minus `exclude_methods`
|
|
1415
1414
|
(methods the spec-derived suites can't drive; an entry naming no domain spec
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adversarial_input_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/adversarial_input_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"adversarial_input_cases.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/adversarial_input_cases.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAuErE,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,0BAA0B,GAAG,OAAO,uBAAuB,CAAC;CACnF;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAID,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACpC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,yBAAyB,GACrC,cAAc,SAAS,EACvB,UAAU,oBAAoB,KAC5B,KAAK,CAAC,aAAa,CAyMrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GACnC,cAAc,SAAS,EACvB,WAAW,aAAa,KACtB,MAAM,GAAG,SAG+C,CAAC;AAmC5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,eAAe,SAAS,KAAG,KAAK,CAAC,cAAc,CAoBzF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,GAAI,cAAc,SAAS,KAAG,KAAK,CAAC,aAAa,CAkCtF,CAAC"}
|
|
@@ -24,8 +24,6 @@ const accepts = (schema, value) => parse(schema, value).ok;
|
|
|
24
24
|
const wrong_type_for = (base_type) => {
|
|
25
25
|
switch (base_type) {
|
|
26
26
|
case 'string':
|
|
27
|
-
case 'uuid':
|
|
28
|
-
case 'email':
|
|
29
27
|
return { label: 'number instead of string', value: 42 };
|
|
30
28
|
case 'number':
|
|
31
29
|
return { label: 'string instead of number', value: 'not_a_number' };
|
|
@@ -35,7 +33,7 @@ const wrong_type_for = (base_type) => {
|
|
|
35
33
|
return { label: 'string instead of array', value: 'not_an_array' };
|
|
36
34
|
case 'object':
|
|
37
35
|
return { label: 'string instead of object', value: 'not_an_object' };
|
|
38
|
-
case '
|
|
36
|
+
case 'one_of':
|
|
39
37
|
return { label: 'number instead of enum', value: 42 };
|
|
40
38
|
default:
|
|
41
39
|
return null;
|
|
@@ -210,7 +208,7 @@ export const generate_input_test_cases = (input_schema, options) => {
|
|
|
210
208
|
}
|
|
211
209
|
// string length boundaries — `x`s are one UTF-16 unit and one code point
|
|
212
210
|
// each, so the over-`maxLength` string is over in either count
|
|
213
|
-
if (field.base_type === 'string'
|
|
211
|
+
if (field.base_type === 'string') {
|
|
214
212
|
if (typeof json.minLength === 'number' && json.minLength > 0) {
|
|
215
213
|
push_field_case(`empty string: ${field.name}`, '', 'value');
|
|
216
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA0H9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"identity_parity.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/identity_parity.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA0H9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA0B5C,uDAAuD;AACvD,MAAM,WAAW,8BAA8B;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAsKD,eAAO,MAAM,oCAAoC,GAChD,SAAS,8BAA8B,KACrC,IA6gBF,CAAC"}
|
|
@@ -112,6 +112,7 @@ import { BOOTSTRAP_TOKEN_LENGTH_MAX } from '../../auth/bootstrap_route_schema.js
|
|
|
112
112
|
import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
|
|
113
113
|
import { test_if } from './capabilities.js';
|
|
114
114
|
import { SPINE_ACCOUNT_BOOTSTRAP_PATH, SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_PASSWORD_PATH, SPINE_ACCOUNT_SIGNUP_PATH } from './spine_surface_constants.js';
|
|
115
|
+
import { SERDE_REFUSED_PARAMS_JSON } from '../rpc_envelope_cases.js';
|
|
115
116
|
/**
|
|
116
117
|
* The flat-REST `{error}` reason each terminal login/signup status carries on
|
|
117
118
|
* every spine — the assertion target that turns a status-only check into a
|
|
@@ -594,10 +595,14 @@ export const describe_identity_parity_cross_tests = (options) => {
|
|
|
594
595
|
// Bootstrap parses ahead of its window check (so the 400 holds after
|
|
595
596
|
// bootstrap completed); the password change parses only after its
|
|
596
597
|
// credential and session-only gates, so it needs a session, and an
|
|
597
|
-
// anonymous caller still hears 401.
|
|
598
|
+
// anonymous caller still hears 401. A body `serde_json` refuses (a lone
|
|
599
|
+
// surrogate escape, a number out of `f64` range, nesting 128 deep) is
|
|
600
|
+
// invalid JSON on both.
|
|
598
601
|
const MALFORMED_BODIES = [
|
|
599
602
|
['{', 'unparseable'],
|
|
600
|
-
['[]', 'a non-object array']
|
|
603
|
+
['[]', 'a non-object array'],
|
|
604
|
+
// what the Rust spine's `serde_json` refuses and `JSON.parse` accepts
|
|
605
|
+
...SERDE_REFUSED_PARAMS_JSON.map(([label, json]) => [json, label])
|
|
601
606
|
];
|
|
602
607
|
const assert_invalid_json_body = (got, label) => {
|
|
603
608
|
assert.strictEqual(got.status, 400, `${label} — status: ${got.text}`);
|
|
@@ -117,7 +117,7 @@ export interface DefaultInProcessSuiteOptions {
|
|
|
117
117
|
* factory input the Tier 1 suites read at their top level
|
|
118
118
|
* (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
|
|
119
119
|
* integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
120
|
-
* (`app_options.max_body_size`) — so the call site spreads once and adds
|
|
120
|
+
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
121
121
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
122
122
|
* `db_factories`, ...).
|
|
123
123
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,MAAM,YAAY,CAAC;AAepB;;;;;GAKG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IAClE;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,kCAAkC,CAAC,EAAE,OAAO,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,qBAAqB,KAAG,SAuEjC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,CAAC,CAAC,SAAS,4BAA4B,EAC5F,SAAS,CAAC,KACR;IACF,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"in_process_setup.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/in_process_setup.ts"],"names":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G;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,CAAC,CAAC,SAAS,4BAA4B,EAC5F,SAAS,CAAC,KACR;IACF,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtC,kBAAkB,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5C,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC;IAClC,QAAQ,EAAE,IAAI,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CAqClC,CAAC"}
|
|
@@ -115,7 +115,7 @@ export const default_in_process_setup = (options) => async () => {
|
|
|
115
115
|
* factory input the Tier 1 suites read at their top level
|
|
116
116
|
* (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
|
|
117
117
|
* integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
|
|
118
|
-
* (`app_options.max_body_size`) — so the call site spreads once and adds
|
|
118
|
+
* (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
|
|
119
119
|
* only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
|
|
120
120
|
* `db_factories`, ...).
|
|
121
121
|
*
|
|
@@ -165,6 +165,7 @@ export const default_in_process_suite_options = (options) => ({
|
|
|
165
165
|
bootstrap: options.bootstrap,
|
|
166
166
|
surface_route: options.app_options?.surface_route,
|
|
167
167
|
max_body_size: options.app_options?.max_body_size,
|
|
168
|
+
host_gate: options.app_options?.host_gate,
|
|
168
169
|
origin_carve_outs: options.app_options?.origin_carve_outs,
|
|
169
170
|
// `create_test_app` always passes a `daemon_token_state`
|
|
170
171
|
daemon_token: true
|
|
@@ -105,6 +105,24 @@ export declare const OriginConformanceMatchRow: import("@fuzdev/fuz_schema/schem
|
|
|
105
105
|
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
106
106
|
}>;
|
|
107
107
|
export type OriginConformanceMatchRow = Infer<typeof OriginConformanceMatchRow>;
|
|
108
|
+
/** A host row: a valid allowlist, the request's `Host` values, and the host gate's answer. */
|
|
109
|
+
export declare const OriginConformanceHostRow: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
110
|
+
patterns: string;
|
|
111
|
+
hosts: string[];
|
|
112
|
+
allowed: boolean;
|
|
113
|
+
note?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
patterns: string;
|
|
116
|
+
hosts: string[];
|
|
117
|
+
allowed: boolean;
|
|
118
|
+
note?: string | undefined;
|
|
119
|
+
}, "object", {
|
|
120
|
+
patterns: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
121
|
+
hosts: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
122
|
+
allowed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
123
|
+
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
124
|
+
}>;
|
|
125
|
+
export type OriginConformanceHostRow = Infer<typeof OriginConformanceHostRow>;
|
|
108
126
|
/** The conformance table, a `@fuzdev/fuz_schema` `object`. */
|
|
109
127
|
export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
110
128
|
match: {
|
|
@@ -113,6 +131,12 @@ export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
113
131
|
allowed: boolean;
|
|
114
132
|
note?: string | undefined;
|
|
115
133
|
}[];
|
|
134
|
+
host: {
|
|
135
|
+
patterns: string;
|
|
136
|
+
hosts: string[];
|
|
137
|
+
allowed: boolean;
|
|
138
|
+
note?: string | undefined;
|
|
139
|
+
}[];
|
|
116
140
|
parse: ({
|
|
117
141
|
ok: true;
|
|
118
142
|
raw: string;
|
|
@@ -132,6 +156,12 @@ export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
132
156
|
allowed: boolean;
|
|
133
157
|
note?: string | undefined;
|
|
134
158
|
}[];
|
|
159
|
+
host: {
|
|
160
|
+
patterns: string;
|
|
161
|
+
hosts: string[];
|
|
162
|
+
allowed: boolean;
|
|
163
|
+
note?: string | undefined;
|
|
164
|
+
}[];
|
|
135
165
|
parse: ({
|
|
136
166
|
ok: true;
|
|
137
167
|
raw: string;
|
|
@@ -280,6 +310,37 @@ export declare const OriginConformance: import("@fuzdev/fuz_schema/schema.ts").S
|
|
|
280
310
|
allowed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
281
311
|
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
282
312
|
}>>>;
|
|
313
|
+
host: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<{
|
|
314
|
+
patterns: string;
|
|
315
|
+
hosts: string[];
|
|
316
|
+
allowed: boolean;
|
|
317
|
+
note?: string | undefined;
|
|
318
|
+
}[], import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
319
|
+
patterns: string;
|
|
320
|
+
hosts: string[];
|
|
321
|
+
allowed: boolean;
|
|
322
|
+
note?: string | undefined;
|
|
323
|
+
}[], {
|
|
324
|
+
patterns: string;
|
|
325
|
+
hosts: string[];
|
|
326
|
+
allowed: boolean;
|
|
327
|
+
note?: string | undefined;
|
|
328
|
+
}[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
329
|
+
patterns: string;
|
|
330
|
+
hosts: string[];
|
|
331
|
+
allowed: boolean;
|
|
332
|
+
note?: string | undefined;
|
|
333
|
+
}, {
|
|
334
|
+
patterns: string;
|
|
335
|
+
hosts: string[];
|
|
336
|
+
allowed: boolean;
|
|
337
|
+
note?: string | undefined;
|
|
338
|
+
}, "object", {
|
|
339
|
+
patterns: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
340
|
+
hosts: import("@fuzdev/fuz_schema/schema.ts").Schema<string[], string[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
341
|
+
allowed: import("@fuzdev/fuz_schema/schema.ts").Schema<boolean, boolean, "boolean", undefined>;
|
|
342
|
+
note: import("@fuzdev/fuz_schema/schema.ts").Schema<string | undefined, string | undefined, "optional", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
343
|
+
}>>>;
|
|
283
344
|
}>;
|
|
284
345
|
export type OriginConformance = Infer<typeof OriginConformance>;
|
|
285
346
|
/** The committed table, resolved relative to this module. */
|
|
@@ -304,7 +365,7 @@ export interface OriginConformanceCheck {
|
|
|
304
365
|
* `{ok: true, allowed: true}`.
|
|
305
366
|
*
|
|
306
367
|
* @param table - the conformance table
|
|
307
|
-
* @returns one check per row
|
|
368
|
+
* @returns one check per row: parse rows, then match rows, then host rows
|
|
308
369
|
*/
|
|
309
370
|
export declare const to_origin_conformance_checks: (table: OriginConformance) => Array<OriginConformanceCheck>;
|
|
310
371
|
/**
|