@7h3/protocol 0.1.2 → 0.4.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/.dockerignore +19 -0
- package/.github/dependabot.yml +32 -0
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/publish.yml +59 -0
- package/.github/workflows/scorecard.yml +37 -0
- package/7h3.example.yaml +125 -0
- package/CHANGELOG.md +92 -0
- package/CONTRIBUTING.md +82 -0
- package/Dockerfile +73 -0
- package/GOVERNANCE.md +62 -0
- package/README.md +323 -6
- package/SECURITY.md +70 -0
- package/bench-results/replay-cache-full-1777891033256.json +10 -0
- package/bench-results/replay-cache-full-1777896317488.json +10 -0
- package/bench-results/replay-cache-full-1777900993184.json +10 -0
- package/bench-results/replay-cache-full-1777901019285.json +10 -0
- package/bench-results/replay-cache-quick-1777870170126.json +10 -0
- package/bench-results/signature-profiles-quick-1775875160079.json +85 -0
- package/bench-results/signature-profiles-quick-1775983539716.json +85 -0
- package/bench-results/signature-profiles-quick-1776237913190.json +85 -0
- package/bench-results/wire-codecs-full-1777891019803.json +93 -0
- package/bench-results/wire-codecs-full-1777896260964.json +93 -0
- package/bench-results/wire-codecs-full-1777901004247.json +93 -0
- package/bench-results/wire-codecs-quick-1775972879056.json +93 -0
- package/bench-results/wire-codecs-quick-1775983541111.json +93 -0
- package/bench-results/wire-codecs-quick-1776237914299.json +93 -0
- package/bench-results/wire-codecs-quick-1777841285236.json +93 -0
- package/bench-results/wire-codecs-quick-1777841321772.json +93 -0
- package/bench-results/wire-codecs-quick-1777841330408.json +93 -0
- package/bench-results/wire-codecs-quick-1777852886082.json +93 -0
- package/bench-results/wire-codecs-quick-1777852988773.json +93 -0
- package/bench-results/wire-codecs-quick-1777870188095.json +93 -0
- package/bench-results/wire-codecs-quick-1777870263918.json +93 -0
- package/bench-results/wire-codecs-quick-1777870455034.json +93 -0
- package/bench-results/wire-codecs-quick-1778816163081.json +93 -0
- package/bench-results/wire-codecs-quick-1778843936130.json +93 -0
- package/bin/7h3.ts +385 -0
- package/conformance/7h3_v0_1.json +77 -0
- package/conformance/7h3_v0_1_binary.json +20 -0
- package/conformance/aip_v0_1_binary.json +20 -0
- package/docker-compose.yaml +77 -0
- package/docs/ADOPTION_PLAN.md +120 -0
- package/docs/AGENTS.md +77 -0
- package/docs/AIP_RFC_v0.1.md +97 -0
- package/docs/AI_DECISION_CARD.md +122 -0
- package/docs/AI_RUNTIME_POLICY.json +126 -0
- package/docs/AI_RUNTIME_POLICY.yaml +110 -0
- package/docs/BACKPRESSURE_TUNING.md +65 -0
- package/docs/BENCHMARK_CLAIM_MATRIX.md +42 -0
- package/docs/BENCHMARK_REPORT_TEMPLATE.md +169 -0
- package/docs/BINARY_CODEC_BENCH.md +23 -0
- package/docs/CLEAN_CLONE_RUNBOOK.md +36 -0
- package/docs/CLOCK_SKEW_POLICY.md +30 -0
- package/docs/DISTRIBUTED_REPLAY.md +142 -0
- package/docs/FUZZ_CAMPAIGN.md +121 -0
- package/docs/GATEWAY.md +195 -0
- package/docs/KEY_MANAGEMENT_POLICY.md +53 -0
- package/docs/KEY_REVOCATION.md +69 -0
- package/docs/MCP_WRAPPER.md +159 -0
- package/docs/MIGRATION_GUIDE.md +40 -0
- package/docs/OPERATORS.md +184 -0
- package/docs/PERF_REGRESSION_POLICY.md +34 -0
- package/docs/PROJECT_EXAMINATION_2026-05-31.md +219 -0
- package/docs/RELEASE_BENCHMARK_REPORT_2026-05-15.md +135 -0
- package/docs/RELEASE_GATE.md +25 -0
- package/docs/RELEASE_NOTES_v0.1.0.md +54 -0
- package/docs/SECURITY_REVIEW_2026-06-05.md +165 -0
- package/docs/TELEMETRY.md +41 -0
- package/docs/THREAT_MODEL.md +89 -0
- package/docs/VERSIONING_POLICY.md +30 -0
- package/docs/assets/banner.png +0 -0
- package/eslint.config.js +15 -0
- package/fuzz/ts/harness-decode.ts +136 -0
- package/fuzz/ts/harness-verify.ts +121 -0
- package/fuzz/ts/run.ts +35 -0
- package/mcp-server/README.md +38 -0
- package/mcp-server/package-lock.json +1187 -0
- package/mcp-server/package.json +35 -0
- package/mcp-server/src/index.ts +236 -0
- package/mcp-server/tsconfig.json +14 -0
- package/package.json +79 -13
- package/scripts/aip-framework-quickstart.ts +110 -0
- package/scripts/aip-mcp-gateway.ts +38 -0
- package/scripts/aip-mcp-wrap-demo.ts +72 -0
- package/scripts/aip-quickstart.ts +60 -0
- package/scripts/bench-diff.ts +118 -0
- package/scripts/bench-protocol-e2e.ts +937 -0
- package/scripts/bench-protocol-openloop.ts +1397 -0
- package/scripts/bench-replay-cache.ts +76 -0
- package/scripts/bench-signature-profiles.ts +180 -0
- package/scripts/bench-wire-codecs.ts +161 -0
- package/scripts/build-binary-conformance.ts +36 -0
- package/scripts/build-release-dashboard.ts +175 -0
- package/scripts/canary-rollout.ts +38 -0
- package/scripts/mcpGatewayCli.test.ts +116 -0
- package/scripts/prepare-aip-package.ts +88 -0
- package/scripts/regen-conformance-sigs.ts +18 -0
- package/scripts/release-gate.ts +19 -0
- package/scripts/validate-runtime-policy.ts +18 -0
- package/sdk/browser/index.test.ts +162 -0
- package/sdk/browser/index.ts +257 -0
- package/sdk/browser/package.json +13 -0
- package/sdk/go/go.mod +3 -0
- package/sdk/go/http.go +135 -0
- package/sdk/go/protocol.go +324 -0
- package/sdk/go/protocol_test.go +334 -0
- package/sdk/go/webhook.go +136 -0
- package/sdk/python/README.md +18 -0
- package/sdk/python/protocol_7h3/__init__.py +46 -0
- package/sdk/python/protocol_7h3/http.py +212 -0
- package/sdk/python/protocol_7h3/keys.py +149 -0
- package/sdk/python/protocol_7h3/protocol.py +525 -0
- package/sdk/python/protocol_7h3/queue.py +118 -0
- package/sdk/python/protocol_7h3/webhook.py +116 -0
- package/sdk/python/pyproject.toml +40 -0
- package/sdk/python/tests/test_conformance.py +110 -0
- package/sdk/python/tests/test_http.py +305 -0
- package/sdk/python/tests/test_keys.py +417 -0
- package/sdk/python/tests/test_queue.py +120 -0
- package/sdk/python/tests/test_webhook.py +345 -0
- package/sdk/rust/Cargo.lock +371 -0
- package/sdk/rust/Cargo.toml +25 -0
- package/sdk/rust/README.md +31 -0
- package/sdk/rust/fuzz/Cargo.toml +29 -0
- package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +46 -0
- package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +11 -0
- package/sdk/rust/src/bin/aip_mcp_gateway.rs +59 -0
- package/sdk/rust/src/http.rs +145 -0
- package/sdk/rust/src/keys.rs +161 -0
- package/sdk/rust/src/lib.rs +688 -0
- package/sdk/rust/src/queue.rs +79 -0
- package/sdk/rust/src/webhook.rs +86 -0
- package/sdk/rust/tests/conformance.rs +148 -0
- package/sdk/rust/tests/gateway.rs +130 -0
- package/sdk/rust/tests/http_webhook_queue.rs +201 -0
- package/sdk/rust/tests/keys.rs +189 -0
- package/src/agentAdapter.test.ts +48 -0
- package/src/agentAdapter.ts +56 -0
- package/src/auditLog.test.ts +145 -0
- package/src/auditLog.ts +147 -0
- package/src/conformance.test.ts +136 -0
- package/src/conformanceVectors.ts +99 -0
- package/src/frameworkAdapters.test.ts +290 -0
- package/src/frameworkAdapters.ts +261 -0
- package/src/gateway.test.ts +343 -0
- package/src/gateway.ts +171 -0
- package/src/grpcBinding.test.ts +211 -0
- package/src/grpcBinding.ts +103 -0
- package/src/httpBinding.test.ts +376 -0
- package/src/httpBinding.ts +163 -0
- package/src/index.ts +32 -0
- package/src/keyInfra.test.ts +278 -0
- package/src/keyInfra.ts +228 -0
- package/src/keyRegistry.ts +59 -0
- package/src/keyRotation.test.ts +78 -0
- package/src/keyRotation.ts +72 -0
- package/src/mcpGateway.test.ts +129 -0
- package/src/mcpGateway.ts +250 -0
- package/src/mcpTransports.test.ts +92 -0
- package/src/mcpTransports.ts +169 -0
- package/src/mcpWrapper.test.ts +179 -0
- package/src/mcpWrapper.ts +206 -0
- package/src/policyEnforcer.test.ts +99 -0
- package/src/policyEnforcer.ts +169 -0
- package/src/policyTelemetryFeedback.test.ts +25 -0
- package/src/policyTelemetryFeedback.ts +38 -0
- package/src/protocol.bench.ts +37 -0
- package/src/protocol.test.ts +155 -0
- package/src/protocol.ts +413 -0
- package/src/protocolAgent.test.ts +105 -0
- package/src/protocolAgent.ts +169 -0
- package/src/protocolBinary.test.ts +165 -0
- package/src/protocolBinary.ts +312 -0
- package/src/protocolCapabilities.ts +70 -0
- package/src/protocolFuzz.advanced.test.ts +235 -0
- package/src/protocolFuzz.test.ts +111 -0
- package/src/protocolNegative.test.ts +97 -0
- package/src/protocolReplay.test.ts +71 -0
- package/src/protocolReplay.ts +194 -0
- package/src/protocolTransport.test.ts +556 -0
- package/src/protocolTransport.ts +483 -0
- package/src/queueBinding.test.ts +130 -0
- package/src/queueBinding.ts +102 -0
- package/src/rateLimiter.test.ts +96 -0
- package/src/rateLimiter.ts +46 -0
- package/src/redisClient.ts +140 -0
- package/src/redisIntegration.test.ts +134 -0
- package/src/replayStores.test.ts +141 -0
- package/src/replayStores.ts +82 -0
- package/src/revocation.test.ts +98 -0
- package/src/revocation.ts +0 -0
- package/src/routePolicy.test.ts +87 -0
- package/src/routePolicy.ts +72 -0
- package/src/runtimePolicy.test.ts +49 -0
- package/src/runtimePolicy.ts +81 -0
- package/src/runtimePolicyManager.test.ts +29 -0
- package/src/runtimePolicyManager.ts +50 -0
- package/src/runtimePolicyPresets.ts +43 -0
- package/src/signedResponse.test.ts +111 -0
- package/src/signedResponse.ts +83 -0
- package/src/webhookBinding.test.ts +144 -0
- package/src/webhookBinding.ts +115 -0
- package/src/wsBinding.test.ts +221 -0
- package/src/wsBinding.ts +100 -0
- package/tsconfig.json +15 -0
- package/tsconfig.lib.json +23 -0
- package/vite.lib.config.ts +16 -0
- package/agentAdapter.d.ts +0 -26
- package/conformanceVectors.d.ts +0 -20
- package/frameworkAdapters.d.ts +0 -72
- package/index.d.ts +0 -20
- package/index.js +0 -1702
- package/keyRotation.d.ts +0 -20
- package/mcpGateway.d.ts +0 -37
- package/mcpTransports.d.ts +0 -62
- package/mcpWrapper.d.ts +0 -83
- package/policyEnforcer.d.ts +0 -50
- package/policyTelemetryFeedback.d.ts +0 -11
- package/protocol.d.ts +0 -66
- package/protocolAgent.d.ts +0 -58
- package/protocolBinary.d.ts +0 -8
- package/protocolCapabilities.d.ts +0 -24
- package/protocolReplay.d.ts +0 -35
- package/protocolTransport.d.ts +0 -73
- package/redisClient.d.ts +0 -49
- package/replayStores.d.ts +0 -32
- package/revocation.d.ts +0 -71
- package/runtimePolicy.d.ts +0 -24
- package/runtimePolicyManager.d.ts +0 -15
- package/runtimePolicyPresets.d.ts +0 -11
package/.dockerignore
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Node modules — rebuilt inside the image by npm ci
|
|
2
|
+
node_modules
|
|
3
|
+
|
|
4
|
+
# Git history — not needed in image layers
|
|
5
|
+
.git
|
|
6
|
+
|
|
7
|
+
# Log files
|
|
8
|
+
*.log
|
|
9
|
+
|
|
10
|
+
# Compiled TypeScript output from local dev builds (the Dockerfile
|
|
11
|
+
# builder stage produces its own clean dist/)
|
|
12
|
+
dist
|
|
13
|
+
|
|
14
|
+
# Rust build artefacts from the SDK sub-crate — large and irrelevant
|
|
15
|
+
# to the Node.js runtime image
|
|
16
|
+
sdk/rust/target
|
|
17
|
+
|
|
18
|
+
# Benchmark result JSON snapshots — not needed at runtime
|
|
19
|
+
bench-results
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Root package (npm)
|
|
4
|
+
- package-ecosystem: "npm"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
target-branch: "main"
|
|
9
|
+
groups:
|
|
10
|
+
npm-non-security:
|
|
11
|
+
applies-to: version-updates
|
|
12
|
+
patterns:
|
|
13
|
+
- "*"
|
|
14
|
+
|
|
15
|
+
# mcp-server sub-package (npm)
|
|
16
|
+
- package-ecosystem: "npm"
|
|
17
|
+
directory: "/mcp-server"
|
|
18
|
+
schedule:
|
|
19
|
+
interval: "weekly"
|
|
20
|
+
target-branch: "main"
|
|
21
|
+
groups:
|
|
22
|
+
npm-mcp-non-security:
|
|
23
|
+
applies-to: version-updates
|
|
24
|
+
patterns:
|
|
25
|
+
- "*"
|
|
26
|
+
|
|
27
|
+
# GitHub Actions
|
|
28
|
+
- package-ecosystem: "github-actions"
|
|
29
|
+
directory: "/"
|
|
30
|
+
schedule:
|
|
31
|
+
interval: "weekly"
|
|
32
|
+
target-branch: "main"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v7
|
|
11
|
+
- uses: actions/setup-node@v6
|
|
12
|
+
with:
|
|
13
|
+
node-version: '22'
|
|
14
|
+
- run: npm install
|
|
15
|
+
- run: npm run lint
|
|
16
|
+
- run: npm run test
|
|
17
|
+
- run: npm run build:aip
|
|
18
|
+
conformance:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v7
|
|
22
|
+
- uses: actions/setup-node@v6
|
|
23
|
+
with:
|
|
24
|
+
node-version: '22'
|
|
25
|
+
- uses: actions/setup-python@v6
|
|
26
|
+
with:
|
|
27
|
+
python-version: '3.12'
|
|
28
|
+
- run: pip install cryptography
|
|
29
|
+
- run: npm install
|
|
30
|
+
- run: npm run conformance:python
|
|
31
|
+
- run: npm run conformance:rust
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish-aip:
|
|
14
|
+
name: publish @7h3/protocol
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v7
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-node@v6
|
|
20
|
+
with:
|
|
21
|
+
node-version: '20'
|
|
22
|
+
registry-url: 'https://registry.npmjs.org'
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm ci
|
|
26
|
+
|
|
27
|
+
- name: Build dist/npm-aip
|
|
28
|
+
run: npm run package:aip
|
|
29
|
+
|
|
30
|
+
- name: Publish @7h3/protocol
|
|
31
|
+
run: npm publish --provenance --access public
|
|
32
|
+
working-directory: dist/npm-aip
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
+
|
|
36
|
+
publish-mcp:
|
|
37
|
+
name: publish @7h3/protocol-mcp
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v7
|
|
41
|
+
|
|
42
|
+
- uses: actions/setup-node@v6
|
|
43
|
+
with:
|
|
44
|
+
node-version: '20'
|
|
45
|
+
registry-url: 'https://registry.npmjs.org'
|
|
46
|
+
|
|
47
|
+
- name: Install dependencies
|
|
48
|
+
run: npm ci
|
|
49
|
+
working-directory: mcp-server
|
|
50
|
+
|
|
51
|
+
- name: Build mcp-server
|
|
52
|
+
run: npm run build
|
|
53
|
+
working-directory: mcp-server
|
|
54
|
+
|
|
55
|
+
- name: Publish @7h3/protocol-mcp
|
|
56
|
+
run: npm publish --provenance --access public
|
|
57
|
+
working-directory: mcp-server
|
|
58
|
+
env:
|
|
59
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: scorecard
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '30 1 * * 1' # weekly, Monday 01:30 UTC
|
|
8
|
+
pull_request:
|
|
9
|
+
branches: [main]
|
|
10
|
+
|
|
11
|
+
permissions: read-all
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
analysis:
|
|
15
|
+
name: scorecard-analysis
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
permissions:
|
|
18
|
+
security-events: write
|
|
19
|
+
id-token: write
|
|
20
|
+
contents: read
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v7
|
|
24
|
+
with:
|
|
25
|
+
persist-credentials: false
|
|
26
|
+
|
|
27
|
+
- name: Run OpenSSF Scorecard
|
|
28
|
+
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
|
29
|
+
with:
|
|
30
|
+
results_file: results.sarif
|
|
31
|
+
results_format: sarif
|
|
32
|
+
publish_results: true
|
|
33
|
+
|
|
34
|
+
- name: Upload SARIF to GitHub Security tab
|
|
35
|
+
uses: github/codeql-action/upload-sarif@v4
|
|
36
|
+
with:
|
|
37
|
+
sarif_file: results.sarif
|
package/7h3.example.yaml
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# 7h3 Protocol — Gateway Configuration Example
|
|
2
|
+
# Wire version: 7h3/0.1
|
|
3
|
+
# Reference: docs/GATEWAY.md
|
|
4
|
+
#
|
|
5
|
+
# All fields shown below are optional unless marked (required).
|
|
6
|
+
|
|
7
|
+
# ---------------------------------------------------------------------------
|
|
8
|
+
# Core proxy settings
|
|
9
|
+
# ---------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
# (required) URL of the upstream service to proxy requests to.
|
|
12
|
+
# The gateway strips AIP envelopes, verifies signatures, and forwards clean
|
|
13
|
+
# HTTP requests to this address. The request path is appended verbatim.
|
|
14
|
+
upstream: http://api:3000
|
|
15
|
+
|
|
16
|
+
# Port the gateway HTTP server binds to (default: 8080).
|
|
17
|
+
port: 8080
|
|
18
|
+
|
|
19
|
+
# ---------------------------------------------------------------------------
|
|
20
|
+
# Gateway identity — needed only when sign_responses: true
|
|
21
|
+
# ---------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
# The sender identifier this gateway uses when signing response envelopes.
|
|
24
|
+
# Must match the key-id advertised in your /.well-known/7h3-keys document
|
|
25
|
+
# if you are using key-discovery.
|
|
26
|
+
sender: gateway@my-service.example.com
|
|
27
|
+
|
|
28
|
+
# Ed25519 private key (PKCS8, base64url-encoded) used to sign responses.
|
|
29
|
+
# Generate one with: 7h3 keygen --output my-keys.json
|
|
30
|
+
# Keep this value secret — store it in a mounted secret or environment
|
|
31
|
+
# variable and reference it as $GATEWAY_PRIVATE_KEY instead.
|
|
32
|
+
#
|
|
33
|
+
# private_key: <base64url-encoded PKCS8 private key> # or use $GATEWAY_PRIVATE_KEY
|
|
34
|
+
|
|
35
|
+
# Whether the gateway should sign every upstream response it proxies.
|
|
36
|
+
# Requires private_key and sender to be set. (default: false)
|
|
37
|
+
sign_responses: false
|
|
38
|
+
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
# Default policy
|
|
41
|
+
# ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
# What to do when an incoming request does not match any entry in the
|
|
44
|
+
# `policies` list below.
|
|
45
|
+
#
|
|
46
|
+
# allow — pass the request through without signature verification
|
|
47
|
+
# (use for development or fully-open APIs)
|
|
48
|
+
# deny — reject with HTTP 403
|
|
49
|
+
# (use for production; whitelist routes explicitly via policies)
|
|
50
|
+
#
|
|
51
|
+
# default: allow
|
|
52
|
+
default_policy: deny
|
|
53
|
+
|
|
54
|
+
# ---------------------------------------------------------------------------
|
|
55
|
+
# Key registry — maps sender identities to their public keys
|
|
56
|
+
# ---------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
keys:
|
|
59
|
+
# The gateway's own public key (used to verify self-signed test requests
|
|
60
|
+
# or to advertise via the /.well-known/7h3-keys endpoint).
|
|
61
|
+
private_key: <base64url-encoded PKCS8 private key>
|
|
62
|
+
|
|
63
|
+
# Registry maps senderID (any opaque string) → Ed25519 SPKI public key
|
|
64
|
+
# (base64url-encoded). Add one entry per trusted agent or service.
|
|
65
|
+
registry:
|
|
66
|
+
# Internal orchestrator service
|
|
67
|
+
orchestrator@my-service.example.com: <base64url-encoded SPKI public key>
|
|
68
|
+
|
|
69
|
+
# Admin automation agent with elevated privileges
|
|
70
|
+
admin-agent@my-service.example.com: <base64url-encoded SPKI public key>
|
|
71
|
+
|
|
72
|
+
# Third-party partner integration
|
|
73
|
+
partner-bot@partner.example.com: <base64url-encoded SPKI public key>
|
|
74
|
+
|
|
75
|
+
# ---------------------------------------------------------------------------
|
|
76
|
+
# Route policies
|
|
77
|
+
# ---------------------------------------------------------------------------
|
|
78
|
+
# Evaluated in order — the first matching policy wins.
|
|
79
|
+
# Glob syntax:
|
|
80
|
+
# /exact/path — exact match
|
|
81
|
+
# /api/* — single segment wildcard (no slashes)
|
|
82
|
+
# /api/** — multi-segment wildcard (crosses slashes)
|
|
83
|
+
# /users/?d — single character wildcard
|
|
84
|
+
#
|
|
85
|
+
# Policy fields:
|
|
86
|
+
# path — glob pattern (required)
|
|
87
|
+
# require — signature algorithm: ed25519 | hmac | any | none
|
|
88
|
+
# allowed_senders — list of senderIDs permitted on this route
|
|
89
|
+
# (omit to allow any verified sender)
|
|
90
|
+
# rate_limit — sliding-window limit applied per sender
|
|
91
|
+
# requests — max requests in the window
|
|
92
|
+
# window_ms — window duration in milliseconds
|
|
93
|
+
# sign_response — override sign_responses for this route only
|
|
94
|
+
|
|
95
|
+
policies:
|
|
96
|
+
# -- Admin endpoints -------------------------------------------------
|
|
97
|
+
# Require Ed25519 signatures and restrict to explicitly named agents.
|
|
98
|
+
# No rate limit — admin tooling is expected to be low-volume.
|
|
99
|
+
- path: /api/admin/**
|
|
100
|
+
require: ed25519
|
|
101
|
+
allowed_senders:
|
|
102
|
+
- admin-agent@my-service.example.com
|
|
103
|
+
- orchestrator@my-service.example.com
|
|
104
|
+
sign_response: true # always sign admin responses so callers can verify
|
|
105
|
+
|
|
106
|
+
# -- General API endpoints -------------------------------------------
|
|
107
|
+
# Require Ed25519; any verified sender may call; rate-limit per sender
|
|
108
|
+
# to 1 000 requests per 60-second sliding window.
|
|
109
|
+
- path: /api/**
|
|
110
|
+
require: ed25519
|
|
111
|
+
rate_limit:
|
|
112
|
+
requests: 1000
|
|
113
|
+
window_ms: 60000 # 60 seconds
|
|
114
|
+
|
|
115
|
+
# -- Health check ----------------------------------------------------
|
|
116
|
+
# Completely open — no signature needed. Suitable for load-balancer
|
|
117
|
+
# probes, uptime monitors, and Kubernetes liveness/readiness checks.
|
|
118
|
+
- path: /health
|
|
119
|
+
require: none
|
|
120
|
+
|
|
121
|
+
# -- Public read-only endpoints --------------------------------------
|
|
122
|
+
# No signature required; these routes serve unauthenticated traffic
|
|
123
|
+
# (documentation, status pages, marketing content, etc.).
|
|
124
|
+
- path: /public/**
|
|
125
|
+
require: none
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@7h3/protocol` are documented here.
|
|
4
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## [0.1.2] — 2026-06-05
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `SECURITY.md` — coordinated vulnerability disclosure process, 48h acknowledgement / 14-day critical patch SLA, Hall of Thanks
|
|
13
|
+
- `CONTRIBUTING.md` — test commands, wire-freeze policy, conformance fixture update requirement, PR workflow
|
|
14
|
+
- `GOVERNANCE.md` — LF Minimum Viable Governance style: single-maintainer stage, decision process, co-maintainership path
|
|
15
|
+
- `.github/dependabot.yml` — weekly npm and GitHub Actions dependency updates; non-security updates grouped to reduce noise
|
|
16
|
+
- `.github/workflows/scorecard.yml` — OpenSSF Scorecard workflow (activates when Actions billing is restored)
|
|
17
|
+
- `.github/workflows/publish.yml` — provenance-enabled npm publish workflow for both `@7h3/protocol` and `@7h3/protocol-mcp` (activates when Actions billing is restored)
|
|
18
|
+
- `src/protocolFuzz.advanced.test.ts` — 8 property-based fuzz tests via fast-check: wire decoder resilience (never throws on arbitrary input), canonicalization determinism (field-order invariant), replay cache uniqueness properties
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- README: added Ed25519 production recommendation with code snippet; added Security section linking to SECURITY.md
|
|
22
|
+
- `docs/MCP_WRAPPER.md`: added HMAC vs Ed25519 comparison table and Ed25519 `wrapMcpServer` example
|
|
23
|
+
- `mcp-server`: updated `aip_wrap_mcp_server` tool description to guide toward Ed25519 for production; HMAC boilerplate now includes a production upgrade comment
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
- README: corrected overstated fuzz status (now accurately notes property-based tests exist; formal fuzzing campaign still not done)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## [0.1.1] — 2026-06-05
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
- Published package was missing 21 individual `.d.ts` module files — only `index.d.ts` was included, causing TS2305 errors in any consumer using NodeNext or bundler moduleResolution. All 22 declaration files now ship with the package.
|
|
34
|
+
- `scripts/prepare-aip-package.ts`: copy all `.d.ts` files from `dist/aip/` instead of only `index.d.ts`
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
- `@7h3/protocol-mcp@0.1.0` — MCP server installable into Claude Code (`claude mcp add aip -- npx @7h3/protocol-mcp`). Five tools: `aip_generate_secret`, `aip_generate_keypair`, `aip_wrap_mcp_server`, `aip_sign`, `aip_verify`
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## [0.1.0] — 2026-06-01
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
**Core protocol (`aip/0.1`)**
|
|
46
|
+
- `createEnvelope` / `signEnvelopeHmac` / `signEnvelopeEd25519` — envelope construction and signing over a deterministic canonical form (fixed key order).
|
|
47
|
+
- `verifyEnvelopeHmac` / `verifyEnvelopeEd25519` — tamper-evident verification via real WebCrypto (no hand-rolled crypto).
|
|
48
|
+
- `validateEnvelope` — structural + TTL + clock-skew validation with typed diagnostics.
|
|
49
|
+
- `receiveEnvelope` — full receive pipeline: validate → verify → replay-check, composable via `ReceiveEnvelopeOptions`.
|
|
50
|
+
- Wire formats: `json`, `compact` (minified), `binary` (MessagePack); encode/decode via `encodeEnvelope` / `decodeEnvelope`.
|
|
51
|
+
- Polyglot parity: shared conformance fixture set (`conformance/aip_v0_1.json`) proves byte-identical signatures across TypeScript, Python (`aip7h3`), and Rust (`aip7h3`).
|
|
52
|
+
|
|
53
|
+
**Replay protection**
|
|
54
|
+
- `InMemoryReplayCache` — single-process `(sender, messageId, nonce)` uniqueness window with TTL.
|
|
55
|
+
- `DistributedReplayCache` — wraps any `DistributedReplayStore`; routes batch ops through `reserveMany` when available.
|
|
56
|
+
- `createRedisReplayStore` — atomic `SET NX PX` reserve over a client-agnostic `RedisLikeClient` interface; batch pipeline via `reserveMany`; `errorBehavior: 'fallback' | 'reject' | 'allow'` with graceful degradation to local store and `onDegraded` hook.
|
|
57
|
+
- `InMemoryRedisLikeClient` — reference implementation for tests (no Redis dep required).
|
|
58
|
+
|
|
59
|
+
**Fleet-wide key revocation**
|
|
60
|
+
- `InMemoryRevocationStore` — single-process; supports time-bounded `untilMs`.
|
|
61
|
+
- `createRedisRevocationStore` — cached reads (`cacheTtlMs` default 5 s), **fail-closed default** (`errorBehavior: 'reject'`), serves stale cache during Redis outage.
|
|
62
|
+
- `withRevocationCheck` — wraps any `SignatureResolver`; revoked key returns `undefined` → verification fails.
|
|
63
|
+
|
|
64
|
+
**MCP hardening wrapper**
|
|
65
|
+
- `wrapMcpServer` — sign + replay-protect an existing MCP handler with zero handler changes; enforces recipient binding (cross-server relay defense).
|
|
66
|
+
- `wrapMcpClient` / `createMcpClientCodec` — sign outbound requests; enforce sender binding (response-spoof defense) and correlation binding (response-substitution defense); replay protection on by default.
|
|
67
|
+
- Demo: `npm run aip:mcp:wrap` — proves tampered and replayed requests rejected.
|
|
68
|
+
|
|
69
|
+
**Transport adapters**
|
|
70
|
+
- `serveMcpOverStdio` / `createStdioMcpClient` — newline-delimited; in-order sequential chain prevents response interleaving.
|
|
71
|
+
- `createHttpMcpHandler` / `createHttpMcpClient` — `node:http` handler + `fetch` client; supports `binary` wire format.
|
|
72
|
+
- No new runtime dependencies (uses `node:readline`, `node:http`, `node:stream`, global `fetch`).
|
|
73
|
+
|
|
74
|
+
**Key management & policy**
|
|
75
|
+
- Key rotation support (`keyRotation`), runtime policy (`runtimePolicy`, `policyEnforcer`), telemetry feedback hooks.
|
|
76
|
+
- Framework adapters (`frameworkAdapters`), agent adapter (`agentAdapter`), MCP gateway (`mcpGateway`).
|
|
77
|
+
|
|
78
|
+
### Documentation
|
|
79
|
+
- `docs/THREAT_MODEL.md` — full threat coverage matrix.
|
|
80
|
+
- `docs/DISTRIBUTED_REPLAY.md` — Redis store setup, `errorBehavior` table, operational guidance.
|
|
81
|
+
- `docs/KEY_REVOCATION.md` — revocation store setup, cache TTL tuning.
|
|
82
|
+
- `docs/MCP_WRAPPER.md` — threat coverage table, server + client usage, transport examples.
|
|
83
|
+
|
|
84
|
+
### Test coverage
|
|
85
|
+
- 123 tests / 22 test files — all green.
|
|
86
|
+
- Live-Redis integration test (`redisIntegration.test.ts`) — auto-skips if no server present.
|
|
87
|
+
- Python conformance: `conformance:python`.
|
|
88
|
+
- Rust: `conformance:rust` (7 tests).
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
[0.1.0]: https://github.com/IceMasterT/7h3-protocol-aip/releases/tag/v0.1.0
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Contributing to @7h3/protocol
|
|
2
|
+
|
|
3
|
+
Thanks for your interest. This document covers how to run tests, submit changes,
|
|
4
|
+
and understand what is and is not open for modification.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
- Node.js 20+
|
|
9
|
+
- Python 3.10+ (for Python conformance tests)
|
|
10
|
+
- Rust stable toolchain (for Rust conformance tests)
|
|
11
|
+
|
|
12
|
+
Install Node dependencies:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Running Tests
|
|
19
|
+
|
|
20
|
+
**TypeScript unit and integration tests:**
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm test
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Cross-runtime conformance tests:**
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm run conformance:python # runs sdk/python/tests via unittest
|
|
30
|
+
npm run conformance:rust # runs cargo test in sdk/rust/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
All three test suites must pass before a PR is mergeable.
|
|
34
|
+
|
|
35
|
+
## The Wire Version is Frozen
|
|
36
|
+
|
|
37
|
+
`aip/0.1` is the current wire version, and **it is frozen**. This means:
|
|
38
|
+
|
|
39
|
+
- The envelope schema (field names, types, required fields) cannot change
|
|
40
|
+
- The canonicalization algorithm cannot change
|
|
41
|
+
- The intent vocabulary (`tool_call`, `tool_result`, `message`, `error`) cannot change
|
|
42
|
+
|
|
43
|
+
Any change to these would silently break cross-runtime interoperability and
|
|
44
|
+
require a new wire version designation. If you believe a wire-level change is
|
|
45
|
+
necessary, open an issue first to discuss versioning strategy before writing code.
|
|
46
|
+
|
|
47
|
+
The TypeScript API (types, builder functions, SDK surface) is pre-1.0 and may
|
|
48
|
+
evolve on minor version bumps. Deprecation notices will be included in the
|
|
49
|
+
changelog when possible.
|
|
50
|
+
|
|
51
|
+
## Conformance Fixtures
|
|
52
|
+
|
|
53
|
+
The canonical fixture set lives at `conformance/aip_v0_1.json`. If your PR adds
|
|
54
|
+
or changes any signing behavior, canonicalization detail, or replay-safety logic,
|
|
55
|
+
you must update this fixture file with vectors that cover the new behavior.
|
|
56
|
+
|
|
57
|
+
Fixtures are the source of truth for cross-runtime verification. A PR that
|
|
58
|
+
changes signing logic without updating fixtures will be rejected.
|
|
59
|
+
|
|
60
|
+
## Submitting a Pull Request
|
|
61
|
+
|
|
62
|
+
1. Fork the repo and create a branch with a descriptive name
|
|
63
|
+
(`fix/nonce-validation`, `feat/ed448-profile`, etc.)
|
|
64
|
+
2. Make your changes and ensure all three test suites pass
|
|
65
|
+
3. Update `conformance/aip_v0_1.json` if signing behavior changed
|
|
66
|
+
4. Open a PR against `main` with a clear description of:
|
|
67
|
+
- What the change does
|
|
68
|
+
- Why it is needed
|
|
69
|
+
- Any trade-offs or alternatives you considered
|
|
70
|
+
5. Reference any related issues in the PR description
|
|
71
|
+
|
|
72
|
+
Keep PRs focused. A single PR that mixes unrelated changes is harder to review
|
|
73
|
+
and slower to land.
|
|
74
|
+
|
|
75
|
+
## Security Findings
|
|
76
|
+
|
|
77
|
+
Do not open GitHub Issues for security vulnerabilities. Follow the process in
|
|
78
|
+
[SECURITY.md](SECURITY.md) instead.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
Maintainer: [@IceMasterT](https://github.com/IceMasterT)
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ---------------------------------------------------------------------------
|
|
2
|
+
# Stage 1 — builder
|
|
3
|
+
# Install all dependencies (including devDeps for the build step) and
|
|
4
|
+
# compile TypeScript sources. The compiled output ends up in /app/dist.
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
FROM node:22-alpine AS builder
|
|
7
|
+
|
|
8
|
+
WORKDIR /app
|
|
9
|
+
|
|
10
|
+
# Copy manifests first so Docker can cache the install layer separately
|
|
11
|
+
# from source changes.
|
|
12
|
+
COPY package.json package-lock.json ./
|
|
13
|
+
|
|
14
|
+
# Install all deps (dev + prod) needed to build
|
|
15
|
+
RUN npm ci --prefer-offline
|
|
16
|
+
|
|
17
|
+
# Copy the full source tree
|
|
18
|
+
COPY src/ src/
|
|
19
|
+
COPY bin/ bin/
|
|
20
|
+
COPY tsconfig.json tsconfig.lib.json ./
|
|
21
|
+
COPY vite.lib.config.ts ./
|
|
22
|
+
|
|
23
|
+
# Run the build script if it exists; swallow the error gracefully so that
|
|
24
|
+
# repositories that haven't wired up the build step yet still produce a
|
|
25
|
+
# working image. The runtime stage uses tsx to execute TypeScript directly,
|
|
26
|
+
# so a missing dist/ is not fatal.
|
|
27
|
+
RUN npm run build:protocol 2>/dev/null || true
|
|
28
|
+
|
|
29
|
+
# ---------------------------------------------------------------------------
|
|
30
|
+
# Stage 2 — runtime
|
|
31
|
+
# Lean image with only production dependencies.
|
|
32
|
+
# tsx executes TypeScript directly, so we don't strictly need dist/; the
|
|
33
|
+
# builder stage is kept separate to avoid polluting the final image with
|
|
34
|
+
# devDependencies and intermediate build artefacts.
|
|
35
|
+
# ---------------------------------------------------------------------------
|
|
36
|
+
FROM node:22-alpine
|
|
37
|
+
|
|
38
|
+
# Install tsx globally so the ENTRYPOINT can invoke TypeScript files.
|
|
39
|
+
# Pinning via the package.json range is intentional — renovate will keep
|
|
40
|
+
# this in sync with the devDependency version.
|
|
41
|
+
RUN npm install -g tsx
|
|
42
|
+
|
|
43
|
+
WORKDIR /app
|
|
44
|
+
|
|
45
|
+
# Copy manifests for production install
|
|
46
|
+
COPY package.json package-lock.json ./
|
|
47
|
+
|
|
48
|
+
# Production-only install; omits devDependencies such as vitest and vite
|
|
49
|
+
RUN npm ci --omit=dev --prefer-offline
|
|
50
|
+
|
|
51
|
+
# Copy the source files required at runtime
|
|
52
|
+
COPY src/ src/
|
|
53
|
+
COPY bin/ bin/
|
|
54
|
+
|
|
55
|
+
# Copy compiled output from the builder stage (used when tsx is not
|
|
56
|
+
# available or when --no-tsx mode is added in future).
|
|
57
|
+
COPY --from=builder /app/dist/ dist/
|
|
58
|
+
|
|
59
|
+
# The gateway listens on this port by default.
|
|
60
|
+
EXPOSE 8080
|
|
61
|
+
|
|
62
|
+
# Lightweight health check: wget is present on node:alpine; curl is not.
|
|
63
|
+
# This probe hits the /health route which, per the example config, is
|
|
64
|
+
# policy-exempt (require: none) and will pass through to the upstream.
|
|
65
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
66
|
+
CMD wget -qO- http://localhost:8080/health || exit 1
|
|
67
|
+
|
|
68
|
+
# Run the gateway sub-command of the 7h3 CLI.
|
|
69
|
+
ENTRYPOINT ["tsx", "bin/7h3.ts", "gateway"]
|
|
70
|
+
|
|
71
|
+
# Default arguments — overridden at runtime via docker-compose environment
|
|
72
|
+
# variables or explicit docker run arguments.
|
|
73
|
+
CMD ["--port", "8080", "--upstream", "http://upstream:3000", "--require", "ed25519"]
|
package/GOVERNANCE.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Governance
|
|
2
|
+
|
|
3
|
+
## Current Stage
|
|
4
|
+
|
|
5
|
+
This project is in single-maintainer, pre-community stage. There is one
|
|
6
|
+
maintainer ([@IceMasterT](https://github.com/IceMasterT)), no formal governance
|
|
7
|
+
board, and no steering committee. That is appropriate for the project's current
|
|
8
|
+
size and maturity, and it is stated clearly here so contributors know what to
|
|
9
|
+
expect.
|
|
10
|
+
|
|
11
|
+
## Decision Making
|
|
12
|
+
|
|
13
|
+
The maintainer makes all final decisions about direction, API shape, release
|
|
14
|
+
timing, and whether to accept a contribution.
|
|
15
|
+
|
|
16
|
+
For significant changes -- anything that touches the wire format, the
|
|
17
|
+
conformance fixture set, or the project's positioning relative to MCP/A2A --
|
|
18
|
+
the maintainer will open a GitHub Issue before deciding, to give the community
|
|
19
|
+
a window to raise concerns or provide context. That window will be at least
|
|
20
|
+
seven days for non-urgent changes.
|
|
21
|
+
|
|
22
|
+
Day-to-day decisions (bug fixes, documentation, minor SDK improvements) do not
|
|
23
|
+
require community input first.
|
|
24
|
+
|
|
25
|
+
## Versioning Policy
|
|
26
|
+
|
|
27
|
+
The wire version `aip/0.1` is frozen. Interoperating implementations can rely
|
|
28
|
+
on it not changing. A new wire version designation (e.g. `aip/0.2`) would be
|
|
29
|
+
introduced in a new package major version and coexist with `aip/0.1` for a
|
|
30
|
+
migration period.
|
|
31
|
+
|
|
32
|
+
The TypeScript API is pre-1.0. Minor version bumps may include breaking API
|
|
33
|
+
changes. Breaking changes will be documented in the changelog with migration
|
|
34
|
+
notes. The `1.0.0` release will signal API stability.
|
|
35
|
+
|
|
36
|
+
The Python and Rust SDKs track the TypeScript wire behavior. Their own version
|
|
37
|
+
numbers are independent of the npm package version.
|
|
38
|
+
|
|
39
|
+
## Path to Co-Maintainership
|
|
40
|
+
|
|
41
|
+
There is no automatic path to co-maintainership based on contribution count.
|
|
42
|
+
The relevant factors are:
|
|
43
|
+
|
|
44
|
+
- Sustained engagement over multiple months
|
|
45
|
+
- Demonstrated familiarity with the threat model (replay attacks, malleability,
|
|
46
|
+
cross-runtime canonicalization edge cases)
|
|
47
|
+
- Good judgment in the review of other contributors' PRs
|
|
48
|
+
- Willingness to own the security disclosure process
|
|
49
|
+
|
|
50
|
+
If you are interested, open a conversation in Discussions rather than raising
|
|
51
|
+
it in a PR.
|
|
52
|
+
|
|
53
|
+
## Standards Body Adoption
|
|
54
|
+
|
|
55
|
+
If this project is accepted into a standards body or foundation, this governance
|
|
56
|
+
document will be replaced by whatever governance model that body requires.
|
|
57
|
+
Community input will be sought before any such transition.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
Last reviewed: 2026-06-05
|
|
62
|
+
Maintainer: [@IceMasterT](https://github.com/IceMasterT) / tech@mysms.promo
|