@godot-mcp/control-plane 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +105 -2
- package/dist/audit/jsonlAuditSink.d.ts +33 -0
- package/dist/audit/jsonlAuditSink.d.ts.map +1 -0
- package/dist/audit/jsonlAuditSink.js +57 -0
- package/dist/audit/jsonlAuditSink.js.map +1 -0
- package/dist/audit/redact.d.ts +2 -0
- package/dist/audit/redact.d.ts.map +1 -0
- package/dist/audit/redact.js +44 -0
- package/dist/audit/redact.js.map +1 -0
- package/dist/auth/pairingDescriptor.d.ts +44 -0
- package/dist/auth/pairingDescriptor.d.ts.map +1 -0
- package/dist/auth/pairingDescriptor.js +91 -0
- package/dist/auth/pairingDescriptor.js.map +1 -0
- package/dist/auth/runtimeDirectory.d.ts +3 -0
- package/dist/auth/runtimeDirectory.d.ts.map +1 -0
- package/dist/auth/runtimeDirectory.js +30 -0
- package/dist/auth/runtimeDirectory.js.map +1 -0
- package/dist/auth/sessionCrypto.d.ts +18 -0
- package/dist/auth/sessionCrypto.d.ts.map +1 -0
- package/dist/auth/sessionCrypto.js +118 -0
- package/dist/auth/sessionCrypto.js.map +1 -0
- package/dist/editor/editorMutationService.d.ts +21 -0
- package/dist/editor/editorMutationService.d.ts.map +1 -0
- package/dist/editor/editorMutationService.js +120 -0
- package/dist/editor/editorMutationService.js.map +1 -0
- package/dist/editor/mutationLedger.d.ts +30 -0
- package/dist/editor/mutationLedger.d.ts.map +1 -0
- package/dist/editor/mutationLedger.js +133 -0
- package/dist/editor/mutationLedger.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/errors.js.map +1 -0
- package/dist/evidence/evidenceStore.d.ts +63 -0
- package/dist/evidence/evidenceStore.d.ts.map +1 -0
- package/dist/evidence/evidenceStore.js +350 -0
- package/dist/evidence/evidenceStore.js.map +1 -0
- package/dist/extensions/extensionRegistry.d.ts +33 -0
- package/dist/extensions/extensionRegistry.d.ts.map +1 -0
- package/dist/extensions/extensionRegistry.js +37 -0
- package/dist/extensions/extensionRegistry.js.map +1 -0
- package/dist/help/coreHelp.d.ts +10 -0
- package/dist/help/coreHelp.d.ts.map +1 -0
- package/dist/help/coreHelp.js +82 -0
- package/dist/help/coreHelp.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/policy/authorize.d.ts +5 -0
- package/dist/policy/authorize.d.ts.map +1 -0
- package/dist/policy/authorize.js +19 -0
- package/dist/policy/authorize.js.map +1 -0
- package/dist/policy/capabilities.d.ts +36 -0
- package/dist/policy/capabilities.d.ts.map +1 -0
- package/dist/policy/capabilities.js +129 -0
- package/dist/policy/capabilities.js.map +1 -0
- package/dist/project/artifactStore.d.ts +32 -0
- package/dist/project/artifactStore.d.ts.map +1 -0
- package/dist/project/artifactStore.js +172 -0
- package/dist/project/artifactStore.js.map +1 -0
- package/dist/project/pathPolicy.d.ts +4 -0
- package/dist/project/pathPolicy.d.ts.map +1 -0
- package/dist/project/pathPolicy.js +74 -0
- package/dist/project/pathPolicy.js.map +1 -0
- package/dist/project/projectConfig.d.ts +10 -0
- package/dist/project/projectConfig.d.ts.map +1 -0
- package/dist/project/projectConfig.js +63 -0
- package/dist/project/projectConfig.js.map +1 -0
- package/dist/project/projectIdentity.d.ts +8 -0
- package/dist/project/projectIdentity.d.ts.map +1 -0
- package/dist/project/projectIdentity.js +58 -0
- package/dist/project/projectIdentity.js.map +1 -0
- package/dist/project/projectJobJournal.d.ts +49 -0
- package/dist/project/projectJobJournal.d.ts.map +1 -0
- package/dist/project/projectJobJournal.js +67 -0
- package/dist/project/projectJobJournal.js.map +1 -0
- package/dist/project/projectJobService.d.ts +52 -0
- package/dist/project/projectJobService.d.ts.map +1 -0
- package/dist/project/projectJobService.js +289 -0
- package/dist/project/projectJobService.js.map +1 -0
- package/dist/project/projectMutationService.d.ts +40 -0
- package/dist/project/projectMutationService.d.ts.map +1 -0
- package/dist/project/projectMutationService.js +145 -0
- package/dist/project/projectMutationService.js.map +1 -0
- package/dist/project/projectPreflight.d.ts +7 -0
- package/dist/project/projectPreflight.d.ts.map +1 -0
- package/dist/project/projectPreflight.js +50 -0
- package/dist/project/projectPreflight.js.map +1 -0
- package/dist/project/projectProcess.d.ts +40 -0
- package/dist/project/projectProcess.d.ts.map +1 -0
- package/dist/project/projectProcess.js +196 -0
- package/dist/project/projectProcess.js.map +1 -0
- package/dist/project/projectService.d.ts +20 -0
- package/dist/project/projectService.d.ts.map +1 -0
- package/dist/project/projectService.js +35 -0
- package/dist/project/projectService.js.map +1 -0
- package/dist/project/secureJournalFile.d.ts +3 -0
- package/dist/project/secureJournalFile.d.ts.map +1 -0
- package/dist/project/secureJournalFile.js +56 -0
- package/dist/project/secureJournalFile.js.map +1 -0
- package/dist/runtime/debugTokenStore.d.ts +41 -0
- package/dist/runtime/debugTokenStore.d.ts.map +1 -0
- package/dist/runtime/debugTokenStore.js +105 -0
- package/dist/runtime/debugTokenStore.js.map +1 -0
- package/dist/runtime/debuggerClient.d.ts +14 -0
- package/dist/runtime/debuggerClient.d.ts.map +1 -0
- package/dist/runtime/debuggerClient.js +21 -0
- package/dist/runtime/debuggerClient.js.map +1 -0
- package/dist/runtime/inputReceipt.d.ts +15 -0
- package/dist/runtime/inputReceipt.d.ts.map +1 -0
- package/dist/runtime/inputReceipt.js +36 -0
- package/dist/runtime/inputReceipt.js.map +1 -0
- package/dist/runtime/runtimeDescriptor.d.ts +50 -0
- package/dist/runtime/runtimeDescriptor.d.ts.map +1 -0
- package/dist/runtime/runtimeDescriptor.js +175 -0
- package/dist/runtime/runtimeDescriptor.js.map +1 -0
- package/dist/runtime/runtimeProcess.d.ts +39 -0
- package/dist/runtime/runtimeProcess.d.ts.map +1 -0
- package/dist/runtime/runtimeProcess.js +180 -0
- package/dist/runtime/runtimeProcess.js.map +1 -0
- package/dist/runtime/runtimeService.d.ts +130 -0
- package/dist/runtime/runtimeService.d.ts.map +1 -0
- package/dist/runtime/runtimeService.js +919 -0
- package/dist/runtime/runtimeService.js.map +1 -0
- package/dist/session/sessionService.d.ts +52 -0
- package/dist/session/sessionService.d.ts.map +1 -0
- package/dist/session/sessionService.js +72 -0
- package/dist/session/sessionService.js.map +1 -0
- package/dist/unsafe/unsafeFixtureAuthority.d.ts +27 -0
- package/dist/unsafe/unsafeFixtureAuthority.d.ts.map +1 -0
- package/dist/unsafe/unsafeFixtureAuthority.js +130 -0
- package/dist/unsafe/unsafeFixtureAuthority.js.map +1 -0
- package/dist/unsafe/unsafeFixtureProcess.d.ts +30 -0
- package/dist/unsafe/unsafeFixtureProcess.d.ts.map +1 -0
- package/dist/unsafe/unsafeFixtureProcess.js +119 -0
- package/dist/unsafe/unsafeFixtureProcess.js.map +1 -0
- package/dist/unsafe/unsafeFixtureService.d.ts +41 -0
- package/dist/unsafe/unsafeFixtureService.d.ts.map +1 -0
- package/dist/unsafe/unsafeFixtureService.js +162 -0
- package/dist/unsafe/unsafeFixtureService.js.map +1 -0
- package/dist/visual/pngComparison.d.ts +12 -0
- package/dist/visual/pngComparison.d.ts.map +1 -0
- package/dist/visual/pngComparison.js +136 -0
- package/dist/visual/pngComparison.js.map +1 -0
- package/dist/visual/scenarioService.d.ts +50 -0
- package/dist/visual/scenarioService.d.ts.map +1 -0
- package/dist/visual/scenarioService.js +421 -0
- package/dist/visual/scenarioService.js.map +1 -0
- package/dist/visual/visualService.d.ts +27 -0
- package/dist/visual/visualService.d.ts.map +1 -0
- package/dist/visual/visualService.js +70 -0
- package/dist/visual/visualService.js.map +1 -0
- package/package.json +26 -6
- package/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Godot MCP contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Godot MCP
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Godot MCP is an open-source, security-first MCP server and Godot editor addon. Phase 7 provides reversible installation, authenticated Godot 4.7 editor attachment, six default observe-only tools, explicitly gated runtime/input surfaces, permission-scoped editor authoring, native read-only GDScript debugging, and bounded structured performance evidence.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- macOS (the currently certified platform)
|
|
8
|
+
- Node.js 22
|
|
9
|
+
- pnpm 11.13.0
|
|
10
|
+
- Godot 4.7 stable
|
|
11
|
+
|
|
12
|
+
Compatibility is evidence-gated by `release/compatibility-matrix.json`. Godot 4.4–4.6 and Linux/Windows remain experimental until their exact matrix cells carry trusted certification receipts; pending cells are not advertised as supported.
|
|
13
|
+
|
|
14
|
+
## Source quick start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm install --frozen-lockfile
|
|
18
|
+
pnpm build
|
|
19
|
+
node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js init --project /absolute/path/to/godot-project
|
|
20
|
+
node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js doctor --project /absolute/path/to/godot-project
|
|
21
|
+
node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js editor --project /absolute/path/to/godot-project
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For a verified release-to-release replacement, run `godot-mcp upgrade --project /absolute/path/to/godot-project --source /absolute/path/to/new/addons/godot_mcp`. Upgrade and rollback refuse independently modified installed files and preserve the original uninstall preimage.
|
|
25
|
+
|
|
26
|
+
Use the `editor` command for the Phase 7-certified launch. It writes a short-lived owner-only startup attestation, then starts Godot with the authenticated editor debugger and native DAP assigned to one loopback port; the debugger binds first, so unauthenticated DAP never acquires a listener. The addon consumes the attestation and connects outward only when a matching MCP runtime publishes a short-lived pairing descriptor. Opening the project through another launcher keeps earlier editor features available, but runtime debugging fails closed because secure startup cannot be proven by copied user arguments alone.
|
|
27
|
+
|
|
28
|
+
Register the source checkout with Codex using absolute paths:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
codex mcp add godot -- node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js connect --project /absolute/path/to/godot-project
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The default registration remains observe-only. To opt into one MCP-owned instrumented runtime, explicitly grant both its tier and pack:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
codex mcp add godot-runtime -- node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js connect --project /absolute/path/to/godot-project --grant runtime_control --pack runtime
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To launch and automate the owned runtime, grant the input pack separately:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
codex mcp add godot-runtime-input -- node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js connect --project /absolute/path/to/godot-project --grant runtime_control --pack runtime --pack input
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
To preview and apply bounded editor mutations, explicitly grant both the mutation tier and editor pack:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
codex mcp add godot-editor -- node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js connect --project /absolute/path/to/godot-project --grant project_mutate --pack editor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Start a fresh Codex task after registration so the newly registered MCP server is exposed. To stop using the addon while retaining its files, or remove the verified installation completely:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js disable --project /absolute/path/to/godot-project
|
|
56
|
+
node /absolute/path/to/godot-mcp/packages/cli/dist/bin.js uninstall --project /absolute/path/to/godot-project
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Uninstall refuses to remove the addon, project configuration, or `project.godot` if they changed independently after installation.
|
|
60
|
+
|
|
61
|
+
## Implemented MCP tools
|
|
62
|
+
|
|
63
|
+
- `godot_session` — attachment, project identity, versions, and grants
|
|
64
|
+
- `godot_capabilities` — currently visible observe/core capabilities
|
|
65
|
+
- `godot_doctor` — installation, plugin, identity, and attachment diagnostics
|
|
66
|
+
- `godot_help` — built-in usage and security-boundary help
|
|
67
|
+
- `godot_query` — bounded editor state, open scene/tree/node metadata, indexed resources, approved project settings, and redacted diagnostics
|
|
68
|
+
- `godot_capture` — bounded PNG from the current 2D or selected 3D editor viewport, returned as MCP image content and persisted as session evidence
|
|
69
|
+
|
|
70
|
+
The default six tools are read-only and closed-world. A runtime-authorized session additionally exposes:
|
|
71
|
+
|
|
72
|
+
- `godot_runtime` — launch, bounded runtime queries/control, native GDScript breakpoints/stacks/variables/selector watches, monitor snapshots, and cancellable structured profiles for one authenticated child runtime
|
|
73
|
+
- `godot_runtime_capture` — one to eight ordered running-game PNG frames with verified evidence metadata
|
|
74
|
+
- `godot_input` — bounded events, frame-indexed sequences, non-passive recording, and deterministic replay for the owned runtime
|
|
75
|
+
- `godot_editor` — preview, apply, undo, and redo one bounded scene/node/resource/source authoring batch with durable idempotency and native editor history
|
|
76
|
+
|
|
77
|
+
For example:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{ "operation": "scene_tree", "scenePath": "res://main.tscn", "maxDepth": 8, "maxNodes": 250 }
|
|
81
|
+
{ "viewport": "2d", "maxWidth": 1280, "maxHeight": 720 }
|
|
82
|
+
{ "operation": "launch", "scenePath": "res://main.tscn" }
|
|
83
|
+
{ "operation": "debug_breakpoints_set", "handle": { "runId": "<run UUID>", "generation": 1 }, "breakpoints": [{ "sourcePath": "res://player.gd", "line": 42 }] }
|
|
84
|
+
{ "operation": "profile_start", "handle": { "runId": "<run UUID>", "generation": 1 }, "durationMs": 1000, "intervalFrames": 1, "groups": ["frame", "memory"], "retainRaw": false }
|
|
85
|
+
{ "operation": "sequence", "handle": { "runId": "<run UUID>", "generation": 1 }, "mode": "deterministic", "events": [{ "frameOffset": 0, "event": { "type": "action", "action": "jump", "pressed": true, "strengthMillionths": 1000000 } }, { "frameOffset": 1, "event": { "type": "action", "action": "jump", "pressed": false, "strengthMillionths": 0 } }] }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Runtime control and input are off unless their explicit flags are present. Deterministic sequences/replay require a paused owned runtime; offsets are zero-based, so offsets 0–1 process across two rendered frames and leave it paused. Recording captures only MCP-injected events. Receipts and audit summaries omit raw action names, keycodes, coordinates, and trace payloads. There is no OS-global/editor input, arbitrary text, process, filesystem, network, method-call, or GDScript-evaluation primitive.
|
|
89
|
+
|
|
90
|
+
## Development and certification
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-0-1
|
|
94
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-2
|
|
95
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-3
|
|
96
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-4
|
|
97
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-5
|
|
98
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-6
|
|
99
|
+
GODOT_BIN=/opt/homebrew/bin/godot pnpm qa:phase-7
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The Phase 7 gate certifies secure shared-port editor startup, native-DAP inertness, authenticated editor-session debugging, breakpoints/stacks/variables/selector watches, bounded public monitor snapshots, completed and cancelled profiles, hostile-input rejection, published stdio behavior, and zero owned-state or fixture residue. Earlier gates remain required regressions. See [Phase 7 testing](docs/testing/phase-7.md), [Phase 6 testing](docs/testing/phase-6.md), the [threat model](docs/security/threat-model.md), the [bridge protocol](docs/protocol/bridge-v1.md), and the [master design](docs/superpowers/specs/2026-07-15-godot-mcp-master-design.md).
|
|
103
|
+
|
|
104
|
+
## Roadmap
|
|
105
|
+
|
|
106
|
+
Later phases add declarative playtests, imports/builds/exports, evidence retrieval, compatibility lanes, and explicitly gated disposable-fixture unsafe mode. None of those capabilities are claimed by Phase 7.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type AuditRecord, type PermissionTier } from "@godot-mcp/protocol";
|
|
2
|
+
export interface AuditInput {
|
|
3
|
+
auditId?: string;
|
|
4
|
+
correlationId?: string;
|
|
5
|
+
sessionId: string | null;
|
|
6
|
+
projectId: string;
|
|
7
|
+
event: string;
|
|
8
|
+
outcome: string;
|
|
9
|
+
permissionTier: PermissionTier;
|
|
10
|
+
protocolVersion?: string;
|
|
11
|
+
startedAt?: string;
|
|
12
|
+
finishedAt?: string;
|
|
13
|
+
arguments: unknown;
|
|
14
|
+
errorCode: string | null;
|
|
15
|
+
evidence?: string[];
|
|
16
|
+
targetIdentities?: unknown[];
|
|
17
|
+
preconditions?: unknown[];
|
|
18
|
+
changes?: unknown[];
|
|
19
|
+
idempotencyKeySha256?: string | null;
|
|
20
|
+
partialEffects?: boolean;
|
|
21
|
+
rollback?: AuditRecord["rollback"];
|
|
22
|
+
}
|
|
23
|
+
export interface AuditSink {
|
|
24
|
+
append(input: AuditInput): Promise<AuditRecord>;
|
|
25
|
+
}
|
|
26
|
+
export declare class JsonlAuditSink implements AuditSink {
|
|
27
|
+
private readonly path;
|
|
28
|
+
private tail;
|
|
29
|
+
static forProject(projectRoot: string): JsonlAuditSink;
|
|
30
|
+
constructor(path: string);
|
|
31
|
+
append(input: AuditInput): Promise<AuditRecord>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=jsonlAuditSink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonlAuditSink.d.ts","sourceRoot":"","sources":["../../src/audit/jsonlAuditSink.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,cAAc,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACjD;AA4BD,qBAAa,cAAe,YAAW,SAAS;IAOlC,OAAO,CAAC,QAAQ,CAAC,IAAI;IANjC,OAAO,CAAC,IAAI,CAAuC;IAEnD,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc;gBAIzB,IAAI,EAAE,MAAM;IAEzC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;CAehD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, open } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { AuditRecordSchema, BRIDGE_PROTOCOL_VERSION, } from "@godot-mcp/protocol";
|
|
5
|
+
import { redactAuditValue } from "./redact.js";
|
|
6
|
+
function buildAuditRecord(input) {
|
|
7
|
+
const timestamp = new Date().toISOString();
|
|
8
|
+
return AuditRecordSchema.parse({
|
|
9
|
+
schemaVersion: 2,
|
|
10
|
+
auditId: input.auditId ?? randomUUID(),
|
|
11
|
+
correlationId: input.correlationId ?? randomUUID(),
|
|
12
|
+
sessionId: input.sessionId,
|
|
13
|
+
projectId: input.projectId,
|
|
14
|
+
event: input.event,
|
|
15
|
+
outcome: input.outcome,
|
|
16
|
+
permissionTier: input.permissionTier,
|
|
17
|
+
protocolVersion: input.protocolVersion ?? BRIDGE_PROTOCOL_VERSION,
|
|
18
|
+
startedAt: input.startedAt ?? timestamp,
|
|
19
|
+
finishedAt: input.finishedAt ?? timestamp,
|
|
20
|
+
arguments: redactAuditValue(input.arguments),
|
|
21
|
+
errorCode: input.errorCode,
|
|
22
|
+
evidence: input.evidence ?? [],
|
|
23
|
+
targetIdentities: input.targetIdentities ?? [],
|
|
24
|
+
preconditions: input.preconditions ?? [],
|
|
25
|
+
changes: input.changes ?? [],
|
|
26
|
+
idempotencyKeySha256: input.idempotencyKeySha256 ?? null,
|
|
27
|
+
partialEffects: input.partialEffects ?? false,
|
|
28
|
+
rollback: input.rollback ?? "not_needed",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export class JsonlAuditSink {
|
|
32
|
+
path;
|
|
33
|
+
tail = Promise.resolve();
|
|
34
|
+
static forProject(projectRoot) {
|
|
35
|
+
return new JsonlAuditSink(join(projectRoot, ".godot/evidence/godot-mcp/audit.jsonl"));
|
|
36
|
+
}
|
|
37
|
+
constructor(path) {
|
|
38
|
+
this.path = path;
|
|
39
|
+
}
|
|
40
|
+
append(input) {
|
|
41
|
+
const record = buildAuditRecord(input);
|
|
42
|
+
const write = this.tail.then(async () => {
|
|
43
|
+
await mkdir(dirname(this.path), { recursive: true, mode: 0o700 });
|
|
44
|
+
const handle = await open(this.path, "a", 0o600);
|
|
45
|
+
try {
|
|
46
|
+
await handle.writeFile(`${JSON.stringify(record)}\n`, "utf8");
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await handle.close();
|
|
50
|
+
}
|
|
51
|
+
return record;
|
|
52
|
+
});
|
|
53
|
+
this.tail = write.catch(() => undefined);
|
|
54
|
+
return write;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=jsonlAuditSink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonlAuditSink.js","sourceRoot":"","sources":["../../src/audit/jsonlAuditSink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,C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act.ts"],"names":[],"mappings":"AAmCA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAExD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const SECRET_KEY = /token|secret|password|authorization|cookie|private[_-]?key/i;
|
|
2
|
+
function binaryLength(value) {
|
|
3
|
+
if (Buffer.isBuffer(value))
|
|
4
|
+
return value.byteLength;
|
|
5
|
+
if (value instanceof ArrayBuffer)
|
|
6
|
+
return value.byteLength;
|
|
7
|
+
if (ArrayBuffer.isView(value))
|
|
8
|
+
return value.byteLength;
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
function redact(value, ancestors) {
|
|
12
|
+
const bytes = binaryLength(value);
|
|
13
|
+
if (bytes !== undefined)
|
|
14
|
+
return `[BINARY ${bytes} bytes]`;
|
|
15
|
+
if (value === null || ["string", "number", "boolean"].includes(typeof value))
|
|
16
|
+
return value;
|
|
17
|
+
if (value === undefined)
|
|
18
|
+
return "[UNDEFINED]";
|
|
19
|
+
if (["bigint", "function", "symbol"].includes(typeof value)) {
|
|
20
|
+
return `[${(typeof value).toUpperCase()}]`;
|
|
21
|
+
}
|
|
22
|
+
const objectValue = value;
|
|
23
|
+
if (ancestors.has(objectValue))
|
|
24
|
+
return "[CIRCULAR]";
|
|
25
|
+
ancestors.add(objectValue);
|
|
26
|
+
try {
|
|
27
|
+
if (Array.isArray(value))
|
|
28
|
+
return value.map((item) => redact(item, ancestors));
|
|
29
|
+
if (value instanceof Date)
|
|
30
|
+
return value.toISOString();
|
|
31
|
+
const output = {};
|
|
32
|
+
for (const [key, item] of Object.entries(value)) {
|
|
33
|
+
output[key] = SECRET_KEY.test(key) ? "[REDACTED]" : redact(item, ancestors);
|
|
34
|
+
}
|
|
35
|
+
return output;
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
ancestors.delete(objectValue);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function redactAuditValue(value) {
|
|
42
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CAAC;QACH,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,YAAY,IAAI;YAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;QAEtD,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC3E,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { SessionGrants } from "../policy/capabilities.js";
|
|
3
|
+
export declare const PairingDescriptorSchema: z.ZodObject<{
|
|
4
|
+
protocolVersion: z.ZodLiteral<"1.0">;
|
|
5
|
+
productVersion: z.ZodLiteral<"0.1.0">;
|
|
6
|
+
project: z.ZodObject<{
|
|
7
|
+
projectId: z.ZodUUID;
|
|
8
|
+
rootRealPath: z.ZodString;
|
|
9
|
+
projectConfigSha256: z.ZodString;
|
|
10
|
+
godotVersion: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
port: z.ZodNumber;
|
|
13
|
+
sessionNonce: z.ZodString;
|
|
14
|
+
token: z.ZodString;
|
|
15
|
+
grants: z.ZodObject<{
|
|
16
|
+
tiers: z.ZodArray<z.ZodEnum<{
|
|
17
|
+
observe: "observe";
|
|
18
|
+
runtime_control: "runtime_control";
|
|
19
|
+
project_mutate: "project_mutate";
|
|
20
|
+
project_operate: "project_operate";
|
|
21
|
+
unsafe_fixture: "unsafe_fixture";
|
|
22
|
+
}>>;
|
|
23
|
+
packs: z.ZodArray<z.ZodEnum<{
|
|
24
|
+
input: "input";
|
|
25
|
+
unsafe: "unsafe";
|
|
26
|
+
debug: "debug";
|
|
27
|
+
core: "core";
|
|
28
|
+
runtime: "runtime";
|
|
29
|
+
editor: "editor";
|
|
30
|
+
visual: "visual";
|
|
31
|
+
project: "project";
|
|
32
|
+
}>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
createdAtUnixMs: z.ZodNumber;
|
|
35
|
+
expiresAtUnixMs: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type SessionDescriptor = z.infer<typeof PairingDescriptorSchema>;
|
|
38
|
+
export interface PairingMaterial {
|
|
39
|
+
path: string;
|
|
40
|
+
descriptor: SessionDescriptor;
|
|
41
|
+
}
|
|
42
|
+
export declare function createPairingDescriptor(project: SessionDescriptor["project"], port: number, grants: SessionGrants): Promise<PairingMaterial>;
|
|
43
|
+
export declare function consumePairingDescriptor(path: string): Promise<SessionDescriptor>;
|
|
44
|
+
//# sourceMappingURL=pairingDescriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairingDescriptor.d.ts","sourceRoot":"","sources":["../../src/auth/pairingDescriptor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAalC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAaD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,iBAAiB,CAAC,SAAS,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,eAAe,CAAC,CA4B1B;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0BvF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { randomBytes, randomUUID } from "node:crypto";
|
|
2
|
+
import { lstat, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { basename, dirname, join } from "node:path";
|
|
4
|
+
import { BRIDGE_PROTOCOL_VERSION, CapabilityPackSchema, PermissionTierSchema, PRODUCT_VERSION, ProjectIdentitySchema, } from "@godot-mcp/protocol";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { GodotMcpException } from "../errors.js";
|
|
7
|
+
import { ensureRuntimeDirectory } from "./runtimeDirectory.js";
|
|
8
|
+
export const PairingDescriptorSchema = z.object({
|
|
9
|
+
protocolVersion: z.literal(BRIDGE_PROTOCOL_VERSION),
|
|
10
|
+
productVersion: z.literal(PRODUCT_VERSION),
|
|
11
|
+
project: ProjectIdentitySchema,
|
|
12
|
+
port: z.number().int().min(1).max(65_535),
|
|
13
|
+
sessionNonce: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
14
|
+
token: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
15
|
+
grants: z.object({
|
|
16
|
+
tiers: z.array(PermissionTierSchema),
|
|
17
|
+
packs: z.array(CapabilityPackSchema),
|
|
18
|
+
}),
|
|
19
|
+
createdAtUnixMs: z.number().int().positive(),
|
|
20
|
+
expiresAtUnixMs: z.number().int().positive(),
|
|
21
|
+
});
|
|
22
|
+
function authenticationFailed(message) {
|
|
23
|
+
return new GodotMcpException({
|
|
24
|
+
code: "AUTHENTICATION_FAILED",
|
|
25
|
+
message,
|
|
26
|
+
retryable: false,
|
|
27
|
+
correlationId: randomUUID(),
|
|
28
|
+
partialEffects: false,
|
|
29
|
+
rollback: "not_needed",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export async function createPairingDescriptor(project, port, grants) {
|
|
33
|
+
const runtimeDirectory = await ensureRuntimeDirectory();
|
|
34
|
+
const now = Date.now();
|
|
35
|
+
const descriptor = PairingDescriptorSchema.parse({
|
|
36
|
+
protocolVersion: BRIDGE_PROTOCOL_VERSION,
|
|
37
|
+
productVersion: PRODUCT_VERSION,
|
|
38
|
+
project,
|
|
39
|
+
port,
|
|
40
|
+
sessionNonce: randomBytes(32).toString("base64url"),
|
|
41
|
+
token: randomBytes(32).toString("base64url"),
|
|
42
|
+
grants,
|
|
43
|
+
createdAtUnixMs: now,
|
|
44
|
+
expiresAtUnixMs: now + 60_000,
|
|
45
|
+
});
|
|
46
|
+
const path = join(runtimeDirectory, `pair-${project.projectId}.json`);
|
|
47
|
+
try {
|
|
48
|
+
await writeFile(path, `${JSON.stringify(descriptor)}\n`, {
|
|
49
|
+
encoding: "utf8",
|
|
50
|
+
flag: "wx",
|
|
51
|
+
mode: 0o600,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code === "EEXIST") {
|
|
56
|
+
throw authenticationFailed("A pairing descriptor already exists for this project");
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
return { path, descriptor };
|
|
61
|
+
}
|
|
62
|
+
export async function consumePairingDescriptor(path) {
|
|
63
|
+
const consumingPath = join(dirname(path), `.consuming-${basename(path)}-${randomUUID()}`);
|
|
64
|
+
try {
|
|
65
|
+
await rename(path, consumingPath);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
throw authenticationFailed("Pairing descriptor is missing or already consumed");
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const metadata = await lstat(consumingPath);
|
|
72
|
+
if (!metadata.isFile() || metadata.isSymbolicLink() || (metadata.mode & 0o077) !== 0) {
|
|
73
|
+
throw authenticationFailed("Pairing descriptor permissions are invalid");
|
|
74
|
+
}
|
|
75
|
+
let descriptor;
|
|
76
|
+
try {
|
|
77
|
+
descriptor = PairingDescriptorSchema.parse(JSON.parse(await readFile(consumingPath, "utf8")));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw authenticationFailed("Pairing descriptor is malformed");
|
|
81
|
+
}
|
|
82
|
+
if (descriptor.expiresAtUnixMs < Date.now()) {
|
|
83
|
+
throw authenticationFailed("Pairing descriptor has expired");
|
|
84
|
+
}
|
|
85
|
+
return descriptor;
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
await rm(consumingPath, { force: true });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=pairingDescriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairingDescriptor.js","sourceRoot":"","sources":["../../src/auth/pairingDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO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AC,CAWjB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { lstat, mkdir } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { GodotMcpException } from "../errors.js";
|
|
5
|
+
function invalidRuntimeDirectory(message) {
|
|
6
|
+
return new GodotMcpException({
|
|
7
|
+
code: "AUTHENTICATION_FAILED",
|
|
8
|
+
message,
|
|
9
|
+
retryable: false,
|
|
10
|
+
correlationId: "runtime-directory",
|
|
11
|
+
partialEffects: false,
|
|
12
|
+
rollback: "not_needed",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function runtimeDirectoryPath(environment = process.env) {
|
|
16
|
+
return join(environment.XDG_RUNTIME_DIR || tmpdir(), "godot-mcp");
|
|
17
|
+
}
|
|
18
|
+
export async function ensureRuntimeDirectory(environment = process.env) {
|
|
19
|
+
const path = runtimeDirectoryPath(environment);
|
|
20
|
+
await mkdir(path, { recursive: true, mode: 0o700 });
|
|
21
|
+
const metadata = await lstat(path);
|
|
22
|
+
if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
|
|
23
|
+
throw invalidRuntimeDirectory("Godot MCP runtime path must be a private regular directory");
|
|
24
|
+
}
|
|
25
|
+
if ((metadata.mode & 0o077) !== 0) {
|
|
26
|
+
throw invalidRuntimeDirectory("Godot MCP runtime directory is accessible by other users");
|
|
27
|
+
}
|
|
28
|
+
return path;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=runtimeDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeDirectory.js","sourceRoot":"","sources":["../../src/auth/runtimeDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,SAAS,uBAAuB,CAAC,OAAe;IAC9C,OAAO,IAAI,iBAAiB,CAAC;QAC3B,IAAI,EAAE,uBAAuB;QAC7B,OAAO;QACP,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,mBAAmB;QAClC,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,cAAiC,OAAO,CAAC,GAAG;IAC/E,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,IAAI,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,cAAiC,OAAO,CAAC,GAAG;IAE5C,MAAM,IAAI,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC;QACzD,MAAM,uBAAuB,CAAC,4DAA4D,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,uBAAuB,CAAC,0DAA0D,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BridgeEnvelope } from "@godot-mcp/protocol";
|
|
2
|
+
export type UnsignedBridgeEnvelope = Omit<BridgeEnvelope, "mac">;
|
|
3
|
+
export interface EnvelopeVerificationOptions {
|
|
4
|
+
now?: () => number;
|
|
5
|
+
maxFutureMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function deriveSessionKey(token: string, sessionNonce: string, serverNonce: string): Buffer;
|
|
8
|
+
export declare function envelopeSigningText(envelope: UnsignedBridgeEnvelope): string;
|
|
9
|
+
export declare function signEnvelope(key: Uint8Array, envelope: UnsignedBridgeEnvelope): BridgeEnvelope;
|
|
10
|
+
export declare function verifyEnvelope(key: Uint8Array, input: unknown, options?: EnvelopeVerificationOptions): BridgeEnvelope;
|
|
11
|
+
export declare class EnvelopeVerifier {
|
|
12
|
+
private readonly key;
|
|
13
|
+
private readonly options;
|
|
14
|
+
private lastSequence;
|
|
15
|
+
constructor(key: Uint8Array, options?: EnvelopeVerificationOptions);
|
|
16
|
+
verify(input: unknown): BridgeEnvelope;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sessionCrypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionCrypto.d.ts","sourceRoot":"","sources":["../../src/auth/sessionCrypto.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAEjE,MAAM,WAAW,2BAA2B;IAC1C,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAuDD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,MAAM,CAMR;AAYD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,CAE5E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,sBAAsB,GAAG,cAAc,CAI9F;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,2BAAgC,GACxC,cAAc,CAqBhB;AAED,qBAAa,gBAAgB;IAIzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,YAAY,CAAK;gBAGN,GAAG,EAAE,UAAU,EACf,OAAO,GAAE,2BAAgC;IAG5D,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc;CAQvC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { BridgeEnvelopeSchema, canonicalFloat64Le, canonicalJson, decodeFloat64Le, } from "@godot-mcp/protocol";
|
|
3
|
+
import { GodotMcpException } from "../errors.js";
|
|
4
|
+
function authenticationFailed(message) {
|
|
5
|
+
return new GodotMcpException({
|
|
6
|
+
code: "AUTHENTICATION_FAILED",
|
|
7
|
+
message,
|
|
8
|
+
retryable: false,
|
|
9
|
+
correlationId: randomUUID(),
|
|
10
|
+
partialEffects: false,
|
|
11
|
+
rollback: "not_needed",
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const FLOAT_WIRE_KEY = "$godotMcpFloat64Le";
|
|
15
|
+
function isFloatWireShape(value) {
|
|
16
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) &&
|
|
17
|
+
Object.keys(value).length === 1 && FLOAT_WIRE_KEY in value;
|
|
18
|
+
}
|
|
19
|
+
function isFloatWireValue(value) {
|
|
20
|
+
return isFloatWireShape(value) && typeof value[FLOAT_WIRE_KEY] === "string" &&
|
|
21
|
+
/^[a-f0-9]{16}$/.test(value[FLOAT_WIRE_KEY]);
|
|
22
|
+
}
|
|
23
|
+
function encodeFloatParams(value, allowWireValues = false) {
|
|
24
|
+
if (typeof value === "number") {
|
|
25
|
+
if (Number.isFinite(value) && !Number.isSafeInteger(value)) {
|
|
26
|
+
return { [FLOAT_WIRE_KEY]: canonicalFloat64Le(value) };
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(value))
|
|
31
|
+
return value.map((entry) => encodeFloatParams(entry, allowWireValues));
|
|
32
|
+
if (value !== null && typeof value === "object") {
|
|
33
|
+
if (isFloatWireShape(value)) {
|
|
34
|
+
if (!allowWireValues)
|
|
35
|
+
throw new TypeError("Bridge parameters contain a reserved float wire value");
|
|
36
|
+
if (!isFloatWireValue(value))
|
|
37
|
+
throw new TypeError("Bridge parameters contain a malformed float wire value");
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, encodeFloatParams(entry, allowWireValues)]));
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function decodeFloatParams(value) {
|
|
45
|
+
if (isFloatWireValue(value))
|
|
46
|
+
return decodeFloat64Le(value[FLOAT_WIRE_KEY]);
|
|
47
|
+
if (Array.isArray(value))
|
|
48
|
+
return value.map(decodeFloatParams);
|
|
49
|
+
if (value !== null && typeof value === "object") {
|
|
50
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, decodeFloatParams(entry)]));
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
export function deriveSessionKey(token, sessionNonce, serverNonce) {
|
|
55
|
+
const tokenBytes = Buffer.from(token, "base64url");
|
|
56
|
+
if (tokenBytes.length !== 32)
|
|
57
|
+
throw authenticationFailed("Pairing token length is invalid");
|
|
58
|
+
return createHmac("sha256", tokenBytes)
|
|
59
|
+
.update(`godot-mcp:v1\n${sessionNonce}\n${serverNonce}`, "utf8")
|
|
60
|
+
.digest();
|
|
61
|
+
}
|
|
62
|
+
function signingText(envelope, allowWireValues) {
|
|
63
|
+
return [
|
|
64
|
+
envelope.sessionId,
|
|
65
|
+
String(envelope.sequence),
|
|
66
|
+
String(envelope.deadlineUnixMs),
|
|
67
|
+
envelope.method,
|
|
68
|
+
canonicalJson(encodeFloatParams(envelope.params, allowWireValues)),
|
|
69
|
+
].join("\n");
|
|
70
|
+
}
|
|
71
|
+
export function envelopeSigningText(envelope) {
|
|
72
|
+
return signingText(envelope, false);
|
|
73
|
+
}
|
|
74
|
+
export function signEnvelope(key, envelope) {
|
|
75
|
+
const wireEnvelope = { ...envelope, params: encodeFloatParams(envelope.params) };
|
|
76
|
+
const mac = createHmac("sha256", key).update(signingText(wireEnvelope, true), "utf8").digest("hex");
|
|
77
|
+
return BridgeEnvelopeSchema.parse({ ...wireEnvelope, mac });
|
|
78
|
+
}
|
|
79
|
+
export function verifyEnvelope(key, input, options = {}) {
|
|
80
|
+
let envelope;
|
|
81
|
+
try {
|
|
82
|
+
envelope = BridgeEnvelopeSchema.parse(input);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
throw authenticationFailed("Signed envelope is malformed");
|
|
86
|
+
}
|
|
87
|
+
const expected = createHmac("sha256", key)
|
|
88
|
+
.update(signingText(envelope, true), "utf8")
|
|
89
|
+
.digest();
|
|
90
|
+
const received = Buffer.from(envelope.mac, "hex");
|
|
91
|
+
if (received.length !== expected.length || !timingSafeEqual(received, expected)) {
|
|
92
|
+
throw authenticationFailed("Signed envelope MAC is invalid");
|
|
93
|
+
}
|
|
94
|
+
const now = (options.now ?? Date.now)();
|
|
95
|
+
const maxFutureMs = options.maxFutureMs ?? 60_000;
|
|
96
|
+
if (envelope.deadlineUnixMs < now || envelope.deadlineUnixMs - now > maxFutureMs) {
|
|
97
|
+
throw authenticationFailed("Signed envelope deadline is invalid");
|
|
98
|
+
}
|
|
99
|
+
return BridgeEnvelopeSchema.parse({ ...envelope, params: decodeFloatParams(envelope.params) });
|
|
100
|
+
}
|
|
101
|
+
export class EnvelopeVerifier {
|
|
102
|
+
key;
|
|
103
|
+
options;
|
|
104
|
+
lastSequence = 0;
|
|
105
|
+
constructor(key, options = {}) {
|
|
106
|
+
this.key = key;
|
|
107
|
+
this.options = options;
|
|
108
|
+
}
|
|
109
|
+
verify(input) {
|
|
110
|
+
const envelope = verifyEnvelope(this.key, input, this.options);
|
|
111
|
+
if (envelope.sequence <= this.lastSequence) {
|
|
112
|
+
throw authenticationFailed("Signed envelope sequence was replayed or reordered");
|
|
113
|
+
}
|
|
114
|
+
this.lastSequence = envelope.sequence;
|
|
115
|
+
return envelope;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=sessionCrypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionCrypto.js","sourceRoot":"","sources":["../../src/auth/sessionCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AASjD,SAAS,oBAAoB,CAAC,OAAe;IAC3C,OAAO,IAAI,iBAAiB,CAAC;QAC3B,IAAI,EAAE,uBAAuB;QAC7B,OAAO;QACP,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,UAAU,EAAE;QAC3B,cAAc,EAAE,KAAK;QACrB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAE5C,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,IAAI,KAAK,CAAC;AAC/D,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,OAA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