@7h3/protocol 0.5.0 → 0.5.2

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 (294) hide show
  1. package/README.md +6 -1317
  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 +3670 -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 -121
  23. package/policyEnforcer.d.ts +50 -0
  24. package/policyTelemetryFeedback.d.ts +11 -0
  25. package/{src/protocol.d.ts → protocol.d.ts} +6 -2
  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 -152
  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 -406
  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-github.png +0 -0
  115. package/docs/assets/banner.png +0 -0
  116. package/docs/assets/banner.svg +0 -123
  117. package/eslint.config.js +0 -15
  118. package/fuzz/ts/harness-decode.ts +0 -136
  119. package/fuzz/ts/harness-verify.ts +0 -121
  120. package/fuzz/ts/run.ts +0 -35
  121. package/mcp-server/README.md +0 -38
  122. package/mcp-server/package-lock.json +0 -1187
  123. package/mcp-server/package.json +0 -35
  124. package/mcp-server/src/index.ts +0 -236
  125. package/mcp-server/tsconfig.json +0 -14
  126. package/scripts/aip-framework-quickstart.ts +0 -110
  127. package/scripts/aip-mcp-gateway.ts +0 -38
  128. package/scripts/aip-mcp-wrap-demo.ts +0 -72
  129. package/scripts/aip-quickstart.ts +0 -60
  130. package/scripts/bench-diff.ts +0 -118
  131. package/scripts/bench-protocol-e2e.ts +0 -937
  132. package/scripts/bench-protocol-openloop.ts +0 -1397
  133. package/scripts/bench-replay-cache.ts +0 -76
  134. package/scripts/bench-signature-profiles.ts +0 -180
  135. package/scripts/bench-wire-codecs.ts +0 -161
  136. package/scripts/build-binary-conformance.ts +0 -36
  137. package/scripts/build-release-dashboard.ts +0 -175
  138. package/scripts/canary-rollout.ts +0 -38
  139. package/scripts/mcpGatewayCli.test.ts +0 -116
  140. package/scripts/prepare-aip-package.ts +0 -88
  141. package/scripts/regen-conformance-sigs.ts +0 -18
  142. package/scripts/release-gate.ts +0 -19
  143. package/scripts/validate-runtime-policy.ts +0 -18
  144. package/sdk/browser/index.test.ts +0 -162
  145. package/sdk/browser/index.ts +0 -257
  146. package/sdk/browser/package.json +0 -13
  147. package/sdk/go/cbor.go +0 -551
  148. package/sdk/go/cbor_test.go +0 -232
  149. package/sdk/go/encryption.go +0 -280
  150. package/sdk/go/encryption_test.go +0 -318
  151. package/sdk/go/go.mod +0 -7
  152. package/sdk/go/go.sum +0 -4
  153. package/sdk/go/http.go +0 -135
  154. package/sdk/go/protocol.go +0 -324
  155. package/sdk/go/protocol_test.go +0 -334
  156. package/sdk/go/replay.go +0 -121
  157. package/sdk/go/replay_test.go +0 -149
  158. package/sdk/go/webhook.go +0 -136
  159. package/sdk/pq/package-lock.json +0 -1358
  160. package/sdk/pq/package.json +0 -42
  161. package/sdk/pq/src/index.test.ts +0 -143
  162. package/sdk/pq/src/index.ts +0 -166
  163. package/sdk/pq/tsconfig.json +0 -14
  164. package/sdk/pq/vitest.config.ts +0 -7
  165. package/sdk/python/README.md +0 -18
  166. package/sdk/python/protocol_7h3/__init__.py +0 -46
  167. package/sdk/python/protocol_7h3/encryption.py +0 -252
  168. package/sdk/python/protocol_7h3/http.py +0 -212
  169. package/sdk/python/protocol_7h3/keys.py +0 -149
  170. package/sdk/python/protocol_7h3/pq.py +0 -244
  171. package/sdk/python/protocol_7h3/protocol.py +0 -525
  172. package/sdk/python/protocol_7h3/queue.py +0 -118
  173. package/sdk/python/protocol_7h3/replay.py +0 -98
  174. package/sdk/python/protocol_7h3/webhook.py +0 -116
  175. package/sdk/python/pyproject.toml +0 -40
  176. package/sdk/python/tests/test_conformance.py +0 -110
  177. package/sdk/python/tests/test_encryption.py +0 -206
  178. package/sdk/python/tests/test_http.py +0 -305
  179. package/sdk/python/tests/test_keys.py +0 -417
  180. package/sdk/python/tests/test_queue.py +0 -120
  181. package/sdk/python/tests/test_webhook.py +0 -345
  182. package/sdk/rust/Cargo.lock +0 -371
  183. package/sdk/rust/Cargo.toml +0 -25
  184. package/sdk/rust/README.md +0 -31
  185. package/sdk/rust/fuzz/Cargo.toml +0 -29
  186. package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +0 -46
  187. package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +0 -11
  188. package/sdk/rust/src/bin/aip_mcp_gateway.rs +0 -59
  189. package/sdk/rust/src/http.rs +0 -145
  190. package/sdk/rust/src/keys.rs +0 -161
  191. package/sdk/rust/src/lib.rs +0 -688
  192. package/sdk/rust/src/queue.rs +0 -79
  193. package/sdk/rust/src/webhook.rs +0 -86
  194. package/sdk/rust/tests/conformance.rs +0 -148
  195. package/sdk/rust/tests/gateway.rs +0 -130
  196. package/sdk/rust/tests/http_webhook_queue.rs +0 -201
  197. package/sdk/rust/tests/keys.rs +0 -189
  198. package/sdk/threshold/index.d.ts +0 -68
  199. package/sdk/threshold/index.d.ts.map +0 -1
  200. package/sdk/threshold/index.js +0 -254
  201. package/sdk/threshold/package-lock.json +0 -1361
  202. package/sdk/threshold/package.json +0 -39
  203. package/sdk/threshold/src/index.d.ts +0 -68
  204. package/sdk/threshold/src/index.d.ts.map +0 -1
  205. package/sdk/threshold/src/index.js +0 -254
  206. package/sdk/threshold/src/index.test.ts +0 -238
  207. package/sdk/threshold/src/index.ts +0 -355
  208. package/sdk/threshold/tsconfig.json +0 -19
  209. package/sdk/threshold/vitest.config.ts +0 -12
  210. package/src/agentAdapter.test.ts +0 -48
  211. package/src/agentAdapter.ts +0 -56
  212. package/src/auditLog.test.ts +0 -145
  213. package/src/auditLog.ts +0 -147
  214. package/src/capability.test.ts +0 -504
  215. package/src/capability.ts +0 -380
  216. package/src/cborCodec.test.ts +0 -263
  217. package/src/cborCodec.ts +0 -339
  218. package/src/conformance.test.ts +0 -136
  219. package/src/conformanceVectors.ts +0 -99
  220. package/src/encryption.test.ts +0 -206
  221. package/src/encryption.ts +0 -245
  222. package/src/envelopeCbor.ts +0 -140
  223. package/src/frameworkAdapters.test.ts +0 -290
  224. package/src/frameworkAdapters.ts +0 -261
  225. package/src/gateway.test.ts +0 -343
  226. package/src/gateway.ts +0 -246
  227. package/src/grpcBinding.test.ts +0 -211
  228. package/src/grpcBinding.ts +0 -103
  229. package/src/httpBinding.test.ts +0 -376
  230. package/src/httpBinding.ts +0 -189
  231. package/src/index.ts +0 -39
  232. package/src/keyInfra.test.ts +0 -278
  233. package/src/keyInfra.ts +0 -228
  234. package/src/keyRegistry.ts +0 -59
  235. package/src/keyRotation.test.ts +0 -78
  236. package/src/keyRotation.ts +0 -72
  237. package/src/mcpGateway.test.ts +0 -129
  238. package/src/mcpGateway.ts +0 -250
  239. package/src/mcpTransports.test.ts +0 -92
  240. package/src/mcpTransports.ts +0 -169
  241. package/src/mcpWrapper.test.ts +0 -179
  242. package/src/mcpWrapper.ts +0 -206
  243. package/src/otel.ts +0 -136
  244. package/src/policyEnforcer.test.ts +0 -99
  245. package/src/policyEnforcer.ts +0 -169
  246. package/src/policyTelemetryFeedback.test.ts +0 -25
  247. package/src/policyTelemetryFeedback.ts +0 -38
  248. package/src/protocol.bench.ts +0 -37
  249. package/src/protocol.d.ts.map +0 -1
  250. package/src/protocol.js +0 -294
  251. package/src/protocol.test.ts +0 -155
  252. package/src/protocol.ts +0 -414
  253. package/src/protocolAgent.test.ts +0 -105
  254. package/src/protocolAgent.ts +0 -169
  255. package/src/protocolBinary.test.ts +0 -165
  256. package/src/protocolBinary.ts +0 -312
  257. package/src/protocolCapabilities.ts +0 -70
  258. package/src/protocolFuzz.advanced.test.ts +0 -235
  259. package/src/protocolFuzz.test.ts +0 -111
  260. package/src/protocolNegative.test.ts +0 -97
  261. package/src/protocolReplay.test.ts +0 -71
  262. package/src/protocolReplay.ts +0 -194
  263. package/src/protocolTransport.test.ts +0 -556
  264. package/src/protocolTransport.ts +0 -483
  265. package/src/queueBinding.test.ts +0 -130
  266. package/src/queueBinding.ts +0 -102
  267. package/src/rateLimiter.test.ts +0 -96
  268. package/src/rateLimiter.ts +0 -46
  269. package/src/redisIntegration.test.ts +0 -134
  270. package/src/replayStores.test.ts +0 -273
  271. package/src/replayStores.ts +0 -215
  272. package/src/revocation.test.ts +0 -98
  273. package/src/revocation.ts +0 -0
  274. package/src/routePolicy.test.ts +0 -87
  275. package/src/routePolicy.ts +0 -72
  276. package/src/runtimePolicy.test.ts +0 -49
  277. package/src/runtimePolicy.ts +0 -81
  278. package/src/runtimePolicyManager.test.ts +0 -29
  279. package/src/runtimePolicyManager.ts +0 -50
  280. package/src/runtimePolicyPresets.ts +0 -43
  281. package/src/signedResponse.test.ts +0 -111
  282. package/src/signedResponse.ts +0 -83
  283. package/src/stream.test.ts +0 -254
  284. package/src/stream.ts +0 -417
  285. package/src/telemetry.test.ts +0 -251
  286. package/src/telemetry.ts +0 -299
  287. package/src/webhookBinding.test.ts +0 -144
  288. package/src/webhookBinding.ts +0 -115
  289. package/src/wsBinding.test.ts +0 -221
  290. package/src/wsBinding.ts +0 -200
  291. package/tsconfig.json +0 -15
  292. package/tsconfig.lib.json +0 -23
  293. package/vite.lib.config.ts +0 -16
  294. package/vitest.config.ts +0 -11
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,152 +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
- ## v0.5.0
10
-
11
- ### New features
12
-
13
- **Feature 1 — Distributed Redis replay cache**
14
- - RedisReplayStore: atomic SET NX PX prevents cross-instance replay attacks
15
- - ClusterRedisReplayStore: queries all Redis Cluster nodes
16
- - InMemoryReplayStore improvements
17
- - Go SDK: InMemoryReplayStore + RedisReplayStore (inject-your-client)
18
- - Python SDK: RedisReplayStore using redis-py
19
-
20
- **Feature 2 — End-to-end encryption (X25519 + ChaCha20-Poly1305)**
21
- - sealEnvelope / openEnvelope: encrypt body before signing, verify before decrypting
22
- - generateX25519KeyPair: ephemeral key pairs for forward secrecy
23
- - Zero new dependencies: Node.js built-in crypto.ecdh + crypto.createCipheriv('chacha20-poly1305')
24
- - Python SDK: X25519 + ChaCha20-Poly1305 via cryptography package
25
- - Go SDK: crypto/ecdh + golang.org/x/crypto/chacha20poly1305
26
-
27
- **Feature 3 — Capability tokens and delegation chains**
28
- - issueCapabilityToken: scoped, time-bounded, cryptographically signed credentials
29
- - delegateCapabilityToken: sub-delegate with equal or narrower scope
30
- - verifyCapabilityChain: verify full A→B→C delegation chain
31
- - Gateway integration: x-7h3-capability header accepted alongside signatures
32
- - tokenMatchesScope: glob path matching
33
-
34
- **Feature 4 — Streaming message signing**
35
- - SignedStreamWriter / SignedStreamReader: per-chunk HMAC + final Ed25519
36
- - signStream / verifyStream: convenience wrappers for arrays
37
- - WebSocket integration: createSignedWebSocketStream / receiveSignedWebSocketStream
38
- - Tampering detected mid-stream on the failing chunk
39
-
40
- **Feature 5 — Prometheus metrics + OpenTelemetry**
41
- - Protocol7h3Metrics: counters and histograms for all verification events
42
- - renderPrometheusText: zero-dep Prometheus exposition format
43
- - createMetricsMiddleware: serve /metrics endpoint
44
- - CLI: 7h3 gateway --metrics-port N
45
- - setOtelProvider / withVerificationSpan: optional OTel tracing
46
-
47
- **Feature 6 — Post-quantum signatures (ML-DSA) — @7h3/protocol-pq**
48
- - generatePqKeyPair: ML-DSA-65 and ML-DSA-87 keypairs
49
- - signEnvelopePq / verifyEnvelopePq: same envelope format, alg: 'ML-DSA-65'
50
- - Python SDK: Dilithium2/3/5 via dilithium-py
51
- - Separate package to keep @7h3/protocol at zero runtime deps
52
-
53
- **Feature 7 — CBOR binary wire format**
54
- - encodeCbor / decodeCbor: zero-dep deterministic CBOR (RFC 8949)
55
- - encodeEnvelopeCbor / decodeEnvelopeCbor: compact numeric-key encoding (~40% smaller)
56
- - HTTP binding: Content-Type: application/7h3-cbor support
57
- - Go SDK: EncodeEnvelopeCBOR / DecodeEnvelopeCBOR
58
-
59
- **Feature 8 — M-of-N threshold signatures (BLS12-381) — @7h3/protocol-threshold**
60
- - generateBlsKeyPair: BLS12-381 keypairs
61
- - signEnvelopeBls: partial signature from one participant
62
- - aggregateSignatures: combine M-of-N partial sigs into one
63
- - verifyThresholdEnvelope: single verify call on aggregated sig
64
- - splitPrivateKey / reconstructPrivateKey: Shamir Secret Sharing over BLS scalar field
65
- - Separate package (@7h3/protocol-threshold) using @noble/curves
66
-
67
- ---
68
-
69
- ## [0.1.2] — 2026-06-05
70
-
71
- ### Added
72
- - `SECURITY.md` — coordinated vulnerability disclosure process, 48h acknowledgement / 14-day critical patch SLA, Hall of Thanks
73
- - `CONTRIBUTING.md` — test commands, wire-freeze policy, conformance fixture update requirement, PR workflow
74
- - `GOVERNANCE.md` — LF Minimum Viable Governance style: single-maintainer stage, decision process, co-maintainership path
75
- - `.github/dependabot.yml` — weekly npm and GitHub Actions dependency updates; non-security updates grouped to reduce noise
76
- - `.github/workflows/scorecard.yml` — OpenSSF Scorecard workflow (activates when Actions billing is restored)
77
- - `.github/workflows/publish.yml` — provenance-enabled npm publish workflow for both `@7h3/protocol` and `@7h3/protocol-mcp` (activates when Actions billing is restored)
78
- - `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
79
-
80
- ### Changed
81
- - README: added Ed25519 production recommendation with code snippet; added Security section linking to SECURITY.md
82
- - `docs/MCP_WRAPPER.md`: added HMAC vs Ed25519 comparison table and Ed25519 `wrapMcpServer` example
83
- - `mcp-server`: updated `aip_wrap_mcp_server` tool description to guide toward Ed25519 for production; HMAC boilerplate now includes a production upgrade comment
84
-
85
- ### Fixed
86
- - README: corrected overstated fuzz status (now accurately notes property-based tests exist; formal fuzzing campaign still not done)
87
-
88
- ---
89
-
90
- ## [0.1.1] — 2026-06-05
91
-
92
- ### Fixed
93
- - 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.
94
- - `scripts/prepare-aip-package.ts`: copy all `.d.ts` files from `dist/aip/` instead of only `index.d.ts`
95
-
96
- ### Added
97
- - `@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`
98
-
99
- ---
100
-
101
- ## [0.1.0] — 2026-06-01
102
-
103
- ### Added
104
-
105
- **Core protocol (`aip/0.1`)**
106
- - `createEnvelope` / `signEnvelopeHmac` / `signEnvelopeEd25519` — envelope construction and signing over a deterministic canonical form (fixed key order).
107
- - `verifyEnvelopeHmac` / `verifyEnvelopeEd25519` — tamper-evident verification via real WebCrypto (no hand-rolled crypto).
108
- - `validateEnvelope` — structural + TTL + clock-skew validation with typed diagnostics.
109
- - `receiveEnvelope` — full receive pipeline: validate → verify → replay-check, composable via `ReceiveEnvelopeOptions`.
110
- - Wire formats: `json`, `compact` (minified), `binary` (MessagePack); encode/decode via `encodeEnvelope` / `decodeEnvelope`.
111
- - Polyglot parity: shared conformance fixture set (`conformance/aip_v0_1.json`) proves byte-identical signatures across TypeScript, Python (`aip7h3`), and Rust (`aip7h3`).
112
-
113
- **Replay protection**
114
- - `InMemoryReplayCache` — single-process `(sender, messageId, nonce)` uniqueness window with TTL.
115
- - `DistributedReplayCache` — wraps any `DistributedReplayStore`; routes batch ops through `reserveMany` when available.
116
- - `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.
117
- - `InMemoryRedisLikeClient` — reference implementation for tests (no Redis dep required).
118
-
119
- **Fleet-wide key revocation**
120
- - `InMemoryRevocationStore` — single-process; supports time-bounded `untilMs`.
121
- - `createRedisRevocationStore` — cached reads (`cacheTtlMs` default 5 s), **fail-closed default** (`errorBehavior: 'reject'`), serves stale cache during Redis outage.
122
- - `withRevocationCheck` — wraps any `SignatureResolver`; revoked key returns `undefined` → verification fails.
123
-
124
- **MCP hardening wrapper**
125
- - `wrapMcpServer` — sign + replay-protect an existing MCP handler with zero handler changes; enforces recipient binding (cross-server relay defense).
126
- - `wrapMcpClient` / `createMcpClientCodec` — sign outbound requests; enforce sender binding (response-spoof defense) and correlation binding (response-substitution defense); replay protection on by default.
127
- - Demo: `npm run aip:mcp:wrap` — proves tampered and replayed requests rejected.
128
-
129
- **Transport adapters**
130
- - `serveMcpOverStdio` / `createStdioMcpClient` — newline-delimited; in-order sequential chain prevents response interleaving.
131
- - `createHttpMcpHandler` / `createHttpMcpClient` — `node:http` handler + `fetch` client; supports `binary` wire format.
132
- - No new runtime dependencies (uses `node:readline`, `node:http`, `node:stream`, global `fetch`).
133
-
134
- **Key management & policy**
135
- - Key rotation support (`keyRotation`), runtime policy (`runtimePolicy`, `policyEnforcer`), telemetry feedback hooks.
136
- - Framework adapters (`frameworkAdapters`), agent adapter (`agentAdapter`), MCP gateway (`mcpGateway`).
137
-
138
- ### Documentation
139
- - `docs/THREAT_MODEL.md` — full threat coverage matrix.
140
- - `docs/DISTRIBUTED_REPLAY.md` — Redis store setup, `errorBehavior` table, operational guidance.
141
- - `docs/KEY_REVOCATION.md` — revocation store setup, cache TTL tuning.
142
- - `docs/MCP_WRAPPER.md` — threat coverage table, server + client usage, transport examples.
143
-
144
- ### Test coverage
145
- - 123 tests / 22 test files — all green.
146
- - Live-Redis integration test (`redisIntegration.test.ts`) — auto-skips if no server present.
147
- - Python conformance: `conformance:python`.
148
- - Rust: `conformance:rust` (7 tests).
149
-
150
- ---
151
-
152
- [0.1.0]: https://github.com/IceMasterT/7h3-protocol-aip/releases/tag/v0.1.0