@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.
Files changed (53) hide show
  1. package/dist/actions/CLAUDE.md +1 -1
  2. package/dist/actions/perform_action.d.ts +4 -3
  3. package/dist/actions/perform_action.d.ts.map +1 -1
  4. package/dist/actions/perform_action.js +21 -16
  5. package/dist/http/CLAUDE.md +5 -4
  6. package/dist/http/error_schemas.d.ts +11 -5
  7. package/dist/http/error_schemas.d.ts.map +1 -1
  8. package/dist/http/error_schemas.js +12 -6
  9. package/dist/http/host.d.ts +137 -0
  10. package/dist/http/host.d.ts.map +1 -0
  11. package/dist/http/host.js +203 -0
  12. package/dist/http/json_text.d.ts +4 -0
  13. package/dist/http/json_text.d.ts.map +1 -1
  14. package/dist/http/json_text.js +4 -0
  15. package/dist/http/origin.d.ts +9 -0
  16. package/dist/http/origin.d.ts.map +1 -1
  17. package/dist/http/origin.js +6 -2
  18. package/dist/http/origin_wildcard.d.ts +20 -5
  19. package/dist/http/origin_wildcard.d.ts.map +1 -1
  20. package/dist/http/origin_wildcard.js +22 -10
  21. package/dist/http/route_spec.d.ts.map +1 -1
  22. package/dist/http/route_spec.js +8 -2
  23. package/dist/http/schema_helpers.d.ts +21 -7
  24. package/dist/http/schema_helpers.d.ts.map +1 -1
  25. package/dist/http/schema_helpers.js +31 -13
  26. package/dist/server/app_server.d.ts +10 -0
  27. package/dist/server/app_server.d.ts.map +1 -1
  28. package/dist/server/app_server.js +14 -3
  29. package/dist/testing/CLAUDE.md +5 -6
  30. package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
  31. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  32. package/dist/testing/cross_backend/in_process_setup.js +2 -1
  33. package/dist/testing/cross_backend/origin_conformance.d.ts +62 -1
  34. package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
  35. package/dist/testing/cross_backend/origin_conformance.js +34 -5
  36. package/dist/testing/cross_backend/origin_conformance.json +330 -0
  37. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -6
  38. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  39. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -15
  40. package/dist/testing/cross_backend/testing_origin_check.d.ts +16 -1
  41. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  42. package/dist/testing/cross_backend/testing_origin_check.js +12 -4
  43. package/dist/testing/cross_backend/testing_server_core.d.ts +2 -2
  44. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  45. package/dist/testing/cross_backend/testing_server_core.js +3 -3
  46. package/dist/testing/stubs.d.ts +11 -4
  47. package/dist/testing/stubs.d.ts.map +1 -1
  48. package/dist/testing/stubs.js +10 -5
  49. package/dist/ui/AppShell.svelte +1 -1
  50. package/dist/ui/PopoverButton.svelte +1 -1
  51. package/dist/ui/popover.svelte.d.ts +1 -1
  52. package/dist/ui/popover.svelte.js +1 -1
  53. package/package.json +8 -4
@@ -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, parse rows first
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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"origin_conformance.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/origin_conformance.ts"],"names":[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,IAiBF,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,iCAAiC,GAAG,wBAAwB,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,uCAAuC,GACnD,SAAS,iCAAiC,KACxC,IA6CF,CAAC"}
@@ -4,7 +4,8 @@ import '../assert_dev_env.js';
4
4
  * runs it against each backend over the wire.
5
5
  *
6
6
  * `origin_conformance.json` (beside this module) is the one statement of the
7
- * allowlist grammar and matcher both spines implement. It holds two tables:
7
+ * allowlist grammar and matcher, and of the host gate's check over them, both
8
+ * spines implement. It holds three tables:
8
9
  *
9
10
  * - **parse** rows — `{raw, ok: true}` or `{raw, errors: [{index?, kind}]}`:
10
11
  * an allowlist value (as `FUZ_ALLOWED_ORIGINS` would carry it) and whether
@@ -12,18 +13,26 @@ import '../assert_dev_env.js';
12
13
  * list-level refusal) and its `AllowedOriginsErrorKind`.
