@crosslink/protocol 0.1.0

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,163 @@
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 the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control
17
+ with that entity. For the purposes of this definition, "control" means
18
+ (i) the power, direct or indirect, to cause the direction or management
19
+ of such entity, whether by contract or otherwise, or (ii) ownership of
20
+ fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
21
+ ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ 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 source,
28
+ and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object
35
+ form, made available under the License, as indicated by a copyright notice
36
+ that is included in or attached to the work.
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form,
39
+ that is based on (or derived from) the Work and for which the editorial
40
+ revisions, annotations, elaborations, or other modifications represent, as
41
+ a whole, an original work of authorship. For the purposes of this License,
42
+ Derivative Works shall not include works that remain separable from, or
43
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
44
+ Works thereof.
45
+
46
+ "Contribution" shall mean any work of authorship, including the original
47
+ version of the Work and any modifications or additions to that Work or
48
+ Derivative Works thereof, that is intentionally submitted to the Licensor
49
+ for inclusion in the Work by the copyright owner or by an individual or
50
+ Legal Entity authorized to submit on behalf of the copyright owner. For the
51
+ purposes of this definition, "submitted" means any form of electronic,
52
+ verbal, or written communication sent to the Licensor or its representatives,
53
+ including but not limited to communication on electronic mailing lists,
54
+ source code control systems, and issue tracking systems that are managed by,
55
+ or on behalf of, the Licensor for the purpose of discussing and improving
56
+ the Work, but excluding communication that is conspicuously marked or
57
+ otherwise designated in writing by the copyright owner as "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
60
+ behalf of whom a Contribution has been received by the Licensor and
61
+ subsequently incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
64
+ License, each Contributor hereby grants to You a perpetual, worldwide,
65
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
66
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
67
+ sublicense, and distribute the Work and such Derivative Works in Source or
68
+ Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of this
71
+ License, each Contributor hereby grants to You a perpetual, worldwide,
72
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
73
+ this section) patent license to make, have made, use, offer to sell, sell,
74
+ import, and otherwise transfer the Work, where such license applies only to
75
+ those patent claims licensable by such Contributor that are necessarily
76
+ infringed by their Contribution(s) alone or by combination of their
77
+ Contribution(s) with the Work to which such Contribution(s) was submitted.
78
+ If You institute patent litigation against any entity (including a
79
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80
+ Contribution incorporated within the Work constitutes direct or contributory
81
+ patent infringement, then any patent licenses granted to You under this
82
+ License for that Work shall terminate as of the date such litigation is filed.
83
+
84
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
85
+ Derivative Works thereof in any medium, with or without modifications, and
86
+ in Source or Object form, provided that You meet the following conditions:
87
+
88
+ (a) You must give any other recipients of the Work or Derivative Works
89
+ a copy of this License; and
90
+
91
+ (b) You must cause any modified files to carry prominent notices stating
92
+ that You changed the files; and
93
+
94
+ (c) You must retain, in the Source form of any Derivative Works that You
95
+ distribute, all copyright, patent, trademark, and attribution notices
96
+ from the Source form of the Work, excluding those notices that do not
97
+ pertain to any part of the Derivative Works; and
98
+
99
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
100
+ then any Derivative Works that You distribute must include a readable
101
+ copy of the attribution notices contained within such NOTICE file,
102
+ excluding any notices that do not pertain to any part of the Derivative
103
+ Works, in at least one of the following places: within a NOTICE text
104
+ file distributed as part of the Derivative Works; within the Source
105
+ form or documentation, if provided along with the Derivative Works; or,
106
+ within a display generated by the Derivative Works, if and wherever
107
+ such third-party notices normally appear. The contents of the NOTICE
108
+ file are for informational purposes only and do not modify the License.
109
+ You may add Your own attribution notices within Derivative Works that
110
+ You distribute, alongside or as an addendum to the NOTICE text from
111
+ the Work, provided that such additional attribution notices cannot be
112
+ construed as modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may
115
+ provide additional or different license terms and conditions for use,
116
+ reproduction, or distribution of Your modifications, or for any such
117
+ Derivative Works as a whole, provided Your use, reproduction, and
118
+ distribution of the Work otherwise complies with the conditions stated
119
+ in this License.
120
+
121
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
122
+ Contribution intentionally submitted for inclusion in the Work by You to
123
+ the Licensor shall be under the terms and conditions of this License,
124
+ without any additional terms or conditions. Notwithstanding the above,
125
+ nothing herein shall supersede or modify the terms of any separate license
126
+ agreement you may have executed with Licensor regarding such Contributions.
127
+
128
+ 6. Trademarks. This License does not grant permission to use the trade names,
129
+ trademarks, service marks, or product names of the Licensor, except as
130
+ required for reasonable and customary use in describing the origin of the
131
+ Work and reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
134
+ writing, Licensor provides the Work (and each Contributor provides its
135
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
136
+ KIND, either express or implied, including, without limitation, any warranties
137
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
138
+ PARTICULAR PURPOSE. You are solely responsible for determining the
139
+ appropriateness of using or redistributing the Work and assume any risks
140
+ associated with Your exercise of permissions under this License.
141
+
142
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
143
+ tort (including negligence), contract, or otherwise, unless required by
144
+ applicable law (such as deliberate and grossly negligent acts) or agreed to
145
+ in writing, shall any Contributor be liable to You for damages, including
146
+ any direct, indirect, special, incidental, or consequential damages of any
147
+ character arising as a result of this License or out of the use or inability
148
+ to use the Work (including but not limited to damages for loss of goodwill,
149
+ work stoppage, computer failure or malfunction, or any and all other
150
+ commercial damages or losses), even if such Contributor has been advised of
151
+ the possibility of such damages.
152
+
153
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work
154
+ or Derivative Works thereof, You may choose to offer, and charge a fee for,
155
+ acceptance of support, warranty, indemnity, or other liability obligations
156
+ and/or rights consistent with this License. However, in accepting such
157
+ obligations, You may act only on Your own behalf and on Your sole
158
+ responsibility, not on behalf of any other Contributor, and only if You
159
+ agree to indemnify, defend, and hold each Contributor harmless for any
160
+ liability incurred by, or claims asserted against, such Contributor by reason
161
+ of your accepting any such warranty or additional liability.
162
+
163
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @crosslink/protocol
2
+
3
+ <p align="center"><img src="https://crosslink.mintlify.site/crosslink.svg" alt="Crosslink" width="320" /></p>
4
+
5
+ Language-neutral Crosslink wire types, framing, versioning, errors, and conformance fixtures.
6
+
7
+ ```bash
8
+ npm install @crosslink/protocol
9
+ ```
10
+
11
+ See the [Crosslink documentation](https://crosslink.mintlify.site) and [repository](https://github.com/jacobpowaza/crosslink).
@@ -0,0 +1,396 @@
1
+ /**
2
+ * Crosslink protocol versioning.
3
+ *
4
+ * Versions are MAJOR.MINOR strings. Implementations MUST negotiate the highest
5
+ * mutually supported version during hello and MUST refuse to operate below
6
+ * MIN_SECURE_VERSION (no silent downgrade).
7
+ */
8
+ declare const PROTOCOL_VERSION = "1.0";
9
+ declare const MIN_SECURE_VERSION = "1.0";
10
+ declare const SUPPORTED_VERSIONS: readonly string[];
11
+ declare function parseVersion(v: unknown): {
12
+ major: number;
13
+ minor: number;
14
+ } | null;
15
+ declare function compareVersions(a: string, b: string): number;
16
+ /** Highest version supported by both lists, or null when incompatible. */
17
+ declare function negotiateVersions(offered: readonly string[], supported: readonly string[]): string | null;
18
+ declare function versionAtLeast(v: string, floor: string): boolean;
19
+
20
+ /**
21
+ * Protocol-level error codes. These travel on the wire and must remain stable;
22
+ * new codes may be appended, existing ones never repurposed.
23
+ */
24
+ declare const ErrorCodes: {
25
+ readonly PARSE_ERROR: "parse_error";
26
+ readonly INVALID_MESSAGE: "invalid_message";
27
+ readonly VERSION_UNSUPPORTED: "version_unsupported";
28
+ readonly UNAUTHORIZED: "unauthorized";
29
+ readonly CAPABILITY_DENIED: "capability_denied";
30
+ readonly METHOD_NOT_FOUND: "method_not_found";
31
+ readonly VALIDATION_FAILED: "validation_failed";
32
+ readonly PAYLOAD_TOO_LARGE: "payload_too_large";
33
+ readonly RATE_LIMITED: "rate_limited";
34
+ readonly DEVICE_REVOKED: "device_revoked";
35
+ readonly SESSION_EXPIRED: "session_expired";
36
+ readonly PAIRING_EXPIRED: "pairing_expired";
37
+ readonly PAIRING_INVALID: "pairing_invalid";
38
+ readonly HOST_OFFLINE: "host_offline";
39
+ readonly TIMEOUT: "timeout";
40
+ readonly CANCELLED: "cancelled";
41
+ readonly INTERNAL: "internal";
42
+ readonly NOT_CONNECTED: "not_connected";
43
+ readonly PEER_LOST: "peer_lost";
44
+ /** the capability is granted but the grant has lapsed and must be renewed */
45
+ readonly GRANT_EXPIRED: "grant_expired";
46
+ /** the host user declined a per-use confirmation prompt */
47
+ readonly CONSENT_DENIED: "consent_denied";
48
+ /** the host could not obtain a per-use confirmation in time */
49
+ readonly CONSENT_TIMEOUT: "consent_timeout";
50
+ /** host permission policy forbids this, independent of what was granted */
51
+ readonly POLICY_DENIED: "policy_denied";
52
+ };
53
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
54
+ declare const ALL_ERROR_CODES: readonly string[];
55
+ interface WireError {
56
+ code: string;
57
+ message: string;
58
+ data?: unknown;
59
+ }
60
+ declare class CrosslinkError extends Error {
61
+ readonly code: ErrorCode | string;
62
+ readonly data?: unknown;
63
+ constructor(code: ErrorCode | string, message: string, data?: unknown);
64
+ toWire(): WireError;
65
+ static from(err: unknown): CrosslinkError;
66
+ /** True for codes that must never leak internal detail across the wire. */
67
+ static isInternal(code: string): boolean;
68
+ }
69
+
70
+ /**
71
+ * Canonical JSON: deterministic serialization used wherever bytes must be
72
+ * stable across implementations — transcript hashing, signatures, fixtures.
73
+ *
74
+ * Rules:
75
+ * - object keys sorted lexicographically (by UTF-16 code unit)
76
+ * - no insignificant whitespace
77
+ * - undefined-valued object keys omitted
78
+ * - non-finite numbers and BigInt rejected (not representable interoperably)
79
+ */
80
+ type Json = null | boolean | number | string | Json[] | {
81
+ [key: string]: Json;
82
+ };
83
+ declare function canonicalJson(value: unknown): string;
84
+
85
+ /**
86
+ * Base64 / base64url / hex byte helpers, isomorphic across Node and browsers.
87
+ * Binary payloads inside JSON messages use the BinaryRef shape.
88
+ */
89
+ interface BinaryRef {
90
+ /** discriminator marking this object as a binary payload */
91
+ $b: true;
92
+ /** optional MIME type */
93
+ c?: string;
94
+ /** standard base64 payload */
95
+ d: string;
96
+ }
97
+ declare function bytesToBase64(bytes: Uint8Array): string;
98
+ declare function base64ToBytes(b64: string): Uint8Array;
99
+ declare function bytesToBase64Url(bytes: Uint8Array): string;
100
+ declare function base64UrlToBytes(s: string): Uint8Array;
101
+ declare function bytesToHex(bytes: Uint8Array): string;
102
+ declare function hexToBytes(hex: string): Uint8Array;
103
+ declare const utf8ToBytes: (s: string) => Uint8Array;
104
+ declare const bytesToUtf8: (b: Uint8Array) => string;
105
+ declare function encodeBinary(bytes: Uint8Array, mime?: string): BinaryRef;
106
+ declare function decodeBinary(ref: unknown): Uint8Array;
107
+ declare function isBinaryRef(value: unknown): value is BinaryRef;
108
+
109
+ declare const PROTOCOL = "crosslink";
110
+ /** All message types. */
111
+ declare const MessageTypes: {
112
+ readonly HELLO: "hello";
113
+ readonly HELLO_OK: "hello_ok";
114
+ readonly REQ: "req";
115
+ readonly RES: "res";
116
+ readonly ERR: "err";
117
+ readonly CHUNK: "chunk";
118
+ readonly END: "end";
119
+ readonly EVT: "evt";
120
+ readonly SUB: "sub";
121
+ readonly UNSUB: "unsub";
122
+ readonly CANCEL: "cancel";
123
+ readonly PING: "ping";
124
+ readonly PONG: "pong";
125
+ readonly BYE: "bye";
126
+ };
127
+ type MessageType = (typeof MessageTypes)[keyof typeof MessageTypes];
128
+ interface HelloMsg {
129
+ v: string;
130
+ t: "hello";
131
+ /** versions the sender supports, highest last */
132
+ versions: string[];
133
+ deviceId: string;
134
+ appId: string;
135
+ features?: string[];
136
+ }
137
+ interface HelloOkMsg {
138
+ v: string;
139
+ t: "hello_ok";
140
+ version: string;
141
+ features?: string[];
142
+ }
143
+ interface RequestMsg {
144
+ v: string;
145
+ t: "req";
146
+ i: string;
147
+ m: string;
148
+ p?: Json;
149
+ /** true when safe to auto-retry/queue across reconnects */
150
+ idem?: true;
151
+ ts?: number;
152
+ }
153
+ interface ResponseMsg {
154
+ v: string;
155
+ t: "res";
156
+ i: string;
157
+ p?: Json;
158
+ }
159
+ interface ErrorMessage {
160
+ v: string;
161
+ t: "err";
162
+ i: string;
163
+ e: {
164
+ code: string;
165
+ message: string;
166
+ data?: unknown;
167
+ };
168
+ }
169
+ interface ChunkMsg {
170
+ v: string;
171
+ t: "chunk";
172
+ i: string;
173
+ n: number;
174
+ d: Json;
175
+ }
176
+ interface EndMsg {
177
+ v: string;
178
+ t: "end";
179
+ i: string;
180
+ p?: Json;
181
+ }
182
+ interface EventMsg {
183
+ v: string;
184
+ t: "evt";
185
+ s: string;
186
+ e: string;
187
+ p?: Json;
188
+ }
189
+ interface SubMsg {
190
+ v: string;
191
+ t: "sub";
192
+ s: string;
193
+ e: string;
194
+ }
195
+ interface UnsubMsg {
196
+ v: string;
197
+ t: "unsub";
198
+ s: string;
199
+ }
200
+ interface CancelMsg {
201
+ v: string;
202
+ t: "cancel";
203
+ i: string;
204
+ }
205
+ interface PingMsg {
206
+ v: string;
207
+ t: "ping";
208
+ ts: number;
209
+ }
210
+ interface PongMsg {
211
+ v: string;
212
+ t: "pong";
213
+ ts: number;
214
+ }
215
+ interface ByeMsg {
216
+ v: string;
217
+ t: "bye";
218
+ code?: string;
219
+ reason?: string;
220
+ }
221
+ type CrosslinkMessage = HelloMsg | HelloOkMsg | RequestMsg | ResponseMsg | ErrorMessage | ChunkMsg | EndMsg | EventMsg | SubMsg | UnsubMsg | CancelMsg | PingMsg | PongMsg | ByeMsg;
222
+ declare function makeRequestId(rand: (n: number) => Uint8Array): string;
223
+ /**
224
+ * Structural validation of a decoded message. Returns null when valid,
225
+ * otherwise a machine-readable problem description.
226
+ *
227
+ * Deliberately cheap and allocation-light — it runs on every inbound frame.
228
+ * Deep payload validation belongs to schema validators at the RPC layer.
229
+ */
230
+ declare function validateMessage(msg: unknown): string | null;
231
+ declare function isMessageType(value: unknown): value is MessageType;
232
+ /** Error codes that indicate the session itself is broken (no point retrying). */
233
+ declare function isFatalErrorCode(code: string): boolean;
234
+
235
+ declare function encodeMessage(msg: object): Uint8Array;
236
+ declare function decodeMessage(data: Uint8Array | string): unknown;
237
+ declare function encodeFrame(msg: object, maxFrameBytes?: number): Uint8Array;
238
+ declare class FrameDecoder {
239
+ private readonly maxFrameBytes;
240
+ private buf;
241
+ constructor(maxFrameBytes?: number);
242
+ /** Feed raw bytes; returns every complete message that became available. */
243
+ push(chunk: Uint8Array): Json[];
244
+ }
245
+
246
+ /**
247
+ * Wire limits. Every implementation MUST enforce these by default;
248
+ * operators may tighten but not loosen beyond documented maxima.
249
+ */
250
+ declare const Limits: {
251
+ readonly DEFAULT_MAX_FRAME_BYTES: number;
252
+ readonly MAX_FRAME_BYTES_HARD: number;
253
+ readonly DEFAULT_CHUNK_BYTES: number;
254
+ readonly DEFAULT_REQUEST_TIMEOUT_MS: 30000;
255
+ readonly DEFAULT_MAX_INFLIGHT: 32;
256
+ readonly DEFAULT_RATE_PER_SEC: 50;
257
+ readonly PAIRING_CODE_TTL_MS: 120000;
258
+ readonly HEARTBEAT_INTERVAL_MS: 15000;
259
+ readonly HEARTBEAT_TIMEOUT_MS: 45000;
260
+ readonly CLOCK_SKEW_MS: 120000;
261
+ };
262
+
263
+ /**
264
+ * Outer wire shapes: the plaintext control vocabulary exchanged *before* an
265
+ * encrypted session exists (handshake, pairing) plus the encrypted-frame
266
+ * envelope itself, and the signaling/relay service protocols.
267
+ *
268
+ * All base64 fields are standard base64 unless suffixed `b64u` (base64url).
269
+ * See docs/reference/protocol.mdx for byte-level details.
270
+ */
271
+ type OuterFrame = SessionInitFrame | SessionAcceptFrame | SessionRejectFrame | EncryptedFrame | OuterPingFrame | OuterPongFrame | ByeFrame;
272
+ interface SessionInitFrame {
273
+ kind: "sinit";
274
+ v: string;
275
+ /** target application id — binds handshake to one app */
276
+ app: string;
277
+ /** client device id */
278
+ dev: string;
279
+ /** client static X25519 public key (base64) */
280
+ sx: string;
281
+ /** client ephemeral X25519 public key (base64) */
282
+ epk: string;
283
+ /** client nonce (base64, 32 bytes) */
284
+ nc: string;
285
+ ts: number;
286
+ sig: string;
287
+ /** Optional ephemeral ML-KEM encapsulation key, transcript-bound by sig. */
288
+ pq?: {
289
+ suite: "ML-KEM-768";
290
+ ek: string;
291
+ };
292
+ }
293
+ interface SessionAcceptFrame {
294
+ kind: "sack";
295
+ v: string;
296
+ epk: string;
297
+ nh: string;
298
+ sig: string;
299
+ /** Ciphertext for the client's ephemeral ML-KEM key. */
300
+ pq?: {
301
+ suite: "ML-KEM-768";
302
+ ct: string;
303
+ };
304
+ }
305
+ interface SessionRejectFrame {
306
+ kind: "srej";
307
+ code: string;
308
+ message: string;
309
+ }
310
+ interface EncryptedFrame {
311
+ kind: "enc";
312
+ /** monotonic per-direction counter starting at 1; strictly increasing */
313
+ n: number;
314
+ /** random 24-byte XChaCha nonce (base64) */
315
+ iv: string;
316
+ /** ciphertext+tag (base64) */
317
+ ct: string;
318
+ }
319
+ interface OuterPingFrame {
320
+ kind: "oping";
321
+ ts: number;
322
+ }
323
+ interface OuterPongFrame {
324
+ kind: "opong";
325
+ ts: number;
326
+ }
327
+ interface ByeFrame {
328
+ kind: "bye";
329
+ code?: string;
330
+ reason?: string;
331
+ }
332
+ declare function isOuterKind(value: unknown): value is OuterFrame["kind"];
333
+ declare const OUTER_KINDS: typeof isOuterKind;
334
+ interface PairClaimFrame {
335
+ ps: string;
336
+ dev: string;
337
+ name: string;
338
+ pub_ed: string;
339
+ pub_x: string;
340
+ nonce: string;
341
+ caps_req?: string[];
342
+ sig: string;
343
+ }
344
+ interface PairChallengeFrame {
345
+ ps: string;
346
+ claim_nonce: string;
347
+ host_pub_ed: string;
348
+ host_pub_x: string;
349
+ nonce: string;
350
+ granted_caps: string[];
351
+ link?: true;
352
+ sig: string;
353
+ }
354
+ interface PairCompleteFrame {
355
+ ps: string;
356
+ claim_nonce: string;
357
+ challenge_nonce: string;
358
+ sig: string;
359
+ }
360
+ interface PairDoneFrame {
361
+ ps: string;
362
+ relay?: {
363
+ url: string;
364
+ channel: string;
365
+ };
366
+ lan?: {
367
+ host: string;
368
+ port: number;
369
+ };
370
+ }
371
+ interface PairErrorFrame {
372
+ error: {
373
+ code: string;
374
+ message: string;
375
+ };
376
+ }
377
+
378
+ /** Stable fixture corpus for cross-language conformance testing.
379
+ *
380
+ * The committed JSON file is generated by scripts/generate-fixtures.mjs and
381
+ * MUST NOT be edited by hand. Independent implementations assert their
382
+ * encoder/decoder against it.
383
+ */
384
+ declare const FIXTURES_VERSION = 1;
385
+ interface FixtureCase {
386
+ name: string;
387
+ obj: unknown;
388
+ canonical: string;
389
+ frame_hex: string;
390
+ }
391
+ declare function sampleMessages(): Array<{
392
+ name: string;
393
+ obj: Record<string, unknown>;
394
+ }>;
395
+
396
+ export { ALL_ERROR_CODES, type BinaryRef, type ByeFrame, type ByeMsg, type CancelMsg, type ChunkMsg, CrosslinkError, type CrosslinkMessage, type EncryptedFrame, type EndMsg, type ErrorCode, ErrorCodes, type ErrorMessage, type EventMsg, FIXTURES_VERSION, type FixtureCase, FrameDecoder, type HelloMsg, type HelloOkMsg, type Json, Limits, MIN_SECURE_VERSION, type MessageType, MessageTypes, OUTER_KINDS, type OuterFrame, type OuterPingFrame, type OuterPongFrame, PROTOCOL, PROTOCOL_VERSION, type PairChallengeFrame, type PairClaimFrame, type PairCompleteFrame, type PairDoneFrame, type PairErrorFrame, type PingMsg, type PongMsg, type RequestMsg, type ResponseMsg, SUPPORTED_VERSIONS, type SessionAcceptFrame, type SessionInitFrame, type SessionRejectFrame, type SubMsg, type UnsubMsg, type WireError, base64ToBytes, base64UrlToBytes, bytesToBase64, bytesToBase64Url, bytesToHex, bytesToUtf8, canonicalJson, compareVersions, decodeBinary, decodeMessage, encodeBinary, encodeFrame, encodeMessage, hexToBytes, isBinaryRef, isFatalErrorCode, isMessageType, isOuterKind, makeRequestId, negotiateVersions, parseVersion, sampleMessages, utf8ToBytes, validateMessage, versionAtLeast };
package/dist/index.js ADDED
@@ -0,0 +1,477 @@
1
+ // src/version.ts
2
+ var PROTOCOL_VERSION = "1.0";
3
+ var MIN_SECURE_VERSION = "1.0";
4
+ var SUPPORTED_VERSIONS = [PROTOCOL_VERSION];
5
+ var VERSION_RE = /^(\d+)\.(\d+)$/;
6
+ function parseVersion(v) {
7
+ if (typeof v !== "string") return null;
8
+ const m = VERSION_RE.exec(v);
9
+ if (!m) return null;
10
+ return { major: Number(m[1]), minor: Number(m[2]) };
11
+ }
12
+ function compareVersions(a, b) {
13
+ const pa = parseVersion(a);
14
+ const pb = parseVersion(b);
15
+ if (!pa || !pb) throw new TypeError(`invalid version: ${JSON.stringify([a, b])}`);
16
+ return pa.major !== pb.major ? pa.major - pb.major : pa.minor - pb.minor;
17
+ }
18
+ function negotiateVersions(offered, supported) {
19
+ const mutual = [...offered].filter((v) => supported.includes(v)).sort(compareVersions);
20
+ return mutual.length ? mutual[mutual.length - 1] : null;
21
+ }
22
+ function versionAtLeast(v, floor) {
23
+ return compareVersions(v, floor) >= 0;
24
+ }
25
+
26
+ // src/errors.ts
27
+ var ErrorCodes = {
28
+ PARSE_ERROR: "parse_error",
29
+ INVALID_MESSAGE: "invalid_message",
30
+ VERSION_UNSUPPORTED: "version_unsupported",
31
+ UNAUTHORIZED: "unauthorized",
32
+ CAPABILITY_DENIED: "capability_denied",
33
+ METHOD_NOT_FOUND: "method_not_found",
34
+ VALIDATION_FAILED: "validation_failed",
35
+ PAYLOAD_TOO_LARGE: "payload_too_large",
36
+ RATE_LIMITED: "rate_limited",
37
+ DEVICE_REVOKED: "device_revoked",
38
+ SESSION_EXPIRED: "session_expired",
39
+ PAIRING_EXPIRED: "pairing_expired",
40
+ PAIRING_INVALID: "pairing_invalid",
41
+ HOST_OFFLINE: "host_offline",
42
+ TIMEOUT: "timeout",
43
+ CANCELLED: "cancelled",
44
+ INTERNAL: "internal",
45
+ NOT_CONNECTED: "not_connected",
46
+ PEER_LOST: "peer_lost",
47
+ /** the capability is granted but the grant has lapsed and must be renewed */
48
+ GRANT_EXPIRED: "grant_expired",
49
+ /** the host user declined a per-use confirmation prompt */
50
+ CONSENT_DENIED: "consent_denied",
51
+ /** the host could not obtain a per-use confirmation in time */
52
+ CONSENT_TIMEOUT: "consent_timeout",
53
+ /** host permission policy forbids this, independent of what was granted */
54
+ POLICY_DENIED: "policy_denied"
55
+ };
56
+ var ALL_ERROR_CODES = Object.values(ErrorCodes);
57
+ var CrosslinkError = class _CrosslinkError extends Error {
58
+ code;
59
+ data;
60
+ constructor(code, message, data) {
61
+ super(message);
62
+ this.name = "CrosslinkError";
63
+ this.code = code;
64
+ this.data = data;
65
+ }
66
+ toWire() {
67
+ return { code: this.code, message: this.message, data: this.data };
68
+ }
69
+ static from(err) {
70
+ if (err instanceof _CrosslinkError) return err;
71
+ const message = err instanceof Error ? err.message : String(err);
72
+ return new _CrosslinkError(ErrorCodes.INTERNAL, message);
73
+ }
74
+ /** True for codes that must never leak internal detail across the wire. */
75
+ static isInternal(code) {
76
+ return code === ErrorCodes.INTERNAL || code === ErrorCodes.PARSE_ERROR || code === ErrorCodes.INVALID_MESSAGE;
77
+ }
78
+ };
79
+
80
+ // src/json.ts
81
+ function canonicalJson(value) {
82
+ return serialize(value);
83
+ }
84
+ function serialize(value) {
85
+ if (value === null) return "null";
86
+ const t = typeof value;
87
+ if (t === "boolean") return value ? "true" : "false";
88
+ if (t === "number") {
89
+ if (!Number.isFinite(value)) {
90
+ throw new TypeError("canonicalJson: non-finite number");
91
+ }
92
+ return String(value);
93
+ }
94
+ if (t === "bigint") {
95
+ throw new TypeError("canonicalJson: bigint not allowed");
96
+ }
97
+ if (t === "string") return JSON.stringify(value);
98
+ if (Array.isArray(value)) {
99
+ let out = "[";
100
+ for (let i = 0; i < value.length; i++) {
101
+ if (i > 0) out += ",";
102
+ out += serialize(value[i]);
103
+ }
104
+ return out + "]";
105
+ }
106
+ if (t === "object") {
107
+ const obj = value;
108
+ const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
109
+ let out = "{";
110
+ for (let i = 0; i < keys.length; i++) {
111
+ if (i > 0) out += ",";
112
+ out += `${JSON.stringify(keys[i])}:${serialize(obj[keys[i]])}`;
113
+ }
114
+ return out + "}";
115
+ }
116
+ throw new TypeError(`canonicalJson: unsupported type ${t}`);
117
+ }
118
+
119
+ // src/encoding.ts
120
+ var HAS_BUFFER = typeof Buffer !== "undefined";
121
+ function bytesToBase64(bytes) {
122
+ if (HAS_BUFFER) return Buffer.from(bytes).toString("base64");
123
+ let bin = "";
124
+ for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
125
+ return btoa(bin);
126
+ }
127
+ function base64ToBytes(b64) {
128
+ if (HAS_BUFFER) {
129
+ const buf = Buffer.from(b64, "base64");
130
+ return new Uint8Array(buf);
131
+ }
132
+ const bin = atob(b64);
133
+ const out = new Uint8Array(bin.length);
134
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
135
+ return out;
136
+ }
137
+ function bytesToBase64Url(bytes) {
138
+ return bytesToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
139
+ }
140
+ function base64UrlToBytes(s) {
141
+ let b64 = s.replace(/-/g, "+").replace(/_/g, "/");
142
+ while (b64.length % 4 !== 0) b64 += "=";
143
+ return base64ToBytes(b64);
144
+ }
145
+ var HEX = "0123456789abcdef";
146
+ function bytesToHex(bytes) {
147
+ let out = "";
148
+ for (let i = 0; i < bytes.length; i++) {
149
+ out += HEX[bytes[i] >> 4] + HEX[bytes[i] & 15];
150
+ }
151
+ return out;
152
+ }
153
+ function hexToBytes(hex) {
154
+ if (hex.length % 2 !== 0 || /[^0-9a-f]/i.test(hex)) {
155
+ throw new TypeError("invalid hex string");
156
+ }
157
+ const out = new Uint8Array(hex.length / 2);
158
+ for (let i = 0; i < out.length; i++) {
159
+ out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
160
+ }
161
+ return out;
162
+ }
163
+ var te = new TextEncoder();
164
+ var td = new TextDecoder();
165
+ var utf8ToBytes = (s) => te.encode(s);
166
+ var bytesToUtf8 = (b) => td.decode(b);
167
+ function encodeBinary(bytes, mime) {
168
+ const ref = { $b: true, d: bytesToBase64(bytes) };
169
+ if (mime !== void 0) ref.c = mime;
170
+ return ref;
171
+ }
172
+ function decodeBinary(ref) {
173
+ if (!isBinaryRef(ref)) throw new TypeError("not a BinaryRef");
174
+ return base64ToBytes(ref.d);
175
+ }
176
+ function isBinaryRef(value) {
177
+ return typeof value === "object" && value !== null && value.$b === true && typeof value.d === "string";
178
+ }
179
+
180
+ // src/messages.ts
181
+ var PROTOCOL = "crosslink";
182
+ var MessageTypes = {
183
+ HELLO: "hello",
184
+ HELLO_OK: "hello_ok",
185
+ REQ: "req",
186
+ RES: "res",
187
+ ERR: "err",
188
+ CHUNK: "chunk",
189
+ END: "end",
190
+ EVT: "evt",
191
+ SUB: "sub",
192
+ UNSUB: "unsub",
193
+ CANCEL: "cancel",
194
+ PING: "ping",
195
+ PONG: "pong",
196
+ BYE: "bye"
197
+ };
198
+ var REQUEST_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
199
+ var METHOD_RE = /^[A-Za-z0-9][A-Za-z0-9_.:@/-]{0,127}$/;
200
+ var EVENT_RE = /^[A-Za-z0-9][A-Za-z0-9_.:@/-]{0,127}$/;
201
+ var DEVICE_ID_RE = /^cd1_[0-9a-f]{32}$/;
202
+ var VERSION_RE2 = /^\d+\.\d+$/;
203
+ function makeRequestId(rand) {
204
+ return toUrlSafeBase64ish(rand(12));
205
+ }
206
+ function toUrlSafeBase64ish(bytes) {
207
+ let out = "";
208
+ for (let i = 0; i < bytes.length; i++) out += String.fromCharCode(bytes[i]);
209
+ const b64 = globalThis.btoa !== void 0 ? btoa(out) : BufferFrom(out);
210
+ return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
211
+ }
212
+ function BufferFrom(s) {
213
+ return Buffer.from(s).toString("base64");
214
+ }
215
+ function validateMessage(msg) {
216
+ if (typeof msg !== "object" || msg === null) return "not-an-object";
217
+ const m = msg;
218
+ if (typeof m.v !== "string" || !VERSION_RE2.test(m.v)) return "bad-version";
219
+ if (!isMessageType(m.t)) return "bad-type";
220
+ switch (m.t) {
221
+ case MessageTypes.HELLO: {
222
+ if (!Array.isArray(m.versions) || m.versions.length === 0) return "hello-versions";
223
+ if (!m.versions.every((x) => typeof x === "string" && VERSION_RE2.test(x))) {
224
+ return "hello-version-format";
225
+ }
226
+ if (typeof m.deviceId !== "string" || !DEVICE_ID_RE.test(m.deviceId)) return "hello-device-id";
227
+ if (typeof m.appId !== "string" || m.appId.length === 0 || m.appId.length > 256) {
228
+ return "hello-app-id";
229
+ }
230
+ break;
231
+ }
232
+ case MessageTypes.HELLO_OK:
233
+ if (typeof m.version !== "string" || !VERSION_RE2.test(m.version)) return "hello-ok-version";
234
+ break;
235
+ case MessageTypes.REQ:
236
+ if (typeof m.i !== "string" || !REQUEST_ID_RE.test(m.i)) return "req-id";
237
+ if (typeof m.m !== "string" || !METHOD_RE.test(m.m)) return "req-method";
238
+ if (m.idem !== void 0 && m.idem !== true) return "req-idem-flag";
239
+ break;
240
+ case MessageTypes.RES:
241
+ case MessageTypes.END:
242
+ case MessageTypes.CANCEL:
243
+ if (typeof m.i !== "string" || !REQUEST_ID_RE.test(m.i)) return `${m.t}-id`;
244
+ break;
245
+ case MessageTypes.ERR:
246
+ if (typeof m.i !== "string" || !REQUEST_ID_RE.test(m.i)) return "err-id";
247
+ if (typeof m.e !== "object" || m.e === null || typeof m.e.code !== "string" || !ALL_ERROR_CODES.includes(m.e.code) || typeof m.e.message !== "string") {
248
+ return "err-body";
249
+ }
250
+ break;
251
+ case MessageTypes.CHUNK:
252
+ if (typeof m.i !== "string" || !REQUEST_ID_RE.test(m.i)) return "chunk-id";
253
+ if (typeof m.n !== "number" || !Number.isInteger(m.n) || m.n < 0) return "chunk-n";
254
+ if (m.d === void 0) return "chunk-data-missing";
255
+ break;
256
+ case MessageTypes.EVT:
257
+ if (typeof m.s !== "string" || !REQUEST_ID_RE.test(m.s)) return "evt-sub";
258
+ if (typeof m.e !== "string" || !EVENT_RE.test(m.e)) return "evt-name";
259
+ break;
260
+ case MessageTypes.SUB:
261
+ case MessageTypes.UNSUB:
262
+ if (typeof m.s !== "string" || !REQUEST_ID_RE.test(m.s)) return `${m.t}-sub`;
263
+ if (m.t === MessageTypes.SUB && (typeof m.e !== "string" || !EVENT_RE.test(m.e))) {
264
+ return "sub-event";
265
+ }
266
+ break;
267
+ case MessageTypes.PING:
268
+ case MessageTypes.PONG:
269
+ if (typeof m.ts !== "number" || !Number.isFinite(m.ts)) return "ts";
270
+ break;
271
+ case MessageTypes.BYE:
272
+ break;
273
+ }
274
+ return null;
275
+ }
276
+ function isMessageType(value) {
277
+ return typeof value === "string" && Object.values(MessageTypes).includes(value);
278
+ }
279
+ function isFatalErrorCode(code) {
280
+ return code === ErrorCodes.DEVICE_REVOKED || code === ErrorCodes.SESSION_EXPIRED || code === ErrorCodes.VERSION_UNSUPPORTED || code === ErrorCodes.UNAUTHORIZED;
281
+ }
282
+
283
+ // src/limits.ts
284
+ var Limits = {
285
+ DEFAULT_MAX_FRAME_BYTES: 4 * 1024 * 1024,
286
+ MAX_FRAME_BYTES_HARD: 16 * 1024 * 1024,
287
+ DEFAULT_CHUNK_BYTES: 256 * 1024,
288
+ DEFAULT_REQUEST_TIMEOUT_MS: 3e4,
289
+ DEFAULT_MAX_INFLIGHT: 32,
290
+ DEFAULT_RATE_PER_SEC: 50,
291
+ PAIRING_CODE_TTL_MS: 12e4,
292
+ HEARTBEAT_INTERVAL_MS: 15e3,
293
+ HEARTBEAT_TIMEOUT_MS: 45e3,
294
+ CLOCK_SKEW_MS: 12e4
295
+ };
296
+
297
+ // src/framing.ts
298
+ function encodeMessage(msg) {
299
+ return utf8ToBytes(canonicalJson(msg));
300
+ }
301
+ function decodeMessage(data) {
302
+ let text;
303
+ try {
304
+ text = typeof data === "string" ? data : bytesToUtf8(data);
305
+ } catch {
306
+ throw new CrosslinkError(ErrorCodes.PARSE_ERROR, "payload is not valid UTF-8");
307
+ }
308
+ let parsed;
309
+ try {
310
+ parsed = JSON.parse(text);
311
+ } catch {
312
+ throw new CrosslinkError(ErrorCodes.PARSE_ERROR, "payload is not valid JSON");
313
+ }
314
+ rejectProto(parsed, 0);
315
+ if (parsed !== null && typeof parsed === "object" && typeof parsed.v === "string" && !SUPPORTED_VERSIONS.includes(parsed.v)) {
316
+ throw new CrosslinkError(ErrorCodes.VERSION_UNSUPPORTED, "protocol version is not supported");
317
+ }
318
+ const problem = validateMessage(parsed);
319
+ if (problem) {
320
+ throw new CrosslinkError(ErrorCodes.INVALID_MESSAGE, `invalid message: ${problem}`);
321
+ }
322
+ return parsed;
323
+ }
324
+ function rejectProto(value, depth) {
325
+ if (depth > 64) {
326
+ throw new CrosslinkError(ErrorCodes.INVALID_MESSAGE, "payload nesting exceeds 64");
327
+ }
328
+ if (Array.isArray(value)) {
329
+ for (const item of value) rejectProto(item, depth + 1);
330
+ } else if (value !== null && typeof value === "object") {
331
+ for (const item of Object.values(value)) rejectProto(item, depth + 1);
332
+ }
333
+ }
334
+ function encodeFrame(msg, maxFrameBytes = Limits.DEFAULT_MAX_FRAME_BYTES) {
335
+ const payload = encodeMessage(msg);
336
+ if (payload.length > maxFrameBytes) {
337
+ throw new CrosslinkError(
338
+ ErrorCodes.PAYLOAD_TOO_LARGE,
339
+ `frame ${payload.length}B exceeds limit ${maxFrameBytes}B`
340
+ );
341
+ }
342
+ const out = new Uint8Array(4 + payload.length);
343
+ const view = new DataView(out.buffer);
344
+ view.setUint32(0, payload.length, false);
345
+ out.set(payload, 4);
346
+ return out;
347
+ }
348
+ var FrameDecoder = class {
349
+ constructor(maxFrameBytes = Limits.DEFAULT_MAX_FRAME_BYTES) {
350
+ this.maxFrameBytes = maxFrameBytes;
351
+ }
352
+ maxFrameBytes;
353
+ buf = new Uint8Array(0);
354
+ /** Feed raw bytes; returns every complete message that became available. */
355
+ push(chunk) {
356
+ const merged = new Uint8Array(this.buf.length + chunk.length);
357
+ merged.set(this.buf);
358
+ merged.set(chunk, this.buf.length);
359
+ this.buf = merged;
360
+ const out = [];
361
+ for (; ; ) {
362
+ if (this.buf.length < 4) break;
363
+ const view = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.byteLength);
364
+ const len = view.getUint32(0, false);
365
+ if (len > this.maxFrameBytes) {
366
+ throw new CrosslinkError(
367
+ ErrorCodes.PAYLOAD_TOO_LARGE,
368
+ `declared frame ${len}B exceeds limit ${this.maxFrameBytes}B`
369
+ );
370
+ }
371
+ if (this.buf.length < 4 + len) break;
372
+ const payload = this.buf.subarray(4, 4 + len);
373
+ out.push(decodeMessage(payload));
374
+ this.buf = this.buf.slice(4 + len);
375
+ }
376
+ return out;
377
+ }
378
+ };
379
+
380
+ // src/wire.ts
381
+ function isOuterKind(value) {
382
+ return value === "sinit" || value === "sack" || value === "srej" || value === "enc" || value === "oping" || value === "opong" || value === "bye";
383
+ }
384
+ var OUTER_KINDS = isOuterKind;
385
+
386
+ // src/fixtures.ts
387
+ var FIXTURES_VERSION = 1;
388
+ function sampleMessages() {
389
+ return [
390
+ {
391
+ name: "request",
392
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.REQ, i: "AAAAAAAAAAAAAAAA", m: "echo", p: { hello: "world", n: 42 } }
393
+ },
394
+ {
395
+ name: "response",
396
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.RES, i: "AAAAAAAAAAAAAAAA", p: { echoed: true } }
397
+ },
398
+ {
399
+ name: "error",
400
+ obj: {
401
+ v: PROTOCOL_VERSION,
402
+ t: MessageTypes.ERR,
403
+ i: "AAAAAAAAAAAAAAAA",
404
+ e: { code: ALL_ERROR_CODES[0], message: "boom" }
405
+ }
406
+ },
407
+ {
408
+ name: "chunk-binary",
409
+ obj: {
410
+ v: PROTOCOL_VERSION,
411
+ t: MessageTypes.CHUNK,
412
+ i: "AAAAAAAAAAAAAAAA",
413
+ n: 0,
414
+ d: { $b: true, c: "application/octet-stream", d: "AQIDBA==" }
415
+ }
416
+ },
417
+ {
418
+ name: "end",
419
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.END, i: "AAAAAAAAAAAAAAAA", p: { total: 3 } }
420
+ },
421
+ {
422
+ name: "event",
423
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.EVT, s: "BBBBBBBBBBBB", e: "tasks.status", p: { pct: 50 } }
424
+ },
425
+ {
426
+ name: "subscribe",
427
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.SUB, s: "BBBBBBBBBBBB", e: "tasks.status" }
428
+ },
429
+ {
430
+ name: "cancel",
431
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.CANCEL, i: "AAAAAAAAAAAAAAAA" }
432
+ },
433
+ {
434
+ name: "ping",
435
+ obj: { v: PROTOCOL_VERSION, t: MessageTypes.PING, ts: 17e11 }
436
+ }
437
+ ];
438
+ }
439
+ export {
440
+ ALL_ERROR_CODES,
441
+ CrosslinkError,
442
+ ErrorCodes,
443
+ FIXTURES_VERSION,
444
+ FrameDecoder,
445
+ Limits,
446
+ MIN_SECURE_VERSION,
447
+ MessageTypes,
448
+ OUTER_KINDS,
449
+ PROTOCOL,
450
+ PROTOCOL_VERSION,
451
+ SUPPORTED_VERSIONS,
452
+ base64ToBytes,
453
+ base64UrlToBytes,
454
+ bytesToBase64,
455
+ bytesToBase64Url,
456
+ bytesToHex,
457
+ bytesToUtf8,
458
+ canonicalJson,
459
+ compareVersions,
460
+ decodeBinary,
461
+ decodeMessage,
462
+ encodeBinary,
463
+ encodeFrame,
464
+ encodeMessage,
465
+ hexToBytes,
466
+ isBinaryRef,
467
+ isFatalErrorCode,
468
+ isMessageType,
469
+ isOuterKind,
470
+ makeRequestId,
471
+ negotiateVersions,
472
+ parseVersion,
473
+ sampleMessages,
474
+ utf8ToBytes,
475
+ validateMessage,
476
+ versionAtLeast
477
+ };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@crosslink/protocol",
3
+ "version": "0.1.0",
4
+ "description": "Crosslink language-neutral wire protocol: envelopes, framing, versioning, errors, fixtures",
5
+ "license": "Apache-2.0",
6
+ "repository": { "type": "git", "url": "git+https://github.com/jacobpowaza/crosslink.git", "directory": "packages/protocol" },
7
+ "homepage": "https://crosslink.mintlify.site",
8
+ "bugs": { "url": "https://github.com/jacobpowaza/crosslink/issues" },
9
+ "publishConfig": { "access": "public" },
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": ["dist"],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format esm --dts --clean",
20
+ "typecheck": "tsc --noEmit",
21
+ "gen:fixtures": "npm run build && node scripts/generate-fixtures.mjs"
22
+ },
23
+ "devDependencies": {
24
+ "tsup": "^8.3.6",
25
+ "typescript": "^5.6.3"
26
+ }
27
+ }