@7h3/protocol 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/README.md +6 -323
  2. package/agentAdapter.d.ts +26 -0
  3. package/auditLog.d.ts +54 -0
  4. package/capability.d.ts +67 -0
  5. package/cborCodec.d.ts +34 -0
  6. package/conformanceVectors.d.ts +20 -0
  7. package/encryption.d.ts +85 -0
  8. package/envelopeCbor.d.ts +33 -0
  9. package/frameworkAdapters.d.ts +72 -0
  10. package/gateway.d.ts +53 -0
  11. package/grpcBinding.d.ts +29 -0
  12. package/httpBinding.d.ts +50 -0
  13. package/index.d.ts +39 -0
  14. package/index.js +3662 -0
  15. package/keyInfra.d.ts +64 -0
  16. package/keyRegistry.d.ts +9 -0
  17. package/keyRotation.d.ts +20 -0
  18. package/mcpGateway.d.ts +37 -0
  19. package/mcpTransports.d.ts +62 -0
  20. package/mcpWrapper.d.ts +83 -0
  21. package/otel.d.ts +65 -0
  22. package/package.json +13 -79
  23. package/policyEnforcer.d.ts +50 -0
  24. package/policyTelemetryFeedback.d.ts +11 -0
  25. package/protocol.d.ts +66 -0
  26. package/protocolAgent.d.ts +58 -0
  27. package/protocolBinary.d.ts +8 -0
  28. package/protocolCapabilities.d.ts +24 -0
  29. package/protocolReplay.d.ts +35 -0
  30. package/protocolTransport.d.ts +73 -0
  31. package/queueBinding.d.ts +43 -0
  32. package/rateLimiter.d.ts +18 -0
  33. package/{src/redisClient.ts → redisClient.d.ts} +25 -75
  34. package/replayStores.d.ts +98 -0
  35. package/revocation.d.ts +71 -0
  36. package/routePolicy.d.ts +30 -0
  37. package/runtimePolicy.d.ts +24 -0
  38. package/runtimePolicyManager.d.ts +15 -0
  39. package/runtimePolicyPresets.d.ts +11 -0
  40. package/signedResponse.d.ts +21 -0
  41. package/stream.d.ts +59 -0
  42. package/telemetry.d.ts +79 -0
  43. package/webhookBinding.d.ts +30 -0
  44. package/wsBinding.d.ts +52 -0
  45. package/.dockerignore +0 -19
  46. package/.github/dependabot.yml +0 -32
  47. package/.github/workflows/ci.yml +0 -31
  48. package/.github/workflows/publish.yml +0 -59
  49. package/.github/workflows/scorecard.yml +0 -37
  50. package/7h3.example.yaml +0 -125
  51. package/CHANGELOG.md +0 -92
  52. package/CONTRIBUTING.md +0 -82
  53. package/Dockerfile +0 -73
  54. package/GOVERNANCE.md +0 -62
  55. package/SECURITY.md +0 -70
  56. package/bench-results/replay-cache-full-1777891033256.json +0 -10
  57. package/bench-results/replay-cache-full-1777896317488.json +0 -10
  58. package/bench-results/replay-cache-full-1777900993184.json +0 -10
  59. package/bench-results/replay-cache-full-1777901019285.json +0 -10
  60. package/bench-results/replay-cache-quick-1777870170126.json +0 -10
  61. package/bench-results/signature-profiles-quick-1775875160079.json +0 -85
  62. package/bench-results/signature-profiles-quick-1775983539716.json +0 -85
  63. package/bench-results/signature-profiles-quick-1776237913190.json +0 -85
  64. package/bench-results/wire-codecs-full-1777891019803.json +0 -93
  65. package/bench-results/wire-codecs-full-1777896260964.json +0 -93
  66. package/bench-results/wire-codecs-full-1777901004247.json +0 -93
  67. package/bench-results/wire-codecs-quick-1775972879056.json +0 -93
  68. package/bench-results/wire-codecs-quick-1775983541111.json +0 -93
  69. package/bench-results/wire-codecs-quick-1776237914299.json +0 -93
  70. package/bench-results/wire-codecs-quick-1777841285236.json +0 -93
  71. package/bench-results/wire-codecs-quick-1777841321772.json +0 -93
  72. package/bench-results/wire-codecs-quick-1777841330408.json +0 -93
  73. package/bench-results/wire-codecs-quick-1777852886082.json +0 -93
  74. package/bench-results/wire-codecs-quick-1777852988773.json +0 -93
  75. package/bench-results/wire-codecs-quick-1777870188095.json +0 -93
  76. package/bench-results/wire-codecs-quick-1777870263918.json +0 -93
  77. package/bench-results/wire-codecs-quick-1777870455034.json +0 -93
  78. package/bench-results/wire-codecs-quick-1778816163081.json +0 -93
  79. package/bench-results/wire-codecs-quick-1778843936130.json +0 -93
  80. package/bin/7h3.ts +0 -385
  81. package/conformance/7h3_v0_1.json +0 -77
  82. package/conformance/7h3_v0_1_binary.json +0 -20
  83. package/conformance/aip_v0_1_binary.json +0 -20
  84. package/docker-compose.yaml +0 -77
  85. package/docs/ADOPTION_PLAN.md +0 -120
  86. package/docs/AGENTS.md +0 -77
  87. package/docs/AIP_RFC_v0.1.md +0 -97
  88. package/docs/AI_DECISION_CARD.md +0 -122
  89. package/docs/AI_RUNTIME_POLICY.json +0 -126
  90. package/docs/AI_RUNTIME_POLICY.yaml +0 -110
  91. package/docs/BACKPRESSURE_TUNING.md +0 -65
  92. package/docs/BENCHMARK_CLAIM_MATRIX.md +0 -42
  93. package/docs/BENCHMARK_REPORT_TEMPLATE.md +0 -169
  94. package/docs/BINARY_CODEC_BENCH.md +0 -23
  95. package/docs/CLEAN_CLONE_RUNBOOK.md +0 -36
  96. package/docs/CLOCK_SKEW_POLICY.md +0 -30
  97. package/docs/DISTRIBUTED_REPLAY.md +0 -142
  98. package/docs/FUZZ_CAMPAIGN.md +0 -121
  99. package/docs/GATEWAY.md +0 -195
  100. package/docs/KEY_MANAGEMENT_POLICY.md +0 -53
  101. package/docs/KEY_REVOCATION.md +0 -69
  102. package/docs/MCP_WRAPPER.md +0 -159
  103. package/docs/MIGRATION_GUIDE.md +0 -40
  104. package/docs/OPERATORS.md +0 -184
  105. package/docs/PERF_REGRESSION_POLICY.md +0 -34
  106. package/docs/PROJECT_EXAMINATION_2026-05-31.md +0 -219
  107. package/docs/RELEASE_BENCHMARK_REPORT_2026-05-15.md +0 -135
  108. package/docs/RELEASE_GATE.md +0 -25
  109. package/docs/RELEASE_NOTES_v0.1.0.md +0 -54
  110. package/docs/SECURITY_REVIEW_2026-06-05.md +0 -165
  111. package/docs/TELEMETRY.md +0 -41
  112. package/docs/THREAT_MODEL.md +0 -89
  113. package/docs/VERSIONING_POLICY.md +0 -30
  114. package/docs/assets/banner.png +0 -0
  115. package/eslint.config.js +0 -15
  116. package/fuzz/ts/harness-decode.ts +0 -136
  117. package/fuzz/ts/harness-verify.ts +0 -121
  118. package/fuzz/ts/run.ts +0 -35
  119. package/mcp-server/README.md +0 -38
  120. package/mcp-server/package-lock.json +0 -1187
  121. package/mcp-server/package.json +0 -35
  122. package/mcp-server/src/index.ts +0 -236
  123. package/mcp-server/tsconfig.json +0 -14
  124. package/scripts/aip-framework-quickstart.ts +0 -110
  125. package/scripts/aip-mcp-gateway.ts +0 -38
  126. package/scripts/aip-mcp-wrap-demo.ts +0 -72
  127. package/scripts/aip-quickstart.ts +0 -60
  128. package/scripts/bench-diff.ts +0 -118
  129. package/scripts/bench-protocol-e2e.ts +0 -937
  130. package/scripts/bench-protocol-openloop.ts +0 -1397
  131. package/scripts/bench-replay-cache.ts +0 -76
  132. package/scripts/bench-signature-profiles.ts +0 -180
  133. package/scripts/bench-wire-codecs.ts +0 -161
  134. package/scripts/build-binary-conformance.ts +0 -36
  135. package/scripts/build-release-dashboard.ts +0 -175
  136. package/scripts/canary-rollout.ts +0 -38
  137. package/scripts/mcpGatewayCli.test.ts +0 -116
  138. package/scripts/prepare-aip-package.ts +0 -88
  139. package/scripts/regen-conformance-sigs.ts +0 -18
  140. package/scripts/release-gate.ts +0 -19
  141. package/scripts/validate-runtime-policy.ts +0 -18
  142. package/sdk/browser/index.test.ts +0 -162
  143. package/sdk/browser/index.ts +0 -257
  144. package/sdk/browser/package.json +0 -13
  145. package/sdk/go/go.mod +0 -3
  146. package/sdk/go/http.go +0 -135
  147. package/sdk/go/protocol.go +0 -324
  148. package/sdk/go/protocol_test.go +0 -334
  149. package/sdk/go/webhook.go +0 -136
  150. package/sdk/python/README.md +0 -18
  151. package/sdk/python/protocol_7h3/__init__.py +0 -46
  152. package/sdk/python/protocol_7h3/http.py +0 -212
  153. package/sdk/python/protocol_7h3/keys.py +0 -149
  154. package/sdk/python/protocol_7h3/protocol.py +0 -525
  155. package/sdk/python/protocol_7h3/queue.py +0 -118
  156. package/sdk/python/protocol_7h3/webhook.py +0 -116
  157. package/sdk/python/pyproject.toml +0 -40
  158. package/sdk/python/tests/test_conformance.py +0 -110
  159. package/sdk/python/tests/test_http.py +0 -305
  160. package/sdk/python/tests/test_keys.py +0 -417
  161. package/sdk/python/tests/test_queue.py +0 -120
  162. package/sdk/python/tests/test_webhook.py +0 -345
  163. package/sdk/rust/Cargo.lock +0 -371
  164. package/sdk/rust/Cargo.toml +0 -25
  165. package/sdk/rust/README.md +0 -31
  166. package/sdk/rust/fuzz/Cargo.toml +0 -29
  167. package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +0 -46
  168. package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +0 -11
  169. package/sdk/rust/src/bin/aip_mcp_gateway.rs +0 -59
  170. package/sdk/rust/src/http.rs +0 -145
  171. package/sdk/rust/src/keys.rs +0 -161
  172. package/sdk/rust/src/lib.rs +0 -688
  173. package/sdk/rust/src/queue.rs +0 -79
  174. package/sdk/rust/src/webhook.rs +0 -86
  175. package/sdk/rust/tests/conformance.rs +0 -148
  176. package/sdk/rust/tests/gateway.rs +0 -130
  177. package/sdk/rust/tests/http_webhook_queue.rs +0 -201
  178. package/sdk/rust/tests/keys.rs +0 -189
  179. package/src/agentAdapter.test.ts +0 -48
  180. package/src/agentAdapter.ts +0 -56
  181. package/src/auditLog.test.ts +0 -145
  182. package/src/auditLog.ts +0 -147
  183. package/src/conformance.test.ts +0 -136
  184. package/src/conformanceVectors.ts +0 -99
  185. package/src/frameworkAdapters.test.ts +0 -290
  186. package/src/frameworkAdapters.ts +0 -261
  187. package/src/gateway.test.ts +0 -343
  188. package/src/gateway.ts +0 -171
  189. package/src/grpcBinding.test.ts +0 -211
  190. package/src/grpcBinding.ts +0 -103
  191. package/src/httpBinding.test.ts +0 -376
  192. package/src/httpBinding.ts +0 -163
  193. package/src/index.ts +0 -32
  194. package/src/keyInfra.test.ts +0 -278
  195. package/src/keyInfra.ts +0 -228
  196. package/src/keyRegistry.ts +0 -59
  197. package/src/keyRotation.test.ts +0 -78
  198. package/src/keyRotation.ts +0 -72
  199. package/src/mcpGateway.test.ts +0 -129
  200. package/src/mcpGateway.ts +0 -250
  201. package/src/mcpTransports.test.ts +0 -92
  202. package/src/mcpTransports.ts +0 -169
  203. package/src/mcpWrapper.test.ts +0 -179
  204. package/src/mcpWrapper.ts +0 -206
  205. package/src/policyEnforcer.test.ts +0 -99
  206. package/src/policyEnforcer.ts +0 -169
  207. package/src/policyTelemetryFeedback.test.ts +0 -25
  208. package/src/policyTelemetryFeedback.ts +0 -38
  209. package/src/protocol.bench.ts +0 -37
  210. package/src/protocol.test.ts +0 -155
  211. package/src/protocol.ts +0 -413
  212. package/src/protocolAgent.test.ts +0 -105
  213. package/src/protocolAgent.ts +0 -169
  214. package/src/protocolBinary.test.ts +0 -165
  215. package/src/protocolBinary.ts +0 -312
  216. package/src/protocolCapabilities.ts +0 -70
  217. package/src/protocolFuzz.advanced.test.ts +0 -235
  218. package/src/protocolFuzz.test.ts +0 -111
  219. package/src/protocolNegative.test.ts +0 -97
  220. package/src/protocolReplay.test.ts +0 -71
  221. package/src/protocolReplay.ts +0 -194
  222. package/src/protocolTransport.test.ts +0 -556
  223. package/src/protocolTransport.ts +0 -483
  224. package/src/queueBinding.test.ts +0 -130
  225. package/src/queueBinding.ts +0 -102
  226. package/src/rateLimiter.test.ts +0 -96
  227. package/src/rateLimiter.ts +0 -46
  228. package/src/redisIntegration.test.ts +0 -134
  229. package/src/replayStores.test.ts +0 -141
  230. package/src/replayStores.ts +0 -82
  231. package/src/revocation.test.ts +0 -98
  232. package/src/revocation.ts +0 -0
  233. package/src/routePolicy.test.ts +0 -87
  234. package/src/routePolicy.ts +0 -72
  235. package/src/runtimePolicy.test.ts +0 -49
  236. package/src/runtimePolicy.ts +0 -81
  237. package/src/runtimePolicyManager.test.ts +0 -29
  238. package/src/runtimePolicyManager.ts +0 -50
  239. package/src/runtimePolicyPresets.ts +0 -43
  240. package/src/signedResponse.test.ts +0 -111
  241. package/src/signedResponse.ts +0 -83
  242. package/src/webhookBinding.test.ts +0 -144
  243. package/src/webhookBinding.ts +0 -115
  244. package/src/wsBinding.test.ts +0 -221
  245. package/src/wsBinding.ts +0 -100
  246. package/tsconfig.json +0 -15
  247. package/tsconfig.lib.json +0 -23
  248. package/vite.lib.config.ts +0 -16
