agentfootprint 9.114.2 → 9.115.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/AGENTS.md +1 -1
- package/CAPABILITIES.md +3 -0
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/adapters/hosting/agentCoreA2A.js +5 -0
- package/dist/adapters/hosting/agentCoreA2A.js.map +1 -1
- package/dist/adapters/hosting/agentcore.js +5 -0
- package/dist/adapters/hosting/agentcore.js.map +1 -1
- package/dist/adapters/hosting/foundryResponses.js +5 -0
- package/dist/adapters/hosting/foundryResponses.js.map +1 -1
- package/dist/adapters/observability/agentcore.js +18 -5
- package/dist/adapters/observability/agentcore.js.map +1 -1
- package/dist/adapters/observability/audit.js +17 -4
- package/dist/adapters/observability/audit.js.map +1 -1
- package/dist/adapters/observability/otel.js +890 -33
- package/dist/adapters/observability/otel.js.map +1 -1
- package/dist/artifacts/capability.js +9 -3
- package/dist/artifacts/capability.js.map +1 -1
- package/dist/bridge/eventMeta.js +40 -1
- package/dist/bridge/eventMeta.js.map +1 -1
- package/dist/core/Agent.js +40 -6
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/RunnerBase.js +32 -1
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +13 -1
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +64 -7
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/flowchartAsTool.js +8 -2
- package/dist/core/flowchartAsTool.js.map +1 -1
- package/dist/core/runbook/runbookAsTool.js +7 -2
- package/dist/core/runbook/runbookAsTool.js.map +1 -1
- package/dist/core/toolShownArgs.js +55 -0
- package/dist/core/toolShownArgs.js.map +1 -0
- package/dist/esm/adapters/hosting/agentCoreA2A.d.ts +14 -1
- package/dist/esm/adapters/hosting/agentCoreA2A.js +5 -0
- package/dist/esm/adapters/hosting/agentCoreA2A.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.d.ts +18 -2
- package/dist/esm/adapters/hosting/agentcore.js +5 -0
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -1
- package/dist/esm/adapters/hosting/foundryResponses.d.ts +15 -1
- package/dist/esm/adapters/hosting/foundryResponses.js +5 -0
- package/dist/esm/adapters/hosting/foundryResponses.js.map +1 -1
- package/dist/esm/adapters/observability/agentcore.d.ts +17 -5
- package/dist/esm/adapters/observability/agentcore.js +18 -5
- package/dist/esm/adapters/observability/agentcore.js.map +1 -1
- package/dist/esm/adapters/observability/audit.d.ts +6 -2
- package/dist/esm/adapters/observability/audit.js +17 -4
- package/dist/esm/adapters/observability/audit.js.map +1 -1
- package/dist/esm/adapters/observability/otel.d.ts +240 -11
- package/dist/esm/adapters/observability/otel.js +890 -33
- package/dist/esm/adapters/observability/otel.js.map +1 -1
- package/dist/esm/artifacts/capability.d.ts +3 -1
- package/dist/esm/artifacts/capability.js +9 -3
- package/dist/esm/artifacts/capability.js.map +1 -1
- package/dist/esm/bridge/eventMeta.d.ts +32 -0
- package/dist/esm/bridge/eventMeta.js +38 -0
- package/dist/esm/bridge/eventMeta.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +18 -5
- package/dist/esm/core/Agent.js +42 -8
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/RunnerBase.d.ts +20 -0
- package/dist/esm/core/RunnerBase.js +32 -1
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.js +13 -1
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +11 -0
- package/dist/esm/core/agent/stages/toolCalls.js +64 -7
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/flowchartAsTool.js +8 -2
- package/dist/esm/core/flowchartAsTool.js.map +1 -1
- package/dist/esm/core/runbook/runbookAsTool.js +7 -2
- package/dist/esm/core/runbook/runbookAsTool.js.map +1 -1
- package/dist/esm/core/toolShownArgs.d.ts +62 -0
- package/dist/esm/core/toolShownArgs.js +49 -0
- package/dist/esm/core/toolShownArgs.js.map +1 -0
- package/dist/esm/events/payloads.d.ts +122 -6
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/events/types.d.ts +7 -0
- package/dist/esm/hosting/artifactWire.d.ts +10 -2
- package/dist/esm/hosting/artifactWire.js +20 -2
- package/dist/esm/hosting/artifactWire.js.map +1 -1
- package/dist/esm/hosting/doorGuard.d.ts +280 -0
- package/dist/esm/hosting/doorGuard.js +499 -0
- package/dist/esm/hosting/doorGuard.js.map +1 -0
- package/dist/esm/hosting/errors.d.ts +113 -0
- package/dist/esm/hosting/errors.js +177 -0
- package/dist/esm/hosting/errors.js.map +1 -1
- package/dist/esm/hosting/httpHost.d.ts +32 -3
- package/dist/esm/hosting/httpHost.js +218 -4
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +7 -5
- package/dist/esm/hosting/index.js +10 -3
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/ingressRecord.d.ts +64 -10
- package/dist/esm/hosting/ingressRecord.js +65 -6
- package/dist/esm/hosting/ingressRecord.js.map +1 -1
- package/dist/esm/hosting/nodeHost.d.ts +32 -2
- package/dist/esm/hosting/nodeHost.js +10 -0
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/standingAgent.js +362 -51
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/hosting/turnArtifacts.d.ts +93 -0
- package/dist/esm/hosting/turnArtifacts.js +126 -0
- package/dist/esm/hosting/turnArtifacts.js.map +1 -0
- package/dist/esm/hosting/types.d.ts +196 -3
- package/dist/esm/hosting/types.js +10 -0
- package/dist/esm/hosting/types.js.map +1 -1
- package/dist/esm/hosting/webSocketConversation.d.ts +15 -1
- package/dist/esm/hosting/webSocketConversation.js +54 -2
- package/dist/esm/hosting/webSocketConversation.js.map +1 -1
- package/dist/esm/integrity/disposition/ledger.d.ts +8 -0
- package/dist/esm/integrity/disposition/ledger.js +0 -0
- package/dist/esm/integrity/disposition/ledger.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.js +39 -2
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/lib/mcp/types.d.ts +30 -0
- package/dist/esm/recorders/observability/commentary/artifactPhrases.d.ts +4 -0
- package/dist/esm/recorders/observability/commentary/artifactPhrases.js +9 -0
- package/dist/esm/recorders/observability/commentary/artifactPhrases.js.map +1 -1
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +30 -3
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/esm/recorders/observability/recordRun.d.ts +12 -0
- package/dist/esm/recorders/observability/recordRun.js +17 -1
- package/dist/esm/recorders/observability/recordRun.js.map +1 -1
- package/dist/esm/strategies/attach.js +87 -1
- package/dist/esm/strategies/attach.js.map +1 -1
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/hosting/artifactWire.js +21 -3
- package/dist/hosting/artifactWire.js.map +1 -1
- package/dist/hosting/doorGuard.js +509 -0
- package/dist/hosting/doorGuard.js.map +1 -0
- package/dist/hosting/errors.js +183 -1
- package/dist/hosting/errors.js.map +1 -1
- package/dist/hosting/httpHost.js +218 -4
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +19 -2
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/ingressRecord.js +66 -6
- package/dist/hosting/ingressRecord.js.map +1 -1
- package/dist/hosting/nodeHost.js +11 -1
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/hosting/standingAgent.js +359 -48
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/hosting/turnArtifacts.js +130 -0
- package/dist/hosting/turnArtifacts.js.map +1 -0
- package/dist/hosting/types.js +11 -1
- package/dist/hosting/types.js.map +1 -1
- package/dist/hosting/webSocketConversation.js +54 -2
- package/dist/hosting/webSocketConversation.js.map +1 -1
- package/dist/integrity/disposition/ledger.js +0 -0
- package/dist/integrity/disposition/ledger.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +39 -2
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/recorders/observability/commentary/artifactPhrases.js +10 -1
- package/dist/recorders/observability/commentary/artifactPhrases.js.map +1 -1
- package/dist/recorders/observability/commentary/commentaryTemplates.js +29 -2
- package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/recorders/observability/recordRun.js +20 -3
- package/dist/recorders/observability/recordRun.js.map +1 -1
- package/dist/strategies/attach.js +87 -1
- package/dist/strategies/attach.js.map +1 -1
- package/dist/types/adapters/hosting/agentCoreA2A.d.ts +14 -1
- package/dist/types/adapters/hosting/agentCoreA2A.d.ts.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts +18 -2
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/hosting/foundryResponses.d.ts +15 -1
- package/dist/types/adapters/hosting/foundryResponses.d.ts.map +1 -1
- package/dist/types/adapters/observability/agentcore.d.ts +17 -5
- package/dist/types/adapters/observability/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/observability/audit.d.ts +6 -2
- package/dist/types/adapters/observability/audit.d.ts.map +1 -1
- package/dist/types/adapters/observability/otel.d.ts +240 -11
- package/dist/types/adapters/observability/otel.d.ts.map +1 -1
- package/dist/types/artifacts/capability.d.ts +3 -1
- package/dist/types/artifacts/capability.d.ts.map +1 -1
- package/dist/types/bridge/eventMeta.d.ts +32 -0
- package/dist/types/bridge/eventMeta.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +18 -5
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/RunnerBase.d.ts +20 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +11 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/flowchartAsTool.d.ts.map +1 -1
- package/dist/types/core/runbook/runbookAsTool.d.ts.map +1 -1
- package/dist/types/core/toolShownArgs.d.ts +63 -0
- package/dist/types/core/toolShownArgs.d.ts.map +1 -0
- package/dist/types/events/payloads.d.ts +122 -6
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/events/types.d.ts +7 -0
- package/dist/types/events/types.d.ts.map +1 -1
- package/dist/types/hosting/artifactWire.d.ts +10 -2
- package/dist/types/hosting/artifactWire.d.ts.map +1 -1
- package/dist/types/hosting/doorGuard.d.ts +281 -0
- package/dist/types/hosting/doorGuard.d.ts.map +1 -0
- package/dist/types/hosting/errors.d.ts +113 -0
- package/dist/types/hosting/errors.d.ts.map +1 -1
- package/dist/types/hosting/httpHost.d.ts +32 -3
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +7 -5
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/ingressRecord.d.ts +64 -10
- package/dist/types/hosting/ingressRecord.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts +32 -2
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/hosting/turnArtifacts.d.ts +94 -0
- package/dist/types/hosting/turnArtifacts.d.ts.map +1 -0
- package/dist/types/hosting/types.d.ts +196 -3
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/hosting/webSocketConversation.d.ts +15 -1
- package/dist/types/hosting/webSocketConversation.d.ts.map +1 -1
- package/dist/types/integrity/disposition/ledger.d.ts +8 -0
- package/dist/types/integrity/disposition/ledger.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/lib/mcp/types.d.ts +30 -0
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/recorders/observability/commentary/artifactPhrases.d.ts +4 -0
- package/dist/types/recorders/observability/commentary/artifactPhrases.d.ts.map +1 -1
- package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
- package/dist/types/recorders/observability/recordRun.d.ts +12 -0
- package/dist/types/recorders/observability/recordRun.d.ts.map +1 -1
- package/dist/types/strategies/attach.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hosting/doorGuard — what a request has to be before any handler sees it.
|
|
3
|
+
*
|
|
4
|
+
* const guard = doorGuard({ name: 'auth', allowedHosts: ['neo.corp.example'] });
|
|
5
|
+
* const refusal = guard.check(req); // an IncomingMessage works as-is
|
|
6
|
+
* if (refusal) return answer(refusal.status, refusal.message, refusal.code);
|
|
7
|
+
*
|
|
8
|
+
* ── The threat, in one paragraph ────────────────────────────────────────────
|
|
9
|
+
* A door with no verifier, reachable only inside a company network, looks safe
|
|
10
|
+
* because the network is the fence. It is not: every person inside the fence
|
|
11
|
+
* runs a browser, and every web page they open can make that browser send
|
|
12
|
+
* requests to the door FROM INSIDE. Three ways, all live before this file:
|
|
13
|
+
*
|
|
14
|
+
* 1. **A forged request (CSRF).** A page on any site can make the browser
|
|
15
|
+
* POST a JSON-shaped body as `text/plain` (or as a form, or with no
|
|
16
|
+
* content type at all) without asking the server first — a CORS "simple"
|
|
17
|
+
* request. The door parsed it as JSON and ran a turn: model budget spent,
|
|
18
|
+
* tools called, a conversation stored. The attacker cannot read the reply;
|
|
19
|
+
* they do not need to.
|
|
20
|
+
* 2. **DNS rebinding.** A page on an attacker's domain re-points its OWN name
|
|
21
|
+
* at the door's address. The browser now treats the attacker's page as
|
|
22
|
+
* same-origin with the door, so it may send anything and READ the answer.
|
|
23
|
+
* 3. **A cross-site WebSocket.** A WebSocket is not bound by the same-origin
|
|
24
|
+
* policy at all; any page can open one, and only the server can say no.
|
|
25
|
+
*
|
|
26
|
+
* ── The rules, one owner ────────────────────────────────────────────────────
|
|
27
|
+
* `check()` judges a request that CHANGES something — every method but GET,
|
|
28
|
+
* HEAD and OPTIONS, plus every WebSocket upgrade (a GET that opens a channel):
|
|
29
|
+
*
|
|
30
|
+
* - **Host** (with `allowedHosts` set, or defaulted to the loopback names on
|
|
31
|
+
* a loopback bind; judged on EVERY method): a name this door was not
|
|
32
|
+
* configured for is refused, 421. First, because under rebinding the other
|
|
33
|
+
* two checks pass — the Host header, which no page can set, is the one
|
|
34
|
+
* fact that still names the attacker. `X-Forwarded-Host` is never read for
|
|
35
|
+
* it: a rebinding page is same-origin and may set that header itself.
|
|
36
|
+
* - **Origin**: a browser request from a page this door does not allow is
|
|
37
|
+
* refused, 403 — including `Origin: null`. A request WITHOUT an Origin is a
|
|
38
|
+
* script or a server (browsers always send one on these requests) and is
|
|
39
|
+
* not judged by it; that is what keeps every non-browser client working.
|
|
40
|
+
* - **Fetch metadata**, as defence in depth: a request the browser itself
|
|
41
|
+
* marked `Sec-Fetch-Site: cross-site` is refused (403) unless its Origin is
|
|
42
|
+
* one `allowedOrigins` LISTS — so a proxy that strips `Origin` but forwards
|
|
43
|
+
* `Sec-Fetch-*` still cannot let a forged request through. For a WebSocket
|
|
44
|
+
* handshake these two are the whole defence: the browser API cannot set a
|
|
45
|
+
* header, so there is no preflight to force.
|
|
46
|
+
* - **Content type** (not for an upgrade — it has no body): anything but
|
|
47
|
+
* `application/json` is refused, 415. A browser must ask first (a
|
|
48
|
+
* preflight, which this host never approves) before it sends that type
|
|
49
|
+
* across origins, so requiring it makes a forged request one the browser
|
|
50
|
+
* refuses to send. It is the same property a required custom header buys
|
|
51
|
+
* (RFC 10017 §6.1.3.3.2), without breaking every JSON client that already
|
|
52
|
+
* sends the header and no other.
|
|
53
|
+
*
|
|
54
|
+
* `checkSessionId()` is the fourth bound, and it is not about browsers: a
|
|
55
|
+
* session id is caller data that rides every stored row, log line and trace
|
|
56
|
+
* span of a conversation, so a door refuses one over
|
|
57
|
+
* {@link MAX_SESSION_ID_LENGTH} or carrying a control character.
|
|
58
|
+
*
|
|
59
|
+
* Where it runs: `httpHost` calls `check()` on every request to its request
|
|
60
|
+
* door and on every conversation upgrade, and `checkSessionId()` on the id each
|
|
61
|
+
* dialect reads. An application's OWN routes beside the door (a sign-in route
|
|
62
|
+
* on `onUnhandled`, say) are the application's, and arrive untouched — so this
|
|
63
|
+
* is exported for them to call, and the rule keeps one spelling.
|
|
64
|
+
*
|
|
65
|
+
* Pure: no socket, no clock, no I/O. The design note is
|
|
66
|
+
* `docs/design/2026-09-door-hardening.md`.
|
|
67
|
+
*/
|
|
68
|
+
import { HostNotAllowedError, InvalidSessionIdError, OriginNotAllowedError, UnsupportedMediaTypeError, } from './errors.js';
|
|
69
|
+
/**
|
|
70
|
+
* The longest session id any door carries, in UTF-16 code units — JavaScript's
|
|
71
|
+
* own `string.length`.
|
|
72
|
+
*
|
|
73
|
+
* 400 is the width the reference SQL session store gives its `session_id`
|
|
74
|
+
* column (`NVARCHAR(400)`, which counts the same units), so no id this door
|
|
75
|
+
* admits is one a store refuses AFTER the model was paid for. The id formats in
|
|
76
|
+
* use fit with room to spare — a UUID is 36 — and there is deliberately no
|
|
77
|
+
* knob: a correlation handle wider than this is not one anybody needs.
|
|
78
|
+
*/
|
|
79
|
+
export const MAX_SESSION_ID_LENGTH = 400;
|
|
80
|
+
/** Methods that change nothing, and so are not judged — the ruling's GET/HEAD/OPTIONS. */
|
|
81
|
+
const SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);
|
|
82
|
+
/**
|
|
83
|
+
* Build a guard. Configuration a door could only ever misread is refused HERE,
|
|
84
|
+
* at construction, by name — never discovered as a mystery 403 in production.
|
|
85
|
+
*/
|
|
86
|
+
export function doorGuard(options) {
|
|
87
|
+
const { name } = options;
|
|
88
|
+
const origins = readAllowedOrigins(name, options.allowedOrigins);
|
|
89
|
+
const defaulted = options.allowedHosts === undefined ? loopbackAllowedHosts(options.bindHost) : undefined;
|
|
90
|
+
const hosts = readAllowedHosts(name, options.allowedHosts ?? defaulted);
|
|
91
|
+
const hostRule = defaulted === undefined ? 'listed' : 'loopback-default';
|
|
92
|
+
const requireJson = readRequireJson(name, options.requireJsonContentType);
|
|
93
|
+
return {
|
|
94
|
+
allowedHostsUnset: options.allowedHosts === undefined && defaulted === undefined,
|
|
95
|
+
browserRulesOff: origins === 'any' && !requireJson,
|
|
96
|
+
check(request) {
|
|
97
|
+
const { headers } = request;
|
|
98
|
+
if (hosts !== 'any' && !hostAllowed(hosts, headerOf(headers, 'host'))) {
|
|
99
|
+
return new HostNotAllowedError(name, hostRule);
|
|
100
|
+
}
|
|
101
|
+
const method = (request.method ?? '').toUpperCase();
|
|
102
|
+
const carriesBody = !SAFE_METHODS.has(method);
|
|
103
|
+
const upgrade = isWebSocketUpgrade(headers);
|
|
104
|
+
if (!carriesBody && !upgrade)
|
|
105
|
+
return undefined;
|
|
106
|
+
const browser = browserVerdict(origins, headers, upgrade);
|
|
107
|
+
if (browser !== undefined)
|
|
108
|
+
return new OriginNotAllowedError(name, browser);
|
|
109
|
+
if (requireJson && carriesBody && !isJson(headerOf(headers, 'content-type'))) {
|
|
110
|
+
return new UnsupportedMediaTypeError(name);
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What the BROWSER said about where this request came from, judged against the
|
|
118
|
+
* origin rule — or `undefined` when it may pass.
|
|
119
|
+
*
|
|
120
|
+
* Two facts, in order. `Origin` first: present and not allowed is a refusal.
|
|
121
|
+
* Then Fetch metadata, as defence in depth: a request the browser itself
|
|
122
|
+
* marked `Sec-Fetch-Site: cross-site` is refused unless its Origin is one
|
|
123
|
+
* `allowedOrigins` LISTS — which catches the request whose `Origin` a proxy
|
|
124
|
+
* stripped while `Sec-Fetch-Site` rode through. Neither header can be set by a
|
|
125
|
+
* page, and a request carrying neither is not a browser's.
|
|
126
|
+
*
|
|
127
|
+
* One more, for a WebSocket upgrade only: a browser ALWAYS sends `Origin` on a
|
|
128
|
+
* handshake, and with it `Sec-Fetch-Site`, so a handshake carrying
|
|
129
|
+
* `Sec-Fetch-Site` but no `Origin` is a browser's with its Origin stripped —
|
|
130
|
+
* refused whatever the site says, because a handshake has no content type and
|
|
131
|
+
* no preflight to fall back on. `Sec-Fetch-Site` and not any `Sec-Fetch-*`:
|
|
132
|
+
* Node's own `WebSocket` client sends `Sec-Fetch-Mode: websocket` and no
|
|
133
|
+
* Origin, and it is not a browser page.
|
|
134
|
+
*/
|
|
135
|
+
function browserVerdict(rule, headers, upgrade) {
|
|
136
|
+
if (rule === 'any')
|
|
137
|
+
return undefined;
|
|
138
|
+
const origin = headerOf(headers, 'origin');
|
|
139
|
+
const listed = rule !== 'same-host';
|
|
140
|
+
if (origin !== undefined) {
|
|
141
|
+
if (!originAllowed(rule, origin, headers))
|
|
142
|
+
return listed ? 'listed' : 'same-host';
|
|
143
|
+
// An origin the deployment LISTED may be on another site by design.
|
|
144
|
+
if (listed)
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
else if (upgrade && headerOf(headers, 'sec-fetch-site') !== undefined) {
|
|
148
|
+
return 'fetch-metadata';
|
|
149
|
+
}
|
|
150
|
+
const site = headerOf(headers, 'sec-fetch-site');
|
|
151
|
+
return site?.trim().toLowerCase() === 'cross-site' ? 'fetch-metadata' : undefined;
|
|
152
|
+
}
|
|
153
|
+
/** Visible ASCII, `!` (0x21) to `~` (0x7E) — nothing else, from any field. */
|
|
154
|
+
const VISIBLE_ASCII = /^[\x21-\x7e]+$/;
|
|
155
|
+
/**
|
|
156
|
+
* The session-id bound — `undefined` for an id a door may carry (or none).
|
|
157
|
+
*
|
|
158
|
+
* A session id is one to {@link MAX_SESSION_ID_LENGTH} characters of VISIBLE
|
|
159
|
+
* ASCII (0x21–0x7E) — the rule MCP gives its own session ids. Why ASCII and
|
|
160
|
+
* not "Unicode minus the dangerous parts":
|
|
161
|
+
*
|
|
162
|
+
* - **One id, one byte string, from every field.** Node reads a header value
|
|
163
|
+
* as latin1 and a JSON body as UTF-8, so `café` in `x-session-id` and `café`
|
|
164
|
+
* in the body were two different stored conversations. With ASCII only,
|
|
165
|
+
* the two readings cannot differ.
|
|
166
|
+
* - **Nothing a log, a span or a store can reinterpret.** Controls, line and
|
|
167
|
+
* paragraph separators (U+2028/9), bidi overrides (U+202E), zero-width
|
|
168
|
+
* characters and lone surrogates (which any UTF-8 store rewrites to U+FFFD,
|
|
169
|
+
* merging two ids) are all outside it — no list of exceptions to keep up.
|
|
170
|
+
* - Every id format in use already fits: UUIDs, platform runtime ids, `conv_…`.
|
|
171
|
+
*
|
|
172
|
+
* The empty string is refused too: every caller that sent `""` shared ONE
|
|
173
|
+
* conversation. The length is judged first, so an over-long id costs one
|
|
174
|
+
* comparison — after a body read that `maxBodyBytes` bounds.
|
|
175
|
+
*/
|
|
176
|
+
export function checkSessionId(sessionId, hostName) {
|
|
177
|
+
if (sessionId === undefined)
|
|
178
|
+
return undefined;
|
|
179
|
+
if (sessionId.length === 0) {
|
|
180
|
+
return new InvalidSessionIdError('empty', hostName, 0, MAX_SESSION_ID_LENGTH);
|
|
181
|
+
}
|
|
182
|
+
if (sessionId.length > MAX_SESSION_ID_LENGTH) {
|
|
183
|
+
return new InvalidSessionIdError('too-long', hostName, sessionId.length, MAX_SESSION_ID_LENGTH);
|
|
184
|
+
}
|
|
185
|
+
if (!VISIBLE_ASCII.test(sessionId)) {
|
|
186
|
+
return new InvalidSessionIdError('invalid-character', hostName, sessionId.length, MAX_SESSION_ID_LENGTH);
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The names a LOOPBACK-bound door answers to when `allowedHosts` was not set —
|
|
192
|
+
* `localhost`, `127.0.0.1`, `[::1]` (and the bound address itself when it is
|
|
193
|
+
* another `127.x`), any port: the socket already fixes the port, so a name is
|
|
194
|
+
* all a rebinding page can vary. `undefined` for any other bind.
|
|
195
|
+
*
|
|
196
|
+
* It closes DNS rebinding on the classic victim, a developer's own machine,
|
|
197
|
+
* and the MCP SDK's `createMcpExpressApp` does the same for a localhost bind.
|
|
198
|
+
* What it refuses that is legitimate, stated rather than discovered:
|
|
199
|
+
*
|
|
200
|
+
* - **A reverse proxy on the same machine that forwards the PUBLIC name** in
|
|
201
|
+
* `Host` (nginx `proxy_set_header Host $host`) — the common case, and the
|
|
202
|
+
* recommended "bind 127.0.0.1 behind nginx" setup. The proxy's requests
|
|
203
|
+
* arrive on loopback carrying `neo.corp.example`, which the socket cannot
|
|
204
|
+
* tell from a rebinding page. List that name in `allowedHosts`; the 421
|
|
205
|
+
* says so, naming this default (`HostNotAllowedError` · `rule`).
|
|
206
|
+
* - A hosts-file alias for a loopback address — the same fix.
|
|
207
|
+
*
|
|
208
|
+
* Both fail loudly and in the safe direction, and the fix is the option such
|
|
209
|
+
* a deployment should set anyway.
|
|
210
|
+
*
|
|
211
|
+
* @internal — `doorGuard` asks it with the address a door bound
|
|
212
|
+
* (`DoorGuardOptions.bindHost`).
|
|
213
|
+
*/
|
|
214
|
+
export function loopbackAllowedHosts(bindHost) {
|
|
215
|
+
if (!isLoopbackBind(bindHost))
|
|
216
|
+
return undefined;
|
|
217
|
+
const names = ['localhost', '127.0.0.1', '[::1]'];
|
|
218
|
+
const literal = (bindHost ?? '').trim().toLowerCase();
|
|
219
|
+
if (/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(literal) && literal !== '127.0.0.1') {
|
|
220
|
+
names.push(literal);
|
|
221
|
+
}
|
|
222
|
+
return names;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* `localhost`, any `127.x` literal, and `::1` or `::ffff:127.x` in ANY IPv6
|
|
226
|
+
* spelling (bracketed or not, `0:0:0:0:0:0:0:1`, leading zeros) — IPv6 is
|
|
227
|
+
* canonicalised by the WHATWG URL parser before it is compared.
|
|
228
|
+
*/
|
|
229
|
+
export function isLoopbackBind(bindHost) {
|
|
230
|
+
if (bindHost === undefined)
|
|
231
|
+
return false;
|
|
232
|
+
const host = bindHost
|
|
233
|
+
.trim()
|
|
234
|
+
.toLowerCase()
|
|
235
|
+
.replace(/^\[|\]$/g, '');
|
|
236
|
+
if (host === 'localhost' || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(host))
|
|
237
|
+
return true;
|
|
238
|
+
if (!host.includes(':'))
|
|
239
|
+
return false;
|
|
240
|
+
const canonical = parseUrl(`http://[${host}]`)?.hostname;
|
|
241
|
+
// `::ffff:127.x.y.z` canonicalises to `[::ffff:7fxx:xxxx]`.
|
|
242
|
+
return canonical === '[::1]' || /^\[::ffff:7f[0-9a-f]{2}:[0-9a-f]{1,4}\]$/.test(canonical ?? '');
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The cross-site rules for a door a PLATFORM fronts — the hosted-runtime
|
|
246
|
+
* adapters' defaults, with whatever the deployment set kept as given.
|
|
247
|
+
*
|
|
248
|
+
* Exempt by default, and why, once for every such adapter: the platform's own
|
|
249
|
+
* front door is the only way to the container's port, and the credential it
|
|
250
|
+
* demands is one no web page holds (a signed request, a bearer the caller
|
|
251
|
+
* attaches) — so a forged browser request cannot authenticate and no browser
|
|
252
|
+
* can reach the port to rebind it. The browser rules would protect nothing
|
|
253
|
+
* there, and which headers the platform forwards (its content type, Origin,
|
|
254
|
+
* Host) is not a fact this library has verified; enforcing them could refuse
|
|
255
|
+
* the platform's own forwarding. Any rule the deployment sets is enforced
|
|
256
|
+
* exactly as on every other door. The session-id bound is NOT exempt: it is
|
|
257
|
+
* not about browsers.
|
|
258
|
+
*
|
|
259
|
+
* @internal — the adapters' shared default, not a public setting.
|
|
260
|
+
*/
|
|
261
|
+
export function platformFrontedDoor(options, bindHost) {
|
|
262
|
+
// A LOOPBACK bind is by definition not behind the platform's front door — it
|
|
263
|
+
// is a laptop or a self-hosted box, the classic victim — so it keeps every
|
|
264
|
+
// default a plain `httpHost` has (and the loopback names for `allowedHosts`).
|
|
265
|
+
if (isLoopbackBind(bindHost)) {
|
|
266
|
+
return {
|
|
267
|
+
...(options.allowedOrigins !== undefined && { allowedOrigins: options.allowedOrigins }),
|
|
268
|
+
...(options.allowedHosts !== undefined && { allowedHosts: options.allowedHosts }),
|
|
269
|
+
...(options.requireJsonContentType !== undefined && {
|
|
270
|
+
requireJsonContentType: options.requireJsonContentType,
|
|
271
|
+
}),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
allowedOrigins: options.allowedOrigins ?? 'any',
|
|
276
|
+
allowedHosts: options.allowedHosts ?? 'any',
|
|
277
|
+
requireJsonContentType: options.requireJsonContentType ?? false,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const warnedHostNames = new Set();
|
|
281
|
+
const warnedRulesOff = new Set();
|
|
282
|
+
/**
|
|
283
|
+
* Said once per host name per process, at boot, when a door serves with the
|
|
284
|
+
* browser rules OFF (`allowedOrigins: 'any'` and `requireJsonContentType:
|
|
285
|
+
* false` — the hosted-runtime adapters' default on a non-loopback bind). Those
|
|
286
|
+
* rules are off because a platform's front door is supposed to be the only way
|
|
287
|
+
* in; a self-hoster on `0.0.0.0` needs to hear that it is not.
|
|
288
|
+
*
|
|
289
|
+
* @internal — the words have one owner; `httpHost` decides when.
|
|
290
|
+
*/
|
|
291
|
+
export function warnBrowserRulesOff(hostName) {
|
|
292
|
+
if (warnedRulesOff.has(hostName))
|
|
293
|
+
return;
|
|
294
|
+
warnedRulesOff.add(hostName);
|
|
295
|
+
// eslint-disable-next-line no-console
|
|
296
|
+
console.warn(`[hosting] the '${hostName}' host serves with the browser rules OFF (allowedOrigins: ` +
|
|
297
|
+
`'any', requireJsonContentType: false): any web page a user opens can make their ` +
|
|
298
|
+
`browser send it requests. That is right only when the one way to this port is a ` +
|
|
299
|
+
`platform front door that demands its own credential. Anywhere else — a ` +
|
|
300
|
+
`laptop, a self-hosted VM — set allowedOrigins, allowedHosts and ` +
|
|
301
|
+
`requireJsonContentType: true, or bind to 127.0.0.1.`);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The staged default, said out loud: a host serving with `allowedHosts` unset
|
|
305
|
+
* prints this ONCE per host name per process, at boot. A name is how every
|
|
306
|
+
* refusal identifies a host, so two hosts sharing one are one door to anyone
|
|
307
|
+
* reading the log — and once is what keeps a warning from becoming noise.
|
|
308
|
+
*
|
|
309
|
+
* @internal — the words have one owner; `httpHost` decides when.
|
|
310
|
+
*/
|
|
311
|
+
export function warnAllowedHostsUnset(hostName) {
|
|
312
|
+
if (warnedHostNames.has(hostName))
|
|
313
|
+
return;
|
|
314
|
+
warnedHostNames.add(hostName);
|
|
315
|
+
// eslint-disable-next-line no-console
|
|
316
|
+
console.warn(`[hosting] the '${hostName}' host answers a request for ANY Host name, because ` +
|
|
317
|
+
`allowedHosts is not set. A web page on another domain can re-point its own name at ` +
|
|
318
|
+
`this server's address (DNS rebinding) and then read this door's answers as if it were ` +
|
|
319
|
+
`the app itself — the Origin check cannot tell, because the page's Origin and the ` +
|
|
320
|
+
`request's Host both carry the attacker's name. Set allowedHosts: ['<the name people ` +
|
|
321
|
+
`use to reach it>'] to refuse every other name (421), or allowedHosts: 'any' to state ` +
|
|
322
|
+
`that no browser can reach this port. Serving continues: in this release an unset ` +
|
|
323
|
+
`list is a warning, not a refusal, so existing deployments keep starting.`);
|
|
324
|
+
}
|
|
325
|
+
function readAllowedOrigins(name, value) {
|
|
326
|
+
if (value === undefined)
|
|
327
|
+
return 'same-host';
|
|
328
|
+
if (value === 'any')
|
|
329
|
+
return 'any';
|
|
330
|
+
if (!Array.isArray(value)) {
|
|
331
|
+
throw new TypeError(`[hosting] ${name}: allowedOrigins must be a list of origins ` +
|
|
332
|
+
`(['https://app.example']) or 'any'; received ${describe(value)}.`);
|
|
333
|
+
}
|
|
334
|
+
const origins = new Set();
|
|
335
|
+
for (const entry of value)
|
|
336
|
+
origins.add(readOriginEntry(name, entry));
|
|
337
|
+
return origins;
|
|
338
|
+
}
|
|
339
|
+
function readOriginEntry(name, entry) {
|
|
340
|
+
const text = typeof entry === 'string' ? entry.trim() : '';
|
|
341
|
+
if (text === '*') {
|
|
342
|
+
throw new TypeError(`[hosting] ${name}: allowedOrigins cannot contain '*'. To turn the Origin check off, ` +
|
|
343
|
+
`pass allowedOrigins: 'any' — a word, so nobody reads it as a wildcard pattern.`);
|
|
344
|
+
}
|
|
345
|
+
if (text.toLowerCase() === 'null') {
|
|
346
|
+
throw new TypeError(`[hosting] ${name}: allowedOrigins cannot contain 'null'. It is the origin of every ` +
|
|
347
|
+
`sandboxed frame and data: page on every site, so allowing it would allow them all.`);
|
|
348
|
+
}
|
|
349
|
+
const url = parseUrl(text);
|
|
350
|
+
if (url === undefined || url.origin === 'null' || !bareAuthority(url)) {
|
|
351
|
+
throw new TypeError(`[hosting] ${name}: allowedOrigins entry ${JSON.stringify(entry)} is not an origin. ` +
|
|
352
|
+
`An origin is scheme://host[:port] with nothing after it — 'https://app.example'.`);
|
|
353
|
+
}
|
|
354
|
+
return url.origin;
|
|
355
|
+
}
|
|
356
|
+
function readAllowedHosts(name, value) {
|
|
357
|
+
if (value === undefined || value === 'any')
|
|
358
|
+
return 'any';
|
|
359
|
+
if (!Array.isArray(value)) {
|
|
360
|
+
throw new TypeError(`[hosting] ${name}: allowedHosts must be a list of host names ` +
|
|
361
|
+
`(['app.example']) or 'any'; received ${describe(value)}.`);
|
|
362
|
+
}
|
|
363
|
+
if (value.length === 0) {
|
|
364
|
+
throw new TypeError(`[hosting] ${name}: allowedHosts is an empty list, so every request would be refused — ` +
|
|
365
|
+
`nothing could ever be served. List the names this door is reached by, or pass 'any'.`);
|
|
366
|
+
}
|
|
367
|
+
return value.map((entry) => readHostEntry(name, entry));
|
|
368
|
+
}
|
|
369
|
+
function readHostEntry(name, entry) {
|
|
370
|
+
const parsed = typeof entry === 'string' ? parseAuthority(entry) : undefined;
|
|
371
|
+
if (parsed === undefined) {
|
|
372
|
+
throw new TypeError(`[hosting] ${name}: allowedHosts entry ${JSON.stringify(entry)} is not a host name. ` +
|
|
373
|
+
`Expected a name with an optional port — 'app.example', 'app.example:8443', or an ` +
|
|
374
|
+
`IPv6 address in brackets, '[::1]'.`);
|
|
375
|
+
}
|
|
376
|
+
return parsed;
|
|
377
|
+
}
|
|
378
|
+
function readRequireJson(name, value) {
|
|
379
|
+
if (value === undefined)
|
|
380
|
+
return true;
|
|
381
|
+
if (typeof value !== 'boolean') {
|
|
382
|
+
throw new TypeError(`[hosting] ${name}: requireJsonContentType must be true or false; received ` +
|
|
383
|
+
`${describe(value)}.`);
|
|
384
|
+
}
|
|
385
|
+
return value;
|
|
386
|
+
}
|
|
387
|
+
// ─── Judging a request (per request) ─────────────────────────────────
|
|
388
|
+
function hostAllowed(entries, host) {
|
|
389
|
+
const seen = host === undefined ? undefined : parseAuthority(host);
|
|
390
|
+
if (seen === undefined)
|
|
391
|
+
return false;
|
|
392
|
+
return entries.some((entry) => entry.hostname === seen.hostname && (entry.port === undefined || entry.port === seen.port));
|
|
393
|
+
}
|
|
394
|
+
function originAllowed(rule, origin, headers) {
|
|
395
|
+
const url = parseUrl(origin.trim());
|
|
396
|
+
if (url === undefined || url.origin === 'null')
|
|
397
|
+
return false;
|
|
398
|
+
if (rule !== 'same-host')
|
|
399
|
+
return rule.has(url.origin);
|
|
400
|
+
// The page's own name, as the browser addressed the door: the Host header,
|
|
401
|
+
// or what a proxy in front recorded before rewriting it. A cross-site page
|
|
402
|
+
// cannot set X-Forwarded-Host without a preflight this host never approves.
|
|
403
|
+
//
|
|
404
|
+
// A Host with no port is read under the scheme the client actually used
|
|
405
|
+
// when a proxy said so (`X-Forwarded-Proto`), and under the Origin's scheme
|
|
406
|
+
// otherwise — so `http://name` (port 80) and `https://name` (port 443) are
|
|
407
|
+
// two origins, as they are to a browser.
|
|
408
|
+
const own = authorityKey(url);
|
|
409
|
+
const scheme = forwardedProto(headers) ?? url.protocol;
|
|
410
|
+
const candidates = [
|
|
411
|
+
headerOf(headers, 'host'),
|
|
412
|
+
...(headerOf(headers, 'x-forwarded-host')?.split(',') ?? []),
|
|
413
|
+
];
|
|
414
|
+
return candidates.some((candidate) => {
|
|
415
|
+
const parsed = candidate === undefined ? undefined : parseUrl(`${scheme}//${candidate.trim()}`);
|
|
416
|
+
return parsed !== undefined && bareAuthority(parsed) && authorityKey(parsed) === own;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/** The first `X-Forwarded-Proto` entry, when it is `http` or `https`. */
|
|
420
|
+
function forwardedProto(headers) {
|
|
421
|
+
const first = headerOf(headers, 'x-forwarded-proto')?.split(',')[0]?.trim().toLowerCase();
|
|
422
|
+
return first === 'http' || first === 'https' ? `${first}:` : undefined;
|
|
423
|
+
}
|
|
424
|
+
/** The media type's essence is exactly `application/json` — never a `+json` cousin. */
|
|
425
|
+
function isJson(contentType) {
|
|
426
|
+
if (contentType === undefined)
|
|
427
|
+
return false;
|
|
428
|
+
const essence = contentType.split(';', 1)[0] ?? '';
|
|
429
|
+
return essence.trim().toLowerCase() === 'application/json';
|
|
430
|
+
}
|
|
431
|
+
function isWebSocketUpgrade(headers) {
|
|
432
|
+
const upgrade = headerOf(headers, 'upgrade');
|
|
433
|
+
if (upgrade === undefined)
|
|
434
|
+
return false;
|
|
435
|
+
return upgrade
|
|
436
|
+
.toLowerCase()
|
|
437
|
+
.split(',')
|
|
438
|
+
.some((token) => token.trim() === 'websocket');
|
|
439
|
+
}
|
|
440
|
+
// ─── Small parsers ───────────────────────────────────────────────────
|
|
441
|
+
/** One header's value, case-insensitively; repeated values joined as node joins them. */
|
|
442
|
+
function headerOf(headers, name) {
|
|
443
|
+
const direct = headers[name];
|
|
444
|
+
if (direct !== undefined)
|
|
445
|
+
return joined(direct);
|
|
446
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
447
|
+
if (key.toLowerCase() === name && value !== undefined)
|
|
448
|
+
return joined(value);
|
|
449
|
+
}
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
function joined(value) {
|
|
453
|
+
return typeof value === 'string' ? value : value.join(', ');
|
|
454
|
+
}
|
|
455
|
+
function parseUrl(text) {
|
|
456
|
+
try {
|
|
457
|
+
return new URL(text);
|
|
458
|
+
}
|
|
459
|
+
catch {
|
|
460
|
+
return undefined;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/** A URL that is nothing but scheme and authority — no credentials, path, query or fragment. */
|
|
464
|
+
function bareAuthority(url) {
|
|
465
|
+
return (url.username === '' &&
|
|
466
|
+
url.password === '' &&
|
|
467
|
+
url.pathname === '/' &&
|
|
468
|
+
url.search === '' &&
|
|
469
|
+
url.hash === '');
|
|
470
|
+
}
|
|
471
|
+
/** A `host[:port]` value as a {@link HostEntry}, or `undefined` when it is anything more. */
|
|
472
|
+
function parseAuthority(value) {
|
|
473
|
+
const url = parseUrl(`http://${value.trim()}`);
|
|
474
|
+
if (url === undefined || !bareAuthority(url) || url.hostname === '')
|
|
475
|
+
return undefined;
|
|
476
|
+
const hostname = withoutTrailingDot(url.hostname);
|
|
477
|
+
return url.port === '' ? { hostname } : { hostname, port: url.port };
|
|
478
|
+
}
|
|
479
|
+
/** Host and EFFECTIVE port as one comparable string — a default port spelled out. */
|
|
480
|
+
function authorityKey(url) {
|
|
481
|
+
const hostname = withoutTrailingDot(url.hostname);
|
|
482
|
+
const port = url.port !== '' ? url.port : DEFAULT_PORT[url.protocol] ?? '';
|
|
483
|
+
return `${hostname}:${port}`;
|
|
484
|
+
}
|
|
485
|
+
const DEFAULT_PORT = {
|
|
486
|
+
'http:': '80',
|
|
487
|
+
'https:': '443',
|
|
488
|
+
'ws:': '80',
|
|
489
|
+
'wss:': '443',
|
|
490
|
+
};
|
|
491
|
+
function withoutTrailingDot(hostname) {
|
|
492
|
+
return hostname.endsWith('.') ? hostname.slice(0, -1) : hostname;
|
|
493
|
+
}
|
|
494
|
+
function describe(value) {
|
|
495
|
+
if (typeof value === 'string')
|
|
496
|
+
return `the string ${JSON.stringify(value)}`;
|
|
497
|
+
return Array.isArray(value) ? 'an array' : typeof value;
|
|
498
|
+
}
|
|
499
|
+
//# sourceMappingURL=doorGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doorGuard.js","sourceRoot":"","sources":["../../../src/hosting/doorGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAEH,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,GAE1B,MAAM,aAAa,CAAC;AAErB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAoHzC,0FAA0F;AAC1F,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACjE,MAAM,SAAS,GACb,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,IAAI,SAAS,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC;IACzE,MAAM,WAAW,GAAG,eAAe,CAAC,IA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AE,CAAC;IAC3E,OAAO,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,YAAY,GAAqC;IACrD,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACnE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5E,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;AAC1D,CAAC"}
|
|
@@ -226,6 +226,28 @@ export declare class ArtifactNotCarriedError extends Error {
|
|
|
226
226
|
readonly ref: string;
|
|
227
227
|
constructor(ref: string, hostName?: string);
|
|
228
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Refused when host code uses a turn's artifact hand-over
|
|
231
|
+
* (`HostReply.turnArtifacts`) after that turn ended.
|
|
232
|
+
*
|
|
233
|
+
* The hand-over is live only while the hook runs: the composer awaits the
|
|
234
|
+
* hook while the session's lane is held, waits for every operation the hook
|
|
235
|
+
* started, then revokes the binding before the reply ends. A verb called
|
|
236
|
+
* after that is refused by name rather than performed. The footprintjs
|
|
237
|
+
* `ScopeFacade · assertLive` law, one layer up: a handle held past its stage
|
|
238
|
+
* is refused, because a write made outside its turn lands on whatever run the
|
|
239
|
+
* instance is serving by then — in the shared shape, another person's — and
|
|
240
|
+
* makes the record lie.
|
|
241
|
+
*
|
|
242
|
+
* The fix is always the same: file INSIDE the hook (`await
|
|
243
|
+
* turn.artifacts.put(...)`), and carry the ticket onward from there.
|
|
244
|
+
*/
|
|
245
|
+
export declare class TurnArtifactsExpiredError extends Error {
|
|
246
|
+
readonly code: "ERR_TURN_ARTIFACTS_EXPIRED";
|
|
247
|
+
/** Which verb was called after the turn ended. */
|
|
248
|
+
readonly op: 'put' | 'head' | 'get' | 'delete' | 'list';
|
|
249
|
+
constructor(op: 'put' | 'head' | 'get' | 'delete' | 'list');
|
|
250
|
+
}
|
|
229
251
|
/**
|
|
230
252
|
* Thrown when a store hands back something that is **present but unreadable**
|
|
231
253
|
* where a `CheckpointEnvelope` should be.
|
|
@@ -523,4 +545,95 @@ export declare class WireRequestRefusal extends Error {
|
|
|
523
545
|
/** HTTP status for this refusal. Default 400 — the request is what is wrong. */
|
|
524
546
|
status?: number);
|
|
525
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* A request that changes something did not say `content-type: application/json`.
|
|
550
|
+
*
|
|
551
|
+
* The door is a JSON API, and that is only half the reason. The other half is
|
|
552
|
+
* the web: a page on ANY site can make a browser send `text/plain`,
|
|
553
|
+
* `application/x-www-form-urlencoded` or `multipart/form-data` — or no content
|
|
554
|
+
* type at all — without asking the server first (a CORS "simple" request). A
|
|
555
|
+
* browser must ask first (a preflight, which this host never approves) before
|
|
556
|
+
* it sends `application/json` across origins. Requiring it is what turns a
|
|
557
|
+
* forged request into one the browser refuses to send.
|
|
558
|
+
*/
|
|
559
|
+
export declare class UnsupportedMediaTypeError extends Error {
|
|
560
|
+
readonly code: "ERR_UNSUPPORTED_MEDIA_TYPE";
|
|
561
|
+
/** 415 Unsupported Media Type. */
|
|
562
|
+
readonly status: 415;
|
|
563
|
+
constructor(hostName: string);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Which browser fact refused an {@link OriginNotAllowedError}.
|
|
567
|
+
*
|
|
568
|
+
* - `'same-host'` — `allowedOrigins` is unset and the page's Origin is not
|
|
569
|
+
* this door's own name.
|
|
570
|
+
* - `'listed'` — the page's Origin is not in `allowedOrigins`.
|
|
571
|
+
* - `'fetch-metadata'` — the browser marked the request `Sec-Fetch-Site:
|
|
572
|
+
* cross-site` and its Origin is not one `allowedOrigins` lists. This is the
|
|
573
|
+
* one that still fires when a proxy strips `Origin` but forwards the Fetch
|
|
574
|
+
* metadata beside it.
|
|
575
|
+
*/
|
|
576
|
+
export type OriginRefusalRule = 'same-host' | 'listed' | 'fetch-metadata';
|
|
577
|
+
/**
|
|
578
|
+
* A browser request came from a page whose origin this door does not allow —
|
|
579
|
+
* or from an opaque origin (`Origin: null`), which any sandboxed frame on any
|
|
580
|
+
* site can produce and which is therefore never allowed — or the browser said
|
|
581
|
+
* outright that it was sent cross-site.
|
|
582
|
+
*
|
|
583
|
+
* Only BROWSERS send `Origin` (on every request that changes something, and on
|
|
584
|
+
* every WebSocket handshake), so a request without one is a script or a
|
|
585
|
+
* server — unless the same request carries the browser's own `Sec-Fetch-Site:
|
|
586
|
+
* cross-site`, which is how a stripped `Origin` still gets caught.
|
|
587
|
+
*/
|
|
588
|
+
export declare class OriginNotAllowedError extends Error {
|
|
589
|
+
readonly code: "ERR_ORIGIN_NOT_ALLOWED";
|
|
590
|
+
/** 403 Forbidden. */
|
|
591
|
+
readonly status: 403;
|
|
592
|
+
/** Which browser fact refused it. */
|
|
593
|
+
readonly rule: OriginRefusalRule;
|
|
594
|
+
constructor(hostName: string, rule: OriginRefusalRule);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* A request named a Host this door was not configured to answer for.
|
|
598
|
+
*
|
|
599
|
+
* The DNS-rebinding defence: a page on an attacker's domain re-points its OWN
|
|
600
|
+
* name at this server's address, and from then on the browser treats it as
|
|
601
|
+
* same-origin with the door — so every other check passes, and the Host header
|
|
602
|
+
* (which no page can set) is the one fact that still names the attacker.
|
|
603
|
+
* 421 is the status HTTP defines for exactly this (RFC 9110 §15.5.20: a target
|
|
604
|
+
* "that does not match an origin for which the server has been configured").
|
|
605
|
+
*/
|
|
606
|
+
export declare class HostNotAllowedError extends Error {
|
|
607
|
+
readonly code: "ERR_HOST_NOT_ALLOWED";
|
|
608
|
+
/** 421 Misdirected Request. */
|
|
609
|
+
readonly status: 421;
|
|
610
|
+
/**
|
|
611
|
+
* Where the list came from: `'listed'` — the deployment's own
|
|
612
|
+
* `allowedHosts`; `'loopback-default'` — nobody set one, and the door is
|
|
613
|
+
* bound to a loopback address, so it answers the loopback names only.
|
|
614
|
+
*/
|
|
615
|
+
readonly rule: 'listed' | 'loopback-default';
|
|
616
|
+
constructor(hostName: string, rule?: 'listed' | 'loopback-default');
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* A session id the door will not carry: empty, longer than the ceiling, or
|
|
620
|
+
* holding anything but visible ASCII (0x21–0x7E).
|
|
621
|
+
*
|
|
622
|
+
* A session id is caller data that travels everywhere the conversation does —
|
|
623
|
+
* the store's key, every log line, every exported trace span of every turn.
|
|
624
|
+
* Unbounded, one caller with no credentials could make every span of a turn
|
|
625
|
+
* carry megabytes; with a control, a line separator or a bidi override, it
|
|
626
|
+
* could forge or disguise a line in any log that prints it; with non-ASCII,
|
|
627
|
+
* the same id read from a header (latin1) and from a body (UTF-8) would be two
|
|
628
|
+
* different conversations. So it is bounded at the door, before any of that
|
|
629
|
+
* happens. The refusal says how long the id was, never what it said.
|
|
630
|
+
*/
|
|
631
|
+
export declare class InvalidSessionIdError extends Error {
|
|
632
|
+
readonly code: "ERR_INVALID_SESSION_ID";
|
|
633
|
+
/** 400 Bad Request — the caller can send a valid id and continue. */
|
|
634
|
+
readonly status: 400;
|
|
635
|
+
/** Which rule the id broke. Never the id. */
|
|
636
|
+
readonly reason: 'empty' | 'too-long' | 'invalid-character';
|
|
637
|
+
constructor(reason: 'empty' | 'too-long' | 'invalid-character', hostName: string, length: number, limit: number);
|
|
638
|
+
}
|
|
526
639
|
export declare function requireCapability(host: AgentHost | ConversationHost, capability: HostCapability): void;
|