13
14
  * - **match** rows — `{patterns, origin, allowed}`: a valid allowlist, one
14
15
  * `Origin` value (`null` for none), and the request-level answer.
16
+ * - **host** rows — `{patterns, hosts, allowed}`: a valid allowlist, the
17
+ * request's `Host` values (`[]` for none), and the host gate's answer.
15
18
  *
16
19
  * A row may carry a `note` for the reader. The TS unit test reads the table
17
20
  * directly; `describe_origin_conformance_cross_tests` sends every row to a
18
21
  * backend's `_testing_origin_check` action and compares the answer, so the
19
- * Rust spine is held to the same rows without reading this file.
22
+ * Rust spine is held to the same rows without reading this file. A row whose
23
+ * input holds U+0000 can't reach the action: the dispatcher refuses NUL in
24
+ * params (`params_nul`) before any handler, and that refusal is what the
25
+ * suite asserts for it. Its verdict is pinned by the TS unit test and by
26
+ * `fuz_http`'s own host and origin tests.
20
27
  *
21
28
  * @module
22
29
  */
23
30
  import { readFileSync } from 'node:fs';
24
31
  import { assert, describe, test } from 'vitest';
25
32
  import { array, boolean, literal, min_length, min_value, nullable, number, object, optional, parse, parse_or_throw, pipe, safe_integer, string, union } from '@fuzdev/fuz_schema/schema.ts';
33
+ import { ERROR_PARAMS_NUL } from '../../http/error_schemas.js';
26
34
  import { AllowedOriginsErrorKind } from '../../http/origin.js';
35
+ import { scan_json_value } from '../../http/schema_helpers.js';
27
36
  import { cross_rpc_call } from './cross_rpc.js';
28
37
  import { SPINE_RPC_PATH } from './spine_surface_constants.js';
29
38
  import { TestingOriginCheckOutput, testing_origin_check_action_spec } from './testing_origin_check.js';
@@ -48,10 +57,18 @@ export const OriginConformanceMatchRow = object({
48
57
  allowed: boolean,
49
58
  note: optional(string)
50
59
  });
60
+ /** A host row: a valid allowlist, the request's `Host` values, and the host gate's answer. */
61
+ export const OriginConformanceHostRow = object({
62
+ patterns: string,
63
+ hosts: array(string),
64
+ allowed: boolean,
65
+ note: optional(string)
66
+ });
51
67
  /** The conformance table, a `@fuzdev/fuz_schema` `object`. */
52
68
  export const OriginConformance = object({
53
69
  parse: pipe(array(OriginConformanceParseRow), min_length(1)),
54
- match: pipe(array(OriginConformanceMatchRow), min_length(1))
70
+ match: pipe(array(OriginConformanceMatchRow), min_length(1)),
71
+ host: pipe(array(OriginConformanceHostRow), min_length(1))
55
72
  });
56
73
  /** The committed table, resolved relative to this module. */
57
74
  export const ORIGIN_CONFORMANCE_URL = new URL('./origin_conformance.json', import.meta.url);
