@clowder-ai/plugin-contract 0.1.0-beta.1 → 0.1.0-beta.11

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 (173) hide show
  1. package/dist/codegen/generate-contract.d.ts +5 -0
  2. package/dist/codegen/generate-contract.d.ts.map +1 -1
  3. package/dist/codegen/generate-contract.js +45 -4
  4. package/dist/codegen/generate-contract.js.map +1 -1
  5. package/dist/conformance/behavior-executor.d.ts +18 -0
  6. package/dist/conformance/behavior-executor.d.ts.map +1 -0
  7. package/dist/conformance/behavior-executor.js +52 -0
  8. package/dist/conformance/behavior-executor.js.map +1 -0
  9. package/dist/conformance/fixtures.d.ts +11 -0
  10. package/dist/conformance/fixtures.d.ts.map +1 -0
  11. package/dist/conformance/fixtures.js +9 -0
  12. package/dist/conformance/fixtures.js.map +1 -0
  13. package/dist/conformance/index.d.ts +6 -0
  14. package/dist/conformance/index.d.ts.map +1 -1
  15. package/dist/conformance/index.js +5 -0
  16. package/dist/conformance/index.js.map +1 -1
  17. package/dist/conformance/messaging-behavior-fixture.d.ts +12 -0
  18. package/dist/conformance/messaging-behavior-fixture.d.ts.map +1 -0
  19. package/dist/conformance/messaging-behavior-fixture.js +30 -0
  20. package/dist/conformance/messaging-behavior-fixture.js.map +1 -0
  21. package/dist/conformance/messaging-loopback-adapter.d.ts +23 -0
  22. package/dist/conformance/messaging-loopback-adapter.d.ts.map +1 -0
  23. package/dist/conformance/messaging-loopback-adapter.js +389 -0
  24. package/dist/conformance/messaging-loopback-adapter.js.map +1 -0
  25. package/dist/conformance/messaging-loopback-state.d.ts +22 -0
  26. package/dist/conformance/messaging-loopback-state.d.ts.map +1 -0
  27. package/dist/conformance/messaging-loopback-state.js +101 -0
  28. package/dist/conformance/messaging-loopback-state.js.map +1 -0
  29. package/dist/conformance/runner.d.ts +18 -1
  30. package/dist/conformance/runner.d.ts.map +1 -1
  31. package/dist/conformance/runner.js +153 -66
  32. package/dist/conformance/runner.js.map +1 -1
  33. package/dist/conformance/stdio-harness/child-process-harness.d.ts +65 -0
  34. package/dist/conformance/stdio-harness/child-process-harness.d.ts.map +1 -0
  35. package/dist/conformance/stdio-harness/child-process-harness.js +296 -0
  36. package/dist/conformance/stdio-harness/child-process-harness.js.map +1 -0
  37. package/dist/conformance/stdio-harness/dual-transport-oracle.d.ts +26 -0
  38. package/dist/conformance/stdio-harness/dual-transport-oracle.d.ts.map +1 -0
  39. package/dist/conformance/stdio-harness/dual-transport-oracle.js +32 -0
  40. package/dist/conformance/stdio-harness/dual-transport-oracle.js.map +1 -0
  41. package/dist/conformance/stdio-harness/harness-process-spawn.d.ts +27 -0
  42. package/dist/conformance/stdio-harness/harness-process-spawn.d.ts.map +1 -0
  43. package/dist/conformance/stdio-harness/harness-process-spawn.js +43 -0
  44. package/dist/conformance/stdio-harness/harness-process-spawn.js.map +1 -0
  45. package/dist/conformance/stdio-harness/index.d.ts +5 -0
  46. package/dist/conformance/stdio-harness/index.d.ts.map +1 -0
  47. package/dist/conformance/stdio-harness/index.js +4 -0
  48. package/dist/conformance/stdio-harness/index.js.map +1 -0
  49. package/dist/conformance/stdio-harness/ndjson-frame.d.ts +31 -0
  50. package/dist/conformance/stdio-harness/ndjson-frame.d.ts.map +1 -0
  51. package/dist/conformance/stdio-harness/ndjson-frame.js +125 -0
  52. package/dist/conformance/stdio-harness/ndjson-frame.js.map +1 -0
  53. package/dist/conformance/stdio-harness/node-process-tree-runtime.d.ts +15 -0
  54. package/dist/conformance/stdio-harness/node-process-tree-runtime.d.ts.map +1 -0
  55. package/dist/conformance/stdio-harness/node-process-tree-runtime.js +78 -0
  56. package/dist/conformance/stdio-harness/node-process-tree-runtime.js.map +1 -0
  57. package/dist/conformance/stdio-harness/process-tree-controller.d.ts +51 -0
  58. package/dist/conformance/stdio-harness/process-tree-controller.d.ts.map +1 -0
  59. package/dist/conformance/stdio-harness/process-tree-controller.js +162 -0
  60. package/dist/conformance/stdio-harness/process-tree-controller.js.map +1 -0
  61. package/dist/conformance/stdio-harness/windows-sentinel.d.ts +15 -0
  62. package/dist/conformance/stdio-harness/windows-sentinel.d.ts.map +1 -0
  63. package/dist/conformance/stdio-harness/windows-sentinel.js +160 -0
  64. package/dist/conformance/stdio-harness/windows-sentinel.js.map +1 -0
  65. package/dist/conformance/stdio-harness/wire-shape.d.ts +18 -0
  66. package/dist/conformance/stdio-harness/wire-shape.d.ts.map +1 -0
  67. package/dist/conformance/stdio-harness/wire-shape.js +2 -0
  68. package/dist/conformance/stdio-harness/wire-shape.js.map +1 -0
  69. package/dist/generated/contract.generated.d.ts +370 -4
  70. package/dist/generated/contract.generated.d.ts.map +1 -1
  71. package/dist/generated/contract.generated.js +7 -1
  72. package/dist/generated/contract.generated.js.map +1 -1
  73. package/dist/index.d.ts +3 -1
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +5 -1
  76. package/dist/index.js.map +1 -1
  77. package/dist/validation/index.d.ts +3 -0
  78. package/dist/validation/index.d.ts.map +1 -1
  79. package/dist/validation/index.js +3 -0
  80. package/dist/validation/index.js.map +1 -1
  81. package/dist/validation/manifest.d.ts +23 -0
  82. package/dist/validation/manifest.d.ts.map +1 -0
  83. package/dist/validation/manifest.js +53 -0
  84. package/dist/validation/manifest.js.map +1 -0
  85. package/dist/validation/messaging-semantic.d.ts.map +1 -1
  86. package/dist/validation/messaging-semantic.js +49 -0
  87. package/dist/validation/messaging-semantic.js.map +1 -1
  88. package/dist/validation/messaging-wire.d.ts +38 -0
  89. package/dist/validation/messaging-wire.d.ts.map +1 -0
  90. package/dist/validation/messaging-wire.js +164 -0
  91. package/dist/validation/messaging-wire.js.map +1 -0
  92. package/dist/validation/signals.d.ts +26 -0
  93. package/dist/validation/signals.d.ts.map +1 -0
  94. package/dist/validation/signals.js +206 -0
  95. package/dist/validation/signals.js.map +1 -0
  96. package/dist/wire/constants.d.ts +36 -0
  97. package/dist/wire/constants.d.ts.map +1 -0
  98. package/dist/wire/constants.js +36 -0
  99. package/dist/wire/constants.js.map +1 -0
  100. package/dist/wire/disposition-fixtures.d.ts +118 -0
  101. package/dist/wire/disposition-fixtures.d.ts.map +1 -0
  102. package/dist/wire/disposition-fixtures.js +1881 -0
  103. package/dist/wire/disposition-fixtures.js.map +1 -0
  104. package/dist/wire/disposition.d.ts +102 -0
  105. package/dist/wire/disposition.d.ts.map +1 -0
  106. package/dist/wire/disposition.js +217 -0
  107. package/dist/wire/disposition.js.map +1 -0
  108. package/dist/wire/envelope.d.ts +253 -0
  109. package/dist/wire/envelope.d.ts.map +1 -0
  110. package/dist/wire/envelope.js +19 -0
  111. package/dist/wire/envelope.js.map +1 -0
  112. package/dist/wire/errors.d.ts +222 -0
  113. package/dist/wire/errors.d.ts.map +1 -0
  114. package/dist/wire/errors.js +153 -0
  115. package/dist/wire/errors.js.map +1 -0
  116. package/dist/wire/grants.d.ts +57 -0
  117. package/dist/wire/grants.d.ts.map +1 -0
  118. package/dist/wire/grants.js +59 -0
  119. package/dist/wire/grants.js.map +1 -0
  120. package/dist/wire/handshake-byte-bounds.d.ts +69 -0
  121. package/dist/wire/handshake-byte-bounds.d.ts.map +1 -0
  122. package/dist/wire/handshake-byte-bounds.js +173 -0
  123. package/dist/wire/handshake-byte-bounds.js.map +1 -0
  124. package/dist/wire/handshake.d.ts +146 -0
  125. package/dist/wire/handshake.d.ts.map +1 -0
  126. package/dist/wire/handshake.js +189 -0
  127. package/dist/wire/handshake.js.map +1 -0
  128. package/dist/wire/index.d.ts +37 -0
  129. package/dist/wire/index.d.ts.map +1 -0
  130. package/dist/wire/index.js +61 -0
  131. package/dist/wire/index.js.map +1 -0
  132. package/dist/wire/lifecycle-byte-bounds.d.ts +55 -0
  133. package/dist/wire/lifecycle-byte-bounds.d.ts.map +1 -0
  134. package/dist/wire/lifecycle-byte-bounds.js +209 -0
  135. package/dist/wire/lifecycle-byte-bounds.js.map +1 -0
  136. package/dist/wire/messaging-byte-bounds.d.ts +61 -0
  137. package/dist/wire/messaging-byte-bounds.d.ts.map +1 -0
  138. package/dist/wire/messaging-byte-bounds.js +459 -0
  139. package/dist/wire/messaging-byte-bounds.js.map +1 -0
  140. package/dist/wire/registry.d.ts +294 -0
  141. package/dist/wire/registry.d.ts.map +1 -0
  142. package/dist/wire/registry.js +256 -0
  143. package/dist/wire/registry.js.map +1 -0
  144. package/dist/wire/request-id.d.ts +34 -0
  145. package/dist/wire/request-id.d.ts.map +1 -0
  146. package/dist/wire/request-id.js +40 -0
  147. package/dist/wire/request-id.js.map +1 -0
  148. package/dist/wire/row-shapes.d.ts +217 -0
  149. package/dist/wire/row-shapes.d.ts.map +1 -0
  150. package/dist/wire/row-shapes.js +75 -0
  151. package/dist/wire/row-shapes.js.map +1 -0
  152. package/dist/wire/signal-byte-bounds.d.ts +97 -0
  153. package/dist/wire/signal-byte-bounds.d.ts.map +1 -0
  154. package/dist/wire/signal-byte-bounds.js +229 -0
  155. package/dist/wire/signal-byte-bounds.js.map +1 -0
  156. package/dist/wire/wire-uint53.d.ts +26 -0
  157. package/dist/wire/wire-uint53.d.ts.map +1 -0
  158. package/dist/wire/wire-uint53.js +32 -0
  159. package/dist/wire/wire-uint53.js.map +1 -0
  160. package/fixtures/behavior/messaging/adversarial-invariants.json +56 -5
  161. package/fixtures/manifest/invalid/duplicate-signal-type.json +33 -0
  162. package/fixtures/messaging/valid/subscription-delivery.json +1 -1
  163. package/fixtures/signals/invalid/destination-injection.json +15 -0
  164. package/fixtures/signals/invalid/dynamic-schema-url.json +10 -0
  165. package/fixtures/signals/invalid/forbidden-raw-privacy.json +10 -0
  166. package/fixtures/signals/invalid/non-utc-occurred-at.json +12 -0
  167. package/fixtures/signals/valid/feishu-meeting-artifact.json +18 -0
  168. package/fixtures/signals/valid/remote-service-declaration.json +10 -0
  169. package/package.json +15 -6
  170. package/src/schemas/manifest.schema.json +5 -2
  171. package/src/schemas/messaging.schema.json +209 -32
  172. package/src/schemas/physical-limb.schema.json +319 -0
  173. package/src/schemas/signal.schema.json +129 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Grant snapshot types — GrantSnapshot for SessionBinding and host.grants.changed.
