wire-mesh-core 0.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +32 -0
  2. package/dist/adapters/frame-codec.cjs +37 -0
  3. package/dist/adapters/frame-codec.d.cts +12 -0
  4. package/dist/adapters/frame-codec.d.mts +12 -0
  5. package/dist/adapters/frame-codec.mjs +33 -0
  6. package/dist/adapters/memory-storage.cjs +14 -0
  7. package/dist/adapters/memory-storage.d.cts +5 -0
  8. package/dist/adapters/memory-storage.d.mts +5 -0
  9. package/dist/adapters/memory-storage.mjs +13 -0
  10. package/dist/adapters/node-identity.cjs +55 -0
  11. package/dist/adapters/node-identity.d.cts +11 -0
  12. package/dist/adapters/node-identity.d.mts +11 -0
  13. package/dist/adapters/node-identity.mjs +52 -0
  14. package/dist/adapters/system-clock.cjs +8 -0
  15. package/dist/adapters/system-clock.d.cts +5 -0
  16. package/dist/adapters/system-clock.d.mts +5 -0
  17. package/dist/adapters/system-clock.mjs +7 -0
  18. package/dist/adapters/tcp-transport.cjs +154 -0
  19. package/dist/adapters/tcp-transport.d.cts +5 -0
  20. package/dist/adapters/tcp-transport.d.mts +5 -0
  21. package/dist/adapters/tcp-transport.mjs +153 -0
  22. package/dist/adapters/tls-transport.cjs +178 -0
  23. package/dist/adapters/tls-transport.d.cts +9 -0
  24. package/dist/adapters/tls-transport.d.mts +9 -0
  25. package/dist/adapters/tls-transport.mjs +177 -0
  26. package/dist/clock-DiSx-WKM.d.cts +7 -0
  27. package/dist/clock-DiSx-WKM.d.mts +7 -0
  28. package/dist/domain/device-id.cjs +27 -0
  29. package/dist/domain/device-id.d.cts +9 -0
  30. package/dist/domain/device-id.d.mts +9 -0
  31. package/dist/domain/device-id.mjs +24 -0
  32. package/dist/domain/handshake.cjs +23 -0
  33. package/dist/domain/handshake.d.cts +16 -0
  34. package/dist/domain/handshake.d.mts +16 -0
  35. package/dist/domain/handshake.mjs +21 -0
  36. package/dist/domain/mesh-session.cjs +439 -0
  37. package/dist/domain/mesh-session.d.cts +101 -0
  38. package/dist/domain/mesh-session.d.mts +101 -0
  39. package/dist/domain/mesh-session.mjs +436 -0
  40. package/dist/domain/relay-hub.cjs +99 -0
  41. package/dist/domain/relay-hub.d.cts +10 -0
  42. package/dist/domain/relay-hub.d.mts +10 -0
  43. package/dist/domain/relay-hub.mjs +98 -0
  44. package/dist/domain/revocation-view.cjs +22 -0
  45. package/dist/domain/revocation-view.d.cts +12 -0
  46. package/dist/domain/revocation-view.d.mts +12 -0
  47. package/dist/domain/revocation-view.mjs +21 -0
  48. package/dist/domain/tokens.cjs +300 -0
  49. package/dist/domain/tokens.d.cts +86 -0
  50. package/dist/domain/tokens.d.mts +86 -0
  51. package/dist/domain/tokens.mjs +296 -0
  52. package/dist/generated/protocol.cjs +466 -0
  53. package/dist/generated/protocol.d.cts +2 -0
  54. package/dist/generated/protocol.d.mts +2 -0
  55. package/dist/generated/protocol.mjs +382 -0
  56. package/dist/generated/runtime.cjs +8 -0
  57. package/dist/generated/runtime.d.cts +2 -0
  58. package/dist/generated/runtime.d.mts +2 -0
  59. package/dist/generated/runtime.mjs +2 -0
  60. package/dist/identity-BRLEUfVY.d.cts +17 -0
  61. package/dist/identity-qNkmGytv.d.mts +17 -0
  62. package/dist/ports/clock.cjs +0 -0
  63. package/dist/ports/clock.d.cts +2 -0
  64. package/dist/ports/clock.d.mts +2 -0
  65. package/dist/ports/clock.mjs +1 -0
  66. package/dist/ports/identity.cjs +0 -0
  67. package/dist/ports/identity.d.cts +2 -0
  68. package/dist/ports/identity.d.mts +2 -0
  69. package/dist/ports/identity.mjs +1 -0
  70. package/dist/ports/storage.cjs +0 -0
  71. package/dist/ports/storage.d.cts +9 -0
  72. package/dist/ports/storage.d.mts +9 -0
  73. package/dist/ports/storage.mjs +1 -0
  74. package/dist/ports/transport.cjs +0 -0
  75. package/dist/ports/transport.d.cts +29 -0
  76. package/dist/ports/transport.d.mts +29 -0
  77. package/dist/ports/transport.mjs +1 -0
  78. package/dist/protocol-B26-5VX7.d.cts +1112 -0
  79. package/dist/protocol-B26-5VX7.d.mts +1112 -0
  80. package/package.json +130 -2