@@ -68,7 +85,7 @@ export const load_origin_conformance = () => parse_or_throw(OriginConformance, J
68
85
  * `{ok: true, allowed: true}`.
69
86
  *
70
87
  * @param table - the conformance table
71
- * @returns one check per row, parse rows first
88
+ * @returns one check per row: parse rows, then match rows, then host rows
72
89
  */
73
90
  export const to_origin_conformance_checks = (table) => [
74
91
  ...table.parse.map((row) => ({
@@ -82,6 +99,11 @@ export const to_origin_conformance_checks = (table) => [
82
99
  label: `match ${JSON.stringify(row.patterns)} × ${JSON.stringify(row.origin)}`,
83
100
  input: { patterns: row.patterns, origin: row.origin },
84
101
  expected: { ok: true, allowed: row.allowed }
102
+ })),
103
+ ...table.host.map((row) => ({
104
+ label: `host ${JSON.stringify(row.patterns)} × ${JSON.stringify(row.hosts)}`,
105
+ input: { patterns: row.patterns, origin: null, hosts: [...row.hosts] },
106
+ expected: { ok: true, allowed: row.allowed }
85
107
  }))
86
108
  ];
87
109
  /**
@@ -124,13 +146,20 @@ export const describe_origin_conformance_cross_tests = (options) => {
124
146
  const transport = fixture.fresh_transport({ origin: null });
125
147
  const headers = fixture.create_daemon_token_headers();
126
148
  const answers = [];
149
+ const wire_checks = [];
127
150
  for (const check of checks) {
151
+ if (scan_json_value(check.input).nul) {
152
+ const refused = await cross_rpc_call(transport, rpc_path, testing_origin_check_action_spec.method, check.input, headers);
153
+ assert.deepStrictEqual(refused.error?.data, { reason: ERROR_PARAMS_NUL }, `${check.label}: a NUL in params is refused before the action`);
154
+ continue;
155
+ }
156
+ wire_checks.push(check);
128
157
  const res = await cross_rpc_call(transport, rpc_path, testing_origin_check_action_spec.method, check.input, headers);
129
158
  assert.ok(res.ok, `${check.label}: RPC failed: ${JSON.stringify(res.error)}`);
130
159
  const parsed = parse(TestingOriginCheckOutput, res.result);
131
160
  answers.push(parsed.ok ? parsed.value : res.result);
132
161
  }
133
- assert_origin_conformance(checks, answers, 'backend');
162
+ assert_origin_conformance(wire_checks, answers, 'backend');
134
163
  });
135
164
  });
136
165
  };
@@ -1675,5 +1675,335 @@
1675
1675
  "allowed": false,
1676
1676
  "note": "fullwidth digits are not digits"
1677
1677
  }
1678
+ ],
1679
+ "host": [
1680
+ {
1681
+ "patterns": "https://app.example.com",
1682
+ "hosts": [],
1683
+ "allowed": true,
1684
+ "note": "a request without a Host passes"
1685
+ },
1686
+ {
1687
+ "patterns": "https://app.example.com",
1688
+ "hosts": [
1689
+ "localhost"
1690
+ ],
1691
+ "allowed": true
1692
+ },
1693
+ {
1694
+ "patterns": "https://app.example.com",
1695
+ "hosts": [
1696
+ "localhost:4460"
1697
+ ],
1698
+ "allowed": true,
1699
+ "note": "a loopback name passes at any port"
1700
+ },
1701
+ {
1702
+ "patterns": "https://app.example.com",
1703
+ "hosts": [
1704
+ "LOCALHOST:5173"
1705
+ ],
1706
+ "allowed": true,
1707
+ "note": "the name is case-insensitive"
1708
+ },
1709
+ {
1710
+ "patterns": "https://app.example.com",
1711
+ "hosts": [
1712
+ "127.0.0.1"
1713
+ ],
1714
+ "allowed": true
1715
+ },
1716
+ {
1717
+ "patterns": "https://app.example.com",
1718
+ "hosts": [
1719
+ "127.0.0.1:4460"
1720
+ ],
1721
+ "allowed": true
1722
+ },
1723
+ {
1724
+ "patterns": "https://app.example.com",
1725
+ "hosts": [
1726
+ "127.1.2.3:80"
1727
+ ],
1728
+ "allowed": true,
1729
+ "note": "all of 127.0.0.0/8 is loopback"
1730
+ },
1731
+ {
1732
+ "patterns": "https://app.example.com",
1733
+ "hosts": [
1734
+ "[::1]"
1735
+ ],
1736
+ "allowed": true
1737
+ },
1738
+ {
1739
+ "patterns": "https://app.example.com",
1740
+ "hosts": [
1741
+ "[::1]:4460"
1742
+ ],
1743
+ "allowed": true
1744
+ },
1745
+ {
1746
+ "patterns": "https://app.example.com",
1747
+ "hosts": [
1748
+ "[0:0:0:0:0:0:0:1]"
1749
+ ],
1750
+ "allowed": true,
1751
+ "note": "::1 in any IPv6 spelling"
1752
+ },
1753
+ {
1754
+ "patterns": "https://app.example.com",
1755
+ "hosts": [
1756
+ "localhost:65535"
1757
+ ],
1758
+ "allowed": true
1759
+ },
1760
+ {
1761
+ "patterns": "https://app.example.com",
1762
+ "hosts": [
1763
+ "[::1]:1"
1764
+ ],
1765
+ "allowed": true
1766
+ },
1767
+ {
1768
+ "patterns": "https://app.example.com",
1769
+ "hosts": [
1770
+ "[::1]junk"
1771
+ ],
1772
+ "allowed": false,
1773
+ "note": "anything after the name but a port refuses it"
1774
+ },
1775
+ {
1776
+ "patterns": "https://app.example.com",
1777
+ "hosts": [
1778
+ "[::1]:"
1779
+ ],
1780
+ "allowed": false
1781
+ },
1782
+ {
1783
+ "patterns": "https://app.example.com",
1784
+ "hosts": [
1785
+ "[::1]:abc"
1786
+ ],
1787
+ "allowed": false
1788
+ },
1789
+ {
1790
+ "patterns": "https://app.example.com",
1791
+ "hosts": [
1792
+ "[::1"
1793
+ ],
1794
+ "allowed": false
1795
+ },
1796
+ {
1797
+ "patterns": "https://app.example.com",
1798
+ "hosts": [
1799
+ "localhost:abc"
1800
+ ],
1801
+ "allowed": false
1802
+ },
1803
+ {
1804
+ "patterns": "https://app.example.com",
1805
+ "hosts": [
1806
+ "localhost: 1"
1807
+ ],
1808
+ "allowed": false
1809
+ },
1810
+ {
1811
+ "patterns": "https://app.example.com",
1812
+ "hosts": [
1813
+ "localhost:"
1814
+ ],
1815
+ "allowed": false
1816
+ },
1817
+ {
1818
+ "patterns": "https://app.example.com",
1819
+ "hosts": [
1820
+ "localhost:+1"
1821
+ ],
1822
+ "allowed": false
1823
+ },
1824
+ {
1825
+ "patterns": "https://app.example.com",
1826
+ "hosts": [
1827
+ "localhost:65536"
1828
+ ],
1829
+ "allowed": false,
1830
+ "note": "a port above 65535 is not a port"
1831
+ },
1832
+ {
1833
+ "patterns": "https://app.example.com",
1834
+ "hosts": [
1835
+ "127.0.0.1:4460x"
1836
+ ],
1837
+ "allowed": false
1838
+ },
1839
+ {
1840
+ "patterns": "https://app.example.com",
1841
+ "hosts": [
1842
+ "127.0.0.01"
1843
+ ],
1844
+ "allowed": false,
1845
+ "note": "an IPv4 octet with a leading zero is not an address"
1846
+ },
1847
+ {
1848
+ "patterns": "http://localhost:4460",
1849
+ "hosts": [
1850
+ "evil.example.com"
1851
+ ],
1852
+ "allowed": false
1853
+ },
1854
+ {
1855
+ "patterns": "http://localhost:4460",
1856
+ "hosts": [
1857
+ "evil.example.com:4460"
1858
+ ],
1859
+ "allowed": false
1860
+ },
1861
+ {
1862
+ "patterns": "http://localhost:4460",
1863
+ "hosts": [
1864
+ "localhost.evil.example.com:4460"
1865
+ ],
1866
+ "allowed": false
1867
+ },
1868
+ {
1869
+ "patterns": "http://localhost:4460",
1870
+ "hosts": [
1871
+ "127.0.0.1.nip.io:4460"
1872
+ ],
1873
+ "allowed": false,
1874
+ "note": "a name that resolves to loopback is not loopback"
1875
+ },
1876
+ {
1877
+ "patterns": "http://localhost:4460",
1878
+ "hosts": [
1879
+ "0.0.0.0:4460"
1880
+ ],
1881
+ "allowed": false
1882
+ },
1883
+ {
1884
+ "patterns": "http://localhost:4460",
1885
+ "hosts": [
1886
+ "[::ffff:127.0.0.1]:4460"
1887
+ ],
1888
+ "allowed": false,
1889
+ "note": "an IPv4-mapped address is not loopback"
1890
+ },
1891
+ {
1892
+ "patterns": "http://localhost:4460",
1893
+ "hosts": [
1894
+ "10.0.0.1:4460"
1895
+ ],
1896
+ "allowed": false
1897
+ },
1898
+ {
1899
+ "patterns": "http://localhost:4460",
1900
+ "hosts": [
1901
+ ""
1902
+ ],
1903
+ "allowed": false,
1904
+ "note": "an empty Host names nothing"
1905
+ },
1906
+ {
1907
+ "patterns": "https://zzz.example.com, http://*.fuz.dev:*",
1908
+ "hosts": [
1909
+ "zzz.example.com"
1910
+ ],
1911
+ "allowed": true,
1912
+ "note": "a host an allowed origin names passes"
1913
+ },
1914
+ {
1915
+ "patterns": "https://zzz.example.com, http://*.fuz.dev:*",
1916
+ "hosts": [
1917
+ "ZZZ.example.com"
1918
+ ],
1919
+ "allowed": true
1920
+ },
1921
+ {
1922
+ "patterns": "https://zzz.example.com, http://*.fuz.dev:*",
1923
+ "hosts": [
1924
+ "api.fuz.dev:8080"
1925
+ ],
1926
+ "allowed": true,
1927
+ "note": "a wildcard entry admits the hosts it admits as origins"
1928
+ },
1929
+ {
1930
+ "patterns": "https://zzz.example.com, http://*.fuz.dev:*",
1931
+ "hosts": [
1932
+ "zzz.example.com:8443"
1933
+ ],
1934
+ "allowed": false,
1935
+ "note": "an entry without a port admits the host without one"
1936
+ },
1937
+ {
1938
+ "patterns": "https://zzz.example.com, http://*.fuz.dev:*",
1939
+ "hosts": [
1940
+ "fuz.dev"
1941
+ ],
1942
+ "allowed": false
1943
+ },
1944
+ {
1945
+ "patterns": "http://localhost:*, https://zzz.example.com",
1946
+ "hosts": [
1947
+ "evil.example.com@zzz.example.com"
1948
+ ],
1949
+ "allowed": false,
1950
+ "note": "userinfo would reshape the origin"
1951
+ },
1952
+ {
1953
+ "patterns": "http://localhost:*, https://zzz.example.com",
1954
+ "hosts": [
1955
+ "zzz.example.com/x"
1956
+ ],
1957
+ "allowed": false,
1958
+ "note": "a path would reshape the origin"
1959
+ },
1960
+ {
1961
+ "patterns": "http://localhost:4460",
1962
+ "hosts": [
1963
+ "localhost:4460",
1964
+ "localhost:4460"
1965
+ ],
1966
+ "allowed": false,
1967
+ "note": "more than one Host is refused, even the same one twice"
1968
+ },
1969
+ {
1970
+ "patterns": "http://localhost:4460",
1971
+ "hosts": [
1972
+ "localhost:4460",
1973
+ "rebind.example.com"
1974
+ ],
1975
+ "allowed": false
1976
+ },
1977
+ {
1978
+ "patterns": "http://localhost:4460",
1979
+ "hosts": [
1980
+ "localhost:4460, rebind.example.com"
1981
+ ],
1982
+ "allowed": false,
1983
+ "note": "two Hosts joined into one value, as the runtimes join them"
1984
+ },
1985
+ {
1986
+ "patterns": "http://localhost:4460",
1987
+ "hosts": [
1988
+ "localhost\u0000"
1989
+ ],
1990
+ "allowed": false,
1991
+ "note": "a value outside header text is refused"
1992
+ },
1993
+ {
1994
+ "patterns": "http://localhost:4460",
1995
+ "hosts": [
1996
+ "localhost\u007f"
1997
+ ],
1998
+ "allowed": false
1999
+ },
2000
+ {
2001
+ "patterns": "http://localhost:4460",
2002
+ "hosts": [
2003
+ "localhost\t"
2004
+ ],
2005
+ "allowed": false,
2006
+ "note": "a tab is header text but names no host"
2007
+ }
1678
2008
  ]
1679
2009
  }
@@ -66,11 +66,11 @@ export interface RustSpineConsumerSurfaceSpecOptions extends RustSpineConsumerRp
66
66
  /** The backend's session config — its cookie name above all. */
67
67
  readonly session_options: SessionOptions<string>;
68
68
  /**
69
- * Whether the server turns on the spine's opt-in host gate
70
- * (`fuz_http::StackOptions::host_gate`), declared as a `host_validation`
71
- * layer at the head of the middleware list.
69
+ * Whether the server mounts the spine's host gate
70
+ * (`fuz_http::StackOptions::host_gate`, on by default), declared as the
71
+ * `host` layer `create_test_app_surface_spec` lists.
72
72
  *
73
- * @default false
73
+ * @default true
74
74
  */
75
75
  readonly host_gate?: boolean;
76
76
  }
@@ -89,8 +89,8 @@ export declare const create_rust_spine_consumer_rpc_endpoints: (options: RustSpi
89
89
  * on `create_test_app_surface_spec`: the spine routes (health, the account
90
90
  * router's paths, signup, and bootstrap as a `surface_only` shape), the RPC
91
91
  * endpoint from `create_rust_spine_consumer_rpc_endpoints`, the daemon-token
92
- * layer every consumer test binary wires, and — with `host_gate` — the
93
- * `host_validation` layer at the head of the middleware list.
92
+ * layer every consumer test binary wires, and — unless `host_gate` is
93
+ * `false` — the host gate's `host` layer.
94
94
  *
95
95
  * @param options - the consumer's session config, action specs, extras and roles
96
96
  * @returns the surface spec, for `describe_spine_cross_suites`'s `surface_source`
@@ -1 +1 @@
1
- {"version":3,"file":"rust_spine_consumer_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/rust_spine_consumer_surface.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,8BAA8B,CAAC;AAM/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAI3E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,wDAAyD,CAAC;AAK3F,8DAA8D;AAC9D,MAAM,WAAW,oCAAoC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IACzE,yFAAyF;IACzF,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjD,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,6DAA6D;AAC7D,MAAM,WAAW,mCAAoC,SAAQ,oCAAoC;IAChG,gEAAgE;IAChE,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,oCAAoC,KAC3C,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,eAAe,CAAC,CA+BpD,CAAC;AAiCF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uCAAuC,GACnD,SAAS,mCAAmC,KAC1C,cAoBA,CAAC"}
1
+ {"version":3,"file":"rust_spine_consumer_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/rust_spine_consumer_surface.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAA6B,MAAM,8BAA8B,CAAC;AAM/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAI3E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,wDAAyD,CAAC;AAK3F,8DAA8D;AAC9D,MAAM,WAAW,oCAAoC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IACzE,yFAAyF;IACzF,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjD,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,6DAA6D;AAC7D,MAAM,WAAW,mCAAoC,SAAQ,oCAAoC;IAChG,gEAAgE;IAChE,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wCAAwC,GACpD,SAAS,oCAAoC,KAC3C,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,eAAe,CAAC,CA+BpD,CAAC;AAiCF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uCAAuC,GACnD,SAAS,mCAAmC,KAC1C,cAUA,CAAC"}
@@ -4,9 +4,8 @@ import { account_status_route_shape, create_account_route_shapes } from '../../a
4
4
  import { create_signup_route_shape } from '../../auth/signup_route_schema.js';
5
5
  import { create_standard_rpc_actions } from '../../auth/standard_rpc_actions.js';
6
6
  import { create_health_route_spec } from '../../http/common_routes.js';
7
- import { REST_FORBIDDEN_HOST } from '../../http/error_schemas.js';
8
7
  import { prefix_route_specs } from '../../http/route_spec.js';
9
- import { create_test_app_surface_spec, stub_mw, stub_route_spec } from '../stubs.js';
8
+ import { create_test_app_surface_spec, stub_route_spec } from '../stubs.js';
10
9
  import { SPINE_ACCOUNT_PATH_PREFIX, SPINE_RPC_PATH } from './spine_surface_constants.js';
11
10
  /**
12
11
  * The routes `fuz_auth::account_router` mounts, relative to `/api/account`. An
@@ -85,8 +84,8 @@ const create_spine_consumer_route_specs = (ctx) => {
85
84
  * on `create_test_app_surface_spec`: the spine routes (health, the account
86
85
  * router's paths, signup, and bootstrap as a `surface_only` shape), the RPC
87
86
  * endpoint from `create_rust_spine_consumer_rpc_endpoints`, the daemon-token
88
- * layer every consumer test binary wires, and — with `host_gate` — the
89
- * `host_validation` layer at the head of the middleware list.
87
+ * layer every consumer test binary wires, and — unless `host_gate` is
88
+ * `false` — the host gate's `host` layer.
90
89
  *
91
90
  * @param options - the consumer's session config, action specs, extras and roles
92
91
  * @returns the surface spec, for `describe_spine_cross_suites`'s `surface_source`
@@ -101,15 +100,5 @@ export const create_rust_spine_consumer_surface_spec = (options) => create_test_
101
100
  bootstrap: { mode: 'surface_only' },
102
101
  // consumer test binaries wire a daemon-token state (production ones don't)
103
102
  daemon_token: true,
104
- transform_middleware: options.host_gate
105
- ? (specs) => [
106
- {
107
- name: 'host_validation',
108
- path: '*',
109
- handler: stub_mw,
110
- errors: [REST_FORBIDDEN_HOST]
111
- },
112
- ...specs
113
- ]
114
- : undefined
103
+ host_gate: options.host_gate ?? true
115
104
  });
@@ -17,14 +17,21 @@ import { type RpcAction } from '../../actions/action_types.js';
17
17
  export declare const TestingOriginCheckInput: import("@fuzdev/fuz_schema/schema.ts").Schema<{
18
18
  patterns: string;
19
19
  origin: string | null;
20
+ hosts?: string[] | undefined;
20
21
  }, {
21
22
  patterns: string;
22
23
  origin: string | null;
24
+ hosts?: string[] | undefined;
23
25
  }, "object", {
24
26
  /** An allowlist value, as `FUZ_ALLOWED_ORIGINS` would carry it. */
25
27
  patterns: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
26
28
  /** One `Origin` header's value, or `null` for a request without one. */
27
29
  origin: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
30
+ /**
31
+ * The request's `Host` header values (`[]` for none), checked by the host
32
+ * gate (`allows_request_hosts`); absent, the host gate isn't asked.
33
+ */
34
+ hosts: 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[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
28
35
  }>;
29
36
  export type TestingOriginCheckInput = Infer<typeof TestingOriginCheckInput>;
30
37
  /**
@@ -94,7 +101,8 @@ export type TestingOriginCheckOutput = Infer<typeof TestingOriginCheckOutput>;
94
101
  /**
95
102
  * Answer one `_testing_origin_check` input: parse `patterns` with
96
103
  * `parse_allowed_origins`, then run the request-level check for one `Origin`
97
- * carrying `origin` (`null` — no `Origin` — passes). The action handler and
104
+ * carrying `origin` (`null` — no `Origin` — passes), and with `hosts` the host
105
+ * gate's check of those `Host` values too. The action handler and
98
106
  * the conformance table's unit test both call this, so the table checks the
99
107
  * same function the wire serves.
100
108
  *
@@ -129,14 +137,21 @@ export declare const testing_origin_check_action_spec: {
129
137
  readonly input: import("@fuzdev/fuz_schema/schema.ts").Schema<{
130
138
  patterns: string;
131
139
  origin: string | null;
140
+ hosts?: string[] | undefined;
132
141
  }, {
133
142
  patterns: string;
134
143
  origin: string | null;
144
+ hosts?: string[] | undefined;
135
145
  }, "object", {
136
146
  /** An allowlist value, as `FUZ_ALLOWED_ORIGINS` would carry it. */
137
147
  patterns: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
138
148
  /** One `Origin` header's value, or `null` for a request without one. */
139
149
  origin: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
150
+ /**
151
+ * The request's `Host` header values (`[]` for none), checked by the host
152
+ * gate (`allows_request_hosts`); absent, the host gate isn't asked.
153
+ */
154
+ hosts: 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[], "array", import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
140
155
  }>;
141
156
  readonly output: import("@fuzdev/fuz_schema/schema.ts").Schema<{
142
157
  ok: true;