package/telemetry.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * telemetry.ts — Prometheus metrics for 7h3 Protocol
3
+ *
4
+ * Zero runtime dependencies. Plain in-memory counters and histograms rendered
5
+ * to standard Prometheus text exposition format.
6
+ */
7
+ export interface TelemetryConfig {
8
+ enabled?: boolean;
9
+ prefix?: string;
10
+ }
11
+ export interface Counter {
12
+ increment(labels?: Record<string, string>): void;
13
+ value(labels?: Record<string, string>): number;
14
+ }
15
+ export interface HistogramSnapshot {
16
+ count: number;
17
+ sum: number;
18
+ buckets: Record<string, number>;
19
+ }
20
+ export interface Histogram {
21
+ observe(value: number, labels?: Record<string, string>): void;
22
+ snapshot(labels?: Record<string, string>): HistogramSnapshot;
23
+ }
24
+ export declare class SimpleCounter implements Counter {
25
+ private counts;
26
+ private labelSets;
27
+ increment(labels?: Record<string, string>): void;
28
+ value(labels?: Record<string, string>): number;
29
+ entries(): Array<{
30
+ labels?: Record<string, string>;
31
+ value: number;
32
+ }>;
33
+ }
34
+ export declare class SimpleHistogram implements Histogram {
35
+ private bucketBounds;
36
+ private states;
37
+ private labelSets;
38
+ constructor(buckets?: number[]);
39
+ observe(value: number, labels?: Record<string, string>): void;
40
+ snapshot(labels?: Record<string, string>): HistogramSnapshot;
41
+ entries(): Array<{
42
+ labels?: Record<string, string>;
43
+ snapshot: HistogramSnapshot;
44
+ }>;
45
+ getBounds(): number[];
46
+ }
47
+ export declare class Protocol7h3Metrics {
48
+ /** labels: result (ok|fail), alg (ED25519|HS256|none), transport (http|ws|grpc|queue|webhook) */
49
+ verifications_total: SimpleCounter;
50
+ /** buckets in ms */
51
+ verification_duration_ms: SimpleHistogram;
52
+ /** labels: sender, path */
53
+ rate_limit_hits_total: SimpleCounter;
54
+ /** labels: sender, path */
55
+ sender_denials_total: SimpleCounter;
56
+ /** labels: transport */
57
+ replay_detections_total: SimpleCounter;
58
+ /** labels: type */
59
+ audit_entries_total: SimpleCounter;
60
+ /** labels: transport — use for WS/gRPC connection tracking */
61
+ active_connections: SimpleCounter;
62
+ }
63
+ export declare const metrics: Protocol7h3Metrics;
64
+ export declare function renderPrometheusText(m: Protocol7h3Metrics, prefix?: string): string;
65
+ type NodeReq = {
66
+ url?: string;
67
+ method?: string;
68
+ };
69
+ type NodeRes = {
70
+ writeHead(status: number, headers: Record<string, string>): void;
71
+ end(body: string): void;
72
+ };
73
+ type NextFn = () => void;
74
+ /**
75
+ * Returns a Node.js http-compatible middleware that serves Prometheus metrics
76
+ * at the given path (default: /metrics).
77
+ */
78
+ export declare function createMetricsMiddleware(path?: string, m?: Protocol7h3Metrics, prefix?: string): (req: NodeReq, res: NodeRes, next: NextFn) => void;
79
+ export {};
@@ -0,0 +1,30 @@
1
+ import { generateEd25519KeypairBase64Url } from './protocol';
2
+ export declare const WEBHOOK_SIG_HEADER = "x-7h3-sig";
3
+ export declare const WEBHOOK_TS_HEADER = "x-7h3-ts";
4
+ export declare const WEBHOOK_DEFAULT_TTL_MS = 300000;
5
+ export interface WebhookSignOptions {
6
+ privateKey: string;
7
+ ttlMs?: number;
8
+ }
9
+ export interface WebhookSignHmacOptions {
10
+ secret: string;
11
+ ttlMs?: number;
12
+ }
13
+ export interface WebhookVerifyOptions {
14
+ publicKey: string;
15
+ maxAgeMs?: number;
16
+ }
17
+ export interface WebhookVerifyHmacOptions {
18
+ secret: string;
19
+ maxAgeMs?: number;
20
+ }
21
+ export interface WebhookHeaders {
22
+ [WEBHOOK_SIG_HEADER]: string;
23
+ [WEBHOOK_TS_HEADER]: string;
24
+ }
25
+ export declare function signWebhook(payload: string | Uint8Array, opts: WebhookSignOptions): Promise<WebhookHeaders>;
26
+ export declare function signWebhookHmac(payload: string | Uint8Array, opts: WebhookSignHmacOptions): Promise<WebhookHeaders>;
27
+ export declare function verifyWebhook(payload: string | Uint8Array, headers: WebhookHeaders | Record<string, string>, opts: WebhookVerifyOptions): Promise<boolean>;
28
+ export declare function verifyWebhookHmac(payload: string | Uint8Array, headers: WebhookHeaders | Record<string, string>, opts: WebhookVerifyHmacOptions): Promise<boolean>;
29
+ export declare function consumeWebhook<T = unknown>(payload: string, headers: Record<string, string>, opts: WebhookVerifyOptions): Promise<T>;
30
+ export { generateEd25519KeypairBase64Url };
package/wsBinding.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { generateEd25519KeypairBase64Url, type ProtocolEnvelope } from './protocol';
2
+ import type { KeyRegistry } from './keyRegistry';
3
+ import { SignedStreamWriter, type StreamSignerOpts, type StreamVerifierOpts, type StreamVerifyResult, type StreamChunk } from './stream';
4
+ export { type KeyRegistry, generateEd25519KeypairBase64Url };
5
+ export type { StreamSignerOpts, StreamVerifierOpts, StreamVerifyResult, StreamChunk };
6
+ export interface WebSocketLike {
7
+ send(data: string): void;
8
+ addEventListener(event: 'message', handler: (e: {
9
+ data: string | Buffer;
10
+ }) => void): void;
11
+ addEventListener(event: 'close', handler: () => void): void;
12
+ removeEventListener(event: string, handler: (...args: unknown[]) => void): void;
13
+ readyState?: number;
14
+ }
15
+ export interface WsBindingOptions {
16
+ privateKey: string;
17
+ sender: string;
18
+ recipient?: string;
19
+ keyRegistry: KeyRegistry;
20
+ ttlMs?: number;
21
+ onVerifyFail?: (err: Error, rawData: string) => void;
22
+ }
23
+ export interface ProtectedWebSocket {
24
+ send(payload: unknown): Promise<void>;
25
+ onMessage(handler: (payload: unknown, envelope: ProtocolEnvelope) => void): void;
26
+ onVerifyFail(handler: (err: Error, rawData: string) => void): void;
27
+ readonly seq: number;
28
+ }
29
+ export declare function wrapWebSocket(ws: WebSocketLike, opts: WsBindingOptions): ProtectedWebSocket;
30
+ /**
31
+ * createSignedWebSocketStream
32
+ *
33
+ * Attaches a SignedStreamWriter to a WebSocket:
34
+ * - Each incoming WebSocket message is signed as a stream chunk and sent back.
35
+ * - On connection close, the final signed frame is sent.
36
+ *
37
+ * Returns the underlying SignedStreamWriter so callers can also call writeChunk
38
+ * directly (e.g. when driving the stream from application code rather than
39
+ * forwarding received messages).
40
+ */
41
+ export declare function createSignedWebSocketStream(ws: WebSocketLike, opts: StreamSignerOpts): SignedStreamWriter;
42
+ /**
43
+ * receiveSignedWebSocketStream
44
+ *
45
+ * Listens for StreamChunk JSON frames on a WebSocket, accumulates them, and
46
+ * when the final frame (f=true) arrives calls verifyStream over the complete
47
+ * set of collected chunks.
48
+ *
49
+ * Resolves with StreamVerifyResult when the final frame is received.
50
+ * Rejects if a frame cannot be decoded.
51
+ */
52
+ export declare function receiveSignedWebSocketStream(ws: WebSocketLike, opts: StreamVerifierOpts): Promise<StreamVerifyResult>;
package/.dockerignore DELETED
@@ -1,19 +0,0 @@
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
@@ -1,32 +0,0 @@
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"
@@ -1,31 +0,0 @@
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
@@ -1,59 +0,0 @@
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 }}
@@ -1,37 +0,0 @@
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 DELETED
@@ -1,125 +0,0 @@
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 DELETED
@@ -1,92 +0,0 @@
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 DELETED
@@ -1,82 +0,0 @@
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)