@agentplat/mesh-protocol 0.3.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # `@agentplat/mesh-protocol`
2
+
3
+ Closed, bounded and transport-neutral wire contracts for AgentPlat Mesh peers.
4
+
5
+ The Alpha 1 implementation provides:
6
+
7
+ - strict UTF-8 and JSON parsing that rejects duplicate decoded keys, malformed
8
+ Unicode, ambiguous syntax and documents outside explicit structural limits;
9
+ - deterministic JSON canonicalization for hashing and signing;
10
+ - closed-schema validation for `peer.hello`, `peer.ping` and `peer.ping_ack`;
11
+ - exact representations for message IDs, SHA-256 payload digests and Ed25519
12
+ proofs;
13
+ - receiver-context checks for tenant and Mesh scope, audience, freshness and
14
+ critical-extension support; and
15
+ - public, structurally valid conformance fixtures in `fixtures/v0`.
16
+
17
+ Use `parseSignedMeshEnvelope` with the decompressed `Uint8Array` at a wire
18
+ boundary. Accepting bytes rather than pre-decoded text prevents lossy UTF-8
19
+ replacement from hiding an invalid representation. The parser performs strict
20
+ parsing and static protocol validation and returns a deeply frozen value. Apply
21
+ `validateMeshEnvelopeContext` before accepting that value into a local peer.
22
+
23
+ Use `canonicalizeMeshPayload` to obtain the bytes covered by `payloadHash`.
24
+ Use `createMeshSigningDocument` or `canonicalizeMeshSigningDocument` to obtain
25
+ the document covered by the envelope proof. The signing document deliberately
26
+ excludes the payload and the proof value while retaining the payload digest and
27
+ proof header.
28
+
29
+ This package does not calculate or verify a payload digest, resolve signing
30
+ keys, verify signatures, perform replay admission, or mutate peer state. Those
31
+ are separate stages so callers cannot confuse structural validity with
32
+ cryptographic authenticity or local acceptance.
33
+
34
+ Importing the package performs no parsing, key resolution, network or storage
35
+ operation.
@@ -0,0 +1,12 @@
1
+ import { type StrictJsonLimits } from './strict-json.js';
2
+ export type CanonicalJsonResult = {
3
+ readonly ok: true;
4
+ readonly value: string;
5
+ readonly bytes: Uint8Array;
6
+ } | {
7
+ readonly ok: false;
8
+ readonly code: 'invalid_json_value' | 'structural_limit_exceeded';
9
+ readonly path: string;
10
+ };
11
+ export declare function canonicalizeJsonValue(input: unknown, limits: StrictJsonLimits, maximumOutputBytes: number): CanonicalJsonResult;
12
+ //# sourceMappingURL=canonical-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-json.d.ts","sourceRoot":"","sources":["../src/canonical-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,mBAAmB,GAC3B;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,2BAA2B,CAAC;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAaN,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,gBAAgB,EACxB,kBAAkB,EAAE,MAAM,GACzB,mBAAmB,CA2BrB"}
@@ -0,0 +1,179 @@
1
+ import { formatJsonPath, isWellFormedUnicode, } from './strict-json.js';
2
+ const utf8Encoder = new TextEncoder();
3
+ class CanonicalJsonFailure extends Error {
4
+ code;
5
+ path;
6
+ constructor(code, path) {
7
+ super(code);
8
+ this.code = code;
9
+ this.path = path;
10
+ }
11
+ }
12
+ export function canonicalizeJsonValue(input, limits, maximumOutputBytes) {
13
+ try {
14
+ const serializer = new CanonicalJsonSerializer(limits, maximumOutputBytes);
15
+ const value = serializer.serialize(input);
16
+ const bytes = utf8Encoder.encode(value);
17
+ if (bytes.byteLength > maximumOutputBytes) {
18
+ return {
19
+ ok: false,
20
+ code: 'structural_limit_exceeded',
21
+ path: '$',
22
+ };
23
+ }
24
+ return { ok: true, value, bytes };
25
+ }
26
+ catch (error) {
27
+ if (error instanceof CanonicalJsonFailure) {
28
+ return {
29
+ ok: false,
30
+ code: error.code,
31
+ path: error.path,
32
+ };
33
+ }
34
+ return {
35
+ ok: false,
36
+ code: 'invalid_json_value',
37
+ path: '$',
38
+ };
39
+ }
40
+ }
41
+ class CanonicalJsonSerializer {
42
+ limits;
43
+ maximumOutputBytes;
44
+ totalObjectKeys = 0;
45
+ totalArrayItems = 0;
46
+ ancestors = new Set();
47
+ constructor(limits, maximumOutputBytes) {
48
+ this.limits = limits;
49
+ this.maximumOutputBytes = maximumOutputBytes;
50
+ }
51
+ serialize(input) {
52
+ return this.serializeValue(input, [], 0);
53
+ }
54
+ serializeValue(value, path, depth) {
55
+ if (value === null)
56
+ return this.assertOutputSize('null', path);
57
+ if (typeof value === 'boolean') {
58
+ return this.assertOutputSize(value ? 'true' : 'false', path);
59
+ }
60
+ if (typeof value === 'number') {
61
+ if (!Number.isFinite(value)) {
62
+ return this.fail('invalid_json_value', path);
63
+ }
64
+ return this.assertOutputSize(JSON.stringify(value), path);
65
+ }
66
+ if (typeof value === 'string') {
67
+ if (!isWellFormedUnicode(value)) {
68
+ return this.fail('invalid_json_value', path);
69
+ }
70
+ if (utf8Encoder.encode(value).byteLength > this.limits.maximumStringBytes) {
71
+ return this.fail('structural_limit_exceeded', path);
72
+ }
73
+ return this.assertOutputSize(JSON.stringify(value), path);
74
+ }
75
+ if (typeof value !== 'object') {
76
+ return this.fail('invalid_json_value', path);
77
+ }
78
+ if (this.ancestors.has(value)) {
79
+ return this.fail('invalid_json_value', path);
80
+ }
81
+ const nextDepth = depth + 1;
82
+ if (nextDepth > this.limits.maximumNestingDepth) {
83
+ return this.fail('structural_limit_exceeded', path);
84
+ }
85
+ this.ancestors.add(value);
86
+ try {
87
+ if (Array.isArray(value)) {
88
+ return this.serializeArray(value, path, nextDepth);
89
+ }
90
+ return this.serializeObject(value, path, nextDepth);
91
+ }
92
+ finally {
93
+ this.ancestors.delete(value);
94
+ }
95
+ }
96
+ serializeArray(value, path, depth) {
97
+ if (value.length > this.limits.maximumArrayItems ||
98
+ this.totalArrayItems + value.length > this.limits.maximumTotalArrayItems) {
99
+ return this.fail('structural_limit_exceeded', path);
100
+ }
101
+ if (Object.getOwnPropertySymbols(value).length > 0 ||
102
+ Object.getOwnPropertyNames(value).length !== value.length + 1) {
103
+ return this.fail('invalid_json_value', path);
104
+ }
105
+ this.totalArrayItems += value.length;
106
+ const serialized = [];
107
+ let outputBytes = 2;
108
+ for (let index = 0; index < value.length; index += 1) {
109
+ const descriptor = Object.getOwnPropertyDescriptor(value, index);
110
+ if (!descriptor || !descriptor.enumerable || !('value' in descriptor)) {
111
+ return this.fail('invalid_json_value', [...path, index]);
112
+ }
113
+ const item = this.serializeValue(descriptor.value, [...path, index], depth);
114
+ outputBytes +=
115
+ (index === 0 ? 0 : 1) + utf8Encoder.encode(item).byteLength;
116
+ if (outputBytes > this.maximumOutputBytes) {
117
+ return this.fail('structural_limit_exceeded', path);
118
+ }
119
+ serialized.push(item);
120
+ }
121
+ return `[${serialized.join(',')}]`;
122
+ }
123
+ serializeObject(value, path, depth) {
124
+ const prototype = Object.getPrototypeOf(value);
125
+ if (prototype !== Object.prototype && prototype !== null) {
126
+ return this.fail('invalid_json_value', path);
127
+ }
128
+ if (Object.getOwnPropertySymbols(value).length > 0) {
129
+ return this.fail('invalid_json_value', path);
130
+ }
131
+ const keys = Object.keys(value);
132
+ if (Object.getOwnPropertyNames(value).length !== keys.length) {
133
+ return this.fail('invalid_json_value', path);
134
+ }
135
+ if (keys.length > this.limits.maximumObjectKeys ||
136
+ this.totalObjectKeys + keys.length > this.limits.maximumTotalObjectKeys) {
137
+ return this.fail('structural_limit_exceeded', path);
138
+ }
139
+ this.totalObjectKeys += keys.length;
140
+ keys.sort();
141
+ const serialized = [];
142
+ let outputBytes = 2;
143
+ for (const key of keys) {
144
+ const keyPath = [...path, key];
145
+ if (!isWellFormedUnicode(key) ||
146
+ utf8Encoder.encode(key).byteLength > this.limits.maximumStringBytes) {
147
+ return this.fail(isWellFormedUnicode(key)
148
+ ? 'structural_limit_exceeded'
149
+ : 'invalid_json_value', keyPath);
150
+ }
151
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
152
+ if (!descriptor || !descriptor.enumerable || !('value' in descriptor)) {
153
+ return this.fail('invalid_json_value', keyPath);
154
+ }
155
+ const canonicalKey = JSON.stringify(key);
156
+ const canonicalValue = this.serializeValue(descriptor.value, keyPath, depth);
157
+ outputBytes +=
158
+ (serialized.length === 0 ? 0 : 1) +
159
+ utf8Encoder.encode(canonicalKey).byteLength +
160
+ 1 +
161
+ utf8Encoder.encode(canonicalValue).byteLength;
162
+ if (outputBytes > this.maximumOutputBytes) {
163
+ return this.fail('structural_limit_exceeded', path);
164
+ }
165
+ serialized.push(`${canonicalKey}:${canonicalValue}`);
166
+ }
167
+ return `{${serialized.join(',')}}`;
168
+ }
169
+ assertOutputSize(value, path) {
170
+ if (utf8Encoder.encode(value).byteLength > this.maximumOutputBytes) {
171
+ return this.fail('structural_limit_exceeded', path);
172
+ }
173
+ return value;
174
+ }
175
+ fail(code, path) {
176
+ throw new CanonicalJsonFailure(code, formatJsonPath(path));
177
+ }
178
+ }
179
+ //# sourceMappingURL=canonical-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../src/canonical-json.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,GAEpB,MAAM,kBAAkB,CAAC;AAc1B,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,oBAAqB,SAAQ,KAAK;IAE3B;IACA;IAFX,YACW,IAAwD,EACxD,IAAY;QAErB,KAAK,CAAC,I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c,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACrC,CAAC;IAEO,gBAAgB,CACtB,KAAa,EACb,IAAkC;QAElC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnE,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,IAAI,CACV,IAAwD,EACxD,IAAkC;QAElC,MAAM,IAAI,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -0,0 +1,154 @@
1
+ /** Public protocol contracts shared by parsing and validation. */
2
+ /** Exact protocol identifier signed by every Mesh peer. */
3
+ export declare const MESH_PROTOCOL: "agentplat.mesh";
4
+ /** Alpha releases use wire version zero until beta fixtures are frozen. */
5
+ export declare const MESH_WIRE_VERSION: 0;
6
+ /** Reference signature suite for the initial protocol. */
7
+ export declare const MESH_SIGNATURE_ALGORITHM: "Ed25519";
8
+ /** Closed audience topics recognized by protocol v0. */
9
+ export declare const MESH_AUDIENCE_TOPICS: readonly ["membership", "capability", "objective", "work", "evidence"];
10
+ /** Closed message registry; later alphas implement additional payload families. */
11
+ export declare const MESH_MESSAGE_TYPES: readonly ["peer.hello", "peer.card", "peer.ping", "peer.ping_ack", "peer.digest", "peer.sync_request", "peer.sync_response", "peer.goodbye", "capability.advertise", "capability.withdraw", "objective.announce", "objective.revise", "objective.cancel", "work.offer", "work.bid", "work.award", "work.accept", "work.decline", "work.progress", "work.checkpoint", "work.result", "work.release", "work.cancel", "lease.renew", "lease.takeover_proposal", "lease.vote", "lease.certificate", "evidence.claim", "evidence.attest", "evidence.challenge", "evidence.retract", "trust.observation"];
12
+ export type MeshAudienceTopic = (typeof MESH_AUDIENCE_TOPICS)[number];
13
+ export type MeshMessageType = (typeof MESH_MESSAGE_TYPES)[number];
14
+ export type MeshSignatureAlgorithm = typeof MESH_SIGNATURE_ALGORITHM;
15
+ /** JSON value accepted by protocol extensions and future message payloads. */
16
+ export type MeshJsonValue = null | boolean | number | string | readonly MeshJsonValue[] | {
17
+ readonly [key: string]: MeshJsonValue;
18
+ };
19
+ /** Direct peer audience. Transport addresses never imply this value. */
20
+ export interface MeshPeerAudience {
21
+ readonly kind: 'peer';
22
+ readonly peerId: string;
23
+ }
24
+ /** Bounded sender fanout to one closed Mesh topic. */
25
+ export interface MeshTopicAudience {
26
+ readonly kind: 'mesh';
27
+ readonly topic: MeshAudienceTopic;
28
+ }
29
+ export type MeshAudience = MeshPeerAudience | MeshTopicAudience;
30
+ /** Peer and process instance that signed one envelope. */
31
+ export interface MeshSender {
32
+ readonly peerId: string;
33
+ readonly instanceId: string;
34
+ }
35
+ /** Signed proof header used to construct the canonical signing document. */
36
+ export interface MeshProofHeader {
37
+ readonly algorithm: MeshSignatureAlgorithm;
38
+ readonly keyId: string;
39
+ }
40
+ /** Complete proof representation carried on the wire. */
41
+ export interface MeshProof extends MeshProofHeader {
42
+ readonly value: string;
43
+ }
44
+ /** Announces liveness for an already admitted Peer Card and instance. */
45
+ export interface PeerHelloPayload {
46
+ readonly type: 'peer.hello';
47
+ readonly peerCardId: string;
48
+ readonly cardRevision: number;
49
+ }
50
+ /** Requests a direct liveness response from the audience peer. */
51
+ export interface PeerPingPayload {
52
+ readonly type: 'peer.ping';
53
+ }
54
+ /** Responds to one accepted ping named by the envelope causation ID. */
55
+ export interface PeerPingAckPayload {
56
+ readonly type: 'peer.ping_ack';
57
+ }
58
+ /** Payload subset implemented by the Alpha 1 vertical slice. */
59
+ export type MeshMessagePayload = PeerHelloPayload | PeerPingPayload | PeerPingAckPayload;
60
+ /** Shared fields that participate in envelope identity and signing. */
61
+ export interface MeshEnvelopeHeader<TPayload extends MeshMessagePayload = MeshMessagePayload> {
62
+ readonly protocol: typeof MESH_PROTOCOL;
63
+ readonly wireVersion: typeof MESH_WIRE_VERSION;
64
+ readonly messageId: string;
65
+ readonly tenantId: string;
66
+ readonly meshId: string;
67
+ readonly objectiveId?: string;
68
+ readonly type: TPayload['type'];
69
+ readonly sender: MeshSender;
70
+ readonly audience: MeshAudience;
71
+ readonly sequence: number;
72
+ readonly sentAt: string;
73
+ readonly expiresAt: string;
74
+ readonly correlationId?: string;
75
+ readonly causationId?: string;
76
+ readonly extensions?: Readonly<Record<string, MeshJsonValue>>;
77
+ readonly criticalExtensions?: readonly string[];
78
+ }
79
+ /** Producer input before payload hashing and signature generation. */
80
+ export interface UnsignedMeshEnvelope<TPayload extends MeshMessagePayload = MeshMessagePayload> extends MeshEnvelopeHeader<TPayload> {
81
+ readonly payload: TPayload;
82
+ readonly proof: MeshProofHeader;
83
+ }
84
+ /** Structurally complete signed wire envelope. */
85
+ export interface MeshEnvelope<TPayload extends MeshMessagePayload = MeshMessagePayload> extends MeshEnvelopeHeader<TPayload> {
86
+ readonly payloadHash: string;
87
+ readonly payload: TPayload;
88
+ readonly proof: MeshProof;
89
+ }
90
+ /** Canonical document signed after hashing the payload. */
91
+ export type MeshSigningDocument<TPayload extends MeshMessagePayload = MeshMessagePayload> = Omit<MeshEnvelope<TPayload>, 'payload' | 'proof'> & {
92
+ proof: MeshProofHeader;
93
+ };
94
+ declare const signedMeshEnvelopeBrand: unique symbol;
95
+ declare const verifiedMeshEnvelopeBrand: unique symbol;
96
+ /** Envelope produced by an approved signer or strict wire parser. */
97
+ export type SignedMeshEnvelope<TPayload extends MeshMessagePayload = MeshMessagePayload> = Readonly<MeshEnvelope<TPayload> & {
98
+ [signedMeshEnvelopeBrand]: true;
99
+ }>;
100
+ /** Signed envelope whose digest and proof have been verified locally. */
101
+ export type VerifiedMeshEnvelope<TPayload extends MeshMessagePayload = MeshMessagePayload> = Readonly<SignedMeshEnvelope<TPayload> & {
102
+ [verifiedMeshEnvelopeBrand]: true;
103
+ }>;
104
+ /** Explicit parser and protocol bounds. */
105
+ export interface MeshProtocolLimits {
106
+ readonly maximumEnvelopeBytes: number;
107
+ readonly maximumPayloadBytes: number;
108
+ readonly maximumNestingDepth: number;
109
+ readonly maximumTotalObjectKeys: number;
110
+ readonly maximumObjectKeys: number;
111
+ readonly maximumTotalArrayItems: number;
112
+ readonly maximumArrayItems: number;
113
+ readonly maximumStringBytes: number;
114
+ readonly maximumExtensions: number;
115
+ readonly maximumCriticalExtensions: number;
116
+ readonly maximumIdBytes: number;
117
+ readonly maximumLifetimeMs: number;
118
+ readonly clockSkewAllowanceMs: number;
119
+ readonly replayWindowSize: number;
120
+ }
121
+ /** Default bounds from the protocol v0 design contract. */
122
+ export declare const DEFAULT_MESH_PROTOCOL_LIMITS: Readonly<MeshProtocolLimits>;
123
+ /** Stable fail-closed protocol errors safe for redacted telemetry. */
124
+ export type MeshProtocolErrorCode = 'invalid_json' | 'invalid_json_value' | 'duplicate_object_key' | 'structural_limit_exceeded' | 'unknown_envelope_field' | 'invalid_protocol' | 'unsupported_wire_version' | 'invalid_identifier' | 'invalid_message_id' | 'invalid_sequence' | 'invalid_timestamp' | 'invalid_lifetime' | 'invalid_audience' | 'type_payload_mismatch' | 'invalid_payload' | 'invalid_payload_hash' | 'invalid_proof' | 'invalid_extension' | 'unknown_critical_extension' | 'scope_mismatch' | 'message_expired' | 'message_from_future' | 'unsupported_message_type';
125
+ /** Bounded issue returned without echoing the rejected payload. */
126
+ export interface MeshProtocolIssue {
127
+ readonly code: MeshProtocolErrorCode;
128
+ readonly path?: string;
129
+ }
130
+ /** Optional limit overrides used by pure parsing and serialization helpers. */
131
+ export interface MeshProtocolOptions {
132
+ readonly limits?: Partial<MeshProtocolLimits>;
133
+ }
134
+ /** Local context applied after structural envelope validation. */
135
+ export interface MeshEnvelopeContext {
136
+ readonly tenantId: string;
137
+ readonly meshId: string;
138
+ readonly peerId: string;
139
+ readonly receivedAt: string;
140
+ readonly subscribedTopics?: readonly MeshAudienceTopic[];
141
+ readonly supportedCriticalExtensions?: readonly string[];
142
+ }
143
+ /** Exact chronological ordering between two valid protocol timestamps. */
144
+ export type MeshTimestampOrder = -1 | 0 | 1;
145
+ /** Generic validation result used across parsing and protocol stages. */
146
+ export type MeshProtocolResult<T> = {
147
+ readonly ok: true;
148
+ readonly value: T;
149
+ } | {
150
+ readonly ok: false;
151
+ readonly issues: readonly MeshProtocolIssue[];
152
+ };
153
+ export {};
154
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,2DAA2D;AAC3D,eAAO,MAAM,aAAa,EAAG,gBAAyB,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,EAAG,CAAU,CAAC;AAE5C,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,EAAG,SAAkB,CAAC;AAE3D,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,wEAMtB,CAAC;AAEZ,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,qkBAiCpB,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,MAAM,sBAAsB,GAAG,OAAO,wBAAwB,CAAC;AAErE,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,aAAa,EAAE,GACxB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAE9C,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAA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