@agentplat/mesh-crypto 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,41 @@
1
+ # `@agentplat/mesh-crypto`
2
+
3
+ Provider-neutral Web Crypto contracts for hashing, signing and verifying
4
+ AgentPlat Mesh envelopes.
5
+
6
+ The Alpha 1 implementation provides:
7
+
8
+ - canonical SHA-256 payload digests;
9
+ - Ed25519 signing and verification through Web Crypto;
10
+ - stable fail-closed signing and verification errors;
11
+ - exact tenant, mesh, peer, key and algorithm binding;
12
+ - inclusive `validFrom`, exclusive `validUntil` and explicit revocation checks;
13
+ - a fixed, bounded `StaticMeshKeyResolver`; and
14
+ - public verification fixtures under `fixtures/v0`.
15
+
16
+ Use `signMeshEnvelope` for the reference outbound path and
17
+ `verifyMeshEnvelope` for the inbound cryptographic boundary. Injectable class
18
+ implementations are available through `createWebCryptoMeshEnvelopeSigner` and
19
+ `createWebCryptoMeshEnvelopeVerifier`.
20
+
21
+ Key resolution is synchronous by design so ordinary inbound verification cannot
22
+ trigger network access. `StaticMeshKeyResolver` rejects duplicate bindings and
23
+ configurations above its explicit record limit.
24
+
25
+ `verifiedAt` is trusted local time supplied by the caller; key validity and
26
+ revocation never depend on the sender-controlled envelope timestamp. Live
27
+ verification always rejects revoked keys. A separate historical-verification
28
+ API may be introduced later, but historical results must never re-enter live
29
+ admission or a reducer.
30
+
31
+ Public-key import and export use the provider-neutral raw 32-byte Ed25519
32
+ representation. Private-key import and export are intentionally outside this
33
+ package's public surface.
34
+
35
+ Verification establishes payload integrity, signature validity and a live
36
+ local key binding. It does not admit a peer, authorize a message, apply replay
37
+ state or mutate domain state.
38
+
39
+ Private keys are never protocol payloads, fixtures or telemetry. Signing tests
40
+ generate temporary key pairs at runtime; public fixtures contain only a raw
41
+ public key and its fixed signed envelope.
@@ -0,0 +1,3 @@
1
+ export declare function encodeBase64Url(bytes: Uint8Array): string;
2
+ export declare function decodeBase64Url(value: string, expectedBytes: number): Uint8Array | undefined;
3
+ //# sourceMappingURL=base64url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../src/base64url.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAiBzD;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,UAAU,GAAG,SAAS,CAwBxB"}
@@ -0,0 +1,50 @@
1
+ const base64UrlPattern = /^[A-Za-z0-9_-]+$/;
2
+ const base64UrlAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
3
+ export function encodeBase64Url(bytes) {
4
+ let encoded = '';
5
+ for (let offset = 0; offset < bytes.byteLength; offset += 3) {
6
+ const first = bytes[offset];
7
+ const second = bytes[offset + 1];
8
+ const third = bytes[offset + 2];
9
+ encoded += base64UrlAlphabet[first >> 2];
10
+ encoded += base64UrlAlphabet[((first & 0b11) << 4) | ((second ?? 0) >> 4)];
11
+ if (second !== undefined) {
12
+ encoded +=
13
+ base64UrlAlphabet[((second & 0b1111) << 2) | ((third ?? 0) >> 6)];
14
+ }
15
+ if (third !== undefined) {
16
+ encoded += base64UrlAlphabet[third & 0b111111];
17
+ }
18
+ }
19
+ return encoded;
20
+ }
21
+ export function decodeBase64Url(value, expectedBytes) {
22
+ if (!base64UrlPattern.test(value))
23
+ return undefined;
24
+ const remainder = value.length % 4;
25
+ if (remainder === 1)
26
+ return undefined;
27
+ if (Math.floor((value.length * 6) / 8) !== expectedBytes)
28
+ return undefined;
29
+ const decoded = new Uint8Array(expectedBytes);
30
+ let accumulator = 0;
31
+ let availableBits = 0;
32
+ let outputOffset = 0;
33
+ for (const character of value) {
34
+ const index = base64UrlAlphabet.indexOf(character);
35
+ if (index < 0)
36
+ return undefined;
37
+ accumulator = (accumulator << 6) | index;
38
+ availableBits += 6;
39
+ if (availableBits >= 8) {
40
+ availableBits -= 8;
41
+ decoded[outputOffset] = (accumulator >> availableBits) & 0xff;
42
+ outputOffset += 1;
43
+ accumulator &= (1 << availableBits) - 1;
44
+ }
45
+ }
46
+ if (outputOffset !== expectedBytes || accumulator !== 0)
47
+ return undefined;
48
+ return decoded;
49
+ }
50
+ //# sourceMappingURL=base64url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64url.js","sourceRoot":"","sources":["../src/base64url.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,iBAAiB,GACrB,kEAAkE,CAAC;AAErE,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChC,OAAO,IAAI,iBAAiB,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;QACzC,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3E,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO;gBACL,iBAAiB,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,IAA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YAC9D,YAAY,IAAI,CAAC,CAAC;YAClB,WAAW,IAAI,CAAC,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,IAAI,YAAY,KAAK,aAAa,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1E,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,101 @@
1
+ import type { MeshMessagePayload, MeshProtocolOptions, MeshSignatureAlgorithm, SignedMeshEnvelope, UnsignedMeshEnvelope, VerifiedMeshEnvelope } from '@agentplat/mesh-protocol';
2
+ /** Locally configured live verification status for one public key. */
3
+ export type MeshKeyStatus = 'active' | 'revoked';
4
+ /**
5
+ * Preprovisioned identity and public-key binding.
6
+ *
7
+ * `validFrom` is inclusive and `validUntil` is exclusive.
8
+ */
9
+ interface MeshKeyRecordBase {
10
+ readonly tenantId: string;
11
+ readonly meshId: string;
12
+ readonly peerId: string;
13
+ readonly keyId: string;
14
+ readonly algorithm: MeshSignatureAlgorithm;
15
+ readonly publicKey: CryptoKey;
16
+ readonly validFrom: string;
17
+ readonly validUntil: string;
18
+ }
19
+ /** Live key record whose validity interval has not been revoked. */
20
+ export interface MeshActiveKeyRecord extends MeshKeyRecordBase {
21
+ readonly status: 'active';
22
+ readonly revokedAt?: never;
23
+ }
24
+ /** Key record explicitly removed from live verification. */
25
+ export interface MeshRevokedKeyRecord extends MeshKeyRecordBase {
26
+ readonly status: 'revoked';
27
+ readonly revokedAt: string;
28
+ }
29
+ export type MeshKeyRecord = MeshActiveKeyRecord | MeshRevokedKeyRecord;
30
+ /**
31
+ * Bounded local key lookup. The synchronous return type intentionally prevents
32
+ * network access from being hidden in the inbound verification path.
33
+ */
34
+ export interface MeshKeyResolver {
35
+ resolve(input: {
36
+ tenantId: string;
37
+ meshId: string;
38
+ peerId: string;
39
+ keyId: string;
40
+ algorithm: MeshSignatureAlgorithm;
41
+ }): MeshKeyRecord | undefined;
42
+ }
43
+ /** Cryptographic suites and key states accepted by one local peer. */
44
+ export interface MeshCryptoPolicy {
45
+ readonly allowedAlgorithms: readonly MeshSignatureAlgorithm[];
46
+ }
47
+ /** Input required to canonicalize and hash one protocol payload. */
48
+ export interface MeshDigestRequest<TPayload extends MeshMessagePayload = MeshMessagePayload> {
49
+ readonly payload: TPayload;
50
+ readonly crypto?: Crypto;
51
+ readonly protocolOptions?: MeshProtocolOptions;
52
+ }
53
+ /** Input required to hash and sign one outbound envelope. */
54
+ export interface MeshSignRequest<TPayload extends MeshMessagePayload = MeshMessagePayload> {
55
+ readonly envelope: UnsignedMeshEnvelope<TPayload>;
56
+ readonly privateKey: CryptoKey;
57
+ readonly crypto?: Crypto;
58
+ readonly protocolOptions?: MeshProtocolOptions;
59
+ }
60
+ /** Input required for bounded local signature verification. */
61
+ export interface MeshVerifyRequest<TPayload extends MeshMessagePayload = MeshMessagePayload> {
62
+ readonly envelope: SignedMeshEnvelope<TPayload>;
63
+ readonly resolver: MeshKeyResolver;
64
+ readonly policy: MeshCryptoPolicy;
65
+ readonly verifiedAt: string;
66
+ readonly crypto?: Crypto;
67
+ readonly protocolOptions?: MeshProtocolOptions;
68
+ }
69
+ /** Stable fail-closed verification failures safe for redacted telemetry. */
70
+ export type MeshCryptoRejectionCode = 'crypto_unavailable' | 'crypto_operation_failed' | 'invalid_envelope' | 'invalid_verification_time' | 'unsupported_algorithm' | 'payload_hash_mismatch' | 'key_not_found' | 'key_resolution_failed' | 'key_binding_mismatch' | 'invalid_key_record' | 'invalid_key_material' | 'key_not_yet_valid' | 'key_expired' | 'key_revoked' | 'signature_invalid';
71
+ /** Stable signer/digest failure raised without including sensitive input. */
72
+ export type MeshCryptoErrorCode = 'crypto_unavailable' | 'crypto_operation_failed' | 'invalid_envelope' | 'invalid_private_key' | 'invalid_public_key' | 'unsupported_algorithm';
73
+ /** Typed operational failure for digest and signing APIs. */
74
+ export declare class MeshCryptoError extends Error {
75
+ readonly code: MeshCryptoErrorCode;
76
+ readonly name = "MeshCryptoError";
77
+ constructor(code: MeshCryptoErrorCode);
78
+ }
79
+ /** Result returned by the reference envelope verifier. */
80
+ export type MeshVerificationResult<TPayload extends MeshMessagePayload = MeshMessagePayload> = {
81
+ readonly verified: true;
82
+ readonly envelope: VerifiedMeshEnvelope<TPayload>;
83
+ readonly key: MeshKeyRecord;
84
+ } | {
85
+ readonly verified: false;
86
+ readonly code: MeshCryptoRejectionCode;
87
+ };
88
+ /** Injectable signer used by production and loopback drivers. */
89
+ export interface MeshEnvelopeSigner {
90
+ sign<TPayload extends MeshMessagePayload>(request: MeshSignRequest<TPayload>): Promise<SignedMeshEnvelope<TPayload>>;
91
+ }
92
+ /** Injectable verifier used before local admission and replay checks. */
93
+ export interface MeshEnvelopeVerifier {
94
+ verify<TPayload extends MeshMessagePayload>(request: MeshVerifyRequest<TPayload>): Promise<MeshVerificationResult<TPayload>>;
95
+ }
96
+ /** Construction bound for the static in-memory key resolver. */
97
+ export interface StaticMeshKeyResolverOptions {
98
+ readonly maximumRecords?: number;
99
+ }
100
+ export {};
101
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,sEAAsE;AACtE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEjD;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAC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AAQ,EAAE,IAAI,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAClD,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B,GACD;IACE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;CACxC,CAAC;AAEN,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,QAAQ,SAAS,kBAAkB,EACtC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC1C;AAED,yEAAyE;AACzE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,QAAQ,SAAS,kBAAkB,EACxC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GACnC,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC9C;AAED,gEAAgE;AAChE,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC"}
@@ -0,0 +1,10 @@
1
+ /** Typed operational failure for digest and signing APIs. */
2
+ export class MeshCryptoError extends Error {
3
+ code;
4
+ name = 'MeshCryptoError';
5
+ constructor(code) {
6
+ super(code);
7
+ this.code = code;
8
+ }
9
+ }
10
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAuHA,6DAA6D;AAC7D,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAGnB;IAFZ,IAAI,GAAG,iBAAiB,CAAC;IAElC,YAAqB,IAAyB;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAC;QADO,SAAI,GAAJ,IAAI,CAAqB;IAE9C,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export * from './contracts.js';
2
+ export { StaticMeshKeyResolver, createStaticMeshKeyResolver, } from './static-key-resolver.js';
3
+ export { DEFAULT_MESH_CRYPTO_POLICY, WebCryptoMeshEnvelopeSigner, WebCryptoMeshEnvelopeVerifier, computeMeshPayloadHash, createWebCryptoMeshEnvelopeSigner, createWebCryptoMeshEnvelopeVerifier, exportMeshEd25519PublicKey, importMeshEd25519PublicKey, signMeshEnvelope, verifyMeshEnvelope, } from './web-crypto.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,0BAA0B,EAC1B,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './contracts.js';
2
+ export { StaticMeshKeyResolver, createStaticMeshKeyResolver, } from './static-key-resolver.js';
3
+ export { DEFAULT_MESH_CRYPTO_POLICY, WebCryptoMeshEnvelopeSigner, WebCryptoMeshEnvelopeVerifier, computeMeshPayloadHash, createWebCryptoMeshEnvelopeSigner, createWebCryptoMeshEnvelopeVerifier, exportMeshEd25519PublicKey, importMeshEd25519PublicKey, signMeshEnvelope, verifyMeshEnvelope, } from './web-crypto.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,sBAAsB,EACtB,iCAAiC,EACjC,mCAAmC,EACnC,0BAA0B,EAC1B,0BAA0B,EAC1B,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { MESH_SIGNATURE_ALGORITHM } from '@agentplat/mesh-protocol';
2
+ import type { MeshKeyRecord, MeshKeyResolver, StaticMeshKeyResolverOptions } from './contracts.js';
3
+ /**
4
+ * Fixed, bounded key resolver with no callbacks, I/O or hidden network path.
5
+ */
6
+ export declare class StaticMeshKeyResolver implements MeshKeyResolver {
7
+ private readonly records;
8
+ constructor(records: readonly MeshKeyRecord[], options?: StaticMeshKeyResolverOptions);
9
+ resolve(input: {
10
+ tenantId: string;
11
+ meshId: string;
12
+ peerId: string;
13
+ keyId: string;
14
+ algorithm: typeof MESH_SIGNATURE_ALGORITHM;
15
+ }): MeshKeyRecord | undefined;
16
+ }
17
+ /** Creates a fixed local resolver without requiring `new`. */
18
+ export declare function createStaticMeshKeyResolver(records: readonly MeshKeyRecord[], options?: StaticMeshKeyResolverOptions): StaticMeshKeyResolver;
19
+ //# sourceMappingURL=static-key-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-key-resolver.d.ts","sourceRoot":"","sources":["../src/static-key-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAEzB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AAIxB;;GAEG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;gBAG1D,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,GAAE,4BAAiC;IAyB5C,OAAO,CAAC,KAAK,EAAE;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,OAAO,wBAAwB,CAAC;KAC5C,GAAG,aAAa,GAAG,SAAS;CAW9B;AAED,8DAA8D;AAC9D,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAEvB"}
@@ -0,0 +1,83 @@
1
+ import { MESH_SIGNATURE_ALGORITHM, compareMeshTimestamps, } from '@agentplat/mesh-protocol';
2
+ const defaultMaximumRecords = 256;
3
+ /**
4
+ * Fixed, bounded key resolver with no callbacks, I/O or hidden network path.
5
+ */
6
+ export class StaticMeshKeyResolver {
7
+ records = new Map();
8
+ constructor(records, options = {}) {
9
+ const maximumRecords = options.maximumRecords ?? defaultMaximumRecords;
10
+ if (!Number.isSafeInteger(maximumRecords) || maximumRecords < 1) {
11
+ throw new RangeError('maximumRecords must be a positive safe integer');
12
+ }
13
+ if (records.length > maximumRecords) {
14
+ throw new RangeError('Static Mesh key record limit exceeded');
15
+ }
16
+ for (const record of records) {
17
+ assertConfiguredRecord(record);
18
+ const key = recordKey(record.tenantId, record.meshId, record.peerId, record.keyId, record.algorithm);
19
+ if (this.records.has(key)) {
20
+ throw new TypeError('Duplicate static Mesh key binding');
21
+ }
22
+ this.records.set(key, Object.freeze({ ...record }));
23
+ }
24
+ }
25
+ resolve(input) {
26
+ return this.records.get(recordKey(input.tenantId, input.meshId, input.peerId, input.keyId, input.algorithm));
27
+ }
28
+ }
29
+ /** Creates a fixed local resolver without requiring `new`. */
30
+ export function createStaticMeshKeyResolver(records, options = {}) {
31
+ return new StaticMeshKeyResolver(records, options);
32
+ }
33
+ function assertConfiguredRecord(record) {
34
+ if (!record ||
35
+ typeof record.tenantId !== 'string' ||
36
+ typeof record.meshId !== 'string' ||
37
+ typeof record.peerId !== 'string' ||
38
+ typeof record.keyId !== 'string' ||
39
+ record.algorithm !== MESH_SIGNATURE_ALGORITHM ||
40
+ (record.status !== 'active' && record.status !== 'revoked') ||
41
+ !isEd25519Key(record.publicKey, 'public', 'verify')) {
42
+ throw new TypeError('Invalid static Mesh key record');
43
+ }
44
+ const validity = compareMeshTimestamps(record.validFrom, record.validUntil);
45
+ if (!validity.ok || validity.value >= 0) {
46
+ throw new TypeError('Invalid static Mesh key validity interval');
47
+ }
48
+ if (record.revokedAt !== undefined &&
49
+ !compareMeshTimestamps(record.revokedAt, record.revokedAt).ok) {
50
+ throw new TypeError('Invalid static Mesh key revocation timestamp');
51
+ }
52
+ if (record.status === 'active' && record.revokedAt !== undefined) {
53
+ throw new TypeError('Active static Mesh key cannot have revokedAt');
54
+ }
55
+ if (record.status === 'revoked') {
56
+ if (record.revokedAt === undefined) {
57
+ throw new TypeError('Revoked static Mesh key requires revokedAt');
58
+ }
59
+ const revokedAfterStart = compareMeshTimestamps(record.revokedAt, record.validFrom);
60
+ const revokedBeforeEnd = compareMeshTimestamps(record.revokedAt, record.validUntil);
61
+ if (!revokedAfterStart.ok ||
62
+ !revokedBeforeEnd.ok ||
63
+ revokedAfterStart.value < 0 ||
64
+ revokedBeforeEnd.value >= 0) {
65
+ throw new TypeError('Invalid static Mesh key revocation interval');
66
+ }
67
+ }
68
+ }
69
+ function isEd25519Key(key, type, usage) {
70
+ try {
71
+ return (!!key &&
72
+ key.type === type &&
73
+ key.algorithm?.name === MESH_SIGNATURE_ALGORITHM &&
74
+ Array.from(key.usages).includes(usage));
75
+ }
76
+ catch {
77
+ return false;
78
+ }
79
+ }
80
+ function recordKey(tenantId, meshId, peerId, keyId, algorithm) {
81
+ return JSON.stringify([tenantId, meshId, peerId, keyId, algorithm]);
82
+ }
83
+ //# sourceMappingURL=static-key-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-key-resolver.js","sourceRoot":"","sources":["../src/static-key-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,0BAA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1
+ import { type MeshMessagePayload, type SignedMeshEnvelope } from '@agentplat/mesh-protocol';
2
+ import { type MeshCryptoPolicy, type MeshDigestRequest, type MeshEnvelopeSigner, type MeshEnvelopeVerifier, type MeshSignRequest, type MeshVerificationResult, type MeshVerifyRequest } from './contracts.js';
3
+ /** Strict default policy for the reference cryptographic suite. */
4
+ export declare const DEFAULT_MESH_CRYPTO_POLICY: Readonly<MeshCryptoPolicy>;
5
+ /** Computes the canonical SHA-256 payload representation. */
6
+ export declare function computeMeshPayloadHash<TPayload extends MeshMessagePayload>(request: MeshDigestRequest<TPayload>): Promise<string>;
7
+ /** Hashes, constructs and signs one structurally valid outbound envelope. */
8
+ export declare function signMeshEnvelope<TPayload extends MeshMessagePayload>(request: MeshSignRequest<TPayload>): Promise<SignedMeshEnvelope<TPayload>>;
9
+ /** Verifies digest, proof, key binding, validity and revocation fail-closed. */
10
+ export declare function verifyMeshEnvelope<TPayload extends MeshMessagePayload>(request: MeshVerifyRequest<TPayload>): Promise<MeshVerificationResult<TPayload>>;
11
+ /** Imports one extractable raw 32-byte Ed25519 public key. */
12
+ export declare function importMeshEd25519PublicKey(rawKey: Uint8Array, injectedCrypto?: Crypto): Promise<CryptoKey>;
13
+ /** Exports one Ed25519 public key as an independent 32-byte raw value. */
14
+ export declare function exportMeshEd25519PublicKey(publicKey: CryptoKey, injectedCrypto?: Crypto): Promise<Uint8Array>;
15
+ /** Reference Web Crypto signer implementation. */
16
+ export declare class WebCryptoMeshEnvelopeSigner implements MeshEnvelopeSigner {
17
+ sign<TPayload extends MeshMessagePayload>(request: MeshSignRequest<TPayload>): Promise<SignedMeshEnvelope<TPayload>>;
18
+ }
19
+ /** Reference Web Crypto verifier implementation. */
20
+ export declare class WebCryptoMeshEnvelopeVerifier implements MeshEnvelopeVerifier {
21
+ verify<TPayload extends MeshMessagePayload>(request: MeshVerifyRequest<TPayload>): Promise<MeshVerificationResult<TPayload>>;
22
+ }
23
+ /** Creates the reference signer without requiring `new`. */
24
+ export declare function createWebCryptoMeshEnvelopeSigner(): WebCryptoMeshEnvelopeSigner;
25
+ /** Creates the reference verifier without requiring `new`. */
26
+ export declare function createWebCryptoMeshEnvelopeVerifier(): WebCryptoMeshEnvelopeVerifier;
27
+ //# sourceMappingURL=web-crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-crypto.d.ts","sourceRoot":"","sources":["../src/web-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAExB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAOxB,mEAAmE;AACnE,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,gBAAgB,CAG9D,CAAC;AAEL,6DAA6D;AAC7D,wBAAsB,sBAAsB,CAC1C,QAAQ,SAAS,kBAAkB,EACnC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAMvD;AA+BD,6EAA6E;AAC7E,wBAAsB,gBAAgB,CAAC,QAAQ,SAAS,kBAAkB,EACxE,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAMvC;AAkGD,gFAAgF;AAChF,wBAAsB,kBAAkB,CAAC,QAAQ,SAAS,kBAAkB,EAC1E,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GACnC,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAQ3C;AAiHD,8DAA8D;AAC9D,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,UAAU,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,SAAS,CAAC,CAoBpB;AAED,0EAA0E;AAC1E,wBAAsB,0BAA0B,CAC9C,SAAS,EAAE,SAAS,EACpB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,UAAU,CAAC,CAgBrB;AAED,kDAAkD;AAClD,qBAAa,2BAA4B,YAAW,kBAAkB;IACpE,IAAI,CAAC,QAAQ,SAAS,kBAAkB,EACtC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;CAGzC;AAED,oDAAoD;AACpD,qBAAa,6BAA8B,YAAW,oBAAoB;IACxE,MAAM,CAAC,QAAQ,SAAS,kBAAkB,EACxC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GACnC,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;CAG7C;AAED,4DAA4D;AAC5D,wBAAgB,iCAAiC,IAAI,2BAA2B,CAE/E;AAED,8DAA8D;AAC9D,wBAAgB,mCAAmC,IAAI,6BAA6B,CAEnF"}
@@ -0,0 +1,378 @@
1
+ import { MESH_SIGNATURE_ALGORITHM, canonicalizeMeshPayload, canonicalizeMeshSigningDocument, compareMeshTimestamps, validateSignedMeshEnvelope, } from '@agentplat/mesh-protocol';
2
+ import { decodeBase64Url, encodeBase64Url } from './base64url.js';
3
+ import { MeshCryptoError, } from './contracts.js';
4
+ const placeholderPayloadHash = 'sha256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
5
+ const placeholderSignature = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
6
+ /** Strict default policy for the reference cryptographic suite. */
7
+ export const DEFAULT_MESH_CRYPTO_POLICY = Object.freeze({
8
+ allowedAlgorithms: Object.freeze([MESH_SIGNATURE_ALGORITHM]),
9
+ });
10
+ /** Computes the canonical SHA-256 payload representation. */
11
+ export async function computeMeshPayloadHash(request) {
12
+ try {
13
+ return await computeMeshPayloadHashInternal(request);
14
+ }
15
+ catch (error) {
16
+ throw normalizeCryptoError(error);
17
+ }
18
+ }
19
+ async function computeMeshPayloadHashInternal(request) {
20
+ if (!request || typeof request !== 'object') {
21
+ throw new MeshCryptoError('invalid_envelope');
22
+ }
23
+ const crypto = resolveCrypto(request.crypto);
24
+ const payloadBytes = canonicalizeMeshPayload(request.payload, request.protocolOptions);
25
+ if (!payloadBytes.ok)
26
+ throw new MeshCryptoError('invalid_envelope');
27
+ let digest;
28
+ try {
29
+ digest = new Uint8Array(await crypto.subtle.digest('SHA-256', copyToArrayBuffer(payloadBytes.value)));
30
+ }
31
+ catch {
32
+ throw new MeshCryptoError('crypto_operation_failed');
33
+ }
34
+ if (digest.byteLength !== 32) {
35
+ throw new MeshCryptoError('crypto_operation_failed');
36
+ }
37
+ return `sha256:${encodeBase64Url(digest)}`;
38
+ }
39
+ /** Hashes, constructs and signs one structurally valid outbound envelope. */
40
+ export async function signMeshEnvelope(request) {
41
+ try {
42
+ return await signMeshEnvelopeInternal(request);
43
+ }
44
+ catch (error) {
45
+ throw normalizeCryptoError(error);
46
+ }
47
+ }
48
+ async function signMeshEnvelopeInternal(request) {
49
+ if (!request || typeof request !== 'object') {
50
+ throw new MeshCryptoError('invalid_envelope');
51
+ }
52
+ const inputEnvelope = request.envelope;
53
+ const privateKey = request.privateKey;
54
+ const injectedCrypto = request.crypto;
55
+ const protocolOptions = snapshotProtocolOptions(request.protocolOptions);
56
+ if (!inputEnvelope ||
57
+ typeof inputEnvelope !== 'object' ||
58
+ !inputEnvelope.proof ||
59
+ typeof inputEnvelope.proof !== 'object') {
60
+ throw new MeshCryptoError('invalid_envelope');
61
+ }
62
+ if (inputEnvelope.proof.algorithm !== MESH_SIGNATURE_ALGORITHM) {
63
+ throw new MeshCryptoError('unsupported_algorithm');
64
+ }
65
+ if (!isEd25519Key(privateKey, 'private', 'sign')) {
66
+ throw new MeshCryptoError('invalid_private_key');
67
+ }
68
+ const inputValidation = validateSignedMeshEnvelope({
69
+ ...inputEnvelope,
70
+ payloadHash: placeholderPayloadHash,
71
+ proof: {
72
+ ...inputEnvelope.proof,
73
+ value: placeholderSignature,
74
+ },
75
+ }, protocolOptions);
76
+ if (!inputValidation.ok) {
77
+ throw new MeshCryptoError('invalid_envelope');
78
+ }
79
+ const envelopeSnapshot = inputValidation.value;
80
+ const crypto = resolveCrypto(injectedCrypto);
81
+ const payloadHash = await computeMeshPayloadHash({
82
+ payload: envelopeSnapshot.payload,
83
+ crypto,
84
+ protocolOptions,
85
+ });
86
+ const structuralCandidate = {
87
+ ...envelopeSnapshot,
88
+ payloadHash,
89
+ };
90
+ const structuralValidation = validateSignedMeshEnvelope(structuralCandidate, protocolOptions);
91
+ if (!structuralValidation.ok) {
92
+ throw new MeshCryptoError('invalid_envelope');
93
+ }
94
+ const structuralEnvelope = structuralValidation.value;
95
+ const signingBytes = canonicalizeMeshSigningDocument(structuralEnvelope, protocolOptions);
96
+ if (!signingBytes.ok)
97
+ throw new MeshCryptoError('invalid_envelope');
98
+ let signature;
99
+ try {
100
+ signature = new Uint8Array(await crypto.subtle.sign(MESH_SIGNATURE_ALGORITHM, privateKey, copyToArrayBuffer(signingBytes.value)));
101
+ }
102
+ catch {
103
+ throw new MeshCryptoError('crypto_operation_failed');
104
+ }
105
+ if (signature.byteLength !== 64) {
106
+ throw new MeshCryptoError('crypto_operation_failed');
107
+ }
108
+ const signedCandidate = {
109
+ ...structuralEnvelope,
110
+ proof: {
111
+ ...structuralEnvelope.proof,
112
+ value: encodeBase64Url(signature),
113
+ },
114
+ };
115
+ const signedValidation = validateSignedMeshEnvelope(signedCandidate, protocolOptions);
116
+ if (!signedValidation.ok)
117
+ throw new MeshCryptoError('invalid_envelope');
118
+ return signedValidation.value;
119
+ }
120
+ /** Verifies digest, proof, key binding, validity and revocation fail-closed. */
121
+ export async function verifyMeshEnvelope(request) {
122
+ try {
123
+ return await verifyMeshEnvelopeInternal(request);
124
+ }
125
+ catch (error) {
126
+ return rejection(error instanceof MeshCryptoError ? error.code : 'crypto_operation_failed');
127
+ }
128
+ }
129
+ async function verifyMeshEnvelopeInternal(request) {
130
+ if (!request || typeof request !== 'object') {
131
+ return rejection('invalid_envelope');
132
+ }
133
+ const inputEnvelope = request.envelope;
134
+ if (!inputEnvelope || typeof inputEnvelope !== 'object') {
135
+ return rejection('invalid_envelope');
136
+ }
137
+ const resolver = request.resolver;
138
+ const allowedAlgorithms = Array.from(request.policy.allowedAlgorithms);
139
+ const verifiedAt = request.verifiedAt;
140
+ const injectedCrypto = request.crypto;
141
+ const protocolOptions = snapshotProtocolOptions(request.protocolOptions);
142
+ const structuralValidation = validateSignedMeshEnvelope(inputEnvelope, protocolOptions);
143
+ if (!structuralValidation.ok)
144
+ return rejection('invalid_envelope');
145
+ const envelope = structuralValidation.value;
146
+ if (envelope.proof.algorithm !== MESH_SIGNATURE_ALGORITHM ||
147
+ !allowedAlgorithms.includes(envelope.proof.algorithm)) {
148
+ return rejection('unsupported_algorithm');
149
+ }
150
+ if (!compareMeshTimestamps(verifiedAt, verifiedAt).ok) {
151
+ return rejection('invalid_verification_time');
152
+ }
153
+ let resolvedKey;
154
+ try {
155
+ resolvedKey = resolver.resolve({
156
+ tenantId: envelope.tenantId,
157
+ meshId: envelope.meshId,
158
+ peerId: envelope.sender.peerId,
159
+ keyId: envelope.proof.keyId,
160
+ algorithm: envelope.proof.algorithm,
161
+ });
162
+ }
163
+ catch {
164
+ return rejection('key_resolution_failed');
165
+ }
166
+ if (!resolvedKey)
167
+ return rejection('key_not_found');
168
+ if (isPromiseLike(resolvedKey))
169
+ return rejection('invalid_key_record');
170
+ let key;
171
+ try {
172
+ key = Object.freeze({ ...resolvedKey });
173
+ }
174
+ catch {
175
+ return rejection('invalid_key_record');
176
+ }
177
+ if (!isEd25519Key(key.publicKey, 'public', 'verify')) {
178
+ return rejection('invalid_key_material');
179
+ }
180
+ let payloadHash;
181
+ try {
182
+ payloadHash = await computeMeshPayloadHash({
183
+ payload: envelope.payload,
184
+ crypto: injectedCrypto,
185
+ protocolOptions,
186
+ });
187
+ }
188
+ catch (error) {
189
+ return rejection(error instanceof MeshCryptoError ? error.code : 'crypto_operation_failed');
190
+ }
191
+ if (payloadHash !== envelope.payloadHash) {
192
+ return rejection('payload_hash_mismatch');
193
+ }
194
+ const signature = decodeBase64Url(envelope.proof.value, 64);
195
+ const signingBytes = canonicalizeMeshSigningDocument(envelope, protocolOptions);
196
+ if (!signature || !signingBytes.ok)
197
+ return rejection('invalid_envelope');
198
+ const crypto = optionalCrypto(injectedCrypto);
199
+ if (!crypto)
200
+ return rejection('crypto_unavailable');
201
+ let signatureValid;
202
+ try {
203
+ signatureValid = await crypto.subtle.verify(MESH_SIGNATURE_ALGORITHM, key.publicKey, copyToArrayBuffer(signature), copyToArrayBuffer(signingBytes.value));
204
+ }
205
+ catch {
206
+ return rejection('crypto_operation_failed');
207
+ }
208
+ if (signatureValid !== true)
209
+ return rejection('signature_invalid');
210
+ const keyState = validateKeyState(key, envelope.tenantId, envelope.meshId, envelope.sender.peerId, envelope.proof.keyId, envelope.proof.algorithm, verifiedAt);
211
+ if (keyState)
212
+ return rejection(keyState);
213
+ return {
214
+ verified: true,
215
+ envelope: envelope,
216
+ key,
217
+ };
218
+ }
219
+ /** Imports one extractable raw 32-byte Ed25519 public key. */
220
+ export async function importMeshEd25519PublicKey(rawKey, injectedCrypto) {
221
+ if (!(rawKey instanceof Uint8Array) || rawKey.byteLength !== 32) {
222
+ throw new MeshCryptoError('invalid_public_key');
223
+ }
224
+ try {
225
+ const crypto = resolveCrypto(injectedCrypto);
226
+ const key = await crypto.subtle.importKey('raw', copyToArrayBuffer(rawKey), { name: MESH_SIGNATURE_ALGORITHM }, true, ['verify']);
227
+ if (!isEd25519Key(key, 'public', 'verify')) {
228
+ throw new MeshCryptoError('invalid_public_key');
229
+ }
230
+ return key;
231
+ }
232
+ catch (error) {
233
+ throw normalizeCryptoError(error);
234
+ }
235
+ }
236
+ /** Exports one Ed25519 public key as an independent 32-byte raw value. */
237
+ export async function exportMeshEd25519PublicKey(publicKey, injectedCrypto) {
238
+ if (!isEd25519Key(publicKey, 'public', 'verify')) {
239
+ throw new MeshCryptoError('invalid_public_key');
240
+ }
241
+ try {
242
+ const crypto = resolveCrypto(injectedCrypto);
243
+ const rawKey = new Uint8Array(await crypto.subtle.exportKey('raw', publicKey));
244
+ if (rawKey.byteLength !== 32) {
245
+ throw new MeshCryptoError('invalid_public_key');
246
+ }
247
+ return rawKey.slice();
248
+ }
249
+ catch (error) {
250
+ throw normalizeCryptoError(error);
251
+ }
252
+ }
253
+ /** Reference Web Crypto signer implementation. */
254
+ export class WebCryptoMeshEnvelopeSigner {
255
+ sign(request) {
256
+ return signMeshEnvelope(request);
257
+ }
258
+ }
259
+ /** Reference Web Crypto verifier implementation. */
260
+ export class WebCryptoMeshEnvelopeVerifier {
261
+ verify(request) {
262
+ return verifyMeshEnvelope(request);
263
+ }
264
+ }
265
+ /** Creates the reference signer without requiring `new`. */
266
+ export function createWebCryptoMeshEnvelopeSigner() {
267
+ return new WebCryptoMeshEnvelopeSigner();
268
+ }
269
+ /** Creates the reference verifier without requiring `new`. */
270
+ export function createWebCryptoMeshEnvelopeVerifier() {
271
+ return new WebCryptoMeshEnvelopeVerifier();
272
+ }
273
+ function validateKeyState(key, tenantId, meshId, peerId, keyId, algorithm, verifiedAt) {
274
+ if (key.tenantId !== tenantId ||
275
+ key.meshId !== meshId ||
276
+ key.peerId !== peerId ||
277
+ key.keyId !== keyId ||
278
+ key.algorithm !== algorithm) {
279
+ return 'key_binding_mismatch';
280
+ }
281
+ const from = compareMeshTimestamps(verifiedAt, key.validFrom);
282
+ const until = compareMeshTimestamps(verifiedAt, key.validUntil);
283
+ const interval = compareMeshTimestamps(key.validFrom, key.validUntil);
284
+ if (!from.ok || !until.ok || !interval.ok || interval.value >= 0) {
285
+ return 'invalid_key_record';
286
+ }
287
+ if (from.value < 0)
288
+ return 'key_not_yet_valid';
289
+ if (until.value >= 0)
290
+ return 'key_expired';
291
+ if (key.revokedAt !== undefined &&
292
+ !compareMeshTimestamps(key.revokedAt, key.revokedAt).ok) {
293
+ return 'invalid_key_record';
294
+ }
295
+ if (key.status !== 'active' && key.status !== 'revoked') {
296
+ return 'invalid_key_record';
297
+ }
298
+ if (key.status === 'active' && key.revokedAt !== undefined) {
299
+ return 'invalid_key_record';
300
+ }
301
+ if (key.status === 'revoked') {
302
+ if (key.revokedAt === undefined)
303
+ return 'invalid_key_record';
304
+ const revokedAfterStart = compareMeshTimestamps(key.revokedAt, key.validFrom);
305
+ const revokedBeforeEnd = compareMeshTimestamps(key.revokedAt, key.validUntil);
306
+ if (!revokedAfterStart.ok ||
307
+ !revokedBeforeEnd.ok ||
308
+ revokedAfterStart.value < 0 ||
309
+ revokedBeforeEnd.value >= 0) {
310
+ return 'invalid_key_record';
311
+ }
312
+ return 'key_revoked';
313
+ }
314
+ return undefined;
315
+ }
316
+ function isEd25519Key(key, type, usage) {
317
+ try {
318
+ return (!!key &&
319
+ key.type === type &&
320
+ key.algorithm?.name === MESH_SIGNATURE_ALGORITHM &&
321
+ Array.from(key.usages).includes(usage));
322
+ }
323
+ catch {
324
+ return false;
325
+ }
326
+ }
327
+ function resolveCrypto(injected) {
328
+ const crypto = optionalCrypto(injected);
329
+ if (!crypto)
330
+ throw new MeshCryptoError('crypto_unavailable');
331
+ return crypto;
332
+ }
333
+ function optionalCrypto(injected) {
334
+ const candidate = injected ?? globalThis.crypto;
335
+ return candidate?.subtle ? candidate : undefined;
336
+ }
337
+ function copyToArrayBuffer(bytes) {
338
+ const copy = new Uint8Array(bytes.byteLength);
339
+ copy.set(bytes);
340
+ return copy.buffer;
341
+ }
342
+ function snapshotProtocolOptions(options) {
343
+ if (options === undefined)
344
+ return undefined;
345
+ return Object.freeze({
346
+ ...(options.limits === undefined
347
+ ? {}
348
+ : { limits: Object.freeze({ ...options.limits }) }),
349
+ });
350
+ }
351
+ function isPromiseLike(value) {
352
+ try {
353
+ return (typeof value === 'object' &&
354
+ value !== null &&
355
+ typeof value.then === 'function');
356
+ }
357
+ catch {
358
+ return true;
359
+ }
360
+ }
361
+ function normalizeCryptoError(error) {
362
+ return error instanceof MeshCryptoError
363
+ ? error
364
+ : new MeshCryptoError('crypto_operation_failed');
365
+ }
366
+ function rejection(code) {
367
+ return {
368
+ verified: false,
369
+ code: code === 'invalid_private_key'
370
+ ? 'invalid_key_material'
371
+ : code === 'invalid_public_key'
372
+ ? 'invalid_key_material'
373
+ : code === 'unsupported_algorithm'
374
+ ? 'unsupported_algorithm'
375
+ : code,
376
+ };
377
+ }
378
+ //# sourceMappingURL=web-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-crypto.js","sourceRoot":"","sources":["../src/web-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,+BAA+B,EAC/B,qBAAqB,EACrB,0BAA0B,GAK3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,eAAe,GAUhB,MAAM,gBAAgB,CAAC;AAExB,MAAM,sBAAsB,GAC1B,oDAAoD,CAAC;AACvD,MAAM,oBAAoB,GACxB,wFAAwF,CAAC;AAE3F,mEAAmE;AACnE,MAAM,CAAC,MAAM,0BAA0B,GACrC,MAAM,CAAC,MAAM,CAAC;IACZ,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,wBAAwB,CAAC,CAAC;CAC7D,CAAC,CAAC;AAEL,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAE1C,OAAoC;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,8BAA8B,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;A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oBAChC,CAAC,CAAC,uBAAuB;oBACzB,CAAC,CAAC,IAAI;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ # Protocol v0 cryptographic fixtures
2
+
3
+ `signed-peer-hello.json` and `peer-a-public.raw.json` form one fixed Ed25519
4
+ verification vector. The payload digest and signature cover the exact
5
+ canonical protocol documents defined by `@agentplat/mesh-protocol`.
6
+
7
+ The public key uses the provider-neutral raw 32-byte representation as a JSON
8
+ byte array so the fixture remains reviewable text.
9
+
10
+ The private key used to create the signature was ephemeral and discarded. It
11
+ is not included in source, package output, telemetry or documentation. Tests
12
+ that exercise signing generate temporary key pairs at runtime and never export
13
+ their private components.
@@ -0,0 +1,8 @@
1
+ {
2
+ "format": "raw",
3
+ "algorithm": "Ed25519",
4
+ "publicKey": [
5
+ 228, 35, 78, 133, 92, 183, 90, 49, 38, 170, 83, 181, 191, 40, 239, 175, 208,
6
+ 16, 54, 81, 220, 74, 200, 22, 95, 152, 65, 23, 206, 235, 80, 192
7
+ ]
8
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "protocol": "agentplat.mesh",
3
+ "wireVersion": 0,
4
+ "messageId": "CCCCCCCCCCCCCCCCCCCCCA",
5
+ "tenantId": "tenant-conformance",
6
+ "meshId": "mesh-conformance",
7
+ "type": "peer.hello",
8
+ "sender": {
9
+ "peerId": "peer-conformance-a",
10
+ "instanceId": "instance-conformance-a"
11
+ },
12
+ "audience": {
13
+ "kind": "peer",
14
+ "peerId": "peer-conformance-b"
15
+ },
16
+ "sequence": 1,
17
+ "sentAt": "2026-07-30T12:00:00Z",
18
+ "expiresAt": "2026-07-30T12:02:00Z",
19
+ "payloadHash": "sha256:1eTTFKIr3MahNi_Mx-duQidWUAeerEpEK-qWQemPkzQ",
20
+ "payload": {
21
+ "type": "peer.hello",
22
+ "peerCardId": "card-conformance-a",
23
+ "cardRevision": 1
24
+ },
25
+ "proof": {
26
+ "algorithm": "Ed25519",
27
+ "keyId": "key-conformance-a",
28
+ "value": "YOM_6GfMuv9xppudjCXvuFxuCOzcl-XbVjBIOV-8LCyE4ECDY8CA3n_idLBMw_Z3Glvgccdmvexr3s2QjIudAw"
29
+ }
30
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@agentplat/mesh-crypto",
3
+ "version": "0.3.0-alpha.1",
4
+ "description": "Web Crypto signing and verification contracts for AgentPlat Mesh envelopes.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "fixtures",
19
+ "README.md"
20
+ ],
21
+ "dependencies": {
22
+ "@agentplat/mesh-protocol": "^0.3.0-alpha.1"
23
+ },
24
+ "engines": {
25
+ "node": ">=20.19.3"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/Agentplat/agentplat.git",
33
+ "directory": "packages/mesh-crypto"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.json",
37
+ "type-check": "tsc -p tsconfig.json --noEmit",
38
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
39
+ }
40
+ }