3
+ * Mechanized verbatim from #1165 frozen shape.
4
+ *
5
+ * GrantSnapshot represents the effective capability set at a point in time.
6
+ * It appears in two locations:
7
+ * - SessionBinding (initial grant state at handshake)
8
+ * - host.grants.changed notification (runtime grant mutations)
9
+ *
10
+ * grantRevision is strictly monotonic per plugin instance — the Host
11
+ * increments it on every grant mutation. A plugin that observes
12
+ * revision N may discard any notification with revision < N.
13
+ */
14
+ import type { Capability } from '../generated/contract.generated.js';
15
+ /**
16
+ * Maximum number of items in effectiveGrants.
17
+ * Derived from the 17-value Capability enum — a plugin cannot hold
18
+ * more capabilities than exist.
19
+ */
20
+ export declare const MAX_GRANT_ITEMS: 17;
21
+ /**
22
+ * GrantSnapshot captures a versioned capability set.
23
+ *
24
+ * Used in SessionBinding (handshake) and host.grants.changed (notification).
25
+ * The two fields are always paired and always travel together.
26
+ */
27
+ export interface GrantSnapshot {
28
+ /**
29
+ * WireUInt53(0, 9_007_199_254_740_991).
30
+ * Monotonically increasing per plugin instance.
31
+ * The Host is the sole writer; plugins observe only.
32
+ */
33
+ readonly grantRevision: number;
34
+ /**
35
+ * Unique Capability[], 0..17 items.
36
+ * Duplicates are a protocol violation (Host guarantees uniqueness).
37
+ * Empty array is valid (plugin has no capabilities).
38
+ */
39
+ readonly effectiveGrants: readonly Capability[];
40
+ }
41
+ /**
42
+ * Frozen set of all valid Capability values, derived from the generated
43
+ * L0/L1/L2 capability arrays. Used for closed-enum membership checks.
44
+ */
45
+ export declare const VALID_CAPABILITIES: ReadonlySet<string>;
46
+ /**
47
+ * Validate that effectiveGrants:
48
+ * 1. Does not exceed MAX_GRANT_ITEMS (17).
49
+ * 2. Contains no duplicates.
50
+ * 3. Contains only valid Capability enum members (closed-enum check).
51
+ *
52
+ * Fail-closed: any unrecognized capability value returns false.
53
+ * This is an authorization boundary — fail-open would allow
54
+ * uncontrolled privilege escalation.
55
+ */
56
+ export declare function validateEffectiveGrants(grants: readonly string[]): boolean;
57
+ //# sourceMappingURL=grants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/wire/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAWrE;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAG,EAAW,CAAC;AAM3C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,UAAU,EAAE,CAAC;CACjD;AAMD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAIjD,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAS1E"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Grant snapshot types — GrantSnapshot for SessionBinding and host.grants.changed.
3
+ * Mechanized verbatim from #1165 frozen shape.
4
+ *
5
+ * GrantSnapshot represents the effective capability set at a point in time.
6
+ * It appears in two locations:
7
+ * - SessionBinding (initial grant state at handshake)
8
+ * - host.grants.changed notification (runtime grant mutations)
9
+ *
10
+ * grantRevision is strictly monotonic per plugin instance — the Host
11
+ * increments it on every grant mutation. A plugin that observes
12
+ * revision N may discard any notification with revision < N.
13
+ */
14
+ import { L0_CAPABILITIES, L1_CAPABILITIES, L2_CAPABILITIES, } from '../generated/contract.generated.js';
15
+ // ---------------------------------------------------------------------------
16
+ // Constants
17
+ // ---------------------------------------------------------------------------
18
+ /**
19
+ * Maximum number of items in effectiveGrants.
20
+ * Derived from the 17-value Capability enum — a plugin cannot hold
21
+ * more capabilities than exist.
22
+ */
23
+ export const MAX_GRANT_ITEMS = 17;
24
+ // ---------------------------------------------------------------------------
25
+ // Validators
26
+ // ---------------------------------------------------------------------------
27
+ /**
28
+ * Frozen set of all valid Capability values, derived from the generated
29
+ * L0/L1/L2 capability arrays. Used for closed-enum membership checks.
30
+ */
31
+ export const VALID_CAPABILITIES = new Set([
32
+ ...L0_CAPABILITIES,
33
+ ...L1_CAPABILITIES,
34
+ ...L2_CAPABILITIES,
35
+ ]);
36
+ /**
37
+ * Validate that effectiveGrants:
38
+ * 1. Does not exceed MAX_GRANT_ITEMS (17).
39
+ * 2. Contains no duplicates.
40
+ * 3. Contains only valid Capability enum members (closed-enum check).
41
+ *
42
+ * Fail-closed: any unrecognized capability value returns false.
43
+ * This is an authorization boundary — fail-open would allow
44
+ * uncontrolled privilege escalation.
45
+ */
46
+ export function validateEffectiveGrants(grants) {
47
+ if (grants.length > MAX_GRANT_ITEMS)
48
+ return false;
49
+ const seen = new Set();
50
+ for (const g of grants) {
51
+ if (!VALID_CAPABILITIES.has(g))
52
+ return false; // unknown capability
53
+ if (seen.has(g))
54
+ return false; // duplicate
55
+ seen.add(g);
56
+ }
57
+ return true;
58
+ }
59
+ //# sourceMappingURL=grants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grants.js","sourceRoot":"","sources":["../../src/wire/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,oCAAoC,CAAC;AAE5C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAW,CAAC;AA2B3C,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAS;IACrE,GAAG,eAAe;IAClB,GAAG,eAAe;IAClB,GAAG,eAAe;CACnB,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAyB;IAC/D,IAAI,MAAM,CAAC,MAAM,GAAG,eAAe;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,qBAAqB;QACnE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC,CAAgB,YAAY;QAC1D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Derived compact-JSON byte bounds for the beta.8 handshake rows.
3
+ *
4
+ * This production module owns only the published summary metadata. The
5
+ * generic byte-proof kernel remains test-only; keeping it out of the packed
6
+ * artifact prevents consumers from accidentally treating a proof generator
7
+ * as a runtime protocol dependency. The test-only templates independently
8
+ * recompute these values from the same closed grammar.
9
+ */
10
+ /** Encoding families used for raw UTF-8 boundary evidence. */
11
+ export declare const HANDSHAKE_BYTE_PROOF_ENCODING_FAMILIES: readonly ["ascii", "multibyte", "escaping"];
12
+ export type HandshakeByteProofEncodingFamily = (typeof HANDSHAKE_BYTE_PROOF_ENCODING_FAMILIES)[number];
13
+ /** One rejected N+1 candidate measured alongside a maximum frame. */
14
+ export interface HandshakeNPlusOneByteProof {
15
+ readonly leaf: string;
16
+ readonly encodedBytes: number;
17
+ readonly fitsFrame: boolean;
18
+ }
19
+ /** Raw UTF-8 measurement for one encoding family. */
20
+ export interface HandshakeEncodedByteProofCase {
21
+ readonly family: HandshakeByteProofEncodingFamily;
22
+ readonly encodedBytes: number;
23
+ readonly fitsFrame: boolean;
24
+ readonly nPlusOne: readonly HandshakeNPlusOneByteProof[];
25
+ }
26
+ /** Published max plus the raw-family proof cases from which it is derived. */
27
+ export interface HandshakeEncodedByteProof {
28
+ readonly maxEncodedBytes: number;
29
+ readonly cases: readonly HandshakeEncodedByteProofCase[];
30
+ }
31
+ /** Per-row frame maxima consumed by the public method registry. */
32
+ export interface HandshakeRowEncodedByteBounds {
33
+ readonly maxEncodedRequestBytes: number;
34
+ readonly maxEncodedResultBytes: number;
35
+ readonly maxEncodedErrorBytes: number;
36
+ }
37
+ /** Raw proof of the largest legal broker.hello request. */
38
+ export declare const BROKER_HELLO_REQUEST_BYTE_PROOF: HandshakeEncodedByteProof;
39
+ /** Raw proof of the largest legal broker.hello success result. */
40
+ export declare const BROKER_HELLO_RESULT_BYTE_PROOF: HandshakeEncodedByteProof;
41
+ /** Raw proof of the largest legal broker.ready request. */
42
+ export declare const BROKER_READY_REQUEST_BYTE_PROOF: HandshakeEncodedByteProof;
43
+ /** Raw proof of the largest handshake rejection envelope. */
44
+ export declare const HANDSHAKE_REJECTED_ERROR_BYTE_PROOF: HandshakeEncodedByteProof;
45
+ /** broker.ready succeeds with the exact JSON-RPC result `null`. */
46
+ export declare const BROKER_READY_MAX_ENCODED_RESULT_BYTES: number;
47
+ export declare const BROKER_HELLO_MAX_ENCODED_REQUEST_BYTES: number;
48
+ export declare const BROKER_HELLO_MAX_ENCODED_RESULT_BYTES: number;
49
+ export declare const BROKER_HELLO_MAX_ENCODED_ERROR_BYTES: number;
50
+ export declare const BROKER_READY_MAX_ENCODED_REQUEST_BYTES: number;
51
+ export declare const BROKER_READY_MAX_ENCODED_ERROR_BYTES: number;
52
+ /**
53
+ * The exact per-row summary consumed by the registry. No byte value is
54
+ * hand-entered in the registry; all maxima are derived above from the closed
55
+ * grammar and raw UTF-8 serialization.
56
+ */
57
+ export declare const HANDSHAKE_ROW_ENCODED_BYTE_BOUNDS: {
58
+ readonly 'broker.hello': {
59
+ readonly maxEncodedRequestBytes: number;
60
+ readonly maxEncodedResultBytes: number;
61
+ readonly maxEncodedErrorBytes: number;
62
+ };
63
+ readonly 'broker.ready': {
64
+ readonly maxEncodedRequestBytes: number;
65
+ readonly maxEncodedResultBytes: number;
66
+ readonly maxEncodedErrorBytes: number;
67
+ };
68
+ };
69
+ //# sourceMappingURL=handshake-byte-bounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake-byte-bounds.d.ts","sourceRoot":"","sources":["../../src/wire/handshake-byte-bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,8DAA8D;AAC9D,eAAO,MAAM,sCAAsC,6CAIzC,CAAC;AAEX,MAAM,MAAM,gCAAgC,GAC1C,CAAC,OAAO,sCAAsC,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,qDAAqD;AACrD,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAClD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,0BAA0B,EAAE,CAAC;CAC1D;AAED,8EAA8E;AAC9E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,SAAS,6BAA6B,EAAE,CAAC;CAC1D;AAED,mEAAmE;AACnE,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC;AA6KD,2DAA2D;AAC3D,eAAO,MAAM,+BAA+B,2BAG3C,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,8BAA8B,2BAG1C,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,+BAA+B,2BAG3C,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,mCAAmC,2BAG/C,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,qCAAqC,QAGjD,CAAC;AAEF,eAAO,MAAM,sCAAsC,QACF,CAAC;AAClD,eAAO,MAAM,qCAAqC,QACF,CAAC;AACjD,eAAO,MAAM,oCAAoC,QACI,CAAC;AACtD,eAAO,MAAM,sCAAsC,QACF,CAAC;AAClD,eAAO,MAAM,oCAAoC,QACI,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;CAW6C,CAAC"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Derived compact-JSON byte bounds for the beta.8 handshake rows.
3
+ *
4
+ * This production module owns only the published summary metadata. The
5
+ * generic byte-proof kernel remains test-only; keeping it out of the packed
6
+ * artifact prevents consumers from accidentally treating a proof generator
7
+ * as a runtime protocol dependency. The test-only templates independently
8
+ * recompute these values from the same closed grammar.
9
+ */
10
+ import { MAX_FRAME_BYTES } from './constants.js';
11
+ import { HANDSHAKE_REJECTED_CODE, HANDSHAKE_REJECTED_MESSAGE, HANDSHAKE_REJECT_REASONS, } from './errors.js';
12
+ import { BINDING_NONCE_MAX_LENGTH, HANDSHAKE_VERSION_MAX_LENGTH, HOST_IDENTIFIER_MAX_LENGTH, PACKAGE_DIGEST_LENGTH, PLUGIN_ID_MAX_LENGTH, } from './handshake.js';
13
+ import { VALID_CAPABILITIES } from './grants.js';
14
+ import { REQUEST_ID_MAX_LENGTH } from './request-id.js';
15
+ import { WIRE_UINT53_MAX } from './wire-uint53.js';
16
+ /** Encoding families used for raw UTF-8 boundary evidence. */
17
+ export const HANDSHAKE_BYTE_PROOF_ENCODING_FAMILIES = [
18
+ 'ascii',
19
+ 'multibyte',
20
+ 'escaping',
21
+ ];
22
+ const FAMILY_CODE_POINT = {
23
+ ascii: 'a',
24
+ multibyte: '😀',
25
+ escaping: '\u0000',
26
+ };
27
+ const MAX_REQUEST_ID = 'a'.repeat(REQUEST_ID_MAX_LENGTH);
28
+ const MAX_PACKAGE_DIGEST = `sha512-${'A'.repeat(PACKAGE_DIGEST_LENGTH - 9)}==`;
29
+ const MAX_EFFECTIVE_GRANTS = [...VALID_CAPABILITIES];
30
+ const MAX_HANDSHAKE_REJECT_REASON = HANDSHAKE_REJECT_REASONS.reduce((longest, value) => (value.length > longest.length ? value : longest));
31
+ function valueFor(family, leaf, nPlusOneLeaf) {
32
+ const codePoint = leaf.asciiOnly ? FAMILY_CODE_POINT.ascii : FAMILY_CODE_POINT[family];
33
+ return codePoint.repeat(leaf.maxCodePoints + Number(leaf.id === nPlusOneLeaf));
34
+ }
35
+ function semverFor(nPlusOneLeaf, leaf) {
36
+ return `0.0.0-${'a'.repeat(HANDSHAKE_VERSION_MAX_LENGTH - 6 + Number(nPlusOneLeaf === leaf))}`;
37
+ }
38
+ function measureProof(leaves, frameFor) {
39
+ const cases = HANDSHAKE_BYTE_PROOF_ENCODING_FAMILIES.map((family) => {
40
+ const encodedBytes = Buffer.byteLength(JSON.stringify(frameFor(family)), 'utf8');
41
+ return {
42
+ family,
43
+ encodedBytes,
44
+ fitsFrame: encodedBytes <= MAX_FRAME_BYTES,
45
+ nPlusOne: leaves.map((leaf) => {
46
+ const nPlusOneBytes = Buffer.byteLength(JSON.stringify(frameFor(family, leaf.id)), 'utf8');
47
+ return {
48
+ leaf: leaf.id,
49
+ encodedBytes: nPlusOneBytes,
50
+ fitsFrame: nPlusOneBytes <= MAX_FRAME_BYTES,
51
+ };
52
+ }),
53
+ };
54
+ });
55
+ return {
56
+ maxEncodedBytes: Math.max(...cases.map(({ encodedBytes }) => encodedBytes)),
57
+ cases,
58
+ };
59
+ }
60
+ const HELLO_REQUEST_LEAVES = [
61
+ { id: 'requestId', maxCodePoints: REQUEST_ID_MAX_LENGTH, asciiOnly: true },
62
+ { id: 'pluginId', maxCodePoints: PLUGIN_ID_MAX_LENGTH },
63
+ { id: 'contractVersion', maxCodePoints: HANDSHAKE_VERSION_MAX_LENGTH, asciiOnly: true },
64
+ { id: 'wireVersion', maxCodePoints: HANDSHAKE_VERSION_MAX_LENGTH, asciiOnly: true },
65
+ ];
66
+ const HELLO_RESULT_LEAVES = [
67
+ { id: 'requestId', maxCodePoints: REQUEST_ID_MAX_LENGTH, asciiOnly: true },
68
+ { id: 'pluginId', maxCodePoints: PLUGIN_ID_MAX_LENGTH },
69
+ { id: 'contractVersion', maxCodePoints: HANDSHAKE_VERSION_MAX_LENGTH, asciiOnly: true },
70
+ { id: 'wireVersion', maxCodePoints: HANDSHAKE_VERSION_MAX_LENGTH, asciiOnly: true },
71
+ { id: 'pluginInstanceId', maxCodePoints: HOST_IDENTIFIER_MAX_LENGTH },
72
+ { id: 'brokerSessionId', maxCodePoints: HOST_IDENTIFIER_MAX_LENGTH },
73
+ { id: 'bindingNonce', maxCodePoints: BINDING_NONCE_MAX_LENGTH },
74
+ ];
75
+ const READY_REQUEST_LEAVES = [
76
+ { id: 'requestId', maxCodePoints: REQUEST_ID_MAX_LENGTH, asciiOnly: true },
77
+ { id: 'bindingNonce', maxCodePoints: BINDING_NONCE_MAX_LENGTH },
78
+ ];
79
+ const HANDSHAKE_ERROR_LEAVES = [
80
+ { id: 'requestId', maxCodePoints: REQUEST_ID_MAX_LENGTH, asciiOnly: true },
81
+ ];
82
+ function helloRequestFrame(family, nPlusOneLeaf) {
83
+ const leaf = (entry) => valueFor(family, entry, nPlusOneLeaf);
84
+ return {
85
+ jsonrpc: '2.0',
86
+ id: leaf(HELLO_REQUEST_LEAVES[0]),
87
+ method: 'broker.hello',
88
+ params: {
89
+ meta: { deadlineUnixMs: WIRE_UINT53_MAX },
90
+ input: {
91
+ pluginId: leaf(HELLO_REQUEST_LEAVES[1]),
92
+ packageDigest: MAX_PACKAGE_DIGEST,
93
+ contractVersion: semverFor(nPlusOneLeaf, 'contractVersion'),
94
+ wireVersion: semverFor(nPlusOneLeaf, 'wireVersion'),
95
+ },
96
+ },
97
+ };
98
+ }
99
+ function helloResultFrame(family, nPlusOneLeaf) {
100
+ const leaf = (entry) => valueFor(family, entry, nPlusOneLeaf);
101
+ return {
102
+ jsonrpc: '2.0',
103
+ id: leaf(HELLO_RESULT_LEAVES[0]),
104
+ result: {
105
+ pluginId: leaf(HELLO_RESULT_LEAVES[1]),
106
+ packageDigest: MAX_PACKAGE_DIGEST,
107
+ contractVersion: semverFor(nPlusOneLeaf, 'contractVersion'),
108
+ wireVersion: semverFor(nPlusOneLeaf, 'wireVersion'),
109
+ pluginInstanceId: leaf(HELLO_RESULT_LEAVES[4]),
110
+ brokerSessionId: leaf(HELLO_RESULT_LEAVES[5]),
111
+ grantRevision: WIRE_UINT53_MAX,
112
+ effectiveGrants: MAX_EFFECTIVE_GRANTS,
113
+ bindingNonce: leaf(HELLO_RESULT_LEAVES[6]),
114
+ },
115
+ };
116
+ }
117
+ function readyRequestFrame(family, nPlusOneLeaf) {
118
+ const leaf = (entry) => valueFor(family, entry, nPlusOneLeaf);
119
+ return {
120
+ jsonrpc: '2.0',
121
+ id: leaf(READY_REQUEST_LEAVES[0]),
122
+ method: 'broker.ready',
123
+ params: {
124
+ meta: { deadlineUnixMs: WIRE_UINT53_MAX },
125
+ input: { bindingNonce: leaf(READY_REQUEST_LEAVES[1]) },
126
+ },
127
+ };
128
+ }
129
+ function handshakeRejectedFrame(family, nPlusOneLeaf) {
130
+ const requestId = valueFor(family, HANDSHAKE_ERROR_LEAVES[0], nPlusOneLeaf);
131
+ return {
132
+ jsonrpc: '2.0',
133
+ id: requestId,
134
+ error: {
135
+ code: HANDSHAKE_REJECTED_CODE,
136
+ message: HANDSHAKE_REJECTED_MESSAGE,
137
+ data: { reason: MAX_HANDSHAKE_REJECT_REASON },
138
+ },
139
+ };
140
+ }
141
+ /** Raw proof of the largest legal broker.hello request. */
142
+ export const BROKER_HELLO_REQUEST_BYTE_PROOF = measureProof(HELLO_REQUEST_LEAVES, helloRequestFrame);
143
+ /** Raw proof of the largest legal broker.hello success result. */
144
+ export const BROKER_HELLO_RESULT_BYTE_PROOF = measureProof(HELLO_RESULT_LEAVES, helloResultFrame);
145
+ /** Raw proof of the largest legal broker.ready request. */
146
+ export const BROKER_READY_REQUEST_BYTE_PROOF = measureProof(READY_REQUEST_LEAVES, readyRequestFrame);
147
+ /** Raw proof of the largest handshake rejection envelope. */
148
+ export const HANDSHAKE_REJECTED_ERROR_BYTE_PROOF = measureProof(HANDSHAKE_ERROR_LEAVES, handshakeRejectedFrame);
149
+ /** broker.ready succeeds with the exact JSON-RPC result `null`. */
150
+ export const BROKER_READY_MAX_ENCODED_RESULT_BYTES = Buffer.byteLength(JSON.stringify({ jsonrpc: '2.0', id: MAX_REQUEST_ID, result: null }), 'utf8');
151
+ export const BROKER_HELLO_MAX_ENCODED_REQUEST_BYTES = BROKER_HELLO_REQUEST_BYTE_PROOF.maxEncodedBytes;
152
+ export const BROKER_HELLO_MAX_ENCODED_RESULT_BYTES = BROKER_HELLO_RESULT_BYTE_PROOF.maxEncodedBytes;
153
+ export const BROKER_HELLO_MAX_ENCODED_ERROR_BYTES = HANDSHAKE_REJECTED_ERROR_BYTE_PROOF.maxEncodedBytes;
154
+ export const BROKER_READY_MAX_ENCODED_REQUEST_BYTES = BROKER_READY_REQUEST_BYTE_PROOF.maxEncodedBytes;
155
+ export const BROKER_READY_MAX_ENCODED_ERROR_BYTES = HANDSHAKE_REJECTED_ERROR_BYTE_PROOF.maxEncodedBytes;
156
+ /**
157
+ * The exact per-row summary consumed by the registry. No byte value is
158
+ * hand-entered in the registry; all maxima are derived above from the closed
159
+ * grammar and raw UTF-8 serialization.
160
+ */
161
+ export const HANDSHAKE_ROW_ENCODED_BYTE_BOUNDS = {
162
+ 'broker.hello': {
163
+ maxEncodedRequestBytes: BROKER_HELLO_MAX_ENCODED_REQUEST_BYTES,
164
+ maxEncodedResultBytes: BROKER_HELLO_MAX_ENCODED_RESULT_BYTES,
165
+ maxEncodedErrorBytes: BROKER_HELLO_MAX_ENCODED_ERROR_BYTES,
166
+ },
167
+ 'broker.ready': {
168
+ maxEncodedRequestBytes: BROKER_READY_MAX_ENCODED_REQUEST_BYTES,
169
+ maxEncodedResultBytes: BROKER_READY_MAX_ENCODED_RESULT_BYTES,
170
+ maxEncodedErrorBytes: BROKER_READY_MAX_ENCODED_ERROR_BYTES,
171
+ },
172
+ };
173
+ //# sourceMappingURL=handshake-byte-bounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake-byte-bounds.js","sourceRoot":"","sources":["../../src/wire/handshake-byte-bounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,sCAAsC,GAAG;IACpD,OAAO;IACP,WAAW;IACX,UAAU;CACF,CAAC;AAuCX,MAAM,iBAAiB,GAAqD;IAC1E,KAAK,EAAE,GAAG;IACV,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACzD,MAAM,kBAAkB,GAAG,UAAU,GAAG,CAAC,MAAM,CAAC,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC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AAoC;KAC3D;IACD,cAAc,EAAE;QACd,sBAAsB,EAAE,sCAAsC;QAC9D,qBAAqB,EAAE,qCAAqC;QAC5D,oBAAoB,EAAE,oCAAoC;KAC3D;CACwF,CAAC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Handshake types — CandidateHello, SessionBinding, BrokerReadyParams.
3
+ * Mechanized verbatim from #1165 frozen shape.
4
+ *
5
+ * Handshake flow:
6
+ * 1. Plugin sends CandidateHello (candidate claims only, no grants/session).
7
+ * 2. Host validates, mints instance/session ids, replies with SessionBinding.
8
+ * 3. Plugin sends broker.ready with the bindingNonce to activate.
9
+ *
10
+ * CandidateHello and BrokerReadyParams REJECT any additional
11
+ * identity/instance/grant/session fields (closed surface).
12
+ */
13
+ import type { Capability } from '../generated/contract.generated.js';
14
+ /** Exact character length of a sha512 SRI digest. */
15
+ export declare const PACKAGE_DIGEST_LENGTH: 95;
16
+ /**
17
+ * Pattern for a valid sha512 SRI package digest.
18
+ * 85 base64 chars + one of [AQgw] + '==' suffix.
19
+ */
20
+ export declare const PACKAGE_DIGEST_PATTERN: RegExp;
21
+ /**
22
+ * Compact-JSON encoded byte count for the digest string.
23
+ * 95 chars (all ASCII) + 2 surrounding quotes = 97 bytes.
24
+ */
25
+ export declare const PACKAGE_DIGEST_ENCODED_BYTES: 97;
26
+ /** H1 wire pluginId minimum length in Unicode code points. */
27
+ export declare const PLUGIN_ID_MIN_LENGTH: 1;
28
+ /** H1 wire pluginId maximum length in Unicode code points. */
29
+ export declare const PLUGIN_ID_MAX_LENGTH: 256;
30
+ /** Worst compact-JSON encoded bytes for H1 pluginId. */
31
+ export declare const PLUGIN_ID_MAX_ENCODED_BYTES: 1538;
32
+ /** Shared H3/H4 SemVer maximum length (the grammar is ASCII-only). */
33
+ export declare const HANDSHAKE_VERSION_MAX_LENGTH: 256;
34
+ /** Worst compact-JSON encoded bytes for H3/H4 version strings. */
35
+ export declare const HANDSHAKE_VERSION_MAX_ENCODED_BYTES: 258;
36
+ /** Exact SemVer 2.0.0 grammar copied from manifest.schema.json $defs.SemVer. */
37
+ export declare const HANDSHAKE_SEMVER_PATTERN: RegExp;
38
+ /** H5/H6 opaque Host-minted identifier minimum length in code points. */
39
+ export declare const HOST_IDENTIFIER_MIN_LENGTH: 1;
40
+ /** H5/H6 opaque Host-minted identifier maximum length in code points. */
41
+ export declare const HOST_IDENTIFIER_MAX_LENGTH: 512;
42
+ /** Worst compact-JSON encoded bytes for either opaque Host identifier. */
43
+ export declare const HOST_IDENTIFIER_MAX_ENCODED_BYTES: 3074;
44
+ /** Minimum code-point length for bindingNonce. */
45
+ export declare const BINDING_NONCE_MIN_LENGTH: 1;
46
+ /** Maximum code-point length for bindingNonce. */
47
+ export declare const BINDING_NONCE_MAX_LENGTH: 512;
48
+ /**
49
+ * Maximum compact-JSON encoded bytes for bindingNonce.
50
+ * Worst case: every code point is a 6-byte escape (\uXXXX) → 6 * 512 + 2 quotes.
51
+ */
52
+ export declare const BINDING_NONCE_MAX_ENCODED_BYTES: 3074;
53
+ /**
54
+ * CandidateHello is sent by the plugin at connection open.
55
+ * It carries only the plugin's candidate claims; no instance ids,
56
+ * grant state, or session identifiers may appear.
57
+ *
58
+ * Additional identity/instance/grant/session fields are REJECTED.
59
+ */
60
+ export interface CandidateHello {
61
+ /** CLOSED (H1) — manifest pluginId, 1..256 Unicode code points. */
62
+ readonly pluginId: string;
63
+ /** CLOSED (H2) — exactly 95 chars, sha512 SRI digest. */
64
+ readonly packageDigest: string;
65
+ /** CLOSED (H3) — SemVer contract version, at most 256 ASCII characters. */
66
+ readonly contractVersion: string;
67
+ /** CLOSED (H4) — SemVer wire protocol version, at most 256 ASCII characters. */
68
+ readonly wireVersion: string;
69
+ }
70
+ /**
71
+ * SessionBinding is the Host's authoritative response to CandidateHello.
72
+ * It echoes the four hello fields, then adds Host-minted identifiers
73
+ * and the effective grant snapshot.
74
+ */
75
+ export interface SessionBinding {
76
+ /** Echoed from CandidateHello. */
77
+ readonly pluginId: string;
78
+ /** Echoed from CandidateHello. */
79
+ readonly packageDigest: string;
80
+ /** Echoed from CandidateHello. */
81
+ readonly contractVersion: string;
82
+ /** Echoed from CandidateHello. */
83
+ readonly wireVersion: string;
84
+ /** CLOSED (H5) — Host-minted instance id, 1..512 Unicode code points. */
85
+ readonly pluginInstanceId: string;
86
+ /** CLOSED (H6) — Host-minted session id, 1..512 Unicode code points. */
87
+ readonly brokerSessionId: string;
88
+ /** CLOSED (H7) — WireUInt53(0, 9_007_199_254_740_991), monotonically increasing. */
89
+ readonly grantRevision: number;
90
+ /** CLOSED (H8) — unique Capability[], 0..17 items. */
91
+ readonly effectiveGrants: readonly Capability[];
92
+ /** CLOSED (H9) — opaque nonce, 1..512 code points. */
93
+ readonly bindingNonce: string;
94
+ }
95
+ /**
96
+ * BrokerReadyParams is the params object for the broker.ready request.
97
+ * It carries only bindingNonce for activation; it is NOT a resume carrier.
98
+ *
99
+ * Additional identity/instance/grant/session fields are REJECTED.
100
+ */
101
+ export interface BrokerReadyParams {
102
+ /** CLOSED (H9) — activation-only; echoes the nonce from SessionBinding. */
103
+ readonly bindingNonce: string;
104
+ }
105
+ /**
106
+ * Validate a string as a conformant sha512 SRI package digest.
107
+ * Checks exact length (95) and pattern match.
108
+ */
109
+ export declare function validatePackageDigest(value: unknown): value is string;
110
+ /** Validate H1's bounded wire representation without narrowing manifest syntax. */
111
+ export declare function validatePluginId(value: unknown): value is string;
112
+ /** Validate H3 contractVersion. Ranges and non-SemVer values are rejected. */
113
+ export declare function validateContractVersion(value: unknown): value is string;
114
+ /** Validate H4 wireVersion. Compatibility negotiation is Host policy, not syntax. */
115
+ export declare function validateWireVersion(value: unknown): value is string;
116
+ /** Validate H5 pluginInstanceId as an opaque Host-minted bounded value. */
117
+ export declare function validatePluginInstanceId(value: unknown): value is string;
118
+ /** Validate H6 brokerSessionId as an opaque Host-minted bounded value. */
119
+ export declare function validateBrokerSessionId(value: unknown): value is string;
120
+ /**
121
+ * Validate a string as a conformant binding nonce.
122
+ * Checks code-point count is within [1, 512].
123
+ *
124
+ * Note: uses spread to count code points (not .length, which counts
125
+ * UTF-16 code units and misreports surrogate pairs).
126
+ */
127
+ export declare function validateBindingNonce(value: unknown): value is string;
128
+ /**
129
+ * Detect caller-supplied fields that belong exclusively to the Host's
130
+ * SessionBinding authority. These are a closed handshake rejection rather
131
+ * than an ordinary grammar error.
132
+ */
133
+ export declare function hasHandshakeAuthorityInjection(value: unknown): boolean;
134
+ /**
135
+ * Validate the closed plugin-to-Host CandidateHello object. It deliberately
136
+ * validates only grammar: the Host decides whether the candidate is allowed.
137
+ */
138
+ export declare function validateCandidateHello(value: unknown): value is CandidateHello;
139
+ /**
140
+ * Validate the closed Host-to-plugin SessionBinding object. Candidate echo
141
+ * equality and nonce-use state are peer protocol checks, not schema grammar.
142
+ */
143
+ export declare function validateSessionBinding(value: unknown): value is SessionBinding;
144
+ /** Validate the closed activation-only broker.ready input object. */
145
+ export declare function validateBrokerReadyParams(value: unknown): value is BrokerReadyParams;
146
+ //# sourceMappingURL=handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/wire/handshake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAQrE,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,EAAG,EAAW,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAuC,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAG,EAAW,CAAC;AAMxD,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,EAAG,CAAU,CAAC;AAE/C,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,EAAG,GAAY,CAAC;AAEjD,wDAAwD;AACxD,eAAO,MAAM,2BAA2B,EAAG,IAAa,CAAC;AAEzD,sEAAsE;AACtE,eAAO,MAAM,4BAA4B,EAAG,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