@fuzdev/fuz_app 0.171.0 → 0.173.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 +1 -1
- package/dist/actions/perform_action.d.ts +4 -3
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +21 -16
- package/dist/http/CLAUDE.md +5 -4
- package/dist/http/error_schemas.d.ts +11 -5
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +12 -6
- 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 +4 -0
- package/dist/http/json_text.d.ts.map +1 -1
- package/dist/http/json_text.js +4 -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_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +8 -2
- package/dist/http/schema_helpers.d.ts +21 -7
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +31 -13
- 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 +5 -6
- 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 +34 -5
- 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/stubs.d.ts +11 -4
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +10 -5
- package/dist/ui/AppShell.svelte +1 -1
- package/dist/ui/PopoverButton.svelte +1 -1
- package/dist/ui/popover.svelte.d.ts +1 -1
- package/dist/ui/popover.svelte.js +1 -1
- package/package.json +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_text.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/json_text.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"json_text.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/json_text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAwFpC;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,OAM9C,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAE1E,qGAAqG;AACrG,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5B;AAID;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,eAAe,KAAG,OAAO,CAAC,cAAc,CAgB3E,CAAC"}
|
package/dist/http/json_text.js
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
* The check is one linear pass over the text after `JSON.parse` accepts it
|
|
15
15
|
* (`is_serde_json_text`): a few milliseconds a MiB, whatever the text holds.
|
|
16
16
|
*
|
|
17
|
+
* `"\u0000"` is not refused here: both parsers accept it. Postgres refuses it,
|
|
18
|
+
* so the input steps do, as an invalid value rather than invalid JSON
|
|
19
|
+
* (`scan_json_value` in `http/schema_helpers.ts`).
|
|
20
|
+
*
|
|
17
21
|
* @module
|
|
18
22
|
*/
|
|
19
23
|
/** The nesting depth `serde_json` refuses: a value nested this deep or deeper fails. */
|
package/dist/http/origin.d.ts
CHANGED
|
@@ -72,6 +72,15 @@ export interface AllowedOriginsError {
|
|
|
72
72
|
* @returns the reason as one line
|
|
73
73
|
*/
|
|
74
74
|
export declare const format_allowed_origins_error: (error: AllowedOriginsError) => string;
|
|
75
|
+
/**
|
|
76
|
+
* `value` in double quotes, ASCII-only: `"` and `\` backslash-escaped, every
|
|
77
|
+
* other UTF-16 code unit outside `\x20-\x7e` as `\uXXXX` — for a client- or
|
|
78
|
+
* env-written value shown in a log line. Twin of the Rust `fuz_sys::text::quoted`.
|
|
79
|
+
*
|
|
80
|
+
* @param value - the text to quote
|
|
81
|
+
* @returns the quoted text
|
|
82
|
+
*/
|
|
83
|
+
export declare const quote_ascii: (value: string) => string;
|
|
75
84
|
/**
|
|
76
85
|
* Parses an allowlist value (conventionally the `FUZ_ALLOWED_ORIGINS` env var)
|
|
77
86
|
* into regex matchers for request source verification.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/origin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,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AAM,WAAW,aAAa;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACnD,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;CAC1C;AAWD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,aAAa,GAAG,SAGlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC/B,QAAQ,MAAM,EACd,kBAAkB,aAAa,CAAC,MAAM,CAAC,KACrC,OAAqF,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,qBAAqB,GAEhC,kBAAkB,aAAa,CAAC,MAAM,CAAC,EACvC,aAAY,aAAa,CAAC,kBAAkB,CAAM,KAChD,OAaF,CAAC"}
|
package/dist/http/origin.js
CHANGED
|
@@ -110,9 +110,13 @@ export const format_allowed_origins_error = (error) => {
|
|
|
110
110
|
const NEEDS_ASCII_ESCAPE = /[^\x20-\x7e]|["\\]/g;
|
|
111
111
|
/**
|
|
112
112
|
* `value` in double quotes, ASCII-only: `"` and `\` backslash-escaped, every
|
|
113
|
-
* other UTF-16 code unit outside `\x20-\x7e` as `\uXXXX
|
|
113
|
+
* other UTF-16 code unit outside `\x20-\x7e` as `\uXXXX` — for a client- or
|
|
114
|
+
* env-written value shown in a log line. Twin of the Rust `fuz_sys::text::quoted`.
|
|
115
|
+
*
|
|
116
|
+
* @param value - the text to quote
|
|
117
|
+
* @returns the quoted text
|
|
114
118
|
*/
|
|
115
|
-
const quote_ascii = (value) => '"' +
|
|
119
|
+
export const quote_ascii = (value) => '"' +
|
|
116
120
|
value.replace(NEEDS_ASCII_ESCAPE, (c) => c === '"' || c === '\\' ? '\\' + c : '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0')) +
|
|
117
121
|
'"';
|
|
118
122
|
/** Printable ASCII without the space. */
|
|
@@ -57,16 +57,30 @@ export type OriginWildcard = {
|
|
|
57
57
|
* @returns its wildcard shape, or `null`
|
|
58
58
|
*/
|
|
59
59
|
export declare const origin_wildcard_kind: (pattern: OriginPattern) => OriginWildcard | null;
|
|
60
|
+
/**
|
|
61
|
+
* What the server adds to a wildcard entry's text. The TS spine adds no
|
|
62
|
+
* note of its own, so only the host gate shapes it — the Rust
|
|
63
|
+
* `OriginWildcardOptions` without its notes.
|
|
64
|
+
*/
|
|
65
|
+
export interface OriginWildcardOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The server mounts the `Host` check (`http/host.ts`), which the same
|
|
68
|
+
* entries widen. On by default, as the gate is.
|
|
69
|
+
*/
|
|
70
|
+
readonly host_gate: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** The host gate on, as `create_app_server` mounts it by default. */
|
|
73
|
+
export declare const ORIGIN_WILDCARD_OPTIONS_DEFAULT: OriginWildcardOptions;
|
|
60
74
|
/**
|
|
61
75
|
* What a wildcard in `pattern` admits — the text `admit_origin_wildcards`
|
|
62
|
-
* warns or refuses with; `null` for an exact entry. The
|
|
63
|
-
* `
|
|
64
|
-
* `OriginWildcardOptions::DEFAULT`.
|
|
76
|
+
* warns or refuses with; `null` for an exact entry. The Rust
|
|
77
|
+
* `origin_wildcard_warning` text word for word, with no notes.
|
|
65
78
|
*
|
|
66
79
|
* @param pattern - a parsed allowlist entry
|
|
80
|
+
* @param options - whether the server mounts the host gate
|
|
67
81
|
* @returns the text, or `null`
|
|
68
82
|
*/
|
|
69
|
-
export declare const origin_wildcard_warning: (pattern: OriginPattern) => string | null;
|
|
83
|
+
export declare const origin_wildcard_warning: (pattern: OriginPattern, options?: OriginWildcardOptions) => string | null;
|
|
70
84
|
/** One wildcard entry an allowlist holds, with what it admits. */
|
|
71
85
|
export interface OriginWildcardEntry {
|
|
72
86
|
readonly entry: string;
|
|
@@ -85,11 +99,12 @@ export interface OriginWildcardEntry {
|
|
|
85
99
|
* @param allowed - whether the operator opted in (`FUZ_ALLOW_ORIGIN_WILDCARDS=true`)
|
|
86
100
|
* @param origins_var - what the list is called in the refusal: the env var it
|
|
87
101
|
* was read from, or the option that carried it
|
|
102
|
+
* @param options - whether the server mounts the host gate, which the text names
|
|
88
103
|
* @returns the wildcard entries admitted, or the refusal — naming each
|
|
89
104
|
* unclassifiable matcher, or else each wildcard entry, what it admits, and
|
|
90
105
|
* the flag (the Rust spine's boot error, word for word)
|
|
91
106
|
*/
|
|
92
|
-
export declare const admit_origin_wildcards: (origins: ReadonlyArray<RegExp>, allowed: boolean, origins_var?: string) => Result<{
|
|
107
|
+
export declare const admit_origin_wildcards: (origins: ReadonlyArray<RegExp>, allowed: boolean, origins_var?: string, options?: OriginWildcardOptions) => Result<{
|
|
93
108
|
wildcards: Array<OriginWildcardEntry>;
|
|
94
109
|
}, {
|
|
95
110
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin_wildcard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/origin_wildcard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEpE,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,8DAA8D;AAC9D,MAAM,MAAM,YAAY;AACvB,4DAA4D;AAC1D;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB,qEAAqE;GACnE;IAAE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;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,aAAa,KAAG,cAAc,GAAG,IAc9E,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B;AAED,qEAAqE;AACrE,eAAO,MAAM,+BAA+B,EAAE,qBAA2C,CAAC;AAE1F;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,aAAa,EACtB,UAAS,qBAAuD,KAC9D,MAAM,GAAG,IA2CX,CAAC;AAEF,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,GAClC,SAAS,aAAa,CAAC,MAAM,CAAC,EAC9B,SAAS,OAAO,EAChB,cAAa,MAA4B,EACzC,UAAS,qBAAuD,KAC9D,MAAM,CAAC;IAAE,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAA;CAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CA8BvE,CAAC"}
|
|
@@ -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
|
}
|
|
@@ -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,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,EACN,KAA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,CAAC,CAAC,CAAC,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;AAgL5D;;;;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
|
@@ -24,7 +24,7 @@ import { is_db_checkout_error } from '../db/db_checkout_error.js';
|
|
|
24
24
|
import { ERROR_INVALID_JSON_BODY, ERROR_INVALID_REQUEST_BODY, ERROR_INVALID_ROUTE_PARAMS, ERROR_INVALID_QUERY_PARAMS, ERROR_INTERNAL_ERROR, ERROR_SERVICE_UNAVAILABLE, ERROR_UNSUPPORTED_CONTENT_TYPE } from './error_schemas.js';
|
|
25
25
|
import { is_post_content_type_refused } from './simple_request.js';
|
|
26
26
|
import { jsonrpc_error_code_to_http_status, jsonrpc_error_code_to_name, dev_only, to_thrown_jsonrpc_error } from './jsonrpc_errors.js';
|
|
27
|
-
import { is_null_schema } from './schema_helpers.js';
|
|
27
|
+
import { is_null_schema, scan_json_value } from './schema_helpers.js';
|
|
28
28
|
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';
|
|
@@ -131,7 +131,9 @@ const create_content_type_check = (spec) => {
|
|
|
131
131
|
* validated elsewhere, e.g. from `?params=` query string in RPC handlers)
|
|
132
132
|
* and for null-input routes (no body expected). For other routes with input
|
|
133
133
|
* schemas, returns a middleware that parses and validates the JSON body,
|
|
134
|
-
* storing the result on the context as `validated_input`.
|
|
134
|
+
* storing the result on the context as `validated_input`. A body that parses
|
|
135
|
+
* but holds U+0000 in a string or key is `invalid_request_body` ahead of the
|
|
136
|
+
* schema (`scan_json_value`), since Postgres refuses it. Input validation
|
|
135
137
|
* runs after the authorization phase and the post-authorization guards, so a
|
|
136
138
|
* caller they refuse never sees a parse failure; the authorization phase reads
|
|
137
139
|
* `acting` off the raw body itself (`read_route_acting` in
|
|
@@ -152,6 +154,10 @@ const create_input_validation = (input_schema, method) => {
|
|
|
152
154
|
if (typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
153
155
|
return c.json({ error: ERROR_INVALID_JSON_BODY }, 400);
|
|
154
156
|
}
|
|
157
|
+
// U+0000 in any string or key, which Postgres refuses to store, ahead of
|
|
158
|
+
// the schema, flat as the Rust spine's `parse_json_body` answers it
|
|
159
|
+
if (scan_json_value(body).nul)
|
|
160
|
+
return c.json({ error: ERROR_INVALID_REQUEST_BODY }, 400);
|
|
155
161
|
const result = parse(input_schema, body);
|
|
156
162
|
if (!result.ok) {
|
|
157
163
|
return c.json({
|
|
@@ -82,10 +82,16 @@ export declare const to_void_params: (raw_params: unknown) => unknown;
|
|
|
82
82
|
* @returns the value the input parse (`parse`) reads
|
|
83
83
|
*/
|
|
84
84
|
export declare const to_input_params: (input: AnySchema, raw_params: unknown) => unknown;
|
|
85
|
+
/** What one walk of a parsed JSON value finds (`scan_json_value`). */
|
|
86
|
+
export interface JsonValueScan {
|
|
87
|
+
/** An object holds an own `__proto__` key, at any depth (`ERROR_PARAMS_PROTO_KEY`). */
|
|
88
|
+
proto_key: boolean;
|
|
89
|
+
/** A string or an object key holds U+0000 (`ERROR_PARAMS_NUL`). */
|
|
90
|
+
nul: boolean;
|
|
91
|
+
}
|
|
85
92
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* (`ERROR_PARAMS_PROTO_KEY`).
|
|
93
|
+
* Walks a parsed JSON value once for the two things a request may not store,
|
|
94
|
+
* at any depth: an own `__proto__` key, and U+0000 in a string or a key.
|
|
89
95
|
*
|
|
90
96
|
* `JSON.parse` defines `"__proto__"` as an ordinary own key, but the first
|
|
91
97
|
* plain assignment that copies it (`target[key] = value`, as any shallow copy
|
|
@@ -94,15 +100,23 @@ export declare const to_input_params: (input: AnySchema, raw_params: unknown) =>
|
|
|
94
100
|
* own `constructor` or `prototype` key is inert on a plain object and is not
|
|
95
101
|
* checked.
|
|
96
102
|
*
|
|
103
|
+
* U+0000 is valid JSON (`"\u0000"`), but Postgres refuses it in `text` and in
|
|
104
|
+
* `jsonb`, so a value holding one fails its write with a 500. The dispatcher
|
|
105
|
+
* refuses either in `params` (`invalid_params`, the proto key first), and a
|
|
106
|
+
* route refuses a NUL in its JSON body (`invalid_request_body`), both after
|
|
107
|
+
* the authority gates as any input refusal is.
|
|
108
|
+
*
|
|
97
109
|
* Walks with an explicit stack rather than recursion: `JSON.parse` accepts
|
|
98
110
|
* nesting deep enough to overflow the call stack, and the walk is linear in
|
|
99
|
-
* the value's nodes, which the request body limit bounds.
|
|
100
|
-
*
|
|
111
|
+
* the value's nodes, which the request body limit bounds. It reads the parsed
|
|
112
|
+
* value, not the text, so of two duplicate keys only the kept one is walked —
|
|
113
|
+
* as on the Rust spine, whose `serde_json::Value` keeps the last too. The twin
|
|
114
|
+
* is `fuz_http::scan_json_value`.
|
|
101
115
|
*
|
|
102
116
|
* @param value - a value as `JSON.parse` produced it
|
|
103
|
-
* @returns
|
|
117
|
+
* @returns what the walk found
|
|
104
118
|
*/
|
|
105
|
-
export declare const
|
|
119
|
+
export declare const scan_json_value: (value: unknown) => JsonValueScan;
|
|
106
120
|
/**
|
|
107
121
|
* `parse(schema, value)`, except that keys the schema doesn't declare are
|
|
108
122
|
* dropped rather than refused — the forward-compatible read of a payload a
|
|
@@ -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,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,OA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A;CAAE,EAC/E,YAAY,MAAM,KAChB,OACyF,CAAC;AAE7F;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM;IACL,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CACtE,EACD,YAAY,MAAM,KAChB,OAAgG,CAAC"}
|
|
@@ -73,9 +73,8 @@ export const to_void_params = (raw_params) => {
|
|
|
73
73
|
*/
|
|
74
74
|
export const to_input_params = (input, raw_params) => is_void_schema(input) ? to_void_params(raw_params) : (raw_params ?? {});
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* (`ERROR_PARAMS_PROTO_KEY`).
|
|
76
|
+
* Walks a parsed JSON value once for the two things a request may not store,
|
|
77
|
+
* at any depth: an own `__proto__` key, and U+0000 in a string or a key.
|
|
79
78
|
*
|
|
80
79
|
* `JSON.parse` defines `"__proto__"` as an ordinary own key, but the first
|
|
81
80
|
* plain assignment that copies it (`target[key] = value`, as any shallow copy
|
|
@@ -84,18 +83,33 @@ export const to_input_params = (input, raw_params) => is_void_schema(input) ? to
|
|
|
84
83
|
* own `constructor` or `prototype` key is inert on a plain object and is not
|
|
85
84
|
* checked.
|
|
86
85
|
*
|
|
86
|
+
* U+0000 is valid JSON (`"\u0000"`), but Postgres refuses it in `text` and in
|
|
87
|
+
* `jsonb`, so a value holding one fails its write with a 500. The dispatcher
|
|
88
|
+
* refuses either in `params` (`invalid_params`, the proto key first), and a
|
|
89
|
+
* route refuses a NUL in its JSON body (`invalid_request_body`), both after
|
|
90
|
+
* the authority gates as any input refusal is.
|
|
91
|
+
*
|
|
87
92
|
* Walks with an explicit stack rather than recursion: `JSON.parse` accepts
|
|
88
93
|
* nesting deep enough to overflow the call stack, and the walk is linear in
|
|
89
|
-
* the value's nodes, which the request body limit bounds.
|
|
90
|
-
*
|
|
94
|
+
* the value's nodes, which the request body limit bounds. It reads the parsed
|
|
95
|
+
* value, not the text, so of two duplicate keys only the kept one is walked —
|
|
96
|
+
* as on the Rust spine, whose `serde_json::Value` keeps the last too. The twin
|
|
97
|
+
* is `fuz_http::scan_json_value`.
|
|
91
98
|
*
|
|
92
99
|
* @param value - a value as `JSON.parse` produced it
|
|
93
|
-
* @returns
|
|
100
|
+
* @returns what the walk found
|
|
94
101
|
*/
|
|
95
|
-
export const
|
|
102
|
+
export const scan_json_value = (value) => {
|
|
103
|
+
let proto_key = false;
|
|
104
|
+
let nul = false;
|
|
96
105
|
const stack = [value];
|
|
97
|
-
while (stack.length > 0) {
|
|
106
|
+
while (stack.length > 0 && !(proto_key && nul)) {
|
|
98
107
|
const current = stack.pop();
|
|
108
|
+
if (typeof current === 'string') {
|
|
109
|
+
if (!nul && current.includes('\0'))
|
|
110
|
+
nul = true;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
99
113
|
if (typeof current !== 'object' || current === null)
|
|
100
114
|
continue;
|
|
101
115
|
if (Array.isArray(current)) {
|
|
@@ -103,12 +117,16 @@ export const json_has_own_proto_key = (value) => {
|
|
|
103
117
|
stack.push(item);
|
|
104
118
|
continue;
|
|
105
119
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
const record = current;
|
|
121
|
+
for (const key of Object.keys(record)) {
|
|
122
|
+
if (key === '__proto__')
|
|
123
|
+
proto_key = true;
|
|
124
|
+
if (!nul && key.includes('\0'))
|
|
125
|
+
nul = true;
|
|
126
|
+
stack.push(record[key]);
|
|
127
|
+
}
|
|
110
128
|
}
|
|
111
|
-
return
|
|
129
|
+
return { proto_key, nul };
|
|
112
130
|
};
|
|
113
131
|
/**
|
|
114
132
|
* `parse(schema, value)`, except that keys the schema doesn't declare are
|
|
@@ -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,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAIN,KAAK,WAAW,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,WAAW,EAMX,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,y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AoB,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
|
|
@@ -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
|
|
@@ -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;A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,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
|