@@ -0,0 +1,382 @@
1
+ import { z } from "zod";
2
+ //#region src/generated/protocol.ts
3
+ const dataHaveFrameSchema = z.lazy(() => z.object({
4
+ "type": z.literal("data-have"),
5
+ "peer": z.lazy(() => deviceIdSchema),
6
+ "head-seq": z.number().int().nonnegative()
7
+ }));
8
+ const dataRequestFrameSchema = z.lazy(() => z.object({
9
+ "type": z.literal("data-request"),
10
+ "peer": z.lazy(() => deviceIdSchema),
11
+ "from-seq": z.number().int().nonnegative()
12
+ }));
13
+ const dataEntriesFrameSchema = z.lazy(() => z.object({
14
+ "type": z.literal("data-entries"),
15
+ "peer": z.lazy(() => deviceIdSchema),
16
+ "from-seq": z.number().int().nonnegative(),
17
+ "entries": z.array(z.instanceof(Uint8Array))
18
+ }));
19
+ const handleClaimsSchema = z.lazy(() => z.object({
20
+ "handle": z.string(),
21
+ "device-id": z.lazy(() => deviceIdSchema),
22
+ "identity-key": z.lazy(() => identityKeySchema),
23
+ "candidates": z.array(z.lazy(() => wireCandidateSchema)).optional(),
24
+ "mailboxes": z.array(z.lazy(() => deviceIdSchema)).optional(),
25
+ "issued": z.number().int().nonnegative(),
26
+ "expires": z.number().int().nonnegative()
27
+ }));
28
+ const handleRecordSchema = z.lazy(() => z.lazy(() => coseSign1Schema));
29
+ const manageCommandParamsSchema = z.lazy(() => z.union([
30
+ z.union([
31
+ z.lazy(() => ptySpawnSchema),
32
+ z.lazy(() => ptyWriteSchema),
33
+ z.lazy(() => ptyResizeSchema),
34
+ z.lazy(() => ptyKillSchema),
35
+ z.lazy(() => procSpawnSchema),
36
+ z.lazy(() => procSignalSchema),
37
+ z.lazy(() => procKillSchema),
38
+ z.lazy(() => execListSchema)
39
+ ]),
40
+ z.object({}).catchall(z.unknown()),
41
+ z.union([
42
+ z.lazy(() => roomSendSchema),
43
+ z.lazy(() => roomReadSchema),
44
+ z.lazy(() => roomLeaveSchema),
45
+ z.lazy(() => roomMembersSchema)
46
+ ]),
47
+ z.union([z.lazy(() => roomJoinSchema), z.lazy(() => roomInviteSchema)]),
48
+ z.union([
49
+ z.lazy(() => webrtcOfferSchema),
50
+ z.lazy(() => webrtcAnswerSchema),
51
+ z.lazy(() => webrtcIceCandidateSchema)
52
+ ])
53
+ ]));
54
+ const ptySpawnSchema = z.lazy(() => z.object({
55
+ "verb": z.literal("pty.spawn"),
56
+ "shell": z.string().optional(),
57
+ "argv": z.array(z.string()),
58
+ "cwd": z.string().optional(),
59
+ "env": z.object({}).catchall(z.string()),
60
+ "cols": z.number().int().nonnegative(),
61
+ "rows": z.number().int().nonnegative()
62
+ }));
63
+ const ptyWriteSchema = z.lazy(() => z.object({
64
+ "verb": z.literal("pty.write"),
65
+ "session": z.lazy(() => streamSessionSchema),
66
+ "bytes": z.instanceof(Uint8Array)
67
+ }));
68
+ const ptyResizeSchema = z.lazy(() => z.object({
69
+ "verb": z.literal("pty.resize"),
70
+ "session": z.lazy(() => streamSessionSchema),
71
+ "cols": z.number().int().nonnegative(),
72
+ "rows": z.number().int().nonnegative()
73
+ }));
74
+ const ptyKillSchema = z.lazy(() => z.object({
75
+ "verb": z.literal("pty.kill"),
76
+ "session": z.lazy(() => streamSessionSchema),
77
+ "signal": z.number().int()
78
+ }));
79
+ const procSpawnSchema = z.lazy(() => z.object({
80
+ "verb": z.literal("proc.spawn"),
81
+ "argv": z.array(z.string()),
82
+ "cwd": z.string().optional(),
83
+ "env": z.object({}).catchall(z.string())
84
+ }));
85
+ const procSignalSchema = z.lazy(() => z.object({
86
+ "verb": z.literal("proc.signal"),
87
+ "session": z.lazy(() => streamSessionSchema),
88
+ "signal": z.number().int()
89
+ }));
90
+ const procKillSchema = z.lazy(() => z.object({
91
+ "verb": z.literal("proc.kill"),
92
+ "session": z.lazy(() => streamSessionSchema)
93
+ }));
94
+ const execListSchema = z.lazy(() => z.object({ "verb": z.literal("exec.list") }));
95
+ const execSessionInfoSchema = z.lazy(() => z.object({
96
+ "session": z.lazy(() => streamSessionSchema),
97
+ "kind": z.union([z.literal("pty"), z.literal("proc")]),
98
+ "argv": z.array(z.string()).optional(),
99
+ "cwd": z.string().optional()
100
+ }));
101
+ const frameVariantSchema = z.lazy(() => z.union([
102
+ z.lazy(() => handshakeFrameSchema),
103
+ z.lazy(() => pingFrameSchema),
104
+ z.lazy(() => closeFrameSchema),
105
+ z.lazy(() => gossipFrameSchema),
106
+ z.lazy(() => candidatesFrameSchema),
107
+ z.lazy(() => syncPunchFrameSchema),
108
+ z.lazy(() => observedAddressFrameSchema),
109
+ z.lazy(() => relayOfferFrameSchema),
110
+ z.lazy(() => relayConnectFrameSchema),
111
+ z.lazy(() => relayDataFrameSchema),
112
+ z.lazy(() => relayInboundFrameSchema),
113
+ z.lazy(() => coordinatorFrameSchema),
114
+ z.lazy(() => manageRequestFrameSchema),
115
+ z.lazy(() => manageResponseFrameSchema),
116
+ z.lazy(() => revocationAnnounceFrameSchema),
117
+ z.lazy(() => streamDataFrameSchema),
118
+ z.lazy(() => streamAckFrameSchema),
119
+ z.lazy(() => streamEndFrameSchema),
120
+ z.lazy(() => dataHaveFrameSchema),
121
+ z.lazy(() => dataRequestFrameSchema),
122
+ z.lazy(() => dataEntriesFrameSchema)
123
+ ]));
124
+ const frameSchema = z.lazy(() => z.lazy(() => frameVariantSchema));
125
+ const protocolVersionSchema = z.lazy(() => z.number().int().nonnegative());
126
+ const domainIdSchema = z.lazy(() => z.union([
127
+ z.lazy(() => coreDomainNameSchema),
128
+ z.lazy(() => namespacedDomainIdSchema),
129
+ z.lazy(() => privateUseDomainIdSchema)
130
+ ]));
131
+ const coreDomainNameSchema = z.lazy(() => z.union([
132
+ z.literal("core/management"),
133
+ z.literal("core/exec"),
134
+ z.literal("core/data"),
135
+ z.literal("core/federation"),
136
+ z.literal("core/webrtc"),
137
+ z.literal("core/room")
138
+ ]));
139
+ const namespacedDomainIdSchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+/[A-Za-z0-9_.-]+")));
140
+ const privateUseDomainIdSchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("x-[A-Za-z0-9_.-]+")));
141
+ const handshakeFrameSchema = z.lazy(() => z.object({
142
+ "type": z.literal("handshake"),
143
+ "version": z.lazy(() => protocolVersionSchema),
144
+ "domains": z.array(z.lazy(() => domainIdSchema)),
145
+ "params": z.object({}).catchall(z.unknown()).optional()
146
+ }));
147
+ const identityKeySchema = z.lazy(() => z.object({
148
+ "alg": z.number().int(),
149
+ "public-key": z.instanceof(Uint8Array)
150
+ }));
151
+ const deviceIdSchema = z.lazy(() => z.instanceof(Uint8Array).refine((v) => v.length === 32, { message: "expected exactly 32 bytes" }));
152
+ const peerIdentitySchema = z.lazy(() => z.object({
153
+ "device-id": z.lazy(() => deviceIdSchema),
154
+ "identity-key": z.lazy(() => identityKeySchema),
155
+ "certificate": z.instanceof(Uint8Array).optional()
156
+ }));
157
+ const manageCommandSchema = z.lazy(() => z.object({
158
+ "verb": z.lazy(() => capabilityVerbSchema),
159
+ "params": z.lazy(() => manageCommandParamsSchema)
160
+ }));
161
+ const manageRequestFrameSchema = z.lazy(() => z.object({
162
+ "type": z.literal("manage-request"),
163
+ "request-id": z.number().int().nonnegative(),
164
+ "command": z.lazy(() => manageCommandSchema),
165
+ "scope": z.lazy(() => capabilityScopeSchema),
166
+ "token": z.lazy(() => capabilityTokenSchema).optional()
167
+ }));
168
+ const manageOkSchema = z.lazy(() => z.object({ "result": z.literal("ok") }).catchall(z.unknown()));
169
+ const manageErrorSchema = z.lazy(() => z.object({
170
+ "result": z.literal("error"),
171
+ "code": z.string(),
172
+ "message": z.string().optional()
173
+ }));
174
+ const manageResponseFrameSchema = z.lazy(() => z.object({
175
+ "type": z.literal("manage-response"),
176
+ "request-id": z.number().int().nonnegative(),
177
+ "outcome": z.union([z.lazy(() => manageOkSchema), z.lazy(() => manageErrorSchema)])
178
+ }));
179
+ const revocationClaimsSchema = z.lazy(() => z.object({
180
+ "token-id": z.instanceof(Uint8Array),
181
+ "issuer": z.lazy(() => deviceIdSchema),
182
+ "issuer-key": z.lazy(() => identityKeySchema),
183
+ "revoked-at": z.number().int().nonnegative()
184
+ }));
185
+ const revocationEntrySchema = z.lazy(() => z.lazy(() => coseSign1Schema));
186
+ const revocationAnnounceFrameSchema = z.lazy(() => z.object({
187
+ "type": z.literal("revocation-announce"),
188
+ "entries": z.array(z.lazy(() => revocationEntrySchema))
189
+ }));
190
+ const roomPathSchema = z.lazy(() => z.union([z.lazy(() => ownerNamedRoomPathSchema), z.lazy(() => dmRoomPathSchema)]));
191
+ const deviceIdHexSchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("[0-9a-f]{64}")));
192
+ const ownerNamedRoomPathSchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("[0-9a-f]{64}/[A-Za-z0-9_-]+")));
193
+ const dmRoomPathSchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("[0-9a-f]{64}\\+[0-9a-f]{64}")));
194
+ const roomSendSchema = z.lazy(() => z.object({
195
+ "verb": z.literal("room.send"),
196
+ "message-id": z.instanceof(Uint8Array),
197
+ "sent-at": z.number().int().nonnegative(),
198
+ "text": z.string(),
199
+ "content-type": z.string().optional(),
200
+ "refs": z.array(z.lazy(() => messageRefSchema)).optional()
201
+ }).catchall(z.unknown()));
202
+ const roomReadSchema = z.lazy(() => z.object({
203
+ "verb": z.literal("room.read"),
204
+ "messages": z.array(z.instanceof(Uint8Array)),
205
+ "at": z.number().int().nonnegative()
206
+ }).catchall(z.unknown()));
207
+ const roomLeaveSchema = z.lazy(() => z.object({ "verb": z.literal("room.leave") }).catchall(z.unknown()));
208
+ const roomMembersSchema = z.lazy(() => z.object({ "verb": z.literal("room.members") }).catchall(z.unknown()));
209
+ const messageRefSchema = z.lazy(() => z.object({
210
+ "id": z.instanceof(Uint8Array),
211
+ "relation": z.string()
212
+ }));
213
+ const roomJoinSchema = z.lazy(() => z.object({ "verb": z.literal("room.join") }).catchall(z.unknown()));
214
+ const roomInviteSchema = z.lazy(() => z.object({
215
+ "verb": z.literal("room.invite"),
216
+ "invitee": z.lazy(() => deviceIdSchema),
217
+ "token": z.lazy(() => capabilityTokenSchema)
218
+ }).catchall(z.unknown()));
219
+ const roomMemberSchema = z.lazy(() => z.object({ "device": z.lazy(() => deviceIdSchema) }).catchall(z.unknown()));
220
+ const roomJoinOkSchema = z.lazy(() => z.object({
221
+ "result": z.literal("ok"),
222
+ "granted-token": z.lazy(() => capabilityTokenSchema),
223
+ "members": z.array(z.lazy(() => roomMemberSchema))
224
+ }).catchall(z.unknown()));
225
+ const roomMembersOkSchema = z.lazy(() => z.object({
226
+ "result": z.literal("ok"),
227
+ "members": z.array(z.lazy(() => roomMemberSchema))
228
+ }).catchall(z.unknown()));
229
+ const roomNoticeSchema = z.lazy(() => z.lazy(() => coseSign1Schema));
230
+ const roomNoticeClaimsSchema = z.lazy(() => z.object({
231
+ "room": z.lazy(() => roomPathSchema),
232
+ "poster": z.lazy(() => deviceIdSchema),
233
+ "poster-key": z.lazy(() => identityKeySchema),
234
+ "token": z.lazy(() => capabilityTokenSchema),
235
+ "notice-id": z.instanceof(Uint8Array),
236
+ "posted-at": z.number().int().nonnegative(),
237
+ "content-type": z.string(),
238
+ "content": z.instanceof(Uint8Array),
239
+ "refs": z.array(z.lazy(() => messageRefSchema)).optional()
240
+ }).catchall(z.unknown()));
241
+ const streamSessionSchema = z.lazy(() => z.number().int().nonnegative());
242
+ const streamDataFrameSchema = z.lazy(() => z.object({
243
+ "type": z.literal("stream-data"),
244
+ "session": z.lazy(() => streamSessionSchema),
245
+ "seq": z.number().int().nonnegative(),
246
+ "channel": z.string(),
247
+ "bytes": z.instanceof(Uint8Array)
248
+ }));
249
+ const streamAckFrameSchema = z.lazy(() => z.object({
250
+ "type": z.literal("stream-ack"),
251
+ "session": z.lazy(() => streamSessionSchema),
252
+ "ack-seq": z.number().int().nonnegative(),
253
+ "window": z.number().int().nonnegative()
254
+ }));
255
+ const streamEndFrameSchema = z.lazy(() => z.object({
256
+ "type": z.literal("stream-end"),
257
+ "session": z.lazy(() => streamSessionSchema),
258
+ "exit-code": z.number().int().optional(),
259
+ "exit-signal": z.number().int().optional()
260
+ }));
261
+ const capabilityVerbSchema = z.lazy(() => z.union([
262
+ z.lazy(() => coreCapabilitySchema),
263
+ z.lazy(() => namespacedCapabilitySchema),
264
+ z.lazy(() => privateUseCapabilitySchema)
265
+ ]));
266
+ const coreCapabilitySchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("[a-z][a-z0-9-]*:[a-z][a-z0-9-]*")));
267
+ const namespacedCapabilitySchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("[a-z0-9.-]+/[A-Za-z0-9_.-]+:[A-Za-z0-9_.-]+")));
268
+ const privateUseCapabilitySchema = z.lazy(() => z.string().regex(/* @__PURE__ */ new RegExp("x-[A-Za-z0-9_.-]+:[A-Za-z0-9_.-]+")));
269
+ const capabilityScopeSchema = z.lazy(() => z.object({
270
+ "kind": z.string(),
271
+ "path": z.string().optional()
272
+ }));
273
+ const coseHeaderAlgSchema = z.lazy(() => z.literal(1));
274
+ const coseHeaderKidSchema = z.lazy(() => z.literal(4));
275
+ const coseHeaderLabelSchema = z.lazy(() => z.union([z.number().int(), z.string()]));
276
+ const coseTokenHeadersSchema = z.lazy(() => z.object({
277
+ "1": z.number().int().optional(),
278
+ "4": z.instanceof(Uint8Array).optional()
279
+ }).catchall(z.unknown()));
280
+ const coseSign1Schema = z.lazy(() => z.tuple([
281
+ z.instanceof(Uint8Array),
282
+ z.lazy(() => coseTokenHeadersSchema),
283
+ z.union([z.instanceof(Uint8Array), z.null()]),
284
+ z.instanceof(Uint8Array)
285
+ ]));
286
+ const capabilityTokenSchema = z.lazy(() => z.lazy(() => coseSign1Schema));
287
+ const tokenClaimsSchema = z.lazy(() => z.object({
288
+ "token-id": z.instanceof(Uint8Array),
289
+ "issuer": z.lazy(() => deviceIdSchema),
290
+ "issuer-key": z.lazy(() => identityKeySchema),
291
+ "bearer": z.lazy(() => deviceIdSchema),
292
+ "capability": z.lazy(() => capabilityVerbSchema),
293
+ "scope": z.lazy(() => capabilityScopeSchema),
294
+ "expires": z.number().int().nonnegative(),
295
+ "not-before": z.number().int().nonnegative().optional(),
296
+ "parent": z.instanceof(Uint8Array).optional(),
297
+ "delegations-remaining": z.number().int().nonnegative().optional()
298
+ }).catchall(z.unknown()));
299
+ const pingFrameSchema = z.lazy(() => z.object({ "type": z.literal("ping") }));
300
+ const closeFrameSchema = z.lazy(() => z.object({
301
+ "type": z.literal("close"),
302
+ "reason": z.string().optional()
303
+ }));
304
+ const peerAdvertSchema = z.lazy(() => z.object({
305
+ "device": z.lazy(() => deviceIdSchema),
306
+ "addresses": z.array(z.string()),
307
+ "snapshot-seconds": z.number().int()
308
+ }));
309
+ const gossipFrameSchema = z.lazy(() => z.object({
310
+ "type": z.literal("gossip"),
311
+ "peers": z.array(z.lazy(() => peerAdvertSchema))
312
+ }));
313
+ const candidateKindSchema = z.lazy(() => z.union([
314
+ z.literal("host"),
315
+ z.literal("server-reflexive"),
316
+ z.literal("relayed")
317
+ ]));
318
+ const wireCandidateSchema = z.lazy(() => z.object({
319
+ "address": z.string(),
320
+ "kind": z.lazy(() => candidateKindSchema),
321
+ "priority": z.number().int().nonnegative()
322
+ }));
323
+ const candidatesFrameSchema = z.lazy(() => z.object({
324
+ "type": z.literal("candidates"),
325
+ "candidates": z.array(z.lazy(() => wireCandidateSchema))
326
+ }));
327
+ const syncPunchFrameSchema = z.lazy(() => z.object({
328
+ "type": z.literal("sync-punch"),
329
+ "nonce": z.number().int().nonnegative(),
330
+ "deadline-unix-ms": z.number().int().nonnegative()
331
+ }));
332
+ const observedAddressFrameSchema = z.lazy(() => z.object({
333
+ "type": z.literal("observed-address"),
334
+ "address": z.string()
335
+ }));
336
+ const relayOfferFrameSchema = z.lazy(() => z.object({
337
+ "type": z.literal("relay-offer"),
338
+ "addresses": z.array(z.string())
339
+ }));
340
+ const relayConnectFrameSchema = z.lazy(() => z.object({
341
+ "type": z.literal("relay-connect"),
342
+ "target-device": z.lazy(() => deviceIdSchema)
343
+ }));
344
+ const relayDataFrameSchema = z.lazy(() => z.object({
345
+ "type": z.literal("relay-data"),
346
+ "payload": z.instanceof(Uint8Array),
347
+ "to-device": z.lazy(() => deviceIdSchema).optional(),
348
+ "from-device": z.lazy(() => deviceIdSchema).optional()
349
+ }));
350
+ const relayInboundFrameSchema = z.lazy(() => z.object({
351
+ "type": z.literal("relay-inbound"),
352
+ "source-device": z.lazy(() => deviceIdSchema)
353
+ }));
354
+ const coordinatorFrameSchema = z.lazy(() => z.object({
355
+ "type": z.literal("coordinator"),
356
+ "term": z.number().int().nonnegative(),
357
+ "coordinator": z.lazy(() => deviceIdSchema),
358
+ "capacity-hint": z.number().int().nonnegative().optional()
359
+ }));
360
+ const webrtcOfferSchema = z.lazy(() => z.object({
361
+ "verb": z.literal("webrtc.offer"),
362
+ "negotiation-id": z.number().int().nonnegative(),
363
+ "sdp": z.string()
364
+ }));
365
+ const webrtcAnswerSchema = z.lazy(() => z.object({
366
+ "verb": z.literal("webrtc.answer"),
367
+ "negotiation-id": z.number().int().nonnegative(),
368
+ "sdp": z.string()
369
+ }));
370
+ const webrtcIceCandidateSchema = z.lazy(() => z.object({
371
+ "verb": z.literal("webrtc.ice-candidate"),
372
+ "negotiation-id": z.number().int().nonnegative(),
373
+ "candidate": z.lazy(() => iceCandidateInitSchema).optional()
374
+ }));
375
+ const iceCandidateInitSchema = z.lazy(() => z.object({
376
+ "candidate": z.string(),
377
+ "sdp-mid": z.string().optional(),
378
+ "sdp-m-line-index": z.number().int().nonnegative().optional(),
379
+ "username-fragment": z.string().optional()
380
+ }));
381
+ //#endregion
382
+ export { candidateKindSchema, candidatesFrameSchema, capabilityScopeSchema, capabilityTokenSchema, capabilityVerbSchema, closeFrameSchema, coordinatorFrameSchema, coreCapabilitySchema, coreDomainNameSchema, coseHeaderAlgSchema, coseHeaderKidSchema, coseHeaderLabelSchema, coseSign1Schema, coseTokenHeadersSchema, dataEntriesFrameSchema, dataHaveFrameSchema, dataRequestFrameSchema, deviceIdHexSchema, deviceIdSchema, dmRoomPathSchema, domainIdSchema, execListSchema, execSessionInfoSchema, frameSchema, frameVariantSchema, gossipFrameSchema, handleClaimsSchema, handleRecordSchema, handshakeFrameSchema, iceCandidateInitSchema, identityKeySchema, manageCommandParamsSchema, manageCommandSchema, manageErrorSchema, manageOkSchema, manageRequestFrameSchema, manageResponseFrameSchema, messageRefSchema, namespacedCapabilitySchema, namespacedDomainIdSchema, observedAddressFrameSchema, ownerNamedRoomPathSchema, peerAdvertSchema, peerIdentitySchema, pingFrameSchema, privateUseCapabilitySchema, privateUseDomainIdSchema, procKillSchema, procSignalSchema, procSpawnSchema, protocolVersionSchema, ptyKillSchema, ptyResizeSchema, ptySpawnSchema, ptyWriteSchema, relayConnectFrameSchema, relayDataFrameSchema, relayInboundFrameSchema, relayOfferFrameSchema, revocationAnnounceFrameSchema, revocationClaimsSchema, revocationEntrySchema, roomInviteSchema, roomJoinOkSchema, roomJoinSchema, roomLeaveSchema, roomMemberSchema, roomMembersOkSchema, roomMembersSchema, roomNoticeClaimsSchema, roomNoticeSchema, roomPathSchema, roomReadSchema, roomSendSchema, streamAckFrameSchema, streamDataFrameSchema, streamEndFrameSchema, streamSessionSchema, syncPunchFrameSchema, tokenClaimsSchema, webrtcAnswerSchema, webrtcIceCandidateSchema, webrtcOfferSchema, wireCandidateSchema };
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let cddl_js_runtime = require("cddl.js/runtime");
3
+ Object.defineProperty(exports, "cborDecodesAs", {
4
+ enumerable: true,
5
+ get: function() {
6
+ return cddl_js_runtime.cborDecodesAs;
7
+ }
8
+ });
@@ -0,0 +1,2 @@
1
+ import { cborDecodesAs } from "cddl.js/runtime";
2
+ export { cborDecodesAs };
@@ -0,0 +1,2 @@
1
+ import { cborDecodesAs } from "cddl.js/runtime";
2
+ export { cborDecodesAs };
@@ -0,0 +1,2 @@
1
+ import { cborDecodesAs } from "cddl.js/runtime";
2
+ export { cborDecodesAs };
@@ -0,0 +1,17 @@
1
+ import { j as IdentityKey, v as DeviceId } from "./protocol-B26-5VX7.cjs";
2
+ //#region src/ports/identity.d.ts
3
+ /**
4
+ * Wraps the local node's own identity plus the signing/verification primitives capability-token handling needs -- never hardcoded to one crypto library's own API shape (Node's webcrypto, a WASM implementation, a hardware key, etc. can all satisfy this same contract).
5
+ */
6
+ interface IdentityPort {
7
+ readonly deviceId: DeviceId;
8
+ readonly identityKey: IdentityKey;
9
+ /** Signs an already-assembled message (e.g. a COSE Sig_structure) with the local node's own private key. Always a fresh buffer, never a view into shared or offset memory -- directly usable as a CapabilityToken tuple element without further normalisation. */
10
+ sign: (message: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
11
+ /** Verifies a signature against an arbitrary identity-key -- not necessarily the local node's own, since capability-token verification checks a token's issuer-key. */
12
+ verify: (key: IdentityKey, message: Uint8Array, signature: Uint8Array) => Promise<boolean>;
13
+ /** Derives the device-id an arbitrary public key would produce (SHA-256 of the raw public-key bytes -- never a certificate's own DER encoding, the bug both Cascade and agent-comms had to fix). Used to check a token's self-certifying issuer-key against its claimed issuer, not just the local node's own identity. */
14
+ deriveDeviceId: (publicKey: Uint8Array) => Promise<DeviceId>;
15
+ }
16
+ //#endregion
17
+ export { IdentityPort as t };
@@ -0,0 +1,17 @@
1
+ import { j as IdentityKey, v as DeviceId } from "./protocol-B26-5VX7.mjs";
2
+ //#region src/ports/identity.d.ts
3
+ /**
4
+ * Wraps the local node's own identity plus the signing/verification primitives capability-token handling needs -- never hardcoded to one crypto library's own API shape (Node's webcrypto, a WASM implementation, a hardware key, etc. can all satisfy this same contract).
5
+ */
6
+ interface IdentityPort {
7
+ readonly deviceId: DeviceId;
8
+ readonly identityKey: IdentityKey;
9
+ /** Signs an already-assembled message (e.g. a COSE Sig_structure) with the local node's own private key. Always a fresh buffer, never a view into shared or offset memory -- directly usable as a CapabilityToken tuple element without further normalisation. */
10
+ sign: (message: Uint8Array) => Promise<Uint8Array<ArrayBuffer>>;
11
+ /** Verifies a signature against an arbitrary identity-key -- not necessarily the local node's own, since capability-token verification checks a token's issuer-key. */
12
+ verify: (key: IdentityKey, message: Uint8Array, signature: Uint8Array) => Promise<boolean>;
13
+ /** Derives the device-id an arbitrary public key would produce (SHA-256 of the raw public-key bytes -- never a certificate's own DER encoding, the bug both Cascade and agent-comms had to fix). Used to check a token's self-certifying issuer-key against its claimed issuer, not just the local node's own identity. */
14
+ deriveDeviceId: (publicKey: Uint8Array) => Promise<DeviceId>;
15
+ }
16
+ //#endregion
17
+ export { IdentityPort as t };
File without changes
@@ -0,0 +1,2 @@
1
+ import { t as Clock } from "../clock-DiSx-WKM.cjs";
2
+ export { Clock };
@@ -0,0 +1,2 @@
1
+ import { t as Clock } from "../clock-DiSx-WKM.mjs";
2
+ export { Clock };
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,2 @@
1
+ import { t as IdentityPort } from "../identity-BRLEUfVY.cjs";
2
+ export { IdentityPort };
@@ -0,0 +1,2 @@
1
+ import { t as IdentityPort } from "../identity-qNkmGytv.mjs";
2
+ export { IdentityPort };
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,9 @@
1
+ //#region src/ports/storage.d.ts
2
+ export interface KeyValueStorage {
3
+ get: (key: string) => Promise<Uint8Array | undefined>;
4
+ set: (key: string, value: Uint8Array) => Promise<void>;
5
+ delete: (key: string) => Promise<void>;
6
+ /** Keys with the given prefix, in no particular order. */
7
+ keys: (prefix: string) => Promise<string[]>;
8
+ }
9
+ //#endregion
@@ -0,0 +1,9 @@
1
+ //#region src/ports/storage.d.ts
2
+ export interface KeyValueStorage {
3
+ get: (key: string) => Promise<Uint8Array | undefined>;
4
+ set: (key: string, value: Uint8Array) => Promise<void>;
5
+ delete: (key: string) => Promise<void>;
6
+ /** Keys with the given prefix, in no particular order. */
7
+ keys: (prefix: string) => Promise<string[]>;
8
+ }
9
+ //#endregion
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,29 @@
1
+ import { v as DeviceId, w as Frame } from "../protocol-B26-5VX7.cjs";
2
+ //#region src/ports/transport.d.ts
3
+ /**
4
+ * An async, serialisable-data contract for exchanging frame values over some connection -- deliberately without baking in any specific transport's own primitives (no raw socket types, no WebSocket-specific options), so a TCP adapter, a WebSocket adapter, or an in-memory adapter for tests can all satisfy it.
5
+ */
6
+ export interface Connection {
7
+ send: (frame: Frame) => Promise<void>;
8
+ /** Frames received on this connection, in arrival order, until the connection closes. */
9
+ receive: () => AsyncIterable<Frame>;
10
+ close: () => Promise<void>;
11
+ /** The peer's device-id, cryptographically authenticated by the adapter itself (never a value read off the wire) -- absent when the adapter has nothing to authenticate against (createTcpTransport) or the peer presented no credential to check (an accepting createTlsTransport connection whose peer sent no certificate). A caller that later receives an application-level claim of who the peer is (e.g. an `introduce`-style message) MUST treat a mismatch against this field as a spoofing attempt and refuse the claim, exactly the same "reject and destroy" obligation self-certifying claims elsewhere in this spec already carry. */
12
+ readonly peerDeviceId?: DeviceId;
13
+ /** Lets the event loop exit while this connection is still open and functioning -- a caller that wants I/O to keep working without keeping the process alive (matching Node's own `net.Socket.unref()`) calls this once. Adapters with no underlying handle to unref (an in-memory test double, a browser WebSocket) simply omit it. */
14
+ unref?: () => void;
15
+ }
16
+ export interface Listener {
17
+ /** Stops listening and closes the listener. */
18
+ close: () => Promise<void>;
19
+ /** The address actually bound, as "host:port". A caller may pass port 0 to take an OS-assigned port and needs it handed back to connect to (or advertise) -- tests rely on this to avoid fixed-port collisions. */
20
+ address: string;
21
+ /** Lets the event loop exit while this listener is still bound and accepting connections. See Connection.unref for the same rationale; adapters with nothing to unref omit it. */
22
+ unref?: () => void;
23
+ }
24
+ export interface Transport {
25
+ connect: (address: string) => Promise<Connection>;
26
+ /** Starts listening; each accepted connection is handed to onConnection. Resolves once bound, with the address actually listening on. */
27
+ listen: (address: string, onConnection: (connection: Readonly<Connection>) => void) => Promise<Listener>;
28
+ }
29
+ //#endregion
@@ -0,0 +1,29 @@
1
+ import { v as DeviceId, w as Frame } from "../protocol-B26-5VX7.mjs";
2
+ //#region src/ports/transport.d.ts
3
+ /**
4
+ * An async, serialisable-data contract for exchanging frame values over some connection -- deliberately without baking in any specific transport's own primitives (no raw socket types, no WebSocket-specific options), so a TCP adapter, a WebSocket adapter, or an in-memory adapter for tests can all satisfy it.
5
+ */
6
+ export interface Connection {
7
+ send: (frame: Frame) => Promise<void>;
8
+ /** Frames received on this connection, in arrival order, until the connection closes. */
9
+ receive: () => AsyncIterable<Frame>;
10
+ close: () => Promise<void>;
11
+ /** The peer's device-id, cryptographically authenticated by the adapter itself (never a value read off the wire) -- absent when the adapter has nothing to authenticate against (createTcpTransport) or the peer presented no credential to check (an accepting createTlsTransport connection whose peer sent no certificate). A caller that later receives an application-level claim of who the peer is (e.g. an `introduce`-style message) MUST treat a mismatch against this field as a spoofing attempt and refuse the claim, exactly the same "reject and destroy" obligation self-certifying claims elsewhere in this spec already carry. */
12
+ readonly peerDeviceId?: DeviceId;
13
+ /** Lets the event loop exit while this connection is still open and functioning -- a caller that wants I/O to keep working without keeping the process alive (matching Node's own `net.Socket.unref()`) calls this once. Adapters with no underlying handle to unref (an in-memory test double, a browser WebSocket) simply omit it. */
14
+ unref?: () => void;
15
+ }
16
+ export interface Listener {
17
+ /** Stops listening and closes the listener. */
18
+ close: () => Promise<void>;
19
+ /** The address actually bound, as "host:port". A caller may pass port 0 to take an OS-assigned port and needs it handed back to connect to (or advertise) -- tests rely on this to avoid fixed-port collisions. */
20
+ address: string;
21
+ /** Lets the event loop exit while this listener is still bound and accepting connections. See Connection.unref for the same rationale; adapters with nothing to unref omit it. */
22
+ unref?: () => void;
23
+ }
24
+ export interface Transport {
25
+ connect: (address: string) => Promise<Connection>;
26
+ /** Starts listening; each accepted connection is handed to onConnection. Resolves once bound, with the address actually listening on. */
27
+ listen: (address: string, onConnection: (connection: Readonly<Connection>) => void) => Promise<Listener>;
28
+ }
29
+ //#endregion
@@ -0,0 +1 @@
1
+ export {};